$(document).ready(function() {
//effet fading body1
    $('.fadein').css({ visibility:'hidden'}); 
        var doFadeIn = function() { 
        $('.fadein').css({ opacity:0, visibility:'visible'}).fadeTo(1000,1); 
    }; 
    doFadeIn();
    
    //menu
    $('.closed').click(function(){
        $('#menu').slideUp('slow');
    });
                    
  //$('body').one('mousemove',doFadeIn); 

  //$('#s').one('blur',doFadeIn); 
//effet fading body2  
      /*$(function () {
        var pause_before_fading_starts = 750; //Amount of time in ms to wait before starting the first fade
        var h1_fade_in_duration = 750; //Amount of time in ms for the h1 to fade in
        var content_fade_in_duration = 750; //Amount of time in ms for the main content to fade in
        var header_faded_up = false;
        var content_faded_up = false;
        var images_loaded = false;
        function content_fadeIn() {
        $("body").fadeIn(content_fade_in_duration, function () {
        //fading complete
        content_faded_up = true;
        });
        }
        if ($("#content .quick-load").length == 0) {
        images_loaded = true;
        }
        $("#content .quick-load").load(function () {
        images_loaded = true;
        if (header_faded_up) {
        content_fadeIn();
        }
        });
        setTimeout(function () {
        $("h1").fadeIn(h1_fade_in_duration, function () {
        header_faded_up = true;
        if (images_loaded) {
        content_fadeIn();
        }
        });
        }, pause_before_fading_starts);
        setTimeout(function () {
        if (!content_faded_up) {
        content_fadeIn();
        }
        }, pause_before_fading_starts + 1000); 
        )};*/ 
    /*********script ombre menu******************************/
    $("#nav-shadow li").append('<img class="shadow" src="http://www.e-visibilite.com/images/ombre_menu.png" alt="" width="41" height="4" />');
    $("#nav-shadow li span").hide();
    $("#nav-shadow li").hover(function() {
    	var e = this;
        $(e).find("a").stop().animate({ marginTop: "-14px" }, 250, function() {
        	$(e).find("a").animate({ marginTop: "-10px" }, 250);
            $(e).find("span").fadeIn(400);
        });
        $(e).find("img.shadow").stop().animate({ width: "80%", height: "4px", marginLeft: "4px", opacity: 0.25 }, 250);
    },function(){
    	var e = this;
        $(e).find("a").stop().animate({ marginTop: "0px" }, 250, function() {
        	$(e).find("a").animate({ marginTop: "0px" }, 250);
            $(e).find("span").fadeOut(400);
        });
        $(e).find("img.shadow").stop().animate({ width: "100%", height: "4px", marginLeft: "0px", opacity: 1 }, 250);
    });
    /*********script hover réa******************************/
    if(!$.browser.msie) {
    var t = parseInt($('.cat_name').css('left')); 
    $(".site_min").hover(function(){
       $(this).find(".cadre_hover").stop().fadeTo(500,0.82);
       $(this).find(".cat_name").show().stop().css({
           opacity : 0
           //left : t 
       }).animate({
           opacity : 1
          // left : t + 125
       }).rotate({angle:0, 
          animateTo:360,
          duration:1000
          });
     },function(){
       $(this).find(".cadre_hover").stop().fadeOut();
           $(this).find(".cat_name").stop().animate({
               //left : t - 125,
               opacity : 0
       }).rotate({angle:0, 
          animateTo:-360,
          duration:1000
          });
    });
}
else{
    var t = parseInt($('.cat_name').css('left')); 
    $(".site_min").hover(function(){
       $(this).find(".cadre_hover").stop().fadeTo(500,0.82);
       $(this).find(".cat_name").show().stop().css({
           opacity : 0
           //left : t 
       }).animate({
           opacity : 1
          // left : t + 125
       });
     },function(){
       $(this).find(".cadre_hover").stop().fadeOut();
           $(this).find(".cat_name").stop().animate({
               //left : t - 125,
               opacity : 0
       });
    });
    
    
}

/*****************************script more et icône et icône réa**********************/
if($.browser.msie) {
    
}
else{
    $(".pole li a").hover(function(){
       $(this).find("span").stop().rotate({angle:0, 
            animateTo:360,
            duration:2000

          });
     },function(){
           $(this).find("span").stop().rotate({angle:0, 
          animateTo:-360,
          duration:2000
          });
    });

    $(".more a").hover(function(){
        $(this).stop().rotate({angle:0, 
            animateTo:360,
            duration:1000

          });
     },function(){
        $(this).stop().rotate({angle:0, 
          animateTo:-360,
          duration:1000
          });
    });  
}
/***************************script projet*******************************/
var t2 = parseInt($('.haut p').css('left'));
  $(".haut, .bas").hover(function(){
       $(this).find("p").stop().animate({
          left : t2 - 2
       }).find("span").show().stop().css({
           opacity : 0
       }).animate({
           opacity : 1
       });

     },function(){
          $(this).find("p").stop().animate({
          left : t2 + 2
       }).find("span").show().stop().css({
           opacity : 1
       }).animate({
           opacity : 0
       });
    });    
/*///////////////twitter et facebook anim**************************/  
if($.browser.msie) {
    
}
else{

    $(".img_move").hover(function(){
        $(this).stop().rotate({angle:0, 
            animateTo:360,
            duration:1000

          });
     },function(){
        $(this).stop().rotate({angle:0, 
          animateTo:-360,
          duration:1000
          });
    });  
} 
/***********evteam******************/
if($.browser.msie) {
    
}
else{

    $(".bloc_team").hover(function(){
        $(this).children("div:first").stop().rotate({angle:0, 
            animateTo:360,
            duration:1000

          });
     },function(){
        /*$(this).children("div:first").stop().rotate({angle:0, 
          animateTo:-360,
          duration:1000
          });*/
    });  
}

    
    /*$(".competence").hover{
       // $("figure img").rotate({ 
       // $(this).rotate({animateTo:180})
       alert("ton");
    }; */
    
    /*********************
    $(".competence").hover(
        function(){
            $(this).find("img").stop().animate({left:"+=180px"},3000).animate({top:"+=180px"},3000).scrollto("1500px").rotate({angle:0, 
          animateTo:960,
          duration:1500,
    
    
          
          });
        },
        function () {
            $(this).find("img").stop().animate({left:"0px"},3000).rotate({angle:1080, 
          animateTo:0,
          duration:5000,   
          });
        }
    );
 *********************/
    
	/**
	* Traitement JS formulaire de contact -- Mickael
	*/
	var nom_ok = false;
	var mail_ok = false;
	var mess_ok = false;
 
	 $("#nom").change(function(){
		if(!$("#nom").val().match(/^[a-zA-Z-/&\s]+$/i)){
			$("#nom").css("border","2px solid #E73E3E");
			nom_ok = false;
		}
		else{
			$("#nom").css("border","2px solid #97CB4B");
			nom_ok = true;
		}
	 });

	 $("#mail").change(function(){
		if(!$("#mail").val().match(/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/i)){
			$("#mail").css("border","2px solid #E73E3E");
			mail_ok = false;
		}
		else{
			$("#mail").css("border","2px solid #97CB4B");
			mail_ok = true;
		}
	 });
     /**partenaires****************************/
    $("#footer2 div").hide();    
    $("#partenaire").click(function(){
        $("#footer2 div").slideToggle();
    });
    /*********************menu scrollto*******************/
    $('.competences2').click(function () {
			$('body,html').animate({
				scrollTop: 440
			}, 800);
			return false;
	});
    $("#adwords").hide();
    $("#back-top").hide();
    $(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() > 1024) {
				$('#back-top').fadeIn();
			} else {
				$('#back-top').fadeOut();
			}
		});

		// scroll body to 0px on click
		$('#back-top a').click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	});

});
