// Script to Set the Selected Menu Item for the Current Page
// COPYRIGHT 2007 FLASHPOINT PRODUCTIONS (YTBE INC.).  ALL RIGHTS RESERVED.
function GetPageFileNameFromPath(path)
{
	pageName = path.substring(path.lastIndexOf('/') + 1);
	pageName = pageName.toLowerCase(); //Convert it to lowercase.
	if(pageName == "")
	{
		pageName = "default.html"; //Set default page name if not found.	
	}
	return pageName;
}

function SetSelectedMenuItem()
{
	//Get the name of the current page
	var currPageName = GetPageFileNameFromPath(window.location.pathname);
	
	var menu = document.getElementById("menu").getElementsByTagName("a"); // Get the menu wrapper.
	
	for(i=0; i<menu.length; i++)
	{
		if(
		   (GetPageFileNameFromPath(menu[i].href) == currPageName && menu[i].target == "")
		   || (GetPageFileNameFromPath(menu[i].href) == "contactus.html" && currPageName == "contactus_thankyou.html") //Special Case: Thank you page for contact us form.
			)
		{
			menu[i].className = "selected";
		} else {
			menu[i].className = "";
		}
	}
}

var origOnload = window.onload; //Get any other window.onloads

window.onload = function()
{
	if (origOnload != null) //If there was another window.onload, call it, then run our script.
	{
		origOnload();
	}
	
	SetSelectedMenuItem();
}