var timer;
var delay = 50;
var bgon = "#990003";
var bgoff = "#003466";





function showMenu(x) {
  clearTimeout(timer);
  hideAll();
  document.getElementById(x).style.visibility = "visible";
}

function hideMenu() {
  timer = setTimeout("hideAll();",delay);
}

function hideAll() {
  for (i=0; i<=1; i++) {
    tmp = "menu" + i;
    document.getElementById(tmp).style.visibility = "hidden";
  }
}

function jumpTo(url) {
  document.location.href = url;
}

function jumpTo2(url) {
  window.open(url);
}

function rollOn(x) {
  if (navigator.userAgent.indexOf("Firefox")!=-1){
    x.style.cursor = 'pointer';
  }
  else {
    x.style.cursor = 'hand';
  }
  x.style.backgroundColor = bgon;
}

function rollOff(x) {
  if (navigator.userAgent.indexOf("Firefox")!=-1){
    x.style.cursor = 'pointer';
  }
  else {
    x.style.cursor = 'hand';
  }
  x.style.backgroundColor = bgoff;
}

function writeMenus() {
  for (i=0; i<menus.length; i++) {
    document.write('<div id="menu' + i + '" class="menu" onmouseover="showMenu(\'menu' + i + '\');" onmouseout="hideMenu();">');
    for (j=0; j<menus[i].length; j++) {
      var item;
      var btm;
      if (j==(menus[i].length-1)) {
        btm = ' class="bottom"';
      } else {
        btm = '';
      }
      if (menus[i][j].external) {
        // This isn't great, but it pulls the URL from the javascript openWindow call
        var urlA = menus[i][j].url.split( "'" );
        
        item = '<div onclick="jumpTo2(\'' + urlA[1] + '\');" onmouseover="rollOn(this);" onmouseout="rollOff(this);"' + btm + '>';
      }
      else {
        item = '<div onclick="jumpTo(\'' + menus[i][j].url + '\');" onmouseover="rollOn(this);" onmouseout="rollOff(this);"' + btm + '>';
      }
      if (menus[i][j].red) {
        item +=  '<span class="red">' + menus[i][j].title + '</span></div>';
      } else {
        item +=  menus[i][j].title + '</div>';
      }
      document.write(item);
    }
    document.write('</div>');
  }
}

var menus = new Array();

// menus are created in calling file