var lis = [];

function initPage()
{
	var navRoot = document.getElementById("nav");
	lis = navRoot.getElementsByTagName("li");
	for (var i=0; i<lis.length; i++)
	{
		if (lis[i].parentNode.id == "nav")
		{
			lis[i].onmouseover = function () 
			{
				this.className += " hover";
			}
			lis[i].onmouseout = function ()
			{
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}

function initClickNavs()
{
	var navRoot = document.getElementById("nav");
	lis = navRoot.getElementsByTagName("li");
	for (var i=0; i<lis.length; i++)
	{
		if (lis[i].parentNode.id == "nav")
		{
			if(true || lis[i].getElementsByTagName('ul')[0])
			{
				lis[i].onclick = function()
				{
					clear_all();
					if (this.className.indexOf("active") != -1) this.className = this.className.replace("active","")
					else this.className += " active";
				}
			}
			else
			{
				lis[i].onclick = function()
				{
					clear_all();
				}				
			}
		}
	}
}

function clear_all()
{
	for (var i=0; i<lis.length; i++)
	{
		if (lis[i].parentNode.id == "nav")
		{
			if (lis[i].className.indexOf("active") != -1) lis[i].className = lis[i].className.replace("active","")
		}
	}
}


/*
if (document.all && window.attachEvent)
	attachEvent("onload", initPage);
	
if (window.addEventListener)
	window.addEventListener("load", initClickNavs, false);
else if (window.attachEvent && !window.opera)
	window.attachEvent("onload", initClickNavs);
*/	

