var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var menuSel = null;

if (!isNS4)
  {
  document.write("<link type='text/css' rel='stylesheet' href='" + ieMozNS7_StyleSheet + "' title='ieMozNS7_MenuLook'>");
  document.write("<style type='text/css'>");
  document.write("#menuDiv {");
  document.write("  position: absolute;");
  document.write("  top: " + menuTopPosition + "px;");
  document.write("}");
  document.write("</style>");
  }
else
  document.write("<link type='text/css' rel='stylesheet' href='" + NS4_StyleSheet + "' title='NS4_MenuLook'>");

function getRefById(objId) {
  if (isNS4) return getRefByIdNS4(objId);
  if (isIE4) return document.all[objId];
  if (isDOM) return document.getElementById(objId);
}
function getRefByIdNS4(objId,doc) {
  var objRef = null;
  if (!doc)
    doc = document;
  if (doc.layers[objId])
    return doc.layers[objId];
  for (var i = 0; i < doc.layers.length; i++)
    {
    objRef = getRefByIdNS4(objId,doc.layers[i].document);
    if (objRef)
      return objRef;
    }
  return objRef;
}

function collapseMenuDivs(menuId)
{
  var theMenu = getRefById(menuId);
  var theULs = theMenu.getElementsByTagName('ul');
  for (var iCtr = 0; iCtr < theULs.length; iCtr++)
    {
    if (theULs[iCtr].className == "subMenu")
      theULs[iCtr].style.display = 'none';
    }
}
function menuClick(subMenuId) {

  if (isNS4)
    return;

  var subMenu = getRefById(subMenuId);
  var displayType = subMenu.style.display;

  if (!bExpandMultipleMenues)
    collapseMenuDivs('menuDiv');

  subMenu.style.display = (displayType == 'block') ? 'none' : 'block';
}

function menuOpen(subMenuId) {
  if (isNS4)
    return;
  var subMenu = getRefById(subMenuId);
  if (!bExpandMultipleMenues)
    collapseMenuDivs('menuDiv');
  subMenu.style.display = 'block';
}

function scrollOver(menuObj) {
  if (menuSel != "null")
    unselectMenuItem(menuSel);
  selectMenuItem(menuObj);
  menuSel = menuObj;
}
function selItem(menuObj,subMenu,x,y) {
  if (menuSel)
    unselItem(menuSel);
  var theLI = menuObj;
  if (theLI.className == "itemTop")
    theLI.className = "itemTopSelected";
  if (theLI.className == "itemTopSub")
    theLI.className = "itemTopSubSelected";
  if (theLI.className == "itemSub")
    theLI.className = "itemSubSelected";
  menuSel = menuObj;
  // roll over menu
  if (bUseRollOverMenues && subMenu)
    window.FW_showMenu(subMenu,x,y);
  return;
}
function unselItem(menuObj) {
  var theLI = menuObj;
  if (theLI.className == "itemTopSelected")
    theLI.className = "itemTop";
  if (theLI.className == "itemTopSubSelected")
    theLI.className = "itemTopSub";
  if (theLI.className == "itemSubSelected")
    theLI.className = "itemSub";
	FW_startTimeout();
  return;
}

function gotoUrl(aTagId) {
  document.location = getRefById(aTagId).href;
}
/* This function was created so that top-level menu items could have URLs for
 * Netscape 4.79 and screen readers since they cannot expand/collapse the menu
 * with Javascript.
 * In other browsers, it will follow the link depending on the value of 
 * bFollowLink which must be declared in your menu include.
 */
function followLink() {
  if (isNS4) return true;
  return bFollowLink;
}



