var re_date = /^\d{1,2}\-\d{1,2}\-\d{4}$/;
var tempo = new Array();
var max_mois = new Array();
for (n=1;n<100;n++)
   {
   if (n==4 || n==6 || n==9 || n==11)
      max_mois[n] = 30;
   else
      max_mois[n] = 31;
   }

function valideDate(dateSaisie)
   {
   t_date = re_date.test(dateSaisie);

   if (t_date)
      t_date = t_date && analyse(dateSaisie,1,2,3);

   return t_date;
   }

function analyse(quoi,p_jour,p_mois,p_an)
   {
   tempo = quoi.split('-')
   jour = eval(tempo[(p_jour-1)]);
   mois = eval(tempo[(p_mois-1)]);
   an = eval(tempo[(p_an-1)]);

   if (bisx(an))
      max_mois[2] = 29;
   else
      max_mois[2] = 28;

   t_tempo = (jour<=max_mois[mois] && mois<=12 && mois>=1 && jour>=1);

   return t_tempo;
   }

function bisx(quoi)
   {
   if ((quoi % 100 == 0) && (quoi % 400 == 0))
      return true;
   else if ((quoi % 4) == 0)
      return true;

   return false;
   }
   
function ValiderCourriel(valeur, langue)
   {
   var stringErreur = '';
   var nAccepte = 'abcdefghijklmnopqrstuvwxyz0123456789-_.@';
   var nChar;
   valeur = valeur.toLowerCase();
   valeur = valeur.trim();  
   var indexOfArobas     = valeur.indexOf('@');
   var indexOf2Arobas    = valeur.lastIndexOf('@');
   var lastIndexOfPoint  = valeur.lastIndexOf('.');
   var indexOf2Point     = valeur.indexOf('..');
   var valeurLength      = valeur.length;		
   var indexOfEspace     = valeur.indexOf(' ');   
   
   if (indexOfEspace     != -1)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail must not contain any spaces.';   
      else
	  	  stringErreur = 'Votre courriel doit pas contenir d\'espace.';   
   if (indexOfArobas     < 0)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail must contain an @ character.';   
      else
	  	  stringErreur = 'Votre courriel doit contenir un arobas (@).';
   if (indexOfArobas     == 0)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail must have at least one character in front of the @ character.';   
      else
	  	  stringErreur = 'Votre courriel doit avoir un minimum d\'un caractère avant l\'arobas (@).';		  
   if (lastIndexOfPoint     < (indexOfArobas + 1))
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail must contain at least one dot (.) after the @ character.';   
      else
	  	  stringErreur = 'Votre courriel doit contenir au moins un point (.) après l\'arobas (@).';
   if (lastIndexOfPoint     == valeurLength-1)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail must not end with a dot (.).';   
      else
	  	  stringErreur = 'Votre courriel ne peut se terminer par un point (.).';		  
   if (indexOf2Arobas       != indexOfArobas)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail must only have one @ character.';   
      else
	  	  stringErreur = 'Votre courriel doit contenir seulement un arobas (@).';	  
   if (indexOf2Point       != -1)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail cannot have two dots (..) in a row.';   
      else
	  	  stringErreur = 'Votre courriel ne peut pas contenir 2 points de suite (..).';
   if (stringErreur == '')
      {       
      for (var i=0; i<valeur.length; i++)
         {
         nChar = '' + valeur.substring(i, i+1).toLowerCase();
         if (nAccepte.indexOf(nChar) == -1){		
                if (langue == '_ang')
                   stringErreur = 'Your e-mail contains the (' + valeur.substring(i, i+1) + ') which is not a valid character for an e-mail.';   
                else
                   stringErreur = 'Votre courriel contient le caractère (' + valeur.substring(i, i+1) + ') qui n\'est pas un caractère valide dans un courriel.';
				i = valeur.length;
			}
         }  
      }
   if (stringErreur == '')
      return true;   	
   else
   	  {
      if (langue == '_ang')
         alert(stringErreur + '\nHere is an example of a valid e-mail: your@email.com');
      else
         alert(stringErreur + '\nVoici l\'exemple d\'un courriel valide : votre@courriel.com');
	    return false;	  
	  }      
   }   
  
function SetMaxChar(champ, max, langue)
   {
   if (champ.value.length > max)
      {
      champ.value = champ.value.substring(0,max);
      if (langue == "_ang")
         alert("Your message has exceeded the maximum length for sending a page and has been automatically truncated to "+max+" characters.");
      else
         alert("Votre message dépasse le nombre de caractères permis et a été réduit à "+max+" caractères."); 
      }
   }

// Utilisé pour empêcher les double-clicks...

var estEnvoye;
estEnvoye=false;
