
function ResetForm(nom,nombre)
{
	var i;
	for(i=1;i<nombre+1;i++)
	{
		document.getElementByID(nom+'_'+str(nombre)).checked = false;
	}
}

function envoie_formulaire(min,location)
{
	if(document.getElementById('fakeblood').value.length >= min)
	{
	//alert('lol');
		if(document.getElementById('ordre_prix'))
		{
			//
		}
		if(document.getElementById('wanted_pos'))
		{
			document.getElementById('wanted_pos').value='0';
		}
		if(location=='greffon')
		{
		if(document.getElementById('param_search_boutique'))
		{
					document.getElementById('param_search_boutique').value = document.getElementById('param_search_boutique_ext').value;	
				}
			
		}
		else
		{
		 		if(document.getElementById('param_search_boutique'))
				{
					document.getElementById('param_search_boutique').value = document.getElementById('fakeblood').value;	
				}
		}

		
		search_article();
	}

}
function SetPosPagination(position)
{
	if(document.getElementById("wanted_pos"))
	{
		document.getElementById('wanted_pos').value=position;
	}
	else
	{
		document.getElementById('wanted_pos_alone').value=position;
	}
	search_article();
}
function switch_vignette(indice_vignette){
	vignette_survolee = "div_photo_principale_"+indice_vignette;
	nbre_boucle = document.getElementById("nbre_vignettes").value;
	if(nbre_boucle>1){
		for(gg=0;gg<nbre_boucle;gg++){		
			indicetof = "div_photo_principale_"+gg;
			document.getElementById(indicetof).style.display='none';
		}
	}
	document.getElementById(vignette_survolee).style.display='block';
return;
}
function search_article_bck(){
	if(document.getElementById("search_boutique"))
	{
	document.getElementById("search_boutique").submit();
	return;
}
	else
	{
		document.getElementById("search_boutique_alone").submit();
	return;
	}
	
}
function search_article(){
	if(document.getElementById("search_boutique"))
		if(document.getElementById('ordre_prix'))
		{
			if(document.getElementById('ordre_prix').value=='')
			{
				document.getElementById('ordre_prix').value = document.getElementById('ordre_prix_n').value;
			}
		}
		document.getElementById("search_boutique_alone").submit();
	return;
	}
	else
	{
		document.getElementById("search_boutique").submit();
	return;
	}

}
/* Reference 2 */
function choix_ref(sous_ref,id_article){
var	refarticle2 = "reference_Article2_"+id_article;
	if(document.getElementById(refarticle2)){
		document.getElementById(refarticle2).value=sous_ref;
	}

	return;
}
/**********************************************/
/*****************   PANIER   *****************/
/**********************************************/
function ajout_panier(existence_sous_ref,id_formulaire,id_article){
	ref_langue = "langue_" + id_article;
	var langue = document.getElementById(ref_langue).value;
	tab_translation = new Array();
	tab_translation[0] = new Array();
	tab_translation[0]["fr"] = "Sélectionnez une sous-référence";
	tab_translation[0]["en"] = "Select a sub-reference";
	
  // Cas ou l'article n'a pas de sous-reference: existence_sous_ref=0
  var sous_ref_choisie_liste_deroulante=0;
  // Si l'article a des sous-references on verifie qu'au moins une a été sélectionnée
  id_select_ref = "choix_reference_"+id_article;
  if(existence_sous_ref==1){
    sous_ref_choisie_liste_deroulante = document.getElementById(id_select_ref).value;
  }
  if(sous_ref_choisie_liste_deroulante==1){ // 1 correspond à la sous-reference vide(-- Choisir la sous-reference--) 
    alert(tab_translation[0][langue]); //Sélectionnez une sous-référence
  }
  else{
    document.getElementById(id_formulaire).submit();
  }
	return;
}

function suppr_art_panier(id_suppr){
	var langue = document.getElementById("langue").value;
	tab_translation = new Array();
	tab_translation[1] = new Array();
	tab_translation[1]["fr"] = "Etes-vous sur de vouloir supprimer le produit ?";
	tab_translation[1]["en"] = "Are you sure you want to delete this product ?";	
	if(confirm(tab_translation[1][langue])){ /*"Etes-vous sur de vouloir supprimer le produit ?"*/
		document.getElementById("mynext_action").value="suppression";
		document.getElementById("id_article_modif").value=id_suppr;
		document.getElementById("the_form_panier").submit();
		return;
	}
}
/**
 * Modifier la quantité à commander 
 */
function modif_qte_produit_panier(id_article_modif,the_operation_qte,id_article){
  document.getElementById("mynext_action").value="modif_quantite";
	document.getElementById("the_operation_qte").value=the_operation_qte;
	document.getElementById("id_article_modif").value=id_article_modif;
	document.getElementById("id_article").value=id_article;
	//document.getElementById("ref2_article_modif").value=ref2_article_modif;
	document.getElementById("the_form_panier").submit();
	return;
}

function vider_panier(){
	var langue = document.getElementById("langue").value;
	tab_translation = new Array();
	tab_translation[2] = new Array();
	tab_translation[2]["fr"] = "Etes-vous sûr de vouloir vider le panier ?";
	tab_translation[2]["en"] = "Are you sure you want to empty your cart ?";	
	if(confirm(tab_translation[2][langue])){ /*"Etes-vous sur de vouloir vider le panier ?"*/
		document.getElementById("mynext_action").value="vidange_panier";
		document.getElementById("the_form_panier").submit();
	}
}

function visualiser_panier(){
	document.getElementById("next_action").value="visualisation";
	document.getElementById("ajout_panier").submit();
}

function valider_commande(the_host, the_id_club,id_membre,recap){
	
	if(recap=="recap_panier"){
		var monaction='http://'+the_host+'/commande_'+the_id_club+'.html';
	}
	else if(recap=="sans_compte"){
		var monaction='http://'+the_host+'/inscription_'+the_id_club+'.html';
	}
	else if(id_membre==""){
		var monaction='http://'+the_host+'/authent_'+the_id_club+'.html';
	}
	else{
		var monaction='http://'+the_host+'/commande_'+the_id_club+'.html';
	}
	document.getElementById("the_form_panier").action=monaction;
	document.getElementById("the_form_panier").submit();
	return;
}

function validation_deja_client(login, mot_de_passe){
	var langue = document.getElementById("langue").value;
	tab_translation = new Array();
	tab_translation[3] = new Array();
	tab_translation[3]["fr"] = "Email ou mot de passe incorrect\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[3]["en"] = "Wrong email or password \nPlease try again.";	
	tab_translation[4] = new Array();
	tab_translation[4]["fr"] = "L\'email n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[4]["en"] = "Please fill in your email and try again.";
	tab_translation[5] = new Array();
	tab_translation[5]["fr"] = "Le mot de passe n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[5]["en"] = "Please fill in your email and try again.";
	
	
	var basehref = "/offres/gestion/";
	
	if(login !='' && mot_de_passe!=''){
		var corps="login="+login+"&mot_de_passe="+mot_de_passe;
		//window.open(basehref+"boutique/controle_login_clients.php?"+corps);
		p = new XMLHttpRequest();
		p.open("POST",basehref+"boutique/controle_login_clients.php",false);
		p.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		p.send(corps);
		if (p.status != "200") {
			//span.innerHTML = "XMLHTTPREQUEST : Echec";
		}
		else {
			var docXML = p.responseXML.documentElement;
			var result = docXML.getElementsByTagName('result')[0].getAttribute('val');
			var mode = docXML.getElementsByTagName('mode')[0].getAttribute('val');
			var firstlog = docXML.getElementsByTagName('firstlog')[0].getAttribute('val');
			var firstid = docXML.getElementsByTagName('firstid')[0].getAttribute('val');
			var pagetoload = docXML.getElementsByTagName('pagetoload')[0].getAttribute('val');
			var menuforced = docXML.getElementsByTagName('menuforced')[0].getAttribute('val');
			var listeids = docXML.getElementsByTagName('listeids')[0].getAttribute('val');
	
			if (result == 'KO'){
				alert(tab_translation[3][langue]);
			}
			else if (result == 'MULTI'){
				document.location=basehref+"login/multi_login.php";					
			}
			else{
			
				if(pagetoload!='' && menuforced==1){
					document.location="/"+pagetoload;
				}
				else if(firstlog == 'yeahfirst'){
					document.location=basehref+"annuaire/fiche_membre.php?annuaire_id="+firstid;
				}
				else if(pagetoload != ''){
					document.location="/"+pagetoload;
				}
				else{
					document.location=basehref+"annuaire/affichage_membre.php";
				}
			}
		}
	} 
	else{			
		if (login == ''){
			alert(tab_translation[4][langue]); /* L'email n'est pas renseigné.Veuillez recommencer s'il vous plaît */			 	
		}
		if (login != '' && mot_de_passe == ''){
			alert(tab_translation[5][langue]); /* Le mot de passe n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		}
	}
}


function modif_add(the_div_origine,the_div_modif){
	
	//document.getElementById("validation_add").style.display="none";
	document.getElementById(the_div_origine).style.display="none";
	document.getElementById(the_div_modif).style.display="block";
	return;
}

function validation_modif_add(the_id_membre,the_choix_add,etape){
	//----- Messages d'erreur
	var langue = document.getElementById("langue").value;
	tab_translation = new Array();
	tab_translation[6] = new Array();
	tab_translation[6]["fr"] = "Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[6]["en"] = "Please fill in your name.";
	//tab_test[6] = new Array("fr"=>"Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.", "en"=>"Name is blank.\nPlease try again.");
	tab_translation[7] = new Array();
	tab_translation[7]["fr"] = "Le prénom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[7]["en"] = "Please fill in your firstname.";		
	tab_translation[8] = new Array();
	tab_translation[8]["fr"] = "Le champ \"adresse\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[8]["en"] = "Please fill in your address.";
	tab_translation[9] = new Array();
	tab_translation[9]["fr"] = "Le champ \"Code postal\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[9]["en"] = "Please fill in your zipcode.";
	tab_translation[10] = new Array();
	tab_translation[10]["fr"] = "Le champ \"Ville\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[10]["en"] = "Please fill in your city.";
	tab_translation[11] = new Array();
	tab_translation[11]["fr"] = "ERREUR.";
	tab_translation[11]["en"] = "ERROR.";
	tab_translation[12] = new Array();
	tab_translation[12]["fr"] = "Merci de renseigner le champ \"Pays\".";
	tab_translation[12]["en"] = "Please fill in your country.";
	tab_translation[13] = new Array();
	tab_translation[13]["fr"] = "Merci de renseigner au moins un champ \"Téléphone\" (Utile pour la livraison).";
	tab_translation[13]["en"] = "Please fill in your phone.";
	
	//the_nom = document.getElementById("nom_"+the_choix_add).value;
	the_nom = document.getElementById("nom_add").value;
	//the_prenom = document.getElementById("prenom_"+the_choix_add).value;
	the_prenom = document.getElementById("prenom_add").value;
	the_tel_fixe = document.getElementById("tel_fixe_"+the_choix_add).value;
	the_tel_mobile = document.getElementById("tel_mobile_"+the_choix_add).value;
	the_add1 = document.getElementById("add1_"+the_choix_add).value;
	the_add2 = document.getElementById("add2_"+the_choix_add).value;
	the_add3 = document.getElementById("add3_"+the_choix_add).value;
	the_cp = document.getElementById("cp_"+the_choix_add).value;
	the_ville = document.getElementById("ville_"+the_choix_add).value;
	the_pays = document.getElementById("pays_"+the_choix_add).value;
	//the_email = document.getElementById("email_"+the_choix_add).value;
	the_email = document.getElementById("email_add").value;
	var basehref = "/offres/gestion/";
	
	if(the_nom ==''){
		alert(tab_test[6][langue]); /* Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_prenom ==''){
		alert(tab_translation[7][langue]); /* Le prénom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_add1==''){
		alert(tab_translation[8][langue]); /*Le champ "adresse" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_cp==""){
		alert(tab_translation[9][langue]); /* Le champ "Code postal" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_ville==''){
		alert(tab_translation[10][langue]); /* Le champ "Ville" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_pays=='-' || the_pays==''){
		alert(tab_translation[12][langue]); /* Le champ "Pays" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_tel_fixe=='' && the_tel_mobile==''){
		alert(tab_translation[13][langue]); /* Le champ "Tel fixe" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(email_valide(the_email)){
		//alert('the_add2 => '+the_add2);
		
		var corps="the_nom="+the_nom+"&the_prenom="+the_prenom+"&the_tel_fixe="+the_tel_fixe+"&the_tel_mobile="+the_tel_mobile+"&the_add1="+the_add1+"&the_add2="+the_add2+"&the_add3="+the_add3+"&the_cp="+the_cp+"&the_ville="+the_ville+"&the_pays="+the_pays+"&the_email="+the_email+"&the_id_membre="+the_id_membre+"&the_choix_add="+the_choix_add;
		
		//window.open(basehref+"boutique/enreg_modif_add.php?"+corps);
		p = new XMLHttpRequest();
		p.open("POST",basehref+"boutique/enreg_modif_add.php",false);
		p.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		p.send(corps);
		if (p.status != "200") {
			//span.innerHTML = "XMLHTTPREQUEST : Echec";
		}
		else {
			var docXML = p.responseXML.documentElement;
			var result = docXML.getElementsByTagName('result')[0].getAttribute('val');
				
			if (result == 'OK'){
				/*document.getElementById("etape").value=etape;
				document.getElementById("the_form_commande").submit();*/
				suite_commande(etape,'');
			}
			else{
				alert(tab_translation[11][langue]); /* ERREUR */
			}
		}
	}
}

//function suite_commande(etape,moyen_paiement){
function suite_commande(etape,paiement_choisi){
	//alert('suite_commande etape => '+etape);
	var langue = document.getElementById("langue").value;
	if(langue==""){
		langue = "fr";		
	}
	tab_translation = new Array();
	tab_translation[12] = new Array();
	tab_translation[12]["fr"] = "ERREUR.";
	tab_translation[12]["en"] = "ERROR.";
	var basehref = "/offres/gestion/";
	
	switch(etape){
		case '2':/** données de facturation -> données de livraison**/
			the_choix_add = document.getElementById("checked_add1").checked;
			if(the_choix_add===true){
				the_id = document.getElementById("id_add_1").value;
			}
			else{
				the_id = document.getElementById("id_add_2").value;
			}
			
			document.getElementById("add_facturation").value =the_id;
			document.getElementById("etape").value = 'etape_2';
			document.getElementById('the_form_commande').submit();
		break;
		
		case '3': /** données de livraison -> recap**/
			
			the_choix_add = document.getElementById("checked_add1").checked;
			if(the_choix_add===true){
				the_id = document.getElementById("id_add_1").value;
			}
			else{
				the_id = document.getElementById("id_add_2").value;
			}
			document.getElementById("add_livraison").value =the_id;
			
			document.getElementById("etape").value = 'etape_3';
			document.getElementById('the_form_commande').submit();
		break;
		
		case '4': /** recap -> paiement**/
			the_id_membre = document.getElementById("the_id_membre").value;
			add_facturation = document.getElementById("add_facturation").value;
			add_livraison = document.getElementById("add_livraison").value;
			HT_fdp = document.getElementById("HT_fdp").value;
			fdp_final = document.getElementById("fdp_final").value;
			HT_final = document.getElementById("HT_final").value; //HT_produits + HT_fdp  
			TVA_final = document.getElementById("TVA_final").value;
			total_final_TTC = document.getElementById("total_final_TTC").value;
			var mon_id_code_promo = "";
			var the_reduc_code_promo = "";
			var montant_reduc_code_promo = "";
			//var prix_final_apres_code_promo = "";
			var prix_TTC_apres_code_promo;
			var TVA_apres_code_promo;
      if(document.getElementById("mon_id_code_promo")){
        var mon_id_code_promo = document.getElementById("mon_id_code_promo").value;// table aiw_boutique.code_promo
        var mode_reduc_code_promo = document.getElementById("mode_reduc_code_promo").value;// Quel type de remise? Montant ou pourcentage
        var the_reduc_code_promo = document.getElementById("the_reduc_code_promo").value;// Montant à déduire
        var montant_a_deduire_code_promo = document.getElementById("montant_a_deduire_code_promo").value;// Montant à déduire
        var prix_HT_apres_code_promo = document.getElementById("prix_HT_apres_code_promo").value;
        var prix_TTC_apres_code_promo = document.getElementById("prix_TTC_apres_code_promo").value;
        var TVA_apres_code_promo = document.getElementById("TVA_apres_code_promo").value;
			}
			if(document.getElementById("id_zone_to_livraison")){
				id_zone_to_livraison = document.getElementById("id_zone_to_livraison").value;
			}
			else{
				id_zone_to_livraison = 1;
			}
			var new_msg_perso = "-";
			choix_paiement = 0;
			if(document.getElementById("affiche_msg_perso")){
				affiche_msg_perso = document.getElementById("affiche_msg_perso").value;
				// Il n'y a aucun produit dans la commande qui propose de mot d'accompagnement
				if(affiche_msg_perso==0){
					new_msg_perso = "";
				}	
			if(document.getElementById("new_msg_perso")){
				new_msg_perso = document.getElementById("new_msg_perso").value;
					if(new_msg_perso == "Saisissez ici un message personnalisé si vous le souhaitez (limité à 250 caractères), ou laissez ce champ vide dans le cas contraire" || new_msg_perso == "You can fill in this field to send a custom message if you want (limited to 250 characters), or let it blank"){
						new_msg_perso = "-";
					}
				}
			}
      if(the_id_membre > 0){
      var corps="the_id_membre="+the_id_membre+"&add_facturation="+add_facturation+"&add_livraison="+add_livraison+"&langue="+langue+"&new_msg_perso="+new_msg_perso+"&id_zone_to_livraison="+id_zone_to_livraison+"&paiement_choisi="+paiement_choisi+"&HT_fdp="+HT_fdp+"&fdp_final="+fdp_final+"&HT_final="+HT_final+"&TVA_final="+TVA_final+"&total_final_TTC="+total_final_TTC+"&mon_id_code_promo="+mon_id_code_promo+"&mode_reduc_code_promo="+mode_reduc_code_promo+"&the_reduc_code_promo="+the_reduc_code_promo+"&montant_a_deduire_code_promo="+montant_a_deduire_code_promo+"&prix_HT_apres_code_promo="+prix_HT_apres_code_promo+"&prix_TTC_apres_code_promo="+prix_TTC_apres_code_promo+"&TVA_apres_code_promo="+TVA_apres_code_promo;
			//window.open(basehref+"boutique/enreg_commande.php?"+corps);
			p = new XMLHttpRequest();
			p.open("POST",basehref+"boutique/enreg_commande.php",false);
			p.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			p.send(corps);
			if (p.status != "200") {
				//span.innerHTML = "XMLHTTPREQUEST : Echec";
			}
			else {
				var docXML = p.responseXML.documentElement;
				var result = docXML.getElementsByTagName('result')[0].getAttribute('val');
				var id_commande = docXML.getElementsByTagName('result')[1].getAttribute('id_commande');
				document.getElementById("the_id_commande").value=id_commande;
				document.getElementById("choix_paiement").value = paiement_choisi;
				var formu;
				//alert('result => '+result+'\nid_commande => '+id_commande);
				if (result == 'OK'){
					switch(paiement_choisi){
						case '1': //Cas PAYPAL
										//alert("paypal");
										document.getElementById("etape").value = 'etape_4';
							formu = "the_form_commande";
										break;
						case '2': //Cas PAYBOX
										//alert("paybox");
										document.getElementById("etape").value = 'etape_4';
							formu = "the_form_commande";
										break;
						case '3': //Cas ATOS
										//alert("atos");
										document.getElementById("caddie").value=document.getElementById("caddie").value + '_***_'+id_commande;
										//alert(document.getElementById("caddie").value);
										document.getElementById("choix_paiement_atos").value = '3';
							formu = "form_atos";
										break;
						case '4': //Paiement par chèque, espèces ou mandat cash
							//alert("chèque");
							document.getElementById("etape").value = 'etape_4';
							formu = "the_form_commande";
							break;
							case '5': //Cas OGONE
										//alert("ogone");
										document.getElementById("etape").value = 'etape_4';
							formu = "the_form_commande";
						break;
						default:
							break;
					}// [end switch]
					document.getElementById(formu).submit();
				}// [end result == 'OK']
				else{
					alert(tab_translation[12][langue]); // ERREUR.
				}
			}
		}// verif id_membre!=0
		else{
		  var mon_id_club = document.getElementById("club").value;
      var myhostis = "http://"+location.host;
      document.location.href = myhostis+"/authent_"+mon_id_club+".html";
    }
	}
}

function recap_modif_panier(the_host,the_id_club){
		document.getElementById("action_recap").value="recap_panier";
		document.getElementById('the_form_commande').action='http://'+the_host+'/panier_'+the_id_club+'.html';
		document.getElementById('the_form_commande').submit();
}

function crea_new_client(the_host, the_id_club){
	document.getElementById("the_form_panier_authent").action = 'http://'+the_host+'/inscription_'+the_id_club+'.html';
	document.getElementById('the_form_panier_authent').submit();
}
/* 
 * Authentification d'un nouveau client
 */
function validation_new_client(the_host,the_id_club){
	var langue = document.getElementById("langue").value;
	tab_translation = new Array();
	tab_translation[13] = new Array();
	tab_translation[13]["fr"] = "Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[13]["en"] = "Please fill in your name";
	tab_translation[14] = new Array();
	tab_translation[14]["fr"] = "Le prénom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[14]["en"] = "Please fill in your firstname";		
	tab_translation[15] = new Array();
	tab_translation[15]["fr"] = "Le champ \"adresse\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[15]["en"] = "Please fill in your address.";
	tab_translation[16] = new Array();
	tab_translation[16]["fr"] = "Le champ \"Code postal\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[16]["en"] = "Please fill in your zipcode.";
	tab_translation[17] = new Array();
	tab_translation[17]["fr"] = "Le champ \"Ville\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[17]["en"] = "Please fill in your city.";
	tab_translation[24] = new Array();
	tab_translation[24]["fr"] = "Le champ \"Pays\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[24]["en"] = "Please fill in your country.";
	tab_translation[25] = new Array();
	tab_translation[25]["fr"] = "Le champ \"Téléphone fixe\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[25]["en"] = "Please fill in your phone.";
	tab_translation[18] = new Array();
	tab_translation[18]["fr"] = "Le champ \"Mot de passe\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[18]["en"] = "Please fill in your password.";
	tab_translation[19] = new Array();
	tab_translation[19]["fr"] = "Le champ \"Confirmation\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[19]["en"] = "Please confirm your password.";
	tab_translation[20] = new Array();
	tab_translation[20]["fr"] = "Attention la confirmation n\'est pas identique au mot de passe.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[20]["en"] = "Confirmation doesn't match the password.\nPlease try again";
	tab_translation[21] = new Array();
	tab_translation[21]["fr"] = "Cet email est déjà utilisé comme identifiant pour un autre compte.";
	tab_translation[21]["en"] = "This email is already used by another account.";
	tab_translation[22] = new Array();
	tab_translation[22]["fr"] = "ERREUR.";
	tab_translation[22]["en"] = "ERROR.";
	tab_translation[23] = new Array();
	tab_translation[23]["fr"] = "Attention l'email et l'email de confirmation sont différents.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[23]["en"] = "Confirmation doesn't match the E-mail.\nPlease try again.";

	the_nom = document.getElementById("nom_new_client").value;
	the_prenom = document.getElementById("prenom_new_client").value;
	the_raison_social = document.getElementById("raison_social_new_client").value;
	the_add1 = document.getElementById("add1_new_client").value;
	the_add2 = document.getElementById("add2_new_client").value;
	the_add3 = document.getElementById("add3_new_client").value;
	the_cp = document.getElementById("cp_new_client").value;
	the_ville = document.getElementById("ville_new_client").value;
	the_pays = document.getElementById("pays_new_client").value;
	the_tel_fixe = document.getElementById("tel_fixe_new_client").value;
	the_tel_mobile = document.getElementById("tel_mobile_new_client").value;
	the_email = document.getElementById("email_new_client").value;
	the_confirm_email = document.getElementById("confirm_email_new_client").value;	
	the_mdp = document.getElementById("mdp_new_client").value;
	the_confirm_mdp = document.getElementById("confim_mdp_new_client").value;
	
	var basehref = "/offres/gestion/";
	
	if(the_nom ==''){
		alert(tab_translation[13][langue]); //Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_prenom ==''){
		alert(tab_translation[14][langue]); //Le prénom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_add1==''){
		alert(tab_translation[15][langue]); //Le champ "adresse" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_cp==""){
		alert(tab_translation[16][langue]); //Le champ "Code postal" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_ville==''){
		alert(tab_translation[17][langue]);//Le champ "Ville" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_pays=='-' || the_pays==''){
		alert(tab_translation[24][langue]);//Le champ "Pays" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_tel_fixe==''){
		alert(tab_translation[25][langue]);//Le champ "Tel fixe" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(email_valide(the_email)){
		if(the_email!=the_confirm_email){
			alert(tab_translation[23][langue]); //Attention l'email et l'email de confirmation sont différents.\nVeuillez recommencer s\'il vous plaît.
		}
		if(the_mdp==''){
			alert(tab_translation[18][langue]); //Le champ "Mot de passe" n'est pas renseigné.\nVeuillez recommencer s'il vous plaît.
		}
		else if(the_confirm_mdp==''){
			alert(tab_translation[19][langue]); //Le champ "Confirmation" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
		}
		else if(the_mdp!=the_confirm_mdp){
			alert(tab_translation[20][langue]); //Attention la confirmation n\'est pas identique au mot de passe.\nVeuillez recommencer s\'il vous plaît.
		}
		else{
			var corps="the_nom="+the_nom+"&the_prenom="+the_prenom+"&the_tel_fixe="+the_tel_fixe+"&the_tel_mobile="+the_tel_mobile+"&the_add1="+the_add1+"&the_add2="+the_add2+"&the_add3="+the_add3+"&the_cp="+the_cp+"&the_ville="+the_ville+"&the_pays="+the_pays+"&the_email="+the_email+"&the_mdp="+the_mdp+"&the_id_club="+the_id_club+"&the_raison_social="+the_raison_social;
			//window.open(basehref+"boutique/enreg_new_client.php?"+corps);
			p = new XMLHttpRequest();
			p.open("POST",basehref+"boutique/enreg_new_client.php",false);
			p.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			p.send(corps);
			if (p.status != "200") {
				//span.innerHTML = "XMLHTTPREQUEST : Echec";
			}
			else {
				var docXML = p.responseXML.documentElement;
				var result = docXML.getElementsByTagName('result')[0].getAttribute('val');
				var id_membre = docXML.getElementsByTagName('result')[1].getAttribute('id_membre');
					
				if(result=='OKI'){
					document.getElementById("the_form_new_client").action='http://'+the_host+'/commande_'+the_id_club+'.html';
					document.getElementById("the_form_new_client").submit();
				}
				else if(result=='EXISTE'){
					alert(tab_translation[21][langue]); //Cet email est déjà utilisé comme identifiant pour un autre compte.
				}
				else{
					alert(tab_translation[22][langue]); //ERREUR.
				}
			}
		}
	}
}
/*
 * Nouveau client (sans compte)
 * ==> Fonction appelée via nouveau_client.php
 */
function validation_new_client_sans_compte(the_host,the_id_club){
	var langue = document.getElementById("langue").value;
	tab_translation = new Array();
	tab_translation[13] = new Array();
	tab_translation[13]["fr"] = "Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[13]["en"] = "Please fill in your name";
	tab_translation[14] = new Array();
	tab_translation[14]["fr"] = "Le prénom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[14]["en"] = "Please fill in your firstname";		
	tab_translation[15] = new Array();
	tab_translation[15]["fr"] = "Le champ \"adresse\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[15]["en"] = "Please fill in your address.";
	tab_translation[16] = new Array();
	tab_translation[16]["fr"] = "Le champ \"Code postal\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[16]["en"] = "Please fill in your zipcode.";
	tab_translation[17] = new Array();
	tab_translation[17]["fr"] = "Le champ \"Ville\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[17]["en"] = "Please fill in your city.";
	tab_translation[24] = new Array();
	tab_translation[24]["fr"] = "Le champ \"Pays\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[24]["en"] = "Please fill in your country.";
	tab_translation[25] = new Array();
	tab_translation[25]["fr"] = "Le champ \"Téléphone fixe\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[25]["en"] = "Please fill in your phone.";
	tab_translation[18] = new Array();
	tab_translation[18]["fr"] = "Le champ \"Mot de passe\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[18]["en"] = "Please fill in your password.";
	tab_translation[19] = new Array();
	tab_translation[19]["fr"] = "Le champ \"Confirmation\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[19]["en"] = "Please confirm your password.";
	tab_translation[20] = new Array();
	tab_translation[20]["fr"] = "Attention la confirmation n\'est pas identique au mot de passe.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[20]["en"] = "Confirmation doesn't match the password.\nPlease try again";
	tab_translation[21] = new Array();
	tab_translation[21]["fr"] = "Cet email est déjà utilisé comme identifiant pour un autre compte.";
	tab_translation[21]["en"] = "This email is already used by another account.";
	tab_translation[22] = new Array();
	tab_translation[22]["fr"] = "ERREUR.";
	tab_translation[22]["en"] = "ERROR.";
	tab_translation[23] = new Array();
	tab_translation[23]["fr"] = "Attention l'email et l'email de confirmation sont différents.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[23]["en"] = "Confirmation doesn't match the E-mail.\nPlease try again.";

	the_nom = document.getElementById("nom_new_client").value;
	the_prenom = document.getElementById("prenom_new_client").value;
	the_raison_social = document.getElementById("raison_social_new_client").value;
	the_add1 = document.getElementById("add1_new_client").value;
	the_add2 = document.getElementById("add2_new_client").value;
	the_add3 = document.getElementById("add3_new_client").value;
	the_cp = document.getElementById("cp_new_client").value;
	the_ville = document.getElementById("ville_new_client").value;
	the_pays = document.getElementById("pays_new_client").value;
	the_tel_fixe = document.getElementById("tel_fixe_new_client").value;
	the_tel_mobile = document.getElementById("tel_mobile_new_client").value;
	the_email = document.getElementById("email_new_client").value;
	the_confirm_email = document.getElementById("confirm_email_new_client").value;	
	/*the_mdp = document.getElementById("mdp_new_client").value;
	the_confirm_mdp = document.getElementById("confim_mdp_new_client").value;*/
	
	the_test_modif = document.getElementById("the_modif_validation").value;	
	the_id_membre = document.getElementById("id_membre").value;	
	
	var basehref = "/offres/gestion/";
	
	if(the_nom ==''){
		alert(tab_translation[13][langue]); //Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_prenom ==''){
		alert(tab_translation[14][langue]); //Le prénom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_add1==''){
		alert(tab_translation[15][langue]); //Le champ "adresse" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_cp==""){
		alert(tab_translation[16][langue]); //Le champ "Code postal" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_ville==''){
		alert(tab_translation[17][langue]);//Le champ "Ville" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_pays=='-' || the_pays==''){
		alert(tab_translation[24][langue]);//Le champ "Pays" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(the_tel_fixe==''){
		alert(tab_translation[25][langue]);//Le champ "Tel fixe" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
	}
	else if(email_valide(the_email)){
		if(the_email!=the_confirm_email){
			alert(tab_translation[23][langue]); //Attention l'email et l'email de confirmation sont différents.\nVeuillez recommencer s\'il vous plaît.
		}
		/*if(the_mdp==''){
			alert(tab_translation[18][langue]); //Le champ "Mot de passe" n'est pas renseigné.\nVeuillez recommencer s'il vous plaît.
		}
		else if(the_confirm_mdp==''){
			alert(tab_translation[19][langue]); //Le champ "Confirmation" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.
		}
		else if(the_mdp!=the_confirm_mdp){
			alert(tab_translation[20][langue]); //Attention la confirmation n\'est pas identique au mot de passe.\nVeuillez recommencer s\'il vous plaît.
		}*/
		var corps="the_nom="+the_nom+"&the_prenom="+the_prenom+"&the_tel_fixe="+the_tel_fixe+"&the_tel_mobile="+the_tel_mobile+"&the_add1="+the_add1+"&the_add2="+the_add2+"&the_add3="+the_add3+"&the_cp="+the_cp+"&the_ville="+the_ville+"&the_pays="+the_pays+"&the_email="+the_email+"&the_id_club="+the_id_club+"&sans_compte=OK&the_raison_social="+the_raison_social+"&the_test_modif="+the_test_modif+"&the_id_membre="+the_id_membre;
		
		//window.open(basehref+"boutique/enreg_new_client.php?"+corps);
		p = new XMLHttpRequest();
		p.open("POST",basehref+"boutique/enreg_new_client.php",false);
		p.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		p.send(corps);
		if (p.status != "200") {
			//span.innerHTML = "XMLHTTPREQUEST : Echec";
		}
		else {
			var docXML = p.responseXML.documentElement;
			var result = docXML.getElementsByTagName('result')[0].getAttribute('val');
			var id_membre = docXML.getElementsByTagName('result')[1].getAttribute('id_membre');
				
			if(result=='OKI'){
				document.getElementById("the_form_new_client").action='http://'+the_host+'/commande_'+the_id_club+'.html';
				document.getElementById("the_form_new_client").submit();
			}
			else if(result=='EXISTE'){
				alert(tab_translation[21][langue]); //Cet email est déjà utilisé comme identifiant pour un autre compte.
			}
			else{
				alert(tab_translation[22][langue]); //ERREUR.
			}
		}
	}
}

function retour_commande(the_etape){
	document.getElementById("etape").value = the_etape;
	document.getElementById('the_form_commande').submit();
}

function retour_commande_sans_compte(the_host,the_id_club){
	document.getElementById('the_form_commande').action = 'http://'+the_host+'/inscription_'+the_id_club+'.html';
	document.getElementById('the_form_commande').submit();
}

function retour_commande_modif_panier(the_host, the_id_club){
	document.getElementById("etape").value = "etape_3";
	document.getElementById('the_form_panier').action='http://'+the_host+'/commande_'+the_id_club+'.html';
	document.getElementById('the_form_panier').submit();
}

function retour_boutique_modif_panier(the_host, the_id_club){
	
	//document.getElementById('the_form_panier').action='http://'+the_host+'/shop_'+the_id_club+'-0-0-0/boutique.html';
	document.getElementById('the_form_panier').action='http://'+the_host;
	document.getElementById('the_form_panier').submit();
}

function change_add(the_add){
	
	if(the_add==1){
		document.getElementById("add_1_bouton").style.display="block";
		document.getElementById("add_2_bouton").style.display="none";
	}
	else{
		document.getElementById("add_1_bouton").style.display="none";
		document.getElementById("add_2_bouton").style.display="block";
	}	
	return;
}

function validation_modif_client_sans_compte(the_host, id_club, the_id_membre){
	//----- Messages d'erreur
	var langue = document.getElementById("langue").value;
	tab_translation = new Array();
	tab_translation[6] = new Array();
	tab_translation[6]["fr"] = "Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[6]["en"] = "Please fill in your name.";
	//tab_test[6] = new Array("fr"=>"Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.", "en"=>"Name is blank.\nPlease try again.");
	tab_translation[7] = new Array();
	tab_translation[7]["fr"] = "Le prénom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[7]["en"] = "Please fill in your firstname.";		
	tab_translation[8] = new Array();
	tab_translation[8]["fr"] = "Le champ \"adresse\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[8]["en"] = "Please fill in your address.";
	tab_translation[9] = new Array();
	tab_translation[9]["fr"] = "Le champ \"Code postal\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[9]["en"] = "Please fill in your zipcode.";
	tab_translation[10] = new Array();
	tab_translation[10]["fr"] = "Le champ \"Ville\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[10]["en"] = "Please fill in your city.";
	tab_translation[11] = new Array();
	tab_translation[11]["fr"] = "Le champ \"Pays\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[11]["en"] = "Please fill in your country.";
  tab_translation[13] = new Array();
	tab_translation[13]["fr"] = "Le champ \"Téléphone fixe\" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît.";
	tab_translation[13]["en"] = "Please fill in your phone.";
	tab_translation[12] = new Array();
	tab_translation[12]["fr"] = "ERREUR.";
	tab_translation[12]["en"] = "ERROR.";
	
	the_nom = document.getElementById("nom_new_client").value;
	the_prenom = document.getElementById("prenom_new_client").value;
	the_raison_social = document.getElementById("raison_social_new_client").value;
	the_add1 = document.getElementById("add1_new_client").value;
	the_add2 = document.getElementById("add2_new_client").value;
	the_add3 = document.getElementById("add3_new_client").value;
	the_cp = document.getElementById("cp_new_client").value;
	the_ville = document.getElementById("ville_new_client").value;
	the_pays = document.getElementById("pays_new_client").value;
	the_tel_fixe = document.getElementById("tel_fixe_new_client").value;
	the_tel_mobile = document.getElementById("tel_mobile_new_client").value;
	the_email = document.getElementById("email_new_client").value;
	the_confirm_email = document.getElementById("confirm_email_new_client").value;
		
	var basehref = "/offres/gestion/";
	
	if(the_nom ==''){
		alert(tab_test[6][langue]); /* Le nom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_prenom ==''){
		alert(tab_translation[7][langue]); /* Le prénom n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_add1==''){
		alert(tab_translation[8][langue]); /*Le champ "adresse" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_cp==""){
		alert(tab_translation[9][langue]); /* Le champ "Code postal" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_ville==''){
		alert(tab_translation[10][langue]); /* Le champ "Ville" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_pays=='-' || the_pays==''){
		alert(tab_translation[11][langue]); /* Le champ "Pays" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(the_tel_fixe==''){
		alert(tab_translation[13][langue]); /* Le champ "Tel fixe" n\'est pas renseigné.\nVeuillez recommencer s\'il vous plaît. */
		return;
	}
	else if(email_valide(the_email)){
		//alert('the_add2 => '+the_add2);
		
		var corps="the_nom="+the_nom+"&the_prenom="+the_prenom+"&the_tel_fixe="+the_tel_fixe+"&the_tel_mobile="+the_tel_mobile+"&the_add1="+the_add1+"&the_add2="+the_add2+"&the_add3="+the_add3+"&the_cp="+the_cp+"&the_ville="+the_ville+"&the_email="+the_email+"&the_id_membre="+the_id_membre+"&the_choix_add="+the_choix_add;
		
		//window.open(basehref+"boutique/enreg_modif_add.php?"+corps);
		p = new XMLHttpRequest();
		p.open("POST",basehref+"boutique/enreg_modif_add.php",false);
		p.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		p.send(corps);
		if (p.status != "200") {
			//span.innerHTML = "XMLHTTPREQUEST : Echec";
		}
		else {
			var docXML = p.responseXML.documentElement;
			var result = docXML.getElementsByTagName('result')[0].getAttribute('val');
				
			if (result == 'OK'){
				/*document.getElementById("etape").value=etape;
				document.getElementById("the_form_commande").submit();*/
				suite_commande(etape,'');
			}
			else{
				alert(tab_translation[12][langue]); /* ERREUR */
			}
		}
	}
}


/******************************************************/
/*****************   ADMIN BOUTIQUE   *****************/
/******************************************************/

function modif_mail_admin_boutique(){
	document.getElementById("read_email").style.display="none";
	document.getElementById("write_email").style.display="block";
	return;
	
}
function check_mail_admin_boutique(email_crea_value){
		var langue = document.getElementById("langue").value;
		tab_translation = new Array();
		tab_translation[14] = new Array();
		tab_translation[14]["fr"] = "Vous devez saisir un email.";
		tab_translation[14]["en"] = "Email compulsory";
		the_email = document.getElementById("email_boutique").value;
		
		if(the_email==""){
			alert(tab_translation[14][langue]); //Vous devez saisir un email.
			return;
		}
		else{			
			document.getElementById('email_crea').value=email_crea_value;
			document.getElementById("form_email_boutique").submit();
		}	
}

function modif_type_action_admin_boutique(){
		var langue = document.getElementById("langue").value;
		tab_translation = new Array();
		tab_translation[15] = new Array();
		tab_translation[15]["fr"] = "Vous devez choisir un type d'action.";
		tab_translation[15]["en"] = "Vous devez choisir un type d'action.";
		type_action = document.getElementById("action_type").value;
		
		if(type_action==""){
			alert(tab_translation[15][langue]); //Vous devez choisir un type d'action
			return;
		}
		else{			
			document.getElementById("form_type_action_boutique").submit();
		}	
}

/**
 * Fonction qui permet de gerer l'utilisation des sous-references
 */ 
function modif_gestion_admin_sous_ref(){
  var etat_oui = document.getElementById('gestion_sous_ref_yes').checked;
  var etat_non = document.getElementById('gestion_sous_ref_no').checked;
  if(etat_oui==true){
   	document.getElementById('gestion_sous_ref_yes').value = "1";
   	document.getElementById('gestion_sous_ref_no').value = 0;
   	document.getElementById('test').value = "activer_sous_ref";
  }
  else if(etat_non==true){
   	document.getElementById('gestion_sous_ref_yes').value = 0;
   	document.getElementById('gestion_sous_ref_no').value = "1";
   	document.getElementById('test').value = "desactiver_sous_ref";
  }
  document.getElementById("form_gestion_admin_sous_ref").submit();
  return false;   
}
/**
 * Fonction qui permet de gerer l'utilisation des frais de port
 */ 
function modif_gestion_admin_fdp(){
  var etat_fdp_oui = document.getElementById('gestion_fdp_yes').checked;
  var etat_fdp_non = document.getElementById('gestion_fdp_no').checked;
  if(etat_fdp_oui==true){
   	document.getElementById('gestion_fdp_yes').value = "1";
   	document.getElementById('gestion_fdp_no').value = 0;
   	document.getElementById('tmp_fdp').value = "activer_fdp";
  }
  else if(etat_fdp_non==true){
   	document.getElementById('gestion_fdp_yes').value = 0;
   	document.getElementById('gestion_fdp_no').value = "1";
   	document.getElementById('tmp_fdp').value = "desactiver_fdp";
  }
  document.getElementById("form_frais_de_port").submit();
  return false;   
}
/**
 * Fonction qui permet de gerer le lien de rétractation de la commande
 */ 
function modif_retractation_commande(){
  var etat_oui = document.getElementById('retractation_commande_yes').checked;
  var etat_non = document.getElementById('retractation_commande_no').checked;
  if(etat_oui==true){
   	document.getElementById('retractation_commande_yes').value = "1";
   	document.getElementById('retractation_commande_no').value = 0;
   	document.getElementById('activation_retractation_commande').value = 1;
  }
  else if(etat_non==true){
   	document.getElementById('retractation_commande_yes').value = 0;
   	document.getElementById('retractation_commande_no').value = "1";
   	document.getElementById('activation_retractation_commande').value = 0;
  }
  document.getElementById("form_retractation_boutique").submit();
  return;   
}
/*-----------------------------------------------------------------------
/* Fonction qui permet de réinitialiser les tailles des miniatures
/* On les recupere dans la table gestion_taille_miniatures avec id_club=0
/* ---------------------------------------------------------------------*/
function reinit_size_miniatures(){
  document.getElementById('do_it').value = "reinit_size_miniatures";
  document.getElementById('form_boutique').submit();
}

/*-----------------------------------------------------------------------------------------------
/* Fonction qui permet de vider les champs au moment du clic
/* ---------------------------------------------------------------------------------------------*/
function emptyInputs(idInput){
  if('newLimitePoidsFdp' == idInput && document.getElementById('newLimitePoidsFdp').value == '-- Poids en Kg--'){
    document.getElementById('newLimitePoidsFdp').value = "";
    newLimitePoidsFdp = true;
  }
  else if('newTarifFdp' == idInput && document.getElementById('newTarifFdp').value == '-- Tarif en € --'){
    document.getElementById('newTarifFdp').value = "";
    newTarifFdp = true;
  }
  else if('newGrilleFdp' == idInput && document.getElementById('newGrilleFdp').value == '-- Nouvelle grille --'){
  	document.getElementById('newGrilleFdp').value = "";
  }
  else if('newLimiteMontantFdp' == idInput && document.getElementById('newLimiteMontantFdp').value == '-- Montant en € --'){
  	 document.getElementById('newLimiteMontantFdp').value = "";
   	 newLimiteMontantFdp = true;
  	}
  else if('newTarifFdpMontant' == idInput && document.getElementById('newTarifFdpMontant').value == '-- Tarif en € --'){
		document.getElementById('newTarifFdpMontant').value = "";
		newTarifFdpMontant = true;
  }
  else if('newFournisseur' == idInput && document.getElementById('newFournisseur').value == '-- Nouveau --') {
		document.getElementById('newFournisseur').value = "";
		newFournisseur = 1;
	}
	else if('newMarque' == idInput && document.getElementById('newMarque').value == '-- Nouveau --'){
		document.getElementById('newMarque').value = "";
		newMarque = 1;
	}
  else if('libelle_code_promo' == idInput && document.getElementById('libelle_code_promo').value == '-- Description du code promo --'){
    document.getElementById('libelle_code_promo').value = "";
    libelle_code_promo = true;
  }
  else if('code_promo' == idInput && document.getElementById('code_promo').value == '-- Saisir le code promo --'){
    document.getElementById('code_promo').value = "";
    code_promo = true;
  }
  else if('limite_max_code_promo' == idInput && document.getElementById('limite_max_code_promo').value == '-- Saisir le nombre d\'utilisation maximum --'){
    document.getElementById('limite_max_code_promo').value = "";
    limite_max_code_promo = true;
  }
  else if('montant_reduc_code_promo' == idInput && document.getElementById('montant_reduc_code_promo').value == '-- Saisir le montant de la réduction --'){
    document.getElementById('montant_reduc_code_promo').value = "";
    montant_reduc_code_promo = true;
  }
  else if('montant_min_panier' == idInput && document.getElementById('montant_min_panier').value == '-- Pour bénéficier de la réduction --'){
    document.getElementById('montant_min_panier').value = "";
  }
  else
  	return;
}
/*-----------------------------------------------------------------------------------------------
/* Fonction qui permet de vider le champ message perso au moment du clic
/* ---------------------------------------------------------------------------------------------*/
function emptyInputsMsgPerso(idInput){
	if(idInput == 'new_msg_perso'){
	  	if(document.getElementById('langue').value == "fr"){
	  		if(document.getElementById('new_msg_perso').value == 'Saisissez ici un message personnalisé si vous le souhaitez (limité à 250 caractères), ou laissez ce champ vide dans le cas contraire'){
	  			document.getElementById('new_msg_perso').value = "";
	  		}
	  	}
	  	else if(document.getElementById('langue').value == "en"){
	  		if(document.getElementById('new_msg_perso').value == 'You can fill in this field to send a custom message if you want (limited to 250 characters), or let it blank'){
	  			document.getElementById('new_msg_perso').value = "";	
	  		}
	  	}
  	}
}
/*---------------------------------------------------------------------
 * Administration des frais de port
 *---------------------------------------------------------------------*/ 
function beforeSubmitFdp(type_action_param){
  	var verif_saisie_champ;
	var cplt_todo;
	if(type_action_param=='fdp_poids'){ 
    	ma_newLimite = "newLimitePoidsFdp";
    	mon_prix = "newTarifFdp";
    	verif_saisie_champ = "-- Poids en Kg--";
    	cplt_todo = "poids";
	}
	else if(type_action_param=='fdp_montant'){
		ma_newLimite = "newLimiteMontantFdp";
		mon_prix = "newTarifFdpMontant";
		verif_saisie_champ = "-- Montant en € --";
		cplt_todo = "montant";
	}
    var newLimite = document.getElementById(ma_newLimite).value;
    var newTarifFdp = document.getElementById(mon_prix).value;
    var etat_coche_une_grille = document.getElementById('fdp_poids_offert_one').checked;
	if(etat_coche_une_grille == true){
		document.getElementById('etat_coche_une_grille').value = 1;
	}
	else{
		document.getElementById('etat_coche_une_grille').value = 0;
	}
    if((newLimite !="" && newLimite != verif_saisie_champ) && (newTarifFdp !="" && newTarifFdp != "-- Tarif en € --")){
    //On renvoie la valeur 'addFdp' à $action (dans option_form.php)
		document.getElementById('todo').value  = 'addFdp|'+cplt_todo;
    }
    else{
		document.getElementById('todo').value  = 'modifFdp|'+cplt_todo;
  }
  document.getElementById('form_frais_de_port').submit();
}
/**
 * Suppression d'une ligne frais de port
 */  
function deleteFdp(id_fdp,limite_poids_max,option){
	if(confirm('Etes-vous sûr de vouloir supprimer cette ligne ?')){
	  	document.getElementById('limite_poids_maxToDelete').value = limite_poids_max;
  		document.getElementById('fdpToDelete').value = id_fdp;
  		document.getElementById('todo').value='deletefdp|'+option;
  		document.getElementById('form_frais_de_port').submit();
	}
}
/**
 * Modifier le frais de port par défaut des frais de livraison
 */  
function modif_tva_fdp(){
  maliste = document.getElementById("choix_tva_fdp");
  indexselected = maliste.selectedIndex;
  valtva = maliste.options[indexselected].value;
  document.getElementById('tmp_tva_fdp').value = "modif_tva_fdp";
  document.getElementById('new_montant_tva_fdp').value = valtva;
  document.getElementById('form_frais_de_port').submit();
}
/**
 * Modifier la tarification des frais de port (par poids, montant)
 */ 
function modif_tarification(){
	maliste = document.getElementById("type_tarification");
  	indexselected = maliste.selectedIndex;
	valtva = maliste.options[indexselected].value;
	/*alert("modif_tarification_fdp ");
	alert("valtva : "+valtva);*/
	document.getElementById('todo').value = "modif_tarification_fdp";
	document.getElementById('tarification_fdp').value = valtva;
	document.getElementById('form_frais_de_port').submit();
}
/**
 * Fonction qui permet de gerer la création d'un compte pour une commande
 */ 
function modif_gestion_compte_inscription(){
  var etat_oui = document.getElementById('gestion_compte_inscription_yes').checked;
  var etat_non = document.getElementById('gestion_compte_inscription_no').checked;
  //alert('etat_oui => '+etat_oui+'\netat_non=>'+etat_non);
  if(etat_oui==true){
   	document.getElementById('test_inscription').value = "OK";
  }
  else if(etat_non==true){
	document.getElementById('test_inscription').value = "NO_OK";
  }
  document.getElementById("form_gestion_compte_inscription").submit();
  return false;   
}
/**
 * Fonction qui permet de gerer la création d'un compte pour une commande
 */ 
function modif_gestion_code_promo(){
  var etat_oui = document.getElementById('gestion_code_promo_yes').checked;
  var etat_non = document.getElementById('gestion_code_promo_no').checked;
  if(etat_oui==true){
   	document.getElementById('activation_code_promo').value = "ok";
  }
  else if(etat_non==true){
	 document.getElementById('activation_code_promo').value = "ko";
  }
  document.getElementById("form_code_promo").submit();
  return false;   
}
/***************************************************************/
/*					Frais de port offerts 						/ 
/***************************************************************/
/**
 * ==> Enregistrer
 * Fonction qui permet d'activer / désactiver les frais de port offerts
 */
function valider_fdp_offert(){
	var etat_coche = document.getElementById('fdp_offert').checked;
	if(etat_coche == true){
		document.getElementById('gestion_fdp_offert').value = "activer_fdp_offert";
	}
	else{
		document.getElementById('gestion_fdp_offert').value = "desactiver_fdp_offert";
	}
	/*if(document.getElementById('type_tarification')){
		document.getElementById('tarification_fdp').value = document.getElementById('type_tarification').value;	
	}*/
	document.getElementById('todo').value = "valider_fdp_offert";
	document.getElementById('form_frais_de_port').submit();
	return false;
}
/**
 * Afficher / masquer le montant à partir duquel les frais de port sont offerts
 */
function show_montant_fdp_offert(type_grille){
	// Frais de port gratuits valables pour toutes les grilles de tarif qui n'ont pas de frais de port offert spécifique activé
	if(type_grille=="all"){
		var etat_coche = document.getElementById('fdp_offert').checked;
		if(etat_coche==0){
			type_display='hidden';
			document.getElementById('gestion_fdp_offert').value = "desactiver_fdp_offert";
		}
		else{
			type_display='visible';
			document.getElementById('gestion_fdp_offert').value = "activer_fdp_offert";
		}
	   	if(document.getElementById('fdp_offert_active')){
		   	document.getElementById('fdp_offert_active').style.visibility=type_display;
	   	}
	}
	// Frais de port spécifique pour une grille
	else if(type_grille=="poids_one"){
		var etat_coche_une_grille = document.getElementById('fdp_poids_offert_one').checked;
		//alert("etat_coche_une_grille : "+etat_coche_une_grille);
		if(etat_coche_une_grille==0){
			type_display='hidden';
			document.getElementById('gestion_fdp_offert_one').value = "desactiver_fdp_offert_one";
		}
		else{
			type_display='visible';
			document.getElementById('gestion_fdp_offert_one').value = "activer_fdp_offert_one";
		}
		if(document.getElementById('fdp_offert_one_active')){
		   	document.getElementById('fdp_offert_one_active').style.visibility=type_display;
	   	}
	}
   	document.getElementById('todo').value = "valider_fdp_offert";
   //document.getElementById('form_frais_de_port').submit();
   return 1;
}
/***************************************************************/
/*					Grilles des frais de port 					/ 
/***************************************************************/
function isThereNewGrilleFdp(id_grille_select){
	// On sélectionne une grille tarifaire
	if(id_grille_select != 0){
	   	document.getElementById('id_grille_to_view').value = id_grille_select;
	   	document.getElementById('todo').value  = 'affichage_grille';
	   	document.getElementById('newGrilleFdp').style.visibility = "hidden";
		document.getElementById('addGrilleFdp').style.visibility = "hidden";
		document.getElementById('cancelGrilleFdp').style.visibility = "hidden";
		//document.getElementById('grille_fdp_selon_id_choix_facturation_masque').style.display = "block";
	   	document.getElementById("form_frais_de_port").submit();
	}
	// On sélectionne Nouveau pour créer une grille
	else if(id_grille_select == 0){
		document.getElementById('newGrilleFdp').style.visibility = "visible";
		document.getElementById('addGrilleFdp').style.visibility = "visible";
		document.getElementById('cancelGrilleFdp').style.visibility = "visible";
		if(document.getElementById('delete_grille_affiche')){
			document.getElementById('delete_grille_affiche').style.visibility = "hidden";
		}
		//document.getElementById('grille_fdp_selon_id_choix_facturation_masque').style.display = "none"; 
	}
  return 1;   
}
/*------------------------------------------------------------------
/* Fonction qui associe une zone avec grille de tarif
/* -----------------------------------------------------------------*/
function set_lien_zone_grille(id_zone,id_grille,id_type_tarification){
	//console.log("id_zone : "+id_zone+ ", id_grille : "+id_grille+",id_type_tarification : "+id_type_tarification);
	document.getElementById('id_zone_a_associer').value  = id_zone;
	document.getElementById('id_grille_a_associer').value  = id_grille;
	document.getElementById('id_type_tarification').value  = id_type_tarification;
	document.getElementById('todo').value = 'set_lien_zone_grille';
	document.getElementById('form_frais_de_port').submit();
	return 1;
}
/*------------------------------------------------------------------
/* Fonction qui supprime les espaces
/* -----------------------------------------------------------------*/
function trim(string){
  return string.replace(/^\s+/g,'').replace(/\s+$/g,'');
}
/*------------------------------------------------------------------
/* Fonction qui permet de créer un nouveau type de publication, avec test pour vérifier son existence
/* -----------------------------------------------------------------*/
function addNouvelleGrilleFdp(nomNouvelleGrilleFdp){
  //console.log("nomNouvelleGrilleFdp : "+nomNouvelleGrilleFdp);
  //On supprime les espaces
  nomNouvelleGrilleFdp = trim(nomNouvelleGrilleFdp.toLowerCase());
  //On vérifie que le libellé de la grille soit saisi
	if(nomNouvelleGrilleFdp == "-- Nouvelle grille --" || nomNouvelleGrilleFdp == ""){
		alert('Saisissez l\'intitul&eacute; de la grille tarifaire.');
	}
	else{
		var limit =  document.getElementById('grille_fdp').length; //Nombre de grilles : récupéré à partir de la liste déroulante select id="grille_fdp"
		//console.log(limit);
    	for(var index=1;index < limit;++index){
	  		lib_G = document.getElementById('grille_fdp').options[index].innerHTML;
	      	lib_G = trim(lib_G.toLowerCase());
      		//console.log('lib_G de la liste deroulante:'+lib_G);
      		//new_G : recupere nouveau nom+prénom des champs de saisie
			new_G  = nomNouvelleGrilleFdp;
			new_G = new_G.toLowerCase();
      		//console.log('new_TP ds les champs d\'ajout:'+new_TP);
  			//console.log('\n');
      		if(lib_G == new_G){
        		continuer = 0;
        		alert('Cette grille existe déjà!');
  		  		return;
      		}
    	}
    	document.getElementById('todo').value = 'add_grille_tarifaire';
	  	document.getElementById('form_frais_de_port').submit();
	}
}
/*------------------------------------------------------------------
/* Fonction qui permet d'annuler
/* -----------------------------------------------------------------*/
function fermerPanel(quoi){
  //document.getElementById('ajout_ou_modif').style.display='none';
  if(quoi == 'addGrille'){
  	document.getElementById('newGrilleFdp').style.display='none';
  	document.getElementById('addGrilleFdp').style.display='none';
  	document.getElementById('cancelGrilleFdp').style.display='none';
  }
  scrollTo(0,0);
}
/*------------------------------------------------------------------
/* Fonction qui permet de supprimer une grille
/* -----------------------------------------------------------------*/
function deleteGrille(){
	if(!confirm('Êtes-vous certain de vouloir supprimer cette grille ?')){
		return;
	}
	maliste = document.getElementById("grille_fdp");
  	indexselected = maliste.selectedIndex;
	idgrilletodelete = maliste.options[indexselected].value;
	document.getElementById('todo').value = "delete_grille";
	document.getElementById('id_grille').value = idgrilletodelete;
	document.getElementById('form_frais_de_port').submit();
	return 1;	
}
/*------------------------------------------------------------------
/* Fonction qui permet d'enregistrer un pour chaque mode de paiement activé
/* -----------------------------------------------------------------*/
function enregistrer_msg_type_paiement(quoi){
	document.getElementById('todo').value = quoi;
	document.getElementById('form_gestion_paiements_actifs').submit();
}
/*------------------------------------------------------------------
/* Message personnalisé
/* Fonction qui permet de limiter le nombre de caractères
/* -----------------------------------------------------------------*/
function limite(textarea, max)
{
    if(textarea.value.length >= max)
    {
        textarea.value = textarea.value.substring(0,max);
    }
    var reste = max - textarea.value.length;
    var affichage_reste =  reste +" caractères restants";
    document.getElementById('max_msg').innerHTML = affichage_reste;
}
/*------------------------------------------------------------------
/* Fonction qui permet d'exporter les catalogue de produits (catalogue / famille / produits)
/* -----------------------------------------------------------------*/
function export_boutique(){
	theform = document.getElementById("form_export_boutique");
	thecheck = document.getElementById("filtreexportdate");
	var dat_deb=document.getElementById('date_debut_export').value;
	var dat_fin=document.getElementById('date_fin_export').value;
	
	if(thecheck.checked==true){
		if(dat_deb==""){
			alert('Vous n\'avez pas saisi de date de début d\'export');
			document.getElementById("date_debut_export").focus();
			return;	
		}
		if(dat_fin==""){
			alert('Vous n\'avez pas saisi de date de fin d\'export');
			document.getElementById("date_fin_export").focus();
			return;	
		}
		if(comparer_2dates(dat_deb,dat_fin) == false ){
			alert("La  date de début doît être inférieure à la date de fin ") ;
			document.getElementById("date_debut_export").focus();
			return;	
		}
	}
	document.getElementById("exportit").value="gogo";
	theform.submit();
}
/*------------------------------------------------------------------
/* Fonction qui permet de paramétrer les fournisseurs et marques de la boutique
/* -----------------------------------------------------------------*/
function beforeSubmit(type_action_param){
	if(type_action_param=='fournisseur'){
		//On regarde si ce fournisseur existe déjà, on utilise une regex
    	if((document.getElementById('newFournisseur').value != "") && (document.getElementById('newFournisseur').value != "-- Nouveau --")){
			var nomNouveauFournisseur = document.getElementById('newFournisseur').value;
			var reg = '^'+nomNouveauFournisseur+'$';
			var drapeau = 'i';
			var regex = new RegExp(reg,drapeau);
			var continuer = 1;
			var monTab = new Array;
			var nbF = document.getElementById('nbFModifiables').value;
			for(var i = 1;i < nbF;i++){
				monTab[i] = document.getElementById('tabf_'+i).value;
			}
      		//on compare les caracteres	
			/*for(i=0;i < monTab.length;i++){
				if(regex.exec(document.getElementById(monTab[i]).value) != null){
					continuer = 0;
					break;
				}
			}*/
			if(continuer == 0){
				alert('Ce fournisseur existe déjà!');
				return ;
			}
			//On renvoie la valeur 'addFournisseur' à $todo (dans fournisseurs.php)
      		document.getElementById('todo').value  = 'addFournisseur';
		}
		else{
			document.getElementById('todo').value  = 'modifFournisseur';
		}
	}
	if(type_action_param=='marque'){
		//On regarde si cette marque existe déjà, on utilise une regex
    	if((document.getElementById('newMarque').value != "") && (document.getElementById('newMarque').value != "-- Nouveau --")){
			var nomNouvelleMarque = document.getElementById('newMarque').value;
			var reg = '^'+nomNouvelleMarque+'$';
			var drapeau = 'i';
			var regex = new RegExp(reg,drapeau);
			var continuer = 1;
			var monTab = new Array;
			var nbM = document.getElementById('nbMModifiables').value;
			for(var i = 1;i < nbM;i++){
				monTab[i] = document.getElementById('tabm_'+i).value;
			}
      		//on compare les caracteres	
			/*for(i=0;i < monTab.length;i++){
				if(regex.exec(document.getElementById(monTab[i]).value) != null){
					continuer = 0;
					break;
				}
			}*/
			if(continuer == 0){
				alert('Cette marque existe déjà!');
				return ;
			}
			//On renvoie la valeur 'addMarque' à $todo (dans fournisseurs.php)
      		document.getElementById('todo').value  = 'addMarque';
		}
		else{
			document.getElementById('todo').value  = 'modifMarque';
		}
	}
	document.getElementById('form_fournisseur').submit();
}
/*-----------------------------------------------------------------------------------------------
/* Fonction qui permet de supprimer un fournisseur
/* ---------------------------------------------------------------------------------------------*/
function deleteFournisseur(name){
	if(confirm('Attention, tous les produits ayant ce fournisseur n\'auront plus de fournisseur associé !')){
		document.getElementById('fournisseurToDelete').value = name;
		document.getElementById('todo').value='deleteFournisseur';
		document.getElementById('form_fournisseur').submit();
	}
}
/*-----------------------------------------------------------------------------------------------
/* Fonction qui permet de supprimer une marque
/* ---------------------------------------------------------------------------------------------*/
function deleteMarque(name){
	if(confirm('Attention, tous les produits ayant cette marque n\'auront plus de marque associée !')){
		document.getElementById('marqueToDelete').value = name;
		document.getElementById('todo').value='deleteMarque';
		document.getElementById('form_fournisseur').submit();
	}
}
/*------------------------------------------------------------------
/* Fonction qui permet l'ajout d'un code promo
/* -----------------------------------------------------------------*/
function prepare_form_add_code_promo(){
  document.getElementById('todo_code_promo').value = 'form_add_code_promo';
  document.getElementById('my_form_liste_code_promo').submit();
  return;
}
/*------------------------------------------------------------------
/* Fonction qui permet de creer un nouveau code promo en verifiant les champs
/* -----------------------------------------------------------------*/
function validation_add_code_promo(){
  if((document.getElementById('code_promo').value == "-- Saisir le code promo --") || (document.getElementById('code_promo').value == "")){ 
    alert ('Vous n\'avez pas saisi le code promo !');
    return;
	}
  if((document.getElementById('montant_reduc_code_promo').value == "-- Saisir le montant de la réduction --") || (document.getElementById('montant_reduc_code_promo').value == "")){
		alert('N\'oubliez pas le montant de la réduction !');
		return;
  }
	if((document.getElementById('mode_reduction').value == 0) || (document.getElementById('mode_reduction').value == "")){
		alert('N\'oubliez pas le mode de réduction !');
		return;
  }
  if(document.getElementById('date_debut_code_promo').value == "-" || document.getElementById('date_debut_code_promo').value == ""){
    alert('N\'oubliez pas la date de début du code promo !');
		return;
	}
  if(document.getElementById('date_fin_code_promo').value == "-" || document.getElementById('date_fin_code_promo').value == ""){
    alert('N\'oubliez pas la date de fin du code promo !');
		return;
	}
  if( (document.getElementById('date_debut_code_promo').value) > (document.getElementById('date_fin_code_promo').value) ){
		alert('La date de début doit être inférieure à la date d\'échéance !');
		return;
	}
  if(document.getElementById('libelle_code_promo').value == "-- Description du code promo --"){
    document.getElementById('libelle_code_promo').value = "";
  }
  if(document.getElementById('limite_max_code_promo').value == "-- Saisir le nombre d'utilisation maximum --"){
    document.getElementById('limite_max_code_promo').value = "";
  }
  if(document.getElementById('montant_min_panier').value == "-- Pour bénéficier de la réduction --"){
    document.getElementById('montant_min_panier').value = 0;
  }
	document.getElementById('todo_code_promo').value = 'add_code_promo';
  document.getElementById('my_form_liste_code_promo').submit();
}
/*------------------------------------------------------------------
/* Fonction qui permet de consulter la fiche d'un code promo
/* -----------------------------------------------------------------*/
function apparition_code_promo(id_my_code_promo_to_see){
  document.getElementById('id_my_code_promo_to_see').value = id_my_code_promo_to_see;
  document.getElementById('todo_code_promo').value = 'see_code_promo';
  document.getElementById('my_form_liste_code_promo').submit();
	return;
}
/*------------------------------------------------------------------
/* Fonction qui permet de fermer une fiche code promo
/* -----------------------------------------------------------------*/
function fermerPanel(quoi){
  document.getElementById('ajout_ou_modif').style.display='none';
  if(quoi == 'see_code_promo'){
  	document.getElementById('consultation').style.display='none';
  	/*document.getElementById('creaModif').style.display='none';*/
  }
  scrollTo(0,0);
}
/*------------------------------------------------------------------
/* Fonction qui permet de modifier une fiche code promo, suite a sa consultation
/* -----------------------------------------------------------------*/
function ouvrirPanelModifCodePromo(){
	document.getElementById('consultation').style.display='none';
	document.getElementById('ajout_ou_modif').style.display='block';
	return 0;
}
/*------------------------------------------------------------------
/* Fonction qui permet de valider la modification d'une fiche code promo
/* -----------------------------------------------------------------*/
function validation_modifier_code_promo(id_code_promo){
  if((document.getElementById('code_promo').value == "-- Saisir le code promo --") || (document.getElementById('code_promo').value == "")){
    alert('N\'oubliez pas le code promo !');
    return;    
	}
	if((document.getElementById('libelle_code_promo').value == "-- Description du code promo --") || (document.getElementById('libelle_code_promo').value == "")){
		document.getElementById('libelle_code_promo').value = '-';
		return;
	}
	if((document.getElementById('limite_max_code_promo').value == "-- Saisir le nombre d\'utilisation maximum --") || (document.getElementById('limite_max_code_promo').value == "")){
		//document.getElementById('limite_max_code_promo').value = '-';
    alert('N\'oubliez pas la limite d\'utilisation pour ce code promo !');
		return;	
	}
	if(document.getElementById('date_debut_code_promo').value == "-" || document.getElementById('date_debut_code_promo').value == ""){
    alert('N\'oubliez pas la date de début du code promo !');
		return;
  }
  if(document.getElementById('date_fin_code_promo').value == "-" || document.getElementById('date_fin_code_promo').value == ""){
    alert('N\'oubliez pas la date de fin du code promo !');
		return;
  }
  if( (document.getElementById('date_debut_code_promo').value) > (document.getElementById('date_fin_code_promo').value) ){
		alert('La date de début doit être inférieure à la date d\'échéance !');
		return;
	}
  if((document.getElementById('montant_reduc_code_promo').value == "-- Saisir le montant de la réduction --") || (document.getElementById('montant_reduc_code_promo').value == "")){
		alert('N\'oubliez pas le montant de la réduction !');
		return;
	}
	if((document.getElementById('mode_reduction').value == 0) || (document.getElementById('mode_reduction').value == "")){
		alert('N\'oubliez pas le mode de réduction !');
		return;
	}
  if(document.getElementById('libelle_code_promo').value == "-- Description du code promo --"){
    document.getElementById('libelle_code_promo').value = "";
  }
  if(document.getElementById('limite_max_code_promo').value == "-- Saisir le nombre d'utilisation maximum --"){
    document.getElementById('limite_max_code_promo').value = "";
	}
	document.getElementById('id_my_code_promo_to_see').value = id_code_promo;
	document.getElementById('todo_code_promo').value = 'modif_code_promo';
	document.getElementById('my_form_liste_code_promo').submit();
}
/*------------------------------------------------------------------
/* Fonction qui supprime un code promo
/* -----------------------------------------------------------------*/
function delete_code_promo(id_club,id_code_promo){ 
	if(confirm('Voulez-vous vraiment supprimer ce code promo ?')){
		document.getElementById('id_my_code_promo_to_see').value = id_code_promo;
		document.getElementById('todo_code_promo').value = 'delete_code_promo';
		document.getElementById('my_form_liste_code_promo').submit();
	}
}