(function($) {
  //
  // plugin
  //
  $.fn.galimg = function() {
	// trabaja con cada elemento
	return this.each(function() {
	  var idCapaGaleria = $(this).attr("id");
	
	  $("a", this).click(function() {
		// otra posibilidad para mostrar el aviso de cargando.
		//$("#" + idCapaGaleria + " .imgprin").append("<div class='jsgalpre'>Cargando...</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).fadeIn("slow");              
        });
		
		$(objImagen).attr("src", rutaImagen);
		
		//$("#" + idCapaGaleria + " .imgprin .jsgalpre").remove();
		
        return false;
      });
	});
  };
  //
  // fin del plugin
  //
})(jQuery);
