/*
Script for drop-down menu.
(c) 2007 Written Byte Ltd.
*/

var timeoutid;
var menusShowing = [];
function show(id, level) {
  if (level == null) level = 0;
  killTimeout();
  while (menusShowing.length > level) {
    showing_id = menusShowing.pop();
    if (showing_id != id) {
      var showing = document.getElementById(showing_id);
      if (showing) showing.style.display = "none";
    }
  }
  var d = document.getElementById(id);
  if (d) {
    d.style.display = 'inline';
    if (!menuIsShowing(id)) menusShowing.push(id);
  }
}
function menuIsShowing(id) {
  for (var i=0; i<menusShowing.length; i++) if (menusShowing[i] == id) return true;
  return false;
}
function killTimeout() {
  if (timeoutid) clearTimeout(timeoutid);
}
