	
	/* Set the Defaults */
	rotationSeconds = 5;
	imageID = "rotationImage";
	linkID = "rotationLink";

	imageArr = new Array();
	linkArr = new Array();
	targetArr = new Array();
	
	currentIndex = -1;
	
	function preload() {
		/* Preload the images here */
		 
		imageObj = new Image();
		for(i=0; i<=imageArr.length; i++) {          
			imageObj.src=imageArr[i];     
		}
		
	}
	
	function startRotation() {
	
		preload();
		doRotation();
	
	}
	
	function doRotation() {

		currentIndex = getNextIndex();
				
		replaceImage(currentIndex);		
		setTimeout('doRotation()', rotationSeconds*1000)
	
	}
	
	function getNextIndex() {
	
		var MIN_INDEX = 0;
		var MAX_INDEX = imageArr.length-1;
	
		if (imageArr.length == 0) {	//no images
			return -1;
		} else if (imageArr.length == 1) {	//only one image
			return 0;
		}
		
		//put an upper bound on the loop for safety
		for (i=0; i<100; i++) {
	
			//from 0 to 1 above the index we want (for the purpose of floor())
			randomNumber = Math.random()*(MAX_INDEX+1);
			randomNumber = Math.floor(randomNumber);
			
			if (randomNumber >= MAX_INDEX) {
				randomNumber = MAX_INDEX;
			}
			
			if (randomNumber != currentIndex) {
				return randomNumber;
			}
		
		}

		return currentIndex;
	
	}

	
	function replaceImage(arrIndex) {
	
		document.getElementById(imageID).src = imageArr[arrIndex];
		document.getElementById(linkID).href = linkArr[arrIndex];
		document.getElementById(linkID).target = targetArr[arrIndex];
	
	}