var currentMenus = new Array();
var currentIFrames = new Array();
var menuText = "";


var changedLocation = false;
function menuOpenLocation(locationpath, newWindow, li){
	if(newWindow){
		window.open(locationpath);	
	}else if(!changedLocation){
		location.href = locationpath;
		changedLocation = true;
	}
	if(li.parentNode.parentNode.tagName.toLowerCase() == "div"){
		changedLocation = false;	
	}
	
}

function showSub(li){
	lastli = null;
	if(li.getAttribute("statusText") && menuText == ""){
		window.status = li.getAttribute("statusText");
		menuText = li.getAttribute("statusText");
	}
	li.className = "hoveredItem";
	if(li.lastChild.className && li.lastChild.className == "subMenuH"){
		var nextUl = li.lastChild;
		var iframe = li.getElementsByTagName('iframe')[0];
		nextUl.className = "subMenuV"
		numberOfLis = nextUl.childNodes.length;
		if(iframe){
			iframe.style.height= (numberOfLis * 29) + 2 + "px";
			iframe.style.display="block";
			iframe.style.visibility = "visible";	
		}
		li.getElementsByTagName("span")[0].className = "menu_downArrow";
	}
 
	lvl = li.getAttribute("lvl");
	if(currentMenus[lvl] && currentMenus[lvl] != li){
		currentMenus[lvl].className = "notHovered";
		if(currentMenus[lvl].lastChild.className && currentMenus[lvl].lastChild.className == "subMenuV"){
			currentMenus[lvl].lastChild.className = "subMenuH";
			currentMenus[lvl].getElementsByTagName("span")[0].className = "menu_rightArrow";
			var iframe = currentMenus[lvl].getElementsByTagName('iframe')[0];
			if(iframe){
				iframe.style.display="none";
				iframe.style.visibility = "hidden";	
				
			}
		}
	}
	currentMenus[lvl] = li;
}
var lastli;
function hideSub(li){
	if(!lastli){
		lastli = li;
		if(window.status == li.getAttribute("statusText")){
			window.status = "";
			menuText = "";
		}
		setTimeout("closeIt()", 750);
	}
}
function closeIt(){
	if(lastli){
		li = lastli;
		while(li.className == "hoveredItem"){
			li.className = "notHovered";
			if(li.lastChild.className && li.lastChild.className == "subMenuV"){
				li.lastChild.className = "subMenuH"
				li.getElementsByTagName("span")[0].className = "menu_rightArrow";
				var iframe = li.getElementsByTagName('iframe')[0];
				if(iframe){
					iframe.style.display="none";
					iframe.style.visibility = "hidden";				
				}
			}
			li = li.parentNode.parentNode;
		}
		lastli = null;
	}
}
