//globals
var gaColors = new Array();
var gColorName = 0;
var gColorHex = 1;
var gTextOverHex = 2;
var gBgColor;
var gFgColor;
var LeftNav;
var Logo;
var TopNav;
var BreadCrumbs;
var LeftRollover;
var TopRollover;
var gWindowWidth;
var gWindowHeight;


// initializations

//functions

function initColorsArray () {
	temp = new Array();

	temp = Array ("red", "#FF0000", "#00FFFF");
	addColorToArray (temp);
	
	temp = Array ("hunter", "#009900", "#FF66FF");
	addColorToArray (temp);
	
	temp = Array ("green", "#008000", "#FF8FFF");
	addColorToArray (temp);
	
	temp = Array ("blue", "#0000FF", "#FFFF00");
	addColorToArray (temp);
	
	temp = Array ("teal", "#008080", "#FF8F8F");
	addColorToArray (temp);
	
}

function initGlobals () {
// have to wait until the page is loaded to find the elements
	if (document.getElementById) {
		LeftNav = document.getElementById("LeftNav");
		Logo = document.getElementById("Logo");
		TopNav = document.getElementById("TopNav");
		BreadCrumbs = document.getElementById("BreadCrumbs");
	}
// now grab window size
	if (!is_ie) {
		gWindowWidth = window.innerWidth;
		gWindowHeight = window.innerHeight;
	} else {
		gWindowWidth = document.body.clientWidth
		gWindowHeight = Math.max(document.body.clientHeight, Content.clientHeight)
	}
		
}
	
function addColorToArray (colorArray) {
	temp = gaColors.length
	gaColors[temp] = colorArray;
}	

function setBg () {
	var theCount = gaColors.length;
	var thisBackground = Math.floor(Math.random() * theCount);
	gBgColor = gaColors[thisBackground][gColorHex];
	gFgColor = gaColors[thisBackground][gTextOverHex];
	
	Logo.style.backgroundColor = gBgColor;
	LeftNav.style.backgroundColor = gBgColor;
	TopNav.style.backgroundColor = gBgColor;
	BreadCrumbs.style.color = gBgColor;
	setHovers();
	return;
}

function setHovers() {
	if (! is_opera) {
	// opera doesn't support dynamic styleSheets yet
		if (is_ie) {
			document.styleSheets["addedStyles"].addRule(".LeftRollover:hover", "color:" + gFgColor);
			document.styleSheets["addedStyles"].addRule(".LeftRollover:active", "color:" + gFgColor);
			document.styleSheets["addedStyles"].addRule(".TopRollover:hover", "color:" + gFgColor);
			document.styleSheets["addedStyles"].addRule(".TopRollover:active", "color:" + gFgColor);
		}
		else if (is_gecko) {
			theStyleSheet = document.getElementById("addedStyles");
			theLength = theStyleSheet.sheet.cssRules.length
			theStyleSheet.sheet.insertRule(".LeftRollover:hover, .LeftRollover:active, .TopRollover:hover, .TopRollover:active { color:" + gFgColor + "}",  theLength);
		}	
			
	}
}

function initPage () {
	initColorsArray();
	initGlobals();
	setBg ();
	hackMe ();
}

function rollText () {
	
}

function pulldownMenu (which) {
	var theMenu;
	theMenuName = "pulldownMenu_" + which;
	if (document.getElementById) {
		theMenu = document.getElementById(theMenuName);
	} else {
		theMenu = eval(theMenuName)
	}
	// fix
	if (theMenu.style.visibility == null) theMenu.style.visibility = "hidden";

	temp = theMenu.style.visibility;

	//hide them all
	hidemenu();
	
	// show this one
	if (temp == "hidden") {
		theMenu.style.visibility = "visible";
	} else {
		theMenu.style.visibility = "hidden";
	}
	
	// hide the others
}
	
function rollover (which) {
	which.src = "images/buttons/" + which.name + "_ro.gif";
	return;
}

function rollout (which) {
	which.src = "images/buttons/" + which.name + ".gif";
	return;
}

function setMsg (message) {
	status = message;
	return status;
}

function hidemenu() {
	var theMenu;
	for (var i = 0; i < gMenus; i++) {
		theMenuName = "pulldownMenu_" + i;
		if (document.getElementById) {
			theMenu = document.getElementById(theMenuName);
		} else {
			theMenu = eval(theMenuName)
		}
		theMenu.style.visibility = "hidden";
	}
	return;
}
