﻿var currMenu = "";
var currMenuTimer = "";
var currSubmenu = "";
var currSubmenuTimer = "";
var delayAmount = 250; // Used when the design requires a delay before hiding a menu so it doesn't disappear...
                       // ...before the user can mouse over it.

function delayHideMenu(currMenu) { // Leave menu visible long enough to cancel the 'hide' action if
  if (currMenu != "") {
      currMenuTimer = window.setTimeout("hideDiv(currMenu);",delayAmount);
  }
}
function delayHideSubmenu(currSubmenu) { // Leave submenu visible long enough to cancel the 'hide' action if...
  if (currSubmenu != "") {
      currSubmenuTimer = window.setTimeout("hideDiv(currSubmenu);",delayAmount);
  }
}
// Every submenu has the same Y as its parent link (menu$DivName), and 
// an X equal to (the X of its parent link DIV + the width of its parent link DIV).
function alignAndShowMenu(id,offsetLeft,offsetTop,idParent) {    // Recalculates left edge of a menu each time it's displayed.
  clearTimeout(currMenuTimer);
  currMenuTimer = "";

 if (offsetTop) {  // Presence of this parameter tells us ID is a submenu's DIV container.
      if ((currSubmenu != id ) && (currSubmenu != "")) {  // Force hideDiv() if new submenu is invoked before another one hides.
           hideDiv(currSubmenu);
      }
      document.getElementById(id).style.top = offsetTop + "px";  // Submenus get their y-position here.
      currSubmenu = id;
  } else {  // It's not a submenu...
     if ((currMenu != id) && (currMenu != "")) { 
          hideDiv(currMenu);
     }
     currMenu = id;
  }
  document.getElementById(id).style.left = (offsetLeft + 10) + "px";   // Menus and submenus get their x-position here.
  showDiv(id);
}

