$(document).ready(function() {
	



	// MENU



	

	$("#menu li a").hover(function(){

			$(this).stop().animate({paddingTop:"10px"});

	 },function(){

			$(this).stop().animate({paddingTop:"0px"});

	 });



	 

	 // LOGO

	 

	 

	 $("#logo").hover(function(){

			$(this).stop().animate({top:"-20px"},'normal','swing');

	 },function(){

			$(this).stop().animate({top:"-187px"},'slow','easeOutElastic');

	 });      

	 

	 

	 // BG

	 

	 

	var offset =  1;

	var offset3 =  1;

	var offset4 = 1;

	var offset5 =  1;

	var offset6 =  1;

 

	function scrollbackground() {



		offset = offset + 1;

		offset3 = offset3 - 1;

		offset4 = offset4 + 0.75;

		offset5 = offset5 - 2;

		offset6 = offset6 - 2.5;



		$('#bateau').css("background-position", offset + "px 0");

		$('#bg2').css("background-position", offset3 + "px bottom");

		$('#vague1').css("background-position", offset4 + "px bottom");

		$('#vague2').css("background-position", offset5 + "px bottom");

		$('#footer p').css("background-position", offset5 + "px 0");

		$('#oiseau').css("background-position", offset6 + "px 0");



		setTimeout(function() {

			scrollbackground();

			}, 25

		);

	}

 

	scrollbackground();

	

	// Fancybox

	

	$('.devis a').fancybox();

	$('.services h3 a').fancybox();

	$('.footer_services a').fancybox();
	
	$('.entry a img').parent().fancybox();
	
	

	
	//tooltip
	
	$("#groupe_insane a").tooltip({ 
			track:true, 
			delay:0, 
			showURL:false, 
			showBody:" - ", 
			fixPNG:false, 
			left:10,
			top:10 
	}); 
		
	$("#services_web_gauche li").tooltip({ 
		track:true, 
		delay:0, 
		showURL:false, 
		showBody:" - ", 
		fixPNG:false, 
		left:10,
		top:10 
	}); 
	

	

	// Portfolio
	
		$('#loading').hide();

		$(".main_image .desc").show(); //Show Banner

		$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity



		//Click and Hover events for thumbnail list

		$(".image_thumb ul li:first").addClass('active'); 

		$(".image_thumb ul li").click(function(){ 

			//Set Variables

			var imgAlt = $(this).find('img#picture').attr("alt"); //Get Alt Tag of Image

			var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL

			var imgDesc = $(this).find('.block').html(); 	//Get HTML of block

			var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	

			

			if ($(this).is(".active")) {  //If it's already active, then...

				return false; // Don't click through

			} else {

				//Animate the Teaser			

				$(".main_image .block").slideToggle( function() {

					$(".main_image .block").html(imgDesc).slideToggle();

					$(".main_image img#picture").fadeOut(function() { $(".main_image img#picture").attr({ src: imgTitle , alt: imgAlt}); } );					
					
					$('#loading').fadeIn();
					
					
					
					$(".main_image img#picture").load( function() { $('#loading').fadeOut(); $(".main_image img#picture").fadeIn(); });
	
					$('a#affiche').fancybox();

				});

			}

			

			$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists

			$(this).addClass('active');  //add class of 'active' on this list only

			return false;

			

		}) .hover(function(){

			$(this).addClass('hover');

			}, function() {

			$(this).removeClass('hover');

		});

				

		//Toggle Teaser

		$("a.collapse").click(function(){

			$(".main_image .block").slideToggle();

			$("a.collapse").toggleClass("show");

		});

		
             

             // LOGO

             

             

             $("div#logo a img").mouseover(function(){

                   $(this).animate({paddingTop:"20px"});

             });

             

             $("div#logo a img").mouseout(function(){

                   $(this).animate({paddingTop:"0px"});

             });

		
		
		
		
		
			// FORMULAIRE
			
			
			
			
			   
		   $('#formulaire input[type=submit]').fadeTo('slow',0.5).css('cursor','not-allowed').attr('disabled','disabled').val('formulaire incomplet');
			
			$('#formulaire input:not(#adresse):not(#societe), #formulaire textarea').each(function() {
									 
				$(this).keyup(checkSubmit);
				
			});
		
			$('#formulaire input:not(#adresse):not(#societe):not(#submit),textarea').keyup( checkSubmit );
			$('#formulaire input:not(#adresse):not(#societe):not(#submit),textarea').blur( checkSubmit );
			$('#formulaire input[type=submit]').click( checkSubmit );
			
			function checkSubmit() {
			
				if($(this).val() == '') {
				
					$(this).css('border-color','red');
				
				} else {
					
					$(this).css('border-color','green');
				
				}
					
				if($('#nom').val() != '' && $('#prenom').val() != '' && $('#objet').val() != '' && $('#mail').val() != '' && $('#message').val() != '') {
					
					$('#formulaire input[type=submit]').fadeTo('slow',1).css('cursor','pointer').removeAttr('disabled').val('envoyer votre demande');
					
				} else {
					
					$('#formulaire input[type=submit]').fadeTo('slow',0.5).css('cursor','not-allowed').attr('disabled','disabled').val('formulaire incomplet');
					
				}
			
			}
	
	 

});