/**
 * Popup Menu Script
 * Copyright Hugo Hudson, 2006
 *
 * Usage:
 *
 * TODO add usage information
 */

// run the setup method after the page loads
addEvent(window, 'load', PM_setupMenu);

/*
 * This function finds all items on the page with the class 'menuItem', that
 * have a corresponding 'subMenu' div.
 * It then assigns onmouseover and onmouseout events to toggle the visibility
 * of the subMenu items, so that they appear when the user places his mouse
 * over the main menu item.
 */
function PM_setupMenu() {
  var headerMenus = byclass("menuItem");
  for (var i=0; i<headerMenus.length; i++) {
    var headerMenu = headerMenus[i];
    var subMenus = byclass("subMenu",headerMenu);
    if (subMenus.length != 1) continue;
    headerMenu.subMenuHandle = subMenus[0];
    headerMenu.onmouseover = function() {
      this.subMenuHandle.style.visibility = "visible";
    };
    headerMenu.onmouseout = function() {
      this.subMenuHandle.style.visibility = "hidden";
    };
  }
}
