
this.document.sr = new Array();

/*
	This function will create images and store them into an array.
	The src for the images is passed into the function using a comma
	separated list. (i.e. /mtb/images/submit_over.gif,/mtb/images/reset_over.gif,...).
	Keep in mind that this method should be called in the body tag and
	is used to decrease the response time on mouseOver type events where
	an image would change.
*/
function preloadImages()
{
	if(this.document.images)
	{
	       // Check to see if this variable is created already.
	       if(!this.document.storedImages)
	       {
	               this.document.storedImages=new Array();
	       }
	       var i = 0;                                 // index of the arguments array
	       var j = this.document.storedImages.length; // index of the storedImages array
	       var args = preloadImages.arguments;             // list of src's of images

               // Loop through src's, create an images, store the src for that image.
	       for(i=0; i<args.length; i++)
	       {
	               if(args[i].indexOf("#") != 0)
	               {
	                       this.document.storedImages[j]=new Image();
	                       this.document.storedImages[j].src = args[i];
	                       j++;
	               }
	       }
	}
}
function findObject(name, doc)
{
	var p;
	var i = 0;
	var x;

       // if a document object has not been passed into the method then use the local one.
	if(!doc)
	{
	       doc = this.document;
	}


	// If the name attribute was sent in with a frame name attached get the doc for the
	// frame.
	if(((p=name.indexOf("?")) > 0) && (parent.frames.length))
	{
	       doc = parent.frames[name.substring(p+1)].document;
	       name = name.substring(0,p);
	}


	// If the image does not appear in the document check all of the.
	if(!(x=doc[name]) && doc.all)
	{
	       x = doc.all[name];
	}


	for(i=0; !x && i<doc.forms.length; i++)
	{
	       x = doc.forms[i][name];
	}

       for(i = 0; !x && doc.layers && i < doc.layers.length; i++)
	{
	       x = findObject(name, doc.layers[i].document);
	}

       return x;
}
function swapImage()
{
	var i = 0;
	var j = 0;
	var x = 0;
	var args = swapImage.arguments;

       if(this.document.sr.length != 0)
	{

               swapImgRestore();
	}

       j = this.document.sr.length;

       // To Support legacy use of this function.
	if(args.length == 4)
	{
	       if((x = findObject(args[0])) != null)
	       {
	               this.document.sr[j++] = x;
	               if(!x.oSrc)
	                       x.oSrc = x.src;
	               x.src = args[2];
	       }
	}
	else if(arguments.length == 2)
	{
	       if((x = findObject(args[0])) != null)
	       {
	               this.document.sr[j++] = x;
	               if(!x.oSrc)
	                       x.oSrc = x.src;

                       x.src = args[1];
	       }

       }

       for(i = 0; i < (args.length-2); i+=3)
	{
	       if((x = findObject(args[i])) != null)
	       {
	               this.document.sr[j++] = x;
	               if(!x.oSrc)
	               {
	                       x.oSrc = x.src;
	               }
	               x.src=args[i+2];
	       }
	}

}

function swapImgRestore()
{
	var i = 0;
	var x = 0;
	var args = this.document.sr;


	for(i = 0; args && i < args.length && (x = args[i]) && x.oSrc; i++)
	{
	       x.src = x.oSrc;
	}

       this.document.sr.length=0;
}
