﻿//intImageNum = Math.round(Math.random() * 49) + 1;

//random number generator for home page image goes here
//-- a random number from 1 to 3 is stored within a global variable
//-- and appended to the filename of the imagevar intImageNum;
var strImageNumberList = "0,1,2,3";
var imageListArray = new Array();
var tempImageArray = strImageNumberList.split(",");
for (i=0; i<=tempImageArray.length; i++)
{
	imageListArray[i] = tempImageArray[i];
}

//var intImageNum;
//intImageNum = Math.round(Math.random() * imageListArray.length) + 1;

function randomizeImage() {
	var intImageNum;
		intImageNum = imageListArray[Math.round(Math.random() * imageListArray.length-1)];
	imageLoc = "images/thumbnails/title00" + intImageNum + ".jpg"
	document.images['random'].src = imageLoc;
}
	
var timerID = null;
var timerRunning = false;

//-- Starts the whole process when this page is opened.
//-- Called from the body tag.
function startTimer(){
	// Stop the clock (in case it's running), then make it go.
	stopTimer();
	runClock();
}

//-- Stops the timer when this page is closed (called from the body tag).
function stopTimer(){
	//stop the clock
	if(timerRunning) {
		clearTimeout(timerID);
		timerRunning = false;
	}
} 

//-- This function calls itself once every three seconds to update the image.
function runClock(){
randomizeImage();
	timerID = setTimeout("runClock()",6000);
	timerRunning = true;
}