// JavaScript Document

function affichediv(idcacher,idafficher){
	if(document.getElementById(idcacher)){
		document.getElementById(idcacher).style.display="none";
	}
	if(document.getElementById(idafficher)){
		document.getElementById(idafficher).style.display="block";
	}
}
function verifier_inscription(){
	var nom = new LiveValidation('nom');
	nom.add(Validate.Presence);
	var prenom = new LiveValidation('prenom');
	prenom.add(Validate.Presence);
   	var societe = new LiveValidation('societe');
	societe.add(Validate.Presence);
	var fonction = new LiveValidation('fonction');
	fonction.add(Validate.Presence);
	var adresse = new LiveValidation('adresse');
	adresse.add(Validate.Presence);
	var codepostal = new LiveValidation('codepostal');
	codepostal.add(Validate.Numericality, { onlyInteger: true } );
	codepostal.add(Validate.Length, { minimum: 5, maximum: 5 } );
	codepostal.add(Validate.Presence);
	var ville = new LiveValidation('ville');
	ville.add(Validate.Presence);
	var email = new LiveValidation('email');
	email.add(Validate.Email);
	email.add(Validate.Presence);
	var password = new LiveValidation('password');
	password.add(Validate.Presence);
	var password2 = new LiveValidation('password2');
	password2.add(Validate.Presence);
	password2.add( Validate.Confirmation, { match: 'password' } );
	var telephone = new LiveValidation('telephone');
	telephone.add(Validate.Presence);
	var portable = new LiveValidation('portable');
	portable.add(Validate.Presence);
}
function verifier_connexion(){
	var msg="Merci de renseigner les champs suivants pour vous identifier:\n";
	var erreur=0;
	if(document.getElementById("identifiant")){
		if(document.getElementById("identifiant").value==""){
			msg+='- Votre email\n';
			erreur=1;
			
		}
	}
	if(document.getElementById("password")){
		if(document.getElementById("password").value==""){
			msg+='- Votre mot de passe\n';
			erreur=1;
		}
	}
	if(erreur==1){
		alert(msg);
	}else{
		document.connexion.submit();
	}
}	
