/*- Run On Load --------------------------------------------------------------*/

// window.onload listener to share event with multiple functions
// Based on runOnLoad function from 
// "JavaScript: The Definitive Guide", 5th ed, p.434, example 17-7

runOnLoad.functionsQueue = new Array();
runOnLoad.isLoaded = false;

function runOnLoad(functionCall) {
	if (runOnLoad.isLoaded) functionCall();
	else runOnLoad.functionsQueue.push(functionCall);
}

runOnLoad.run = function() {
	if (runOnLoad.isLoaded) return;
	for (var i = 0; i < runOnLoad.functionsQueue.length; i++) {	
		//
		// runOnLoad.functionsQueue[i]();
		//
		try { runOnLoad.functionsQueue[i](); }		
		catch(functionError) { 
			if (functionError instanceof Error) {
				alert(functionError.name + ": " + functionError.message);
			}
		}
	}
	runOnLoad.isLoaded = true;
	delete runOnLoad.functionsQueue;
	delete runOnLoad.run;
};

if (window.addEventListener) {
	window.addEventListener("load", runOnLoad.run, false);
} else if (window.attachEvent) {
	window.attachEvent("onload", runOnLoad.run)
} else {
	window.onload = runOnLoad.run;
}

runOnLoad(addHover);

function addHover() {
	if (!document.getElementById) return false;
	if (!document.getElementsByTagName) return false;
	if (!document.defaultView) {	
		nav = document.getElementById("navigationGlobal");
		if (!nav) return false;
		navListItems = nav.getElementsByTagName("li");
		for (i = 0; i < navListItems.length; i++) {
			var node = navListItems[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() {
					this.className += " hover";
				};
				node.onmouseout = function() {
					this.className = this.className.replace(" hover", "");
				};
			}
		}
	}
}
