$(document).ready(function() {
						   
	 // MENU						   
	$("ul#nav li a").addClass("js");
	$("ul#nav li a").hover(
      function () {
        $(this).stop(true,true).animate({backgroundPosition:"(0 0)"}, 200);
      },
      function () {
        $(this).animate({backgroundPosition:"(0 150px)"}, 70);

      }
    );
	
	
	// ÉQUIPE
	$("ul.equipeliste li").hover(function() {
	
	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			width: '140px', /* Set new width */
			height: '140px', /* Set new height */
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
	$(this).find('div').css({'z-index' : '10'}).addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			top: '-20px',
			left: '-20px',
			marginTop: '0', /* The next 4 lines will vertically align this image */ 
			marginLeft: '0',
			height: '140px',
			width: '140px', /* Set new width */
		}, 200,
		function(){
		$(this) /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			height: '170px',
		}, 200)}
		
		); /* this value of "200" is the speed of how fast/slow this hover animates */
		
	} ,function() {
	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
			marginTop: '0', /* Set alignment back to default */
			marginLeft: '0',
			top: '0',
			left: '0',
			width: '100px', /* Set width back to default */
			height: '100px', /* Set height back to default */
		}, 100);
	$(this).find('div').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			marginTop: '0', /* The next 4 lines will vertically align this image */ 
			marginLeft: '0',
			top: '0',
			left: '0',
			height: '100px',
			width: '100px', /* Set new width */
		}, 100, function(){$(this).css({'z-index' : '0'})}); /* this value of "200" is the speed of how fast/slow this hover animates */

});
	
	
	
	
	// MAP
    $("#maplocationin").stop(true,true).animate({backgroundPosition:"(5px 126px)"}, 0);
	$("#maplocationin a").hover(
      function () {
        $("#maplocationin").stop(true,true).animate({backgroundPosition:"(5px 15px)"}, 300);
		$("#maplocationin").animate({backgroundPosition:"(5px 20px)"}, 150);
      },
      function () {
        $("#maplocationin").animate({backgroundPosition:"(5px 126px)"}, 100);

      }
    );
	
	 // SOUMISSION
	 
  $('#sform').hide();
  $('#soumission').click(function() {				  
    $('#sform').slideToggle(300);
    return false;
  });


    // SOUMISSION FORMULAIRE
	//if submit button is clicked
	$('#submit').click(function () {		
		
		//Get the data from all the fields
		var name = $('input[name=name]');
		var email = $('input[name=email]');
		var phone = $('input[name=phone]');
		var besoins = $('textarea[name=besoins]');

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='') {
			name.addClass('hightlight');
			return false;
		} else name.removeClass('hightlight');
		
		if (email.val()=='') {
			email.addClass('hightlight');
			return false;
		} else email.removeClass('hightlight');
		
		if (besoins.val()=='') {
			besoins.addClass('hightlight');
			return false;
		} else besoins.removeClass('hightlight');
		
		//organize the data properly
		var data = 'name=' + name.val() + '&email=' + email.val() + '&phone=' + 
		phone.val() + '&besoins='  + encodeURIComponent(besoins.val());
		
		//disabled all the text fields
		$('.text').attr('disabled','true');
		
		//show the loading sign
		$('.loading').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "http://www.avcollins.com/wp-content/themes/collins/process.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					$('.form').fadeOut('200');					
					
					//show the success message
					$('.done').fadeIn('slow');
						  
    				$('#sform').delay(2000).slideToggle(300);
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Désolé, nous avons rencontré une erreur, réessayez plus tard.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	
	
	
	
	// SLIDER
   $('#s3slider').s3Slider({ 
      timeOut: 4000 
   });
	
});

