// This is index.js which contains the code to rotate through a series of testimonial quotes
// and also rotate through the calendar screen shots in index.htm.

// preload first couple of images and create other image variables.

var CAL_INTERVAL = 2500;

var image1=new Image();
image1.src="ek_images/home_image_0.gif"; 

var image2=new Image();
var image3=new Image();
var image4=new Image();
var image5=new Image();
var image6=new Image();
var image7=new Image();
var image8=new Image();
var image9=new Image();
var image10=new Image();
var image11=new Image();
var image12=new Image();

var maxImageNum = 2;

function LoadOtherImages()
{
	image2.src="ek_images/home_image_1.gif";
	maxImageNum = 2;
	image3.src="ek_images/home_image_2.gif";
	maxImageNum = 3;
	image4.src="ek_images/home_image_3.gif";
	maxImageNum = 4;
	image5.src="ek_images/home_image_7.gif";
	maxImageNum = 5;	
	image6.src="ek_images/home_image_5.gif";
	maxImageNum = 6;	
	image7.src="ek_images/home_image_6.gif";
	maxImageNum = 7;
	image8.src="ek_images/home_image_4.gif";
	maxImageNum = 8;	
	image9.src="ek_images/home_image_8.gif";
	maxImageNum = 9;	
	image10.src="ek_images/home_image_9.gif";
	maxImageNum = 10;
	image11.src="ek_images/home_image_10.gif";
	maxImageNum = 11;
	image12.src="ek_images/home_image_11.gif";
	maxImageNum = 12;
}

var imageNum=1;

function StartImageShow()
{
	//start the recursive call to function "Show Image()" after 4 seconds
	setTimeout("ShowImage()",4000)
	
	//spawn thread to load other images in background
	setTimeout("LoadOtherImages()",4000)
}

function ShowImage()
{
	//if browser does not support the image object, exit.
	if (!document.images)
		return

	document.images.samplecal.src=eval("image"+imageNum+".src")
	
	if (imageNum<maxImageNum)
		imageNum++
	else
		imageNum=1
	
	setTimeout("ShowImage()",CAL_INTERVAL)
}

// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See:  http://www.msc.cornell.edu/~houle/javascript/randomizer.html

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};

// end central randomizer. -->

/* Testimonial Display  Variables */

var numTestim=10;
var TestimTime = 5000;
var randTestim = rand(numTestim) - 1;

/* define text for testimonials  */
var testimText= new Array(numTestim);

testimText[0]='"[EventKeeper] saves me a lot of time..."';
testimText[1]='"[Our theatre] schedules are constantly changing..."';
testimText[2]='"Our patrons love it..."';
testimText[3]='"EventKeeper is very reasonably priced..."';
testimText[4]='"Our patrons are totally informed about our workshops..."';
testimText[5]='"..the website is always up to date..."';
testimText[6]='"..customize the colors to match the rest of our website..."';
testimText[7]='"We love you EventKeeper..."';
testimText[8]='"...update our site without any hassles..."';
testimText[9]='"...provides great tech support ..."';

var theIndex=randTestim + 1;

function StartTestimony()
{
   if (document.images)
   {
      setTimeout('ChangeTestimony()', TestimTime);  
   }
}

function ChangeTestimony()
{
    theIndex+=1;

    if (theIndex > numTestim-1)
    	theIndex=0;

		document.all("TESTIMCELL").innerText = testimText[theIndex];	
		setTimeout('ChangeTestimony()', TestimTime);
}

