/**
 * An array with slides
 * 
 * @var array
 */
var images = null;

/**
 * The current slide
 * 
 * @var int
 */
var current = 0;

function startSlideshow()
{
	/* retrieve and set all images from container */
	images = $$('#content-right img');
	
	/* update progress */
	updateProgress(current, images.length);
	
	/* start the slideshow */
	setInterval("showSlide()", 4000);
}

function showSlide()
{
	/* fade the current slide */
	Effect.Fade(images[current].id, {"duration":0.5, "from":1.0, "to":0.0});
	
	/* determine next slide */
	current = current == (images.length - 1) ? 0 : current + 1; 
		
	/* update progress */
	updateProgress(current, images.length);
	
	/* show the next slide */
	Effect.Appear(images[current].id, {"duration":0.5, "from":0.0, to:1.0, "queue": "end" });
}

function updateProgress(index, max)
{
	/* retrieve progress element */
	elem = $('slideshow-progress');
	
	/* check for element */
	if (elem)
	{
		/* since the index starts at 0, increase it with 1 */
		index++;
		
		/* update content */
		elem.innerHTML = index + '/' + max; 
	}
}
