
// set the starting image.
var j = 0;			

// The array of div names which will hold the images.
//var image_slide = new Array('image-1', 'image-2');
var comp_slide = new Array('comp-1', 'comp-2');
// The number of images in the array.
var NumOfCompImages = 2;

/*function initSlides(arrayElements, numElements) {
	alert(numElements);
	image_slide = arrayElements;
	NumOfImages = numElements;
}*/
	
// The time to wait before moving to the next image. Set to 4 seconds by default.
var wait = 12000;

// The Fade Function
function SwapCompImage(x,y) {
	$(comp_slide[x]).appear({ duration: 0.5 });
	$(comp_slide[y]).fade({duration: 0.5});
}

// the onload event handler that starts the fading.
function StartCompSlideShow() {
	
	playComp = setInterval('PlayComp()',wait);
	//$('PlayButton').hide();
	//$('PauseButton').hide();
	
	//updateCompCounter();								
}

function PlayComp() {
	var imageCompShow, imageCompHide;

	imageCompShow = j+1;
	imageCompHide = j;
	
	if (imageCompShow == NumOfCompImages) {
		SwapCompImage(0,imageCompHide);	
		j = 0;					
	} else {
		SwapCompImage(imageCompShow,imageCompHide);			
		j++;
	}
	
	//var textInComp = j+1 + ' of ' + NumOfCompImages;
	//updateCompCounter();
}

function StopComp () {
	clearInterval(playComp);				
	//$('PlayButton').appear({ duration: 0});
	//$('PauseButton').hide();
}

function GoNextComp() {
	//clearInterval(play);
	//$('PlayButton').appear({ duration: 0});
	//$('PauseButton').hide();
	
	var imageCompShow, imageCompHide;

	imageCompShow = j+1;
	imageCompHide = j;
	
	if (imageCompShow == NumOfCompImages) {
		SwapCompImage(0,imageCompHide);	
		j = 0;					
	} else {
		SwapCompImage(imageCompShow,imageCompHide);			
		j++;
	}

	//updateCompCounter();
}

function GoPreviousComp() {
	//clearInterval(play);
	//$('PlayButton').appear({ duration: 0});
	//$('PauseButton').hide();

	var imageCompShow, imageCompHide;
				
	imageCompShow = j-1;
	imageCompHide = j;
	
	if (j == 0) {
		SwapCompImage(NumOfCompImages-1,imageCompHide);	
		j = NumOfCompImages-1;		
		
		//alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
					
	} else {
		SwapCompImage(imageCompShow,imageCompHide);			
		j--;
		
		//alert(imageShow + ' and ' + imageHide)
	}
	
	//updateCompCounter();
}

/*function updateCompCounter() {
	var textInComp = j+1 + ' of ' + NumOfCompImages;
	document.getElementById('CompCounter').innerHTML = textInComp;
}*/
