﻿function hideMenus(elemID, currentTarget) {
  if (currentTarget) {
    var nextChild = document.getElementById(currentTarget.id + "_submenu");
    // If we're about to re-show the currently displayed menu, bail early to
    // avoid flickering
    if (nextChild && nextChild.id == lastMenu)
      return;
  }
  // Hide up to the passed element:
  var elem;
  if (elemID)
    elem = document.getElementById(elemID);
  while (men = menus.pop()) {
    if (elem && men.id == elem.id) {
      menus.push(men); // Put the match back into the array
      return;
    } else {
      men.style.display = "none";
      if (isIE && men.iframe)
        document.body.removeChild(men.iframe);
      tab = document.getElementById(men.id.replace(/(.*)_submenu/, "$1") + "_img");
      if (tab)
        tab.src = tab.src.replace(/(.*)2\.(.*)/, "$11.$2");
    }
  }
}
