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("active") != -1)
					{
						currentActiveItem = nodes[i];
					}
				nodes[i].onmouseover = function() {
					
					for (var i=0; i<nodes.length; i++)
					{
							nodes[i].className = "";
					}
					this.className += " active";
					
				}
				nodes[i].onmouseout = function() {
					this.className = this.className.replace("hover", "");
				}
			}
		}
	}
	nav.onmouseout = function()	{
		
		for (var i=0; i<nodes.length; i++)
		{
			nodes[i].className = nodes[i].className.replace("active", "");
		}
		if (currentActiveItem)
		{
			currentActiveItem.className += 'active';
		}
		
	}
}


function initMenu () {
	nav = document.getElementById("navigation-main");
	if (nav)
	{
		nodes = nav.getElementsByTagName("li");
		startList();
	}
}

if (window.addEventListener) {
	window.addEventListener("load", initMenu, false);
}
else if (window.attachEvent) {
	window.attachEvent("onload", initMenu);
}