//fonction de verification des champs de la commande
function verifier_qte() 
         { var trouve_qte=false;
		   var nbr_prod=document.getElementById("nbr_produit").value;
		   
		   for(var i = 1; i <= nbr_prod; i++) 
	          { var qte=0;
			    qte=document.getElementById("qte"+i).value;
			   if(qte!='')
				 {
				trouve_qte=true;
			     if((isNaN(qte))||(qte<1))
		           {alert('Entrez une valeur supérieur ou égale 1.');
					document.getElementById("qte"+i).focus();
					return false;
				   }
				 }
			  } 
			  
			  if(trouve_qte==false)
			    {alert('Veuillez choisir au moins un produit pour continuer votre commande.');
				 return false;}
			  return true;
		 }

$(document).ready(function(){


//$('#interne').corner();
						   
				$('#interne').corner({
			  tl: { radius: 15 },
			  tr: { radius: 15 },
			  bl: { radius: 0 },
			  br: { radius: 0 }});
						   

//Evenement click bt authentification		
$("#bt_authentification").click(function(){
  //alert("email "+$("#temail").val()+"   pass"+$("#tpassword").val());		 
  if(($("#temail").val()=='')||($("#tpassword").val()==''))
     { $("#msg_echec").html('E-mail ou mot de passe vide! '); }
	 else
	 {
		 
   $.ajax({
   type: "POST",
   url: "lib/check_user.php",
   data: "email="+$("#temail").val()+"&password="+$("#tpassword").val(),
   success: function(msg){
	   
	  // alert (msg);
	   if(msg=="ok")
	   $("#form_identification").submit()
	   
	   if(msg=="ko")
	   $("#msg_echec").html('Echec authentification ! ');
        }
        });		
   
	  }
										 
    });	


$("#form_inscription" ).validate({ 									 
onfocusout: true,
onkeyup: true, 
showErrors: function(errorMap, errorList) { 
if (errorList.length > 0) {
jQuery('#ereur_form').html( errorList[0].message);  }  }
});

$("#form_livraison" ).validate({ 									 
onfocusout: true,
onkeyup: true, 
showErrors: function(errorMap, errorList) { 
if (errorList.length > 0) {
jQuery('#ereur_form').html( errorList[0].element.msg_erreur+" : "+errorList[0].message); 

//$("#"+errorList[0].element.id+"").css("background", "#FFCCFF" ); 


}  }
});

//validation du formulaire recalculer panier
	$("#form_panier").validate({ meta: "validate", errorLabelContainer: $("#ereur_form") });
	
	
//switchage des obligatoire adresse livraison
	$("#form_livraison #checkliv").click(function(){if($(this).is(':checked')) {$("#tablivraison input[id!=checkliv]").removeClass("required");} else {$("#tablivraison input[id!=checkliv]").addClass("required");} });
	

//Validation du formulaire de contact
$("#form_contact" ).validate({ 									 
onfocusout: true,
onkeyup: true, 
showErrors: function(errorMap, errorList) { 
if (errorList.length > 0) {
jQuery('#ereur_form').html( errorList[0].message);  }  }
});

//**********fancy box***********//
				   
	
//fancy box 

$("a.fancyimage").fancybox({
		'overlayShow'			: true,
		'hideOnContentClick'    : false,
		'zoomSpeedIn'			: 600,
		'zoomSpeedOut'			: 500,
		'easingIn'				: 'easeOutBack',
		'easingOut'				: 'easeInBack',
		'frameWidth': 800,
		'frameHeight': 650
	});

});