var imagenActual = 0;
var totalImagenes;
var intervaloImagenes;
var tiempoEspera= 5;  // Tiempo de espera entre casos expresado en SEGUNDOS
var tiempoFundido = 600; // Tiempo de fundido de los casos expresado en MILISEGUNDOS

jQuery(document).ready(function (){
			
			// CARRUSEL TRABAJOS
			totalImagenes = jQuery("#picMask img").length;
			jQuery("#picMask").removeClass("oculto");
			jQuery("#picMask img").hide();
			jQuery("#picMask img:first").show();
			clearInterval(intervaloImagenes);
			intervaloImagenes = setInterval(carruselImagenes, tiempoEspera*1000);
			    		
			// BOTONES NÚMERO DE IMAGEN CARRUSEL TRABAJOS
			jQuery("#picNum span a").stop().click(controlCarrusel);
			// DECORA
			jQuery("#picNum span a:first").addClass("actual").css("cursor", "text");
})




// FUNCIONES BOTONES CARRUSEL TRABAJOS

function controlCarrusel(){
	imagenActual =  jQuery("#picNum span a").index(jQuery(this));
		// DECORA
		jQuery(this).addClass("actual").css("cursor", "text");
	carruselImagenes();
	return false;
}



// FUNCIONES CARRUSEL AUTOMÁTICO TRABAJOS

function carruselImagenes(){
	clearInterval(intervaloImagenes);
	jQuery("#picMask img:eq("+imagenActual+")").fadeOut(tiempoFundido, muestraNuevaFoto)
	if (imagenActual<totalImagenes-1){
		imagenActual++;
	}else{
		imagenActual=0;
	}
	return false;
}

function muestraNuevaFoto(){
	jQuery("#picMask img").hide();
	jQuery("#picMask img:eq("+imagenActual+")").fadeIn(tiempoFundido, function (){intervaloImagenes = setInterval(carruselImagenes, tiempoEspera*1000); });
	// DECORA
	jQuery("#picNum span a").removeClass("actual").css("cursor", "pointer");
	jQuery("#picNum span a:eq("+imagenActual+")").addClass("actual").css("cursor", "text");	
}


