
// array to hold the swap images.
var swappedOut = new Array(), nSwappedOut = 0, pics = new Array();

function mout()
{
  /***** supports multiple images *****/
  // no need to pass any arguments

  var i;
  
  for(i = 0; i < nSwappedOut; i++)
  {
    // swap all tracked images
    swappedOut[i].src = swappedOut[i].oldSrc;
  }
}

function mover()
{
  /***** supports multiple images *****/
  // pass the arguments in as a list of place holder name
  // ie: mover('holder1', 'holder2', 'holder3');
  // it will find the extension and path of the original image
  // and use the same one for the new image
  // it will also assume that the mouseover image start with an 
  // underscore '_' character

  var i, j = 0, imgSwapped, args = mover.arguments, path = "", file = "", slash = 0;
  nSwappedOut = args.length;

  for(i = 0; i < nSwappedOut; i++)
  {
    imgSwapped = document.images[args[i]];  // gets the image
      
    if(imgSwapped != null)
    {
      // get the filename of the image
      slash = imgSwapped.src.lastIndexOf("/") + 1;
      file = imgSwapped.src.substring(slash);
      path = imgSwapped.src.substring(0, slash);

      // if the image is already m/o, then don't do it again
      if ( file.indexOf("_") != 0 )
      {
        // track all swapped images
        swappedOut[j++] = imgSwapped;
        imgSwapped.oldSrc = imgSwapped.src;
        imgSwapped.src = path + "_" + file;
      }
      else
      {
        nSwappedOut = 0;
      }
    }
  }
}

function preload()
{
  if( document.images )
  {
    if( ! document.pics ) document.pics = new Array();

    var i;
    var j = 0;
    var args = preload.arguments;

    for(i = 0; i < args.length; i++)
    {
      if (args[i].indexOf("#") != 0)
      {
        document.pics[j] = new Image;
        document.pics[j++].src = args[i];
      }
    }
  }
}
