// set the starting image.
var i = 0; 

// The array of div names which will hold the images.
var image_slide;

// The number of images in the array.
var NumOfImages = 0;

// The time to wait before moving to the next image. Set to 3 seconds by default.
var wait = 3000;

// The Fade Function
function SwapImage(x,y) {
$(image_slide[x]).appear({ duration: 1.0 });
$(image_slide[y]).fade({duration: 1.0});
}

// the onload event handler that starts the fading.
function StartSlideShow() {

    var slides = $$(".simple-slide");
    NumOfImages = slides.length;
    image_slide = new Array(slides.length);

    for (var j = 0; j < slides.length; j++) {
    image_slide[j] = slides[j].id;
}
	play = setInterval('Play()',wait);								
}

function Play() {
	var imageShow, imageHide;

	imageShow = i+1;
	imageHide = i;
	
	if (imageShow == NumOfImages) {
		SwapImage(0,imageHide);	
		i = 0;					
	} else {
		SwapImage(imageShow,imageHide);			
		i++;
	}
}

