/* JF - This script is used to swap jpeg images at a specified interval.

	FUNCTION INPUTS USED BELOW
	prefix - common portion of name shared by all images in swap set
	total - total number of images in swap set
	pause - interval between swaps
	imgname - the name assigned to the IMG element in the calling document
	
	NOTES
	- 	All images in a swap set should be named as follows:
		xxxx1.jpg,xxxxx2.jpg ... xxxxn.jpg
		where xxxx is the common prefix and n is the total number of images
	- 	The script could be changed to support multiple image formats
*/

// ---- BEGIN GLOBALS ----

// Create global image array
var myswapimgs = new Array();
// Create global image incrementer
//	Start with 2 since first image is loaded by the html page
var c = 2;

// ---- END GLOBALS ----

// ---- BEGIN FUNCTIONS ----
function preloadImgByPrefix(prefix,total)
{
	var path = ""
	for (n = 1; n <= total; n++)
	{
		myswapimgs[n] = new Image();
		myswapimgs[n].src = "images/" + prefix + n + ".jpg";
	}
}

// Performs swaps
function swapImgByPrefix(total,prefix,imgobj)
{
	if (c > total)
	{
			c = 1;
	}
	var img_src = "images/" + prefix + c + ".jpg";
	imgobj.src = img_src;
	c++;
}

// ---- END FUNCTIONS ----

