var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;
var dom = (document.getElementById)? true:false;

function GetValue(ID_Objet) {
// Recherche la valeur d'un objet INPUT TEXT du formulaire

   if (dom) {
      return document.getElementById(ID_Objet).value;
   }
   if (ie4) {
      return eval("document.all."+ID_Objet+".value");
   }
   if (ns4) {
      return eval("document.saisie."+ID_Objet+".value");
   }
}

// Rejects: empty strings or strings full of blanks,
//          strings without @ or without . (dot)
// Rejects: A@, @B, A@B, .A@B, A@B., A@.B
// Accepts: A@B.C, A.B@C.D

function ValidEmail(s) {
var Count;
var s2;
// empty or blank email
if (EmptyString(s) == true) return (false);
// email without @
if (s.indexOf('@') == -1) return (false);
// email with @ as the 1st char
if (s.indexOf('@') == 0) return (false);
// email with @ as the last char
if ((s.indexOf('@')+1) == s.length) return (false);
// email without .
if (s.indexOf('.') == -1) return (false);
// email with . as the 1st char
if (s.indexOf('.') == 0) return (false);
// email with . as the last char
if ((s.indexOf('.')+1) == s.length) return (false);

// Now look for the first . after the first @
// s2 = string after the first @
s2=s.substring(s.indexOf('@')+1,s.length);
// email without a dot after the first @
if (s2.indexOf('.') == -1) return (false);
// email dot right after the first @
if (s2.indexOf('.') == 0) return (false);
return (true);
}

function EmptyString(s) {
var Count;
var Nblank = 0;
if (s.length == 0) return (true); // empty string
// count the number of blank chars
for (Count = 0; Count < s.length; Count++) {
if (s.charAt(Count) == " ") Nblank++;
}
if (Nblank == s.length)
return (true);
else
return (false);
}

var str_in;
var str_out = ""; 
var num_in;
var num_out = "";

function str_to_num(txt) {
	num_out = "";
	str_in = txt;
	for(i = 0; i < str_in.length; i++) {
		num_out += str_in.charCodeAt(i) - 23;
	}
	return num_out;
}


var tentative = 0;
function validate(){

if (GetValue('nom')==''){alert('Veuillez indiquer votre nom');document.saisie.nom.focus();return false;}
if (GetValue('prenom')==''){alert('Veuillez indiquer votre prénom');document.saisie.prenom.focus();return false;}
if (GetValue('societe')=='' && GetValue('autre_cie')==''){alert('Veuillez indiquer le nom de votre compagnie');document.saisie.societe.focus();return false;}
if (GetValue('login_email')==''){alert('Veuillez saisir votre email');document.saisie.login_email.focus();return false;}
if (GetValue('pass_login')==''){alert('Veuillez choisir un mot de passe');document.saisie.pass_login.focus();return false;}
if (GetValue('fonction')==''){alert('Veuillez indiquer votre fonction');document.saisie.fonction.focus();return false;}

if (!(document.saisie.ep1.checked || document.saisie.ep2.checked)){alert('Veuillez indiquer s\'il sagit d\'email personnel ou professionnel');document.saisie.ep1.focus();return false;}

if (!ValidEmail(document.saisie.login_email.value)){
	alert('Votre adresse email est incorrecte');
	return false;
}


}//fin de function

