// JavaScript Document
function verif_adhesion_etape1(){
	var nom = document.adhesion.nom.value ;
	var prenom = document.adhesion.prenom.value ;
	var date_nais = document.adhesion.date_nais.value ;
	var email = document.adhesion.email.value ;
	var email_c = document.adhesion.email_c.value ;
	var profession = document.adhesion.profession.value ;
	var adresse = document.adhesion.adresse.value ;
	var codepostal = document.adhesion.codepostal.value ;
	var ville = document.adhesion.ville.value ;
	var pays = document.adhesion.pays.value ;
	var tel = document.adhesion.tel.value ;
	var conditions = document.adhesion.conditions;
	var crea_assoc = document.adhesion.crea_assoc.value;
	var nom_assoc = document.adhesion.nom_assoc.value;
	var nom_club = document.adhesion.nom_club.value;
	var error = false;
	var errorMsg = 'Veuillez vérifier les informations suivantes : \n\n';
	if(nom == ''){
			error = true;
			errorMsg += '* votre nom\n';
	}
	if(prenom == ''){
			error = true;
			errorMsg += '* votre prénom\n';
	}
	if(date_nais == '' || !date_nais.isDate()){
			error = true;
			errorMsg += '* votre date de naissance\n';
	}
	if(email == ''){
			error = true;
			if(email_c != email)errorMsg += '* votre adresse email (confirmation incorrecte)\n';
			else errorMsg += '* votre adresse email\n';
	}
	if(profession == ''){
			error = true;
			errorMsg += '* votre profession\n';
	}
	if(adresse == ''){
			error = true;
			errorMsg += '* votre adresse postale\n';
	}
	if(codepostal == '' || !codepostal.isNumeric()){
			error = true;
			errorMsg += '* votre code postal\n';
	}
	if(ville == ''){
			error = true;
			errorMsg += '* votre ville\n';
	}
	if(pays == ''){
			error = true;
			errorMsg += '* votre pays\n';
	}
	if(tel == ''){
			error = true;
			errorMsg += '* votre numéro de téléphone\n';
	}
	if(!conditions.checked){
			error = true;
			errorMsg += '* l\'acceptation des conditions générales d\'adhésion\n';
	}
	if(error == true)alert(errorMsg);
	else document.adhesion.submit();
	
}

function calc_prest(){
	document.adhesion.prest_commande.value = "";
	for (i=0;i<document.adhesion.elements.length;i++) {
		if (document.adhesion.elements[i].type == 'checkbox' && document.adhesion.elements[i].id == 'total' && document.adhesion.elements[i].checked){
			document.adhesion.prest_commande.value = document.adhesion.prest_commande.value + document.adhesion.elements[i].name + ";";

		}
	}
}
function calc_cat(){
	document.adhesion.listeCat.value = "";
	for (i=0;i<document.adhesion.elements.length;i++) {
		if (document.adhesion.elements[i].type == 'checkbox' && document.adhesion.elements[i].id == 'cat' && document.adhesion.elements[i].checked){
			document.adhesion.listeCat.value = document.adhesion.listeCat.value + document.adhesion.elements[i].name + ";";

		}
	}
}
function modif_adhesion(){
	document.adhesion.action='parrainage.php';
	document.adhesion.mode.value='modifier';
	document.adhesion.submit();
	
}
function modif_commande(){
	document.commande.action='parrainage.php';
	document.commande.mode.value='modifier';
	document.commande.submit();
	
}
function confirm_adhesion(){
	document.adhesion.mode.value='enregistrer';
	document.adhesion.submit();
}
function confirm_commande(){
	document.commande.mode.value='enregistrer';
	document.commande.submit();
}
function verif_login(){
	var error = false;
	var errorMsg = 'Veuillez vérifier les informations suivantes : \n\n';
	if(!document.form_login.login.value.isEmail()){
		error = true;
		errorMsg += '* votre login\n';
	}
	if(document.form_login.passwd.value == ''){
		error = true;
		errorMsg += '* votre mot de passe\n';
	}
	if(error == true)alert(errorMsg);
	else document.form_login.submit();
}
function verif_contact(){
	var nom = document.contact.nom.value;
	var prenom = document.contact.prenom.value;
	var email =document.contact.email.value;
	var adresse =document.contact.adresse.value;
	var codepostal = document.contact.codepostal.value;
	var ville = document.contact.ville.value;
	var tel = document.contact.tel.value;
	var email = document.contact.email.value;
	var message = document.contact.message.value;
	
	var error = '';
	
	if(nom == '')error += '* votre nom.\n';
	if(prenom == '')error += '* votre prénom.\n';
	if(email == '')error += '* votre email.\n';
	if(adresse == '')error += '* votre adresse.\n';
	if(codepostal == '')error += '* votre code postal.\n';
	if(ville == '')error += '* votre ville.\n';
	if(tel == '')error += '* votre numéro de téléphone.\n';
	if(message == '')error += '* votre message.\n';
	if(error == '')document.contact.submit();
	else alert('Veuillez vérifier les mentions suivantes :\n'+error);
	
}
function checkTiers(){
	document.commande.nom.value = '' ;
	document.commande.prenom.value = '' ;
	document.commande.date_nais.value = '' ;
	document.commande.email.value = '' ;
	document.commande.email_c.value = '' ;
	document.commande.profession.value = '' ;
	document.commande.adresse.value = '' ;
	document.commande.codepostal.value = '' ;
	document.commande.ville.value = '' ;
	document.commande.pays.value = '' ;
	document.commande.tel.value = '' ;
}
function verif_commande(){
	var nom = document.commande.nom.value ;
	var prenom = document.commande.prenom.value ;
	var date_nais = document.commande.date_nais.value ;
	var email = document.commande.email.value ;
	var email_c = document.commande.email_c.value ;
	var profession = document.commande.profession.value ;
	var adresse = document.commande.adresse.value ;
	var codepostal = document.commande.codepostal.value ;
	var ville = document.commande.ville.value ;
	var pays = document.commande.pays.value ;
	var tel = document.commande.tel.value ;
	var conditions = document.commande.conditions;
	var crea_assoc = document.commande.crea_assoc.value;
	var nom_assoc = document.commande.nom_assoc.value;
	var nom_club = document.commande.nom_club.value;
	var error = false;
	var errorMsg = 'Veuillez vérifier les informations suivantes : \n\n';
	if(nom == ''){
			error = true;
			errorMsg += '* votre nom\n';
	}
	if(prenom == ''){
			error = true;
			errorMsg += '* votre prénom\n';
	}
	if(date_nais == '' || !date_nais.isDate()){
			error = true;
			errorMsg += '* votre date de naissance\n';
	}
	if(email == ''){
			error = true;
			errorMsg += '* votre adresse email\n';
	}
	if(email_c == '' || email_c != email){
		error = true;
		errorMsg += '* votre adresse email (confirmation incorrecte)\n';
	}
	if(profession == ''){
			error = true;
			errorMsg += '* votre profession\n';
	}
	if(adresse == ''){
			error = true;
			errorMsg += '* votre adresse postale\n';
	}
	if(codepostal == '' || !codepostal.isNumeric()){
			error = true;
			errorMsg += '* votre code postal\n';
	}
	if(ville == ''){
			error = true;
			errorMsg += '* votre ville\n';
	}
	if(pays == ''){
			error = true;
			errorMsg += '* votre pays\n';
	}
	if(tel == ''){
			error = true;
			errorMsg += '* votre numéro de téléphone\n';
	}
	if(!conditions.checked){
			error = true;
			errorMsg += '* l\'acceptation des conditions générales de vente\n';
	}
	if(error == true)alert(errorMsg);
	else document.commande.submit();
	
}