var adresseScripts = document.location.href;
adresseScripts     = adresseScripts.substring(0,eval(adresseScripts.lastIndexOf('/'))+1);
adresseScripts     = adresseScripts.replace('https://','http://');

String.prototype.trim = function() {
temp = this;
while (escape(temp).indexOf('%u2018') > -1)
   { 
   temp = escape(temp).replace('%u2018', '%27');
   temp = unescape(temp);
   }
return temp.replace(/^\s*/,"").replace(/\s*$/,"").replace(/’/g,"'").replace(/–/g,"-")
}

function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { 
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function OuvrirExtranet()
   {
   PageExtranet = open('', 'PageExtranet', 'toolbar=yes,resizable=yes,scrollbars=yes,status=yes,menubar=yes,' + StringGrandeur((screen.width * .99),(screen.height * .50)));
   document.DonneesExtranet.action = adresseScripts + 'Extranet/validerUsager.cfm';
   document.DonneesExtranet.submit(); 
   PageExtranet.focus();
   }
	
function OuvrirBanqueImage(noBanqueDImage, noBanqueDImageAvecCategorie, langue)
   {
   WindowBanqueImage = open(adresseScripts + 'banqueDImagesPop' + langue + '.cfm?noBanqueDImage=' + noBanqueDImage + '&noBanqueDImageAvecCategorie=' + noBanqueDImageAvecCategorie, 'FenetreBanqueImage', 'scrollbars=no,status=yes,menubar=no,locationbar=no,directories=no,resizable=no,statusbar=no,toolbar=no,' +  StringGrandeur(730,379));
   WindowBanqueImage.focus();	
   }
   
function OuvrirFenetre(page, largeur, hauteur, scrollBars)
   {
   if (typeof(scrollBars) == 'undefined')
      scrollBars = true;
   if (scrollBars)
      WindowFenetre = open(page, 'WindowFenetre', 'resizable=no,scrollbars=yes,status=yes,menubar=no,' + StringGrandeur(largeur,hauteur));
   else
      WindowFenetre = open(page, 'WindowFenetre', 'resizable=no,scrollbars=no,status=yes,menubar=no,' + StringGrandeur(largeur,hauteur));
   WindowFenetre.focus();
   }

function OuvrirVideo(page, largeur, hauteur)
   {
   WindowVideo = open(page, 'Video', 'scrollbars=no,status=yes,' + StringGrandeur(largeur + 20,hauteur + 48));
   WindowVideo.focus();	
   }

function ImprimerPage()
   {
   WindowImprimer = open('', 'Imprimer', 'resizable=yes,scrollbars=yes,status=yes,menubar=yes,' + StringGrandeur(710,400));
   document.DonneesImprimer.action = document.DonneesImprimer.nomPagePourImprimer.value;
   document.DonneesImprimer.target = 'Imprimer';
   document.DonneesImprimer.submit();
   WindowImprimer.focus();
   }

function OuvrirEnvoyerAUnAmi(langue)
   {
   EnvoyerAmi = open('', 'EnvoyerAmi', 'resizable=no,scrollbars=yes,status=no,menubar=no,' + StringGrandeur(477,510));
   document.DonneesImprimer.action = adresseScripts + 'demandeDEnvoyerAUnAmi' + langue + '.cfm';
   document.DonneesImprimer.target = 'EnvoyerAmi';
   document.DonneesImprimer.submit();
   }   
   
function OuvrirCarte(langue)
   {
   WindowCarte = open(adresseScripts + 'carteDeLocalisation' + langue + '.cfm', 'Carte', 'resizable=no,scrollbars=no,status=no,menubar=no,' + StringGrandeur(565,480));
   WindowCarte.focus();
   }

function OuvrirPolitiqueConfidentialite(langue)
   {
   WindowPolitique = open(adresseScripts + 'politiqueDeConfidentialite' + langue + '.cfm?politiqueDeConfidentialite=1', 'Politique', 'resizable=no,scrollbars=yes,status=yes,menubar=no,' + StringGrandeur(668,500));
   }

function OuvrirPolitiqueDePrix(langue)
   {
   WindowPolitique = open(adresseScripts + 'politiqueDePrix' + langue + '.cfm', 'Prix', 'resizable=no,scrollbars=yes,status=yes,menubar=no,' + StringGrandeur(477,500));
   }

function OuvrirListeForfaits(langue)
   {
   WindowListeForfait = open(adresseScripts + 'demandeDeCertificatCadeauListeForfaits' + langue + '.cfm', 'Liste', 'resizable=no,scrollbars=yes,status=yes,menubar=yes,' + StringGrandeur(477,500));
   }

function ValiderExtranet(langue)
   {
   i = 0; 
   while (i < document.DonneesExtranet.elements.length) 
      { 
      document.Donnees.elements[i].value = document.Donnees.elements[i].value.trim();
      if ((document.DonneesExtranet.elements[i].type != 'select-one') && (document.DonneesExtranet.elements[i].type != 'select-multiple') && (document.DonneesExtranet.elements[i].type != 'file')) 
         { 
         if ((document.DonneesExtranet.elements[i].value.length == 0) && (document.DonneesExtranet.elements[i].type != 'hidden')
            ) 
            { 
            if (langue == '_ang')
               alert('You must fill in every required field.'); 
            else
               alert('Vous devez remplir tous les champs obligatoires.'); 
            document.DonneesExtranet.elements[i].focus(); 
            return false; 
            } 
         } 
      i = i + 1; 
      }
   return true;

   }
   
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;
   }

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: name@domain.com');
      else
         alert(stringErreur + '\nVoici l\'exemple d\'un courriel valide : nom@domaine.com');
	    return false;	  
	  }      
   }

function DivExpanderDate(modeAVerifier) {
	  
  if (!modeAVerifier)
  { 
     TableauDateArrivee2.style.visibility = 'hidden'; 
     TableauDateArrivee2.style.display = 'none'; 
  }
  else
  { 
    TableauDateArrivee2.style.visibility = 'visible'; 
    TableauDateArrivee2.style.display = 'block';
  }
}   
   
function TraiterErreur()
   {
   WindowAvertissement = open('http://www.numerique.ca/scripts/Publique/templateErrorJavascript.cfm?nomPage=' + document.location, 'ErreurJS', 'scrollbars=no,status=no,' + StringGrandeur(400,150));
   return true;
   }

   
   
function Antispam(tableau1, tableau2, subject){
   var courriel = ""; 
   var texte    = "";
   for (i=0;i<tableau1.length;i++)
     courriel+=String.fromCharCode(tableau1[i])
   if (typeof(tableau2) != 'undefined'){
       if (tableau2.length > 0){
           for (i=0;i<tableau2.length;i++)
             texte+=String.fromCharCode(tableau2[i])
	   }
	   else
	      texte = courriel;
   }			  
   else
   	  texte = courriel;
   if (typeof(tableau2) == 'undefined')
       subject = "";
	   
   tableauTexte = texte.split("@");
   if (tableauTexte.length == 2){
   	  texte = tableauTexte[0] + '<span style="display:none;">REMOVE-THIS-FOR-SPAM</span>&#64;' + tableauTexte[1];
   }   
   document.write('<a href="mailto:a" onclick="this.href = AntiSpamClic(Array(' + tableau1 + '),\'' + subject + '\');">' + texte + '</a>');   
 }   

function AntiSpamClic(tableau1, subject){ 
   var courriel = ""; 
   for (i=0;i<tableau1.length;i++)
     courriel+=String.fromCharCode(tableau1[i]);
   if (subject.length > 0)
   	  courriel+= '?subject=' + subject;
   return 'mai' + 'lto:' + courriel; 
 }        
//window.onerror = TraiterErreur;
