//
// Galeria v1.3
// Autor: Oscar Linares
// http://www.innovacionweb.com/galeria-accesible-jquery.php
// http://code.google.com/p/galeria-jquery-jsgal/
//
// Gracias a:
// Ariel Flesler por su plugin jQuery.Preload, aunque al final no lo uso (muy potente, demasiado
// para lo que necesito aquí).
// Para la precarga me inspire en (muchas gracias)
// http://www.noth.es/2007/11/25/actualizacion-del-jquery-gallery-v-0-2/
(function($) {
  //
  // plugin
  //
  $.fn.galimg = function() {
	// trabaja con cada elemento
	return this.each(function() {
//console.log(this);
	  var idCapaGaleria = $(this).attr("id");
	
	  $("#thumbs li a").click(function() {
//alert("oioi");
		// otra posibilidad para mostrar el aviso de cargando.
		//$("#" + idCapaGaleria + " .imgprin").append("<div class='jsgalpre'>Caricando...</div>");
		var rutaImagen = $(this).attr("href");
		var altImagen = $(this).children("img").attr("alt");
		
		$("#" + idCapaGaleria + " .imgprin img").fadeOut("normal").remove();
		
		var objImagen = new Image(); 
		
		$(objImagen).load(function() {
			$(this).hide();
			
            $("#" + idCapaGaleria + " .imgprin").append(this);
//		$(this).insertAfter("#" + idCapaGaleria + " .imgprin .va");
//console.log(this); 
                                             
            $(this).fadeIn("show");              
        });
		
		$(objImagen).attr("src", rutaImagen);
		
		//$("#" + idCapaGaleria + " .imgprin .jsgalpre").remove();
		
        return false;
      });
	});
  };
  //
  // fin del plugin
  //
})(jQuery);





