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("’","'").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(noMembreBanqueImage, noMembre, langue)
   {
   WindowBanqueImage = open('banqueImagesPop' + langue + '.cfm?noMembreBanqueImage=' + noMembreBanqueImage + '&noMembre=' + noMembre, '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)
   {
   WindowFenetre = open(page, 'WindowFenetre', 'resizable=no,scrollbars=yes,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)
   {
   WindowEnvoyer = open('', 'Envoyer', 'resizable=no,scrollbars=yes,status=no,menubar=no,' + StringGrandeur(477,470));
   nomDeDomaine	 = document.location.href;
   nomDeDomaine  = nomDeDomaine.substring(0,eval(nomDeDomaine.lastIndexOf('/')+1)).replace('https://','http://');
   document.DonneesImprimer.action = nomDeDomaine + 'demandeDEnvoyerAUnAmi' + langue + '.cfm';
   document.DonneesImprimer.target = 'Envoyer';
   document.DonneesImprimer.submit();
   WindowEnvoyer.focus();
   }   
   
function OuvrirCarte(langue)
   {
   WindowCarte = open('carteDeLocalisation' + langue + '.cfm', 'Carte', 'resizable=no,scrollbars=no,status=no,menubar=no,' + StringGrandeur(565,480));
   WindowCarte.focus();
   }
   
function OuvrirCapsule(rep)
   {
   WindowCapsule = open('capsule.cfm?rep=' + rep, 'Capsule', 'resizable=no,scrollbars=no,status=no,menubar=no,' + StringGrandeur(640,550));
   WindowCapsule.focus();
   }    

function OuvrirPolitiqueConfidentialite(langue)
   {
   WindowPolitique = open('politiqueDeConfidentialite' + langue + '.cfm?politiqueDeConfidentialite=1', 'Politique', 'resizable=no,scrollbars=yes,status=yes,menubar=no,' + StringGrandeur(668,500));
   }

function OuvrirPolitiqueDePrix(langue)
   {
   WindowPolitique = open('politiqueDePrix' + langue + '.cfm', 'Prix', 'resizable=no,scrollbars=yes,status=yes,menubar=no,' + StringGrandeur(477,500));
   }

function OuvrirListeForfaits(langue)
   {
   WindowListeForfait = open('demandeDeCertificatCadeauListeForfaits' + langue + '.cfm', 'Liste', 'resizable=no,scrollbars=yes,status=yes,menubar=yes,' + 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;
   }

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 OuvrirLien(page)
   {
   WindowLien = open(page, 'WindowLien', 'location=yes,resizable=yes,scrollbars=yes,status=yes,menubar=yes,' + StringGrandeur((screen.width * .90),(screen.height * .55)));
   WindowLien.focus();
   }   
   
function ValiderRecherche(langue)
   {
   document.donneesRecherche.texteRecherche.value = document.donneesRecherche.texteRecherche.value.trim();
   if ((document.donneesRecherche.texteRecherche.value.length < 3) || (document.donneesRecherche.texteRecherche.value == 'Recherche') || (document.donneesRecherche.texteRecherche.value == 'Search'))
      {
      if (langue == '_ang')
        alert('You must enter at least 3 characters.\nEx.: massage');
	  else
        alert('Vous devez entrer un minimum de 3 caractères.\nEx.: inn');
      document.donneesRecherche.texteRecherche.focus();
      return false;
      }
   return true;
   }   
   
function getXhr(){
  var xhr = null; 
  if(window.XMLHttpRequest) // Firefox et autres
    xhr = new XMLHttpRequest(); 
  else if(window.ActiveXObject){ // Internet Explorer 
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
  } else { // XMLHttpRequest non supporté par le navigateur 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
    xhr = false; 
  } 
  return xhr
}   

function afficherSoin(noSoin,noEtablissement){
  if(document.getElementById("soin"+noSoin).style.display == "none"){
    document.getElementById("titreSoin"+noSoin).className = "ouvert";
    document.getElementById("soin"+noSoin).style.display = "block";
  }else{
    document.getElementById("titreSoin"+noSoin).className = "";
    document.getElementById("soin"+noSoin).style.display = "none";
  }
}

function go(noEtablissement,noSection,langue){

 if(document.getElementById("contenu"+noSection).innerHTML != ""){
  document.getElementById("titre"+noSection).className = "";
  document.getElementById("contenu"+noSection).innerHTML = "";
  document.getElementById("contenu"+noSection).style.display = "none";
  return false;
 }
 
 var xhr = getXhr()
 // On défini ce qu'on va faire quand on aura la réponse
 xhr.onreadystatechange = function(){
   // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    if(xhr.readyState == 4 && xhr.status == 200){	    
   contenuReponse = xhr.responseText;
   //alert(contenuReponse);
   document.getElementById("titre"+noSection).className = "ouvert";
   document.getElementById("contenu"+noSection).style.display = "block";
   document.getElementById("contenu"+noSection).innerHTML = contenuReponse;
    }
 }
 
 if(langue == "_ang"){
   xhr.open("POST","_trouverSoin_ang.cfm",true);
 }else{
   xhr.open("POST","_trouverSoin.cfm",true);
 }

 xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
 
 //xhr.send(null);
 if(noEtablissement == 0){
  xhr.send("noSectionSoin="+noSection);
 }else{ 
  xhr.send("noEtablissement="+noEtablissement+"&noSectionSoin="+noSection);
 }
 
}

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 = "";
	   
   if (typeof(subject) == '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;
   else if (courriel.indexOf('?subject=') == -1 )
   	  courriel+= '?subject=' + 'Demande via ' + window.location.hostname;   
   return 'mai' + 'lto:' + courriel; 
 }  

