var currentActiveItem = null;
var nodes = null;
var nav = null;

function startList() {
	if (nav){
		if (nodes){
			for (var i=0; i<nodes.length; i++) {
				if (nodes[i].className.indexOf("current") != -1)
				{
						currentActiveItem = nodes[i];
				}
				
				nodes[i].onmouseover = function() {	
					for (var i=0; i<nodes.length; i++)
					{
						nodes[i].className = nodes[i].className.replace("current", "");
					}
					this.className += " current";
					
				}
				nodes[i].onmouseout = function() {
					this.className = this.className.replace("current", "");
				}
			}
		}
	}
	nav.onmouseout = function()	{
		for (var i=0; i<nodes.length; i++)
		{
			nodes[i].className = nodes[i].className.replace("current", "");
		}
		if (currentActiveItem)
		{
			currentActiveItem.className += " current";
		}
	}
}

function initMenu() {
	
	nav = document.getElementById("main-nav");
	if (nav)
	{
		nodes = document.getElementById("main-nav").getElementsByTagName("li");
		startList();
	}
}

if (window.addEventListener) {
	window.addEventListener("load", initMenu, false);
}
else if (window.attachEvent) {
	window.attachEvent("onload", initMenu);
}
