jQuery(function($){ 
 
  var settings = { 
    thumbListId: "thumbs", 
    imgViewerId: "viewer", 
    activeClass: "active", 
    activeTitle: "Photo en cours de visualisation", 
    loaderTitle: "Chargement en cours", 
    loaderImage: "wp-content/themes/JS_BernardVie/images/loader.gif" 
  }; 
 
  var thumbLinks = $("#"+settings.thumbListId).find("a"), 
    firstThumbLink = thumbLinks.eq(0), 
    highlight = function(elt){ 
      thumbLinks.removeClass(settings.activeClass).removeAttr("title"); 
      elt.addClass(settings.activeClass).attr("title",settings.activeTitle); 
    }, 
    loader = $(document.createElement("img")).attr({ 
      alt: settings.loaderTitle, 
      title: settings.loaderTitle, 
      src: settings.loaderImage 
    }); 
 
  highlight(firstThumbLink); 
 
 $("#"+settings.thumbListId).before(
 	$(document.createElement("div")).attr("id", settings.imgViewerId).append(
 		$(document.createElement("a")).attr({
 			href: firstThumbLink.attr("href").slice(0, -4)+"_hd.jpg",
 		}).append(
 			$(document.createElement("img")).attr({
 				alt: "",
 				src: firstThumbLink.attr("href")
 			})
 		)
 	)
 );
 
 	var imgViewer = $("#"+settings.imgViewerId), bigPicLink = imgViewer.children("a"), bigPic = bigPicLink.children("img");
 	thumbLinks.click(function(e) {
 		e.preventDefault();
 		
 		var $this = $(this), target = $this.attr("href");
 		
 		if (bigPic.attr("src") == target) return;
 		highlight($this);
 		imgViewer.html(loader);
 		bigPic.load(function() {
 			imgViewer.html(bigPicLink.attr("href", target.slice(0, -4)+"_hd.jpg").html($(this).fadeIn(250)));
 		}).attr("src", target);
 	});
});



 
