
// set the starting image.
var iBn = 0;			

// The array of div names which will hold the images.
var image_slideBn = new Array();

// The number of images in the array.
var NumOfImagesBn = 0;
	
// The time to waitBn before moving to the next image. Set to 4 seconds by default.
var waitBn = 12000;

var botonPlayBn = null;
var botonPauseBn = null;
var divContadorBn = null;
var idLinkBn = "";
var contenedorLinkBn = "";
var cssActivoBn = "";
var cssInactivoBn = "";

// The Fade Function
function SwapImageBn(x,y) {		
	$(image_slideBn[x]).appear({ duration: 0.8 });
	$(image_slideBn[y]).fade({duration: 0.6});
	
	cambiarEstilosBn($(idLinkBn+x));
	
}

// the onload event handler that starts the fading.
function StartSlideShowBn(listaDivsBn,idLinksBn,idPlayBn,idPauseBn,divContBn,idContenedorBn,classActivoBn,classInactivoBn) {
	
	image_slideBn = listaDivsBn.split(';');
	NumOfImagesBn = image_slideBn.length;
	botonPlayBn 	= $(idPlayBn);
	botonPauseBn 	= $(idPauseBn);
	divContadorBn = $(divContBn);
	idLinkBn 		= idLinksBn;
	contenedorLinkBn = idContenedorBn;
	cssActivoBn 	= classActivoBn;
	cssInactivoBn = classInactivoBn;

	PlayBn = setInterval('PlayBnx()',waitBn);
	
	botonPlayBn.hide();
	botonPauseBn.appear({ duration: 0});
	
	updatecounterBn();
								
}

function PlayBnx() { 
	var imageShowBn, imageHideBn;

	imageShowBn = iBn+1;
	imageHideBn = iBn;
	
	if (imageShowBn == NumOfImagesBn) {
		SwapImageBn(0,imageHideBn);	
		iBn = 0;					
	} else {
		SwapImageBn(imageShowBn,imageHideBn);			
		iBn++;
	}
	
	var textIn = iBn+1 + ' of ' + NumOfImagesBn;
	updatecounterBn();
}

function StopBn () {
	clearInterval(PlayBn);				
	botonPlayBn.appear({ duration: 0});
	botonPauseBn.hide();
}

function GoNextBn() {
	clearInterval(PlayBn);
	botonPlayBn.appear({ duration: 0});
	botonPauseBn.hide();
	
	var imageShowBn, imageHideBn;

	imageShowBn = iBn+1;
	imageHideBn = iBn;
	
	if (imageShowBn == NumOfImagesBn) {
		SwapImageBn(0,imageHideBn);	
		iBn = 0;					
	} else {
		SwapImageBn(imageShowBn,imageHideBn);			
		iBn++;
	}

	updatecounterBn();
}

function GoPreviousBn() {
	clearInterval(PlayBn);
	botonPlayBn.appear({ duration: 0});
	botonPauseBn.hide();

	var imageShowBn, imageHideBn;
				
	imageShowBn = iBn-1;
	imageHideBn = iBn;
	
	if (iBn == 0) {
		SwapImageBn(NumOfImagesBn-1,imageHideBn);	
		iBn = NumOfImagesBn-1;		
		
		//alert(NumOfImagesBn-1 + ' and ' + imageHideBn + ' iBn=' + iBn)
					
	} else {
		SwapImageBn(imageShowBn,imageHideBn);			
		iBn--;
		
		//alert(imageShowBn + ' and ' + imageHideBn)
	}
	
	updatecounterBn();
}

function updatecounterBn() {
	var textIn = iBn+1 + ' of ' + NumOfImagesBn;
	divContadorBn.innerHTML = textIn;
}

function cambiarEstilosBn(vinc){				//Cambia el estilo de los lnks

	$$('#'+contenedorLinkBn+' a').each(function(check) { 
			//alert(check);
			check.className = cssInactivoBn;
		});
	vinc.className = cssActivoBn;

}

function GoPageBn(num_pagBn, detenerBn) {
	
	clearInterval(PlayBn);
	botonPlayBn.appear({ duration: 0});
	botonPauseBn.hide();	
	
	var imageShowBn, imageHideBn;

	imageShowBn = num_pagBn;
	imageHideBn = iBn;
	
	if (num_pagBn != iBn){
		SwapImageBn(num_pagBn,imageHideBn);	
		iBn = num_pagBn;
	}
	updatecounterBn();
	
}
