function WM_preloadImages() {

/*
WM_preloadImages()
Loads images into the browser's cache for later use.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
Author Email: nadav@wired.com

Usage: WM_preloadImages('image 1 URL', 'image 2 URL', 'image 3 URL', ...);
*/

  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
  }
}

function WM_imageSwap(daImage, daSrc){
/*
WM_imageSwap()
Changes the source of an image.
Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)
Author: Shvatz
Author Email: shvatz@wired.com
Usage: WM_imageSwap(originalImage, 'newSourceUrl');
Requires: WM_preloadImages() (optional, but recommended)
*/
  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name 
    // or the array placement and swap the source.
    // Thanks to Nadav for suggesting that typeof be 
    // used to differentiate between them.
    if ((typeof daImage == 'string') || (typeof daImage == 'number')) {
      document.images[daImage].src = daSrc;
      // Or if an object reference was used, make sure it's an image.
    } else if (daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}
