// JavaScript Document
//var thisObj = null;
var mouseOverIn = false; 
var lastMouseOverLi = null;
var timer = null;
var timer2 = null;
startList = function() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("nav");
		var ieULs =navRoot.getElementsByTagName('ul');
		for (j=0; j<ieULs.length; j++) {
			ieULs[j].style.display="block";
			ieULs[j].innerHTML = ('<iframe src="about:blank" scrolling="no" frameborder="0"></iframe>' + ieULs[j].innerHTML);
			var ieMat = ieULs[j].firstChild;
			ieMat.style.width=ieULs[j].offsetWidth+"px";
			ieMat.style.height=ieULs[j].offsetHeight+"px";
			ieULs[j].style.zIndex="99";
			ieULs[j].style.display="";
		}
		
		
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
					if (node.nodeName=="LI") {
							  node.onmouseover=function(){
								  mouseOverIn = true;
								  if(lastMouseOverLi != null){
									  lastMouseOverLi.className=lastMouseOverLi.className.replace(" over", ""); 
										if(timer2 != null){
											clearTimeout(timer2);
										}

								  }
								  lastMouseOverLi = this;
							  this.className+=" over";
							  }
							  node.onmouseout=function() {
								  mouseOverIn = false;
								  this.className=this.className.replace(" over", "");
		  
							  }
					}
		}
	}else if (document.getElementById){
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
					if (node.nodeName=="LI") {
							  node.onmouseover=function(){
								  mouseOverIn = true;
								  if(lastMouseOverLi != null){
									  lastMouseOverLi.className=""; 
									  var lastMouseOverUl = lastMouseOverLi.getElementsByTagName('ul')[0];
										if(timer2 != null){
											clearTimeout(timer2);
										}

								  }
								  lastMouseOverLi = this;
							  };
							  node.onmouseout=function() {
								  mouseOverIn = false;
		  
							  };
					}
		}
		
	}
}

function applyStay() {
	if(timer != null){
		clearTimeout(timer);
	}
	timer = window.setTimeout(function(){
		if(!mouseOverIn && lastMouseOverLi != null){
			if(document.all && document.getElementById){
				lastMouseOverLi.className+=" over";
				if(timer2 != null){
					clearTimeout(timer2);
				}
				timer2 = window.setTimeout(function(){lastMouseOverLi.className=lastMouseOverLi.className.replace(" over", "");},1000);
			}else if (document.getElementById){
				lastMouseOverLi.className+=" over";
				if(timer2 != null){
					clearTimeout(timer2);
				}
				timer2 = window.setTimeout(function(){lastMouseOverLi.className="";},1000);
				
			}
		}
	},10);
}



/*function changeImage(element){
	var imgUrl=element.src;
	var docPos = imgUrl.lastIndexOf(".");
	imgUrl=imgUrl.substring(0,docPos)+"_over.jpg";
	element.src=imgUrl;
	
}

function restoreImage(element){
	var imgUrl=element.src;
	var docPos = imgUrl.lastIndexOf("_over");
	imgUrl=imgUrl.substring(0,docPos)+".jpg";
	element.src=imgUrl;
}*/



window.onload=startList;



