// menuHandler.js --

var MHopenDelay=100;
var MHcloseDelay=300;

// On resize reload the page.
MHreloadPage(true);

// Define global variables that we will use throughout this javascript.
var MHmenuNames=new Array();
var MHmenus=new Array();
var MHcounter=0;
var MHisVis=null;
var MHisSubVis=null;
var MHtimer=null;
var MHsubTimer=null;
var MHlayerInc=null;
var MHisOver=0;
var MHnestTop=0;

// Determine browser type
var MHapp = null;
if ((navigator.appName == "Netscape") && (document.layers != null) && (navigator.appVersion.charAt(0) == "4")){
  MHapp="N";
}else if ((navigator.appName == "Microsoft Internet Explorer") && (document.all != null)){
  MHapp="E";
}else if ((navigator.appName == "Netscape") && (document.getElementById != null) && (navigator.appVersion.charAt(0) == "5")){
  MHapp="N5";
}
if (navigator.userAgent.indexOf("Opera") > -1) MHapp = "O";		// CRW,A:01/29/03

// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}

// Global variables for mouse position
var xMousePos = 0; // Horizontal position of the mouse on the screen
var yMousePos = 0; // Vertical position of the mouse on the screen
var xMousePosMax = 0; // Width of the page
var yMousePosMax = 0; // Height of the page

//=================================
// Function to create a new menu.
// Parameters:
//     menuName - menu name
//     x - x coordinate
//     width - Width of menu
//     iewinY - y coordinate for IE on Windows
//     iemacY - y coordinate for IE on Mac
//     nwinY - y coordinate for Netscape 4 on Windows
//     nmacY - y coordinate for Netscape 4 on Mac
//     n5winY - y coordinate for Netscape 5 or later on Windows
//     n5macY - y coordinate for Netscape 5 or later on Mac
function MHaddMenu(menuName,x,width,iewinY,nwinY,n5winY,iemacY,nmacY,n5macY){
  MHmenuNames[MHmenuNames.length] = menuName;
  MHmenus[menuName] = new MHmenu(menuName,x,width,iewinY,iemacY,nwinY,nmacY,n5winY,n5macY);
}

//=================================
function MHcloseMenu(menuName){
  MHisOver=0;
  MHhideDelay(menuName);
}

//=================================
// Function that creates the break which can be used to separate the menu links.
// Parameters:
//     menuName - name of menu
//     w - width of menu
//     menuItem - menu item object
function MHcreateMenuBreak(menuName, w, menuItem){
  this.code = "";

  if (navigator.platform.indexOf("Win") < 0){
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }else{
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }

  functionCalls = "onMouseOver=\"MHoverMenu('" + menuName + "');\" " +
                  "onMouseOut=\"MHoffMenu('" + menuName + "');\"";

  // Figure out if we are going to use a div or a layer depending on the browser.
  if ((MHapp == "E") || (MHapp == "N5")){
    this.code = "<div id=\"br\" class=\"navBreak\" style=\"position:relative;z-index=0;left:0px;top:0px;background-color:" + menuItem.bg1 + ";width:" + w + "px;height:" + menuItem.h + "px;\" " + functionCalls + "><img src=\"" + menuItem.img + "\" width=" + w + " height=" + menuItem.h + " border=0></div>";
  }else if (MHapp == "N"){
    this.code = "<layer id=\"br\" class=\"navBreak\" z-index=0 bgcolor=" + menuItem.bg1 + " width=" + w + " height=" + menuItem.h + " left=0 top=" + MHnestTop + " " + functionCalls + "><img src=\"" + menuItem.img + "\" width=" + w + " height=" + menuItem.h + " border=0></layer>";
  }
  return this.code;
}

//=================================
// Start the function that creates the links that will be used in the menus that do not open sub menus
// Parameters:
//     menuName - name of menu
//     w - width of menu
//     menuItem - menu item object
function MHcreateMenuLink(menuName, w, menuItem){
  this.code = "";

  if (navigator.platform.indexOf("Win") < 0){
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }else{
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }

  functionCalls = "onMouseOver=\"MHoverLayer('" + menuName + "layerId" + MHcounter + "', '" + menuName + "', '" + menuItem.bg2 + "', '" + menuItem.c2 + "');\" " +
                  "onMouseOut=\"MHoffLayer('" + menuName + "layerId" + MHcounter + "', '" + menuName + "', '" + menuItem.bg1 + "', '" + menuItem.c1 + "');\"";

  if ((MHapp == "E") || (MHapp == "N5")){
    this.code = "<div id=\"" + menuName + "layerId" + MHcounter + "\" class=\"navLink\" style=\"position:relative;z-index=0;left:0px;top:0px;background-color:" + menuItem.bg1 + ";color:" + menuItem.c1 + ";width:" + w + "px;height:" + menuItem.h + "px;\" " + functionCalls + " onClick=\"MHredirectTo('" + menuItem.url + "'," + menuItem.target + ");\">&nbsp;" + menuItem.name + "&nbsp;</div>";
  }else if (MHapp == "N"){
    this.code = "<layer id=\"" + menuName + "layerId" + MHcounter + "\" class=\"navLink\" z-index=0 bgcolor=" + menuItem.bg1 + " width=" + w + " height=" + menuItem.h + " left=0 top=" + MHnestTop + " " + functionCalls + "><a class=\"navHref\" href=\"javascript:MHredirectTo('" + menuItem.url + "'," + menuItem.target + ")\">&nbsp;" + menuItem.name + "&nbsp;</a></layer>";
  }
  MHcounter ++;
  return this.code;
}

//=================================
// Start the function that creates a link on a submenu
// Parameters:
//     menuName - name of menu
//     w - width of menu
//     menuItem - menu item object
function MHcreateSubMenuLink(menuName, w, menuItem){
  this.code = "";

  if (navigator.platform.indexOf("Win") < 0){
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }else{
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }
  
  functionCalls = "onMouseOver=\"MHoverSubLayer('" + menuName + "layerId" + MHcounter + "', '" + menuName + "', '" + menuItem.bg2 + "', '" + menuItem.c2 + "');\" " +
                  "onMouseOut=\"MHoffSubLayer('" + menuName + "layerId" + MHcounter + "', '" + menuName + "', '" + menuItem.bg1 + "', '" + menuItem.c1 + "');\"";
  
  if ((MHapp == "E") || (MHapp == "N5")){
    this.code = "<div id=\"" + menuName + "layerId" + MHcounter + "\" class=\"navLink\" style=\"position:relative;z-index=0;left:0px;top:0px;background-color:" + menuItem.bg1 + ";color:" + menuItem.c1 + ";width:" + w + "px; height:" + menuItem.h + "px;\" " + functionCalls + " onClick=\"MHredirectTo('" + menuItem.url + "'," + menuItem.target + ");\">&nbsp;" + menuItem.name + "&nbsp;</div>";
  }else if (MHapp == "N"){
    this.code = "<layer id=\"" + menuName + "layerId" + MHcounter + "\" class=\"navLink\" z-index=0 bgcolor=" + menuItem.bg1 + " width=" + w + " height=" + menuItem.h + " left=0 top=" + MHnestTop + " " + functionCalls + "><a class=\"navHref\" href=\"javascript:MHredirectTo('" + menuItem.url + "'," + menuItem.target + ")\">&nbsp;" + menuItem.name + "&nbsp;</a></layer>";
  }
  MHcounter ++;
  return this.code;
}

//=================================
// Start the function that creates a break on submenu
// Parameters:
//     menuName - name of menu
//     w - width of menu
//     menuItem - menu item object
function MHcreateSubMenuBreak(menuName, w, menuItem){
  this.code = "";

  if (navigator.platform.indexOf("Win") < 0){
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }else{
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }

  functionCalls = "onMouseOver=\"MHoverSubMenu('" + menuName + "');\" " +
                  "onMouseOut=\"MHoffSubMenu('" + menuName + "');\"";

  if ((MHapp == "E") || (MHapp == "N5")){
    this.code = "<div id=\"br\" class=\"navBreak\" style=\"position:relative;z-index=0;left:0px;top:0px;background-color:" + menuItem.bg1 + ";width:" + w + "px;height:" + menuItem.h + "px;\" " + functionCalls + "><img src=\"" + menuItem.img + "\" width=" + w + " height=" + menuItem.h + " border=0></div>";
  }else if (MHapp == "N"){
    this.code = "<layer id=\"br\" class=\"navBreak\" z-index=0 bgcolor=" + menuItem.bg1 + " width=" + w + " height=" + menuItem.h + " left=0 top=" + MHnestTop + " " + functionCalls + "><img src=\"" + menuItem.img + "\" width=" + w + " height=" + menuItem.h + " border=0></layer>";
  }
  return this.code;
}

//=================================
// Start the function that creates a link to a submenu
// Parameters:
//     menuName - name of menu
//     w - width of menu
//     menuItem - menu item object
function MHcreateMenuSubMenu(menuName, w, menuItem){
  this.code = "";

  if (navigator.platform.indexOf("Win") < 0){
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }else{
    MHlayerInc = 0;
    MHlayerInc += (menuItem.h - 1);
  }

  functionCalls = "onMouseOver=\"MHoverLayer('" + menuName + "layerId" + MHcounter + "', '" + menuName + "', '" + menuItem.bg2 + "', '" + menuItem.c2 + "', 1, '" + menuItem.targetMenu + "');\" " +
                  "onMouseOut=\"MHoffLayer('" + menuName + "layerId" + MHcounter + "', '" + menuName + "', '" + menuItem.bg1 + "', '" + menuItem.c1 + "', 1, '" + menuItem.targetMenu + "');\"";

  if ((MHapp == "E") || (MHapp == "N5")){
    this.code = "<div id=\"" + menuName + "layerId" + MHcounter + "\" class=\"navLink\" style=\"position:relative;z-index=0;left:0px;top:0px;background-color:" + menuItem.bg1 + ";color:" + menuItem.c1 + ";width:" + w + "px; height:" + menuItem.h + "px;\" " + functionCalls + " onClick=\"MHredirectTo('" + menuItem.url + "'," + menuItem.target + ");\"><table id=\"Tab" + menuName + "layerId" + MHcounter + "\" cellspacing=0 cellpadding=0 border=0 width=100%><tr><td class=\"navLink\" width=99%>&nbsp;" + menuItem.name + "&nbsp;</td><td width=1% align=right><img src=\"" + MHmenuArrow + "\" border=0 width=10 height=10></td></tr></table></div>";
  }else if (MHapp == "N"){
    this.code = "<layer id=\"" + menuName + "layerId" + MHcounter + "\" class=\"navLink\" z-index=0 bgcolor=" + menuItem.bg1 + " width=" + w + " height=" + menuItem.h + " left=0 top=" + MHnestTop + " " + functionCalls + "><table id=\"Tab" + menuName + "layerId" + MHcounter + "\" cellspacing=0 cellpadding=0 border=0 width=100%><tr><td width=99%><a class=\"navHref\" href=\"javascript:MHredirectTo('" + menuItem.url + "'," + menuItem.target + ");\">&nbsp;" + menuItem.name + "&nbsp;</a></td><td width=1% align=right><img src=\"" + MHmenuArrow + "\" border=0 width=10 height=10></td></tr></table></layer>";
  }
  MHcounter ++;
  return this.code;
}

//=================================
// This function runs through the sequence of menu names and calls the define
//   menu funtion on each of them.
function MHcreateMenus() {
  for (i = 0; i < MHmenuNames.length; i ++){
    MHdefineMenu(MHmenuNames[i]);
  }
}

//=================================
// This is the function that actually will build the
//   menu layers as the page is loading.
// Parameters:
//     menuName - name of menu
function MHdefineMenu(menuName){
  this.menu = MHmenus[menuName];
  this.inner = "";
  MHnestTop = 0;

  // Run through the list of menuItems to create the various elements
  for (mi = 0; mi < menu.menuItems.length; mi ++){
    // Skip if menuItem element is not defined.
    if (menu.menuItems[mi] != null){
      // Build the div or layer that we need to get the desired effect.
      if (menu.menuItems[mi].type == "break"){
        this.inner += MHcreateMenuBreak(menuName, menu.w, menu.menuItems[mi]);
      }else if (menu.menuItems[mi].type == "subbreak"){
        this.inner += MHcreateSubMenuBreak(menuName, menu.w, menu.menuItems[mi]);
      }else if (menu.menuItems[mi].type == "link"){
        this.inner += MHcreateMenuLink(menuName, menu.w, menu.menuItems[mi]);
      }else if (menu.menuItems[mi].type == "sublink"){
        this.inner += MHcreateSubMenuLink(menuName, menu.w, menu.menuItems[mi]);
      }else if (menu.menuItems[mi].type == "sub"){
        this.inner += MHcreateMenuSubMenu(menuName, menu.w, menu.menuItems[mi]);
      }
      MHnestTop = MHnestTop + MHlayerInc + 1;
    }
  }

  MHnestTop --;

  this.outer = "";
  // For IE and Netscape 6 we will encapsulate a bunch of DIVs into an outer div
  // yet in netscape 4 we want to use their layer tag cause will allow us
  // to do some stuff that n4 doesn't like to do with div tages.
  if ((MHapp == "E") || (MHapp == "N5")){
    this.outer += "<div id=\"" + menuName + "\" style=\"cursor:pointer;cursor:hand;position:absolute;width:" + menu.w + "px;left:" + menu.x + "px;top:" + menu.y + "px;visibility:hidden;z-index=0;\">";
    this.outer += "<table cellspacing=0 cellpadding=0 border=1 width=100%><tr><td>";
    this.outer += this.inner;
    this.outer += "</td></tr></table>";
    this.outer += "</div>\n";
  }else if (MHapp == "N"){
    this.outer += "<layer id=\"" + menuName + "\" z-index=0 width=" + menu.w + " left=" + menu.x + " top=" + menu.y + " visibility=\"hidden\">";
    this.outer += "<table cellspacing=0 cellpadding=0 border=1 width=100%><tr><td>";
    this.outer += inner;
    this.outer += "</td></tr></table>";
    this.outer += "</layer>\n";
  }
  // Finally write the menu to the document.
  document.write(this.outer);
}		// End of 'defineMenu(menuName)' function

//=================================
// Start a function to delay the hiding of an undesired menu
// Parameters:
//     menuName - name of menu
function MHhideDelay(menuName){
  MHtimer = setTimeout("MHhideMenu('" + menuName + "');", MHcloseDelay);
}

//=================================
// Function to hide an undesired menu
// Parameters:
//     menuName -
function MHhideMenu(menuName){
  clearTimeout(MHtimer);
  MHtimer = null;

  if (MHapp == "N"){
    theObj2 = document.layers[MHisVis];
    if (theObj2){
      if (theObj2.visibility == 'inherit'){
        theObj2.visibility = 'hide';
        theObj2.zIndex = 0;
      }
    }
  }else if (MHapp == "E"){
    theObj2 = document.all[MHisVis];
    if (theObj2){
      if (theObj2.style.visibility == 'inherit'){
        theObj2.style.visibility = 'hidden';
        theObj2.style.zIndex = 0;
      }
    }
  }else if (MHapp == "N5"){
    theObj2 = document.getElementById(MHisVis);
    if (theObj2){
      if (theObj2.style.visibility == 'inherit'){
        theObj2.style.visibility = 'hidden';
        theObj2.style.zIndex = 0;
      }
    }
  }
}

//=================================
// Function to hide an undesired submenu
// Parameters:
//     menuName -
function MHhideSubMenu(menuName){
  clearTimeout(MHsubTimer);
  MHsubTimer = null;

  if (MHapp == "N"){
    theObj = document.layers[menuName];
    if (theObj){
      if (theObj.visibility == 'inherit'){
        theObj.visibility='hide';
        theObj.zIndex = 0;
      }
    }
  }else if (MHapp == "E"){
    theObj = document.all[menuName];
    if (theObj){
      if (theObj.style.visibility == 'inherit'){
        theObj.style.visibility='hidden';
        theObj.style.zIndex = 0;
      }
    }
  }else if (MHapp == "N5"){
    theObj = document.getElementById(menuName);
    if (theObj){
      if (theObj.style.visibility == 'inherit'){
        theObj.style.visibility='hidden';
        theObj.style.zIndex = 0;
      }
    }
  }
}

//=================================
// Function to delay hide of a submenu
// Parameters:
//     menuName -
function MHhideSubDelay(menuName){
  MHsubTimer = setTimeout("MHhideSubMenu('" + menuName + "');", MHcloseDelay);
}

//=================================
// Function to highlight a menu item.
// Parameters:
//     layerId -
//     menu - 
function MHhighlightLayer(layerId,menu,bg,c,isSub){
  if (MHapp == "N"){
    document.layers[menu].document.layers[layerId].bgColor = bg;
    document.layers[menu].document.layers[layerId].color = c;
  }else if (MHapp == "E"){
    document.all[layerId].style.backgroundColor = bg;
    document.all[layerId].style.color = c;
    if (isSub) document.all["Tab" + layerId].style.color = c;
  }else if (MHapp == "N5"){
    document.getElementById(layerId).style.backgroundColor = bg;
    document.getElementById(layerId).style.color = c;
    if (isSub) document.getElementById("Tab" + layerId).style.color = c;
  }
}

//=================================
// Function to define a menu object. Creates an array to store the menu items in.
// Parameters:
//     menuName - menu name
//     x - x coordinate
//     w - Width of menu
//     iewinY - y coordinate for IE on Windows
//     iemacY - y coordinate for IE on Mac
//     nwinY - y coordinate for Netscape 4 on Windows
//     nmacY - y coordinate for Netscape 4 on Mac
//     n5winY - y coordinate for Netscape 5 or later on Windows
//     n5macY - y coordinate for Netscape 5 or later on Mac
function MHmenu(menuName,x,w,iewinY,iemacY,nwinY,nmacY,n5winY,n5macY){
  this.type="";
  this.parent=null;
  this.name=menuName;
  this.x=x;
  this.y=iewinY;
  if (MHapp == "N") this.y=nwinY;
  if (MHapp == "N5") this.y=n5winY;
  if ((navigator.platform.indexOf("Win") < 0) && (MHapp == "E")) this.y=iemacY;
  if ((navigator.platform.indexOf("Win") < 0) && (MHapp == "N")) this.y=nmacY;
  if ((navigator.platform.indexOf("Win") < 0) && (MHapp == "N5")) this.y=n5macY;
  this.w=w;
  this.menuItems=new Array();
}

//=================================
// Function to define a menu break.
// Parameters:
//     h - height
//     img - image url
function MHmenuBreak(img,h,bg1){
  this.type = "break";
  this.h=h;
  this.img=img;
  this.bg1=bg1;
}

//=================================
// Function to define a menu link.
// Parameters:
//     name - text to display
//     url - link to URL
//     target - 1 (new window) or 0 (current window)
//     attrib - attributes for the a new window
function MHmenuLink(name,h,bg1,bg2,c1,c2,url,target,attrib){
  this.type="link";
  this.name=name;
  this.url=url;
  this.target=target;
  this.attrib=attrib;
  this.h=h;
  this.bg1=bg1;
  this.bg2=bg2;
  this.c1=c1;
  this.c2=c2;
}

//=================================
// Function to define a submenu break
// Parameters:
//     h - height
//     img - image url
function MHsubMenuBreak(img,h,bg1){
  this.type="subbreak";
  this.h=h;
  this.img=img;
  this.bg1=bg1;
}

//=================================
// Function to define a submenu link
// Parameters:
//     name - text to display
//     url - link to URL
//     target - 1 (new window) or 0 (current window)
//     attrib - attributes for the a new window
function MHsubMenuLink(name,h,bg1,bg2,c1,c2,url,target,attrib){
  this.type="sublink";
  this.name=name;
  this.url=url;
  this.target=target;
  this.attrib=attrib;
  this.h=h;
  this.bg1=bg1;
  this.bg2=bg2;
  this.c1=c1;
  this.c2=c2;
}

//=================================
// Function to define a link to a submenu
// Parameters:
//     name - text to display
//     targetMenu - target menu layer it will affect
//     par - parent menu name
//     url - link to URL
//     target - 1 (new window) or 0 (current window)
//     attrib - attributes for the a new window
function MHmenuSubMenu(name,h,bg1,bg2,c1,c2,targetMenu,parentMenu,url,target,attrib){
  this.type="sub";
  this.name=name;
  this.targetMenu=targetMenu;
  this.url=url;
  this.target=target;
  this.attrib=attrib;
  this.h=h;
  this.bg1=bg1;
  this.bg2=bg2;
  this.c1=c1;
  this.c2=c2;
  MHmenus[targetMenu].type="parent";
  MHmenus[targetMenu].parent=parentMenu;
}

//=================================
// Function to be called when going off a menu layer
// Parameters:
//     layerId -
//     menu -
//     isSub -
//     subTarget -
function MHoffLayer(layerId,menu,bg,c,isSub,subTarget){
  MHunHighlightLayer(layerId,menu,bg,c,isSub);
  if (isSub == 1) MHhideSubDelay(subTarget);
  MHhideDelay(menu);
}

//=================================
// Function to know when you are off the menu;
// Parameters:
//     menuName -
function MHoffMenu(menuName){
  MHhideDelay(menuName);
}

//=================================
// Function called when going off a submenu layer
// Parameters:
//     layerId -
//     menu -
function MHoffSubLayer(layerId,menu,bg,c){
  MHhideSubDelay(menu);
  MHhideDelay(MHmenus[menu].parent);
  MHunHighlightLayer(layerId,menu,bg,c);
}

//=================================
// Function to know when you are off the sub menu;
// Parameters:
//     menuName -
function MHoffSubMenu(menuName){
  MHhideDelay(MHmenus[menuName].parent);
  MHhideSubDelay(menuName);
}

//=================================
// Parameters:
//     menuName -
function MHopenMenu(menuName,locX,locY){
  if ((MHisVis != null) && (MHisVis == menuName)){
    clearTimeout(MHtimer);
    MHtimer = null;
    MHhideMenu(menuName);
  }
  MHisOver = 1;
  setTimeout("MHshowMenu('" + menuName + "'," + locX + "," + locY + ")",MHopenDelay);
  clearTimeout(MHtimer);
}

//=================================
// Function to be called when going over a menu layer
// Parameters:
//     layerId -
//     menu -
//     isSub -
//     subTarget -
function MHoverLayer(layerId,menu,bg,c,isSub,subTarget){
  clearTimeout(MHtimer);
  MHtimer = null;  
  MHhighlightLayer(layerId,menu,bg,c,isSub);
  if (isSub == 1) MHshowSubMenu(subTarget); 
}

//=================================
// Function to know when you are over the menu;
function MHoverMenu(){
  clearTimeout(MHtimer);
}

//=================================
// Function called when going over a submenu layer
// Parameters:
//     layerId -
//     menu -
function MHoverSubLayer(layerId,menu,bg,c){
  clearTimeout(MHtimer);
  MHtimer = null;
  clearTimeout(MHsubTimer);
  MHsubTimer = null;
  MHhighlightLayer(layerId,menu,bg,c);
}

//=================================
// Function to know when you are over the sub menu;
function MHoverSubMenu(){
  clearTimeout(MHtimer);
  clearTimeout(MHsubTimer);
}

//=================================
// Function to redirect users to the proper page.
// Parameters:
//     url -
//     target -
function MHredirectTo(url,target){
  if (target == 0){
    window.location = url;
  }else if (target == 1){
    window.open(url, "newwin");
  }
}

//=================================
// Function to reload Netscape browsers on resize
// Parameters:
//     init -
function MHreloadPage(init){
  //reloads the window if Nav4 resized
  if (init == true){
    with (navigator){
      if ((appName == "Netscape") && (parseInt(appVersion) == 4)){
        document.pgW = innerWidth;
        document.pgH = innerHeight;
        onresize = MHreloadPage;
      }
    }
  }else if ((innerWidth != document.pgW) || (innerHeight != document.pgH)){
    location.reload();
  }
}

//=================================
// Function to show a desired menu
// Parameters:
//     menuName -
function MHshowMenu(menuName,locX,locY){
  if (MHisOver == 1) {
    if (MHisVis != null) MHhideMenu(MHisVis);
    if (MHapp == "N"){
      theObj = document.layers[menuName];
      if (theObj){
        if (theObj.visibility == 'hide'){
          theObj.visibility = 'inherit';
          theObj.zIndex ++;
          if (locX) theObj.left=xMousePos-10;
          if (locY) theObj.top=yMousePos-10;
        }
      }
    }else if (MHapp == "E"){
      theObj = document.all[menuName];
      if (theObj){
        if (theObj.style.visibility == 'hidden'){
          theObj.style.visibility = 'inherit';
          theObj.style.zIndex ++;
          if (locX) theObj.style.pixelLeft=xMousePos-10;
          if (locY) theObj.style.pixelTop=yMousePos-10;
        }
      }
    }else if (MHapp == "N5"){
      theObj = document.getElementById(menuName);
      if (theObj){
        if (theObj.style.visibility == 'hidden'){
          theObj.style.visibility = 'inherit';
          theObj.style.zIndex ++;
          if (locX) theObj.style.left=xMousePos-10;
          if (locY) theObj.style.top=yMousePos-10;
        }
      }
    }
    MHisVis = menuName;
  }
}

//=================================
// Start a function to show a desired menu
// Parameters:
//     menuName -
function MHshowSubMenu(menuName,locX,locY){
  if (MHisSubVis != null) MHhideSubMenu(MHisSubVis);
  if (MHapp == "N"){
    theObj = document.layers[menuName];
    if (theObj){
      if (theObj.visibility == 'hide'){
        theObj.visibility = 'inherit';
        theObj.zIndex = theObj.zIndex + 2;
        if (locX) theObj.left=xMousePos-10;
        if (locY) theObj.top=yMousePos-10;
      }
    }
  }else if (MHapp == "E"){
    theObj = document.all[menuName];
    if (theObj){
      if (theObj.style.visibility == 'hidden'){
        theObj.style.visibility = 'inherit';
        theObj.style.zIndex = theObj.style.zIndex + 2;
        if (locX) theObj.style.pixelLeft=xMousePos-10;
        if (locY) theObj.style.pixelTop=yMousePos-10;
      }
    }
  }else if (MHapp == "N5"){
    theObj = document.getElementById(menuName);
    if (theObj){
      if (theObj.style.visibility == 'hidden'){
        theObj.style.visibility = 'inherit';
        theObj.style.zIndex = theObj.style.zIndex + 2;
        if (locX) theObj.style.left=xMousePos-10;
        if (locY) theObj.style.top=yMousePos-10;
      }
    }
  }
  MHisSubVis = menuName;
}

//=================================
// Function to unhighlight a menu item
// Parameters:
//     layerId -
//     menu -
function MHunHighlightLayer(layerId,menu,bg,c,isSub){
  if (MHapp == "N") {
    document.layers[menu].document.layers[layerId].bgColor = bg;
    document.layers[menu].document.layers[layerId].color = c;
  }else if (MHapp == "E"){
    document.all[layerId].style.backgroundColor = bg;
    document.all[layerId].style.color = c;
    if (isSub) document.all["Tab" + layerId].style.color = c;
  }else if (MHapp == "N5"){
    document.getElementById(layerId).style.backgroundColor = bg;
    document.getElementById(layerId).style.color = c;
    if (isSub) document.getElementById("Tab" + layerId).style.color = c;
  }
}

//=================================
function captureMousePosition(e){
  if (document.layers){
    xMousePos = e.pageX;
    yMousePos = e.pageY;
    xMousePosMax = window.innerWidth+window.pageXOffset;
    yMousePosMax = window.innerHeight+window.pageYOffset;
  }else if (document.all){
    xMousePos = window.event.x+document.body.scrollLeft;
    yMousePos = window.event.y+document.body.scrollTop;
    xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
    yMousePosMax = document.body.clientHeight+document.body.scrollTop;
  }else if (document.getElementById){
    xMousePos = e.pageX;
    yMousePos = e.pageY;
    xMousePosMax = window.innerWidth+window.pageXOffset;
    yMousePosMax = window.innerHeight+window.pageYOffset;
  }
//window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;
}
//=================================
