// JavaScript Document
$(document).ready(function(){
	$buildingup = false;

	//Blurs all links when clicked
	$("a").click(function(){
		$(this).blur();
	});
	
	$(this).delay(2000,function(){
		$("#titlebar").fadeOut(1000);
	});
		
	
	$(this).delay(3500,function(){
		
		//Show the elements	
		$(".village").stop().animate({top:'400px',left:'0px'}, {queue:false, duration:2000, easing: 'easeOutBack'});
		$(".cloudbar").stop().animate({top:'350px',left:'668px'}, {queue:false, duration:2000, easing: 'easeOutBack'});
		
		$buildingup = true;	

	$(this).delay(2000,function(){
		$("#header_content").fadeIn(5000);
		$("#body_content").fadeIn(5000);
		$("#footer_content").fadeIn(5000);
		$("#tabs").fadeIn(5000);
		$("#adresse").fadeIn(5000);
		$("#text_menu").fadeIn(5000);
		$("#titre_partenaire").fadeIn(5000);
		$("#partenaire").fadeIn(5000);
		$("#footer_infos").fadeIn(5000);
		
	});
	$(this).delay(2015,function(){
	document.getElementById("test").style.top = '128px';
	});

		
    });
	
	$("a.toggle").click(function(){
		
		if ($buildingup == false){
			
			$("#titlebar").fadeOut(1000);
			$(this).delay(1000,function(){
				$(".village").stop().animate({top:'30px'}, {queue:false, duration:2000, easing: 'easeInOutBack'});
				$(".cloudbar").stop().animate({top:'0px'}, {queue:false, duration:2000, easing: 'easeInOutBack'});
				$buildingup = true;
			});
		
		}else{
			
			$(".village").stop().animate({top:'366px'}, {queue:false, duration:2000, easing: 'easeInOutBack'});
			$(".cloudbar").stop().animate({top:'-465px'}, {queue:false, duration:2000, easing: 'easeInOutBack'});
			$buildingup = false;
			
			$(this).delay(2000,function(){
				$("#titlebar").fadeIn(1000);
			});
			
		}
		
	});
	
	//Change background color of body
	$("a.change").click(function(){
		$('body').css('background-color','#FFF');				 
	});
	 
});
