window.onload = function(){
	startList();
	setPage();
}


function startList() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("topnav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}


/* Functions to add "current" class to current page menu items */
function extractPageName(hrefString)
{
	var arr = hrefString.split('/');
	return  (arr.length < 2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();
}
 
function setActiveMenu(arr, crtPage)
{
	for (var i=0; i < arr.length; i++)
	{
		if(extractPageName(arr[i].href) == crtPage)
		{
			if (arr[i].parentNode.tagName != "DIV")
			{
				arr[i].className = "current";
				arr[i].parentNode.className = "current";
			}
		}
	}
}
 
function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;
 
	if (document.getElementById("topnav") !=null )
	setActiveMenu(document.getElementById("topnav").getElementsByTagName("a"), extractPageName(hrefString));
	
	if (document.getElementById("subMenu") !=null )
	setActiveMenu(document.getElementById("subMenu").getElementsByTagName("a"), extractPageName(hrefString));
	
	if (document.getElementById("footernav") !=null )
	setActiveMenu(document.getElementById("footernav").getElementsByTagName("a"), extractPageName(hrefString));
}

