/*

Author: Chris Faiette
Date: 12/19/06

Description: Revolves images in and out based on a specified revolveTime with a fade, must include fade.js by Patrick H. Lauke aka redux
Use: Include this js file by using <script type="text/javascript" src="scripts/imageRevolve.js"></script>
Where your main javascript goes, use the setRevolveSettings method to setup the required parameters
After the setup method has been called, call the startRevolving() method when ever you like. If you want
the images to start revolving 

This script also has builds in functionality from fade.js, which allows the images to fade in and out
when transitioning. If you do not have fade.js or just want to revolve images, comment out the lines
which require fade.js

Initial Setup
*/
var imageList;
var textList;

var objectIDIMG;
var totalObjectsIMG;
var countIMG;

var objectIDTXT;
var totalObjectsTXT;
var countTXT;

var indexIMG;
var indexTXT;
var revolveTime;

/* Input: 	image_list - an array of objects that should be revolved
			revolve_time - number of miliseconds to wait between each revolution
			image_id - the id of the image where the revolved images will take place
*/		
function setRevolveSettings(image_list,revolve_time,image_id)
{
	imageList = image_list;
	revolveTime = revolve_time;
	objectIDIMG = image_id;
	totalObjectsIMG = imageList.length;
	
	//Start with a random image
	countIMG = Math.floor(totalObjectsIMG * Math.random());
}

function setRevolveSettingsText(txt_list,revolve_time,text_id)
{
	textList = txt_list;
	revolveTime = revolve_time;
	objectIDTXT = text_id;
	totalObjectsTXT = textList.length;
	
	//Start with a random image
	countTXT = Math.floor(totalObjectsTXT * Math.random());
}

function startRevolving()
{
	fadeInit(); //REQUIRED by fade.js, remove or comment if you do not want to fade
	
	//Images
	indexIMG =  countIMG % totalObjectsIMG;
	document.getElementById(objectIDIMG).src = imageList[indexIMG];	
	countIMG = countIMG + 1;
	
	//Text
	indexTXT =  countTXT % totalObjectsTXT;
	document.getElementById(objectIDTXT).innerHTML = textList[indexTXT];	
	countTXT = countTXT + 1;
	
	setTimeout('startRevolving()',revolveTime);
	setTimeout('fadeOut(100);',revolveTime-1500); //REQUIRED by fade.js , remove remove or comment if you do not want to fade
}

