






// Speed of the automatic slideshow
var slideshowSpeed = 6000;

// Variable to store the images we need to set as background
// which also includes some text and url's.
var photos = [ {
		"image" : "fond.jpg",
		"url" : "./images/"
	}, {
		"image" : "fond2.jpg",
		"url" : "./images/"
	}, {
		"image" : "fond3.jpg",
		"url" : "./images/"
	}, {
		"image" : "fond4.jpg",
		"url" : "./images/"
	}, {
		"image" : "fond5.jpg",
		"url" : "./images/"
	}
];


















   $(document).ready(function() {
	   
	   $("#plopplop").carouFredSel({
	   	direction : 'left',
		scroll : {
			fx : 'directscroll',
			duration : 400,
			pauseOnHover : true
		},
		ciruclar : false,
		pagination : {
			container : '#pagination',	
			anchorBuilder :
				function(nr, item) {
   					 return '<a href="#'+nr+'" class="proutprout"><span&nbsp;> </span></a>';
				}
		}
   	   });
	   
		zoombox.init();		
		  $("#IDdubouton").scrollToTop({
			speed:1800,
			ease:"easeOutBounce",
			start:250});		
		
		
		$("#FootASite").hover(function(){$(this).children("img").attr("src","./images/creation_site_internetHover.png")},function(){$(this).children("img").attr("src","./images/creation_site_internet.png")});		   
		$("#FootADesign").hover(function(){$(this).children("img").attr("src","./images/design_webHover.png")},function(){$(this).children("img").attr("src","./images/design_web.png")});
		$("#FootAFormations").hover(function(){$(this).children("img").attr("src","./images/formationHover.png")},function(){$(this).children("img").attr("src","./images/formation.png")});
		$("#FootAPrint").hover(function(){$(this).children("img").attr("src","./images/print_mediaHover.png")},function(){$(this).children("img").attr("src","./images/print_media.png")});	   
	   
		
		// ----------------------------------		
		// formulaire contact
		// ----------------------------------
		
		
		$("#submitcontactForm").live("mousedown",function(){ $("#submitcontactForm").css("background","url(./images/submithover.png)") })
		$("#submitcontactForm").live("mouseup",function(){ $("#submitcontactForm").css("background","url(./images/submit.png)") })
		
		$("#bottom_contactc").live("mousedown",function(){ $("#bottom_contactc").css("background","url(./images/Gsubmit.png) 0 -40px") })
		$("#bottom_contactc").live("mouseup",function(){ $("#bottom_contactc").css("background","url(./images/Gsubmit.png)  0 0  ")})		
		
			
		
		$("#footContact input").click(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Nom" || $(this).val() == "Prénom" || $(this).val() == "Téléphone"  || $(this).val() == "Email" || 
			 $(this).val() == "Entrez votre nom" || $(this).val() == "Entrez votre prénom" || $(this).val() == "Entrez votre téléphone"  || $(this).val() == "Entrez votre email" || $(this).val() == "email incorrect" 
		  )
		 {
				$(this).val("") ;
		 }
		});	 
		$("#footContact textarea").click(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Ecrivez ici votre message" || $(this).val() == "Aucune demande ?")
		 {
				$(this).val("") ;
		 } 
		 });
		 
		 
		 $("#footContact input").focus(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Nom" || $(this).val() == "Prénom" || $(this).val() == "Téléphone"  || $(this).val() == "Email" || 
			 $(this).val() == "Entrez votre nom" || $(this).val() == "Entrez votre prénom" || $(this).val() == "Entrez votre téléphone"  || $(this).val() == "Entrez votre email" || $(this).val() == "email incorrect" 
		  )
		 {
				$(this).val("") ;
		 }			 
		 });
		 $("#footContact textarea").focus(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Ecrivez ici votre message" || $(this).val() == "Aucune demande ?")
		 {
				$(this).val("") ;
		 } 			 
		}); 
		 
		 
		$("#submitcontactForm").click(function(){
			
		var couleurErreur = "#427BBE"	
		var count = 0;
		if ( $("#nom").val() == "" || $("#nom").val() == "Nom"  || $("#nom").val() == "Entrez votre nom" )
		{
			$("#nom").css("color",couleurErreur);
			$("#nom").val("Entrez votre nom");
		}else
		{
			count++;	
		}
		
		if ( $("#prenom").val() == "" || $("#prenom").val() == "Prénom" || $("#prenom").val() == "Entrez votre prénom" )
		{
			$("#prenom").css("color",couleurErreur);
			$("#prenom").val("Entrez votre prénom");
		}else
		{
			count++;	
		}		
		
		if ( $("#tel").val() == "" || $("#tel").val() == "Téléphone" || $("#tel").val() == "Entrez votre téléphone")
		{
			$("#tel").css("color",couleurErreur);
			$("#tel").val("Entrez votre téléphone");
		}else
		{
			count++;	
		}			

		if ( $("#email").val() == ""  || $("#email").val() == "Email" || $("#email").val() == "Entrez votre email")
		{
			$("#email").css("color",couleurErreur);
			$("#email").val("Entrez votre email");
		}
		else
		{
			
			var verif = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/
			if (verif.exec($("#email").val()) == null)
			{ 
				$("#email").css("color",couleurErreur);
				$("#email").val("email incorrect");	
			}
			else
			{
				count++;
			}
		}	

		if ( $("#message").val() == "" || $("#message").val() == "Ecrivez ici votre message"  || $("#message").val() == "Aucune demande ?")
		{
			$("#message").css("color",couleurErreur);
			$("#message").val("Aucune demande ?")
		}
		else
		{
			count++;	
		}	
		
		if (  count == 5 )
		{
					$("#verifForm").fadeIn("fast");
					$.post("ajaxContact.php", { 
					   nom: $("#nom").val(),
					   prenom: $("#prenom").val(),
					   telephone: $("#tel").val(),
					   email: $("#email").val(),
					   message: $("#message").val()
					   },
						function(data){	
									
								if ( data == "ok" )
								{
									apprise('E-mail envoyé<br/> Votre e-mail a été transmis avec succès à l\'équipe et sera traité dans les meilleurs délais.');
									$("#verifForm").fadeOut("fast");
									$("#nom").val("Nom");
									$("#prenom").val("Prénom");
									$("#tel").val("Téléphone");
									$("#email").val("Email");
									$("#message").val("Ecrivez ici votre message");
								}
								else
								{
									apprise('Une erreur est survenue... pas de panique !<br/>Il semble que le message n\'a pu ëtre delivré<br/>Reéssayez...');	
									$("#verifForm").fadeOut("fast");
								}
						 },"html" );	
		}});
		
		
		// ----------------------------------		
		//  
		// ----------------------------------		 
		 
		$("#Gcontact input").click(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Nom / Prénom"  || $(this).val() == "Téléphone"  || $(this).val() == "Email" || $(this).val() == "Sujet" || 
			 $(this).val() == "Entrez votre Nom / Prénom"  || $(this).val() == "Entrez votre téléphone"  || $(this).val() == "Entrez votre email" || $(this).val() == "email incorrect" || $(this).val() == "Entrez le sujet de votre demande" 
		  )
		 {
				$(this).val("") ;
		 }
		});	 
		$("#Gcontact textarea").click(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Ecrivez ici votre message" || $(this).val() == "Aucune demande ?")
		 {
				$(this).val("") ;
		 } 
		 });
		 
		 
		 $("#Gcontact input").focus(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Nom / Prénom" ||  $(this).val() == "Téléphone"  || $(this).val() == "Email" ||  $(this).val() == "Sujet" || 
			 $(this).val() == "Entrez votre Nom / Prénom"   || $(this).val() == "Entrez votre téléphone"  || $(this).val() == "Entrez votre email" || $(this).val() == "email incorrect" || $(this).val() == "Entrez le sujet de votre demande"
		  )
		 {
				$(this).val("") ;
		 }			 
		 });
		 $("#Gcontact textarea").focus(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Ecrivez ici votre message" || $(this).val() == "Aucune demande ?")
		 {
				$(this).val("") ;
		 } 			 
		}); 
		 
		 
		$("#bottom_contactc").click(function(){
		
		var couleurErreur = "#FFFFFF"	
		var count = 0;
		
		if ( $("#Gnom").val() == "" || $("#Gnom").val() == "Nom / Prénom"  || $("#Gnom").val() == "Entrez votre nom / Prénom" )
		{
			$("#Gnom").css("color",couleurErreur);
			$("#Gnom").val("Entrez votre Nom / Prénom");
		}else
		{
			count++;	
		}
		
			
		
		if ( $("#Gtel").val() == "" || $("#Gtel").val() == "Téléphone" || $("#Gtel").val() == "Entrez votre téléphone")
		{
			$("#Gtel").css("color",couleurErreur);
			$("#Gtel").val("Entrez votre téléphone");
		}else
		{
			count++;	
		}			

		if ( $("#Gsujet").val() == "" || $("#Gsujet").val() == "Sujet" || $("#Gsujet").val() == "Entrez le sujet de votre demande")
		{
			$("#Gsujet").css("color",couleurErreur);
			$("#Gsujet").val("Entrez le sujet de votre demande");
		}else
		{
			count++;	
		}	
		
		if ( $("#Gemail").val() == ""  || $("#Gemail").val() == "Email" || $("#Gemail").val() == "Entrez votre email")
		{
			$("#Gemail").css("color",couleurErreur);
			$("#Gemail").val("Entrez votre email");
		}
		else
		{
			
			var verif = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/
			if (verif.exec($("#Gemail").val()) == null)
			{ 
				$("#Gemail").css("color",couleurErreur);
				$("#Gemail").val("email incorrect");	
			}
			else
			{
				count++;
			}
		}	

		if ( $("#Gdemande").val() == "" || $("#Gdemande").val() == "Ecrivez ici votre message"  || $("#Gdemande").val() == "Aucune demande ?")
		{
			$("#Gdemande").css("color",couleurErreur);
			$("#Gdemande").val("Aucune demande ?")
		}
		else
		{
			count++;	
		}	
		
		if (  count == 5 )
		{
					alert('coucou');			
					$.post("ajaxGContact.php", { 
					   nom: $("#Gnom").val(),
					   telephone: $("#Gtel").val(),
					   email: $("#Gemail").val(),
					   sujet: $("#Gsujet").val(),
					   demande: $("#Gdemande").val()
					   },
						function(data){	
									
								if ( data == "ok" )
								{
									alert('E-mail envoyé<br/> Votre e-mail a été transmis avec succès à l\'équipe et sera traité dans les meilleurs délais.');
									
									$("#Gnom").val("Nom / Prénom");
									$("#Gtel").val("Téléphone");
									$("#Gemail").val("Email");
									$("#Gsujet").val("Sujet");
									$("#Gdemande").val("Ecrivez ici votre message");
								}
								else
								{
									alert('Une erreur est survenue... pas de panique !<br/>Il semble que le message n\'a pu ëtre delivré<br/>Reéssayez...');	
									$("#verifForm").fadeOut("fast");
								}
						 },"html" );	
		}});
		
		
		// ----------------------------------		
		//  
		// ----------------------------------	












		$('#referencesImg').bxCarousel({
		   display_num: 3,
		   move: 1,
		   auto: true,
		   controls: false,
		   margin: 10,
		   auto_hover: true,
		   border: 0

		});		
		
		// ----------------------------------		
		//  
		// ----------------------------------			
		
	var interval;
	$("#control").toggle(function(){
		stopAnimation();
	}, function() {

		
		// Show the next image
		navigate("next");
		
		// Start playing the animation
		interval = setInterval(function() {
			navigate("next");
		}, slideshowSpeed);
	});
	
	
	var activeContainer = 1;	
	var currentImg = Math.floor(Math.random()*6);
	var animating = false;
	var navigate = function(direction) {
		// Check if no animation is running. If it is, prevent the action
		if(animating) {
			return;
		}
		
		// Check which current image we need to show
		if(direction == "next") {
			currentImg++;
			if(currentImg == photos.length + 1) {
				currentImg = 1;
			}
		} else {
			currentImg--;
			if(currentImg == 0) {
				currentImg = photos.length;
			}
		}
		
		// Check which container we need to use
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		}
		
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
		
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
		
		// Make sure the new container is always on the background
		currentZindex--;
		
		// Set the background image of the new active container
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(images/" + photoObject.image + ")",
			"display" : "block",
			"z-index" : currentZindex
		});
		

		
		
		// Fade out the current container
		// and display the header text when animation is complete
		$("#headerimg" + currentContainer).fadeOut(function() {
			setTimeout(function() {
				$("#headertxt").css({"display" : "block"});
				animating = false;
			}, 3000);
		});
	};
	
	var stopAnimation = function() {
		clearInterval(interval);
	};
	
	// We should statically set the first image
	navigate("next");
	
	// Start playing the animation
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
				 
		// ----------------------------------		
		//  
		// ----------------------------------	
		
		
		$("#menuSite").hover(function(){$("#SmenuDesign").slideUp("fast");$("#SmenuInternet").slideDown("slow");});
		$("#menuDesign").hover(function(){$("#SmenuInternet").slideUp("fast");$("#SmenuDesign").slideDown("slow");});
		
		$("#menuPrint").hover(function(){$("#SmenuFormations").slideUp("fast");$("#SmenuPrint").slideDown("slow");});
		$("#menuFormations").hover(function(){$("#SmenuPrint").slideUp("fast");$("#SmenuFormations").slideDown("slow");});		
		
		
		$("#logoClick").hover( function(){$(".Smenu").slideUp("fast");},function(){});
		$("#menuContact").hover( function(){$(".Smenu").slideUp("fast");},function(){});			
		 
		$("#logo").hover(function(){},function(){ $(".Smenu").slideUp("fast");});
		
		// ----------------------------------		
		//  
		// ----------------------------------
		
		

		
				

						 	 
   });
      
 var nombreClick = 0;   
   
 function pattern()
 {
	var nombreimage = Math.floor(Math.random()*16);
	if ( nombreimage < 10 )
	{
	nombreimage = "0"+nombreimage;	
		
	}
	//$("#headerimgpattern").fadeOut("slow");
	//$("#fond").animate({marginTop:"0px"});
	$("#headerimgpattern").css("background","url(./pattern/"+nombreimage+".png)");
	//$("#headerimgpattern").fadeIn("slow");
	//$("#fond").animate({marginTop:"-1600px"});
	if ( nombreClick == 0 )
	{ 		 
		//apprise("Voici encore une possibilité dans le web! Ajouter des patterns au dessus des images pour ajouter du style, une ambiance... Ici c'est l'ambiance de l'image de fond qui change, Recliquez pour changer les patterns pour voir la différence");
		nombreClick = 1;
	}
 }
   
   
   
   
   
   
   
   
   
   
