/* $Header: /d01/cvsrep/site/common/htdoc/script/dynmenu.js,v 1.6 2000/02/03 09:08:56 jmarschall Exp $ */

/* The currently visible menu */
var visibleMenu = "";
/* The currently visible sub menu */
var visibleSubMenu;
/* The menu timeout id */
var menuTimeoutId;

if (ns4) {
  window.captureEvents(Event.MOUSEDOWN);
  window.onmousedown=closeMenu;
  /* !!! Coution (re) !!! */
}

/* Closes all visible layers */
function closeMenu() {
  if (visibleMenu) {
     hideLayer('submenu' + visibleMenu);
     visibleMenu="";    
  }
  closeSubMenu();
  return true;
}

/* Closes the visible Layer for a sub menu */
function closeSubMenu() {
  if (visibleSubMenu) {
     hideLayer('submenu' + visibleSubMenu);
     visibleSubMenu="";    
  }
  return true;
}

/* Shows a layer for a top level menu */
function doMenu(newMenu) {

  if (visibleMenu != newMenu) {
     closeMenu();
     showLayer('submenu' + newMenu);
     visibleMenu=newMenu;
  }
  clearMenuTimeout();
  return true;
}

/* Shows a layer for a sub menu */
function doSubMenu(newSubMenu) {
  if (visibleSubMenu != newSubMenu) {
     hideLayer(visibleSubMenu);
     showLayer(newSubMenu);
     visibleSubMenu=newSubMenu;
  }
  clearMenuTimeout();
  return true;
}

/* Sets timeout for menu display */
function setMenuTimeout() {
  menuTimeoutId = setTimeout("closeMenu()", 2000);
  return true;
}

/* Clears timeout for menu display */
function clearMenuTimeout() {
  clearTimeout(menuTimeoutId);
  return true;
}
