// JavaScript Document

//function requires an array called imageArray which holds the images as first param and caption as the second
function rotateImages(imageNo)
{
	var bodyDivItem = document.getElementById("bodyDiv"); //image tag that will contain rotated images
	var linkItem = document.getElementById("findOutMoreLink"); //image tag that will contain rotated images
		
	var speed = 10000; //in miliseconds, smaller is faster 
	var nextImage = imageNo + 1;
	var lstrImageAndFileArray;
	
	//make sure there is an image at the requested position
    if (imageArray[imageNo] != null)
    {
        lstrImageAndFileArray = imageArray[imageNo].toString().split("___");
        bodyDivItem.style.backgroundImage = "url('" + lstrImageAndFileArray[0] + "')";
        linkItem.href = lstrImageAndFileArray[1];
        setTimeout("rotateImages(" + nextImage + ")", speed);	
    }
    else //restart
    {
        rotateImages(0);  
    }
}

