// Turn on left menus
function turnOnMenus() {
	if (document.getElementById("leftMenuContainerOFF"))
	{
		document.getElementById("leftMenuContainerOFF").id = "leftMenuContainer";
	}
    startList('leftMenuUL');
	document.getElementById("leftMenuContainer").style.zIndex = '50';
}

// Turn off left menus
function turnOffMenus(){
	document.getElementById("leftMenuContainer").id = "leftMenuContainerOFF";
	stopList('leftMenuUL');
}

// Turn off all open submenus
function turnOffAll(name, id) {
	navRoot = document.getElementById(name);
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if(node.id != id && node.on)
		{
			node.className = "";
			node.on = 0;
		}	
	}
}

// Tracks if theres any open submenus
trackOn = new Object();

// Set up leftmenu to open submenus on mouseon & mouseover
function startList(name) {
	if (document.getElementById) {
		navRoot = document.getElementById(name);
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					// Check if theres still any open windows & close em (required for mozilla)
					if(trackOn.on) turnOffAll(name,this.id);
					this.on = 1;
					trackOn.on = 1 
					// Turn on the submenu
					//alert("on");
					this.className = "over";
					//alert("over");
				}
				node.onmouseout=function() {
					this.className = "";
					this.on = 0;
					// Turn off the submenu
					trackOn.on = 0;
				}
			}
		}
	}
}

// Disable Left Menu
function stopList(name) {
	if (document.getElementById) {
		navRoot = document.getElementById(name);
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					return false;
				}
				node.onmouseout=function() {
					return false;
				}
			}
		}
	}
}
