function createGallery(){
  var settings = { 
    thumbListId: "thumbs", 
    imgViewerId: "viewer", 
    activeClass: "active", 
    activeTitle: "Photo en cours de visualisation", 
    loaderTitle: "Chargement en cours", 
    loaderImage: "../_medias/elements/Loader.gif" 
  }; 
  if($('#'+settings.thumbListId+' li').length > 0)
  {
	  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("p")) 
	      .attr("id",settings.imgViewerId) 
	      .append( 
	        $(document.createElement("img")).attr({ 
	          alt: "", 
	          /* src: firstThumbLink.attr("href") */
	          src:firstThumbLink.children('img').attr('src').replace('width=120&height=', 'width=580&height=465')
	        }) 
	      ) 
	  ); 
	 
	  var imgViewer = $("#"+settings.imgViewerId), 
	    bigPic = imgViewer.children("img"); 
	 
	  thumbLinks 
	    .click(function(e){ 
	      e.preventDefault(); 
	      
	      var $this = $(this), 
	        target = $this.attr("href");
	        target = $(this).children('img').attr('src').replace('width=120&height=', 'width=580&height=465');
	      if (bigPic.attr("src") == target) return; 
	      highlight($this); 
	      imgViewer.html(loader); 
	      bigPic 
	        .load(function(){ 
	          imgViewer.html($(this).fadeIn(250)); 
	        }) 
	        .attr("src",target); 
	    }); 
	
	    $('#'+settings.thumbListId+',#'+settings.imgViewerId+',#sidebar #infos_projet,#side_info_projects').hide().fadeIn('slow');
 }
}

jQuery(function($){ 
	createGallery();
});
