/*
	Most of this code was taken from example at http://blog.richnetapps.com/index.php?blog=1&p=23&page=1&more=1&c=1&tb=1&pb=1&disp=single

	Make sure the navigation section that needs highlighting is within <div id="nav"></div>, else it won't work.
	Within the CSS, there also needs to be a class name "current" that specifies the background of the current page.
	Doesn't matter where you include this javascript code in your page (i.e. can be up top).
*/

// JavaScript Document
function extractPageName(hrefString)
{
	var hrefString = hrefString.split('#');
	var hrefString = hrefString[0].split('?');
	
	var arr = hrefString[0].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)
		{
/*				arr[i].className = "current";
*/				arr[i].parentNode.className = "current";
		}
	}
}

function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;

	if (document.getElementById("nav")!=null) 
		setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
}



window.onload=function()
{
  setPage();
}
