

//====================================================
// preloadImg() - Preloads an image
//
// Argument: String containing URL of image to preload
// Returns:  Image object created for the image
// Author:   Larry Coats
//====================================================
function preloadImg (zsUrl)
{
  // Prevent alerts in IE 3 and Netscape 2
  if (!document.images) return null;

  // Create an image object and preload the image
  var xo = new Image();   // Create the image object
  xo.src = zsUrl;         // Set URL - Preloads
  return xo;              // Return the image object
}

//====================================================
// swapImg() - Swaps one or more images and optionally
//             sets a status bar message
// Arguments:
//   One or more pairs of strings:
//     Name in <img> tag
//     Name of preloaded image
//   Optionally, a string to display in the status bar
// Returns:
//   true
//       Lets you code
//       onmouseover="return swapImg(...);"
//       instead of
//       onmouseover="swapImg(...); return true;"
// Author:   Larry Coats
//====================================================
function swapImg ()
{
  // Count number of name pairs passed
  var xiNumPairs = Math.floor(arguments.length / 2);

  // If an odd number arguments, the last is a status
  //   bar message
  var xsMsg = "*none*";    // Assume no status bar message
  if (arguments.length > xiNumPairs * 2)
    xsMsg = arguments[arguments.length-1];

  // Set the status bar message
  if (xsMsg != "*none*") status = xsMsg;

  // Prevent alerts in IE 3 and Netscape 2
  if (!document.images) return true;

  // Prepare to do rollovers
  var xsImg, xsPre;   // Receives a pair of arguments
  var xiArg = 0;      // Counts arguments

  // Loop - Once per pair of arguments passed
  var xiLoop;
  for (xiLoop = 0 ; xiLoop < xiNumPairs ; ++xiLoop)
  {
    // Fetch the pair of arguments
    xsImg = arguments[xiArg++];
    xsPre = arguments[xiArg++];

    // Swap the image
    eval ("document." + xsImg + ".src = " + xsPre + ".src");
  }
  return true;
}

