window.onload=function()
{
	setPage();
}

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)
		{
			arr[i].className = "current";
			if (arr[i].parentNode.tagName == "LI")
			{
				var ShortNode2
				//alert(arr[i].parentNode.tagName); //LI #2 FF IE       
				//alert(arr[i].parentNode.parentNode.tagName);//UL #2 FF IE        //UL #3 FF     //LI #2
				//alert(arr[i].parentNode.parentNode.parentNode.tagName);//DIV #2 FF IE         //LI #3 FF    //UL #2
				ShortNode2 = arr[i].parentNode.parentNode; //UL
				//alert(ShortNode2.tagName);
								  
				//level 3
				if (ShortNode2.parentNode.tagName == "LI")
				{
					//alert("level 3");
					ShortNode2.parentNode.firstChild.className = "currentSub";
					//arr[i].parentNode.parentNode.previousSibling.parentNode.parentNode.parentNode = sideNavSub
					var ShortNode = arr[i].parentNode.parentNode.previousSibling.parentNode.parentNode.parentNode;
					if (ShortNode.previousSibling.tagName==null)
					{
						ShortNode.previousSibling.previousSibling.firstChild.className = "current";
					}
					else
					{
						ShortNode.previousSibling.firstChild.className = "current";
					}
				}
				else
				{
					//alert("level 2");
					//level 2
					if (arr[i].parentNode.parentNode.parentNode.previousSibling.tagName==null)
					{
						arr[i].parentNode.parentNode.parentNode.previousSibling.previousSibling.firstChild.className = "current";
					}
					else
					{
						arr[i].parentNode.parentNode.parentNode.previousSibling.firstChild.className = "current";
					}
				}
			}
		}
	}
}
 
function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;
 
	if (document.getElementById("sideNavBar") !=null )
		setActiveMenu(document.getElementById("sideNavBar").getElementsByTagName("a"), extractPageName(hrefString));
}

