
// set the starting image.
var l = 0;			
var startedPg = false;

// The array of div names which will hold the images.
//var image_slide = new Array('image-1', 'image-2', 'image-3');
var image_slidePg;

// The number of images in the array.
var NumOfImagesPg;

// The time to wait before moving to the next image. Set to 3 seconds by default.
var wait = 4500;

// The Fade Function
function SwapImagePg(x,y) {		
	image_slidePg[x].appear({ duration: 2 });
	image_slidePg[y].fade({duration: 2});
}

// the onload event handler that starts the fading.
function StartSlideShowPg() {
  startedPg = true;
  playPg = setInterval('PlayPg()',wait);
}

function PlayPg() {
  image_slidePg = $$('#image-container-pg div');
  NumOfImagesPg = image_slidePg.length;

	var imageShowPg, imageHidePg;

	imageShowPg = l+1;
	imageHidePg = l;
	
	if (imageShowPg == NumOfImagesPg) {
		SwapImagePg(0,imageHidePg);	
		l = 0;					
	} else {
		SwapImagePg(imageShowPg,imageHidePg);			
		l++;
	}
}

function StopPg () {
  if (startedPg == true)
  	clearInterval(playPg);				
  startedPg = false;
}

function GoNextPg() {
  image_slidePg = $$('#image-container-pg div');
  NumOfImagesPg = image_slidePg.length;

  if (startedPg == true)
  	clearInterval(playPg);				
	
	var imageShowPg, imageHidePg;

	imageShowPg = l+1;
	imageHidePg = l;
	
	if (imageShowPg == NumOfImagesPg) {
		SwapImagePg(0,imageHidePg);	
		l = 0;					
	} else {
		SwapImagePg(imageShowPg,imageHidePg);			
		l++;
	}
}

function GoPreviousPg() {
  image_slidePg = $$('#image-container-pg div');
  NumOfImagesPg = image_slidePg.length;

  if (startedPg == true)
  	clearInterval(playPg);				

	var imageShowPg, imageHidePg;
				
	imageShowPg = l-1;
	imageHidePg = l;
	
	if (l == 0) {
		SwapImagePg(NumOfImagesPg-1,imageHidePg);	
		l = NumOfImagesPg-1;						
	} else {
		SwapImagePg(imageShowPg,imageHidePg);			
		l--;
	}
}