// This file handles the style switching for the topNav.
// This script can be replaced by adding styles to the CSS
// style sheets when the :hover pseudo element is more widely supported.
// This is based on the standards-based dhtml menu script freely
// available at www.gazingus.org.

if (!document.getElementById)
	document.getElementById = function() { return null; }

function initializeTopNavButton(buttonId,currentButtonId) {

	var topNavButton = document.getElementById(buttonId);
	var currentButton = document.getElementById(currentButtonId);
	var isCurrentButton = false;
	
	if (currentButton != null && topNavButton.parentNode.id == currentButton.id) {
		isCurrentButton = true;
	}

	if (topNavButton == null) return;

	if (window.opera) return; // I'm too tired
	
	if (!isCurrentButton) {
		topNavButton.onmouseover = function() {
			topNavButton.parentNode.style.backgroundColor = "#233289";
			topNavButton.style.color = "#fff";
			topNavButton.style.fontWeight = "bold";
			return false;
		}
		topNavButton.onmouseout = function() {
			topNavButton.parentNode.style.backgroundColor = "#bfd5ef";
			topNavButton.style.color = "#233289";
			topNavButton.style.fontWeight = "bold";
			return false;
		}
	}
}

// This would typically go in the html file, but the best solution
// for phschool.com is to keep it here, since the site isn't completely
// dynamic.
window.onload = function() {
	initializeTopNavButton("laButton","current");
	initializeTopNavButton("sciButton","current");
	initializeTopNavButton("mathButton","current");
	initializeTopNavButton("ssButton","current");
	initializeTopNavButton("flButton","current");
	initializeTopNavButton("ctButton","current");
	initializeTopNavButton("apButton","current");
}

