if (!upDir) {
  var upDir = ""; // directory structure context
}

var btnMetroOut = new Image(139, 25);
btnMetroOut.src = upDir + "graphics/btn_metro_out.gif";

var btnMetroOver = new Image(139, 25);
btnMetroOver.src = upDir + "graphics/btn_metro_over.gif";

/**
 *  Makes an element visible.
 *  @param  {String} id   the element's id
 *  @type   void
 */
function showMenu(id)
{
  if (document.getElementById) {
    document.getElementById(id).style.visibility = "visible";
  }
  else if (document.all) {
    document.all[id].style.visibility = "visible";
  }
}

/**
 *  Hides an element.
 *  @param  {String} id   the element's id 
 *  @type   void
 */
function hideMenu(id)
{
  if (document.getElementById) {
    document.getElementById(id).style.visibility = "hidden";
  }
  else if (document.all) {
    document.all[id].style.visibility = "hidden";
  }
}

/**
 *  Hides all div elements of class 'popup'. 
 *  @type   void
 */
function hideAll()
{
  var elements = false;

  if (document.getElementById) {
    elements = document.getElementsByTagName("div");
  }
  else if (document.all) {
    elements = document.all.tags("div");
  }

  if (elements) {
    for (var i = 0; i < elements.length; i++) {
      if (elements.item(i).className == "popup") {
        hideMenu(elements.item(i).id);
      }
    }
  }
}

var timerID = null;
var timecount = 200;  // milleseconds

/**
 *  Starts the countdown to hiding the popups.
 *  @type   void
 */
function startHideAllTimer()
{
  if (!timerID) {
    timerID = setTimeout("hideAll()", timecount);
  }
}

/**
 *  Stops the countdown to hiding the popups.
 *  @type   void
 */
function stopHideAllTimer()
{
  if (timerID) {
    clearTimeout(timerID);
    timerID = null;
  }
}

/**
 *  Event handler for mouse over menu button.
 *  @param  {String} imgId
 *  @param  {Image} img
 *  @param  {String} divId
 *  @type   void
 */
function doMouseOverBtn(imgId, img, divId)
{
  swapImg(imgId, img);
  stopHideAllTimer();
  hideAll();
  showMenu(divId);
}

/**
 *  Event handler for mouse out of menu button.
 *  @param  {String} id
 *  @param  {Image} img
 *  @type   void
 */
function doMouseOutBtn(id, img)
{
  swapImg(id, img);
  startHideAllTimer();
}