//** Sniff for the two major browsers **
	var ie  = (document.all)? true:false
	var ns6 = ((document.getElementById)&&(!ie))? true:false

//** Sniff for browser version, used for IE 5 only **
	var agt = navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var ie5 = (ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	var ie5_5 = (ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));

//** Sniff for Mac, used for IE Mac browsers **
	var mac = (agt.indexOf("mac") > -1)? true:false

//** Sniff for AOL, used in certain cases where AOL won't pop open a window the size we want it **
	var aol = (agt.indexOf("aol") > -1)? true:false

//** Used to test if a value is 'undefined'.  What 'undefined' represents is different for each **
//** browser, but any variable that has not been defined a value IS 'undefined' in all browsers. **
//** So, we'll test against this variable to see if another is 'undefined'. **
	var undef;

//** When used, this var would be declared in an offsite page. **
//** It's used to define the full path to each menu item for non-NUSA pages.
//** We don't want to erase any existing value, so we'll check if it has one first.
	if (!NUSAnavPath) {
		var NUSAnavPath = "";
	}

//** Menu vars **
	var LAYtnMenu, LAYtopDiv;
	var origClassName, curMenu;
	var HOLDcurMenu = "";
	var HOLDLAYtopDiv = "";
	var NotInMenuNow = true;

//** tnCurSection is declared inline. **

	var MasterPageWidth = 742;
//** Menu ends 15px from edge of page area. **
	var MasterMenuWidth = 727;

	var PreloadComplete = false;

//** These links are considered absolute links at this point. **
//** Declarations for tnMenu[] done inline in each page. **

	var tnContents = new Array();
	tnContents["Abo"] = "";
	tnContents["Our"] = "";
	tnContents["Car"] = "";
	tnContents["Rec"] = "";
	tnContents["Nut"] = "";
	tnContents["Com"] = "";


//** Leave these set to 0.  The code will calculate and populate the values in tnBuild(). **
//** Setting values here will bypass the calculations. **
	var tnMenuWidth = new Array();
	tnMenuWidth["Abo"] = 0;
	tnMenuWidth["Our"] = 0;
	tnMenuWidth["Car"] = 0;
	tnMenuWidth["Rec"] = 0;
	tnMenuWidth["Nut"] = 0;
	tnMenuWidth["Com"] = 0;
	
	
	var tnMenuPos = new Array();
	tnMenuPos["Abo"] = "0px 0px";
	tnMenuPos["Our"] = "0px 0px";
	tnMenuPos["Car"] = "0px 0px";
	tnMenuPos["Rec"] = "0px 0px";
	tnMenuPos["Nut"] = "0px 0px";
	tnMenuPos["Com"] = "0px 0px";
	
	tnMenuPos["Abo_hover"] = "0px -21px";
	tnMenuPos["Our_hover"] = "0px -21px";
	tnMenuPos["Car_hover"] = "0px -21px";
	tnMenuPos["Rec_hover"] = "0px -21px";
	tnMenuPos["Nut_hover"] = "0px -21px";
	tnMenuPos["Com_hover"] = "0px -21px";
	
	tnMenuPos["Abo_selected"] = "0px -46px";
	tnMenuPos["Our_selected"] = "0px -46px";
	tnMenuPos["Car_selected"] = "0px -46px";
	tnMenuPos["Rec_selected"] = "0px -46px";
	tnMenuPos["Nut_selected"] = "0px -46px";
	tnMenuPos["Com_selected"] = "0px -46px";
	
	


//** Layer Build functions.  The IF verifies that, if a layer doesn't exist **
//** the function will return null instead of a JavaScript error. **
	function refLayer(layerName) {
		var LAYref;
		if (ie) {
			if (document.all[layerName]) {
				LAYref = document.all[layerName];
				HideText = "hidden";
			} else {
				LAYref = null;
			}
		} else {
		    // default to NS6+
			if (document.getElementById(layerName)) {
				LAYref = document.getElementById(layerName);
				HideText = "hidden";
			} else {
				LAYref = null;
			}
		}

		return LAYref;
	}


//** Functions to determine browser window width/height **
	function getInsideWindowWidth() {
		if (ie) {
			return document.body.scrollWidth
		} else {
			return document.width
		}
	}

	function getInsideWindowHeight() {
		if (ie) {
			return document.body.scrollHeight
		} else {
			return document.height
		}
	}


//** Calculate Offsets from current item. **
	function eventXoffset(evt) {
		if (ie) {
			return document.body.scrollLeft - document.body.clientLeft + evt.clientX - evt.offsetX;
		} else {
			return evt.pageX - evt.layerX
		}
	}

	function eventYoffset(evt) {
		if (ie) {
			return document.body.scrollTop - document.body.clientTop + evt.clientY - evt.offsetY;
		} else {
			return evt.pageY - evt.layerY
		}
	}


	function layerWidth(LAYer) {
		if (ie) {
			return LAYer.scrollWidth;
		} else {
			return LAYer.offsetWidth;
		}
	}



//** Init the top nav layer **
	function menuInit() {
		LAYtnMenu = refLayer("TnDD");
	//	oldFashionedPreload();
		PreloadComplete = true;
	}


//****************************************
//** Top Nav DHTML Menu Functions START **
//****************************************

	function tnBuild(menuName) {
		var i, menuHTML, linkURL;
	//** Build Menu Contents.  Should only be done once. **
		i = 0;
		menuHTML = "";

	//** Build each line in the menu. **
		while (tnMenu[menuName + i]) {
		//** If this is a JavaScript command, just use it instead of trying a document.location.href. **
			if (tnMenu[menuName + i][1].toLowerCase().indexOf("javascript:") == 0) {
				linkURL = tnMenu[menuName + i][1].substr(11);
			} else if (tnMenu[menuName + i][1].toLowerCase().indexOf("http") == 0) {
				linkURL = "top.location.href='"+tnMenu[menuName+i][1]+"'";
			} else {
				linkURL = "top.location.href='"+NUSAnavPath+tnMenu[menuName+i][1]+"'";
			}

			menuHTML += '<div class="tnMenuItem" '
			menuHTML += 'onClick="'+linkURL+'" onMouseOver="navRollOver(this);" '
			menuHTML += 'onMouseOut="navRollOff(this);">'

			if (ie5) {
				menuHTML += '<nobr>' + tnMenu[menuName + i][0] + '</nobr>';
			} else {
				menuHTML += tnMenu[menuName + i][0];
			}

			menuHTML += '</div>\n';
			i++;
		}
		return menuHTML;
	}

//** Calculates max width of layer (if first time thru), and sets the outer DIV to that size. **
	function calcAndSetWidth(menuName) {
		var i;
		if (tnMenuWidth[menuName] <= 0) {
		//** Calc max width of inner DIVs **
		//** IE Mac width is pre-set before we get here, so these calcs will never be run.
			for (i=0; i<LAYtnMenu.childNodes.length; i++) {
				if (LAYtnMenu.childNodes[i].offsetWidth > tnMenuWidth[menuName]) {
					tnMenuWidth[menuName] = LAYtnMenu.childNodes[i].offsetWidth;
				}
			}
		}

		LAYtnMenu.style.width = tnMenuWidth[menuName] + "px";
	}


//** Rollover function **
	function navRollOver(LAYer) {
		if (PreloadComplete) {
			LAYer.style.backgroundColor = "#FCDB89";
			showTnDD();
		}
	}

	function navRollOff(LAYer) {
		if (PreloadComplete) {
			LAYer.style.backgroundColor = "#FCDB40";
			hideTnDD(true);
		}
	}


//** Top Nav Dropdown functions **
//** Check PreloadComplete on these just in case **
	function showTnDD() {
		if (PreloadComplete) {
			NotInMenuNow = false;
			LAYtnMenu.style.visibility = "inherit";
		//	LAYtopDiv.childNodes[0].style.height = "23px";
			LAYtopDiv.childNodes[0].style.visibility = "inherit";
			
		}
	}

	function hideTnDD(FirstTry) {
		if (PreloadComplete) {
			if (FirstTry) {
				NotInMenuNow = true;
				HOLDLAYtopDiv = LAYtopDiv;
				HOLDcurMenu = curMenu;
				setTimeout("hideTnDD(false)", 50);
			} else if (NotInMenuNow) {
				LAYtnMenu.style.visibility = "hidden";
				//** Must split these two IFs, 'cause the second one will fail if the first is true. **
				if (HOLDLAYtopDiv) {
					if (HOLDLAYtopDiv != "") {
		//				HOLDLAYtopDiv.childNodes[0].style.height = "0px";
						HOLDLAYtopDiv.childNodes[0].style.visibility = "hidden";
					}
				}
				HOLDLAYtopDiv = "";
				HOLDcurMenu = "";
			}
		}
	}


	function openTnDD(menuName, topDiv, evt) {
		var MenuEdge, MDxCoord, MDyCoord;
		if (!evt) evt = event;

		if (PreloadComplete) {

		//** Hide menu and move it off the page.  This resolves menu flicker. **
			NotInMenuNow = true;
			hideTnDD(false);
			LAYtnMenu.style.left = -200;
			LAYtnMenu.style.top = -200;

		//** If we haven't viewed this menu before, write out its contents and store in array. **
			if (tnContents[menuName] == "") {
				tnContents[menuName] = tnBuild(menuName);
			}

			if (ie) {
				LAYtnMenu.style.width = "10px";
			} else {
				LAYtnMenu.style.width = "auto";
			}

			LAYtnMenu.innerHTML = tnContents[menuName];

			calcAndSetWidth(menuName);

	// Calculate right edge of menu.  If it's past the edge of the centered table, align it so it is.

			MDxCoord = eventXoffset(evt);
			MDyCoord = eventYoffset(evt);

			LeftPageStart = (getInsideWindowWidth()-MasterPageWidth)/2;
			MenuEdge = MDxCoord + layerWidth(LAYtnMenu) - LeftPageStart;

			if (MenuEdge > MasterMenuWidth) {
	// The right edge of the menu is beyond the designed-for MasterMenuWidth.  Adjust MDxCoord appropriately.
				MDxCoord -= (MenuEdge-MasterMenuWidth) - 3;

				if (ns6) {
					MDxCoord -= 1;
				} else if (ie && mac)  {
					MDxCoord -= 2;
				}
			}

		//** Put in IE Mac resize fix (add & subtract 1px) here if we need it. **				
			if (ie && mac) {
	//			alert("ie mac");
				MDxCoord -= 28;
			}

		//** Set left & top coordinates. **
			LAYtnMenu.style.left = MDxCoord;
			LAYtnMenu.style.top = MDyCoord + 21;
			LAYtopDiv = topDiv;
			curMenu = menuName;

			showTnDD();
		}
	}

/*** Generic Function Library **/

	function divHREF(varHref, target) {
		if (target) {
			// code goes here
		} else {
			document.location.href = varHref;
		}
	}


