$(document).ready(   
    function(){
 
        $("#galNav a").click(function () {
				$("#galNav a").removeClass("active");
				$(this).addClass("active");
				return false;
			}).filter(":first").click();
       
        // On click events

        $(".section a").click (
			
            function() {   
				
				//Thumbnails effect
				$(".section a").removeClass('active');
				$(".section a").fadeTo("fast", 1);
				$(this).addClass('active');
				$(this).fadeTo("fast", 0.45);

				
               	//Set current image
				var currentImg = $("#photo2 img");
               
                //New image attributes
                var newImg = $(this).attr("href");
                var newAlt = $(this).attr("title");
               
                //Create new image
                var newPic = new Image();
                $(newPic).attr({ src: newImg, alt: newAlt });
               
                $("#photo1 img").remove();
                $("#photo2").hide('fast',loadContent);
                $("#photo1").append(currentImg);
				
				//Display Loader
				$('#loader').remove();
				$('#mainPhoto').append('<div id="loader">Chargement...</div>');
				$('#loader').fadeIn('normal');
               
                
				function loadContent() {
					$('#photo2').load(newPic,'',hideLoader());
				}
				function hideLoader() {
					$('#loader').fadeOut('normal',showNewContent());
				}
				function showNewContent() {
					$("#photo2 img").remove();
					$("#photo2").append(newPic);
					$("#photo2").fadeIn("slow");
				}
                return false;
            }
               
        ).filter(":first").click();

    }
);
