// This script is used to highlight and expand the left navigation menus. It will also highlight top mavigation buttons.
// This script will work on both the original left navigations from the 1st design as well as the new CSS based left navigations
// in the web 2 design.

// Global Navigation Variables

var	currTopNav = "";
var	currLeftNav = "";
var activeMenu;
var menuColor = "";
var firstPass = "y";
	
function menuOpen () {

	menuColor = document.getElementById('lefttitlebox').style.backgroundColor;		// Get color of left nav titlebox to use for menu button highlight color
	if (document.getElementById('secondary_title')){								// Check if secondary menu exists
		document.getElementById('secondary_title').style.backgroundColor = menuColor;	// Set color for Secondary menu title	
	}
	
// Get the ID names for the leftNav from the <body> tag
	var bodyTag = ns6? document.getElementsByTagName('body')[0]: document.all.tags("body")[0];
	
// Check to see if page uses new CSS method for setting leftNav and TopNav from the BODY tag.
// If so, get the values. If not values were already specified in the javaScript within the page.
	if (bodyTag.id != "") {
		currTopNav = bodyTag.id.substring(0, bodyTag.id.lastIndexOf("_on"));
	}
	
	if (bodyTag.className != "") {
		currLeftNav = bodyTag.className;	
	}
	
// Turn Top Navigation menu On
	if (currTopNav && document.getElementById(currTopNav)){			// Check for valid id reference
		element = document.getElementById(currTopNav);
		element=ns6? element.parentNode : element.parentElement;	// backup to <li> tag
		element.className="topNav_item_On";							// change style to Highlighted
	}
	
// Turn Left Navigation menu On

	if (!currLeftNav || !document.getElementById(currLeftNav)){						// Check for valid id reference
		return 0;
	} 
	else {
		sourceElement = document.getElementById(currLeftNav);
		element = sourceElement;
		expandNav_CSS();
	}
}


function expandNav_CSS() {
	while (ns6&&element.parentNode||(ie&&element.parentElement)){
		element=ns6? element.parentNode : element.parentElement;     //up a level

//		alert ("While Loop:  tag = " + element.tagName + "    Id = " + element.id + "    Class = " + element.className);
		
		if (element.className=="list_1_item"){
			element.className="list_1_item_On";				// change style to Highlighted
			element.firstChild.style.backgroundColor = menuColor;	// modify base style bgcolor of <a> to color of "lefttitlebox" style which may have been overridden by and in-line style. 

			b = ns6? element.getElementsByTagName('ul')[0]: element.all.tags("ul")[0];				// folder contain contents ?
			if (firstPass == "y" && (b != null)){			// expand tier two menu
				b.style.display="";
			}
			firstPass = "n";
			break;											// At the top. ALL DONE
		}
		if (element.className=="list_2_item"){
			element.className="list_2_item_On";				// change style to Highlighted
			
			b = ns6? element.getElementsByTagName('ul')[0] : element.all.tags("ul")[0];				// folder contain contents ?
			if (firstPass == "y" && (b != null)){			// expand tier three menu
				b.style.display="";
			}			
			firstPass = "n";
		}
		if (element.className=="navList_2" || element.className=="navList_3"){
			sourceElement.className="menuText_On";			// change style to Highlighted
			element.style.display="";
			firstPass = "n";
		}		
		if (element.className=="list_3_item"){
			element.className="list_3_item_On";				// change style to Highlighted
			firstPass = "n";
		}
	}									// end while loop
	element.style.display="";           // expand sub-menu list
}