/* 
    Script: image_swap.js

    Copyright: Fishnet NewMedia (c) 2003

    Create: 04.01.03

    Version: 1.0

    Compatibility: JavaScript 1.2

    Changes: none

    Description:  

        This script requires the preload script: image_load.js

        To swap an image, use the function SwapIMG() in the image's 
        onmouseover/onmouseout attribute value and pass the "NAME" 
        (defined by you) and action (either "over" or "out")

           For example: 
 
           onmouseover="SwapIMG('NAME','over');"

        The image's name attribute value must also be set to "NAME"

        This script also supports multiple instances for the same preloaded
        image object.  This is for when you have multiple instances of the
        same image on the page, such as a button. Instead of giving each
        image a different name and having to preload the image more than 
        once, you can preload the image using a generic image name like
        "NAME" and label the instance by giving each instance a unique name
        for the image "name" value, 
  
           For example: 

           <IMG src="button.gif" name="NAME-instance1">
           <IMG src="button.gif" name="NAME-instance2">
           <IMG src="button.gif" name="NAME-instance3">

        The image name (i.e. "NAME") and instance name (i.e. "instance3") 
        must be separated by an underscore. To swap the instance using the
        SwapIMG() function, follow the instuctions above, but include a
        third argument: the instance name.

           For example: 

           onmouseover="SwapIMG('NAME','over',"instance3");

*/

// Function swaps an image based on name and action arguments
function SwapIMG(name,action,instance){
    if (instance) document.images[name + "-" + instance].src = image_cache[name][action].src;
    else document.images[name].src = image_cache[name][action].src;
}