
String.prototype.trim = function() {
return this.replace(/^\s*/,"").replace(/\s*$/,"")
}


function MAJProvinces(pays, province)
{
nbOptions = province.length;
for (i=0; i < nbOptions; i++)
{
province[0] = null;
}

if (pays[pays.selectedIndex].value == 'Canada')

{
tableauProvinces1 = new Array();

tableauProvinces1[0] = new Option('Alberta', 'Alberta');
tableauProvinces1[1] = new Option('British Columbia', 'British Columbia');
tableauProvinces1[2] = new Option('Manitoba', 'Manitoba');
tableauProvinces1[3] = new Option('New Brunswick', 'New Brunswick');
tableauProvinces1[4] = new Option('Newfoundland', 'Newfoundland');
tableauProvinces1[5] = new Option('Northwest Terr. ', 'Northwest Terr. ');
tableauProvinces1[6] = new Option('Nova Scotia ', 'Nova Scotia ');
tableauProvinces1[7] = new Option('Nunavut', 'Nunavut');
tableauProvinces1[8] = new Option('Ontario', 'Ontario');
tableauProvinces1[9] = new Option('Prince Edward Isl.', 'Prince Edward Isl.');
tableauProvinces1[10] = new Option('Quebec', 'Quebec');
tableauProvinces1[11] = new Option('Saskatchewan', 'Saskatchewan');
tableauProvinces1[12] = new Option('Yukon', 'Yukon');
i = 0;
while (i < tableauProvinces1.length)
{
province.options[i] = tableauProvinces1[i];
if (province.options[i].value == 'Quebec')
province.options[i].selected = true;
i = i + 1;
}
if (pays[pays.selectedIndex].value != 'Canada')
province.options[0].selected = true;
}

else if (pays[pays.selectedIndex].value == 'United States')

{
tableauProvinces14 = new Array();

tableauProvinces14[0] = new Option('Alabama', 'Alabama');
tableauProvinces14[1] = new Option('Alaska', 'Alaska');
tableauProvinces14[2] = new Option('Arizona', 'Arizona');
tableauProvinces14[3] = new Option('Arkansas', 'Arkansas');
tableauProvinces14[4] = new Option('California', 'California');
tableauProvinces14[5] = new Option('Colorado', 'Colorado');
tableauProvinces14[6] = new Option('Connecticut', 'Connecticut');
tableauProvinces14[7] = new Option('D.C.', 'D.C.');
tableauProvinces14[8] = new Option('Delaware', 'Delaware');
tableauProvinces14[9] = new Option('Florida', 'Florida');
tableauProvinces14[10] = new Option('Georgia', 'Georgia');
tableauProvinces14[11] = new Option('Hawaii', 'Hawaii');
tableauProvinces14[12] = new Option('Idaho', 'Idaho');
tableauProvinces14[13] = new Option('Illinois', 'Illinois');
tableauProvinces14[14] = new Option('Indiana', 'Indiana');
tableauProvinces14[15] = new Option('Iowa', 'Iowa');
tableauProvinces14[16] = new Option('Kansas', 'Kansas');
tableauProvinces14[17] = new Option('Kentucky', 'Kentucky');
tableauProvinces14[18] = new Option('Louisiana', 'Louisiana');
tableauProvinces14[19] = new Option('Maine', 'Maine');
tableauProvinces14[20] = new Option('Maryland', 'Maryland');
tableauProvinces14[21] = new Option('Massachusetts', 'Massachusetts');
tableauProvinces14[22] = new Option('Michigan', 'Michigan');
tableauProvinces14[23] = new Option('Minnesota', 'Minnesota');
tableauProvinces14[24] = new Option('Mississippi', 'Mississippi');
tableauProvinces14[25] = new Option('Missouri', 'Missouri');
tableauProvinces14[26] = new Option('Montana', 'Montana');
tableauProvinces14[27] = new Option('Nebraska', 'Nebraska');
tableauProvinces14[28] = new Option('Nevada', 'Nevada');
tableauProvinces14[29] = new Option('New Hampshire', 'New Hampshire');
tableauProvinces14[30] = new Option('New Jersey', 'New Jersey');
tableauProvinces14[31] = new Option('New Mexico', 'New Mexico');
tableauProvinces14[32] = new Option('New York', 'New York');
tableauProvinces14[33] = new Option('North Carolina', 'North Carolina');
tableauProvinces14[34] = new Option('North Dakota ', 'North Dakota ');
tableauProvinces14[35] = new Option('Ohio', 'Ohio');
tableauProvinces14[36] = new Option('Oklahoma', 'Oklahoma');
tableauProvinces14[37] = new Option('Oregon', 'Oregon');
tableauProvinces14[38] = new Option('Pennsylvania', 'Pennsylvania');
tableauProvinces14[39] = new Option('Rhode Island', 'Rhode Island');
tableauProvinces14[40] = new Option('South Carolina', 'South Carolina');
tableauProvinces14[41] = new Option('South Dakota ', 'South Dakota ');
tableauProvinces14[42] = new Option('Tennessee', 'Tennessee');
tableauProvinces14[43] = new Option('Texas', 'Texas');
tableauProvinces14[44] = new Option('Utah', 'Utah');
tableauProvinces14[45] = new Option('Vermont', 'Vermont');
tableauProvinces14[46] = new Option('Virginia', 'Virginia');
tableauProvinces14[47] = new Option('Washington', 'Washington');
tableauProvinces14[48] = new Option('West Virginia', 'West Virginia');
tableauProvinces14[49] = new Option('Wisconsin', 'Wisconsin');
tableauProvinces14[50] = new Option('Wyoming', 'Wyoming');
i = 0;
while (i < tableauProvinces14.length)
{
province.options[i] = tableauProvinces14[i];
if (province.options[i].value == 'Quebec')
province.options[i].selected = true;
i = i + 1;
}
if (pays[pays.selectedIndex].value != 'Canada')
province.options[0].selected = true;
}

else
{
nouvelleOption = new Option("Other", "Other");
province.options[0] = nouvelleOption;
province.options[0].selected = true;
}
}

   
   
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 PopulerJours(mois, jour, annee)
   {
   var vieuxJourSelectionne = jour.selectedIndex;
   
   nbOptions = jour.length;
   for (i=0; i < nbOptions; i++)
      jour[0] = null;

   var nbJours = 0;
   
   switch (mois)
      {
	  case '01' :
	     nbJours = 31;
	     break; 
	  case '02' :
		 if ((annee % 4) == 0)
			if (((annee % 100) == 0) && ((annee % 400) == 0))
			   nbJours = 29;
			else 
			   if ((annee % 100) == 0)
			      nbJours = 28;
			   else
			      nbJours = 29;
		 else
			nbJours = 28;
	     break; 
	  case '03' :
	     nbJours = 31;
	     break; 
	  case '04' :
	     nbJours = 30;
	     break; 
	  case '05' :
	     nbJours = 31;
	     break; 
	  case '06' :
	     nbJours = 30;
	     break; 
	  case '07' :
	     nbJours = 31;
	     break; 
	  case '08' :
	     nbJours = 31;
	     break; 
	  case '09' :
	     nbJours = 30;
	     break; 
	  case '10' :
	     nbJours = 31;
	     break; 
	  case '11' :
	     nbJours = 30;
	     break; 
	  case '12' :
	     nbJours = 31;
	     break; 
	  default : 
         nbJours = 31;
	     break;
      }
	  
   var i = 1;
   while (i <= nbJours)
      {
      if (i < 10)
         nouvelleOption = new Option('0' + i, '0' + i);
      else
         nouvelleOption = new Option(i, i);

      jour.options[(i - 1)] = nouvelleOption;
	  i++;
	  }
   
   if (vieuxJourSelectionne >= jour.length)
      jour[(jour.length - 1)].selected = true;
   else 
      jour[vieuxJourSelectionne].selected = true;
   }


function ouvrirTelechargement()
   {
      WindowTelechargement = open('fenetreTelechargement_ang.cfm', 'Telechargement', 'scrollbars=no,statusbar=no,menubar=no,' + stringGrandeur(423,230));
   }  

   
function stringGrandeur (width, height)
  {
    var string = 'width=' + width + ',height=' + height + ',left=' + ((screen.width - width) / 2) + ',top=' + ((screen.height - height) / 2) + ',screenX=' + ((screen.width - width) / 2) + ',screenY=' + ((screen.height - height) / 2);
    return string;
  }

var defaultEmptyOK = true

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isAlphanumeric (s)

{   var i;
    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }
    return true;
}

function maxChar(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."); 
      }
   	}

	
function ValiderCourriel(valeur) {
  var ok = true;
  var nAccepte = "abcdefghijklmnopqrstuvwxyz0123456789-_.@";
  var nChar;
  var valeur; 
  
  valeur = valeur.toLowerCase();
  
  var indexOfArobas     = valeur.indexOf('@');
  var indexOf2Arobas    = valeur.lastIndexOf('@');
  var lastIndexOfPoint  = valeur.lastIndexOf('.');
  var indexOf2Point     = valeur.indexOf('..');
  var valeurLength      = valeur.length;		
	
  if ( (indexOfArobas          > 0)			          && 
	   (lastIndexOfPoint       > (indexOfArobas + 1)) &&
	   ((lastIndexOfPoint + 2) < valeurLength)	      &&
	   (indexOf2Arobas         == indexOfArobas)      &&
	   (indexOf2Point          == -1)
	  ){       
  		for (var i=0; i<valeur.length; i++) {
    		nChar = "" + valeur.substring(i, i+1);
    		if (nAccepte.indexOf(nChar) == "-1")
				ok = false;
  		}  
  }	
  else
    ok = false;
	
  return ok;
}		
	
// Utilisé pour empêcher les double-clicks...

   var estEnvoye;
   estEnvoye=false;