function setCurrentSubNav( aSubNavId )
{
    var theElementNodeType = 1;
    var theSubNav = document.getElementById("subnav");
    for (var i = 0; i < theSubNav.childNodes.length; i++)
    {
        if ( theSubNav.childNodes[i].nodeType == theElementNodeType )
        {
            theSubNav.childNodes[i].className = "";
            theSubNav.childNodes[i].firstChild.style.color = "purple";
        }
    }

    var theNavElement = document.getElementById(aSubNavId);
    theNavElement.className="currentSubNav";
    theNavElement.firstChild.style.color = "white";
}

function setCurrentSubNavByHtmlNavBarTitle()
{
	var theHtmlNavBarTitle = getNavBarTitleFromHtmlElement();

	var theElementNodeType = 1;
    var theSubNav = document.getElementById("subnav");
    for (var i = 0; i < theSubNav.childNodes.length; i++)
    {
		var theSubNavChildNode = theSubNav.childNodes[i];
		
        if ( theSubNavChildNode.nodeType == theElementNodeType )
        {
			var theSubNavItem = theSubNavChildNode;
			
            theSubNavItem.className = "";
            theSubNavItem.firstChild.style.color = "purple";

			if ( ifPageNavBarTitleMatchesNavBarLinkId( theHtmlNavBarTitle, theSubNavItem ) )
			{
				theSubNavItem.className="currentSubNav";
				theSubNavItem.firstChild.style.color = "white"			
			}
		}
    }
}

function ifPageNavBarTitleMatchesNavBarLinkId( anHtmlNavBarTitle, aSubNavItem )
{
	return anHtmlNavBarTitle && anHtmlNavBarTitle == aSubNavItem.id;
}

function getNavBarTitleFromHtmlElement()
{
	var theHtmlElement = document.getElementsByTagName("html")[0];
	return theHtmlElement.getAttribute( "navBarTitle" );
}

