//The below code will set the current page's subnav to 'hidden', allowing the others to be 'visible' when they're hovered on.
function hideLocalSubnav(thisSubnav) {
	
	//if we are indeed in a section and not the homepage, the body should have an id
	if (document.getElementsByTagName('body')[0].id.length > 0 ) {

		//If the subnav being moused-over is not the subnav for the section of the site we are in (the "local" section)...
		if (thisSubnav.id.replace('Links', 'Page') != document.getElementsByTagName('body')[0].id) {
	
			//..., then hide the local subnav.
			document.getElementById(document.getElementsByTagName('body')[0].id.replace('Page', 'List')).style.visibility = 'hidden';
		}
		
	}
}

function restoreLocalSubnav() {
	
	//if we are indeed in a section and not the homepage, the body should have an id
	if (document.getElementsByTagName('body')[0].id.length > 0 ) {

		//Show the local subnav.
		document.getElementById(document.getElementsByTagName('body')[0].id.replace('Page', 'List')).style.visibility = 'visible';
		
	}
	
}

//Called when the body loads, this will light up the current section's link.
function lightUpSectionLink() {
	
	//Get the DOM element to light up (essentially, the one graphic that represents the current section you're in).
	var linkImg = document.getElementById(document.getElementsByTagName('body')[0].id.replace('Page', 'Links')).firstChild.firstChild;
	
	//Light up the element by modifying the src attribute.
	linkImg.src = linkImg.src.replace('.gif', '-over.gif')
	
}

//The below code will set the top-level nav image to its red version when being hovered over, or when on that page
function lightUpThisTopNavLink(thisLink) {
	
	//If this is not Safari, or if it is and a build less than 520... (Safari 3 will supposedly start at build 521)
	//This is created because there is a glitch with this nav system in Safari 2, but likely go away in Safari 3
	if (navigator.userAgent.indexOf('Safari') < 0 || parseFloat(navigator.userAgent.split('/')[3]) > 520) {

		//If this is not the top-level link for the current local section
		if (thisLink.id.replace('Links', 'Page') != document.getElementsByTagName('body')[0].id) {
			thisLink.firstChild.firstChild.src = thisLink.firstChild.firstChild.src.replace('.gif', '-over.gif');
		}

	}	
	
}

//Restores original top-level link image on mouseout (except for link of local section)
function restoreThisTopNavLink(thisLink) {
	
	//If this is not Safari, or if it is, a built less than 520... (Safari 3 will supposedly start at build 521)
	//This is created because there is a glitch in Safari 2, but likely go away in Safari 3
	if (navigator.userAgent.indexOf('Safari') < 0 || parseFloat(navigator.userAgent.split('/')[3]) > 520) {

		//If this is not the top-level link for the current local section
		if (thisLink.id.replace('Links', 'Page') != document.getElementsByTagName('body')[0].id) {
			thisLink.firstChild.firstChild.src = thisLink.firstChild.firstChild.src.replace('-over.gif', '.gif');
		}

	}
	
}
