var locationHref  = document.location.href;
var adresseLiens  = locationHref.substring(0,eval(locationHref.lastIndexOf('/'))+1).replace('https://','http://');

String.prototype.trim = function() {
return this.replace(/^\s*/,"").replace(/\s*$/,"").replace("’","'")
}

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 OuvrirBanqueImage(noBanqueDImage, langue)
   {
   WindowBanqueImage = open(adresseLiens + 'banqueDImagesPop' + langue + '.cfm?noBanqueDImage=' + noBanqueDImage, 'FenetreBanqueImage', 'scrollbars=no,status=yes,menubar=no,locationbar=no,directories=no,resizable=no,statusbar=no,toolbar=no,' +  StringGrandeur(730,403));
   WindowBanqueImage.focus();	
   }   
   
function OuvrirFenetre(page, largeur, hauteur)
   {
   WindowFenetre = open(page, 'WindowFenetre', 'resizable=no,scrollbars=yes,status=yes,menubar=no,' + StringGrandeur(largeur,hauteur));
   WindowFenetre.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)
   {
   WindowEnvoyer = open('', 'Envoyer', 'resizable=no,scrollbars=yes,status=no,menubar=no,' + StringGrandeur(477,450));
   document.DonneesImprimer.action = adresseLiens + 'demandeDEnvoyerAUnAmi' + langue + '.cfm';
   document.DonneesImprimer.target = 'Envoyer';
   document.DonneesImprimer.submit();
   WindowEnvoyer.focus();
   }   
   
function OuvrirCarte(langue)
   {
   WindowCarte = open(adresseLiens + 'carteDeLocalisation' + langue + '.cfm', 'Carte', 'resizable=no,scrollbars=no,status=no,menubar=no,' + StringGrandeur(565,480));
   WindowCarte.focus();
   }
      
 function OuvrirPolitiqueDePrix(langue)
   {
   WindowPolitique = open(adresseLiens + 'politiqueDePrix' + langue + '.cfm', 'Politique', 'resizable=no,scrollbars=yes,status=yes,menubar=no,' + StringGrandeur(477,500));
   }
   
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;
   }

 
btnOver     = new Image;
btnOver.src = "../banquedimages/play02.gif";
btnOn       = new Image;
btnOn.src   = "../banquedimages/play01.gif";
temps = 0;
function animation() {
  if (document.Donnees.automatique.value == 1){
        if (temps <= 10) {      	  
         temps = temps + 1;
         setTimeout("animation()",500);
        }
        else{
          document.Donnees.submit();
		  return false;
        }
  }
}

function stopMode(){
   if (document.Donnees.automatique.value == 1){
	  document.Donnees.automatique.value  = 0;
	  document.btnPlay.src 				  = btnOn.src;
   }
}

function playMode(){
   if (document.Donnees.automatique.value == 0){
      document.btnPlay.src 				 = btnOver.src;
	  document.Donnees.automatique.value = 1;
	  temps = 10;
	  animation();   
   }
}

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 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 ValiderNewsletter(lang)
   {    
   obj = document.DonneesNewsletter.courriel;
   if (!ValiderCourriel(obj.value, lang) || (obj.value == 'Votre courriel') || (obj.value == 'Your E-mail'))
      {
      obj.focus();
      return false;
      }
   document.DonneesNewsletter.estEnvoye.value = 1;
   return true;
   }   

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;   
