var i = 0; //initialize the counter
var slide; //setup the image array variable



function SetSlideShow(){
	
	if(document.getElementById('slideShow'))
	{
	//hide all of the slideshow images	
	$$('#slideShow img').each(function(image){
		$(image).hide();
	});
		
	//dump the images into an array
	slide =  $('slideShow').childElements();

	//fade in the first slide and after it's finished, start the slideshow
	$( slide[0] ).appear({ duration:1.5, afterFinish: function () { SlideShow(); } });
	}

}	


function SlideShow() {


	if(document.getElementById('slideShow'))
	{
	
	//fade out the current slide
	$( slide[i] ).fade({ duration:1.5 });
	
	//add 1 to i 
	i++;		
	//check if we've reached the end of our slides, if so, rewind i to 0		
	if (i == slide.length) i = 0; 
	
	//fade in the next slide and after it's finished, loop this function
	$( slide[i] ).appear({ duration:1.5, afterFinish: function () { SlideShow(); } });
	
	}
} 
