var menu={
	init:function(){
		$$('a.hasSubmenu').each(function(a){
			a.parentNode.timerSet=0;
			$(a.parentNode).observe('mouseover' , function(event){
				var fromElement=event.relatedTarget || event.fromElement || false;		
				if(fromElement && !$(fromElement).descendantOf(this) && fromElement != this){
					this.timerSet++;
					this.className='sfhover';
				}
			}.bindAsEventListener(a.parentNode));
			
			$(a.parentNode).observe('mouseout' , function(event){
				var fromElement=event.relatedTarget || event.fromElement || false;
				if(fromElement && !$(fromElement).descendantOf(this) && $(fromElement) != this){
					this.timerSet++;
					this.timerInit=this.timerSet;
					setTimeout(function(){
						if(this.timerSet==this.timerInit) this.className='';
					}.bind(this), 200);
				}
			}.bindAsEventListener(a.parentNode));
		 });
		if (window.attachEvent && ! window.opera) window.attachEvent("onload", menu.ieOver);
	},
	ieOver: function() {
		$("nav_main").select("li").each(function(li){
			var hasSubmenu=$A(li.childNodes).any(function(cn){ return cn.className=='hasSubmenu';});
			$A(li.childNodes).each(function(cn){
				if(cn.className=='hasSubmenu'){
						li.hasSubmenu=true;
						throw $break;
					}
			});
			if(!li.hasSubmenu){
				$(li).observe('mouseover', function() {
					this.className="sfhover";
				}.bindAsEventListener(li));
				
				$(li).observe('mouseout', function(event) {
					var fromElement=event.relatedTarget || event.fromElement || false;
					if(fromElement && !$(fromElement).descendantOf(this) && $(fromElement) != this){
						this.className='';
					}
				}.bindAsEventListener(li));
			}
		});
	}
}

