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