$(document).ready(function() {
		
	$(".thumb").hover(function() { $(this).fadeTo('1000', 0.5); }, function() { $(this).fadeTo('3000', 1); } );
	
	$("#email").each(function(){
         var email = $(this).html();
         email = email.replace("_at_","@");
         email = email.replace("_dot_",".");
         $(this).html("<a href=\"mailto:"+email+"\">"+email+"</a>");
    });

	
	$("#email").hover(function() { $(this).fadeTo('1000', 0.5); }, function() { $(this).fadeTo('3000', 1); } );
	
	function redirectPage() {
    window.location = linkLocation;
    }
	
	$("#menu-info").click(function() { 
		if($("#project").is(":visible")) {
			event.preventDefault();
            linkLocation = this.href;
			$("#project").slideUp("slow", function() { redirectPage(); } );
		    $(".thumb").each(function() { if($(this).is(":hidden")) { $(this).fadeIn(); } });
		    $("#thumbs").css("margin","0px");
		    }
		else { event.preventDefault(); linkLocation = this.href; redirectPage(); }
		return false;
		});
	
	$(".thumb").click(function() { 
		$(".thumb").each(function() { if($(this).is(":hidden")) { $(this).fadeIn(); } }); // si un projet est déjà ouvert, on ré-affiche sa vignette
		$(this).fadeOut();
		var lien = $(this).attr("href");
		$("#loading").fadeIn();
		$("#project").load(lien +' #content-project', 
		                function() { $("#project").slideDown("slow", function() { $("#thumbs").css("margin-top","20px").css("margin-bottom","20px"); });
		                             $("#loading").fadeOut();
		                             $("#slideshow").cycle({timeout: 4000, speed: 500, next: ".next", prev: ".prev"});
		                             $("body, html").animate({scrollTop:$("body").offset().top}, 500);
		                             $(".close").click(function() { $("#project").slideUp("slow", function() { 
		                             	  $("#project").empty(); }); 
		                             	  $("#thumbs").css("margin","0px");
		                             	  $(".thumb").each(function() { if($(this).is(":hidden")) { $(this).fadeIn(); }
		                             	  });
		                             	  return false; });
		                             $(".index").click(function() { $("body, html").animate({scrollTop:$("#thumbs").offset().top}, 500);
		                             	  return false; });
		              
		              
		              });
		                
		                return false; 
     } );
    
});
