var titles = new Array();
var links = new Array();

var img_id = new Array();
var active_section = -1;
var wait = 50;

function populate_dropmenu() {
  var i;
  document.getElementById("dropmenu").options[0] = new Option('Quick Links...', '#');
  document.getElementById("dropmenu").options[1] = new Option('----', '#');

  for (i=0; i<links.length; i++) {
    document.getElementById("dropmenu").options[document.getElementById("dropmenu").length] =
       ((links[i] != null) ? new Option(titles[i], links[i]) : new Option('----', '#'));
  }
}

function menu_init() {
  var i;
  for (i=0; i<img_id.length; i++) {
    var img = new Image(145,20);
    img.src = "images/menu/" + img_id[i] + "-over.gif";
    img = new Image(145,20);
    img.src = "images/menu/" + img_id[i] + "-out.gif";
    img = new Image(145,20);
    img.src = "images/menu/" + img_id[i] + "-active.gif";
  }

  self.setTimeout("set_id('" + img_id[active_section] + "-lo', '" + img_id[active_section] + "-active')", wait);
}

function set_id(old_id, new_id) {  try { document.getElementById(old_id).id = new_id; } catch (e) { } }
function set_active(active)       {  active_section = active;  }
function do_over(obj, id)          {  obj.id=img_id[id] + (id != active_section ? "-hi" : "-active"); }
function do_out(obj, id)            {  if (id != active_section)    obj.id=img_id[id] + "-lo"; }

function create_menu_item(title, name, link, link_args, spacer) {
  // generate the stylesheet for the rollover effect.
  // three images are required in the "images/menu/" directory:
  //    1. name-out.gif         transparent background   (mouseout effect)
  //    2. name-over.gif       BLUE background              (mouseover effect)
  //    3. name-active.gif     GREEN background           (indicates the current page)
  document.write('<style>\n');
  document.write("#" + name + "-lo { background: url('../images/menu/" + name + "-out.gif') no-repeat; }\n");
  document.write("#" + name + "-hi { background: url('../images/menu/" + name + "-over.gif') no-repeat; }\n");
  document.write("#" + name + "-active { background: url('../images/menu/" + name + "-active.gif') no-repeat; }\n");
  document.write('</style>\n');

  // generate the div, spacer, and link for the menu item
  // optionally, link_args can be used to insert a target="_blank" or other HTML elements inside the anchor tag
  document.write('<div class="menu-button" id="' + name + '-lo" ' +
		'onmouseover="do_over(this, ' + img_id.length + ');" ' +
		'onmouseout= "do_out(this, ' + img_id.length + ');"' +
		(spacer ? '  style="margin-top: 15px;"' : '') + '>\n');
  document.write('\t<a href="' + link + '" ' + link_args + '><img src="images/spacer.gif" width="145px" height="20px" border="0"></a>\n');
  document.write('</div>\n\n');

  // fill the img_id array so that we can call the rollover effects
  img_id[img_id.length] = name;

  if (spacer) {
    links[links.length] = null;
    titles[titles.length] = null;
  }
  links[links.length] = link;
  titles[titles.length] = title;
}
