var inRotation = true;
var isIE = false;
var fadeDuration = 0.5;
if (document.getElementById&&document.all&&!window.opera)
{
	isIE = true;
}

addEvent(window,"load" , StartRotation);
addEvent(window,"beforeunload" , StopRotation);

function StopRotation()
{
	inRotation = false;
}

function StartRotation()
{
	window.setInterval("DoRotation();", 3000);
}

function DoRotation()
{
	if (!inRotation)
	{
		return;
	}
	var elements = document.getElementsByName("RotatedScreenshots");
	for (var i=0;i<elements.length ;i++ )
	{
		var belongedFolder = elements[i].attributes.belongedFolder.value;
		var currentPos = elements[i].attributes.currentPos.value*1;
		var screenshots = elements[i].attributes.screenShots.value;
		var arrScreenshots = screenshots.split(",");
		currentPos+=1;
		if (currentPos>=arrScreenshots.length)
		{
			currentPos = 0;
		}
		elements[i].attributes.currentPos.value = currentPos;


		elements[i].style.filter="blendTrans(duration="+fadeDuration+")";
		if (isIE)
		{
			elements[i].filters.blendTrans.Apply();
		}

		var newUrl = arrScreenshots[currentPos];
		if (newUrl.indexOf("://") > 0)
		{
			elements[i].src = newUrl;
		}
		else
		{
			elements[i].src = belongedFolder + newUrl;
		}
		if (isIE)
		{
			elements[i].filters.blendTrans.Play();
		}

	}
}