

$(document).ready(function()
{

	$('.nyro').nyroModal({bgColor: '#000000'});
	
	(function($) {
	  $.fn.inputdynvalue = function (args) {

		var params = $.extend({
		  text: false, // 'texte libre', si laissé vide on utilise un attribut HTML
		  attr: 'title', // attribut à exploiter ('value' déconseillé!)
		  clss: 'hint' // classe à ajouter quand une suggestion est affichée
		}, args);

		return this.each(function(){

		  // Initialisation de l'input (attributs value, class)
		  var $input = $(this), startVal = $input.val();
		  if (!params.text) {var text = $input.attr(params.attr);}
		  else {var text = params.text;}
		  if (!startVal) {$input.val(text).addClass(params.clss);}
		  else if (startVal == text) {$input.addClass(params.clss);}

		  // Ajout et suppression du texte au focus ou à la perte de focus
		  $input.unbind('focus.dynvalue blur.dynvalue');
		  $input.bind('focus.dynvalue', function() {
			if ($input.val() == text) {$input.val('').removeClass(params.clss);}
		  });
		  $input.bind('blur.dynvalue', function() {
			var currentVal = $input.val();
			if (currentVal == '') {$input.val(text).addClass(params.clss);}
			else if (currentVal == text) {$input.val(text).addClass(params.clss);}
		  });

		  // Suppression du texte par défaut à l’envoi du formulaire
		  $(this.form).bind('submit.dynvalue', function(){
			if ($input.val() == text) {$input.val('');}
		  });

		});
	  };
	})(jQuery);
	
	$("#form_contact input:text").inputdynvalue();
	$("#form_contact textarea").inputdynvalue();
	
});
$(document).ready(function()
{				
	$('#form_contact').submit(function()
	{
	var erreur = 0;
		$("#form_contact input:text").each(function(i){
			
			
			var temp_name = $(this).attr('name');
			
			
			switch (temp_name) {
			 case "set_prenom":
				if($(this).val() == 'Prenom' || $(this).val() == '')
				{
					
					$(this).css('border','1px solid red');
					$(this).css('background-color','#fcabad');
					$(this).val('Prenom');
					
					erreur++;
				
				}
				else
				{
					$(this).css('border','1px solid #C4C2C2');
					$(this).css('background-color','#F5F5F5');
				}
			 break;
			  case "set_nom":
				if($(this).val() == 'Nom' || $(this).val() == '')
				{
					$(this).val('Nom');
					$(this).css('border','1px solid red');
					$(this).css('background-color','#fcabad');
					erreur++;
				}
				else
				{
					$(this).css('border','1px solid #C4C2C2');
					$(this).css('background-color','#F5F5F5');
				}
			 break;
			 
			  case "set_societe":
				if($(this).val() == 'Societe' || $(this).val() == '')
				{
					$(this).val('Societe');
					$(this).css('border','1px solid red');
					$(this).css('background-color','#fcabad');
					erreur++;
				}
				else
				{
					$(this).css('border','1px solid #C4C2C2');
					$(this).css('background-color','#F5F5F5');
				}
			 break;
			  case "set_email":
				if($(this).val() == 'Email' || $(this).val() == '' || verifierEMail($(this).val()) == false) 
				{
					$(this).val('Email');
					$(this).css('border','1px solid red');
					$(this).css('background-color','#fcabad');
					erreur++;
				}
				else
				{
					$(this).css('border','1px solid #C4C2C2');
					$(this).css('background-color','#F5F5F5');
				}
			 break;
			  case "set_telephone":
				if($(this).val() == 'Telephone' || $(this).val() == '')
				{
					$(this).val('Telephone');
					$(this).css('border','1px solid red');
					$(this).css('background-color','#fcabad');
					erreur++;
				}
				else
				{
					$(this).css('border','1px solid #C4C2C2');
					$(this).css('background-color','#F5F5F5');
				}
			 break;
			}
			
			
				
		});
		
		if(erreur != 0){ return false; }
		
	});
	});
function verifierEMail(email)
{
	var expr=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}[.]?[a-zA-Z]{0,3}$/;
	if(expr.exec(email))
	{
		return true;
	}
	else
	{
		return false;
	}
}

$(document).ready(function()
{
	$('#input_recherche').click(function()
	{
		if($(this).val() == 'Recherche')
		{
			$(this).val('');
		}
	});
	
	total_pduit = $('#nb_pduit').val();
	tampon_largeur_caroussel = 0;
	var temp_move = 1;
	total_pduit =Math.floor(total_pduit/2);
	total_marge = total_pduit*-646;
	action_user=0;
	u=0;
	$(document).everyTime(4000, function(i) {
		
		
	
		if(u<(total_pduit-1) && temp_move == 1 && action_user==0)
		{
			temp_move = 0;
			tampon_largeur_caroussel = tampon_largeur_caroussel-646;
			$('#full_animate').animate({marginLeft:tampon_largeur_caroussel+'px'}, 1000, function()
			{
				temp_move = 1;
				u++;
			});
		}
		else if(action_user==0 && temp_move == 1)
		{
			
			tampon_largeur_caroussel = 0;
			temp_move = 0;
			$('#full_animate').animate({marginLeft:'0px'}, 1000, function()
			{
				temp_move = 1;
				u=0;
			});
		}
		
	
	});
	
	
	$('#fl_droite').click(function()
	{
		
		var tampon_css = $('#full_animate').css('margin-left');
		tampon_css= parseInt(tampon_css);
		if(temp_move == 1 && total_marge != (tampon_css-646))
		{
			action_user=1;
			temp_move = 0;
			tampon_largeur_caroussel = tampon_largeur_caroussel-646;
			$('#full_animate').animate({marginLeft:tampon_largeur_caroussel+'px'}, 600, function()
			{
				temp_move = 1;
			});
		}
	});
	
	$('#fl_gauche').click(function()
	{
		var tampon_css = $('#full_animate').css('margin-left');
		tampon_css= parseInt(tampon_css);
		if(temp_move == 1 && tampon_css != 0)
		{
			action_user=1;
			tampon_largeur_caroussel = tampon_largeur_caroussel+646;
			temp_move = 0;
			$('#full_animate').animate({marginLeft:tampon_largeur_caroussel+'px'}, 600, function()
			{
				temp_move = 1;
			});
		}
	});
});
