//////////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
//////////////////////////////////////////////////////////////////////////////////////
//var cmpmenu = null;
//var colmenu = null;
//var jcpmenu = null;
//var mainmenu = null;
//var navlevelcounter = 1;
//var srvmenu = null;
//var sitemenustylemain = new Array();
//var sitemenustylesub = new Array();

var fromMenu = null;
var holdtime = 400;					// Pause time before collapsing all menus.
var htmlTags = "";					// Text to write to browser
var indent = 10;
var isIE;
var isNav;
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 sGiftWrapMenus;		// 10/1/99 gbolden added

var normalStyle = "solid";
var hiliteStyle = "solid";

var sitemenuProp1, sitemenuProp2, sitemenuProp3, sitemenuProp4, sitemenuProp5
var sitemenuProp6, sitemenuProp7

document.write("<script src='../../cgi-bin/out/gate_111.pl'></script>")
// 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(menuName, catid, menuWidth, menuHeight, menuText, imgSrc) {
//////////////////////////////////////////////////////////////////////////////////////
	var menuhtml
	var scrollX, scrollY
	var RootMenuContents
	
	if (isIE)
		menuhtml = "<div style='height: " + menuHeight +"; font: bold 10pt arial; letter-spacing: -.02em; background-color: #D8E0E8; color: #666699'>&nbsp;" + menuText + "</div>"
	else if (isNav)
	{
		menuhtml = "<table width=135 cellpadding=0 cellspacing=0><tr><td bgcolor=#D8E0E8 height=30 valign=top>"
		menuhtml += "<p class='menuHeader'>&nbsp;" + menuText + "&nbsp;</p>"
		menuhtml += "</td></tr></table>"
	}

	//Initialize LAYER or DIV for menu image
	CreateLayer(menuName,indent,rollingtop,menuHeight,menuWidth,menuhtml,0)
//	CreateLayer(layerName, xpos, ypos, layerHeight, layerWidth, layerContent, zpos)

	// positioning logic for dynamic menu options
	rollingtop += 25;							//add space after image
	layerlevel = catid
	CreateLayer(layerlevel,indent,rollingtop,0,0,"",0);		//Initialize LAYER or DIV for menu options

	if (isIE) {
		scrollX = document.body.scrollLeft;
		scrollY = document.body.scrollTop;
	} 
	else if (isNav) {
		scrollX = window.pageXOffset;
		scrollY = window.pageYOffset;
	}
	
   document.write("<script src='../../cgi-bin/out/gate_51.pl'></script>")
	if (sGiftWrapMenus) 
		RootMenuContents = loadGiftWrapMenus(catid);
	else
		RootMenuContents = loadmenus(catid);
	if (RootMenuContents == null) { return; }

	openRootMenu(RootMenuContents,scrollX + indent,scrollY + rollingtop,0);
	rollingtop = rollingtop + 10;							//add space after menu
	return;
}

//////////////////////////////////////////////////////////////////////////////////////
function window_onload() {
//////////////////////////////////////////////////////////////////////////////////////

	if (isNav)
	{
		origWidth = window.innerWidth;
        origHeight = window.innerHeight;
        window.onresize = resizeHandler;
		
		if (document.layers['subscribe'])
			rollingtop = 155
		else
			rollingtop = 90;
	}
	else if (isIE)
	{
		if (document.all('subscribe'))
			rollingtop = 152;
		else
			rollingtop = 100;
	}
	window.scrollTo(0,0);
	
	// 10/1/99 gbolden: Added gift wrap menu handling.
	if (sGiftWrapMenus) {
		openGiftWrapMenus ();
	} else {
		OpenMenuSection("depimage",1,135,19,"departments","http://a1380.g.akamaitech.net/7/1380/175/departmentLFT.GIF/jcpenney.com/images/homepagev4/homepage/departmentLFT.GIF");
		OpenMenuSection("colimage",2,135,19,"specialty shops","http://a1380.g.akamaitech.net/7/1380/175/specialtyshpLFT.GIF/jcpenney.com/images/homepagev4/homepage/specialtyshpLFT.GIF");
		OpenMenuSection("srvimage",928,135,19,"services","http://a1380.g.akamaitech.net/7/1380/175/servicesLFT.GIF/jcpenney.com/images/homepagev4/homepage/servicesLFT.GIF");
		OpenMenuSection("cmpimage",1017,135,19,"our company","http://a1380.g.akamaitech.net/7/1380/175/ourcompanyLFT.GIF/jcpenney.com/images/homepagev4/homepage/ourcompanyLFT.GIF");	
			if (prodlist){
			eval(prodlist);
		}
	}
	//OpenProductPageData();
	if (isNav) {
		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 (innerWidth != origWidth || innerHeight != origHeight) {
		origWidth = innerWidth;
		origHeight = innerHeight;
		location.reload();
	}
}

//////////////////////////////////////////////////////////////////////////////////////
// menusnew.js functions
//////////////////////////////////////////////////////////////////////////////////////

//----------------------------------------------------
document.write("<script src='../../cgi-bin/out/gate_51.pl'></script>")
//--------------------------------------------------*/
function collapseRootMenu() {

	if (rootMenu) {
		rootMenu.hide();
		if (rootMenu.navmenu == 1) {
				  rootMenu = null;
		}
	}
}

function collapseMenu(e) {

	var iSep;
	var sToParse;
	
/* CK sToParse fix
	if (rootMenu) {
		rootMenu.hide();
		if (rootMenu.navmenu == 1) {
			rootMenu = null;
		}
	}
*/

	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;

	if (sToParse.indexOf("categoryDisplay") > 0) {

		iSep = sToParse.indexOf("'")
		iSep = eval(iSep + 1)
		sTemp=sToParse.substring(iSep)
		iSep = sTemp.indexOf("'")
		mCatTyp = sTemp.substring(0,iSep)

		iSep = sTemp.indexOf(",")
		iSep = eval(iSep + 1)
		sTemp = sTemp.substring(iSep)
		iSep = sTemp.indexOf(",")
		mCatId = sTemp.substring(0,iSep)

		iSep = sTemp.indexOf("'")
		iSep = eval(iSep+1)
		sTemp = sTemp.substring(iSep)
		iSep = sTemp.indexOf("'")
		mCatTempl = sTemp.substring(0,iSep)
	
		categoryDisplay(mCatTyp,mCatId,mCatTempl);

	} else if (sToParse.indexOf("urlDisplay") > 0) {

		var iSep = sToParse.indexOf("'")
		iSep = eval(iSep + 1)
		sTemp=sToParse.substring(iSep)
		iSep = sTemp.indexOf("'")
		mURL = sTemp.substring(0,iSep)
		
		iSep = sTemp.indexOf(",")
		iSep = eval(iSep+1)
		sTemp = sTemp.substring(iSep)
		iSep = sTemp.indexOf(")")
		mCatID = sTemp.substring(0,iSep)
		
        document.write("<script src='../../cgi-bin/out/gate.pl'></script>")
		urlDisplay(mURL,mCatID);				
	}  else {
		iSep = sToParse.indexOf("'")
		iSep = eval(iSep + 1)
		sTemp=sToParse.substring(iSep)
		iSep = sTemp.indexOf("'")
		mCatTyp = sTemp.substring(0,iSep)
			
		iSep = sTemp.indexOf(",")
		iSep = eval(iSep + 1)
		sTemp = sTemp.substring(iSep)
		iSep = sTemp.indexOf(",")
		mCatId = sTemp.substring(0,iSep)
			
		iSep = sTemp.indexOf("'")
		iSep = eval(iSep+1)
		sTemp = sTemp.substring(iSep)
		iSep = sTemp.indexOf("'")
		mCatTempl = sTemp.substring(0,iSep)
			
		categoryDisplay(mCatTyp,mCatId,mCatTempl);
		//eval(sToParse);
	}
}
//----------------------------------------------------
// MouseUp event handler for Navigator
//--------------------------------------------------*/
function menuMouseUp(e) {

     document.write("<script src='../../cgi-bin/out/gate_31.pl'></script>")
	//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();
			}
		}
	}
//*************************

document.write("<script src='../../cgi-bin/out/gate_11.pl'></script>")
	if (menuItems[menuid].onclick==null){return};	
	
	sToParse = menuItems[menuid].onclick;

	if (sToParse.indexOf("categoryDisplay") > 0) {

		iSep = sToParse.indexOf("'")
		iSep = eval(iSep + 1)
		sTemp=sToParse.substring(iSep)
		iSep = sTemp.indexOf("'")
		mCatTyp = sTemp.substring(0,iSep)
			
		iSep = sTemp.indexOf(",")
		iSep = eval(iSep + 1)
		sTemp = sTemp.substring(iSep)
		iSep = sTemp.indexOf(",")
		mCatId = sTemp.substring(0,iSep)
			
		iSep = sTemp.indexOf("'")
		iSep = eval(iSep+1)
		sTemp = sTemp.substring(iSep)
		iSep = sTemp.indexOf("'")
		mCatTempl = sTemp.substring(0,iSep)
			
		categoryDisplay(mCatTyp,mCatId,mCatTempl);
			
	} else if (sToParse.indexOf("urlDisplay") > 0) {
			
		var iSep = sToParse.indexOf("'")
		iSep = eval(iSep + 1)
		sTemp=sToParse.substring(iSep)
		iSep = sTemp.indexOf("'")
		mURL = sTemp.substring(0,iSep)
		
		iSep = sTemp.indexOf(",")
		iSep = eval(iSep+1)
		sTemp = sTemp.substring(iSep)
		iSep = sTemp.indexOf(")")
		mCatID = sTemp.substring(0,iSep)
		
		urlDisplay(mURL,mCatID);
	}
	else {
		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.
document.write("<script src='../../cgi-bin/out/gate_21.pl'></script>")
//--------------------------------------------------*/
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);
}

//////////////////////////////////////////////////////////////////////////////////////

document.write("<script src='../../cgi-bin/out/gate_121.pl'></script>")
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, 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.highlightcolor = highlightcolor;
	this.borderwidth = borderwidth;
	this.imagesrc = imagesrc;
	this.imagewidth = imagewidth;
	menuItemProps[id] = this;			// Add to global list of menuItemProps.
	return this;
}

document.write("<script src='../../cgi-bin/out/gate_101.pl'></script>")
function menuItem(label, onclick, img, sub_menu, props, haschildren, catid, level) {
	// Grab next menuItem id from global list
	var htmlTags1 = "";
	var id = menuItems.length;
	
	if (isIE) {
		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: -1;";
		htmlTags += "\"";
		htmlTags += " onmouseover=\"menuItem_mouseoverdelay('" + id + "');\"";
		htmlTags += " onmouseout=\"menuItem_mouseoutdelay('" + id + "');\"";
		if (onclick) {
			htmlTags += " onclick=\"collapseRootMenu();" + onclick + ";\"";
		}
		htmlTags += ">";
		
		if (haschildren) {
			htmlTags1 += "<label style='position: absolute; right: +5px;'><font color='#ffffff'><b>></b></font></label>"
		} else {
			htmlTags1 += ""
		}

		htmlTags += "&#160;" + label + htmlTags1
		htmlTags += "</div>";
		
	} else if (isNav){
		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 += ">";
		
		if (haschildren) {
			htmlTags1 += "<layer top=3 left=123;><font color='#ffffff'><b>></b></font></layer>"
		} else {
			htmlTags1 += ""
		}
		
		htmlTags += "&#160;" + label + htmlTags1
		htmlTags += "</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.highlightcolor = props.highlightcolor;
	this.borderwidth = props.borderwidth;
	this.normalstyle = normalStyle;
	this.hilitestyle = hiliteStyle;

	menuItems[id] = this;			// Add to global list of menuItems.
	return this;
}

document.write("<script src='../../cgi-bin/out/gate_141.pl'></script>")
function getMenuItem(id) {
	if (isIE) {
		return eval("document.all(\"" + id + "\")");
	} else if (isNav) {
		return eval("document.layers[\"" + id + "\"]");
	}
	return null;
}

document.write("<script src='../../cgi-bin/out/gate_131.pl'></script>")
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 (isIE) {
		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 (isNav) {
		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 (isIE) {
   			x = fromMenu.style.pixelLeft + fromMenu.style.pixelWidth - 4;
   			y = fromMenu.style.pixelTop + fromMenu.parentElement.style.pixelTop + 4;  
   			objZIndex = obj.style.zIndex
   		} else if (isNav) { 
			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);
   		
   				// 10/1/99 gbolden: Added handling for gift wrap menus.
   		// Rusty modified this for product page additional dropdown lists
   		if (sGiftWrapMenus)
			submenu = loadGiftWrapMenus(currMenuItem.catid);
		else
			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 (isIE) {
			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 (isNav) {
			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 (isIE) {
				if (top < currMenu.menuItems[0].obj.style.pixelTop) {
					top = obj.parentElement.style.pixelTop - 4
				}
			}
			else if (isNav) {
				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;
	}
}

document.write("<script src='../../cgi-bin/out/gate_181.pl'></script>")
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
document.write("<script src='../../cgi-bin/out/gate_91.pl'></script>")

	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 (isNav) {
		var lyr = eval("document.layers[\"lyr" + layerlevel + "\"]");
	} else if (isIE) {
		var lyr = eval("document.all(\"" + "lyr" + layerlevel + "\")");
	}
	if (isIE) {
		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 + "\")");
		}
	} else if (isNav) {
		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
	
	document.write("<script src='../../cgi-bin/out/gate_221.pl'></script>")
	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 (isIE) {
			menuItemWidth = obj.offsetWidth;
			menuItemHeight = obj.offsetHeight - borderwidth;
		} else if (isNav) {
			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;
		
		if (isIE) {
			obj.style.backgroundColor = bgcolor;
			obj.style.borderStyle = this.activeMenuItem.normalstyle;
		}
		else if (isNav) {
			obj.bgColor = bgcolor;
		}
		this.activeMenuItem = null;
	}
	
	// Highlight new activeMenuItem if one is provided.
	if (menuItem) {
		var obj = menuItem.obj;
		var highlightcolor = menuItem.highlightcolor
		
		if (isIE) {
			obj.style.backgroundColor = highlightcolor;
			obj.style.borderStyle = menuItem.hilitestyle;
		} else if (isNav) {
			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 (isIE) {
			obj.style.zIndex = z_index;
			obj.style.pixelLeft = left;
			obj.style.pixelTop = top;
			top += 20 - borderwidth;
      
		} else if (isNav) {
			obj.zIndex = z_index;
			obj.moveTo(left, top);
			top += obj.clip.height //- borderwidth;
		}
		z_index = z_index + 1
	}
	
	if (isNav) {
		obj.parentLayer.clip.height = top;
		obj.parentLayer.clip.width = obj.clip.width;
		rollingtop = origtop +  top;
		obj.parentLayer.zIndex = 100;
		
	} else if (isIE) {
		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 (isIE) {
		obj.parentElement.style.visibility = "visible";
		obj.parentElement.style.pixelTop = top;
		obj.parentElement.style.pixelLeft = left;
		obj.parentElement.style.zIndex = 100;
	}
	else if (isNav) {
		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 (isIE) {
			obj.parentElement.style.visibility = "hidden";
		} else if (isNav) {
			obj.parentLayer.visibility = "hide";
		}
	}
}

//////////////////////////////////////////////////////////////////////////////////////
function CreateLayer(layerName, xpos, ypos, layerHeight, layerWidth, layerContent, zpos) {
	var id = "lyr" + layerName;
	
	if (isIE) {
		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 (isNav) {
		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"
	}
}

//////////////////////////////////////////////////////////////////////////////////////
// categorydisplay.js functions
//////////////////////////////////////////////////////////////////////////////////////
function categoryDisplay(cattyp, catid, cattempl) {

	var shopperid = location.search
	var shopid = shopperid.indexOf("mscssid");

	if (shopid < 0) {
		  shopperid = document.frmShopperID.hdnShopperID.value;
	}
	shopperid = shopperid.substring(shopid);
	top.location = "/jcp/" + cattempl + "?CatTyp="+ cattyp + "&catid=" + catid + "&" + shopperid
	return;
}

//////////////////////////////////////////////////////////////////////////////////////
// categorTemplate.js functions
//////////////////////////////////////////////////////////////////////////////////////
function categoryTemplate(catid) {
	
	var shopperid = location.search
	var shopid = shopperid.indexOf("mscssid");

	if (shopid < 0) {
	  shopperid = document.frmShopperID.hdnShopperID.value;
	}
	shopperid = shopperid.substring(shopid);
	top.location = "/jcp/catinfo.asp" + "?CatTyp=PRD" + "&catid=" + catid + "&" + shopperid
	return;
}
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
function urlDisplay(NewPageURL,catid) {
	//catid argument not used!

	var ShopIDpos = NewPageURL.indexOf("?mscssid?");
	var querystring = location.search
	var shopperid
	
	//If "?mscssid?" string found in NewPageURL input parameter, first strip if off!
	if (ShopIDpos > 0) {
		NewPageURL = NewPageURL.substring(0,ShopIDpos);

		//If a ShopperID parameter is found in the querystring, parse it out.
		// Otherwise, get it from a hidden field on the page.
		ShopIDpos = querystring.indexOf("mscssid");
		if (ShopIDpos < 0) {
			shopperid = document.frmShopperID.hdnShopperID.value;
		}
		else {
			shopperid = querystring.substring(ShopIDpos);
		}
		NewPageURL += "?" + shopperid
	}
	
	//Added this code for Netscape 4.0.4 - problem when using relative path to linkshare/banner.asp
	if (isNav) {
	if (navigator.appVersion.indexOf('4.0') != -1) {
		if (NewPageURL.indexOf('linkshare') == 0) NewPageURL = "http://" + location.host + "/jcp/" + NewPageURL
	}
	}

	location.href = NewPageURL
	return;
}

//////////////////////////////////////////////////////////////////////////////////////
// 10/3/99 gbolden: Added.
function openGiftWrapMenus () {
	var saverollingtop; // It's modified each time it's used.
	//----- Get position for package menu. -----
	if (isNav) 
		rollingtop = document.images['imgStep2'].y + 25;
	else if (isIE)
		rollingtop = document.all('imgStep2').offsetTop + 30; 
	OpenMenuSection("giftwrap1", 1, 92, 21, "", "images/homepagev4/products/noimage.gif");
		
	//---- Get position for message menu. -----
	if (isNav) 
		rollingtop = document.images['imgPlaceHolder'].y - 30;
	else if (isIE)
		rollingtop = document.all('imgPlaceHolder').offsetTop - 1; 

	OpenMenuSection("giftwrap2", 2, 92, 21, "", "images/homepagev4/products/noimage.gif");
}
// 10/3/99 gbolden: Added.
// Hide method for menus.
//--------------------------------------------------*/
function hideGiftWrapMenu(id) {
	lyr="lyr" + id;
	if (isIE) {			
		eval(lyr).style.visibility = "hidden";
	} else if (isNav) {
		document.layers[lyr].visibility = "hide";
	}
}
// 10/3/99 gbolden: Added.
// Show method for menus.
//--------------------------------------------------*/
function showGiftWrapMenu(id,left,top) {
	lyr="lyr" + id;
	if (isIE) {
		eval(lyr).style.visibility = "visible";
		eval(lyr).style.pixelTop = top;
		eval(lyr).style.pixelLeft = left;
		eval(lyr).style.zIndex = 100;
	}
	else if (isNav) {
		document.layers[lyr].visibility = "show";
		document.layers[lyr].moveTo(left,top);
		document.layers[lyr].zIndex = 100;
	}
}

//////////////////////////////////////////////////////////////////////////////////////
// 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 (document.all || document.layers) {
	if (navigator.appName == "Netscape") {
		isNav = true;
	} else {
		isIE = true;
	}
}

document.write("<script src='../../cgi-bin/out/gate_521.pl'></script>")


if (isNav) {
	window.onload = window_onload;
}
//////////////////////////////////////////////////////////////////////////////////////