function extractPageName(hrefString)
{
	//Gets the string and checks to see if there is ".php" in the hrefString
	var isindex = hrefString.search(/.php/)
	//If there is no ".php" it must be pointing to the home page
	if (isindex == '-1')
	{
		//Add index.php to the hrefString so that when viewing the home page the home page link is highlighted
		var hrefString = hrefString + "index.php";	
	}
	//Gets the string and checks to see if there is pid=(productID) in the hrefString and replaces it with pid=0
	//so that when you are viewing the product description, the product category link is still highlighted
	var hrefString = hrefString.replace(/pid=\d+/,"pid=0");
	//Gets the string and checks to see if there is ?lang=(language) in the hrefString and removes it
	//so that when you are viewing a page the current page link is highlighted
	var hrefString = hrefString.replace(/\?lang=??/,"");
	var arr = hrefString.split('.');
	
	// Check to see if the url has a query string by searching for the question mark 
	var hasquestion=hrefString.indexOf('?');
	if (hasquestion == '-1')
	{
		arr = arr[arr.length-2].split('/'); 
		return arr[arr.length-1].toLowerCase();
	} 
	else
	{	
		return 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()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;
	
	if (document.getElementById("topmenu")!=null) 
		setActiveMenu(document.getElementById("topmenu").getElementsByTagName("a"), extractPageName(hrefString));
	if (document.getElementById("verticalmenu")!=null) 
		setActiveMenu(document.getElementById("verticalmenu").getElementsByTagName("a"), extractPageName(hrefString));
}