//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2000-2002 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

var activeButton2 = null;

//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------

function buttonClick2(event, menuId) {

  var button;

  // Get the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  
  // Blur focus from the link to remove that annoying outline.

  button.blur();

  // Associate the named menu to this button if not already done.
  // Additionally, initialize menu display.

  if (button.menu == null) {
    button.menu = document.getElementById(menuId);
    if (button.menu.isInitialized == null)
      menuInit(button.menu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout2;

  // Exit if this button is the currently active one.

  if (button == activeButton2)
    return false;

  // [END MODIFIED]

  // Reset the currently active button, if any.

  if (activeButton2 != null)
    resetButton2(activeButton2);

  // Activate this button, unless it was the currently active one.

  if (button != activeButton2) {
    depressButton2(button);
    activeButton2 = button;
  }
  else
    activeButton2 = null;

  return false;
}

function buttonMouseover2(event, menuId) {

  var button;

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Activates this button's menu if no other is currently active.

  if (activeButton2 == null) {
    buttonClick2(event, menuId);
    return;
  }

  // [END MODIFIED]

  // Find the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // If any other button menu is active, make this one active instead.

  if (activeButton2 != null && activeButton2 != button)
    buttonClick2(event, menuId);
}

function depressButton2(button) {

  var x, y;

  // Update the button's style class to make it look like it's
  // depressed.


  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout2;
  if (button.menu.onmouseout == null)
    button.menu.onmouseout = buttonOrMenuMouseout2;

  // [END MODIFIED]

  // Position the associated drop down menu under the button and
  // show it.

  x = getPageOffsetLeft(button);
  y = getPageOffsetTop(button) + button.offsetHeight;

  // For IE, adjust position.

  if (browser.isIE) {
    x += button.offsetParent.clientLeft;
    y += button.offsetParent.clientTop;
  }

  x += 42;
  y -= 6;

  button.menu.style.left = x + "px";
  button.menu.style.top  = y + "px";
  button.menu.style.visibility = "visible";
}

function resetButton2(button) {

  // Restore the button's style class.


  // Hide the button's menu, first closing any sub menus.

  if (button.menu != null) {
    closeSubMenu(button.menu);
    button.menu.style.visibility = "hidden";
  }
}

//----------------------------------------------------------------------------
// Code to handle the menus and sub menus.
//----------------------------------------------------------------------------

function menuMouseover2(event) {

  var menu;

  // Find the target menu element.

  if (browser.isIE)
    menu = getContainerWith(window.event.srcElement, "DIV", "menu");
  else
    menu = event.currentTarget;

  // Close any active sub menu.

  if (menu.activeItem2 != null)
    closeSubMenu(menu);
}

function buttonOrMenuMouseout2(event) {

  var el;

  // If there is no active button, exit.

  if (activeButton2 == null)
    return;

  // Find the element the mouse is moving to.

  if (browser.isIE)
    el = window.event.toElement;
  else if (event.relatedTarget != null)
      el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);

  // If the element is not part of a menu, reset the active button.

  if ((getContainerWith(el, "DIV", "menu") == null) &&
      (getContainerWith(el, "A", "main_menu_item") == null))  {
    if (browser.isIE) {
      resetButton2(activeButton2); 
      activeButton2 = null;
    }
    else 
      setTimeout("resetButton2(activeButton2); activeButton2 = null;",100);
  }
}

