/* AUTEUR: Michel Brousseau */
/* DATE DE CREATION: 6/02/2001 */
/*MODIFIER PAR Benoit Rivard*/
/*DATE DE modification 15/08/2001*/
function formcheck() {
 var lok = false ;
 var depart =  document.theform.email.value.indexOf("@");
 
        if (document.theform.Nom.value == "")  {
        alert("Vous avez oublié le champ NOM.");
		document.theform.Nom.focus();
        return false }
		
		if (document.theform.Prenom.value == "")  {
        alert("Vous avez oublié le champ PRENOM.");
		document.theform.Prenom.focus();
        return false }
/*
		if (document.theform.DateJ.value == "") {
        alert("Vous avez oublié le champ Jour de naissance.");
		document.theform.DateJ.focus();
        return false }
		
		if (document.theform.DateM.value == "") {
        alert("Vous avez oublié le champ Mois de naissance.");
		document.theform.DateM.focus();
        return false }
		
		if (document.theform.DateM.value == "02" ){	   
		   if (document.theform.DateJ.value > "29") {
           	  alert("Il y seuleument 28 jours dans le mois de février");
		   	  document.theform.DateM.focus();
		   return false}
		} 

        if (document.theform.DateA.value == "") {
        alert("Vous avez oublié le champ Année de naissance.");
		document.theform.DateA.focus();
        return false }
		
		if (document.theform.DateA.value.search(/[0-9]{2}/)==-1){
         alert("Seulement des caratères numérique pour l'année de naissance.");
		 document.theform.DateA.focus();
        return false }
*/

		for(var i=0; i < document.theform.Sexe.length; i++) {
		
		if(document.theform.Sexe[i].checked == true ) {
		    // We got one so exit from loop
			lok = true ;
			break }
		}

		if(lok == false) {
		alert("Vous avez oublié le champ SEXE.") ;
		return false }
/*		  
		if (document.theform.Adr1.value == "")  {
        alert("Vous avez oublié le champs ADRESSE 1.");
		document.theform.Adr1.focus();
        return false }
*/		
		if (document.theform.Ville.value == "") {
           alert("Vous avez oublié le champ VILLE.");
		   document.theform.Ville.focus();
        return false }
		
		if (document.theform.ProvEtat.value == "")  {
        alert("Vous avez oublié le champs Prov/Etat.");
		document.theform.ProvEtat.focus();
        return false }
		
		//if (document.theform.Pays.value == "")  {
        //alert("Vous avez oubliez le champ Pays.");
        //return false }
		
		if (document.theform.Cp.value == "")  {
        alert("Vous avez oublié le champ CODE POSTAL.");
		document.theform.Cp.focus();
        return false }

		//document.theform.Pays =document.theform.Pays.value.toUpperCase()
		if (document.theform.Pays.value == "Canada" ){	   
		   if (document.theform.Cp.value.search(/^[a-z0-9a-z0-9a-z0-9]/i)==-1){
		 	  alert("Il y a une erreur dans votre CODE POSTAL. aucun espace");
			  document.theform.Cp.focus();
		   return false}
		   
		   if (document.theform.Cp.value.length > 6){
		 	  alert("Il y a une erreur dans votre CODE POSTAL. aucun espace.");
			  document.theform.Cp.focus();
		   return false}
		} 
		if (document.theform.Pays.value == "États-Unis" ){	   
		   if (document.theform.Cp.value.search(/[0-9]{5}/)==-1){
		 	  alert("Il y a une erreur dans votre CODE POSTAL.aucun espace");
			  document.theform.Pays.focus();
		   return false}
		   
		   if (document.theform.Cp.value.length > 5){
		 	  alert("Il y a une erreur dans votre CODE POSTAL. aucun espace.");
			  document.theform.Cp.focus();
		   return false}
		}   

        if (document.theform.email.value == "") {
        alert("Vous avez oublié le champ votre ADRESSE ÉLECTRONIQUE.");
		document.theform.email.focus();
		return false }
				
		if (document.theform.email.value.search(/[a-z0-9.-_]+@[a-z0-9-]{2,}[.][a-z-]{2,3}/i)== -1){
		 	  alert("Il y a une erreur dans votre ADRESSE ÉLECTRONIQUE.");
			  document.theform.email.focus();
		return false }
		
		if (document.theform.Password.value == "")  {
        alert("Vous avez oublié d'inscrire un MOT DE PASSE .");
		document.theform.Password.focus();
		return false }
		
		if (document.theform.Password.value.length < 6)  {
        alert("Votre mot de passe doit comporter au moins 6 caracteres sans espace.");
		document.theform.Password.focus();
        return false }
		
		if (document.theform.Password.value.length > 20)  {
        alert("Votre mot de passe doit comporter moins de 20 caracteres sans espace.");
		document.theform.Password.focus();
        return false }
		
		if (document.theform.ConfirmPassword.value == "" )  {
        alert("Vous devez confirmer votre MOT DE PASSE.");
		document.theform.ConfirmPassword.focus();
        return false }
		
		if (document.theform.Password.value !== document.theform.ConfirmPassword.value)  {
        alert("Vous devez inscrire le même MOT DE PASSE.")
		document.theform.ConfirmPassword.focus();
        return false }
		
		if (document.theform.Question.value == "")  {
        alert("Vous devez inscrire une QUESTION.");
		document.theform.Question.focus();
        return false }
		
		if (document.theform.Question.value.length > 120)  {
		   alert("Votre QUESTION est trop longue.");
		   document.theform.Question.focus();
        return false }
		
		if (document.theform.Reponse.value == "")  {
        alert("Vous devez inscrire une RÉPONSE à votre QUESTION.");
		document.theform.Reponse.focus();
        return false }		

function setCookie(name, value, expires, path, domain, secure){
 var curCookie = name + "=" + escape(value) + 
 ((expires) ? "; expires=" + expires.toGMTString() : "") +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "") +
 ((secure) ? "; secure" : "")
 document.cookie = curCookie
}

function fixDate(date) {
 var base = new Date(0)
 var skew = base.getTime()
 if (skew > 0)
 date.setTime(date.getTime() - skew)
}

var now = new Date()
fixDate(now)
now.setTime(now.getTime() + 31 * 24 * 60 * 60 * 1000)
Init = document.theform.Prenom.value.substr(0,1)
Pre = document.theform.Prenom.value.substr(1)
name = Init.toUpperCase() + Pre.toLowerCase() //document.theform.Prenom.value //+" "+ document.theform.Nom.value
setCookie("name", name, now)
		
return true ;
}

