// Javascript Code for Level Three pages:
// Flashes top and left-side menu items,
// and bursts and collapses the right-side menu items.
// Copyright 2001 David Roth. All Rights Reserved.

// determine which browser version
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1 : 0;
DOM = (document.getElementById) ? 1 : 0;
DHTML = (NS || IE || DOM) ? 1 : 0;
// check if this browser supports DOM image objects
if (DHTML) {
  // load an array of mouseout image names
  // (mouseover names are the same but are implied to have an "_on" appended)
  arImageFiles = new Array (
    "logo_asi", "logo1", "logo2", "logo3", "logo4", "logo5", "logo6",
    "menu1", "menu2", "menu3", "menu4", "menu5", "menu6", "menu7", "menu8", "menu9"
  );
  // set up the DOM image objects and source file references
  for (counter in arImageFiles) {
    eval( arImageFiles[counter] + ' = new Image();' );
    eval( arImageFiles[counter] + '.src = "images/" + arImageFiles[counter] + ".jpg" ' );
    eval( arImageFiles[counter] + "_on" + ' = new Image();' );
    eval( arImageFiles[counter] + "_on" + '.src = "images/" + arImageFiles[counter] + "_on.jpg" ' );
  }
  // (this particular image is really a gif, not a jpg...)
  logo_asi_on.src = "images/logo_asi_anim.gif";
}

// the function that does the left and top mouse work
function changeImages() {
  if (DHTML) {
    document[changeImages.arguments[0]].src = eval(changeImages.arguments[1] + ".src");
  }
}

// the function that does the mouse work on the right-menu items
function rollItem(elmt) {
  if (IE||DOM) {
    var elmtParent = elmt.parentElement;
    if (elmt.children[1].style.display == "block") //don't bother if it's already displayed
      return;
    for (i=0;i<elmtParent.children.length;i=i+2) { //close the currently displayed item
      var sibling = elmtParent.children[i];
      if (elmt!=sibling) //don't bother if it's our item
        collapseItem(sibling);
    }
    for (i=1;i<elmt.children.length;i++) { //expand our item's children
      elmt.children[i].style.display = "block";
    }
    elmt.style.backgroundColor = "#ff99ff"; //flash our item
    elmt.style.border = "1px solid #ffccff";
    elmt.style.borderColor = "#ffddff #ff66ff #ff66ff #ffddff";
  }
}

function collapseItem(elmtSblng) {
  if (IE||DOM) {
    if (elmtSblng.children[1].style.display == "none") //don't bother if it's already closed
      return;
    for (j=1;j<elmtSblng.children.length;j++) {
      elmtSblng.children[j].style.display = "none";  //collapse each child
    }
    elmtSblng.style.backgroundColor = "#ccccff"; //unflash the item
    elmtSblng.style.border = "1px solid #ccccff";
    elmtSblng.style.borderColor = "#eeeeff #aaaaff #aaaaff #eeeeff";
  }
}

