// JavaScript Document


function affiche() {
var id = document.form_inscription.partpro.value;
var id2 = '';
var id1 = '';
if (id =='non')
{
id1 = 'part';
id2 = 'pro'
document.form_inscription.choixpartpro.value = 'pro';
document.getElementById("inscription").style.height = "850px";
} else {
document.getElementById("inscription").style.height = "700px";
}
if (id =='oui'){
id1 = 'pro';
id2 = 'part'
document.form_inscription.choixpartpro.value = 'part';
}
document.getElementById(id1).style.visibility='hidden';
document.getElementById(id2).style.visibility='visible';

//document.getElementById('partpro').style.visibility='hidden';


}

function verif(codesecu) {
var choix = document.form_inscription.choixpartpro.value;
var err = '';
if(choix=='part'){
  if (document.form_inscription.nompart.value==''){err = err+'Votre nom \n';}
  if (document.form_inscription.prenompart.value==''){err = err+'Votre prénom \n';}
  if (document.form_inscription.adressepart.value==''){err = err+'Votre adresse \n';}
  if (document.form_inscription.cppart.value==''){err = err+'Votre code postal \n';}
  if (document.form_inscription.villepart.value==''){err = err+'Votre ville \n';}
  if (document.form_inscription.mail1part.value==''){err = err+'Votre e-mail \n';}
  if (document.form_inscription.telpart.value==''){err = err+'Votre téléphone \n';}
  if (document.form_inscription.codesecuPart.value!=codesecu){err = err+'\ncode de sécurité incorrecte\n';}

  if (document.form_inscription.telpart.value!=''){
     if (!Verifier_Numero_Telephone(document.form_inscription.telpart.value)){
     
     err = err+'Mauvais n° de téléphone \n';
     }
  }
  if (document.form_inscription.mail1part.value!=document.form_inscription.mail2part.value){
  err = err+'\n les deux champs e-mails ne \n correspondent pas \n';
  }
  if (document.form_inscription.mail1part.value !=''){
    if (document.form_inscription.mail1part.value==document.form_inscription.mail2part.value ){
      if (!bonmail(document.form_inscription.mail1part.value)){
      err = err+'\n e-mail invalide \n';
      }
    }
  }
}
else {
  if (document.form_inscription.noment.value==''){err = err+'Le nom de votre entreprise \n';}
  if (document.form_inscription.adresseent.value==''){err = err+"l'adresse \n";}
  if (document.form_inscription.cpent.value==''){err = err+'le code postal \n';}
  if (document.form_inscription.villeent.value==''){err = err+'la ville \n';}
  if (document.form_inscription.nomrepresentantent.value==''){err = err+'Le nom du représentant \n';}
  if (document.form_inscription.prenomrepresentantent.value==''){err = err+'Le prénom du représentant\n';}  
  if (document.form_inscription.fonctionrepresentantent.value==''){err = err+'La fonction du représentant\n';}  
  if (document.form_inscription.telrepresentantent.value==''){err = err+'le téléphone \n';}
  if (document.form_inscription.mail1representantent.value==''){err = err+'Votre e-mail \n';}
  if (document.form_inscription.prenomparticipantent.value==''){err = err+'le prénom du participant\n';}
  if (document.form_inscription.nomparticipantent.value==''){err = err+'le nom du participant \n';}  
  if (document.form_inscription.codesecuPRO.value!=codesecu){err = err+'\ncode de sécurité incorrecte\n';}
  if (document.form_inscription.telrepresentantent.value!=''){
     if (!Verifier_Numero_Telephone(document.form_inscription.telrepresentantent.value)){
     
     err = err+'Mauvais n° de téléphone \n';
     }
  }
  if (document.form_inscription.mail1representantent.value!=document.form_inscription.mail2representantent.value){
  err = err+'\n les deux champs e-mails ne \n correspondent pas \n';
  }
  if (document.form_inscription.mail1representantent.value !=''){
    if (document.form_inscription.mail1representantent.value==document.form_inscription.mail2representantent.value ){
      if (!bonmail(document.form_inscription.mail1representantent.value)){
      err = err+'\n e-mail invalide \n';
      }
    }
  }

}


if (err !=''){
  alert('Veuillez renseigner \n\n'+err);
  return false;
}else {
  
  document.form_inscription.formvalid.value='oui';
  return true;
}
}
function Verifier_Numero_Telephone(num_tel)
{
	// Definition du motif a matcher
	var regex = new RegExp(/^(01|02|03|04|05|06|08|09)[0-9]{8}/gi);
	
	// Definition de la variable booleene match
	var match = false;
	
	// Test sur le motif
	if(regex.test(num_tel))
	{
		match = true;
	}
	  else
	{
		match = false;
	}
	
	// On renvoie match
	return match;
}

function bonmail(mailteste)

{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

 if(reg.test(mailteste) == false) {
      
      return false;
   }else
   {return true;}
}

function fermer(){
 Effect.Fade('inscription'), { duration: 0.0 };
 document.getElementById('part').style.visibility='hidden';
document.getElementById('pro').style.visibility='hidden';
document.getElementById("inscription").style.height = "300px";
request('wait.php' ,'inscription') 
}

function fin(id){
 Effect.Fade(id), { duration: 0.0 };
document.getElementById("inscription").style.height = "300px";

}

