// Front page image swapping stuff
// @author Richard Christie
// @version 1.0

var frameTime = 2000;
var curImage = 0;
var imageBase = "../scaled/";
var swapTimer;
function doSwap( )
{
	if ( curImage == document.RichardsPreload.loadedImages.length )
		curImage = 0;
	ImageSwap( document.RichardsPreload.loadedImages[curImage].src );
	curImage++;
	
	swapTimer = setTimeout( "doSwap();", frameTime );
}

function ImageSwap( daSrc )
{
	var objStr,obj;
	var daImage = 'Image1';
	
	// 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 crap browsers... cough.. nutscrape... cough ... IE3... cough
			objStr = 'document.' + daImage;
			obj = eval(objStr);
			obj.src = daSrc;
			}
		else if ((typeof(daImage) == 'object') && daImage && daImage.src)
			{
			daImage.src = daSrc;
			}
		else
			alert( "oops, weird src arg" );
		}

}


function PreloadImages()
{
  // Don't bother if there's no images in the document

	if (document.images)
	{
	if (typeof(document.WM) == 'undefined')
		document.RichardsPreload = new Object();
		
	document.RichardsPreload.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.RichardsPreload.loadedImages[arg] = new Image();
		// Then set the source of that image to the current argument.
		document.RichardsPreload.loadedImages[arg].src = imageBase + PreloadImages.arguments[arg];
		}
	}
	
	swapTimer = setTimeout( "doSwap();", frameTime );
}