function $(id) {
   if (document.getElementById(id))
      return document.getElementById(id);
   else return false;
}

   function getClientSize() {
     var myWidth = 0, myHeight = 0;
     if( typeof( window.innerWidth ) == 'number' ) {
       //Non-IE
       myWidth = window.innerWidth;
       myHeight = window.innerHeight;
     } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
       //IE 6+ in 'standards compliant mode'
       myWidth = document.documentElement.clientWidth;
       myHeight = document.documentElement.clientHeight;
     } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
       //IE 4 compatible
       myWidth = document.body.clientWidth;
       myHeight = document.body.clientHeight;
     }
     return [ myWidth, myHeight ];
   }

   function getScrollXY() {
     var scrOfX = 0, scrOfY = 0;
     if( typeof( window.pageYOffset ) == 'number' ) {
       //Netscape compliant
       scrOfY = window.pageYOffset;
       scrOfX = window.pageXOffset;
     } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
       //DOM compliant
       scrOfY = document.body.scrollTop;
       scrOfX = document.body.scrollLeft;
     } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
       //IE6 standards compliant mode
       scrOfY = document.documentElement.scrollTop;
       scrOfX = document.documentElement.scrollLeft;
     }
     return [ scrOfX, scrOfY ];
   }

    // Internet Explorer 6
     var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
    // exactly Internet Explorer 7
     var IE7 = false /*@cc_on || @_jscript_version == 5.7 @*/;
    // at least Internet Explorer 7
     var gteIE7 = false /*@cc_on || @_jscript_version >= 5.7 @*/;
   // any Internet Explorer (thanks to Dean)
     var isMSIE = /*@cc_on!@*/false;


   var IEfader = (navigator.appName == "Microsoft Internet Explorer");

   var fadings = new Array();

   function trans(element,op) {
       if (IEfader)
            element.style.filter = "alpha(opacity="+op+")";
          else {
            element.style.opacity = (op / 100);
            element.style.MozOpacity = (op / 100);
          }
   }

   function fade_in(id,op,max,to,sp) {
     if (to === undefined) to = 80;
     if (sp === undefined) sp = 18;/* CHANGÉ POUR RAPIDITÉ : */
     if (!fadings[id] || fadings[id] == "") fadings[id] = "in";
     if (fadings[id] == "in") {
      if (element = $(id)) {
          if (op==0) element.style.visibility = "visible";
          //if (element.style.visibility != "visible") element.style.visibility = "visible";
          if (op>max) op=max;
          if (IEfader)
            element.style.filter = "alpha(opacity="+op+")";
          else {
            element.style.opacity = (op / 100);
            element.style.MozOpacity = (op / 100);
          }
          if (op < max) setTimeout('fade_in("'+id+'",'+(op+sp)+','+max+','+to+','+sp+');',to);
          else fadings[id] = "";
      }
     }
     else { //sinon attendre...
        setTimeout('fade_in("'+id+'",'+op+','+max+','+to+','+sp+');',115);
     }
    }

    function fade_out(id,op,min,to,sp) {
      if (to === undefined) to = 80;
      if (sp === undefined) sp = 18;/* CHANGÉ POUR RAPIDITÉ : */
      if (!fadings[id] || fadings[id] == "") fadings[id] = "out";
      if (fadings[id] == "out") {
       if (element = $(id)) {
          if (op < min) op=min;
          if (IEfader)
            element.style.filter = "alpha(opacity="+op+")";
          else {
            element.style.opacity = (op / 100);
            element.style.MozOpacity = (op / 100);
          }

          if (op==0) element.style.visibility = "hidden";

          if (op>min) setTimeout('fade_out("'+id+'",'+(op-sp)+','+min+','+to+','+sp+');',to);
          else fadings[id] = "";
       }
       else { //sinon attendre...
         setTimeout('fade_out("'+id+'",'+op+','+min+','+to+','+sp+');',115);
      }
     }
   }

   function Traduit(obj,ln) {
     if (obj) {
      for (i in obj.childNodes) {
         Traduit(obj.childNodes[i],ln);
      }
      if (obj.nodeValue) {
       google.language.translate(obj.nodeValue, "fr", ln, function(result) {
        if (!result.error) {
          if (obj)
            obj.nodeValue = result.translation.replace(/&#39;/g,"'").replace(/&quot;/g,'"');    
        }
       });
      }
    }
   }


   var lang_page = 'fr';
   function TraduirePage(ln) {
     if ($('cachette_admin_aj_elem')) alert('Vous ne pouvez pas traduire une page en cours de modification.');
     else {
      lang_page = ln;
      if (page_active < 0 ) {
        /* if ($('cal_ev_pres_contenu')) CalEvSelect(cal_ev_dernier_select);
         if ($('sommaire_cal_ev').style.display == "block") {
            AfficheCalEvSommaire(cal_ev_sommaire_type);
            if (ln != 'fr') Traduit($('sommaire_cal_ev'),ln)
         }*/
      }
      else {         
         if (article_actif > 0 && cache_art[article_actif]) $('contenu_pages').innerHTML = cache_art[article_actif];
         else if (cache_pages[page_active]) $('contenu_pages').innerHTML = cache_pages[page_active];

         if ($('archives_articles').style.display == "block") {
            $('archives_articles').innerHTML = aa_temp;
            if (ln != 'fr') Traduit($('archives_articles'),ln)
         }
      }
      ColonnesAuto();
      NettoieContenu();
      if (ln != 'fr') Traduit($('contenu_pages'),ln);
     }
   }

   /* ------------------  Fonctions de fenêtres "génériques"..  ------ */
    function Ouvrir(id) {
      if (!IEfader)
        fade_in(id,0,100);
      $(id).style.display = "block";
    }

    function Fermer(id) {
      if (!IEfader)
        fade_out(id,70,0);
      else $(id).style.display = "none";
    }


/* ------------------  Fonction de base pour capture / drag de la souris..  ------ */

   var nowX = 0;
   var nowY = 0;
   var curr_z = 200;

   var sourisX1 = 0;
   var sourisY1 = 0;
   var objX1 = 0;
   var objY1 = 0;
   var initialise = false;

   function getMouseXY(e) {    
      var posX = 0;
      var posY = 0;
      var e = (!e) ? window.event : e;
      if (e.pageX || e.pageY) {
         posX = e.pageX;
         posY = e.pageY;
      }
      else if (e.clientX || e.clientY) {
         if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            posX = e.clientX + document.body.scrollLeft;
            posY = e.clientY + document.body.scrollTop;
         }
         else {
            posX = e.clientX + document.documentElement.scrollLeft;
            posY = e.clientY + document.documentElement.scrollTop;
         }
      }
      nowX = posX;
      nowY = posY;    
   }

   /* onmousemove appelle toujours getMouseXY, */
   /* pour s'assurer que lorsqu'on commence un drag, on a une valeur de nowX et nowY valide */   
   document.onmouseup = function() {
       document.onmousemove = function(e) { getMouseXY(e); }       
   }
   document.onmousemove = function(e) { getMouseXY(e); }

    function drag(id) {
       obj = $(id);
       obj.style.zIndex = curr_z++;
       /* initialise les positions relatives au début du drag */
       sourisX1 = nowX;
       sourisY1 = nowY;
       objX1 = obj.offsetLeft;
       objY1 = obj.offsetTop;
       /* redéfinis la fonction temporairement (jusqu'à "onmouseup") */
       document.onmousemove = function(e) {
           getMouseXY(e);
           newX = (objX1-sourisX1+nowX);
           newY = (objY1-sourisY1+nowY);
           obj.style.left = newX+"px";
           obj.style.top = newY+"px";
       }
   }


   /* ------------------  Fin des fonctions de capture de la souris..  ------ */


/* ---------------------------------------------------------------
 *
 *          Fonctions ALBUM PHOTOS
 *
 * -------------------------------------------------------------*/

var album_page_active = "";
var album_photo_active = "";
var album_page_back_admin = "";
var album_photo_back_admin = "";

function AfficheAlbumThumbs(idalbum) {
   album_page_back_admin = "";
   if ( $('album_pres_thumbs')) {
     //window.scroll(0,0);
     $('album_pres_thumbs_titre').innerHTML = $('album_titre_page_'+idalbum).innerHTML;

     if (album_page_active != idalbum) {
       // patch pour historique, pas grave puisque bouton non clicable lorsque sélectionné !
        if (album_page_active != "" && $('album_thumbs_page_'+album_page_active))
            $('album_thumbs_page_'+album_page_active).style.display = "none";
        album_page_active = idalbum;

        if (obj = $('album_thumbs_page_'+idalbum)) {
           Ouvrir('album_thumbs_page_'+idalbum);
           for (i in obj.childNodes) {              
              if (obj.childNodes[i].className == "album_thumbs") {
                temp = obj.childNodes[i];
                tid = temp.id.substring(12);
                if (temp.childNodes[0].childNodes[1].innerHTML.replace(/\s/g,'') == "") {
                 nouvelle = '<img src="'+$('album_photo_tsrc_'+tid).innerHTML+'" onload="AjusteThumb(this);" />';
                 temp.childNodes[0].childNodes[1].innerHTML = nouvelle;
                  }
              }
           }
        }

     }

   }
}
function AjusteThumb(th) {
   w = th.width;
   if (w > 0 && w < 125) {
      th.parentNode.parentNode.style.width = w+"px";
      th.parentNode.parentNode.style.marginLeft = ((125-w)/2)+"px";
   }
}

var effacer_photo = false;
var ap_start_x = 150;
var ap_start_y = 150;

function AfficheAlbumPhoto(idphoto) {
    ap_start_x = nowX-250;
    ap_start_y = nowY-200;

  album_photo_back_admin = "";
  if (!effacer_photo) {
   histo_iframe = false;
   AjusteFiltre();
   if ($('overlay_filtre').style.display != 'block') {
      fade_in("overlay_filtre",0,70);
      $('overlay_filtre').style.display = 'block';
   }
   fadings['loading_img'] = "in";
   fade_in('loading_img',0,100);


   if ( $('album_pres_photo') && $('album_photo_src_'+idphoto)) {
     if (album_photo_active != idphoto) {
       $('album_pres_photo').style.visibility = "hidden";       
       //fade_out('album_pres_photo',10,0);
       album_photo_active = idphoto;
       $('album_pres_prec').innerHTML = "";
       $('album_pres_suiv').innerHTML = "";

       thumb = $('album_thumb_'+idphoto);
       if ((prev = thumb.previousSibling) && prev.id !== undefined) {
         $('album_pres_prec').innerHTML = '<img src="images/Fleche_gauche_album.gif"  style="width:45px; position:absolute; top:30px; left:40px; z-index:150;" />'+prev.innerHTML;
         idprev = prev.id.substring(12);
         $('album_pres_prec').onclick = function() {
            $('album_pres_conteneur').style.display = 'none';
            AfficheAlbumPhoto(idprev);
         }
         $('album_pres_prec').style.display = 'block';
       } else $('album_pres_prec').style.display = 'none';
       if ((next = thumb.nextSibling) && next.id !== undefined && next.className != "clearing") {
         $('album_pres_suiv').innerHTML = '<img src="images/Fleche_droite_album.gif" style="width:45px; position:absolute; top:30px; left:40px; z-index:150;" />'+next.innerHTML;
         idnext = next.id.substring(12);
         $('album_pres_suiv').onclick = function() {
            $('album_pres_conteneur').style.display = 'none';
            AfficheAlbumPhoto(idnext);
         }
         $('album_pres_suiv').style.display = 'block';
       } else $('album_pres_suiv').style.display = 'none';
       
        $('album_pres_titre').style.display = "none";
        $('album_pres_contenu').style.display = "none";

       $('album_pres_titre').innerHTML = $('album_photo_titre_'+idphoto).innerHTML;
       $('album_pres_photo').innerHTML = '<img id="app" src="'+$('album_photo_src_'+idphoto).innerHTML+'" onload="AlbumPhotoLoaded();" onmousedown="return false;" ondrag="return false;" />';

       //setTimeout("fade_in('album_pres_photo',0,100);",200); // puisque juste l'image, IE AUSSI, donc fade_in sans "ouvrir" ! :)

       $('album_pres_contenu').innerHTML = $('album_photo_contenu_'+idphoto).innerHTML;
     }
     else AlbumPhotoLoaded();
   }
  }
}

var apv = 0;
function ap(v,ang,w1,h1) {
  if (p =  $('app')) {
    i = Math.sin(ang);
    if (ang > 1.66 || IEfader) i=1;
    if (i<1) {
        p.style.width = Math.ceil(i*w1)+"px";
        p.style.height =  Math.ceil(i*h1)+"px";
        inc = 1.0;
        if (v==apv) setTimeout("ap("+v+","+(ang+inc)+","+w1+","+h1+");",70)
    }
    else {
        p.style.width = w1+"px";
        p.style.height = h1+"px";

        $('album_pres_titre').style.width = w1+"px";
        $('album_pres_contenu').style.width = w1+"px";
        if (!IEfader) {
            fade_in('album_pres_titre',30,100);
            fade_in('album_pres_contenu',30,100);
        }
        $('album_pres_titre').style.display = "block";
        $('album_pres_contenu').style.display = "block";
    }

    c = $('album_pres_conteneur');
    l = apCL - c.offsetWidth;
    if (l<0) l = 15;
    t = apCT - c.offsetHeight;
    if (t<0) t = 15;
    c.style.top = ap_start_y - i*(ap_start_y - (apSY+t/2))+"px";
    c.style.left = ap_start_x - i*(ap_start_x - (apSX+l/2))+"px";
  }
}

var apCL = 0;
var apCT = 0;
var apSY = 0;
var apSX = 0;
function AlbumPhotoLoaded() {
   p =  $('app');
   $('album_pres_conteneur').style.display = "inline";

   apv++;
   apCL = getClientSize()[0];
   apCT = getClientSize()[1];
   apSY = getScrollXY()[1];
   apSX = getScrollXY()[0];
   ap(apv,1.4,p.width,p.height);

   delai = 20;
   if (IEfader) delai = 90;
   $('album_pres_photo').style.display = "block";
   $('album_pres_photo').style.visibility = "visible";
   //setTimeout("fade_in('album_pres_photo',0,100,60,90);",delai);
   fadings['loading_img'] = "out";
   fade_out('loading_img',30,0);
}

function FermeAlbumPhoto() {
   $('album_pres_conteneur').style.display = 'none';
   $('overlay_filtre').style.display = 'none';
   fade_out('album_pres_photo',10,0);
   /*fade_out("overlay_filtre",70,0);*/

   if ($('div_modifier_album_photo') && $('div_modifier_album_photo').style.display=="block") {
      Annuler('div_modifier_album_photo');
   }
   histo_iframe = true;
}

   /* ------------------  Fin des fonctions de l'album photo..  ------ */


/* ---------------------------------------------------------------
 *
 *          Fonctions du MENU DES CATÉGORIES
 *
 * -------------------------------------------------------------*/

var menu_cat_hauteurs = Array();
var pompe_cat = Array();
var sens_cat = Array();
var menu_cat_ouvert = -1;

function OuvreCat(cat) {

  $('menu_cat'+cat).style.display = "block";

  //go_sousmenu = false;
  if (!menu_cat_hauteurs[cat]) { // initialisation
     menu_cat_hauteurs[cat] = $('menu_cat'+cat).scrollHeight;
     pompe_cat[cat] = 10;
  }
  if (menu_cat_ouvert >= 0) { // pas déjà en train de se fermer...
     sens_cat[menu_cat_ouvert] = 0;
     EnrouleCat(menu_cat_ouvert,70,15);
     //$('titre_cat'+menu_cat_ouvert).style.color = "#ffffff";
     Enlever(sm_actif);
  }
     
  if (cat != menu_cat_ouvert) {
     //alert("Ouvre : "+cat+"\nHauteur : "+menu_cat_hauteurs[cat]);
     sens_cat[cat] = 1;
     menu_cat_ouvert = cat;
     DerouleCat(cat,70,60);
     //$('titre_cat'+cat).style.color = "#000000";
  }
  else menu_cat_ouvert = -1;    
}

function DerouleCat(cat,ms,dy) {
 if (sens_cat[cat] == 1) {
    $('menu_cat'+cat).style.height = menu_cat_hauteurs[cat]+"px";
    $('menu_cat'+cat).style.overflow = "visible";
 }
/*
  if ((pompe_cat[cat] + dy) >= menu_cat_hauteurs[cat]) {
    $('menu_cat'+cat).style.height = menu_cat_hauteurs[cat]+"px";
    $('menu_cat'+cat).style.overflow = "visible";
    //go_sousmenu = true;
  }
  else {
      $('menu_cat'+cat).style.overflow = "hidden";
      //alert('DérouleCat = '+pompe_cat[cat]);

      //inclure acceleration ou ralentissement...
      if (dy > 18) dy-= 1;
      pompe_cat[cat] = pompe_cat[cat] + dy;
      $('menu_cat'+cat).style.height = pompe_cat[cat]+"px";
      setTimeout("DerouleCat("+cat+","+ms+","+dy+");",ms);
  }
    */
}

function EnrouleCat(cat,ms,dy) {
  /* si le menu est DÉJÀ OUVERT avant javascript (display : block)! */
  /*if (!menu_cat_hauteurs[cat]) { // initialisation
     menu_cat_hauteurs[cat] = $('menu_cat'+cat).scrollHeight;
     pompe_cat[cat] = menu_cat_hauteurs[cat];
  }
*/
 if (sens_cat[cat] == 0)
  if ((pompe_cat[cat] - dy) <= 0) {
      $('menu_cat'+cat).style.display = "none";
  }
  else {
      $('menu_cat'+cat).style.overflow = "hidden";
     //alert('EnrouleCat = '+pompe_cat[cat]);
     //
      //inclure acceleration ou ralentissement...
      if (dy < 40) dy+= 4;
      pompe_cat[cat] = pompe_cat[cat] - dy;
      $('menu_cat'+cat).style.height = pompe_cat[cat]+"px";
      setTimeout("EnrouleCat("+cat+","+ms+","+dy+");",ms);
  }
}


/* ---------------------------------------------------------------
 *
 *          Fonctions des MENU DÉROULANT DE PAGES
 *
 * -------------------------------------------------------------*/

var sm_actif = "aucun";
var sm_ancien = "aucun";
//var sh=0;
var pompe = 1;              // menu déroulants: contourne des petits problèmes (diff. IE vs FIREFOX)..

var last_padtop = 0;
var last_padbot = 0;
var hauteurs = Array();
//var go_sousmenu = true;

function MsiOver(obj,s) {
 obj.out = false;
 Apparait(s);
}
function MsiOut(obj) {
 obj.out = true;
 setTimeout("Enlever(sm_actif);",100);
}

function Enlever(Sousmenu) {
  //Sousmenu = "sm_"+sect;
  if ($(Sousmenu) && $(Sousmenu).parentNode.out && $(Sousmenu).style.display=="block") {
     $(Sousmenu).style.visibility="hidden";
     $(Sousmenu).style.display="none";
     $(Sousmenu).parentNode.style.color="#000000";
     $(Sousmenu).parentNode.style.backgroundColor="transparent";
     $(Sousmenu).parentNode.style.cursor="pointer";
     $(Sousmenu).parentNode.style.zIndex="1";
     $(Sousmenu).parentNode.active = false;
     $(Sousmenu).parentNode.parentNode.style.padding = "0px";
  }  
}
function Apparait(sect) {  
  Sousmenu = "sm_"+sect;
  if (Sousmenu != sm_actif) { //&& go_sousmenu
    Enlever(sm_actif);
  }   
    if ($(Sousmenu)) {      
      sm_actif = Sousmenu;
      /* mettre en commentaire pour enlever l'effet déroulant : */
      if ($(Sousmenu).style.visibility != "visible") {
        $(Sousmenu).style.visibility="visible";
        $(Sousmenu).style.display="block";
        $(Sousmenu).parentNode.style.color="#ffffff";        
        $(Sousmenu).parentNode.style.backgroundColor="#d00040";
        $(Sousmenu).parentNode.style.cursor="default";
        $(Sousmenu).parentNode.style.zIndex="10";
        $(Sousmenu).parentNode.active = true;
        
        if (!hauteurs[Sousmenu])
           hauteurs[Sousmenu] = $(Sousmenu).scrollHeight;

        maxy = hauteurs[Sousmenu];
        pompe = 20;
        last_padtop = last_padbot = 0;
        $(Sousmenu).style.height = pompe+"px";
        //sh = $(Sousmenu).parentNode.parentNode.scrollHeight;
        // les vitesse sont différentes selon les navigateurs
        // premier chiffre : milisecondes entre les rafraichissements
        // deuxième chiffre : nombre de pixel qu'on agrandit à chaque rafraichissements
        if (IEfader) {
             Deroule(Sousmenu,240,maxy-2);
         }
         else {
             Deroule(Sousmenu,240,maxy);
             /*fade_in(Sousmenu,70,100);*/
         }
         
      }
    	
    }
  
}

function Deroule(Sousmenu,dy,maxy) {
    Numero = Sousmenu;    
    deltay = dy+120;//dy+12; // accélération !
    max = maxy;
    
    if ((pompe + dy) >= maxy) {
        pompe = maxy;
    }
    else {
        pompe = pompe+dy;
    }
    sm = $(Sousmenu);
    //patch = sm.parentNode.scrollHeight; // ne fonctionne pas pour safari non plus.. ?
    //if (isMSIE && !IE6) // ne fonctionne pas pour IE8 en tout cas...
        patch = 22; 

    ntop = Math.ceil((pompe-patch)/2);
    sm.style.top = (-ntop)+"px";
    sm.style.height = pompe+"px";
/*
     test = ntop - sm.parentNode.offsetTop;
     if (test > 0) {         
         last_padtop += test+6; // jeu supplémentaire, bouge moins souvent
         sm.parentNode.parentNode.style.paddingTop = last_padtop+"px";                
     }
     
     test = (ntop + sm.parentNode.offsetTop + patch) - sm.parentNode.parentNode.scrollHeight;// - sh;
     //alert((ntop + sm.parentNode.offsetTop + patch) +" "+ sm.parentNode.parentNode.scrollHeight);
     if (test > 0) {         
         last_padbot += test+6;
         sm.parentNode.parentNode.style.paddingBottom = last_padbot+"px";
         //alert('test');
     }
*/
    if (pompe < maxy) {setTimeout("Deroule(Numero,deltay,max)",65);}
}

function AjusteFiltre() {
   if (filtre = $("overlay_filtre")) {
      cl = getClientSize();
      sc = getScrollXY();

      filtre.style.width = (cl[0])+ "px";
      filtre.style.height = (cl[1])+ "px";
      filtre.style.left = (sc[0])+'px';
      filtre.style.top = (sc[1])+'px';

   }
}
window.onresize = function() {
   AjusteFiltre();
}
window.onscroll = function() {
   AjusteFiltre();
}



function Deconnecter() {
  if (CheckEdition()) {
      window.location.href = "zen_login.php?logout";
  }
}

function AlterneOptionsVisiteur() {
   if ($('options_visiteur').style.display!='block') {
      $('options_visiteur').style.display='block';
   }
   else {
      $('options_visiteur').style.display='none';
   }
}


function Imprimer() {
   window.open('print.php?p='+page_active);
}

/* *******************************************************
 *    Fonctions pour AJAX
 *
 * ******************************************************* */
var edition_active = false;
var efface_msg_admin = true;

function CheckEdition() {
   if ($("msg_admin") && efface_msg_admin)
     $("msg_admin").innerHTML = "&nbsp;";
   efface_msg_admin = true;
   
   if (edition_active) {
      if (est_admin) {
         alert("Vous devriez finir ce que vous avez commencé !\nEnregistrez ou annulez vos modifications puis ré-essayez.");
         $("msg_admin").innerHTML = "Finissez ou annulez ce que vous êtes en train de faire.";
      }
      else
         alert("Vous êtes déjà en train de changer de page,\n veuillez patienter un moment...");
      return false;
   }
   else {
      edition_active = true;
      return true;
   }
}

function Highlight(obj,rexp) {  
  if ($('check_highlight').checked && obj && obj.className != "zen_light" && !$('cachette_admin_aj_elem')
      && !(obj.id && obj.id.substring(0,5) == "album")) {
   nb = 0;
   for (i in obj.childNodes) {
      nb++;
      Highlight(obj.childNodes[i],rexp);
   }
   if (!IEfader) {
     if (nb == 0 && obj.nodeValue && rexp.test(obj.nodeValue)) { // fonctionne pour firefox, sans boucles inutiles ou infinies...
      if (obj.parentNode && obj.parentNode.className != "zen_light" && obj.parentNode.innerHTML.indexOf('zen_light') == -1) {
        temp = obj.parentNode.innerHTML.replace(rexp,'<u class="zen_light">$&</u>');
        obj.parentNode.innerHTML = temp;        
      }
     }
   }
   else {
     if (nb == 1 && obj.nodeValue && rexp.test(obj.nodeValue)) {// fonctionne pour IE ???...
      if (obj.parentNode && obj.parentNode.className != "zen_light" && obj.parentNode.innerHTML.indexOf('zen_light') == -1) {
        temp = obj.parentNode.innerHTML.replace(rexp,'<u class="zen_light">$&</u>');
        obj.parentNode.innerHTML = temp;
      }
     }
   }
  }
}

var ajaxContenu = new Ajax();

function NettoieContenu() {
   var cp = $("contenu_pages");
   for (i in cp.childNodes) {
     var child = cp.childNodes[i];
     if (child && child.tagName == 'DIV') {
        vide = true;
        if (child.className == "colonnes") {          
          for (j in child.childNodes) {
             col = child.childNodes[j];             
             if (col.tagName == 'DIV') {
               if (col.innerHTML.replace(' ','').length > 0)
                vide = false;
               else
                col.style.display = 'none';
             }
             if (!IE6 && col.className == 'colonne_droite_petite' && !vide) 
                col.innerHTML = '<div class="ombre_div_bg"><div class="ombre_bg ombre_n"></div><div class="ombre_bg ombre_ne"></div><div class="ombre_bg ombre_e"></div><div class="ombre_bg ombre_se"></div>         <div class="ombre_bg ombre_s"></div><div class="ombre_bg ombre_sw"></div><div class="ombre_bg ombre_w"></div><div class="ombre_bg ombre_nw"></div></div><div class="dessus_ombre">'
                                +col.innerHTML+'</div>';
          }                    
        }
        else if (child.innerHTML.replace(' ','').length > 0) vide = false;
        
        if (vide) {
          child.style.display = 'none';            
        }
     }     
   }
}

var showContenu = function(str) {
  lang_page = 'fr';
  $("cherche_contenu").style.display = 'none';
  
  edition_active = false;
  $("contenu_pages").innerHTML = str;
  if ($('time_up')) window.location.href="zen_login.php";

  if (est_admin) SwapAdminOptions();

  q = '';
  if (!q_cc_vide)
   q = $('q_cc').value;

  if (q.replace(/\s{1,}/g,'').length > 2) {
      question = PrepareQ(q);
      Highlight($("contenu_pages"),question);
  }

  if (!IEfader) {
      fadings['contenu_pages'] = "in"; // stop explicitement le fade-out ! :)
      fade_in('contenu_pages',20,100);
  }
  /*fadings['sablier'] = "out";
  fade_out('sablier',60,0);*/

  
  p = page_active;
  titre = liste_sect[liste_ts[p][3]];
 // $('option_URL').value = url_base+liste_fp[p]+'.php';
  if (art_p != p) {
     if (titre != liste_ts[p][1]) titre += " - "+liste_ts[p][1];
     article_actif = 0;
     if (!est_admin && !cache_pages[page_active])
        cache_pages[page_active] = str;
  }
  else {
    getArchivesArticles(); 
    if (article_actif > 0) {
       titre += " - "+$('titre_article').innerHTML;
       $('option_URL').value += '?art='+article_actif;
       if (!cache_art[article_actif])
        cache_art[article_actif] = str;
    }
    else {
       if (!cache_pages[page_active])
        cache_pages[page_active] = str;
    }
  }

  document.title = (est_admin?'ADMIN - ':'')+titre_site+" - "+titre;

  if (est_admin) {
     PlaceAdminGenerale();
     if ($('admin_sections')) ChangeAdminSections(cat_active);
     //if ($('admin_pages')) ChangeAdminPages(section_active); // inclus dans ChangeAdminSections ?
  }


  effacer_photo = false;
  setTimeout("ColonnesAuto();",90);
  setTimeout("NettoieContenu();",160);

  if ($('album_premiere_page')) {
    if (album_page_back_admin == "") {
      setTimeout("AfficheAlbumThumbs($('album_premiere_page').innerHTML);",250);
      //AfficheAlbumPhoto($('album_premiere_photo').innerHTML);
    }
    else {
      setTimeout("AfficheAlbumThumbs(album_page_back_admin);",250);
      if (album_photo_back_admin != "")
         setTimeout("AfficheAlbumPhoto(album_photo_back_admin);",350);     
    }
  }

  if (IE6 && !est_admin) supersleight.run();
}

var ajaxRegistre = new Ajax();
var backRegistre = function(str) {
    //'<a href="javascript:;" onclick="$(\'registre_utilisateurs\').style.display=\'none\'; $(\'start_registre\').style.display=\'block\';">fermer la liste</a>'
    RegistreTimer();
    $('registre_utilisateurs').innerHTML = str;
    //if ($('registre_utilisateurs').style.display!="none")
    //    setTimeout('getRegistre();',20000);
}
var timer_width = -1;
function RegistreTimer() {
  if (timer_width > 0) {
    $('registre_timer').style.width=timer_width+'px'; timer_width-=2; setTimeout("RegistreTimer();",220);
  }
  else getRegistre();

}
function getRegistre() {
    if (timer_width <=0) { timer_width = 190; $('registre_timer').style.display="block";}
    ajaxRegistre.doGet('zen_registre.php',backRegistre);
}

var ajaxHisto = new Ajax();
var backHisto = function(str) {
    //rien à faire
}
function getContenuPatch(p) { /* Patch pour l'historique (retour du iframe..) */

   window.scroll(0,0);
   c = liste_ts[p][2];
   s =  liste_ts[p][3];

   cat_active = c;
   section_active = s;
   page_active = p;

   album_page_active = "";
   album_photo_active = "";
   art = ""
   if (article_actif != "") art = "&art="+article_actif;
   if (p == art_p) {
      if (art == "") art = "&art=0";
   }
   else {
       article_actif = "";
       $('archives_articles').style.display = "none";
   }

   bp = "";
   if (est_admin) {
      bp = adbp; adbp = "";
      ajaxContenu.doGet('zen_contenu_pages.php?p='+p+art+bp, showContenu);   
   }
   else {
      if ((p != art_p || art == "&art=0") && cache_pages[p]) {         
         showContenu(cache_pages[p]);
         //alert('cache..');
         ajaxHisto.doGet('zen_historique.php?session=1&p='+p+art,backHisto);
      }
      else if (article_actif > 0 && cache_art[article_actif]){
         showContenu(cache_art[article_actif]);
         //alert('cache article..');
         ajaxHisto.doGet('zen_historique.php?session=1&p='+p+art,backHisto);
      }
      else
        ajaxContenu.doGet('zen_contenu_pages.php?p='+p+art+bp, showContenu);

      try { pageTracker._trackPageview(liste_fp[p]+'.php'+art);  } catch(err) {}
   }

   
   if (!IEfader) {
      fade_out("contenu_pages",94,10);
   }

}

var alterne_img = 0;
var histo_iframe = true;
var capture_lien = false;

function getContenu(p) {

 if (est_admin || page_active != p || (art_p && p == art_p)) {
  if (capture_lien) {CaptureLien(p);}
  else if (CheckEdition()){
   histo_iframe = false;
   $('iframe_historique').src='zen_historique.php?p='+p;
   if (p == art_p) article_actif = 0;
   getContenuPatch(p);
  }
 }
}

var dernier_q_cc = "_rien_";
function PrepareQ(q) {
    /*expérimental...*/
   /*q = q.replace(/[^a-z]d[eu]s* /gi," ");
   q = q.replace(/[^a-z]l[ea]s* /gi," ");
   q = q.replace(/[^a-z][cç]a /gi," ");*/

   q = q.replace(/[eéèêë]/gi,"[eéèêë]");
   q = q.replace(/[aàâä]/gi,"[aàâä]");
   q = q.replace(/[iîï]/gi,"[iîï]");
   q = q.replace(/[oôö]/gi,"[oôö]");
   q = q.replace(/[uùûü]/gi,"[uùûü]");
   q = q.replace(/[cç]/gi,"[cç]");
   q = q.replace(/^[\s,;:!\.?+]+/g,'').replace(/[\s,;:!\.?+]+$/g,'');
   return new RegExp("("+q.replace(/[\s,;:!\.?+]+/g,")|(")+")","ig");
}


var ajaxChercheContenu = new Ajax();
var showChercheContenu = function(str) {
   $('cherche_contenu').innerHTML = str;
   if ($('cherche_contenu').style.display != "block")
      Ouvrir('cherche_contenu');
      
      question = "";
      result = new Array();

      nb_res = 0;
      if ($('rcpt')) {
         for (p in liste_ts)
            if ($('rcc'+p)) {
               result[nb_res] = new Array(liste_sect[liste_ts[p][3]],liste_ts[p][0],p,0);
               nb_res++;
            }
      }
      else {
         question = PrepareQ(dernier_q_cc);
         for (p in liste_ts) {
            s_test = liste_sect[liste_ts[p][3]]+" "+liste_ts[p][0]+" "+liste_ts[p][1];
            if ($('rcc'+p) || s_test.search(question) > -1) { // checker noms fichier aussi ? || question.test(liste_fp[c][i][j])
               result[nb_res] = new Array(liste_sect[liste_ts[p][3]],liste_ts[p][0],p,0);
               nb_res++;
            }
         }
         
         for (p in liste_le) {
            s_test = liste_le[p][0]+" "+liste_sect[liste_le[p][3]];
            if (s_test.search(question) > -1) {
               result[nb_res] = new Array(liste_sect[liste_le[p][3]],liste_le[p][0],p,1,liste_le[p][1]);
               nb_res++;
            }
         }
          
        

      }

      lst = "<ul>";
      
      result.sort();
      last_titre = "";
      for (p in result) {
        if (last_titre != result[p][0]) {
           last_titre = result[p][0];
           nb_res++;
        }
      }


      nb_div = Math.ceil(nb_res / 3);
      if (nb_div<3) nb_div=3;
      i = 0;
      last_titre = "";
      cols = 1;
      next = nb_div;
      for (p in result) {
         if (i>0 && (i > next) && (cols < 3)) {
            lst += "</ul><ul>";
            cols++;
            next += nb_div;
            // RÉPÉTER LE TITRE SI ON CHANGE DE COLONNE...
            if (last_titre == result[p][0]) {
               lst += "<p>"+last_titre+"</p>";
            }
         }
         if (last_titre != result[p][0]) {
            last_titre = result[p][0];
            lst += "<p>"+last_titre+"</p>";
            i++
         }
         i++;
         if (result[p][3] == 0)
            lst += '<li class="cmr_int" onmouseover="this.className=\'cmr_int_over\';" onmouseout="this.className=\'cmr_int\';" onclick="getContenu('+result[p][2]+');">'+result[p][1]+'</li>';
         else
            lst += '<li class="cmr_ext" onmouseover="this.className=\'cmr_ext_over\';" onmouseout="this.className=\'cmr_ext\';" onclick="window.open(\''+result[p][4]+'\',\'_BLANK\')">'+result[p][1]+'</li>';

      }

      lst += "</ul>";
      if (nb_res == 0) lst = "<h4 style='text-align:center;'>Aucun résultats</h4>";
      
      $('cherche_contenu_resultats').innerHTML += lst;
      if (question != "") Highlight($('cherche_contenu_resultats'),question);

}

var pa_cc = -1;
function ChercheContenu(q) {
 if (!q_cc_vide && !edition_active) {
  /* FermeCalEv();// répété dans getArchivesArticles... */
  if (q.replace(/\s{1,}/g,'').length > 2) {
   if (q == dernier_q_cc) {
    if ($('cherche_contenu').style.display != "block")
      Ouvrir('cherche_contenu');
   }
   else {
      q_ajax = encodeURIComponent(q);
      ajaxChercheContenu.doGet('zen_cherche_contenu.php?q='+q_ajax, showChercheContenu);
      dernier_q_cc = q;    
   }
   getArchivesArticles(q);
   pa_cc = page_active;
   page_active = -1;
   article_actif = -1;
   $("contenu_pages").innerHTML = "";
   /*$("sommaire_cal_ev").style.display='none';*/
  }
  else {
       $('cherche_contenu').innerHTML = '<div style="padding: 4px; position:relative;">'+
'<img style="cursor : pointer; position:absolute; top: 2px; right: 2px; width:24px; z-index : 10;" onclick="FermerChercheContenu();" src="images/fermer.png" title="Fermer la recherche" />'+
'<h2>Entrez au moins trois lettres pour chercher dans tout le site</h2></div><div class="cherche_contenu_resultats"></div>';
       if ($('cherche_contenu').style.display != "block")
         Ouvrir('cherche_contenu');
   }
 }
}
function FermerChercheContenu() {
   $('cherche_contenu').style.display='none';
   if (page_active == -1) getContenu(pa_cc);
}

var q_cc_vide = true;
function cc_blur(obj) {
   if (obj.value == "") {
      obj.style.color = "#999999";
      obj.style.fontStyle = "italic";
      obj.value = "Chercher dans le contenu";
      q_cc_vide = true;
   }
}
function cc_click(obj) {
   if (q_cc_vide) {
      obj.style.color = "#000000";
      obj.style.fontStyle = "normal";
      obj.value = "";
      q_cc_vide = false;
   } else obj.select();
}

var dernier_q_art = "_toutes_";
var aa_temp = "";

var ajaxArticles = new Ajax();
var showArchivesArticles = function(str) {
   $('archives_articles').innerHTML = str;
   aa_temp = str;
   $('archives_articles').style.display = "block";
   q = dernier_q_art;
   
   if (q.replace(/\s{1,}/g,'').length > 2 && q != '_toutes_') {      
      question = PrepareQ(q);
      Highlight($('archives_articles'),question);
   }
}
function getArchivesArticles(q){
   /*FermeCalEv();*/
   if (q === undefined) {
      q = "_tous_";
      if ($('q_art')) {
       test = $('q_art').value;
       if (test != "") q = test;
      }
   }
   
   if (dernier_q_art != q || $('archives_articles').innerHTML == "") {
      
      if ($('bouton_q_art')) {
         $('q_art').value  = q;
         $('bouton_q_art').value='recherche...';
         $('bouton_q_art').disabled=true;
      }
      else $('archives_articles').innerHTML = "<h2>Recherche dans les archives...</h2>";
      q_ajax = encodeURIComponent(q);
      // n'est chargé que lorsqu'on en a besoin...
      ajaxArticles.doGet('zen_archives_articles.php?q='+q_ajax, showArchivesArticles);
   }
   
   if ($('archives_articles').style.display != "block")
      Ouvrir('archives_articles');

   dernier_q_art = q;

}

function getArticle(art){
 if (est_admin || art == 0 || art != article_actif) {
  if (capture_lien) {CaptureLien(art_p,art);}
  else if (CheckEdition()){  
   histo_iframe = false;
   $('iframe_historique').src='zen_historique.php?p='+art_p+'&art='+art;
   article_actif = art;
   if (art==0 && $('q_art')) $('q_art').value = ""; //enleve la recherche si on fait "tout voir"
   getContenuPatch(art_p);
  }
 }
}



function ChangeOnglet(id,prefix) {
 if (prefix === undefined) prefix = "";
 if (!edition_active) {
   if ($(prefix+'onglet_actif')) {
      ferme = $(prefix+'onglet_actif').innerHTML;
      $(prefix+'onglet_actif').innerHTML = id;
      if (ferme != id) {

         $(prefix+'onglet_'+ferme).style.display = "none";
         $(prefix+'menu_onglet_'+ferme).className = "";
         $(prefix+'menu_onglet_'+id).className = "onglet_selection";
         Ouvrir(prefix+'onglet_'+id);
      }
   }
 }
}

function ChangeVOnglet(id, prefix) {
 if (prefix === undefined) prefix = "";
 if (!edition_active) {
   if ($(prefix+'vonglet_actif')) {
      ferme = $(prefix+'vonglet_actif').innerHTML;
      $(prefix+'vonglet_actif').innerHTML = id;
      if (ferme != id) {

         $(prefix+'vonglet_'+ferme).style.display = "none";
         $(prefix+'menu_vonglet_'+ferme).className = "";
         $(prefix+'menu_vonglet_'+id).className = "vonglet_selection";
         Ouvrir(prefix+'vonglet_'+id);
      }
   }
 }
}


var menu_q_vide = true;

function ChercheMenu() {
   if (menu_q_vide) {
      $('cherche_menu_q').value = "";
      $('cherche_menu_q').style.color = "#000000";
      $('cherche_menu_q').style.fontStyle = "normal";
      menu_q_vide = false;
   }
   q = $('cherche_menu_q').value;
   $('cherche_menu_resultats').innerHTML = "";
   //$('contenu_pages').innerHTML = "";
   if (q != '') {
      
      question = PrepareQ(q);
      result = new Array();      
      nb_res = 0;
      for (p in liste_ts) {
         s_test = liste_sect[liste_ts[p][3]]+" "+liste_ts[p][0]+" "+liste_ts[p][1];
         if (s_test.search(question) > -1) { //question.test(s_test) -> pour une raison X, skip des résultats !
            result[nb_res] = new Array(liste_sect[liste_ts[p][3]],liste_ts[p][0],p,0);
            nb_res++;
            //$('contenu_pages').innerHTML += "<b><u>"+nb_res+"</u></b> - ";
         }
         //$('contenu_pages').innerHTML += s_test+"<br />";
      }
      for (p in liste_le) {
         s_test = liste_le[p][0]+" "+liste_sect[liste_le[p][3]];
         if (s_test.search(question) > -1) {
            result[nb_res] = new Array(liste_sect[liste_le[p][3]],liste_le[p][0],p,1,liste_le[p][1]);
            nb_res++;
         }
      }
      /*for (p in liste_le) {
        if (question.test(liste_le[p][0]+" "+liste_sect[liste_le[p][3]])) {            
            result[nb_res] = new Array(liste_sect[liste_le[p][3]],liste_le[p][0],p,1,liste_le[p][1]);
            nb_res++;
            $('contenu_pages').innerHTML += "<b>"+nb_res+"</b> - ";
         }
         $('contenu_pages').innerHTML += s_test+"<br />";
      }*/

      lst = "<ul>";
      if (nb_res == 0) lst += "<h4 style='text-align:center;'>Aucun résultats</h4>";
      result.sort();
      last_titre = "";
      for (p in result) {
        if (last_titre != result[p][0]) {
           last_titre = result[p][0];
           nb_res++;
        }
      }

      nb_div = Math.ceil(nb_res / 4);
      if (nb_div<10) nb_div=10;
      i = 0;
      last_titre = "";
      cols = 1;
      next = nb_div;
      for (p in result) {
         if (i>0 && (i > next) && (cols < 4)) {
            lst += "</ul><ul>";
            cols++;
            next += nb_div;
            // RÉPÉTER LE TITRE SI ON CHANGE DE COLONNE...
            if (last_titre == result[p][0]) {
               lst += "<p>"+last_titre+"</p>";               
            }
         }
         if (last_titre != result[p][0]) {
            last_titre = result[p][0];
            lst += "<p>"+last_titre+"</p>";
            i++;
         }
         i++;
         if (result[p][3] == 0)
            lst += '<li class="cmr_int" onmouseover="this.className=\'cmr_int_over\';" onmouseout="this.className=\'cmr_int\';" onclick="getContenu('+result[p][2]+');">'+result[p][1]+'</li>';
         else
            lst += '<li class="cmr_ext" onmouseover="this.className=\'cmr_ext_over\';" onmouseout="this.className=\'cmr_ext\';" onclick="window.open(\''+result[p][4]+'\',\'_BLANK\')">'+result[p][1]+'</li>';

      }
         
      lst += "</ul>";


      $('cherche_menu_resultats').innerHTML += lst;

      $('cherche_menu_resultats').style.display = "block";
      $('cherche_menu_resultats').style.top = (5-$('cherche_menu_resultats').scrollHeight)+"px";
      Highlight($('cherche_menu_resultats'),question);
      //if (!IEfader)
        // fade_in('cherche_menu_resultats',90,90);
   }
   else {
      $('cherche_menu_resultats').style.display = "none";
   }
}


function FermeChercheMenu() {
   if ($('cherche_menu_q').value == "") {
      $('cherche_menu_q').style.color = "#999999";
      $('cherche_menu_q').style.fontStyle = "italic";
      $('cherche_menu_q').value = "Chercher dans le menu";
      menu_q_vide = true;
   }
   setTimeout("$('cherche_menu_resultats').style.display = 'none';",200);

}




var  c1a = 0;
var  c2a = 0;

function ColonnePlace(){
  if ((obj = $('colonnes_auto_cachette').childNodes[0])) {

   c1 = $('ca1');
   c2 = $('ca2');

    if (c1.offsetHeight <= c2.offsetHeight) {          
      c1.appendChild(obj);
      c1.style.display = "block";
    }
    else {      
      c2.appendChild(obj);
      c2.style.display = "block";
    }

    to = 20;
    if (obj.innerHTML && obj.innerHTML.indexOf('<img ') >= 0 ) to = 300; // on laisse plus de temps aux éléments qui contiennent des images !
    setTimeout('ColonnePlace();',to);
  }
}

function ColonnesAuto(){
  if (cc = $('colonnes_auto_cachette')) {
     c1a = 0;
     c2a = 0;
     ColonnePlace(); 
  }
}

ajaxPlainte = new Ajax();
var backPlainte = function(str) {
   if ($('msg_plainte')) {
      if (str=="OK") {
         $('form_plainte').style.display = 'none';
         $('msg_plainte').innerHTML = "<div class='note'>Un courriel a été envoyé à un responsable. Merci d'avoir utilisé ce service.</div>";
      }
      else {
         $('msg_plainte').innerHTML = str;
         $('form_plainte').code.value="";
         $('img_captcha_plainte').src='securimage_show.php?sid='+(Math.random()*1000000000);
      }
   }
}
   

    function ValidePlainte() {
      if (f = $('form_plainte')) {
        message = "";

        if (f.nom.value == "") message += "Vous devez entrer un nom.<br />";

        testc = f.courriel.value;
        testl = testc.length;
        at_pos = testc.indexOf("@");
        dot_pos = testc.lastIndexOf(".");

        if ((testl < 8) || at_pos == null || dot_pos == null || (at_pos < 1) || (dot_pos < (at_pos+2)))
            message += "Vous devez entrer un courriel valide.<br />";

        tel = f.telephone.value;
        len = tel.replace(/[^0-9]/gi,'').length;
        if (len != 10)
           message += "Vous devez un numéros de téléphone valide, à 10 chiffres,<br />par exemple (819) 555-5555 ou encore 8195555555.<br />";

        if (f.objet.value == "") message += "Vous devez entrer un sujet.<br />";

        if (f.description.value == "") message += "Vous devez écrire un commentaire.<br />";


        if (message == "") {
           code = encodeURIComponent(f.code.value);
           //type =  encodeURIComponent(f.type.value);
           nom = encodeURIComponent(f.nom.value);
           courriel = encodeURIComponent(f.courriel.value);
           //adresse = encodeURIComponent(f.adresse.value);
           telephone = encodeURIComponent(f.telephone.value);
           objet = encodeURIComponent(f.objet.value);
           description = encodeURIComponent(f.description.value);
           
           ajaxPlainte.doPost('zen_traite_commentaires.php',
               'plainte_go=1&code='+code+               
               '&nom='+nom+
               '&courriel='+courriel+               
               '&telephone='+telephone+
               '&objet='+objet+
               '&description='+description,backPlainte);
        }
        else {
         message = '<div class="avertissement">'+message+'</div>';
         $('msg_plainte').innerHTML = message;         
        }
      }
    }


/* ********************************************************************************
 *
 *  Animations de l'entête...
 */

var largeur_anim = 0;
//var id_anim = 0;

function ImgAnimLoaded(obj,i) {
    la = largeur_anim;
    largeur_anim += obj.scrollWidth;
    if (isMSIE && !IE6) largeur_anim += 4;
    obj.id = "img_anim"+i;    
    obj.style.left = la+"px";
    obj.position_left = la;
    obj.style.visibility = "visible";
    /*if (la < 1600) fade_in(obj.id,80,100,75,20);
    /* CHANGÉ POUR RAPIDITÉ : opacité de base de 40 à 80*/
}

function LoadEntete() {   
    for (i in img_src) {
       $('animation').innerHTML += '<img src="'+img_src[i]+'" onload=\"ImgAnimLoaded(this,'+i+');\"  onmousedown="return false;" ondrag="return false;" />';
    }
    setTimeout("ChangeEntete();",(Math.random()*7000)+8000);
}

function BougeImgAnim(id,ang,dist) {
    /*if (ang == 0) {
        fadings[id] = "in";
        if (($(id).position_left - dist) < 1600)             
            fade_in(id,40,100,70,20);
    }
    /* CHANGÉ POUR RAPIDITÉ */
    i = Math.sin(ang);
    if (ang >= 1.6) i = 1;
    if (isMSIE && !IE6) {
        dist+=4;
        i = 1;
    }
    pos = $(id).position_left - Math.round(i*dist);
    $(id).style.left = pos+"px";
    
    if (i < 1) /* CHANGÉ POUR RAPIDITÉ ang+0.2 à ang+0.8 */
        setTimeout("BougeImgAnim('"+id+"',"+(ang+1.1)+","+dist+");",90);
    else
       $(id).position_left = pos;
}

var unsorted = true;
function SortImgAnim(anim) {
   var sorted = true;
   //var i=0;
   do {
      sorted = true;
     // i++;
      for (i in anim.childNodes) {
        n = anim.childNodes[i];
        if (n.nextSibling && n.nextSibling.position_left < n.position_left) {
           anim.insertBefore(n.nextSibling,n);
           sorted = false;
          // alert('tour: '+i);
        }
      }
    } while (!sorted)
    unsorted = false;
}

function ChangeEntete(next) {
  if (anim = $('animation')) {
    if (unsorted) SortImgAnim(anim);


    distance = anim.childNodes[0].scrollWidth;
    anim.childNodes[0].style.left = largeur_anim+"px";
    anim.childNodes[0].position_left = largeur_anim;
    anim.appendChild(anim.childNodes[0]);
   
    to = 60;
    for (i in anim.childNodes) {
        n = anim.childNodes[i];
         if (n.id != undefined) {
             /* CHANGÉ POUR RAPIDITÉ */
             /*if (n.position_left < 1700) fade_out(n.id,60,30,90,20);*/
             setTimeout("BougeImgAnim('"+n.id+"',0,"+distance+");",to);
             if (isMSIE && !IE6) to += 240;
             else to += 290;
        }
    }
    if (next === undefined) setTimeout("ChangeEntete();",(Math.random()*21000)+32000);
  }
}

