var currentImage = -1;
var timeout = 0;
function showNextImage()
{
	var nextImageIndex = currentImage + 1;
	
	if (nextImageIndex < images.length)
	{
		// Fade in next image
		$('big_photo_'+nextImageIndex).appear({duration:.5});
		currentImage = nextImageIndex;
		
		// Set timeout to next image
		timeout = setTimeout(showNextImage,4000);
	}
	else
	{
		// It's the last image, so hide all the images but the first and last
		for (var i=1; i<images.length-1; i++)
		{
			$('big_photo_'+i).style.display = 'none';
		}
		// Fade out the last image
		$('big_photo_'+(images.length-1)).fade({duration:.5});
		currentImage = -1;
		
		// Set timeout to next image
		timeout = setTimeout(showNextImage,4000);
	}	
}

// Start slideshow
showNextImage();
