$(document).ready(function() {
	$("div.three").css({
		right:240,
		opacity:0
	});
	$("div.three").delay(500).animate({
		right:37,
		opacity:1
	},1000,'linear');
	
	$("img.logos").css({
		top:-100,
		opacity:0
	});
	$("img.logos").delay(20).animate({
		top:25,
		opacity:1
	},1500,'linear');
	
	$("div.hidden").hide();
	$("a.suite").bind("click", toggleMoreInfo);
	$("a.suite").parents('h1').toggleClass("dotted");
	
	$(".arrows a").bind("click", scrollTo);
	
	elements = $('div.overflow');
	elements.each(function() { 
		var sum=0;
		$(this).find("img").each( function(){ 
			sum += $(this).outerWidth(true); 
		console.log(sum);
		});
		$(this).width( sum );
    });
	setTimeout(function(){
		$("div.all").animate({ backgroundColor: "#5c5c59" }, "5000");
	}, 1000);
	
	setTimeout(function(){
		$("div.webdesign").animate({ backgroundColor: "#7d6183" }, "5000");
	}, 1000);
	
	setTimeout(function(){
		$("div.illustration").animate({ backgroundColor: "#96ac5a" }, "5000");
	}, 1000);
	
	setTimeout(function(){
		$("div.scenographie").animate({ backgroundColor: "#c39c4f" }, "5000");
	}, 1000);
	
	setTimeout(function(){
		$("div.graphisme").animate({ backgroundColor: "#559fb1" }, "5000");
	}, 1000);
	
//	setTimeout(function(){
//		$("img.default").attr("src","images/logo_default_on.jpg");
//	}, 2030);
	
});


	var toggleMoreInfo = function(e) {
		e.preventDefault();
		$(e.currentTarget).parent().next("div.hidden").slideDown("slow").siblings("div.hidden").slideUp();
		$(e.currentTarget).parent().siblings('h1:not(:first-child)').addClass("dotted");
		$(e.currentTarget).parent().toggleClass("dotted");
	}
	
	var scrollTo = function(e) {
		e.preventDefault();
		var move = "+=0";
		if($(this).hasClass('previous')){
			current = $(e.currentTarget).parent().next().find('img.current');
			if($(current).next("img").length > 0){
				current.removeClass("current");
				move = "-=" + current.outerWidth(true);
				current.next("img").addClass("current");		
			}
		}
		else{
			current = $(e.currentTarget).parent().next().find('img.current');
			if(current.prev("img").length > 0){
				current.removeClass("current");
				move = "+=" + current.prev("img").outerWidth(true);
				current.prev("img").addClass("current");		
			}
		}
		$(e.currentTarget).parent().next().find('div.overflow').animate({left: move});
	}
	

