// This is a generic script for highlighting links with rollovers.
// It was taken from http://www.rabich.de
//
// To use it, you have to make sure, that the image file names exist in two
// variations:
// "button1.gif"
// "button1_high.gif"
//
// Also, make sure your link has the same name as the image, i.e. if your link
// is called "button1", the images will be called "button1.gif" and
// "button1_high.gif".
//
// Then preload the images and select the active one when the page loads by using the following code:
// <body ... onload="load_images('button1','/images/button1');load_images('button2','/images/button2');load_images('button3','/images/button3');select_active_image();">
//
// For a link, use something like
//    <a href="../scripts/..." onmouseover="return show_image('button1');"
//    onmouseout="hide_image('button1');"><img src="/images/button1.gif" name="button1"
//    width=".." height=".." border="0" alt="Button 1"></a>
//

// Create the image array
var Img = new Array();

// Create the image object
function doc_image(filename) {
  this.normal     = new Image();
  this.high       = new Image();
  this.normal.src = filename + ".gif";
  this.high.src   = filename + "_high.gif";
  return this;
}

// Create the image information
function load_images(name, filename) {
  Img[name] = new doc_image(filename);
}

// Show the image
function show_image(name) {
  document[name].src = Img[name].high.src;
  return true;
}

// Hide the image, but only if it's not the image of the current page
function hide_image(name) {
  var currentPage;
  currentPage = document.URL;
  currentPage = currentPage.substring(currentPage.lastIndexOf("/")+1);

  if (name != currentPage.substr(0,name.length)) {
    document[name].src = Img[name].normal.src;
  }
}

// Select the active image, depending on the page's file name.
function select_active_image () {
  var i;
  var currentPage;
  var keyLength;

  currentPage = document.URL;
  currentPage = currentPage.substring(currentPage.lastIndexOf("/")+1);

  for (i in Img) {
    keyLength = i.length;
    if (i == currentPage.substr(0,keyLength)) {
      document[i].src = Img[i].high.src;
    }
  }
}
