var currentActiveItem = null;
var nodes = null;
var nav = null;

startList = function() {
	initMenu();
	fixLayout();
	
	if (nav){
		if (nodes){
			for (var i=0; i<nodes.length; i++) {
				nodes[i].onmouseover = function() {
					
					for (var i=0; i<nodes.length; i++)
					{
						if (nodes[i].className == 'active')
						{
							currentActiveItem = nodes[i];
							nodes[i].className = '';
						}
						else
						{
							nodes[i].className = "";
						}
					}
					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';
		}
		
	}
}

function fixLayout()
{
	var cw = document.getElementById("container").offsetHeight + 88;
	if ( document.documentElement.clientHeight < cw )
	{
		document.getElementById("footer").style.position = "static";
		document.body.style.position = "static";
	}
	else
	{
		document.body.style.position ="relative";
		document.getElementById("footer").style.position = "absolute";
	}
}

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

if (window.addEventListener) {
	window.addEventListener("load", startList, false);
	window.addEventListener("resize", fixLayout, false);
}
else if (window.attachEvent) {
	window.attachEvent("onload", startList);
	window.attachEvent("onresize", fixLayout);
}
