
initNavigation = function() {

	if (document.getElementById) { 
		navRoot = document.getElementById("nav_list"); // Get main list ul

		if (typeof defaultMainList!="undefined")
			var reMainNav = new RegExp("^" + defaultMainList + "<", "i"); // Regex for finding the index of the default main list item

		for (i=0; i<navRoot.childNodes.length; i++) { // Loop over main list items
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				if ((typeof defaultMainList!="undefined") && node.firstChild.innerHTML.match(reMainNav)) { // Found default main nav item
					defaultMainListIndex = i;
				} else {

					////// Apply onmouseover and onmouseout event handlers to each main list item //////
					node.onmouseover = function() {
						if (defaultMainListIndex != -1) // Is there a default main list item?
							navRoot.childNodes[defaultMainListIndex].className = "nav_default_off"; // De-activate it
						this.className = "mouse_over"; // Activate the hovered item
					}
					node.onmouseout = function() {
						this.className = ""; // De-activate the hovered item
						if (defaultMainListIndex != -1) // Is there a default main list item?
							navRoot.childNodes[defaultMainListIndex].className = "nav_default_on"; // Activate it
					}
				}
			}
		}

		////// Activate the default main list item //////
		if (defaultMainListIndex != -1) {
			navRoot.childNodes[defaultMainListIndex].className = "nav_default_on";
			if (defaultMainList == "Home") { // This if-else statement was added to display or hide the first list item of the Home tab. //
				document.getElementById("hmpgText").style.display = "block";
				//document.getElementById("home").style.className = "current";
			}
				else { 
				    document.getElementById("hmpgLink").style.display = "block";
				    //document.getElementById(currentMenu).style.className = "current"; 
				    } 
		}
	}
}

// Adds a handler to an event without over-riding other handlers

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

startList = function() {
  initNavigation();
  defaultOnload();  // Call defaultOnload, defined in common.js
}

var defaultMainListIndex = -1; // Initialize the index of the default main list item

addLoadEvent(initNavigation); // Add initNavigation to the page onload event handler

window.onload=startList; // Set the page onload event handler