// Script to Set the Selected Navigation 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 SetSelectedNavigationItem()
{
	//Get the name of the current page
	var currPageName = GetPageFileNameFromPath(window.location.pathname);
	
	var navigation = document.getElementById("navigation").getElementsByTagName("a"); // Get the navigation wrapper.
	
	for(i=0; i<navigation.length; i++)
	{
		//Check to see if the link is an internal page.  If not, then there is no need to set to selected style.
		if (navigation[i].href.toLowerCase().indexOf("http://www.newbreedfitness.com") == 0)
		{
			if(GetPageFileNameFromPath(navigation[i].href) == currPageName)
			{
				navigation[i].className = "navTopLevelSelected";
			} else {
				navigation[i].className = "navTopLevel";
			}
		} else {
			navigation[i].className = "navTopLevel";
		}
	}
}

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();
	}
	
	SetSelectedNavigationItem();
}