// Image Rollovers
// An alternate to using the recommended CSS functionality
// when the latter is not a possibility for some reason.

// The JavaScript remembers the original image URL, and thus a file
// does not need to be passed unless you're rolling out to an image
// that is different from the one originally loaded.

var oldImages = new Array();
var imgPath   = ''; // a path to the images if all the same (else blank)

function imageSwap(imgName, newImage, setPath) {

  if( newImage != undefined && newImage != null ) {
  // Store the old image for when it needs to be reverted
  var oldImageParts  = new Array();

    oldImageURL        = document.getElementsByName(imgName)[0].src;
    oldImageParts      = oldImageURL.split('/');
    oldImages[imgName] = oldImageParts[oldImageParts.length - 1];

  } else {
  // Set the image to be loaded to the old (original) value
    if( oldImages[imgName] != undefined ) {
      newImage = oldImages[imgName];
    } else {
      // Not enough data to work with
      return false;
    }
  }

  // Swap the path if requested
  imgPath = (setPath != undefined) ? setPath : imgPath;

  // Swap the image with another
  document.getElementsByName(imgName)[0].src = imgPath + newImage;

} // ! imageSwap function

// Pop open a new window
function newWindow(name, url, width, height, settings) {

  if( settings == 'undefined' ) {
  // Set default settings for the new window
    settings = 'toolbar=0, menubar=0, location=0, status=0, scrollbars=yes';
  }

  // Open the new window
  window.open(url, name, 'width=' + width + ', height=' + height + ', ' + settings);
  return false;

} // ! newWindow