function verifPanier(qForm){

	var forme = document.getElementById(qForm);
	var qteMax = forme.nbProduitMax.value * 1;
	var qte = forme.nbProduit.value * 1;
	var nb = forme.nb.value * 1;
	
	if(nb>0){
	
		
		if( nb <= qteMax && (qte+nb <=qteMax)){
			
		forme.submit();
		}
		 else {
			
		alert("Vous ne pouvez plus ajouter de produit \340 votre panier");
		return false;
		}
	
	} else return false;
	
}

function verifPanierEtape3(qForm){
	var forme = document.getElementById(qForm);
	
	var qteMax = forme.nbProduitMax.value * 1;
	var nbTour = forme.nbTour.value * 1;
	var qte = forme.nbProduit.value * 1;
	var nb = forme.nb.value * 1;

	/*qte = nombre déja dans panier
	sumTotal = nouvellevaleur
	nb = nouvelle valeur*/
	var sumBillet=0;
	for(i=0;i<nbTour;i++){
			var forme2 = document.getElementById("form"+i);

		sumBillet = sumBillet*1 + forme2.nb.value*1;	
		
	}
	if(sumBillet <= qteMax){
		forme.submit();
	}
	else {
		alert("Vous avez d\351pass\351 le maximum de billets autoris\351");
		return false;
		
	}
	
}


function verifAdresse(){

		var nom = document.getElementById("nom").value;
		var validAdresse = document.getElementById("validAdresse").value;
		var prenom = document.getElementById("prenom").value;
		var adresse1 = document.getElementById("adresse1").value;
		var adresse2 = document.getElementById("adresse2").value;
		var ville = document.getElementById("ville").value;
		var cp = document.getElementById("cp").value;
		var pays = document.getElementById("pays").value;
		var email = document.getElementById("email").value;
		var tel = document.getElementById("tel").value;
		
		if(validAdresse != 1){
		alert("Vous devez valider votre adresse");
		return false;	
		}
		
		if(!nom || !prenom || !adresse1 || !ville || !cp || !email || !tel){
		alert("Vous devez renseignez tous les champs obligatoire");
		return false;
		}
		else {
		return true;	
		}
}

function setAdresse(where){

	switch(where){
		case "facturation":



		var validAdresse = document.getElementById("validAdresse");
		
		validAdresse.value = 1;
		var formFacturation = document.getElementById("formFacturation");
		var showFacturation = document.getElementById("showFacturation");

		var nom = document.getElementById("nom").value;
		var prenom = document.getElementById("prenom").value;
		var adresse1 = document.getElementById("adresse1").value;
		var adresse2 = document.getElementById("adresse2").value;
		var ville = document.getElementById("ville").value;
		var cp = document.getElementById("cp").value;
		var pays = document.getElementById("pays").value;
		var email = document.getElementById("email").value;
		var tel = document.getElementById("tel").value;
		var offres = document.getElementById("accepte_offre").checked;
		
		if(offres == true){
			offres = 1;
		}else{
			offres = 0;
		}

		
		
		if(!nom || !prenom || !adresse1 || !ville || !cp || !email || !tel){
		alert("Vous devez renseignez tous les champs obligatoire");
		
		}
		else {
		
		
		    	 
		showFacturation.innerHTML = '<div class="adresse">';
		showFacturation.innerHTML +=  '<div style="line-height:15px; width:268px; float:left;">';
		showFacturation.innerHTML +=  		'<div style="width:15px; float:left;"><img src="images/fljaune.gif" alt="fleche" style="float:left;"/></div>';
		showFacturation.innerHTML +=  			'<div class="adresse" style="line-height:18px; font-weight:bold;">'+nom+' '+prenom+'</div>';
		showFacturation.innerHTML +=  	 '</div>  ';
	if(adresse1)	showFacturation.innerHTML +=         '<div style="line-height:15px; width:253px; margin-left:15px;float:left; line-height:14px;">'+adresse1+'</div>';
	if(adresse2)	showFacturation.innerHTML +=        ' <div style="line-height:15px; width:253px;margin-left:15px; float:left;line-height:14px;">'+adresse2+'</div>';
			
	if(cp)	showFacturation.innerHTML +=        ' <div style="line-height:15px; margin-left:15px;float:left; line-height:14px;">'+cp+'</div>';
	if(ville)	showFacturation.innerHTML +=        ' <div style="line-height:15px; margin-left:5px; float:left;line-height:14px;">'+ville+'</div>';
		  
		  
	if(pays)	showFacturation.innerHTML +=       ' <div style="line-height:15px; width:253px; margin-left:15px;float:left; line-height:14px;">'+pays+'</div>';
	if(email)	showFacturation.innerHTML +=        ' <div style="line-height:15px; width:253px; margin-left:15px;float:left; line-height:14px;">'+email+'</div>';
	if(tel)	showFacturation.innerHTML +=        ' <div style="line-height:15px; width:253px; margin-left:15px;float:left; line-height:14px;">'+tel+'</div>';
		
		showFacturation.innerHTML +=  	'</div>';

    		showFacturation.innerHTML +=  	'<a href="javascript:modifieAdresse(\'facturation\');" style="float:left; margin-left:15px; margin-top:10px;"><img src="images/modif_adresse.gif" alt="valider" border="0" /></a>';


		showFacturation.innerHTML +=  '<input type="hidden" name="nomFacturation" value="'+nom+'">';		
		showFacturation.innerHTML +=  '<input type="hidden" name="prenomFacturation" value="'+prenom+'">';		
		showFacturation.innerHTML +=  '<input type="hidden" name="adresse1Facturation" value="'+adresse1+'">';		
		showFacturation.innerHTML +=  '<input type="hidden" name="adresse2Facturation" value="'+adresse2+'">';		
		showFacturation.innerHTML +=  '<input type="hidden" name="cpFacturation" value="'+cp+'">';		
		showFacturation.innerHTML +=  '<input type="hidden" name="villeFacturation" value="'+ville+'">';		
		showFacturation.innerHTML +=  '<input type="hidden" name="paysFacturation" value="'+pays+'">';		
		showFacturation.innerHTML +=  '<input type="hidden" name="emailFacturation" value="'+email+'">';		
		showFacturation.innerHTML +=  '<input type="hidden" name="telFacturation" value="'+tel+'">';
		showFacturation.innerHTML +=  '<input type="hidden" name="AccepteOffrePromo" value="'+offres+'">';		
		
		formFacturation.style.display = "none";
		showFacturation.style.display = "block";

		}
		break;
		
		
		case "livraison":
		var formLivraison = document.getElementById("formLivraison");
		var showLivraison = document.getElementById("showLivraison");



		var nom = document.getElementById("nom_livraison").value;
		var prenom = document.getElementById("prenom_livraison").value;
		var adresse1 = document.getElementById("adresse1_livraison").value;
		var adresse2 = document.getElementById("adresse2_livraison").value;
		var ville = document.getElementById("ville_livraison").value;
		var cp = document.getElementById("cp_livraison").value;
		var pays = document.getElementById("pays_livraison").value;
		
		 
		showLivraison.innerHTML = '<div class="adresse">';
		showLivraison.innerHTML +=  '<div style="line-height:15px; width:268px; float:left;">';
		showLivraison.innerHTML +=  		'<div style="width:15px; float:left;"><img src="images/fljaune.gif" alt="fleche" style="float:left;"/></div>';
		showLivraison.innerHTML +=  			'<div class="adresse" style="line-height:18px; font-weight:bold;">'+nom+' '+prenom+'</div>';
		showLivraison.innerHTML +=  	 '</div>  ';
		if(adresse1)	showLivraison.innerHTML +=         '<div style="line-height:15px; width:253px; margin-left:15px;float:left; line-height:14px;">'+adresse1+'</div>';
		if(adresse2)	showLivraison.innerHTML +=        ' <div style="line-height:15px; width:253px;margin-left:15px; float:left;line-height:14px;">'+adresse2+'</div>';
		if(cp)	showLivraison.innerHTML +=        ' <div style="line-height:15px; margin-left:15px;float:left; line-height:14px;">'+cp+'</div>';
		if(ville)	showLivraison.innerHTML +=        ' <div style="line-height:15px; margin-left:5px; float:left;line-height:14px;">'+ville+'</div>';
		if(pays)	showLivraison.innerHTML +=       ' <div style="line-height:15px; width:253px; margin-left:15px;float:left; line-height:14px;">'+pays+'</div>';
		showLivraison.innerHTML +=  	'</div>';
		showLivraison.innerHTML +=  	'<a href="javascript:modifieAdresse(\'livraison\');" style="float:left; margin-left:15px; margin-top:10px;"><img src="images/modif_adresse.gif" alt="valider" border="0" /></a>';
		


		showLivraison.innerHTML +=  '<input type="hidden" name="nomLivraison" value="'+nom+'">';		
		showLivraison.innerHTML +=  '<input type="hidden" name="prenomLivraison" value="'+prenom+'">';		
		showLivraison.innerHTML +=  '<input type="hidden" name="adresse1Livraison" value="'+adresse1+'">';		
		showLivraison.innerHTML +=  '<input type="hidden" name="adresse2Livraison" value="'+adresse2+'">';		
		showLivraison.innerHTML +=  '<input type="hidden" name="cpLivraison" value="'+cp+'">';		
		showLivraison.innerHTML +=  '<input type="hidden" name="villeLivraison" value="'+ville+'">';		
		showLivraison.innerHTML +=  '<input type="hidden" name="paysLivraison" value="'+pays+'">';		
		formLivraison.style.display = "none";
		showLivraison.style.display = "block";
		break;
	}
}


function modifieAdresse(where){

	switch(where){
		case "facturation":
		
		var formFacturation = document.getElementById("formFacturation");
		var showFacturation = document.getElementById("showFacturation");
		
		showFacturation.innerHTML = '';
		showFacturation.style.display = "none";
		formFacturation.style.display = "block";
		break;
		
				case "livraison":
		
		var formFacturation = document.getElementById("formLivraison");
		var showFacturation = document.getElementById("showLivraison");
		
		showFacturation.innerHTML = '';
		showFacturation.style.display = "none";
		formFacturation.style.display = "block";
		break;

	}
}

function verifPaiement(){

if(document.getElementById("cgv").checked == true){
	return true;
}
else {
	alert("Vous devez accepter les conditions g\351n\351rales de ventes");
	return false;
	}
}

document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('');
