//////////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
//////////////////////////////////////////////////////////////////////////////////////

var fromMenu = null;
var holdtime = 400;					// Pause time before collapsing all menus.
var htmlTags = "";					// Text to write to browser
var indent = 10;
var isIE4;
var isNav4;
var layerlevel = 0;
var mouseOutTimer = null;
var mouseOverTimer = null;
var mouseoverhold = 100;
var navmenu = null;
var rollingtop = 100;
var rootMenu = null;
var submenu = null;
var timer;							// Timer.  Gives a pause before collapsing all menus
var prodlist;
var normalStyle = "solid";
var hiliteStyle = "solid";

var sitemenuProp1, sitemenuProp2

// Keeps track of menuItem ids and provides a quick
// method for grabbing the handle of a menuItem based on its id
var menuItems = new Array();

// Keeps track of menuItemProp ids and provides a quick
// method for grabbing the handle of a menuItemProp based on its id
var menuItemProps = new Array();

var menuid = null;

//////////////////////////////////////////////////////////////////////////////////////
function OpenMenuSection(imgName, catid, imgWidth, imgHeight, imgAltText, imgSrc, bgcolor) {
//////////////////////////////////////////////////////////////////////////////////////
	var imghtml, headerhtml
	var lyr
	var scrollX, scrollY
	var RootMenuContents
	
	// positioning logic for menu image
	//imghtml = "<img align=bottom border=0 alt='" + imgAltText + "' "
	//imghtml += "src='" + imgSrc + "' "
	//imghtml += "height=" + imgHeight + " "
	//imghtml += "width=" + imgWidth + ">"
	
	//<table border=0 width=150><tr><td></td></tr></table>
	if (imgAltText != "") {
		if (isIE4) {
			headerhtml = "<div class=\"treehighlight\" style=\"width=150\" >" + imgAltText + "</div>"
		} 
		else if (isNav4) {
			headerhtml = "<layer width=150 bgcolor=" + bgcolor+ " ><div class=\"treehighlight\" style=\"width=150\" >" + imgAltText + "</div></layer>"
		}
		
		//Initialize LAYER or DIV for menu image
		CreateLayer(imgName,indent,rollingtop,imgHeight,imgWidth,headerhtml,0)
		// positioning logic for dynamic menu options
		rollingtop = rollingtop + 25;							//add space after header
	}
	layerlevel = catid
	CreateLayer(layerlevel,indent,rollingtop,0,0,"",0);		//Initialize LAYER or DIV for menu options

	if (isIE4) {
		scrollX = document.body.scrollLeft;
		scrollY = document.body.scrollTop;
	} 
	else if (isNav4) {
		scrollX = window.pageXOffset;
		scrollY = window.pageYOffset;
	}
	
	//If menu contents can't be loaded, exit after displaying only top graphic layer
	RootMenuContents = loadmenus(catid);
	if (RootMenuContents == null) { return; }

	openRootMenu(RootMenuContents,scrollX + indent,scrollY + rollingtop,0);
	rollingtop = rollingtop + 10;							//add space after menu
	return;
}

function getRealPos(el,which) {
	var iPos = 0
	while (el!=null) {
	 	iPos += el["offset" + which]
		el = el.offsetParent
	}
	return iPos
}



//////////////////////////////////////////////////////////////////////////////////////
function window_onload() {
//////////////////////////////////////////////////////////////////////////////////////
//	added code for NS resize bug - rsb 8/99
	rollingtop = 182;
	if (isNav4) {
		origWidth = window.innerWidth;
        origHeight = window.innerHeight;
        window.onresize = resizeHandler;

		if (document.layers['subscribe']) { rollingtop = 147; } 
		rollingtop = document.images["DynamicMenu"].y;
		indent = document.images["DynamicMenu"].x;

	} else if (isIE4) {

        window.onresize = resizeHandler;
		if (document.all('subscribe')) { rollingtop = 147; }
		rollingtop = getRealPos(document.images["DynamicMenu"],"Top");
		indent = getRealPos(document.images["DynamicMenu"],"Left");
	}
	window.scrollTo(0,0);
	
	openMenuSections(); 
	//OpenMenuSection("depimage",0,150,19,"Departments","images/noimage.gif"); // dep.gif
	//OpenMenuSection("depimage",-1,150,19,"Departments","images/noimage.gif"); // gift.gif
	if (prodlist){
		eval(prodlist);
	}
	//OpenProductPageData();
	if (isNav4) {
		if (document.layers['subscribe']) { document.layers['subscribe'].visibility='show'; }
		if (document.layers['menujava']) { document.layers['menujava'].visibility='show'; }
	}
}

//////////////////////////////////////////////////////////////////////////////////////
function resizeHandler() {
//////////////////////////////////////////////////////////////////////////////////////
//	event handler for NS resize bug - rsb 8/99
	if (isNav4) {
		if (innerWidth != origWidth || innerHeight != origHeight) {
			origWidth = innerWidth;
			origHeight = innerHeight;
			location.reload();
		}

	} else if (isIE4) {
			location.reload();
	}
}

//////////////////////////////////////////////////////////////////////////////////////
// menusnew.js functions
//////////////////////////////////////////////////////////////////////////////////////

//----------------------------------------------------
// Hides all open menus beginning with rootMenu.
//--------------------------------------------------*/
function collapseRootMenu() {
	//alert("collapseRootMenu:" + rootMenu.navmenu);
	if (rootMenu) {
		rootMenu.hide();
		if (rootMenu.navmenu == 1) {
				  rootMenu = null;
		}
	}
}

function collapseMenu(e) {

	var iSep;
	var sToParse;
	
	sToParse = this.id;
	if (sToParse) {
		if (sToParse.indexOf("enu") > 0) {	//for menu
			sTemp=sToParse.substring(4)		

			currMenuItem=menuItems[sTemp];
			currmenu=currMenuItem;
 
			if (currMenuItem.haschildren || currmenu.level==1){}
			else {
				if (timer) {
					clearTimeout(timer);
				}
				clearTimeout(mouseOverTimer);
				clearTimeout(mouseOutTimer);

				collapseRootMenu();
			}
		}
	}

	if (menuItems[menuid].onclick==null){return};	

	sToParse = menuItems[menuid].onclick;

}
//----------------------------------------------------
// MouseUp event handler for Navigator
//--------------------------------------------------*/
function menuMouseUp(e) {

	//Rusty added this for the menu 
	//go away on mouseup in the product page in Netscape
	
	var iSep;
	var sToParse;
	
	sToParse = this.id;
	if (sToParse) {
		if (sToParse.indexOf("enu") > 0) {	//for menu
			sTemp=sToParse.substring(4)		

			currMenuItem=menuItems[sTemp];
			currmenu=currMenuItem;

			if (currMenuItem.haschildren || currmenu.level==1){}
			else {
				if (timer) {
					clearTimeout(timer);
				}
				clearTimeout(mouseOverTimer);
				clearTimeout(mouseOutTimer);

				collapseRootMenu();
			}
		}
	}
//*************************

//	collapseRootMenu;
	if (menuItems[menuid].onclick==null){return};	
	sToParse = menuItems[menuid].onclick;
	eval(sToParse);
	
}

//----------------------------------------------------
// Opens a menu as the rootMenu.  Use this function
// to begin a cascading menu instead of calling the
// menu's show method directly.
//--------------------------------------------------*/
function openRootMenu(menu, left, top, z_index) {

	// If any other menus are open, close them
	if (rootMenu) {
	  if (rootMenu.navmenu != 1) {
		  collapseRootMenu();
		}
	}
	
	// If the timer has been started, clear it.
	if (timer) {
		clearTimeout(timer);
	}
	
	// Assign menu as the rootMenu
	rootMenu = menu;

	z_index = 0;
	rootMenu.expand(left, top, z_index);
	rootMenu.show(left, top);
}

//////////////////////////////////////////////////////////////////////////////////////
function showRootMenu(menu, left, top, z_index) {
//////////////////////////////////////////////////////////////////////////////////////
	// If any other menus are open, close them
	if (rootMenu) {
		collapseRootMenu();
	}

	// If the timer has been started, clear it.
	if (timer) {
		clearTimeout(timer);
	}
	
	// Assign menu as the rootMenu
	rootMenu = menu;
	
	z_index = 0;
 	rootMenu.show(left, top);
}

//----------------------------------------------------
// Describes display properties of a menuItem
//--------------------------------------------------*/
function menuItemProp(width, bgcolor, fgcolor, highlightcolor, borderwidth, imagesrc, imagewidth) {
	// Grab next menuItemProp id from global list.
	var id = menuItemProps.length;

	this.id = id;
	this.className = "menuProp" + id;
	this.width = width;
	this.bgcolor = bgcolor;
	this.fgcolor = fgcolor;
	this.highlightcolor = highlightcolor;
	this.borderwidth = borderwidth;
	this.imagesrc = imagesrc;
	this.imagewidth = imagewidth;
	menuItemProps[id] = this;			// Add to global list of menuItemProps.
	return this;
}

//----------------------------------------------------
// Constructor for menuItem
//
// Pass in a label, a string to be evaluated as the onclick event handler (optional), a
// menuItemProp object and a handle to a subMenu (optional).
//
// The subMenu can be set later by assigning it to the menuItem's subMenu property.
// However, a "true" value must be passed to the constructor as the third parameter 
// if you want the subMenu graphic to show on the menuItem.
// e.g.
//		var menu1 = new menuItem("Menu 1", "", menuItemProp, true);
//		var menu2 = new menuItem("Menu 2", "", menuItemProp, false);
//		menu1.subMenu = menu2;
//--------------------------------------------------*/
function menuItem(label, onclick, img, sub_menu, props, haschildren, catid, level) {
	// Grab next menuItem id from global list
	var id = menuItems.length;
  
	if (isIE4) {
		htmlTags += "<div id=\"" + id + "\"";
		htmlTags += " class=\"" + props.className + "\"";
		htmlTags += " style=\"";
		htmlTags += " position: absolute;";
		htmlTags += " visibility: inherit;";
		htmlTags += " left: 0;";
		htmlTags += " top: 0;";
		htmlTags += " width: " + props.width + ";";
		htmlTags += " background-color: " + props.bgcolor +";";
		if (props.className == "menuProp0") {
			htmlTags += " padding: 0;";				// override CSS setting for menuProp
		} else {
			htmlTags += " padding: 2; line-height:1.1;";				// override CSS setting for menuProp
		}
		htmlTags += " z-index: 0;"; // just test with index 0
		htmlTags += "\"";
		htmlTags += " onmouseover=\"menuItem_mouseoverdelay('" + id + "');\"";
		htmlTags += " onmouseout=\"menuItem_mouseoutdelay('" + id + "');\"";
		if (onclick) {
			htmlTags += " onclick=\"collapseRootMenu();" + onclick + ";\"";
		}
		htmlTags += ">";
		if (haschildren) {
			htmlTags += "<img src=\"" + props.imagesrc + "\" border=\"0\" align=\"right\" width=\"" + props.imagewidth + "\" vspace=\"2\">"
		} else {
			htmlTags += "<img src=\"images/noimage.gif\" border=\"0\" align=right width=\"" + props.imagewidth + "\" vspace=\"2\">"
		}
		//htmlTags += "&#160;" + "<font color=\"" + props.fgcolor  + "\">" + label + "</font>"
		htmlTags += "<div class=\"tree\">&#160;" + "<font color=\"" + props.fgcolor  + "\"><nobr>" + label + "</nobr></font></div>"
		htmlTags += "</div>";
	} else if (isNav4){
		htmlTags += "<layer id=\"" + "menu" + id + "\"";
		htmlTags += " class=\"" + props.className + "\"";
		htmlTags += " position=\"absolute\"";
		htmlTags += " visibility=\"inherit\"";
		htmlTags += " left=0";
		htmlTags += " top=0";
		htmlTags += " width=" + props.width;
		htmlTags += " bgcolor=" + props.bgcolor;
		htmlTags += " z-index=-1";
		htmlTags += " onmouseover=\"menuItem_mouseoverdelay('" + id + "');\"";
		htmlTags += " onmouseout=\"menuItem_mouseoutdelay('" + id + "');\"";
		htmlTags += ">";
		htmlTags += "<div class=\"tree\" >"
		if (haschildren) {
		  htmlTags += "<img src=\"" + props.imagesrc + "\" border=\"0\" align=right width=\"" + props.imagewidth + "\" vspace=\"2\">"
		} else {
		  htmlTags += "<img src=\"images/noimage.gif\" border=\"0\" align=right width=\"" + props.imagewidth + "\" vspace=\"2\">"
		}
		htmlTags += "&#160;" + "<font color=\"" + props.fgcolor  + "\"><nobr>" + label + "</nobr></font>"
		htmlTags += "</div></layer>";

		if (onclick) {				// Save onclick var for captureEvents(mouseup) - nav only
			this.onclick = onclick;
		} else {
			this.onclick = null;
		}
	}
	this.menu = null;				// The menu that the menuItem belongs to.
	this.subMenu = sub_menu;		// A subMenu to display beneath the menuItem.

	// new variables
	this.img = null;
	this.seperator = null;
	this.haschildren = haschildren;
	this.submenuloaded = false;
	this.catid = catid;
	this.level = level;
	
	// Save the display properties that we need.
	this.bgcolor = props.bgcolor;
	this.fgcolor = props.fgcolor;
	
	this.highlightcolor = props.highlightcolor;
	this.borderwidth = props.borderwidth;
	this.normalstyle = normalStyle;
	this.hilitestyle = hiliteStyle;

	menuItems[id] = this;			// Add to global list of menuItems.
	return this;
}

//----------------------------------------------------
// Grabs a handle to a menuItem's object based on id.
// Called by menuItem constructor.
//--------------------------------------------------*/
function getMenuItem(id) {
	if (isIE4) {
		return eval("document.all(\"" + id + "\")");
	} else if (isNav4) {
		return eval("document.layers[\"" + id + "\"]");
	}
	return null;
}

//----------------------------------------------------
// Event handler for menuItem mouseovers.
// Is passed the id of the menuItem.
//--------------------------------------------------*/
function menuItem_mouseoverdelay(id) {
	var currMenuItem = menuItems[id];
	var currMenu = currMenuItem.menu;
	var obj = currMenuItem.obj;
	var objLeft, objTop, objWidth, objHeight, objZIndex;
	var pageLeft, pageRight, pageBottom, pageTop;
  
	if (timer) {
		clearTimeout(timer);
	}
	clearTimeout(mouseOverTimer);
	clearTimeout(mouseOutTimer);

	mouseOverTimer = setTimeout("menuItem_mouseover(" + id + ");",mouseoverhold)

	currMenu.setActiveMenuItem(currMenuItem);
	if (currMenuItem.level == 1) {
		if (currMenuItem.menu != rootMenu) {
			collapseRootMenu();
		}
		if (timer) {
			clearTimeout(timer);
		}
		rootMenu = currMenu;
	}
	
	if (isIE4) {
		objLeft = obj.parentElement.style.pixelLeft;
		objTop = obj.style.pixelTop + obj.parentElement.style.pixelTop;
		objWidth = obj.offsetWidth;
		objHeight = obj.offsetHeight;
		objZIndex = obj.style.zIndex;
		pageLeft = document.body.scrollLeft;
		pageRight = document.body.clientWidth + document.body.scrollLeft;
		pageBottom = document.body.clientHeight + document.body.scrollTop;
		pageTop = document.body.scrollTop;
		if (objTop + objHeight > pageBottom) {
			window.scrollTo(0,pageTop + objHeight);
		}
		if (objTop - objHeight/2 < pageTop) {
			window.scrollTo(0,pageTop - objHeight);
		}
	}
	else if (isNav4) {
		objLeft = obj.parentLayer.left;
		objTop = obj.top + obj.parentLayer.top;
		objWidth = obj.parentLayer.clip.width;
		objHeight = obj.clip.height;
		objZIndex = obj.zIndex;
		pageLeft = pageXOffset;
		pageRight = window.innerWidth + pageXOffset;
		pageBottom = window.innerHeight + pageYOffset;
		pageTop = window.pageYOffset;
		if (objTop + objHeight > pageBottom) {
			window.scrollTo(0,pageTop + objHeight);
		}
		if (objTop - objHeight/2 < pageTop) {
			window.scrollTo(0,pageTop - objHeight);
		}
		menuid = id
	}
}

//////////////////////////////////////////////////////////////////////////////////////
function menuItem_mouseover(id) {
//////////////////////////////////////////////////////////////////////////////////////
	var currMenuItem = menuItems[id];
	var currMenu = currMenuItem.menu;
	var obj = currMenuItem.obj;
	var submenu = null;
	var left, top, z_index;
	var objLeft, objTop, objWidth, objHeight, objZIndex;
	var pageLeft, pageRight, pageBottom;

	// Clear timer to avoid collapse of all menus.
	clearTimeout(timer);

	layerlevel = currMenuItem.catid;
	fromMenu = obj;
	
	if (currMenuItem.level == 1) {
		if (currMenuItem.menu != rootMenu) {
			collapseRootMenu();
		}
		if (timer) {
			clearTimeout(timer);
		}
		rootMenu = currMenu;
	}
	
	if ((currMenuItem.haschildren) && (! currMenuItem.submenuloaded)) {
   		htmlTags = ""; 
   		if (isIE4) {
   			x = fromMenu.style.pixelLeft + fromMenu.style.pixelWidth - 4;
   			y = fromMenu.style.pixelTop + fromMenu.parentElement.style.pixelTop + 4;  
   			objZIndex = obj.style.zIndex
   		} else if (isNav4) { 
			x = fromMenu.parentLayer.left + fromMenu.clip.width - 4;
   			y = fromMenu.parentLayer.top + fromMenu.parentLayer.top + 4;  
   			objZIndex = obj.zIndex;
   		}
   		// for java navigation page
   		if (fromMenu.navmenu == 1) {
   			layerlevel = rootMenu.id + layerlevel + "nav"
   		}
   		CreateLayer(layerlevel,x,y,0,0,"",0);
   		
		submenu = loadmenus(currMenuItem.catid);
			
		if (submenu == null) {
			if (prodlist){
				submenu = loadProdmenus(currMenuItem.catid)
				if (submenu == null) {return}
			}
			else {return}
		}

		currMenuItem.subMenu = submenu;
		currMenuItem.submenuloaded = true;
		var left, top, z_index;
		z_index = objZIndex + 1;
		currMenuItem.subMenu.expand(0, 0, z_index);
	}
	
	
	currMenu.setActiveMenuItem(currMenuItem);

	// If another subMenu is open for the current menu, close it.
	if (currMenu.openSubMenu) {
		currMenu.openSubMenu.hide();
		currMenu.openSubMenu = null;
	}

	// If there is a subMenu associated with this menuItem, open it.
	if (currMenuItem.subMenu) {
		if (currMenuItem.subMenu.width <= 0 || currMenuItem.subMenu.height <= 0) {
			currMenuItem.subMenu.calculateDimensions();
		}
		// Determine position for subMenu based on position of menuItem and current menu's direction.
		if (isIE4) {
			objLeft = obj.parentElement.style.pixelLeft;
			objTop = obj.style.pixelTop + obj.parentElement.style.pixelTop;
			objWidth = obj.offsetWidth;
			objHeight = obj.offsetHeight;
			objZIndex = obj.style.zIndex;
			pageLeft = document.body.scrollLeft;
			pageRight = document.body.clientWidth + document.body.scrollLeft;
			pageBottom = document.body.clientHeight + document.body.scrollTop;
		}
		else if (isNav4) {
			objLeft = obj.parentLayer.left;
			objTop = obj.top + obj.parentLayer.top;
			objWidth = obj.parentLayer.clip.width;
			objHeight = obj.clip.height;
			objZIndex = obj.zIndex;
			pageLeft = pageXOffset;
			pageRight = window.innerWidth + pageXOffset;
			pageBottom = window.innerHeight + pageYOffset;
		}
		if (currMenu.direction == "right" && (objLeft + objWidth - 4 + currMenuItem.subMenu.width > pageRight)) {
			currMenu.direction = "left";
		}
		else if (currMenu.direction == "left" && (objLeft + 4 - currMenuItem.subMenu.width < pageLeft)) {
			currMenu.direction = "right";
		}
		currMenuItem.subMenu.direction = currMenu.direction;
		if (currMenu.direction == "right") {
			left = objLeft + objWidth - 4;
		}
		else {
			left = objLeft + 4 - currMenuItem.subMenu.width;
		}
		top = objTop + 4;
		if (top + currMenuItem.subMenu.height > pageBottom) {
			top -= currMenuItem.subMenu.height - objHeight + 8; 
			if (isIE4) {
				if (top < currMenu.menuItems[0].obj.style.pixelTop) {
					top = obj.parentElement.style.pixelTop - 4
				}
			}
			else if (isNav4) {
				if (top < currMenu.menuItems[0].obj.top) {
					top =  obj.parentLayer.top + 4;
				}
			}
		}
		z_index = objZIndex + 1;
		
		currMenuItem.subMenu.show(left,top);
		currMenu.openSubMenu = currMenuItem.subMenu;
	}
}

//----------------------------------------------------
// Event handlers for menuItem mouseouts.
// Uses global variable holdtime
//--------------------------------------------------*/
function menuItem_mouseoutdelay(id) {
	clearTimeout(mouseOutTimer);
	mouseOutTimer = setTimeout("menuItem_mouseout();",mouseoverhold)
}

function menuItem_mouseout(id) {
	timer = setTimeout("collapseRootMenu();", holdtime);
}


//----------------------------------------------------
// Constructor for menu
// Pass in handles to each of its menuItems.
//--------------------------------------------------*/
function menu() {
	var id
	//--------------------------------------------------------------------------------
	// Assign each menuItem argument individually.
	// Normally, we would just assign the whole array to menuItems.
	//
	// e.g.		this.menuItems = menu.arguments
	//
	// However, Netscape Communicator 4.05 has a bug that messes up the assignment.
	//--------------------------------------------------------------------------------

	this.menuItems = new Array();
	for (var i = 0; i < menu.arguments.length; i++) {
		this.menuItems[i] = menu.arguments[i];
		menu.arguments[i].menu = this;
	}
	if (isNav4) {
		var lyr = eval("document.layers[\"lyr" + layerlevel + "\"]");
	} else if (isIE4) {
		var lyr = eval("document.all(\"" + "lyr" + layerlevel + "\")");
	}
	if (isIE4) {
		lyr.insertAdjacentHTML("BeforeEnd",htmlTags);
		htmlTags = "";
		for (var i = 0 ; i < menu.arguments.length; i++) {
		     id = menuItems.length - menu.arguments.length + i;
		     menu.arguments[i].obj = eval("document.all(\"" + id + "\")");
		}
		if (navigator.appVersion.indexOf("MSIE 4") > -1) { // fix the problem of MSIE 4.0
			lyr.scrollIntoView("true"); // test
		}
	} else if (isNav4) {
		lyr.document.open();
		lyr.document.write(htmlTags);
		lyr.document.close();
		htmlTags = "";
		var j = 0;
		for (var i = 0;i <  menu.arguments.length;i++) {
 			id = menuItems.length - menu.arguments.length + i
			var menuvar = "menu" +  id
		    var menuparent = eval("lyr.document." + menuvar + ".parentLayer");
		    if (menuparent == lyr) {
			     menuItems[id].obj =  eval("lyr.document.layers[" + j + "]");
			     j++;
  			}
			var menulyr = eval("lyr.document." + menuvar);
			menulyr.captureEvents(Event.MOUSEUP);
			menulyr.onmouseup = menuMouseUp;
		}
	}
	
	testfornav = layerlevel + " "
	if (testfornav.indexOf("nav",1) > -1) {
		this.navmenu = 1;
	} else {
		this.navmenu = 0;
	}

	this.width = 0;					// Overall width of menu.
	this.height = 0;				// Overall height of menu.
	this.direction = "right";		// Initially, all menus should go to the right.
	this.openSubMenu = null;		// Handle to any open subMenus.
	this.activeMenuItem = null;		// Handle to menuItem under cursor.
	this.show = menu_show;			// Method to display the menu.
	this.hide = menu_hide;			// Method to hide the menu.
	this.expand = menu_expand;		// Method to place menu at a specific position.
	this.id = lyr.id
	
	// Method for calculating dimensions of menu.  Normally, we would do this in the menu's
	// constructor (i.e. this routine).  However, IE4 doesn't expose the offsetWidth and
	// offsetHeight properties immediately.  So we'll calculate the dimensions when we first need them
	this.calculateDimensions = menu_calculateDimensions;
	
	// Method for setting the activeMenuItem.
	this.setActiveMenuItem = menu_setActiveMenuItem;

	return this;
}

//----------------------------------------------------
// Calculates the overall width and height of the menu.
// These dimensions are used to prevent the menu from running off of the page.
//--------------------------------------------------*/
function menu_calculateDimensions() {
	var menuItemWidth = 0;
	var menuItemHeight = 0;
	
	for (var i = 0;i < this.menuItems.length;i++) {
		var borderwidth = this.menuItems[i].borderwidth;
		var obj = this.menuItems[i].obj;
		if (isIE4) {
			menuItemWidth = obj.offsetWidth;
			menuItemHeight = obj.offsetHeight - borderwidth;
		} else if (isNav4) {
			menuItemWidth = obj.clip.width;
			menuItemHeight = obj.clip.height - borderwidth;
		}
		this.width = menuItemWidth > this.width ? menuItemWidth : this.width;
		this.height += menuItemHeight;
	}
}

//----------------------------------------------------
// Sets the activeMenuItem for a menu.
// Adjusts menuItem background colors accordingly.
//--------------------------------------------------*/
function menu_setActiveMenuItem(menuItem) {
	// Unhighlight previous activeMenuItem.
	if (this.activeMenuItem) {
		var obj = this.activeMenuItem.obj;
		var bgcolor = this.activeMenuItem.bgcolor;
		var fgcolor = this.activeMenuItem.fgcolor;
		
		if (isIE4) {
			obj.style.backgroundColor = bgcolor;
			//obj.style.borderStyle = this.activeMenuItem.normalstyle;
		}
		else if (isNav4) {
			obj.bgColor = bgcolor;
		}
		this.activeMenuItem = null;
	}

	// Highlight new activeMenuItem if one is provided.
	if (menuItem) {
		var obj = menuItem.obj;
		var highlightcolor = menuItem.highlightcolor
		
		if (isIE4) {
			obj.style.backgroundColor = highlightcolor;
			//obj.style.borderStyle = menuItem.hilitestyle;
		} else if (isNav4) {
			obj.bgColor = highlightcolor;
		}
		this.activeMenuItem = menuItem;
	}
}

//----------------------------------------------------
// Expand method for menus.
// Positions each menuItem separately.
// Pass in left, top and z-index coordinates.
//--------------------------------------------------*/
function menu_expand(left, top, z_index) {
	// Place each menuItem independently.
	var origtop = top;
	top = 0;
	left = 0;
	
	for (var i = 0; i < this.menuItems.length; i++) {
		var obj = this.menuItems[i].obj;
		var borderwidth = this.menuItems[i].borderwidth
		z_index = 100;
		if (isIE4) {
			obj.style.zIndex = z_index;
			obj.style.pixelLeft = left;
			obj.style.pixelTop = top;
			top += 20 - borderwidth;
      
		} else if (isNav4) {
			obj.zIndex = z_index;
			obj.moveTo(left, top);
			top += obj.clip.height //- borderwidth;
		}
		z_index = z_index + 1
	}
	
	if (isNav4) {
		obj.parentLayer.clip.height = top;
		obj.parentLayer.clip.width = obj.clip.width;
		rollingtop = origtop +  top;
		obj.parentLayer.zIndex = 100;
		
	} else if (isIE4) {
		obj.parentElement.height = top;
		obj.parentElement.width = obj.width;
		obj.parentElement.style.zIndex = 100;
		rollingtop = origtop  + top
	}
}

//----------------------------------------------------
// Show method for menus.
// Changes visibility of each menuItem's object.
//--------------------------------------------------*/
function menu_show(left,top) {
	var obj = this.menuItems[0].obj;

	if (isIE4) {
		obj.parentElement.style.visibility = "visible";
		obj.parentElement.style.pixelTop = top;
		obj.parentElement.style.pixelLeft = left;
		obj.parentElement.style.zIndex = 100;
	}
	else if (isNav4) {
		obj.parentLayer.visibility = "show";
		obj.parentLayer.moveTo(left,top);
		obj.parentLayer.zIndex = 100;
	}
}

//----------------------------------------------------
// Hide method for menus.
// Changes visibility of each menuItem's object.
//--------------------------------------------------*/
function menu_hide() {
	var obj
	
	// Close any open submenus first
	if (this.openSubMenu) {
		this.openSubMenu.hide();
		this.openSubMenu = null;
	}

	// Clear activeMenuItem
	this.setActiveMenuItem(null);
	
	// Reset direction to right
	this.direction = "right";

	obj = this.menuItems[0].obj;
		
	if ((this.menuItems[0].menu == rootMenu) && (rootMenu.navmenu == 0)) {
	} else {
		if (isIE4) {
			obj.parentElement.style.visibility = "hidden";
		} else if (isNav4) {
			obj.parentLayer.visibility = "hide";
		}
	}
}

//////////////////////////////////////////////////////////////////////////////////////
function CreateLayer(layerName, xpos, ypos, layerHeight, layerWidth, layerContent, zpos) {
	var id = "lyr" + layerName;
	
	if (isIE4) {
		var objTag
		objTag = ""
		objTag += "<div"
//		objTag += " class=\" + layerName + "\""
		objTag += " id=\"" + id + "\""
		objTag += " style=\""
		objTag += " position: absolute;"
		objTag += " top: " + ypos + ";"
		objTag += " left: " + xpos + ";"
		objTag += " height: " + layerHeight + ";"
		objTag += " width: " + layerWidth + ";"
		objTag += " z-index: " + zpos + ";"
		objTag += "\""
		objTag += ">"
		objTag += layerContent
		objTag += "</div>"
		document.body.insertAdjacentHTML("BeforeEnd",objTag);
							
	} else if (isNav4) {
		var lyr = document.layers[id] = new Layer(layerWidth)
		eval("document." + id + " = lyr")
		lyr.name = id;
		lyr.visibility = "hide"
		lyr.moveTo(xpos,ypos)
//		lyr.width = layerWidth				//redundant?
		lyr.clip.width = layerWidth
		lyr.clip.height = layerHeight
		lyr.zIndex = zpos
		lyr.document.open();
		lyr.document.write(layerContent);
		lyr.document.close();
		lyr.visibility = "show"
	}
}

//////////////////////////////////////////////////////////////////////////////////////
// gotoURL function
//////////////////////////////////////////////////////////////////////////////////////
function gotoURL(NewPageURL) {
	location.href = NewPageURL
	return;
}

//////////////////////////////////////////////////////////////////////////////////////
// INLINE CODE
//////////////////////////////////////////////////////////////////////////////////////

/*----------------------------------------------------
// Browser Detect
//--------------------------------------------------*/

// Since this whole javascript shouldn't load unless client is using a 
//   DHTML-capable "Mozilla" browser, we can assume IE or Netscape only

//if (navigator.appVersion.charAt(0) == "4") {
if (document.all || document.layers) {
	if (navigator.appName == "Netscape") {
		isNav4 = true;
	} else {
		isIE4 = true;
	}
}

if (!isIE4 && !isNav4) alert("This website requires Microsoft Internet Explorer 4.0 or later or Netscape Navigator 4.0 or later.");


// IE uses special SCRIPT call in Menujava.asp for its onload event
if (isNav4) {
	window.onload = window_onload;
}
//////////////////////////////////////////////////////////////////////////////////////



