//MINIATURA
this.screenshotPreview = function(){	
	/* CONFIG */
		xOffset = 15;
		yOffset = 20;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		//this.title = "";	//OCULTO TITLE EN NAVEGADOR
		var c = (this.t != "") ? "" + this.t : "";
		$("body").append("<div id='screenshot'><img src='"+ this.rel +"' alt='Cargando imagen...' /><span>"+ c +"</span></div>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		//this.title = this.t;		//RETORNO TITLE GUARDADO
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();

	$(".galeria .fotos img:gt(0)").hide(); //ocultamos todas las fotos
	$(".galeria .boton_izq a").hide(); //ocultamos al nav izquierdo al ser la 1º foto
	ultimovalor = $(".galeria .fotos img:last-child").attr("data-num"); //obtenemos el total de fotos rel="VALOR"
	if (ultimovalor == "1") {
		$(".galeria .boton_der a, .nav").hide();
	}
	$(".galeria .nav").html("1 / "+ultimovalor); //texto información (fotoactual / totalfotos)
	$('.galeria .fotos img:first-child').fadeIn(1000); //mostramos la primera foto con un bonito efecto
	
	$('.galeria .botones a').click(function(evento) {
		evento.preventDefault();
		nav = $(this).attr('id');
		if(nav=="nav_izq") { //si pulsamos el boton izquierdo
			$('.galeria .fotos :first-child').fadeOut();
			$('.galeria .fotos :last-child').prependTo('.galeria .fotos').end().fadeIn(1000); //mandamos ultimo IMG al principio
		}
		if(nav=="nav_der") { //si pulsamos el boton derecho
			$('.galeria .fotos :first-child').fadeOut().next('img').fadeIn(1000).end().appendTo('.galeria .fotos'); //mandamos primer IMG al final
		}
		actualvalor = $(".galeria .fotos img").attr("data-num"); //foto actual
		$(".galeria .nav").html(actualvalor+" / "+ultimovalor); //mostramos el texto
		//ocultamos o mostramos el nav dependiendo del valor actual
		if(actualvalor==ultimovalor){ //si actual es igual a totalfotos, ocultamos derecha
			$(".galeria .boton_der a").fadeOut(200);
		} else {
			$(".galeria .boton_der a").fadeIn(200);
		}
		if(actualvalor=="1"){ //si actual es igual a 1, indicamos que es la primera, ocultamos izquierda
			$(".galeria .boton_izq a").fadeOut(200);
		} else {
			$(".galeria .boton_izq a").fadeIn(200);
		}
	});
	
	
	$(function(){
		$('.galeriauto .fotos img:gt(0)').hide();
		setInterval(function(){$('.galeriauto .fotos :first-child').fadeOut().next('img').fadeIn(1000).end().appendTo('.galeriauto .fotos');}, 3000);
	});
		
});
