var images_to_rotate = null;

function RotateBanner()
{
	images_to_rotate = $('screenshots').getElementsBySelector('a');			
	RotateImages(images_to_rotate);
}

function RotateImages(images)
{
	if (!images) return;
	var current_index = 0;

	$A(images).each(function(img, i)
	{
		if (img.visible())
		{
			current_index = i;
			return;
		}
	});

	var next_index = (current_index < (images.length -1)) ? current_index +1 : 0;

	window.setTimeout(function()
	{
		Effect.Fade(images[current_index], { duration:2 });
		Effect.Appear(images[next_index], { 
			duration:2, 
			afterFinish: function() 
			{
				current_index = next_index;
				RotateImages(images);
			}
		});
	}, 5000);
}

window.setTimeout(RotateBanner, 1000);
