<!--
window.onError = null;
// File: images.js
// ---------------
//
// A library of functions related to images.
//
// Global variables :

var offImgArray		= new Array();  // Array of 'off' images
var onImgArray		= new Array();  // Array of 'on' images

// ----------------------------------------------------------------------
//
// Function: cacheImages(num,path,ext)
// Pre cache the images in document
//  num  = number of images
//  path = base path of images (plus prefix)
//   ie. 'graphics/' becomes 'graphics/<number>-on.<extension>'
//                       and 'graphics/<number>-off.<extension>'
//       'graphics/filename' becomes 'graphics/filename<number>-on.<extension>'
//                               and 'graphics/filename<number>-off.<extension>'
//  ext  = filename extension (jpeg, jpg, gif, etc)
// save the images as '1-on.jpg', '1-off.jpg', '2-on.jpg', '2-off.jpg', etc.
//  or 'filename1-on.jpg', 'filename1-off.jpg', 'filename2-on.jpg',
//     'filename2-off.jpg', etc.
function cacheImages(num,path,ext)
{
  if (version() <= 2)
    return false;

  var offImgsrc	= "";
  var onImgsrc	= "";
  var imagenum  = "";

  for ( var i = 0; i <= num-1; i++ )
  {
    imagenum		= i+1;

    onImgArray[i]	= new Image();
    onImgsrc		= path + imagenum + "-on." + ext;
    onImgArray[i].src	= onImgsrc;

    offImgArray[i]	= new Image();
    offImgsrc		= path + imagenum + "-off." + ext;
    offImgArray[i].src	= offImgsrc;
  }

  return true;
}
// ----------------------------------------------------------------------

// Function: imageOn(image number)
// Switches an image on
function imageOn(i)
{
  if (version() <= 2)
    return false;

  document.images[i-1].src = onImgArray[i-1].src;
  return true;
}
// ----------------------------------------------------------------------

// Function: imageOff(image number)
// Switches an image off
function imageOff(i)
{
  if (version() <= 2)
    return false;

  document.images[i-1].src = offImgArray[i-1].src;
  return true;
}
// ----------------------------------------------------------------------

// Function: imageSwitch(from image number, to image number)
// Switches an image off
function imageSwitch(i,j)
{
  if (version() <= 2)
    return false;

  document.images[i-1].src = onImgArray[j-1].src;
  return true;
}
// ----------------------------------------------------------------------

// -->
