




// set the starting image.
var slideindex = 0;			

// The array of div names which will hold the images.
var image_slide = new Array('image-1', 'image-2', 'image-3','image-4','image-5','image-6');


// The number of images in the array.
var NumOfImages = image_slide.length;

	
// The time to wait before moving to the next image. Set to 4 seconds by default.
var wait = 4000;

// The Fade Function
function SwapImage(x,y) {//alert(image_slide[x]+' '+x+' : '+y+' '+image_slide[y]);		
	$(image_slide[x]).appear({ duration: 0.8 });
	$(image_slide[y]).fade({duration: 0.8});
}

// the onload event handler that starts the fading.
function StartSlideShow() {
	play = setInterval('Play()',wait);
	if($('PlayButton')!=null)
		$('PlayButton').hide();
	if($('PauseButton')!=null)
		$('PauseButton').appear({ duration: 0});
	
	updatecounter();
								
}

function Play() {
	var imageShow, imageHide;
	if(slideindex>5)
		i=0;
	imageShow =slideindex+1;
	imageHide =slideindex;
	
	if (imageShow == NumOfImages) {
		SwapImage(0,imageHide);	
		slideindex= 0;					
	} else {
		SwapImage(imageShow,imageHide);			
		slideindex++;
	}
	
	var textIn = slideindex+1 + ' of ' + NumOfImages;
	updatecounter();
}

function Stop () {
	clearInterval(play);
	if($('PlayButton')!=null)	
		$('PlayButton').appear({ duration: 0});
	if($('PauseButton')!=null)
		$('PauseButton').hide();
}

function GoNext() {
	clearInterval(play);
	if($('PlayButton')!=null)
		$('PlayButton').appear({ duration: 0});
	if($('PauseButton')!=null)
		$('PauseButton').hide();
	
	var imageShow, imageHide;

	imageShow = slideindex+1;
	imageHide = slideindex;
	
	if (imageShow == NumOfImages) {
		SwapImage(0,imageHide);	
		slideindex = 0;					
	} else {
		SwapImage(imageShow,imageHide);			
		slideindex++;
	}

	updatecounter();
}

function GoPrevious() {
	clearInterval(play);
	if($('PlayButton')!=null)
		$('PlayButton').appear({ duration: 0});
	if($('PauseButton')!=null)
		$('PauseButton').hide();

	var imageShow, imageHide;
				
	imageShow = slideindex-1;
	imageHide = slideindex;
	
	if (slideindex == 0) {
		SwapImage(NumOfImages-1,imageHide);	
		slideindex = NumOfImages-1;		
		
					
	} else {
		SwapImage(imageShow,imageHide);			
		slideindex--;
		
	}
	
	updatecounter();
}

function updatecounter() {
	var textIn = slideindex+1 + ' of ' + NumOfImages;
	//document.getElementById('Counter').innerHTML = textIn;
}

