/* -------------------------------------------------------------- 
  
   style.js
   * Javascript for http://vincent.turnthelighton.fr/
   * Author : Denis Fongue
   
-------------------------------------------------------------- */	

	
	 $(document).ready(function(){
	 	
	 	//
	 	
	 	if ($("body").hasClass("single-projects")) {
	 		var project = $("div#project div p img");
		    $("div#content").width(404*(project.size()+1)+$("div#left_menu").width()+70);  
		     
		$("body").css('width','auto'); 
	 	};
		
	 	// On calcule la largeur de div#content pour activer le scroll horizontal
	 	
	 	
	 	if ($("body").hasClass("home")) {
	 		var projects = $("div#projects").children();
		    $("div#content").width(204*projects.size()+$("div#left_menu").width()+60);
		    
		// On décale proportionnellement chaque vignette    
		    for (var i=1; i<=projects.size(); i++){
		    
		    	var my_project = $("div#projects div:nth-child("+i+")");
		    	my_project.css("z-index",90-i);
		    	
		    	var img_url_previous = $("div#projects div:nth-child("+(i-1)+") a").attr("href");
		    	var img_url_current = $("div#projects div:nth-child("+i+") a").attr("href");
		    	var img_url_next = $("div#projects div:nth-child("+(i+1)+") a").attr("href");
		    	
		    	$("div#projects div:nth-child("+i+") img").attr("usemap","#ma_map"+i+"");
		    	
		    	if(i == 1){
		    	my_project.children("map").append("<area shape='poly' coords='137,0,340,0,203,518,0,518' href="+img_url_current+" alt=''/><area shape='poly' coords='340,0,340,518,203,518' href="+img_url_next+" alt=''/>");
		    	
		    	} else if (i == projects.size()) {
		    	my_project.children("map").append("<area shape='poly' coords='0,0,137,0,0,518' href="+img_url_previous+" alt=''/><area shape='poly' coords='137,0,340,0,203,518,0,518' href="+img_url_current+" alt=''/>");
		    	
		    	} else {
		    	my_project.children("map").append("<area shape='poly' coords='0,0,137,0,0,518' href="+img_url_previous+" alt=''/><area shape='poly' coords='137,0,340,0,203,518,0,518' href="+img_url_current+" alt=''/><area shape='poly' coords='340,0,340,518,203,518' href="+img_url_next+" alt=''/>");
		    	
		    	};
		    	
		    			    	
		    	$("div#projects div:nth-child("+i+")").append($("div#projects div:nth-child("+i+") img"));
		    	
		    };
		    
		   $("div#projects a").remove();
		   
		$("body").css('width','auto'); 
		   
		   };
		   
	});
