var oAutoRotators = new Array();

function Rotate(sId)
{
	var oAutoRotator;
	
	//get the autorotator based on the id
	oAutoRotator = oAutoRotators[sId];
	
	//is the auto rotator valid?
	if(oAutoRotator != null)
	{
		//increment the image id
		oAutoRotator.iImageId++;
		
		//have we exceeded the array?
		if(oAutoRotator.iImageId >= oAutoRotator.oPaths.length)
		{
			//set the index
			oAutoRotator.iImageId = 0;
		}
		
		//update the image
		oAutoRotator.oImage.src = oAutoRotator.oPaths[oAutoRotator.iImageId];
		
		//continue the rotator
		setTimeout('Rotate("' + sId + '")', oAutoRotator.iTiming);
	}
}

function GenerateAutoRotate(iTiming, sId, oPaths)
{
	var oImage;
	var oAutoRotator;
	
	//output the photo				
	document.writeln("<img src=\"" + oPaths[0] + "\" id=\"" + sId + "\" />");
	
	//get the image
	oImage = document.getElementById(sId);
	
	//add the auto rotater to the list
	oAutoRotator = new AutoRotator(oImage, sId, oPaths, iTiming);
	
	//add the auto rotator to the list
	oAutoRotators[sId] = oAutoRotator;
	
	//start the rotator
	setTimeout('Rotate("' + sId + '")', oAutoRotator.iTiming);
}

function AutoRotator(oImage, sId, oPaths, iTiming)
{
	this.oImage = oImage;
	this.sId = sId;
	this.oPaths = oPaths;
	this.iTiming = iTiming;
	this.iImageId = 0;
}