//////////////////////////////////////////////////////////////////////////////////////
//
//  Function Name: imageSwap()
//
//  Description:
//    Changes the source of an image.
//
//  Arguments:
//    originalImage - required - Image to be replaced
//    newImage - required - replacement image
//
//  Returns:
//    N/A
//
//  Author: Shvatz (shvatz@wired.com)
//
//  Examples:
//    <a href="#" onMouseOver="imageSwap('myImg', 'on.gif');" onMouseOut="imageSwap('myImg', 'off.gif');">
//    	<img name="myImg" src="off.gif">
//    </a>
//
//
//////////////////////////////////////////////////////////////////////////////////////
function imageSwap(daImage, daSrc){
  var objStr,obj;

  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}


//////////////////////////////////////////////////////////////////////////////////////
//
//  Function Name: preloadImages()
//
//  Description:
//    Loads images into the browser's cache for later use.
//
//  Arguments:
//    parm1 - required - image file name
//    parm(2 - n) - optional - image file name(s)
//
//  Returns:
//    N/A
//
//  Author: Nadav Savio (nadav@wired.com)
//  Date:
//
//  Examples:
//    <body onLoad="preloadImages('header.gif','nav1.gif','foo.gif','scoob.gif');">
//
//////////////////////////////////////////////////////////////////////////////////////
function preloadImages() {
  // 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 = 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 = preloadImages.arguments[arg];
    }
  }
}
