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 OuvrirBanqueImage(noBanqueDImage, noBanqueDImageAvecCategorie, langue)
   {
   WindowBanqueImage = open('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(723,364));
   WindowBanqueImage.focus();	
   }
      
function OuvrirSoins(lien)
 {
   WindowLien = open(lien, 'WindowLien', 'resizable=no,scrollbars=no,status=no,menubar=no,' + StringGrandeur(475,250));
   WindowLien.focus(); 
 }
 
function OuvrirPolitiqueReservation(langue)
 {
   WindowPolitiqueReservation = open('politiqueReservation' + langue + '.cfm', 'WindowPolitiqueReservation', 'resizable=no,scrollbars=yes,status=no,menubar=no,' + StringGrandeur(490,500));
   WindowPolitiqueReservation.focus(); 
 } 
  
function OuvrirPolitiqueReservationCorpo(langue)
 {
   WindowPolitiqueReservation = open('politiqueReservationCorpo' + langue + '.cfm', 'WindowPolitiqueReservation', 'resizable=no,scrollbars=yes,status=no,menubar=no,' + StringGrandeur(490,500));
   WindowPolitiqueReservation.focus(); 
 } 

function OuvrirEnvoyerAUnAmi(langue)
   {
   EnvoyerAmi = open('', 'EnvoyerAmi', 'resizable=no,scrollbars=no,status=no,menubar=no,' + StringGrandeur(477,465));
   document.DonneesImprimer.action = 'demandeDEnvoyerAUnAmi' + langue + '.cfm';
   document.DonneesImprimer.target = 'EnvoyerAmi';
   document.DonneesImprimer.submit();
   }   
   
function OuvrirCarteFlash(langue)
 {
   WindowCarteFlash = open('http://www.numeriquetechnologies.com/baluchon/carteFlashJ2011/index' + langue + '.html','WindowCarteFlash', 'resizable=no,scrollbars=no,status=no,menubar=no,' + StringGrandeur(753,555));
   WindowCarteFlash.focus(); 
 }   
   
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 (username) must not contain any spaces.';   
      else
	  	  stringErreur = 'Votre courriel (nom d\'usager) doit pas contenir d\'espace.';   
   if (indexOfArobas     < 0)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail (username) must contain an @ character.';   
      else
	  	  stringErreur = 'Votre courriel (nom d\'usager) doit contenir un arobas (@).';
   if (indexOfArobas     == 0)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail (username) must have at least one character in front of the @ character.';   
      else
	  	  stringErreur = 'Votre courriel (nom d\'usager) doit avoir un minimum d\'un caractère avant l\'arobas (@).';		  
   if (lastIndexOfPoint     < (indexOfArobas + 1))
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail (username) must contain at least one dot (.) after the @ character.';   
      else
	  	  stringErreur = 'Votre courriel (nom d\'usager) doit contenir au moins un point (.) après l\'arobas (@).';
   if (lastIndexOfPoint     == valeurLength-1)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail (username) must not end with a dot (.).';   
      else
	  	  stringErreur = 'Votre courriel (nom d\'usager) ne peut se terminer par un point (.).';		  
   if (indexOf2Arobas       != indexOfArobas)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail (username) must only have one @ character.';   
      else
	  	  stringErreur = 'Votre courriel (nom d\'usager) doit contenir seulement un arobas (@).';	  
   if (indexOf2Point       != -1)
      if (langue == '_ang')
	  	  stringErreur = 'Your e-mail (username) cannot have two dots (..) in a row.';   
      else
	  	  stringErreur = 'Votre courriel (nom d\'usager) 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 (username) contains the (' + valeur.substring(i, i+1) + ') which is not a valid character for an e-mail.';   
                else
                   stringErreur = 'Votre courriel (nom d\'usager) 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 (username): name@domain.com');
      else
         alert(stringErreur + '\nVoici l\'exemple d\'un courriel (nom d\'usager) 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 ValiderNewsletter(lang)
   {    
   obj = document.DonneesNewsletter.courriel;
   if (!ValiderCourriel(obj.value, lang) || (obj.value == 'Votre courriel') || (obj.value == 'Your E-mail'))
      {
      obj.focus();
      return false;
      }
   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-FORM-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; 
 }         

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... Merci de le mettre à jour Firefox, Internet Explorer, Opera'); 
	xhr = false; 
  } 
  return xhr;
} 

function afficherFournisseur(noPlat,noBulle){
  eval('document.getElementById("plats' + noPlat + 'aliments' + noBulle + '").className = "infoBulle"');
  return false;
} 
 
function cacherFournisseur(noPlat,noBulle){
  eval('document.getElementById("plats' + noPlat + 'aliments' + noBulle + '").className = ""');
  return false;
}

function realisationsFlash(posGauche,action,langue)
{

  posGauche = parseInt(posGauche);
  
  var tableau=new Array;
  if(langue!="_ang"){
  tableau[0] = "Épopée de nos rivières";
  tableau[1] = "Terrine de cerf";
  tableau[2] = "Saucisses de cerf et sanglier";
  tableau[3] = "Fromage et gelé de porto";
  tableau[4] = "Palette de bières";
  tableau[5] = "Thé";
  tableau[6] = "Cafés biologiques et équitables";
  }else{
  tableau[0] = "Épopée de nos rivières";
  tableau[1] = "Terrine de cerf";
  tableau[2] = "Saucisses de cerf et sanglier";
  tableau[3] = "Fromage et gelé de porto";
  tableau[4] = "Palette de bières";
  tableau[5] = "Thé";
  tableau[6] = "Cafés biologiques et équitables";  
  }
  
  if(posGauche > (tableau.length - 3))
    posGauche = 4;
  
 if(action == "gauche")
 { 
   if(posGauche != 0)
   {
      posGauche = parseInt(posGauche - 1);
   }
 }else{   
   if((posGauche + 4) != tableau.length)
   {
      posGauche = parseInt(posGauche + 1);
   }   
 }

 contenuEcoCafe = '<div class="fleche"><a href="javascript:void(0);" onclick="realisationsFlash(\'' + posGauche + '\',\'gauche\',\'' + langue + '\')"><img src="/images/btn_flecheGauche.gif" alt="" /></a></div>';
 contenuEcoCafe += '<div><a href="gastronomie_plats'+ langue +'.cfm?noPlat='+ eval(posGauche + 1) +'"><img src="/images/thumb_plat'+ eval(posGauche + 1) +'.jpg" alt="'+tableau[posGauche]+'" /></a></div>';
 contenuEcoCafe += '<div><a href="gastronomie_plats'+ langue +'.cfm?noPlat='+ eval(posGauche + 2) +'"><img src="/images/thumb_plat'+ eval(posGauche + 2) +'.jpg" alt="'+tableau[posGauche + 1]+'" /></a></div>';
 contenuEcoCafe += '<div><a href="gastronomie_plats'+ langue +'.cfm?noPlat='+ eval(posGauche + 3) +'"><img src="/images/thumb_plat'+ eval(posGauche + 3) +'.jpg" alt="'+tableau[posGauche + 2]+'" /></a></div>';
 contenuEcoCafe += '<div><a href="gastronomie_plats'+ langue +'.cfm?noPlat='+ eval(posGauche + 4) +'"><img src="/images/thumb_plat'+ eval(posGauche + 4) +'.jpg" alt="'+tableau[posGauche + 3]+'" /></a></div>';
 contenuEcoCafe += '<div class="fleche"><a href="javascript:void(0);" onclick="realisationsFlash(\'' + posGauche  + '\',\'droite\',\'' + langue + '\')"><img src="/images/btn_flecheDroite.gif" alt="" /></a></div>';  

 document.getElementById("realisationsFlash").innerHTML=contenuEcoCafe;  
}
