paginacionCallbacks.registrar(fotogaleria_rules);

function iniciarTimers (){
	numFotogalerias = $("div.fgl1").length;
    timers = new Array();
    for (x = 0; x < numFotogalerias; x++){
        xref = $("div.fgl1[id$='Zes']");
        timers[xref[x]["id"]] = setInterval("pasarSiguiente(\""+xref[x]["id"]+"\")", 8000);
    }
};

$(document).ready(
	function (){
		fotogaleria_rules();
		iniciarTimers();
		stop = false;
	}
);

function fotogaleria_rules()
{

	$("div.fgl1 #f_ant").click(function(){
		stop = false;
	});
		
	$("div.fgl1 #f_sig").click(function(){
		stop = false;
	});

   	$("div.fgl1 #f_stop").click(
		function(){
			// Obtener id de la capa de paginacion
			id = $(this).parent().parent().parent().attr("id");
			switch (this.title){
				case 'detener pase de imágenes':
					//Detengo el timer
					clearInterval(timers[id]);
					this.title="activar pase de imágenes";
					$(this).text("continuar");
					stop = true;
					break;
				case 'activar pase de imágenes':
				    //Activo el timer
					this.title="detener pase de imágenes";
			 		timers[id] = setInterval("pasarSiguiente(\""+id+"\")", 8000);
			 		$(this).text("parar diapositivas");
					stop = false;
			 		break;
			}//switch
		}
	);
}


function pasarSiguiente (idFotogaleria)
{
	if(!stop)
	{
		sig = $("#"+ idFotogaleria +" #f_sig");	
		// Provocar el click sobre el botón siguiente de la fotogaleria actual
		sig.click();
	}
}

