/*
 * jquery-gallery 0.2 (25-11-2007)
 *
 * Copyright (c) 2007 Queli Coto (http://www.noth.es)
 * Lincencia bajo CC
 * Built upon jQuery 1.2 (http://jquery.com)
 */


$(document).ready(crearGaleria);

function crearGaleria ()
{
	//cargamos el title y la descripcion de la primera imagen
	var title = $(".slideShowGallery dt img").attr('title');
	//conseguimos el ancho y la altura de nuestra galerçia
	//var height = $(".slideShowGallery dt img").height();
	//var width = $(".slideShowGallery dt img").width();
	//$(".slideShowGallery dt").css({ width: width-10, height: height });
	var descripcion = $(".slideShowGallery dt img").attr('alt');
	
	//$(".slideShowGallery dt").append("<p id='infoinx'><strong>"+ title+"</strong> "+ descripcion +"</b>");
  	//$(".slideShowGallery dt p").hide();
  	//$(".slideShowGallery dt p").fadeIn('slow');
  	
	//inicializamos los click en las imagenes
	$(".slideShowGallery dd img").click( function() { 
		var urlImagen =$(this).parent().attr('href');
		var urlImagenBig =$(this).parent().attr('rev');
		var title = $(this).attr('title');
		var descripcion = $(this).attr('alt');
		ocultarFoto(urlImagen,urlImagenBig, title, descripcion);
		return false; //cancelamos el click en el a 
	} );
	
	//$('#aseg').unbind()
	//$('#aant').unbind()
}



function ocultarFoto(url,urlBig,title,descripcion)
{
	   $(".slideShowGallery dt p").fadeOut();
       $(".slideShowGallery dt img").animate({ 
		  left: 50, opacity: 'hide' 
		}, 1000, function() {
			var i = new Image();
	        i.src = url;
	       // i.onload=function(){ 	
		   		
			   $(".slideShowGallery dt img").attr('src',url);		   
			   
			   
			   
			   
			   $(".slideShowGallery dt img").animate({ 
				   left: 50, opacity: 'show'}, 1000,function() {
						  
						//$(".slideShowGallery dt a").attr('href',urlBig);
						//$(".slideShowGallery dt a").attr('title',title+" / "+ descripcion);
						//$('#infoimx').remove();
						//$(".slideShowGallery dt").append("<p id='infoimx'><strong>"+ title+"</strong> "+ descripcion +"</b>");
						//$(".slideShowGallery dt p").hide();
						//$(".slideShowGallery dt p").fadeIn('slow');
						//$(".slideShowGallery dt p").css('opacity',0.6);
				   } );
		  //};
		 
      });
}


function get_anteriores(ini,tamano){
	data = $.ajax({
		type:'POST',
		url: '/seccion_web/galeria/php/getImaxesAjax.php',
		dataType: 'json',
		data: "ini="+ini+"&t="+(tamano)+"&idg="+galeria,
		success: function(data){
			datos=eval(data);
			cargarSlide(ini,tamano,datos)
		}
	});
}

function get_seguintes(ini,tamano){
	
	data = $.ajax({
		type:'POST',
		url: '/seccion_web/galeria/php/getImaxesAjax.php',
		dataType: 'json',
		data: "ini="+ini+"&t="+(tamano)+"&idg="+galeria,
		success: function(data){
			
			datos=eval(data);
			
			cargarSlide(ini,tamano,datos)
			
		}
	});
}


