/**
 * fw_menu 24OCT2000 Version 4.0
 * John Ahlquist, October 2000
 * Copyright (c) 2000 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.
 */
function Menu(
	label,
	mw, mh, //Menu item width & height
	fnt, fs, //Font face and size
	fclr, fhclr, //Font colour and active colour
	bg, bgh, //Background and active background
	ibt, ibb, ibl, ibr, //Inner border top, bottom, left, right
	obt, obb, obl, obr, //Outer border top, bottom, left, right
	mib, //Menu item border
	cmi, cmia, cmiw, cmih, //Child menu icon (image or ""), active menu icon, icon width, icon height
	miu, miua, miuw, miuh, //Menu item bullet (image or ""), active menu item bullet, bullet width, bullet height
	ms, msh, footer, //Menu item separator (HTML), separator height, menu footer (HTML)
	cxo, cyo // Child menu X and Y offset
	) {


	this.version = "990702 [Menu; menu.js]";
	this.type = "Menu";
	this.menuWidth = mw;
	this.menuItemHeight = mh;
	this.menuItemIndent = 0;
	this.fontSize = fs||12;
	this.fontWeight = "normal";
	this.fontFamily = fnt||"arial,helvetica,verdana,sans-serif";
	this.fontColor = fclr||"#000000";
	this.fontColorHilite = fhclr||"#000000";
	this.bgColor = "#e1542a";
	this.menuBorder = 10; // Not used (Rodd)
	// Added by Rodd Snook
	this.menuInnerBorderTop    = ibt; //1;
	this.menuInnerBorderBottom = ibb; //0;
	this.menuInnerBorderLeft   = ibl; //1;
	this.menuInnerBorderRight  = ibr; //1;
	this.menuOuterBorderTop    = obt; //0;
	this.menuOuterBorderBottom = obb; //0;
	this.menuOuterBorderLeft   = obl; //0;
	this.menuOuterBorderRight  = obr; //0;
	// End modified section
	this.menuItemBorder = mib; //0;
	this.menuItemBgColor = bg||"#cccccc";
	this.menuLiteBgColor = "#FF0000";
	this.menuBorderBgColor = null;
	this.menuHiliteBgColor = bgh||"#e1542a";
	this.menuContainerBgColor = "";
	this.childMenuIconWidth = cmiw||10;
	this.childMenuIconHeight = cmih||this.menuItemHeight;
	this.childMenuIcon = cmi ? '<img src="'+cmi+'" width="'+cmiw+'" height="'+cmih+'">' : '&raquo;';
	this.childMenuIconActive = cmia ? '<img src="'+cmia+'" width="'+cmiw+'" height="'+cmih+'">' : '&raquo;';
	this.menuItemBulletWidth = miuw||10;
	this.menuItemBulletHeight = miuh||this.menuItemHeight;
	this.menuItemBullet = miu||'images/spacer.gif';
	this.menuItemBulletActive = miua||'images/spacer.gif';
	this.menuSeparator = ms||'';
	this.menuSeparatorHeight = msh||0;
	this.footer = footer||"";
	this.childXOffset = cxo||0;
	this.childYOffset = cyo||0;
	this.items = new Array();
	this.actions = new Array();
	this.childMenus = new Array();

	this.hideOnMouseOut = true;

	this.addMenuItem = addMenuItem;
	this.addMenuSeparator = addMenuSeparator;
	this.writeMenus = writeMenus;
	this.writeSingleMenu = writeSingleMenu;
	this.FW_showMenu = FW_showMenu;
	this.onMenuItemOver = onMenuItemOver;
	this.onMenuItemAction = onMenuItemAction;
	this.hideMenu = hideMenu;
	this.hideChildMenu = hideChildMenu;

	if (!window.menus) window.menus = new Array();
	this.label = label || "menuLabel" + window.menus.length;
	this.index = window.menus.length;
	window.menus[this.label] = this;
	window.menus[this.index] = this;
	if (!window.activeMenus) window.activeMenus = new Array();
}

function addMenuItem(label, action) {
	this.items[this.items.length] = label;
	this.actions[this.actions.length] = action;
}

function addMenuSeparator() {
	this.items[this.items.length] = "separator";
	this.actions[this.actions.length] = "";
	this.menuItemBorder = 0;
}

// For NS6. 
function FIND(item) {
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function writeMenus(container) {
	if (window.triedToWriteMenus) return;

	window.fwHideMenuTimer = null;
	if (!container) return;	
	window.triedToWriteMenus = true; 
	container.isContainer = true;
	container.menus = new Array();
	for (var i=0; i<window.menus.length; i++) 
		container.menus[i] = window.menus[i];

	// *** Insert (empty) DIVs which will hold the menus ***
	var content = '';
	for (var i=0; i<container.menus.length; i++) {
		var menu = container.menus[i];
		if (menu.bgImageUp) {
			menu.menuBorder = 0;
			menu.menuItemBorder = 0;
		}
		content += ''+
		'<DIV ID="menuLayer'+ menu.index +'" STYLE="position:absolute;z-index:1;left:10;top:'+ (i * 100) +';visibility:hidden;"></DIV>\n';
	}
	
	container.innerHTML=content;

	if (!FIND("menuLayer0")) return;
	var menuCount = 0;
	for (var x=0; x<container.menus.length; x++) {
		var menuLayer = FIND("menuLayer" + x);
		container.menus[x].menuLayer = "menuLayer" + x;
		menuLayer.Menu = container.menus[x];
		menuLayer.Menu.container = "menuLayer" + x;
		menuLayer.style.zIndex = 1;
		var s = menuLayer.style;
		s.top = s.pixelTop = -300;
		s.left = s.pixelLeft = -300;
// HACK BY TOAST ESPECIALLY FOR MARTIN
		container.menus[x].writeSingleMenu(container);

	}
	if (document.captureEvents) {	
		document.captureEvents(Event.MOUSEUP);
	}
	if (document.addEventListener) {	
		document.addEventListener("mouseup", onMenuItemOver, false);
	}
	document.onmouseup = mouseupMenu;
	window.fwWroteMenu = true;
	status = "";
}

function writeSingleMenu(container) {
	var menu = this;
	var menuLayer = FIND(menu.menuLayer);
	//var menuLayer = FIND("menuLayer" + menu.index);
	var content = '';
	menu.menuWritten = true;

	if (menu.bgImageUp) {
	  menu.menuBorder = 0;
	  menu.menuItemBorder = 0;
	}
	content += ''+
	  '  <DIV ID="menuLite'+ menu.index +'" STYLE="position:absolute;z-index:1;left:'+ menu.menuOuterBorderLeft +';top:'+ menu.menuOuterBorderTop +';visibility:inherit;" onMouseOut="mouseoutMenu();">\n'+
	  '	 <DIV ID="menuFg'+ menu.index +'" STYLE="position:absolute;left:' + menu.menuInnerBorderLeft + ';top:' + menu.menuInnerBorderTop + ';visibility:inherit;">\n'+
	  '';
	for (var i=0; i<menu.items.length; i++) {
	  var item = menu.items[i];
	  var childMenu = false;
	  var defaultHeight = menu.fontSize+6;
	  var defaultIndent = menu.fontSize;
	  if (item.label) {
	    item = item.label;
	    childMenu = true;
	  }
	  // Changed by Rodd to allow menuItemIndent and friends to be defined as 0
	  //menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
	  menu.menuItemHeight = (typeof menu.menuItemHeight == 'undefined') ? defaultHeight : menu.menuItemHeight ;
	  menu.menuItemIndent = (typeof menu.menuItemIndent == 'undefined') ? defaultIndent : menu.menuItemIndent ;
	  var itemProps = 'font-family:' + menu.fontFamily +';font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + ';';
	  if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
	  if (document.all) 
	    itemProps += 'font-size:' + menu.fontSize + ';" onMouseOver="onMenuItemOver(null,this);" onClick="onMenuItemAction(null,this);';
	  else if (!document.layers) {
	    itemProps += 'font-size:' + menu.fontSize + 'px;'; // zilla wants 12px.
	  }
	  var dTag	= '<DIV ID="menuItem'+menu.index+'_'+i+'" STYLE="position:absolute;left:0;top:'+ ( i * menu.menuItemHeight) +';'+ itemProps +'">';
	  var dClose = '</DIV>'
	    if (menu.bgImageUp) {
	      menu.menuBorder = 0;
	      menu.menuItemBorder = 0;
	      dTag	= '<DIV ID="menuItem'+menu.index+'_'+i+'" STYLE="background:url('+menu.bgImageUp+');position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
	    }
	  /* THE FOLLOWING LINE WAS ADDED BY TOAST FROM GLASSONION TO CENTER TEXT WITHIN LARGE MENUS, CHANGE THE 3 TO A 1 */
	  var textProps = 'position:absolute;left:' + menu.menuItemIndent + ';top:0;';

	  /* THE FOLLOWING 6-8 LINES WERE CHANGED BY TOAST FROM GLASSONION TO USE CUSTOMISED ROLLOVER IMAGES */
	  /* THE DIV THE CHILD MENU IMAGE NORMALLY RESIDES IN IS NOW EMPTY (BUT IT STILL EXISTS), BUT THE OTHER TWO "NORMAL" DIVS ADD THE APPROPRIATE COLOURED ARROW */


	  /* THE FOLLOWING LINE WAS ADDED BY TOAST FROM GLASSONION TO CENTER TEXT WITHIN LARGE MENUS, CHANGE THE 3 TO A 1 */
	  var dText;
	  if(childMenu) {
	    dText = 
	      '<DIV ID="menuItemText'+menu.index+'_'+i+'" STYLE="' + textProps + 'top:0;color:'+ menu.fontColor +';">' +
	      '<table border="0" cellspacing="0" cellpadding="0">' +
	      '<tr>' +
	      '<td><img src="' + menu.menuItemBullet + '" width="' + menu.menuItemBulletWidth + '" height="' + menu.menuItemBulletHeight + '"></td>'+
	      '<td width=" ' + (menu.menuWidth - menu.menuItemIndent - menu.menuItemBulletWidth - menu.childMenuIconWidth) + ' " nowrap style="color: ' + menu.fontColor + ';' + itemProps + '" valign="middle">' + item + '</td>' +
	      '<td width="' + menu.childMenuIconWidth + '" style="color: '+ menu.fontColor +';' + itemProps+'" valign="middle">'+ menu.childMenuIcon + '</td>' +
	      '</tr>';
	    if(i < (menu.items.length - 1)) {
	      dText += menu.menuSeparator;
	    }
	    dText +=
	      '</table>' +
	      '</DIV>\n<DIV ID="menuItemHilite'+menu.index+'_'+i+'" STYLE="' + textProps + 'top:0;color:'+ menu.fontColorHilite +';visibility:hidden;">' +
	      '<table border="0" cellspacing="0" cellpadding="0">' +
	      '<tr>' +
	      '<td><img src="' + menu.menuItemBulletActive + '" width="' + menu.menuItemBulletWidth + '" height="' + menu.menuItemBulletHeight + '"></td>'+
	      '<td width="' + (menu.menuWidth - menu.menuItemIndent - menu.menuItemBulletWidth - menu.childMenuIconWidth) + '" nowrap style="color: '+ menu.fontColorHilite +';' + itemProps+'" valign="middle">'+ item + '</td>' +
	      '<td width="' + menu.childMenuIconWidth + '" style="color: '+ menu.fontColorHilite +';' + itemProps+'" valign="middle">'+ menu.childMenuIconActive + '</td>' +
	      '</tr>';
	    if(i < (menu.items.length - 1)) {
	      dText += menu.menuSeparator;
	    }
	    dText +=
	      '</table>' +
	      '</DIV>';
	  } else {
	    dText =
	      '<DIV ID="menuItemText'+menu.index+'_'+i+'" STYLE="' + textProps + 'top:0;color:'+ menu.fontColor +';">' +
	      '<table border="0" cellspacing="0" cellpadding="0">' +
	      '<tr>' +
	      '<td><img src="' + menu.menuItemBullet + '" width="' + menu.menuItemBulletWidth + '" height="' + menu.menuItemBulletHeight + '"></td>'+
	      '<td width=" ' + (menu.menuWidth - menu.menuItemIndent - menu.menuItemBulletWidth - menu.childMenuIconWidth) + ' " nowrap style="color: ' + menu.fontColor + ';' + itemProps + '">' + item +  '</td>' +
	      '<td style="color: '+menu.fontColor+';" width="10">' +
	      '<img src="images/general/spacer.gif" width="' + menu.childMenuIconWidth + '" height="' + menu.childMenuIconHeight + '">' +
	      '</td>' +
	      '</tr>';
	    if(i < (menu.items.length - 1)) {
	      dText += menu.menuSeparator;
	    }
	    dText +=
	      '</table>' +
	      '</DIV>\n<DIV ID="menuItemHilite'+menu.index+'_'+i+'" STYLE="' + textProps + 'top:0;color:'+ menu.fontColorHilite +';visibility:hidden;">' +
	      '<table border="0" cellspacing="0" cellpadding="0">' +
	      '<tr>' +
	      '<td><img src="' + menu.menuItemBulletActive + '" width="' + menu.menuItemBulletWidth + '" height="' + menu.menuItemBulletHeight + '"></td>'+
	      '<td width="' + (menu.menuWidth - menu.menuItemIndent - menu.menuItemBulletWidth - menu.childMenuIconWidth) + '" nowrap style="color: '+ menu.fontColorHilite +';' + itemProps+'">'+ item + '</td>' +
	      '<td style="color: '+ menu.fontColorHilite +';" width="10">' +
	      '<img src="images/general/spacer.gif" width="' + menu.childMenuIconWidth + '" height="' + menu.childMenuIconHeight + '">' +
	      '</td>' +
	      '</tr>';
	    if(i < (menu.items.length - 1)) {
	      dText += menu.menuSeparator;
	    }
	    dText +=
	      '</table>' +
	      '</DIV>';
	  }

	  if (item == "separator") {
	    content += ( dTag + '<DIV ID="menuSeparator'+menu.index+'_'+i+'" STYLE="position:absolute;left:1;top:2;"></DIV>\n<DIV ID="menuSeparatorLite'+menu.index+'_'+i+'" STYLE="position:absolute;left:1;top:2;"></DIV>\n' + dClose);
	  } else if (childMenu) {
	    content += ( dTag + dText + '<DIV ID="childMenu'+menu.index+'_'+i+'" STYLE="position:absolute;left:0;top:3;"></DIV>\n' + dClose);
	  } else {
	    content += ( dTag + dText + dClose);
	  }
	}
	content += '	  <DIV ID="focusItem'+ menu.index +'" STYLE="position:absolute;left:0;top:0;visibility:hidden;" onClick="onMenuItemAction(null,this);">&nbsp;</DIV>\n';
	content += '   </DIV>\n</DIV>\n<DIV ID="curvyBit' + menu.index +'" STYLE="position:absolute;left:0;top:' + (menu.items.length * (menu.menuItemHeight+menu.menuSeparatorHeight+menu.menuItemBorder) - menu.menuSeparatorHeight) +';z-index: 1;">' + menu.footer + '</DIV></DIV>\n';

	// *** Write the HTML for the menus ***
	menuLayer.innerHTML = content;

	// *** Format the newly drawn menus ***
	container.menus[menu.index].menuLayer = "menuLayer" + menu.index;
	menuLayer.Menu = container.menus[menu.index];
	menuLayer.Menu.container = "menuLayer" + menu.index;
	menuLayer.style.zIndex = 1;
	var s = menuLayer.style;
	s.top = s.pixelTop = -300;
	s.left = s.pixelLeft = -300;
	menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
	menuLayer.style.backgroundColor = menu.menuBorderBgColor;
	var top = 0;
	for (var i=0; i<menu.items.length; i++) {
	  var l = FIND("menuItem"+menu.index+'_'+i);
	  l.Menu = container.menus[menu.index];
	  if (l.addEventListener) { // ns6
	    l.style.width = menu.menuItemWidth;	
	    l.style.height = menu.menuItemHeight;
	    l.style.top = top;
	    l.addEventListener("mouseover", onMenuItemOver, false);
	    l.addEventListener("click", onMenuItemAction, false);
	    l.addEventListener("mouseout", mouseoutMenu, false);
	  } else { //ie
	    l.style.pixelWidth = menu.menuItemWidth;	
	    l.style.pixelHeight = menu.menuItemHeight;
	    l.style.pixelTop = top;
	  }
	  top = top + menu.menuItemHeight+menu.menuItemBorder+menu.menuSeparatorHeight;
	  l.style.fontSize = menu.fontSize;
	//l.style.backgroundColor = menu.menuItemBgColor;
	  l.style.backgroundImage = 'url('+menu.menuItemBgColor+')';
	  l.style.visibility = "inherit";
	//l.saveColor  = menu.menuItemBgColor;
	  l.saveColor  = 'url('+menu.menuItemBgColor+')';
	//l.menuHiliteBgColor = menu.menuHiliteBgColor;
      l.menuHiliteBgColor = 'url('+menu.menuHiliteBgColor+')';
	  l.action = container.menus[menu.index].actions[i];
	  l.hilite = FIND("menuItemHilite"+menu.index+'_'+i);
	  l.focusItem = FIND("focusItem"+menu.index);
	  l.focusItem.style.pixelTop = l.focusItem.style.top = -30;
	  var childItem = FIND("childMenu"+menu.index+'_'+i);
	  if (childItem) {
	    l.childMenu = menu.items[i].menuLayer;
	    childItem.style.pixelLeft = childItem.style.left = menu.menuItemWidth -11;
	    childItem.style.pixelTop = childItem.style.top =(menu.menuItemHeight /2) -4;
	    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
	  }
	  var sep = FIND("menuSeparator"+menu.index+'_'+i);
	  if (sep) {
	    sep.style.clip = "rect(0 " + (menu.menuItemWidth - 3) + " 1 0)";
	    sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;	
	    sep.style.backgroundColor = menu.bgColor;
	    sep = FIND("menuSeparatorLite"+menu.index+'_'+i);
	    sep.style.clip = "rect(1 " + (menu.menuItemWidth - 3) + " 2 0)";
	    sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;	
	    sep.style.backgroundColor = menu.menuLiteBgColor;
	    l.style.height = l.style.pixelHeight = menu.menuItemHeight/2;
	    l.isSeparator = true
	      top -= (menu.menuItemHeight - l.style.pixelHeight)
	  } else {
	    l.style.cursor = "hand"
	  }
	}
	menu.menuHeight = top - menu.menuItemBorder;
	var lite = FIND("menuLite"+menu.index);
	var s = lite.style;
	s.height = s.pixelHeight = menu.menuHeight + menu.menuInnerBorderTop + menu.menuInnerBorderBottom ;
	s.width = s.pixelWidth = menu.menuItemWidth + menu.menuInnerBorderLeft + menu.menuInnerBorderRight ;
	s.backgroundColor = menu.menuLiteBgColor;

	var body = FIND("menuFg" + menu.index);
	s = body.style;
	s.height = s.pixelHeight = menu.menuHeight;
	s.width = s.pixelWidth = menu.menuItemWidth;
	s.backgroundColor = menu.bgColor;
	s = menuLayer.style;
	s.width = s.pixelWidth  = menu.menuItemWidth + menu.menuOuterBorderLeft + menu.menuOuterBorderRight + menu.menuInnerBorderLeft + menu.menuInnerBorderRight;
	s.height = s.pixelHeight  = menu.menuHeight + menu.menuOuterBorderTop + menu.menuOuterBorderBottom + menu.menuInnerBorderTop + menu.menuInnerBorderBottom;

	if (document.captureEvents) {	
		document.captureEvents(Event.MOUSEUP);
	}
	if (document.addEventListener) {	
		document.addEventListener("mouseup", onMenuItemOver, false);
	}
	document.onmouseup = mouseupMenu;
	window.fwWroteMenu = true;
	status = "";
}

function onMenuItemOver(e, l) {
	FW_clearTimeout();
	l = l || this;
	a = window.ActiveMenuItem;
	if (l.style && l.Menu) {
		if (a) {
			//a.style.backgroundColor = a.saveColor;
			a.style.backgroundImage = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.Menu.bgImageUp) {
				a.style.background = "url(" + a.Menu.bgImageUp +")";;
			}
		} 
		if (l.isSeparator) return;
		//l.style.backgroundColor = l.menuHiliteBgColor;
        l.style.backgroundImage= l.menuHiliteBgColor;

		l.zIndex = 1;  // magic IE 4.5 mac happy doohicky.	jba
		if (l.Menu.bgImageOver) {
			l.style.background = "url(" + l.Menu.bgImageOver +")";
		}
		if (l.hilite) {
			//l.style.backgroundColor = l.menuHiliteBgColor;
			l.style.backgroundImage = l.menuHiliteBgColor;
			l.hilite.style.visibility = "inherit";
		}
		l.focusItem.style.top = l.focusItem.style.pixelTop = l.style.pixelTop;
		l.focusItem.style.zIndex = l.zIndex +1;
		l.Menu.hideChildMenu(l);
	} else {
		return; // not a menu - magic IE 4.5 mac happy doohicky.  jba
	}
	window.ActiveMenuItem = l;
}

function onMenuItemAction(e, l) {
	l = window.ActiveMenuItem;
	if (!l) return;
	hideActiveMenus();
	if (l.action) {
		eval("" + l.action);
	}
	window.ActiveMenuItem = 0;
}

function FW_clearTimeout()
{
	if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
	fwHideMenuTimer = null;
	fwDHFlag = false;
}
function FW_startTimeout()
{
	fwStart = new Date();
	fwDHFlag = true;
	fwHideMenuTimer = setTimeout("fwDoHide()", 1000);
}

function fwDoHide()
{
	if (!fwDHFlag) return;
	var elapsed = new Date() - fwStart;
	if (elapsed < 1000) {
		fwHideMenuTimer = setTimeout("fwDoHide()", 1100-elapsed);
		return;
	}
	fwDHFlag = false;
	hideActiveMenus();
	window.ActiveMenuItem = 0;
}

function FW_showMenu(menu, x, y, child) {
	if(!menu.menuWritten) menu.writeSingleMenu(FIND('menudiv'));
	FW_clearTimeout();
	if (FIND("menuItem" + menu.index + "_0")) { // *** There is at least one item in this menu
		//var l = menu.menuLayer || menu;	
		var l = menu.menuLayer;	
		hideActiveMenus();
		if (typeof(l) == "string") {
			l = FIND(l);
		}
		window.ActiveMenu = l;
		var s = l.style;
		s.visibility = "inherit";
		if (x != "relative") 
			var parentoffset;
			s.left = s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
			if (l.parentElement)
				parentoffset = l.parentElement.offsetLeft;
			else
				parentoffset = l.parentNode.parentNode.offsetLeft;
 			if ((parentoffset + s.pixelLeft + menu.menuWidth + menu.menuInnerBorderLeft + menu.menuInnerBorderRight + menu.menuOuterBorderLeft + menu.menuOuterBorderRight - document.body.scrollLeft) > document.body.clientWidth) {
				s.left = s.pixelLeft = (document.body.clientWidth - parentoffset - ( menu.menuWidth + menu.menuInnerBorderLeft + menu.menuInnerBorderRight + menu.menuOuterBorderLeft + menu.menuOuterBorderRight) + document.body.scrollLeft);
			}
		if (y != "relative") 
			s.top = s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
		l.Menu.xOffset = document.body.scrollLeft;
		l.Menu.yOffset = document.body.scrollTop;
	}
	if (menu) {
		window.activeMenus[window.activeMenus.length] = l;
	}
}

function onMenuItemDown(e, l) {
	var a = window.ActiveMenuItem;
}

function mouseupMenu(e)
{
	hideMenu(true, e);
	hideActiveMenus();
	return true;
}

function mouseoutMenu()
{
	hideMenu(false, false);
	return true;
}


function hideMenu(mouseup, e) {
	var a = window.ActiveMenuItem;
	if (window.ActiveMenu && FIND("menuItem" + window.ActiveMenu.Menu.index + "_0")) {
		if (a) {
			//a.style.backgroundColor = a.saveColor;
			a.style.backgroundImage = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.Menu.bgImageUp) {
				a.style.background = "url(" + a.Menu.bgImageUp +")";;
			}
		}
	}
	if (!mouseup && window.ActiveMenu) {
		if (window.ActiveMenu.Menu) {
			if (window.ActiveMenu.Menu.hideOnMouseOut) {
				FW_startTimeout();
			}
			return(true);
		}
	}
	return(true);
}

function PxToNum(pxStr)
{ // pxStr == 27px, we want 27.
	if (pxStr.length > 2) {
		n = Number(pxStr.substr(0, pxStr.length-2));
		return(n);
	}
	return(0);
}

function hideChildMenu(hcmLayer) {
	FW_clearTimeout();
	var l = hcmLayer;
	for (var i=0; i < l.Menu.childMenus.length; i++) {
		var theLayer = l.Menu.childMenus[i];
		theLayer = FIND(theLayer);
		theLayer.style.visibility = "hidden";
		theLayer.Menu.hideChildMenu(theLayer);
	}

	if (l.childMenu) {
		var childMenu = l.childMenu;
		if (FIND("menuItem"+l.Menu.index+"_0")) {
			childMenu = FIND(l.childMenu);
			if(!childMenu.Menu.menuWritten) childMenu.Menu.writeSingleMenu(FIND('menudiv'));
			var menuLayer = FIND(l.Menu.menuLayer);
			var s = childMenu.style;
			s.zIndex = menuLayer.style.zIndex+1;
			if (document.all) { // ie case.
				s.pixelTop = l.style.pixelTop + menuLayer.style.pixelTop + l.Menu.childYOffset;
				var left = s.pixelLeft = (menuLayer.style.pixelWidth) + menuLayer.style.pixelLeft + l.Menu.childXOffset;

				var menuoffset = FIND("menuLayer0").parentElement.offsetLeft;
				if (left + s.pixelWidth + menuoffset - document.body.scrollLeft > document.body.clientWidth)
					left = document.body.clientWidth - s.pixelWidth + document.body.scrollLeft - menuoffset;
				s.left = left;
			} else { // zilla case
				var top = PxToNum(l.style.top) + PxToNum(menuLayer.style.top) + l.Menu.childYOffset;
				var left = (PxToNum(menuLayer.style.width)) + PxToNum(menuLayer.style.left) + l.Menu.childXOffset;
				var menuoffset = FIND("menuLayer0").parentNode.parentNode.offsetLeft;
				if (left + PxToNum(s.width) + menuoffset - document.body.scrollLeft > document.body.clientWidth)
					left = document.body.clientWidth - PxToNum(s.width) + document.body.scrollLeft - menuoffset;
				s.top = top;
				s.left = left;
			}
			childMenu.style.visibility = "inherit";
		} else {
			return;
		}
		window.activeMenus[window.activeMenus.length] = childMenu;
	}
}

function hideActiveMenus() {
	if (!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 = -200;
			s.top = -200;
		}
	}
	if (window.ActiveMenuItem) {
		hideMenu(false, false);
	}
	window.activeMenus.length = 0;
}

 
