// JavaScript Document
// Create array of image names to loop through the image rotator
var arImages = new Array("img01.jpg", "img02.jpg", "img03.jpg", "img04.jpg", "img05.jpg", "img06.jpg", "img07.jpg", "img08.jpg", "img09.jpg", "img10.jpg", "img11.jpg", "img12.jpg");
var iImg = 1;
var intRotator;
function startRotator(){
	// start an interval to swap the image every 3 seconds
	intRotator = setInterval(swapImage, 3000);
}
function swapImage(){
	var img = document.getElementById("rotator-img");
	if(img && img.src){  // use object detection to make sure the element exists
		if(iImg > arImages.length-1) iImg=0;  // check to see if we've reached the end of our array, if so reset the index to 0 to start over.
		img.src = "images/slideshow-home/" + arImages[iImg];  // change the src of the image to the next image in the array
		iImg++;  // increment the iImg index so it will use the next image in the array next time thru
	}else{
		// Something is wrong, stop the interval
		clearInterval(intRotator);
	}
}
// have the startRotator function run when the page loads
window.onload = startRotator;

