

/************************************************
*
*Fonction qui active ou desactive les champs si une
*
*une personne accompagne ou pas
*
**************************************************/

function accompagnant_represente(){

	var cocher = document.getElementById("accompagne_represente").checked;
	
	if (cocher == true) {
	
		document.getElementById("nom_participant2").disabled = false;
		document.getElementById("nom_participant2").style.backgroundColor = "#FFFFFF";
		
		document.getElementById("prenom_participant2").disabled = false;
		document.getElementById("prenom_participant2").style.backgroundColor = "#FFFFFF";
		
		document.getElementById("fonction_participant2").disabled = false;
		document.getElementById("fonction_participant2").style.backgroundColor = "#FFFFFF";
		
		document.getElementById("tel_participant2").disabled = false;
		document.getElementById("tel_participant2").style.backgroundColor = "#FFFFFF";
		
		document.getElementById("email_participant2").disabled = false;
		document.getElementById("email_participant2").style.backgroundColor = "#FFFFFF";
		
		
		/*rend visible les span corespondant */
		document.getElementById("text_nom2").innerHTML = "* Nom: ";
		document.getElementById("text_prenom2").innerHTML = "* Pr\351nom: ";
		document.getElementById("text_fonction2").innerHTML = "* Fonction: ";
		document.getElementById("text_tel2").innerHTML = "* T\351l.: ";
		document.getElementById("text_email2").innerHTML = "* Email:";
		

	
	}else{
		
		document.getElementById("nom_participant2").disabled = true;
		document.getElementById("nom_participant2").value = "";
		document.getElementById("nom_participant2").style.backgroundColor = "#96abd8";
		
		document.getElementById("prenom_participant2").disabled = true;
		document.getElementById("prenom_participant2").value = "";
		document.getElementById("prenom_participant2").style.backgroundColor = "#96abd8";
		
		document.getElementById("fonction_participant2").disabled = true;
		document.getElementById("fonction_participant2").value = "";
		document.getElementById("fonction_participant2").style.backgroundColor = "#96abd8";
		
		document.getElementById("tel_participant2").disabled = true;
		document.getElementById("tel_participant2").value = "";
		document.getElementById("tel_participant2").style.backgroundColor = "#96abd8";
		
		
		document.getElementById("email_participant2").disabled = true;
		document.getElementById("email_participant2").value = "";
		document.getElementById("email_participant2").style.backgroundColor = "#96abd8";
		
		
		/*change le texte des champs corespondant */
		document.getElementById("text_nom2").innerHTML = "Nom: ";
		document.getElementById("text_prenom2").innerHTML = "Pr\351nom: ";
		document.getElementById("text_fonction2").innerHTML = "Fonction: ";
		document.getElementById("text_tel2").innerHTML = "T\351l.: ";
		document.getElementById("text_email2").innerHTML = "Email: ";
		
		
		/*met le texte des intituler des champs en noire*/
		document.getElementById("text_nom2").style.color = "#000000";
		document.getElementById("text_prenom2").style.color = "#000000";
		document.getElementById("text_fonction2").style.color = "#000000";
		document.getElementById("text_tel2").style.color = "#000000";
		document.getElementById("text_email2").style.color = "#000000";
	}

	
}

/****************************************************
*
* Fonction pour la validation du format de l'e-mail
*
******************************************************/

function valideEmail(Email)
{
	var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return re.test(Email)
}


/***********************************************************************************
*
* Fonction de validation du Formulaire
*
*
************************************************************************************/

function validation() {
	
	chaine_erreur = "";
		
	
	/*Recupération des donnée du formulaire*/
	var nom_participant = document.getElementById("nom_participant").value;
	var prenom_participant = document.getElementById("prenom_participant").value;
	var fonction_participant = document.getElementById("fonction_participant").value;
	var tel_participant = document.getElementById("tel_participant").value;
	var email_participant = document.getElementById("email_participant").value;
	
	/*savoir si il y a un accompagnant*/
	var cocher = document.getElementById("accompagne_represente").checked;
	
	/*Récupération des donnée de l'acoompagnant*/
	var nom_participant2 = document.getElementById("nom_participant2").value;
	var prenom_participant2 = document.getElementById("prenom_participant2").value;
	var fonction_participant2 = document.getElementById("fonction_participant2").value;
	var tel_participant2 = document.getElementById("tel_participant2").value;
	var email_participant2 = document.getElementById("email_participant2").value;
	
	
	/*Récupération des checkbox si elle sont cocher les variable seront à true sinon à false*/
	
	var module1_cocher = document.getElementById("module1").checked;
	var module2_cocher = document.getElementById("module2").checked;
	var module3_cocher = document.getElementById("module3").checked;
	var module4_cocher = document.getElementById("module4").checked;
	
	/*Vérification des donnée*/
	if ( nom_participant == ""){
		
		chaine_erreur = chaine_erreur + "- Le champ \"Nom\" doit \352tre renseign\351." + "\n";
		document.getElementById("text_nom").style.color = "#FF0000";
	}
	else{
		document.getElementById("text_nom").style.color = "#000000";
	}
	
	if ( prenom_participant == ""){
		
		chaine_erreur = chaine_erreur + "- Le champ \"Pr\351nom\" doit \352tre renseign\351." + "\n";
		document.getElementById("text_prenom").style.color = "#FF0000";
	}else{
		document.getElementById("text_prenom").style.color = "#000000";
	}
	
	if ( fonction_participant == ""){
		
		chaine_erreur = chaine_erreur + "- Le champ \"Fonction\" doit \352tre renseign\351." + "\n";
		document.getElementById("text_fonction").style.color = "#FF0000";
	}
	else{
		document.getElementById("text_fonction").style.color = "#000000";
	}
	
	if ( tel_participant == ""){
		
		chaine_erreur = chaine_erreur + "- Le champ \"Tel\" doit \352tre renseign\351." + "\n";
		document.getElementById("text_tel").style.color = "#FF0000";
	}
	else{
		document.getElementById("text_tel").style.color = "#000000";
	}
	
	if ( email_participant == ""){
		
		chaine_erreur = chaine_erreur + "- Le champ \"Email\" doit \352tre renseign\351." + "\n";
		document.getElementById("text_email").style.color = "#FF0000";
	}
	else{
		
		if (!valideEmail(email_participant)) {
			
			chaine_erreur = chaine_erreur + "- Adresse email non valide." + "\n";
			document.getElementById("text_email").style.color = "#FF0000";
		
		}else{
			document.getElementById("text_email").style.color = "#000000";
		}	
	}
	
	if ((module1_cocher == false) && (module2_cocher == false) && (module3_cocher == false) && (module4_cocher == false)) {
	
		chaine_erreur = chaine_erreur + "- Vous devez choisir au moins un module." + "\n";
	
	}
	
	if (cocher == true) {
	
		if ( nom_participant2 == ""){
		
		chaine_erreur = chaine_erreur + "- Le champ \"Nom\" de l'accompagnant doit \352tre renseign\351." + "\n";
		document.getElementById("text_nom2").style.color = "#FF0000";
		}
		else{
			document.getElementById("text_nom2").style.color = "#000000";
		}
		
		if ( prenom_participant2 == ""){
			
			chaine_erreur = chaine_erreur + "- Le champ \"Pr\351nom\" de l'accompagnant doit \352tre renseign\351." + "\n";
			document.getElementById("text_prenom2").style.color = "#FF0000";
		}else{
			document.getElementById("text_prenom2").style.color = "#000000";
		}
		
		if ( fonction_participant2 == ""){
			
			chaine_erreur = chaine_erreur + "- Le champ \"Fonction\" de l'accompagnant doit \352tre renseign\351." + "\n";
			document.getElementById("text_fonction2").style.color = "#FF0000";
		}
		else{
			document.getElementById("text_fonction2").style.color = "#000000";
		}
		
		if ( tel_participant2 == ""){
		
		chaine_erreur = chaine_erreur + "- Le champ \"Tel\" de l'accompagnant doit \352tre renseign\351." + "\n";
		document.getElementById("text_tel2").style.color = "#FF0000";
		}
		else{
			document.getElementById("text_tel2").style.color = "#000000";
		}
		
		if ( email_participant2 == ""){
			
			chaine_erreur = chaine_erreur + "- Le champ \"Email\" de l'accompagnant doit \352tre renseign\351." + "\n";
			document.getElementById("text_email2").style.color = "#FF0000";
		}
		else{
		
			if (!valideEmail(email_participant2)) {
				
				chaine_erreur = chaine_erreur + "- Adresse email de l'accompagnant non valide." + "\n";
				document.getElementById("text_email2").style.color = "#FF0000";
			
			}else{
				document.getElementById("text_email2").style.color = "#000000";
			}	
	}
	
	
	
	
	}


	/*Verification si il y a eu des erreurs*/
	if (chaine_erreur == ""){
		return true;	
	}else{
		alert (chaine_erreur);
		return false;
		
	}
	
}
