// JavaScript Page

var currentMenuNum = "";
var newMenuNum = "";
var currentSub = "";
var newSub = "";

/*This site has 4 different backgrounds depending on the page you are on.  This routine is called from the initialize script
in the editable area of the head tag in a page and sets the appropriate background.  If the page also has a scroll area, this
routine sets its background as well.*/
function setBKG(level) {
	document.getElementById("pageContainer").style.backgroundImage="url('images/skin/bkg_level_" + level + ".jpg')"; 
	if (document.getElementById("scrollArea")!=null)
		document.getElementById("scrollArea").style.backgroundImage="url('images/skin/scroll_bkg_" + level + ".jpg')"; 
}

function showSub(m,s) { //m = main menu id, s = sub menu id ("none" indicates that ther is no sub menu)
version=0
// Determine the number of the menu that called this function
	newMenuNum = m.substring(5,6);
	// Turn off the last submenu if one exists
	if (newMenuNum != currentMenuNum && currentSub != "") {
		document.getElementById(currentSub).style.display = "none";
	}
	// If the new menu has a submenu, turn it on and update the currentMenuNum and currentSubNum status pointers
	if (s != "none") {
		//  Check to see if we are running IE6, if so change the submenu div background to the jpg version instead of the png
		if (navigator.appVersion.indexOf("MSIE")!=-1){ // determines the version of IE if user is using an IE browser
			temp=navigator.appVersion.split("MSIE")
			version=parseFloat(temp[1])
		}
		if ((version >= 5.5) && (version <7) && (document.body.filters)) {  //because Firefox does not support "outerHTML" and IE6 does not support "src" we need two routines
			//alert (s + "  " + document.getElementById(s).style.display);
			document.getElementById(s).style.backgroundImage="url('images/skin/menubkg.jpg')"; 
		}
		// turn on submenu and update the currentMenuNum and currentSubNum status pointers
		newSub = s;
		document.getElementById(newSub).style.display = "block";
		currentSub = newSub;
		currentMenuNum = newMenuNum;
	}
	// If the new menu does not have a submenu, reset status pointers
	else {
		currentMenuNum = "";
		newMenuNum = "";
		currentSub = "";
		newSub = "";
	}
}
/*Function is called whenever the cursor rolls over an item that is not a menu item -- it must be called on the mouse over
event in the HTML.  It is typically set to execute when rolling over the "Banner" or the "Content" area.*/
function allRollsOff(e) {
//alert ("here");

	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	toLoc = targ.id.substring(0,4);
	toParent = targ.parentNode.id.substring(0,4);
		if (toLoc!="menu") {
			if (toParent!="menu") {
				if (currentSub!="") {
					document.getElementById(currentSub).style.display = "none";
					currentSub = "";
				}
			}
		}
}
