//	1=animate; 0=do not animate

animateFrame = 1;

//	imgNum keeps track of current image
//	equals the index into the filmStrip[] array
//	so it will be 0 to (filmStrip.length - 1)

		var imgNum = 0;


//	startEffect() initiates whatever effect is to be applied to the image

function startEffect(frame) {

	if (animateFrame) {
		sel_frame = frame;

//	sets imgNum to a randomly selected image
//	(not used if we increment imgNum)
//		imgNum = Math.floor(Math.random() * 10)

//	alert("length = " + filmStrip.length + "  imgNum = " + imgNum);


//	sets the iamge in the selected frame to the image specified by imgNum:
		document.images["frame" + sel_frame].src = filmStrip[imgNum].src;


//	increments imgNum or loops back to 0
//	(requires imgNum to be initialized outside of the startEffect() function)
//	(not used if we set imgNum randomly)
		imgNum = imgNum + 1;
		if (imgNum == filmStrip.length) {
			imgNum = 0;
		}

	}
}


//	empty function (not needed, but the onmouseout calls it)
function endEffect(frame) {
}


//	selects a frame/image at random and applies an effect to it
//	by calling the startEffect() and endEffect() functions
//	multiply random number by 7 because there are 7 frames numbered 0 through 6

function randomSelect() {

	theFrame = Math.floor(Math.random() * 7);
	startEffect(theFrame);
}

//	waits 2000 miliseconds and initiates the randomSelect() function

function frameLoop() {

	iTimerID = window.setInterval("randomSelect()",2000);
}

//	empty function to be called when page loads
//	to turn on animation, have this function call frameLoop() or a similar function

function pageLoad() {
	if (animateFrame) {

//	preload images after page loads 
//	so that people with slow modems don't have to wait to see the page

//	define array:
	filmStrip = new Array()

//	loads a .gif into each position:
	for(i=0; i < 10; i++) {
	   filmStrip[i] = new Image();
	   if (i < 10) {
	   	filmStrip[i].src = "images/img0" + i + ".gif";
	   } else {
	   	filmStrip[i].src = "images/img" + i + ".gif";
	   }
	} 

//	initializes imgNum to a randomly selected image
//	so that it starts with a different image each time the page is loaded
//	multiply be any number up to the length of the filmStrip array
//	(lower numbers force it to start with the lower number images)

		imgNum = Math.floor(Math.random() * filmStrip.length)

//	begins animation:

		frameLoop();
	}
}

