var selectboxes = null;
var selectboxTimerID = null;
var selectboxTimerRunning = false;

window.onload = init;
window.onunload = hidePop;

function init() { // Start-up
  setBrowser();  // Initiate DHTML set
  
// Get select boxes so we can hide them while showing pop-up menus
  if (document.getElementById) {
    selectboxes = document.getElementsByTagName("select");
  }
}

// Pop-up menu display

function popupMenu(nameToUse) {
  this.boxName = nameToUse;
  this.timerID = null;
  this.timerRunning = false;
  this.show = showPop;
  this.hide = hidePop;
  return this;
}

quicklinks = new popupMenu("quicklinkBox");
toolslinks = new popupMenu("toolslinkBox");

function showPop() {
  if (isNav4) return;
  if (this.timerRunning) {
    clearTimeout(this.timerID);
    timerRunning = false;
  }
  
  // Clear timer to re-show select boxes and then hide them
  if (selectboxTimerRunning) {
    clearTimeout(selectboxTimerID);
    selectboxTimerRunning = false;
  }

  hideSelectBoxes();
  
  setIdProperty(this.boxName, "visibility", "visible");
  
  return true;
}

function hidePop() {
  if (isNav4) return;
  
  if (this.timerRunning) {
    clearTimeout(this.timerID);
  }
  
  if (selectboxTimerRunning) {
    clearTimeout(selectboxTimerID);
  }

  this.timerID = window.setTimeout("setIdProperty('" + this.boxName + "', 'visibility', 'hidden')", 300);
  selectboxTimerID = window.setTimeout("showSelectBoxes()", 300);

  this.timerRunning = true;
  selectboxTimerRunning = true;
  return true;
}

function showSelectBoxes() {
  //if (document.getElementById && selectboxes != null) {
  //  for (x = 0; x < selectboxes.length; x++) {
  //    selectboxes[x].style.visibility="visible";
  //  }
  //}
}

function hideSelectBoxes() {
  //if (document.getElementById && selectboxes != null) {
  //  for (x = 0; x < selectboxes.length; x++) {
   //   selectboxes[x].style.visibility="hidden";
   // }
  //}
}

/* old code
var timerID = null;
var timerRunning = false;

function popMenu(menu) { // Show menu
  if (isNav4) return;
  if (timerRunning) clearTimeout(timerID);
  timerRunning = false;
  setIdProperty(menu, "visibility", "visible");
  return true;
}
	
function hide(menu) {  // Hide menu
  if (isNav4) return;
  if (timerRunning) clearTimeout(timerID);
  timerID = window.setTimeout("setIdProperty('" + menu + "', 'visibility', 'hidden')", 300) 
  timerRunning = true;
}
*/
