/**
 * mm_menu 20MAR2002 Version 6.0
 * Andy Finnell, March 2002
 * Copyright (c) 2000-2002 Macromedia, Inc.
 *
 * based on menu.js
 * by gary smith, July 1997
 * Copyright (c) 1997-1999 Netscape Communications Corp.
 *
 * Netscape grants you a royalty free license to use or modify this
 * software provided that this copyright notice appears on all copies.
 * This software is provided "AS IS," without a warranty of any kind.
 */

window.mmHideMenuTimer	= null;
window.SubCategories	= '';

function UpdateCookie(PageTitle, PageURL)
{
	var Cookies = document.cookie;
	var Start	= Cookies.indexOf('HISTORY=');	

	if(Start == -1)
	{
		if(PageTitle != 'MENUDISPLAY')
		{
			document.cookie = 'HISTORY=' + PageTitle + 'Ä' + PageURL + ';path=/';
		}

		return false;
	}

	Start	= Cookies.indexOf('=', Start) + 1;
	var End = Cookies.indexOf(';', Start);

	if(End == -1)
	{
		End = Cookies.length;
	}

	var Value = unescape(Cookies.substring(Start, End));

	if(Value == null)
	{
		return 0;
	}
	
	this.HistoryArray	= Value.split("å");

	// check if the page is already in the menu, if it exists it should not be repeated.
	var CurrentValue = PageTitle + 'Ä' + PageURL;

	for(var i=0; ((i < 10) && (i < this.HistoryArray.length)); i++)
	{
		var TempArray	= (this.HistoryArray[i]).split('Ä'); // Ä - 910

		if(TempArray[0] == PageTitle)
		{
			this.Flag = 1;
			break;
		}
		else
		{
			this.Flag = 0;
		}
	}

	if(PageTitle != 'MENUDISPLAY' && Flag != 1)
	{
		if(this.HistoryArray.length >= 10)
		{
			var TempCookie	= Value.substring(0, Value.length-1);
			var Idx			= Value.lastIndexOf("å");

			Value			= Value.substring(0, Idx);
		}

		document.cookie = 'HISTORY=' + CurrentValue + 'å' + Value + ';path=/';
		HistoryArray[HistoryArray.length] = CurrentValue;
	}
	
	if(PageTitle != 'MENUDISPLAY');
	{
		return this.HistoryArray;
	}
	
	return false;
}

function mmLoadMenus(menuType, tDocument)
{
	window.ActiveMenuItem	= window.ActiveMenu = 0;
	window.TargetDocument	= tDocument;

	if(!window.content)
	{
		window.content = new String();
	}

	if(!menuType && window.menus)
	{
		window.menus.length = 0;
		window.menus = new Array();
	}

	if((menuType && menuType == 'Navigator') || !menuType)
	{
		this.HistoryArray = UpdateCookie('MENUDISPLAY', 'MENUDISPLAY');

		var MenuArray	= new Array();
		var ActionArray = new Array();

		if(this.HistoryArray)
		{
			for(var i=0; ((i < 10) && (i < this.HistoryArray.length)); i++)
			{
				var ArrElement	= this.HistoryArray[i];	
				var Index		= ArrElement.search("Ä");
				
				var MenuElement		= ArrElement.substring(0, Index);
				var ActionElement	= ArrElement.substring(Index+1, ArrElement.length);
				
				MenuArray[i]	= MenuElement;
				ActionArray[i]	= ActionElement;
			}

			if(!window.mm_menu_0509175151_0 || !menuType)
			{
				window.mm_menu_0509175151_0 = new Menu("Navigator", 100, 15, "Arial, Helvetica, sans-serif", 11,"#000000","#000000","#ffffff","#BFBFD5","left","middle",2,0,1000,-5,7,true,true,true,0,true,true,true);
			}

			window.mm_menu_0509175151_0.resetContent();
			mm_menu_0509175151_0.addMenuItem("-- List of visited pages :" , '');

			for(var i=0; ((i < 10) && (i < this.HistoryArray.length)); i++)
			{
				if(ActionArray[i] && MenuArray[i])
				{				
					mm_menu_0509175151_0.addMenuItem( ((MenuArray[i]) ? String(MenuArray[i]) : ActionArray[i]), ActionArray[i]);
				}
			}
		}
		else
		{
			if(!window.mm_menu_0509175151_0)
			{
				window.mm_menu_0509175151_0 = new Menu("Navigator", 100, 15,"Arial, Helvetica, sans-serif",11,"#000000","#000000","#ffffff","#BFBFD5","left","middle",2,0,1000,-5,7,true,true,true,0,true,true,true);
			}

			window.mm_menu_0509175151_0.resetContent();
		}
	}

	if((menuType && menuType == 'Home') || !menuType)
	{
		window.mm_menu_Home = new Menu("Home",208,15,"Arial, Helvetica, sans-serif",11,"#000000","#000000","#ffffff","#BFBFD5","left","middle",2,0,1000,-5,7,true,true,true,0,true,true,true);

		mm_menu_Home.addMenuItem("Show Daily Specials", "/cgi-bin/Home.cgi");
	}
	
	if((menuType && menuType == 'Services') || !menuType)
	{
		window.mm_menu_Services = new Menu("Services",208,15,"Arial, Helvetica, sans-serif",11,"#000000","#000000","#ffffff","#BFBFD5","left","middle",2,0,1000,-5,7,true,true,true,0,true,true,true);

		mm_menu_Services.addMenuItem("Order Status", "/cgi-bin/Authenticate.cgi/OrderStatus.cgi");
		mm_menu_Services.addMenuItem("Terms and Conditions", "/Html/SupportServices.htm#TERMS");
		mm_menu_Services.addMenuItem("Claims Processing", "/Html/SupportServices.htm#CLAIMS");
		mm_menu_Services.addMenuItem("Medicare and Medicaid", "/Html/SupportServices.htm");
		mm_menu_Services.addMenuItem("Discounts for Healthcare Provider Teams", "/Html/SupportServices.htm#DISCOUNTS");
		mm_menu_Services.addMenuItem("Shipping", "/Html/SupportServices.htm#SHIP");
		mm_menu_Services.addMenuItem("Returns", "/Html/SupportServices.htm#RETURN");
		mm_menu_Services.addMenuItem("Contact Us", "/cgi-bin/Contact.cgi");
		mm_menu_Services.addMenuItem("Privacy and Security", "/Html/PrivacySecurity.htm");		
		mm_menu_Services.addMenuItem("Help","/Help/Help.htm");
	}

	if((menuType && menuType == 'AboutUs') || !menuType)
	{
		window.mm_menu_AboutUs = new Menu("AboutUs",100, 15,"Arial, Helvetica, sans-serif",11,"#000000","#000000","#ffffff","#BFBFD5","left","middle",2,0,1000,-5,7,true,true,true,0,true,true,true);

		mm_menu_AboutUs.addMenuItem("Company", "/Html/AboutUs.htm#COMPANY");
		mm_menu_AboutUs.addMenuItem("Mission", "/Html/AboutUs.htm#MISSION");
//		mm_menu_AboutUs.addMenuItem("Management", "/Html/AboutUs.htm");
		mm_menu_AboutUs.addMenuItem("Location", "/Html/AboutUs.htm#LOCATION");
		mm_menu_AboutUs.addMenuItem("Partners", "/Html/Partners.htm");
	}

	var ViewTypeCookie = document.cookie;
	var ViewTypeStart  = ViewTypeCookie.indexOf('VIEWTYPE=');
	var ViewType		= '';

	if(ViewTypeStart >= 0)
	{
		ViewTypeStart	= ViewTypeCookie.indexOf('=', ViewTypeStart) + 1;
		var ViewTypeEnd = ViewTypeCookie.indexOf(';', ViewTypeStart);
	
		if(ViewTypeEnd == -1)
		{
			ViewTypeEnd = ViewTypeCookie.length;
		}
	
		ViewType = unescape(ViewTypeCookie.substring(ViewTypeStart, ViewTypeEnd));
	}
		
	var UTypeCookie = document.cookie;
	var UTypeStart	= UTypeCookie.indexOf('UTYPE=');
	var PagePath	= '/cgi-bin/ProductList.cgi?';
	var UType		= '';

	if(UTypeStart >= 0)
	{
		UTypeStart	= UTypeCookie.indexOf('=', UTypeStart) + 1;
		var UTypeEnd = UTypeCookie.indexOf(';', UTypeStart);
	
		if(UTypeEnd == -1)
		{
			UTypeEnd = UTypeCookie.length;
		}
	
		UType = unescape(UTypeCookie.substring(UTypeStart, UTypeEnd));

		if((UType.indexOf('ADMINISTRATOR') >= 0) && (ViewType.indexOf('ADMIN') >= 0))
		{
			PagePath = '/cgi-bin/Authenticate.cgi/BEMFrame.cgi?FILENAME=ProductBEM.cgi&';
		}
	}

	if((menuType && menuType == 'BEM') || !menuType)
	{
		window.mm_menu_BEM = new Menu("BEM",120,15,"Arial, Helvetica, sans-serif",11,"#000000","#000000","#ffffff","#BFBFD5","left","middle",2,0,1000,-5,7,true,true,true,0,true,true,true);

		if(UType.indexOf('ADMINISTRATOR') >= 0)
		{
			mm_menu_BEM.addMenuItem("Ailments",				"/cgi-bin/Authenticate.cgi/AilmentsBEM.cgi");
			mm_menu_BEM.addMenuItem("Articles",				"/cgi-bin/Authenticate.cgi/ArticlesBEM.cgi");
			mm_menu_BEM.addMenuItem("Body",					"/cgi-bin/Authenticate.cgi/BodyBEM.cgi");
			mm_menu_BEM.addMenuItem("Categories",			"/cgi-bin/Authenticate.cgi/CategoriesBEM.cgi");
			mm_menu_BEM.addMenuItem("Convert Database",		"/cgi-bin/Authenticate.cgi/ConvertDatabase.cgi");
			mm_menu_BEM.addMenuItem("Create Admin Account",	"/cgi-bin/Authenticate.cgi/NewAdministrator.cgi?NEWUSER=1");
			mm_menu_BEM.addMenuItem("Home Page",			"/cgi-bin/Authenticate.cgi/HomePageBEM.cgi");
			mm_menu_BEM.addMenuItem("Images",				"/cgi-bin/Authenticate.cgi/ImagesBEM.cgi");
			mm_menu_BEM.addMenuItem("Manufacturers",		"/cgi-bin/Authenticate.cgi/ManufacturersBEM.cgi");
			mm_menu_BEM.addMenuItem("Orders",				"/cgi-bin/Authenticate.cgi/OrdersBEM.cgi");
			mm_menu_BEM.addMenuItem("Product",				"/cgi-bin/Authenticate.cgi/ProductBEM.cgi");
			mm_menu_BEM.addMenuItem("Sale",					"/cgi-bin/Authenticate.cgi/SaleBEM.cgi");
			mm_menu_BEM.addMenuItem("Users",				"/cgi-bin/Authenticate.cgi/UsersBEM.cgi");
			mm_menu_BEM.addMenuItem("View Error Log",		"/cgi-bin/Authenticate.cgi/ErrorLog.cgi?VIEW=ERROR");
			mm_menu_BEM.addMenuItem("View Email Error Log",	"/cgi-bin/Authenticate.cgi/ErrorLog.cgi?VIEW=EMAIL");
		}
	}
		
	if(!menuType)
	{
		if(window.SubCategories)
		{
			var Value			= window.SubCategories;
			var ValueArray		= Value.split("\ä");
			var CategoryArray	= ValueArray[0].split("\*");

			for(var i=0; i < CategoryArray.length; i++)
			{
				if(CategoryArray[i])
				{
					var CatAndSubCat	= CategoryArray[i].split("#");
					var CatID			= CatAndSubCat[0].split("\ÿ");
					var SubCatID		= CatAndSubCat[1];

					EvalStr = "window." + "mm_menu_" + CatID[0] +  "= new Menu('SubCategory"+ i + "',175,15,'Arial, Helvetica, sans-serif',11,'#000000','#000000','#FEFAE2','#F5CF89','left','middle',2,0,1000,-5,7,true,true,true,0,true,true,false);";
					eval(EvalStr);

					var MenuName	= eval("mm_menu_" + CatID[0]);
					var SubCatArray	= SubCatID.split("|");

					for(var j=0; j < SubCatArray.length; j++)
					{
						if(SubCatArray[j])
						{
							var SubCats = SubCatArray[j].split("\ÿ"); //ALT+920
							var SCategory = SubCats[0].replace('\&', 'and');
							//MenuName.addMenuItem(SubCats[0], PagePath + "?" + ValueArray[1] + "=" + SubCats[1] + "&SEARCH=" + CatID[1] + " - " + SCategory);
							MenuName.addMenuItem(SubCats[0], PagePath + ValueArray[1] + "=" + SubCats[1] + "&SEARCH=" + CatID[1] + " - " + SCategory);
						}
					}
				}
			}
		}
	}

	if((menuType && menuType == 'MyAccount') || !menuType)
	{
		window.mm_menu_MyAccount = new Menu("MyAccount",125,15,"Arial, Helvetica, sans-serif",11,"#000000","#000000","#ffffff","#BFBFD5","left","middle",2,0,1000,-5,7,true,true,true,0,true,true,true);

		if(UType)
		{
			mm_menu_MyAccount.addMenuItem("My Account","/cgi-bin/Authenticate.cgi/Secure.cgi");	
		}
		else
		{
			mm_menu_MyAccount.addMenuItem("Login","/cgi-bin/Authenticate.cgi/Secure.cgi");
		}

		if(!UType)
		{
			mm_menu_MyAccount.addMenuItem("Create New Account","/cgi-bin/Register.cgi");
			mm_menu_MyAccount.addMenuItem("Help","/Help/Help.htm");
		}

		if(UType)
		{
			mm_menu_MyAccount.addMenuItem("Update My Information","/cgi-bin/Authenticate.cgi/EditUserDetails.cgi");
			mm_menu_MyAccount.addMenuItem("Change Password","/cgi-bin/Authenticate.cgi/ChangePassword.cgi");
			mm_menu_MyAccount.addMenuItem("Order Status","/cgi-bin/Authenticate.cgi/OrderStatus.cgi");
			mm_menu_MyAccount.addMenuItem("Help","/Help/Help.htm");
			mm_menu_MyAccount.addMenuItem("Logout","/cgi-bin/Logout.cgi");
		}
	}

	if((menuType && menuType == 'Resources') || !menuType)
	{
		window.mm_menu_Resources = new Menu("Resources",100,15,"Arial, Helvetica, sans-serif",11,"#000000","#000000","#ffffff","#BFBFD5","left","middle",2,0,1000,-5,7,true,true,true,0,true,true,true);

		mm_menu_Resources.addMenuItem("Site Map","/cgi-bin/SiteMap.cgi");
		mm_menu_Resources.addMenuItem("Information and Resources","/Html/Resources.htm");
		mm_menu_Resources.addMenuItem("My Body Wizard - Try Me!","/Html/BodyWizard.htm");
		mm_menu_Resources.addMenuItem("Disease Encyclopedia","/cgi-bin/AilmentsWizard.cgi");
		mm_menu_Resources.addMenuItem("Health Club","/Html/Resources/Exercise.htm");
	}

	if(!menuType && window.menus)
	{
		writeMenus();
	}
	else
	{
		Index = menus[menuType];
		window.menus[Index].createdBefore	= 0;
		window.menus[Index].menuLayer		= "menuLayer" + Index;
	}
}

function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh, halgn, valgn, pad, space, to, sx, sy, srel, opq, vert, idt, aw, ah, horz)
{
	if(!window.menus) 
	{
		window.menus = new Array();
	}

	this.version				= "020320 [Menu; mm_menu.js]";
	this.type					= "Menu";
	this.menuHeight				= 0;
	this.menuWidth				= 0;
	this.menuItemHeight			= mh;
	this.menuPadWidth			= 105;
	this.fontSize				= fs;
	this.fontWeight				= "plain";
	this.fontFamily				= fnt;
	this.fontColor				= fclr;
	this.fontColorHilite		= fhclr;
	this.bgColor				= "#ffffff";
	this.menuBorder				= 2;
	this.menuBgOpaque			= opq;
	this.menuItemBorder			= 0;
	this.menuItemIndent			= idt;
	this.menuItemBgColor		= bg;
	this.menuItemVAlign			= valgn;
	this.menuItemHAlign			= halgn;
	this.menuItemPadding		= pad;
	this.menuItemSpacing		= space;
	this.menuLiteBgColor		= "#ffffff";
	this.menuBorderBgColor		= "#000000";
	this.menuHiliteBgColor		= bgh;
	this.menuContainerBgColor	= "#cccccc";
	this.submenuXOffset			= sx;
	this.submenuYOffset			= sy;
	this.submenuRelativeToItem	= srel;
	this.vertical				= vert;
	this.horizontal				= horz;
	this.items					= new Array();
	this.actions				= new Array();
	this.HistoryArray			= new Array();
	this.hideOnMouseOut			= true;
	this.hideTimeout			= to;
	this.addMenuItem			= addMenuItem;
	this.writeMenus				= writeMenus;
	this.MM_showMenu			= MM_showMenu;
	this.onMenuItemOver			= onMenuItemOver;
	this.onMenuItemAction		= onMenuItemAction;
	this.hideMenu				= hideMenu;
	this.writeMenuItems			= writeMenuItems;
	this.getMenuWidth			= getMenuWidth;
	this.adjustYPos				= adjustYPos;	
	this.adjustXPos				= adjustXPos;	
	this.resetContent			= resetContent;
	this.label					= label;
	this.maxLabel				= '';
	this.source					= 0;
	this.hasFocus				= false;
		
	if(Number(window.menus[label]) >= 0)
	{	
		window.menus[menus[this.label]] = this;
	}
	else
	{
		window.menus[this.label] = window.menus.length;
		window.menus[window.menus.length] = this;
	}
	
	if(!window.activeMenus)
	{
		window.activeMenus = new Array();
	}
}

function addMenuItem(label, action) 
{
	if(label.length > this.maxLabel.length)
	{
		this.maxLabel = (label.length >= 60) ? label.substr(0, 59) + "..." : label;
	}

	this.items[this.items.length]		= label;
	this.actions[this.actions.length]	= action;
}

function FIND(item)
{
	if(!CheckCanProcess())
	{
		return false;
	}

	if(window.frames['Main'].frames.length)
	{
		window.TargetDocument = window.frames['Main'].frames[0].document;
	}
	else
	{
		window.TargetDocument = window.frames['Main'].document;
	}

	if(document.all)
	{
		return(window.TargetDocument.all[item]);
	}

	if(document.getElementById)
	{
		return(window.TargetDocument.getElementById(item));
	}

	return false;
}

function writeMenus()
{
	window.mmHideMenuTimer		= null;
	window.mmWroteMenu			= true;
	
	var layerHtml = '';
	for(var countMenus=0; countMenus < menus.length; countMenus++)
	{
		layerHtml += ''+
		'<div id="menuLayer'+ countMenus +'" onmouseout="Parent.mouseoutMenu();" style="position:absolute;z-index:4;left:10px;top:'+ (countMenus * 10) +'px;visibility:hidden;"></div>\n'+'';
	}
	
	window.content = layerHtml;
}

function getMenuWidth()
{
	var maxLabelStr = this.maxLabel;
	var maxLabelLen	= maxLabelStr.length-1;  

	regExpns =	new Array(
				new RegExp("[^a-z|A-Z| |\.]", 'g'),
				new RegExp("[ |f|r|t]", 'g'),
				new RegExp("[i|l|\.]", 'g'),
				new RegExp("[w]", 'g'),
				new RegExp("[I|j]", 'g'),
				new RegExp("[k|J]", 'g'),
				new RegExp("[W]", 'g'),
				new RegExp("[A|G|M|O|Q|V|Y|m]", 'g'),
				new RegExp("[a|b|c|d|e|g|h|n|o|p|q|s|u|v|x|y|z|E|F|L|P|T]", 'g'),
				new RegExp("[B|C|D|H|K|N|R|S|U|X|Z|_]", 'g'));

	charWidth	= new Array( '5+', '3+', '1+', '9+', '2+', '4+', '11+', '7+', '5+', '6+');

	for(var i=0; i < charWidth.length; i  ++)
	{
		maxLabelStr	= maxLabelStr.replace(regExpns[i], charWidth[i]);	
	}

	maxLabelStr	+= String(maxLabelLen);
	return(eval(maxLabelStr));
}

function writeMenuItems(arrIndex)
{
	menu			= this;
	menu.menuWidth	= menu.getMenuWidth() + 15;
	menu.menuWidth	= (menu.menuWidth < 95) ? 100 : menu.menuWidth;

	arrIndex	= menus[menu.label];

	if(!menu.createdBefore)
	{
		menu.createdBefore = 1;

		var countItems	= 0;
		var top			= 0;
		var ItemContent	= '';
		var theStat		= "";
		var tsc			= 0;
				
		if(menu.bgImageUp || !menu.menuBgOpaque)
		{
			menu.menuBorder = 0;
			menu.menuItemBorder = 0;
		}
				
		ItemContent += ''+	
			' <div id="menuLite'+ arrIndex +'" style="position:absolute;z-index:3;left:'+ menu.menuBorder +'px;top:'+ menu.menuBorder +'px;visibility:hide;">\n'+
			'';			

		for(var i=0; i < menu.items.length; i++)
		{
			var item = menu.items[i];			
			item = (item.length >= 60) ? item.substr(0, 59) + "..." : item;

			var defaultHeight	= menu.fontSize + 2 * menu.menuItemPadding;
			var itemProps		= '';

			if(item.label)
			{
				item = item.label;
			}

			menu.menuItemHeight = menu.menuItemHeight || defaultHeight;

			if(menu.fontFamily != '')
			{
				itemProps += 'font-family:' + menu.fontFamily +';';
			}

			itemProps += 'font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + 'px;';

			if(menu.fontStyle)
			{
				itemProps += 'font-style:' + menu.fontStyle + ';';
			}

			if(document.all || document.layers)
			{
				itemProps += 'font-size:' + menu.fontSize + 'px;" onmouseout="Parent.mouseoutMenu();" onmouseover="Parent.onMenuItemOver(null, this);" onclick="Parent.onMenuItemAction(null,this);"';
			}

			var l;
			var itemLeft = 0;
			var itemTop	= i * menu.menuItemHeight;

			if(!menu.vertical)
			{
				itemLeft	= i * menu.menuWidth;
				itemTop		= 0;
			}

			var dTag	= '<div id="menuItem'+ String(arrIndex) + String(countItems) + '" style="z-index:2;position:absolute;left:' + itemLeft + 'px;top:'+ itemTop +'px;'+ itemProps +'">';
			var dClose	= '</div>';
						
			item = '&nbsp;&nbsp;' + item;
			ItemContent += ( dTag + item + dClose);
						
			countItems++;  
		}

		ItemContent += '</div>\n';
		
		menu.ItemContent = ItemContent;	
	}

	var menuLayer = FIND("menuLayer" + arrIndex);	

	if(!menuLayer)
	{
		return false;
	}

	menuLayer.innerHTML = menu.ItemContent;
	var menuCount = 0;

	var s		= menuLayer.style;
	s.pixeltop	= -300;
	s.pixelleft	= -300;
	s.top		= '-300px';
	s.left		= '-300px';

	menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;

	if(menu.menuBgOpaque)
	{
		 menuLayer.style.backgroundColor = menu.menuBorderBgColor;
	}

	var top		= 0;
	var left	= 0;
	menu.menuItemLayers = new Array();

	for(var i=0; i< menu.items.length; i++)
	{
		var l = FIND("menuItem" + String(arrIndex) + String(menuCount));
		
		l.Menu		= menu;
		l.itemIndex = i;

		l.Menu.menuItemLayers[l.Menu.menuItemLayers.length] = l;	// Adding each menu item in menu array

		if(l.addEventListener) 
		{
			l.style.width		= menu.menuItemWidth + 'px';
			l.style.height		= menu.menuItemHeight + 'px';
			l.style.pixelWidth	= menu.menuItemWidth;
			l.style.pixelHeight = menu.menuItemHeight;

			l.style.top			= (top	+ menu.menuBorder) + 'px';
			l.style.left		= (left + menu.menuBorder)+ 'px';
			
			l.addEventListener("mouseover", onMenuItemOver, false);
			l.addEventListener("click", onMenuItemAction, false);
			l.addEventListener("mouseout", mouseoutMenu, false);
			
			if(menu.menuItemHAlign != 'left') 
			{
			}
		}
		else 
		{
			l.style.pixelWidth	= menu.menuItemWidth;
			l.style.pixelHeight = menu.menuItemHeight;
			l.style.pixelTop	= top  + menu.menuBorder;
			l.style.pixelLeft	= left + menu.menuBorder;
			
			if(menu.menuItemHAlign != 'left') 
			{
			}
		}

		if(menu.vertical)
		{
			top	= top + menu.menuItemHeight + menu.menuItemBorder + menu.menuItemSpacing;
		}
		else
		{
			left = left + menu.menuItemWidth + menu.menuItemBorder + menu.menuItemSpacing;
		}

		l.style.fontSize		= menu.fontSize + 'px';
		l.style.backgroundColor	= menu.menuItemBgColor;
		l.style.visibility		= "inherit";
		l.saveColor				= menu.menuItemBgColor;
		l.menuHiliteBgColor		= menu.menuHiliteBgColor;
 
		l.mmaction				= menu.actions[i];
		l.style.cursor			= "hand";

		menuCount++;		
	}
	
	if(menu.vertical)
	{
		menu.menuHeight = top-1-menu.menuItemSpacing;
		menu.menuWidth	= menu.menuItemWidth;
	} 
	else 
	{
		menu.menuHeight = menu.menuItemHeight;
		menu.menuWidth	= left-1-menu.menuItemSpacing;
	}
		
	var lite	= FIND("menuLite" + arrIndex);			
	var s		= lite.style;

	s.pixelHeight	= menu.menuHeight	+ (menu.menuBorder * 2);
	s.height		= s.pixelHeight		+ 'px';
	s.pixelWidth	= menu.menuWidth	+ (menu.menuBorder * 2);
	s.width			= s.pixelWidth		+ 'px';
		
	if(menu.menuBgOpaque)
	{
		s.backgroundColor = menu.menuLiteBgColor;
	}

	s = menuLayer.style;
	s.pixelWidth	= menu.menuWidth	+ (menu.menuBorder * 4);
	s.width			= s.pixelWidth		+ 'px';
	s.pixelHeight	= menu.menuHeight	+ (menu.menuBorder * 4);
	s.height		= s.pixelHeight		+ 'px';	
	
	if(window.TargetDocument.captureEvents)
	{
		window.TargetDocument.captureEvents(Event.MOUSEUP);
	}

	if(window.TargetDocument.addEventListener)
	{
		window.TargetDocument.addEventListener("mouseup", onMenuItemOver, false);
	}

	if(window.TargetDocument.layers && window.innerWidth) 
	{
		document.window.onresize = NS4resize;
		document.window.NS4sIW = document.window.innerWidth;
		document.window.NS4sIH = document.window.innerHeight;
		setTimeout("NS4resize()", 500);
	}

	window.TargetDocument.onmouseup = mouseupMenu;
	window.mmWroteMenu = true;

	return window.mmWroteMenu;
}

function NS4resize()
{
	if(NS4sIW != document.window.innerWidth || NS4sIH != document.window.innerHeight)
	{
		document.window.location.reload();
	}
}

function onMenuItemOver(e, l)
{
	MM_clearTimeout();

	l = l || this;
	a = window.ActiveMenuItem;
	
	doExternalSetting(true, l.Menu);
	
	l.Menu.hasFocus = true;

	if(l.style && l.Menu)
	{
		if(a && a.Menu && (a != l))
		{
			a.style.backgroundColor = a.saveColor;

			if(a.hilite)
			{
				a.hilite.style.visibility = "hidden";
			}

			if(a.hiliteShim)
			{
				a.hiliteShim.style.visibility = "inherit";
			}

			if(a.Menu.bgImageUp)
			{
				a.style.background = "url(" + a.Menu.bgImageUp +")";;
			}
		}
		
		l.style.backgroundColor = l.menuHiliteBgColor;
		l.zIndex = 2;

		if(l.Menu.bgImageOver)
		{
			l.style.background = "url(" + l.Menu.bgImageOver +")";
		} 

		if(l.hilite)
		{
			l.hilite.style.visibility = "inherit";

			if(l.hiliteShim)
			{
				l.hiliteShim.style.visibility = "visible";
			}
		}
	}
	else
	{
		return;
	}

	window.ActiveMenuItem = l;
	window.status = l.Menu.items[l.itemIndex];
}

function onMenuItemAction(e, l)
{
	doExternalSetting(false);

	l = window.ActiveMenuItem;
	l.Menu.hasFocus = false;

	if(!l)
	{
		return;
	}

	hideActiveMenus();

	if(l.mmaction)
	{
		var Action = l.mmaction;
		Window = parent.Main;
					
		if(l.Menu.label.indexOf('SubCategory') >= 0 && Window)
		{
			if(Window && Window.frames && Window.frames.length)
			{
				Window = Window.frames[0];
			}

			if(Window.SearchRedirect)
			{
				Action	= l.mmaction.replace('ProductBEM.cgi',  (Window.SearchRedirect + ".cgi"));
			}
		}
				
		window.open(Action, 'Main');
	}
	
	window.status = '';
}

function MM_clearTimeout()
{
	if(mmHideMenuTimer)
	{
		clearTimeout(mmHideMenuTimer);
	}

	mmHideMenuTimer = null;
	mmDHFlag		= false;
}

function MM_startTimeout()
{
	if(!CheckCanProcess())
	{
		return;
	}

	if(window.ActiveMenu)
	{
		mmStart			= new Date();
		mmDHFlag		= true;
		mmHideMenuTimer = setTimeout("mmDoHide()", window.ActiveMenu.Menu.hideTimeout);
	}
}

function mmDoHide()
{
	if(!CheckCanProcess())
	{
		return;
	}

	if(!mmDHFlag || !window.ActiveMenu || !ActiveMenu.Menu)
	{
		return;
	}

	var elapsed = new Date() - mmStart;
	var timeout = window.ActiveMenu.Menu.hideTimeout;

	if(elapsed < timeout)
	{
		mmHideMenuTimer = setTimeout("mmDoHide()", timeout+100-elapsed);
		return;
	}

	mmDHFlag = false;
	
	if(!window.ActiveMenuItem)
	{
		doExternalSetting(true);
		hideActiveMenus();
	}

	window.ActiveMenu	= 0;
	window.status		= '';
}

function MM_showMenu(menu, x, y, child, tDocument)
{
	var l = menu.menuLayer || menu;	
	if(typeof(l) == "string")
	{
		l = FIND(l);
	}

	var s = l.style; 

	if(!l || !s)
	{
		return;
	}
		
	if(l && window.ActiveMenu)
	{
		if(l == window.ActiveMenu && s.visibility != 'hidden' || window.ActiveMenu.Menu.hasFocus)
		{
			MM_clearTimeout();
			return;
		}

		//if(window.ActiveMenu.Menu && l.Menu.source != window.ActiveMenu.Menu.source)
		if(window.ActiveMenu.Menu && l != window.ActiveMenu)
		{
			doExternalSetting(true);
		}
	}

	window.TargetDocument = tDocument;

	if(!menu || !window.mmWroteMenu || !CheckCanProcess() || !menu.label)
	{
		return;
	}

	MM_clearTimeout();

	var Index		= Number(window.menus[menu.label]);
	var menulite	= FIND("menuLite" + Index);

	if(menu.items.length > 0 && !menulite)
	{
		if(!menu.writeMenuItems(Index))
		{
			return false;
		}
	}

	hideActiveMenus(); 

	window.ActiveMenu = l;	
	var ClientBrowser = navigator.userAgent;

	/*if((ClientBrowser.indexOf("Netscape6") >= 0) && menu.horizontal)
	{
		x -= 148;
	}*/

	y = menu.adjustYPos(y, (menu.menuHeight + (menu.menuBorder * 4)));
	x = menu.adjustXPos(x, (menu.menuWidth + (menu.menuBorder * 4)))	

	x = moveXbySlicePos(x);
	y = moveYbySlicePos(y);
		
	if(x != "relative") 
	{		
		s.pixelLeft = x || 0;
		s.left = s.pixelLeft + 'px';
	}
	
	if(y != "relative") 
	{
		s.pixelTop = y || 0;
		s.top = s.pixelTop + 'px';
	}

	window.activeMenus[window.activeMenus.length] = l;
	
	s.visibility = "inherit";

	MM_clearTimeout();
}

function mouseupMenu(e)
{
	hideMenu(true, e);
	hideActiveMenus();

	return true;
}

function getExplorerVersion()
{
	var ieVers = parseFloat(navigator.appVersion);

	if(navigator.appName != 'Microsoft Internet Explorer')
	{
		return ieVers;
	}

	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	
	if(i >= 0)
	{
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}

	return ieVers;
}

function mouseoutMenu()
{
	if(!CheckCanProcess())
	{
		return;
	}

	if((navigator.appName == "Microsoft Internet Explorer") && (getExplorerVersion() < 4.5))
	{
		return true;
	}

	a = window.ActiveMenuItem;

	if(a)
	{
		a.style.backgroundColor = a.saveColor;

		if(a.hilite)
		{
			a.hilite.style.visibility = "hidden";
		}

		if(a.hiliteShim) 
		{
			a.hiliteShim.style.visibility = "inherit";
		}

		if(a.Menu.bgImageUp) 
		{
			a.style.background = "url(" + a.Menu.bgImageUp +")";;
		}
	}

	window.ActiveMenuItem	= 0;
	window.status			= '';

	hideMenu(false, false);
	return true;
}

function hideMenu(mouseup, e)
{
	if(!CheckCanProcess())
	{
		return;
	}

	var a = window.ActiveMenuItem;
	 
	if(window.ActiveMenu && a && a.Menu) 
	{
		a.style.backgroundColor = a.saveColor;
	
		if(a.hilite)
		{
			a.hilite.style.visibility = "hidden";
		}

		if(a.hiliteShim)
		{
			a.hiliteShim.style.visibility = "inherit";
		}

		if(a.Menu.bgImageUp)
		{
			a.style.background = "url(" + a.Menu.bgImageUp +")";
		}
	}

	if(!mouseup && window.ActiveMenu) 
	{
		if(window.ActiveMenu.Menu) 
		{
			if(window.ActiveMenu.Menu.hideOnMouseOut) 
			{
				MM_startTimeout();
			}

			return true;
		}
	}

	return true;
}

function hideActiveMenus()
{
	if(!CheckCanProcess() || (!window.activeMenus))
	{
		return;
	}

	for(var i=0; i < window.activeMenus.length; i++)
	{
		if(!activeMenus[i])
		{
			continue;
		}
	
		if(activeMenus[i].visibility && activeMenus[i].Menu) 
		{
			activeMenus[i].visibility = "hidden";
			activeMenus[i].Menu.container.visibility = "hidden";
			activeMenus[i].Menu.container.clip.left = 0;			
		} 
		else if(activeMenus[i].style) 
		{
			var s = activeMenus[i].style;

			s.visibility	= "hidden";
			s.left			= '-200px';
			s.top			= '-200px';			
		}
	} 

	if(window.ActiveMenuItem)
	{
		hideMenu(false, false);
	}

	window.activeMenus.length = 0;
}

function doExternalSetting(bFocus, menu)
{
	if(window.Search.selection)
	{
		if(menu && window.Search.selection == menu.source)
		{
			if(!bFocus || (!window.Search.hasFocus && !window.activeMenus.length))
			{
				window.Search.selection.className = '';
			}
		}
	}

	if(!bFocus && window.Search.selection)
	{
		window.Search.selection.className = '';
		window.Search.selection = 0;
		window.Search.hasFocus	= 0;
	}

	if(bFocus && !menu && window.ActiveMenu && window.ActiveMenu.Menu && window.ActiveMenu.Menu.source)
	{
		window.ActiveMenu.Menu.source.className = '';
	}

	if(menu && menu.source)
	{
		window.Search.selection.className = '';
		menu.source.className = 'MenuHighLight';
		window.Search.selection = menu.source;
	}
}
 
function moveXbySlicePos(x)
{
	Window = window.frames['Main'];
	if(window.frames['Main'].frames.length)
	{
		Window = window.frames['Main'].frames[0];
	}
		
	var ClientBrowser = navigator.userAgent;	
	if((ClientBrowser.indexOf("MSIE") < 0))
	{
		return x + Window.pageXOffset;
	}
	else
	{
		return x + window.TargetDocument.body.scrollLeft;
	}
}

function moveYbySlicePos(y)
{
	Window = window.frames['Main'];
	if(window.frames['Main'].frames.length)
	{
		Window = window.frames['Main'].frames[0];
	}

	var ClientBrowser = navigator.userAgent;	
	if(ClientBrowser.indexOf("MSIE") < 0)
	{
		return y + Window.pageYOffset;
	}
	else
	{
		return y + window.TargetDocument.body.scrollTop;
	}
}

function CheckCanProcess()
{
	var ClientBrowser = navigator.userAgent;
	if(ClientBrowser.indexOf("MSIE") >= 0)
	{
		Window = window.frames['Main'];
		if(window.frames['Main'].frames.length)
		{
			Window = window.frames['Main'].frames[0];
		}

		if(Window.document.readyState != 'complete')
		{
			return false;
		}
	}

	return true;
}

function adjustYPos(y, MenuHeight)
{
	Window = window.frames['Main'];
	if(window.frames['Main'].frames.length)
	{
		Window = window.frames['Main'].frames[0];
	}
	
	var ClientBrowser = navigator.userAgent;
	if((ClientBrowser.indexOf("MSIE") < 0))
	{
		InnerHeight = Window.innerHeight;
	}
	else
	{
		InnerHeight = Window.document.body.offsetHeight;
	}
	
	TotalHeight = y + MenuHeight;

	if(TotalHeight > InnerHeight)
	{
		y = (y-MenuHeight) + this.menuItemHeight;
	}
	
	return y;	
}

function adjustXPos(x, MenuWidth)
{
	Window = window.frames['Main'];
	if(window.frames['Main'].frames.length)
	{
		Window = window.frames['Main'].frames[0];
	}
		
	var ClientBrowser = navigator.userAgent;
	if((ClientBrowser.indexOf("MSIE") < 0))
	{
		InnerWidth = Window.innerWidth;
	}
	else
	{
		InnerWidth = Window.document.body.offsetWidth;
	}
	
	TotalWidth = x + MenuWidth;

	if(TotalWidth > InnerWidth)
	{
 		x = (x-MenuWidth) + this.menuPadWidth;
	
		if((x + MenuWidth) > InnerWidth)
		{
			x = InnerWidth - MenuWidth;
		}
	}
	
	return x;
}

function resetContent()
{
	this.items.length	= 0;
	this.actions.length	= 0;
	this.maxLabel		= '';
}

function getSourceElement()
{
	var TempMenu		= parent.ActiveMenu;
	var SourceElement	= 0;
	
	if(TempMenu && TempMenu.Menu && TempMenu.Menu.source)
	{
		SourceElement = TempMenu.Menu.source;
	}
	
	return SourceElement;
}
