//Javascript COPYRIGHT: RUUD DATA / Torgrim Ruud July 2008

function ImageRotate(img,interval) {

	//Fetch Image object and Object that holds Amount of images an img element can display.
	var image = document.getElementById(img);

	if (image.complete == false)
	{
		setTimeout("ImageRotate('" + img + "'," + (interval/2) + ")",interval);
		return;
	}

	var imgamount = document.getElementById(img + "-num");
	var RotateNum = document.getElementById(img + "-current").value;
	//Failsafe to go back to first object if reached end of Image list
	if (RotateNum > imgamount.value)
	{
		RotateNum = 1;
	}

	//Fetch the URL for the new image
	var url = document.getElementById(img + "-" + RotateNum);
	var src = url.value;
	//Change the URL
	image.src = src;
	//Prepare for next run
	RotateNum ++;
	document.getElementById(img + "-current").value = RotateNum;

	setTimeout("ImageRotate('" + img + "'," + interval + ")",interval);
}