
// set the starting image. iBtn
var iBtn = 0;			

// The array of div names which will hold the images.
var image_slideBtn = new Array();

// The number of images in the array.
var NumOfImagesBtn = 0;
	
// The time to waitBtn before moving to the next image. Set to 4 seconds by default.
//var waitBtn = 12000;
var waitBtn = 5000;

var botonPlayBtn = null;
var botonPauseBtn = null;
var divContadorBtn = null;
var idLinkBtn = "";
var contenedorLinkBtn = "";
var cssActivoBtn = "";
var cssInactivoBtn = "";

//var estiloActivo = "";//////////agregado
//var estiloInactivo = "";

// The Fade Function SwapImageBtn
function SwapImageBtn(x,y) {
	//alert('uno');
	//alert(x+'____'+y);
	//alert(iBtn);	
	if($(image_slideBtn[x])){		
		$(image_slideBtn[x]).appear({ duration: 0.8 });
	}
	if($(image_slideBtn[y])){		
		$(image_slideBtn[y]).fade({duration: 0.6});
	}	
	//cambiarEstilosBtn($(idLinkBtn+x));
	//ocultarbotones($(idLinkBtn+x));/////agregado	
}

// the onload event handler that starts the fading.
function StartSlideShowBtn(listaDivsBtn,idLinksBtn,idPlayBtn,idPauseBtn,divContBtn,idContenedorBtn,classActivoBtn,classInactivoBtn) {
//	alert(listaDivsBtn+'____'+idLinksBtn+'____'+idPlayBtn+'____'+idPauseBtn+'____'+divContBtn+'____'+idContenedorBtn+'____'+classActivoBtn+'____'+classInactivoBtn);
//alert('dos');	
	image_slideBtn = listaDivsBtn.split(';');
	//alert(iBtn);	
	//alert(image_slideBtn);
	NumOfImagesBtn = image_slideBtn.length;	
	//alert(NumOfImagesBtn);
	botonPlayBtn 	= $(idPlayBtn);	
	//alert(botonPlayBtn);
	botonPauseBtn 	= $(idPauseBtn);	
	//alert(botonPauseBtn);
	divContadorBtn = $(divContBtn);	
	//alert(divContadorBtn);
	idLinkBtn 		= idLinksBtn;	
	//alert(idLinkBtn);
	contenedorLinkBtn = idContenedorBtn;	
	//alert(contenedorLinkBtn);
	cssActivoBtn 	= classActivoBtn;	
	//alert(cssActivoBtn);
	cssInactivoBtn = classInactivoBtn;	
	//alert(cssInactivoBtn);	
	//estiloActivo   = "inline";//////////agregado
    //estiloInactivo = "none";
	PlayBtn = setInterval('PlayBtnx()',waitBtn);	
	botonPlayBtn.hide();
	
	botonPauseBtn.appear({ duration: 0});	
	//alert('hola');	
	updatecounterBtn();	
	//alert(iBtn);	
}

function Goto(){
	//alert('tres');
		var imageShowBtn, imageHideBtn;
		imageHideBtn = iBtn;
		SwapImageBtn(0,imageHideBtn);
}

function PlayBtnx() { 
   // alert('cuatro');	
   
	var imageShowBtn, imageHideBtn;
	imageShowBtn = iBtn+1;	
	imageHideBtn = iBtn;	
	//alert(imageShowBtn);
	
	//alert(imageHideBtn);
	if (imageShowBtn == NumOfImagesBtn) {
		 //alert('uno');		
		SwapImageBtn(0,imageHideBtn);	
		iBtn = 0;			
	} else {
		//alert('dos');		
		SwapImageBtn(imageShowBtn,imageHideBtn);		
		iBtn++;			
	}
	
	var textIn = iBtn+1 + ' of ' + NumOfImagesBtn;		
	updatecounterBtn();	
}

function StopBtn () {
	//alert('cinco');
	clearInterval(PlayBtn);				
	botonPlayBtn.appear({ duration: 0});
	botonPauseBtn.hide();
}

function GoNextBtn() {
	//alert('seis');
	clearInterval(PlayBtn);
	botonPlayBtn.appear({ duration: 0});
	botonPauseBtn.hide();
	
	var imageShowBtn, imageHideBtn;

	imageShowBtn = iBtn+1;
	imageHideBtn = iBtn;
	
	
	
	if (imageShowBtn == NumOfImagesBtn) {
		SwapImageBtn(0,imageHideBtn);	
		iBtn = 0;					
	} else {
		SwapImageBtn(imageShowBtn,imageHideBtn);			
		iBtn++;
	}

	updatecounterBtn();
}

function GoPreviousBtn() {
	//alert('siete');
	clearInterval(PlayBtn);
	botonPlayBtn.appear({ duration: 0});
	botonPauseBtn.hide();

	var imageShowBtn, imageHideBtn;
				
	imageShowBtn = iBtn-1;
	imageHideBtn = iBtn;
	
	if (iBtn == 0) {
		SwapImageBtn(NumOfImagesBtn-1,imageHideBtn);	
		iBtn = NumOfImagesBtn-1;		
		
		//alert(NumOfImagesBtn-1 + ' and ' + imageHideBtn + ' iBtn=' + iBtn)
					
	} else {
		SwapImageBtn(imageShowBtn,imageHideBtn);			
		iBtn--;
		
		//alert(imageShowBtn + ' and ' + imageHideBtn)
	}
	
	updatecounterBtn();
}

function updatecounterBtn() {	
	/*for(ind=0; ind<5; ind++){
		$('contFotos3['+ind+']').style.border='';
	}//end for	
	$('contFotos3['+iBtn+']').style.border='3px solid #CC0000';*/
	var textIn = iBtn+1 + ' of ' + NumOfImagesBtn;
	//alert(iBtn);
	divContadorBtn.innerHTML = textIn;	
	
	//alert(divContadorBtn.innerHTML);
	//document.getElementById('contFotos3').border = '3';
    //alert(iBtn);
	//var borde_v = $('contFotos3'+iBtn).border;
	
	//document.borde_v.border = 3;
	//$('contFotos3['+iBtn+']').border =3;
	//alert($('contFotos3'+iBtn).value +'____'+$('contFotos3'+iBtn).border);
	//alert(document.contFotos3.border );
	//cont
}

function cambiarEstilosBtn(vinc){//Cambia el estilo de lsos lnks
 // alert('nueve');
	$$('#'+contenedorLinkBtn+' a').each(function(check) { 
			//alert(check);
			check.className = cssInactivoBtn;
		});
	vinc.className = cssActivoBtn;
	//alert(vinc.className);
}
/*function ocultarbotones(vinc){				

	$$('#'+contenedorLinkBtn+' a').each(function(check) { 
			//alert(check);
			check.className = estiloInactivo;
		});
	vinc.className = estiloActivo; 

}*/

function GoPageBtn(num_pagBtn, detenerBtn) {	
	//alert('diez');
	clearInterval(PlayBtn);
	//alert(NumOfImagesBtn);
	if(num_pagBtn>=NumOfImagesBtn || num_pagBtn<0){
			return;
	}//end if

	botonPlayBtn.appear({ duration: 0});
	botonPauseBtn.hide();	
	
	var imageShowBtn, imageHideBtn;

	imageShowBtn = num_pagBtn;
	imageHideBtn = iBtn;
	
	if (num_pagBtn != iBtn){
		SwapImageBtn(num_pagBtn,imageHideBtn);	
		iBtn = num_pagBtn;
	}
	updatecounterBtn();
	
}
