/*global Win, document, window */
// ideas fished from http://www.htmldog.com/articles/suckerfish/dropdowns/, well, sortof.
var SF = function(){
var _inited=false,_isIE=document.all?true:false;var _types=['INPUT','TEXTAREA','SELECT'],_fish=[],_bait=[];var _to={},_tn={};var _bp='backgroundPosition',_fc='firstChild';
function _sucker(frms){var i=0,j=0,k=0;var l=frms.length,m=_types.length,n=0;var f={},t=[],o={},p={};for(i=0;i<l;i++){for(j=0;j<m;j++){t=frms[i].getElementsByTagName(_types[j]);for(k=0,n=t.length;k<n;k++){o=t[k];if(o.type==='text'||o.type==='select-one'||o.type==='textarea'){o.onfocus=SF.F;o.onblur=SF.B;}else if(o.type==='submit'||o.type==='button'||o.type==='reset'){p=(_isIE)?o.parentElement:o.parentNode;if(p.tagName==='DIV'){p.onmouseover=SF.H;p.onmouseout=SF.N;p.onmousedown=SF.D;p.onmouseup=SF.U;}}}}}}
function _tackle(navs){
	var i=0,l=navs.length;
	for(i=0;i<l;i++){
		var nav=document.getElementById(navs[i]);
		if(nav!==null){
			var nodes=nav.childNodes;
			var j=0,m=nodes.length;
			for(j=0;j<m;j++){
				var no=nodes[j];
				if(no.nodeName==='LI'){
					no.onmouseover=SF.S;
					no.onmouseout=SF.M;
				}
			}
		}
	}
}
return{
init:function(){_inited=true;if(_fish.length>0)_sucker(_fish);if(_bait.length>0)_tackle(_bait);},
F:function(){this.className+=' sffocus';},
B:function(){this.className=this.className.replace(new RegExp('\s*sffocus\\b'),'');},
H:function(){this.style[_bp]='right -23px';this[_fc].style[_bp]='left -23px';},
U:function(){this.style.color='#fff';this[_fc].style.color='#fff';},
N:function(){this.style[_bp]='right 0px';this[_fc].style[_bp]='left 0px';this.style.color='#fff';this[_fc].style.color='#fff';},
D:function(){this.style.color='#777';this[_fc].style.color='#777';},
S:function(){clearTimeout(_to);if(_tn!=this){SF.P();}this.className='sfhover';},
M:function(){_tn=this;_to=setTimeout(SF.P,200);},
P:function(){_tn.className='top';_tn={};},
fish:function(frms){_fish=frms;if(_inited&&_fish.length){_sucker(_fish);}},
bait:function(navs){_bait=navs.split(',');if(_inited&&_bait.length){_tackle(_bait);}}};
}();
Win.load(window,SF.init);
SF.fish(document.getElementsByTagName('FORM'));
SF.bait('nav');
