
// set the starting image.
var iPr = 0;			

// The array of div names which will hold the images.
var image_slidePr = new Array();

// The number of images in the array.
var NumOfImagesPr = 0;
	
// The time to waitPr before moving to the next image. Set to 4 seconds by default.
var waitPr = 4000;

var botonPlayPr = null;
var botonPausePr = null;
var divContadorPr = null;
var idLinkPr = "";
var contenedorLinkPr = "";
var cssActivoPr = "";
var cssInactivoPr = "";

// The Fade Function
function SwapImagePr(x,y) {		
	$(image_slidePr[x]).appear({ duration: 0.8 });
	$(image_slidePr[y]).fade({duration: 0.6});
	
	cambiarEstilosPr($(idLinkPr+x));
	
}

// the onload event handler that starts the fading.
function StartSlideShowPr(listaDivsPr,idLinksPr,idPlayPr,idPausePr,divContPr,idContenedorPr,classActivoPr,classInactivoPr) {
	
	image_slidePr = listaDivsPr.split(';');
	NumOfImagesPr = image_slidePr.length;
	botonPlayPr 	= $(idPlayPr);
	botonPausePr 	= $(idPausePr);
	divContadorPr = $(divContPr);
	idLinkPr 		= idLinksPr;
	contenedorLinkPr = idContenedorPr;
	cssActivoPr 	= classActivoPr;
	cssInactivoPr = classInactivoPr;

	PlayPr = setInterval('PlayPrx()',waitPr);
	
	botonPlayPr.hide();
	botonPausePr.appear({ duration: 0});
	
	updatecounterPr();
								
}

function PlayPrx() { 
	var imageShowPr, imageHidePr;

	imageShowPr = iPr+1;
	imageHidePr = iPr;
	
	if (imageShowPr == NumOfImagesPr) {
		SwapImagePr(0,imageHidePr);	
		iPr = 0;					
	} else {
		SwapImagePr(imageShowPr,imageHidePr);			
		iPr++;
	}
	
	var textIn = iPr+1 + ' of ' + NumOfImagesPr;
	updatecounterPr();
}

function StopPr () {
	clearInterval(PlayPr);				
	botonPlayPr.appear({ duration: 0});
	botonPausePr.hide();
}

function GoNextPr() {
	clearInterval(PlayPr);
	botonPlayPr.appear({ duration: 0});
	botonPausePr.hide();
	
	var imageShowPr, imageHidePr;

	imageShowPr = iPr+1;
	imageHidePr = iPr;
	
	if (imageShowPr == NumOfImagesPr) {
		SwapImagePr(0,imageHidePr);	
		iPr = 0;					
	} else {
		SwapImagePr(imageShowPr,imageHidePr);			
		iPr++;
	}

	updatecounterPr();
}

function GoPreviousPr() {
	clearInterval(PlayPr);
	botonPlayPr.appear({ duration: 0});
	botonPausePr.hide();

	var imageShowPr, imageHidePr;
				
	imageShowPr = iPr-1;
	imageHidePr = iPr;
	
	if (iPr == 0) {
		SwapImagePr(NumOfImagesPr-1,imageHidePr);	
		iPr = NumOfImagesPr-1;		
		
		//alert(NumOfImagesPr-1 + ' and ' + imageHidePr + ' iPr=' + iPr)
					
	} else {
		SwapImagePr(imageShowPr,imageHidePr);			
		iPr--;
		
		//alert(imageShowPr + ' and ' + imageHidePr)
	}
	
	updatecounterPr();
}

function updatecounterPr() {
	var textIn = iPr+1 + ' of ' + NumOfImagesPr;
	divContadorPr.innerHTML = textIn;
}

function cambiarEstilosPr(vinc){				//Cambia el estilo de los lnks

	$$('#'+contenedorLinkPr+' a').each(function(check) { 
			//alert(check);
			check.className = cssInactivoPr;
		});
	vinc.className = cssActivoPr;

}

function GoPagePr(num_pagPr, detenerPr) {
	
	clearInterval(PlayPr);
	botonPlayPr.appear({ duration: 0});
	botonPausePr.hide();	
	
	var imageShowPr, imageHidePr;

	imageShowPr = num_pagPr;
	imageHidePr = iPr;
	
	if (num_pagPr != iPr){
		SwapImagePr(num_pagPr,imageHidePr);	
		iPr = num_pagPr;
	}
	updatecounterPr();
	
}
