
// set the starting image.
var n = 0;			
var startedRight = false;

// The array of div names which will hold the images.
//var image_slide = new Array('image-1', 'image-2', 'image-3');
var image_slideRight;

// The number of images in the array.
var NumOfImagesRight;

// The time to wait before moving to the next image. Set to 3 seconds by default.
var wait = 4500;

// The Fade Function
function SwapImageRight(x,y) {		
	image_slideRight[x].appear({ duration: 2 });
	image_slideRight[y].fade({duration: 2});
}

// the onload event handler that starts the fading.
function StartSlideShowRight() {
  startedRight = true;
  playRight = setInterval('PlayRight()',wait);
}

function PlayRight() {
  image_slideRight = $$('#image-container-right div');
  NumOfImagesRight = image_slideRight.length;

	var imageShowRight, imageHideRight;

	imageShowRight = n+1;
	imageHideRight = n;
	
	if (imageShowRight == NumOfImagesRight) {
		SwapImageRight(0,imageHideRight);	
		n = 0;					
	} else {
		SwapImageRight(imageShowRight,imageHideRight);			
		n++;
	}
}

function StopRight () {
  if (startedRight == true)
  	clearInterval(playRight);				
  startedRight = false;
}

function GoNextRight() {
  image_slideRight = $$('#image-container-right div');
  NumOfImagesRight = image_slideRight.length;

  if (startedRight == true)
  	clearInterval(playRight);				
	
	var imageShowRight, imageHideRight;

	imageShowRight = n+1;
	imageHideRight = n;
	
	if (imageShowRight == NumOfImagesRight) {
		SwapImageRight(0,imageHideRight);	
		n = 0;					
	} else {
		SwapImageRight(imageShowRight,imageHideRight);			
		n++;
	}
}

function GoPreviousRight() {
  image_slideRight = $$('#image-container-right div');
  NumOfImagesRight = image_slideRight.length;

  if (startedRight == true)
  	clearInterval(playRight);				

	var imageShowRight, imageHideRight;
				
	imageShowRight = n-1;
	imageHideRight = n;
	
	if (n == 0) {
		SwapImageRight(NumOfImagesRight-1,imageHideRight);	
		n = NumOfImagesRight-1;						
	} else {
		SwapImageRight(imageShowRight,imageHideRight);			
		n--;
	}
}