function $(id) {
   if (document.getElementById(id))
      return document.getElementById(id);
   else return false;
}
function resize_frame(obj) { // resize le div complet pour "suivre"
        obj.style.height = "1px";
        obj.style.height = 120+obj.contentWindow.document.body.scrollHeight+"px";
}

   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 = 60;
     if (sp === undefined) sp = 12;
     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+');',75);
     }
    }

    function fade_out(id,op,min,to,sp) {
      if (to === undefined) to = 65;
      if (sp === undefined) sp = 15;
      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+');',75);
      }
     }
   }


   /* ------------------  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 = 0.18;
        //if (IEfader) inc = 0.3;
        if (v==apv) setTimeout("ap("+v+","+(ang+inc)+","+w1+","+h1+");",60)
    }
    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',40,100);
            fade_in('album_pres_contenu',40,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,0.3,p.width,p.height);

   delai = 20;
   if (IEfader) delai = 130;
   setTimeout("fade_in('album_pres_photo',0,100);",delai);
   fadings['loading_img'] = "out";
   fade_out('loading_img',60,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.backgroundPosition="0px 0px";
     $(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="#000000";
        $(Sousmenu).parentNode.style.backgroundPosition="0px -32px";
        $(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,24,maxy-2);
         }
         else {
             Deroule(Sousmenu,10,maxy);
             fade_in(Sousmenu,60,100);
         }
         
      }
    	
    }
  
}

function Deroule(Sousmenu,dy,maxy) {
    Numero = Sousmenu;    
    deltay = dy+8; // 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 = 0; //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)",45);}
}

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() {
   if (page_active < 0) alert('Désolé, cette page n\'est malheureusement pas disponible en version imprimable.');
   else {
    parametres = "";
    if (page_active == art_p) parametres +="&art="+article_actif;
    if (page_active == entr_p) parametres +="&entr="+entr_actif;
    if (page_active == annonce_p) parametres +="&annonce="+annonce_actif;
    if (liste_fp[page_active]) window.open('imprimer.php?p='+page_active+'&s='+liste_fp[page_active]+'.php'+parametres);
    else window.open('imprimer.php?p='+page_active+parametres);
   }
}

/* *******************************************************
 *    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 requete_visiteur = "";
var showContenu = function(str) {
  
  $("cherche_contenu").style.display = 'none';
  FermeBarreDroite()
  
  edition_active = false;
  $("contenu_pages").innerHTML = str;
  if ($('time_up')) window.location.href="zen_login.php";

  if (requete_visiteur != "" && $('form_plainte')) {
      $('form_plainte').objet.value=requete_visiteur;
      requete_visiteur = "";
  }

  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',40,100);
  }
  /*fadings['sablier'] = "out";
  fade_out('sablier',60,0);*/

  
  p = page_active;
  titre = liste_sect[liste_ts[p][3]];
  if (section_active == 109) titre = "";
 // $('option_URL').value = url_base+liste_fp[p]+'.php';


  if (art_p != p && entr_p != p && annonce_p != p) {
     if (titre == "" && liste_ts[p][1] == "") titre += liste_ts[p][0];
     else if (titre != liste_ts[p][1]) titre += (titre!=""?" - ":"")+liste_ts[p][1];
     article_actif = 0;
     entr_actif = 0;
     if (!est_admin && !cache_pages[page_active])
        cache_pages[page_active] = str;
  }
  else {
   if (art_p == p) {
    getArchivesArticles();
    if (article_actif > 0) {
       titre += (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;
    }
   }
   else if (entr_p == p) {
    getListeEntreprises();
    if (entr_actif > 0) {
       titre +=(titre!=""?" - ":"")+$('nom_entr').innerHTML;
       $('option_URL').value += '?entr='+entr_actif;
       if (!cache_entr[entr_actif])
        cache_entr[entr_actif] = str;
    }
    else {
       if (!cache_pages[page_active])
        cache_pages[page_active] = str;
    }
   }
   else if (annonce_p == p) {
    getListeAnnonces();
    if (annonce_actif > 0) {
       titre +=(titre!=""?" - ":"")+$('titre_annonce').innerHTML;
       $('option_URL').value += '?annonce='+annonce_actif;
       if (!cache_ann[annonce_actif])
        cache_ann[annonce_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 ?
  }

  $('iframe_annonce').style.display = show_iframe_annonce;
  show_iframe_annonce = "none";

  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;
var cur = 0;
function RegistreTimer() {
  if (timer_width > 0) {
    $('registre_timer').style.width=timer_width+'px'; timer_width-=2; setTimeout("RegistreTimer();",220);
  }
  else getRegistre();
/*  var new_cur = ajaxRegistre.req.responseText.length;
  if (new_cur > cur) {
      $('registre_utilisateurs').innerHTML = ajaxRegistre.req.responseText.substring(cur);

      cur = new_cur;
  }
*/
}
function getRegistre() {
    if (timer_width <=0) { timer_width = 190; $('registre_timer').style.display="block";}
    ajaxRegistre.doGet('zen_registre.php',backRegistre);
    /*ajaxRegistre.init();
    ajaxRegistre.req.open('GET','zen_registre.php',true);
    ajaxRegistre.req.onreadystatechange = function() {
        if ( ajaxRegistre.req.readyState==4) { } // alert("done!");
    }
    ajaxRegistre.req.send(null);*/
    //RegistreTimer();
}


var ajaxHisto = new Ajax();
var backHisto = function(str) {
    //rien à faire
}
function getContenuPatch(p) { /* Patch pour l'historique (retour du iframe..) */

   window.scroll(0,0);
   /*fade_in("sablier",0,80);*/
   c = liste_ts[p][2];
   s =  liste_ts[p][3];
   //if (cat_active != c || (section_active != s && (s==62 || section_active==62))) ChangeFond(c,s);

   cat_active = c;
   section_active = s;
   page_active = p;
  
   //if (cat_active != menu_cat_ouvert) OuvreCat(cat_active);
   
   //Apparait(section_active);

   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";
   }
   entr = ""
   if (entr_actif != "") entr = "&entr="+entr_actif;
   if (p == entr_p) {
      if (entr == "") entr = "&entr=0";
   }
   else {
       entr_actif = "";
       $('liste_entreprises').style.display = "none";
   }
   annonce = ""
   if (annonce_actif != "") annonce = "&annonce="+annonce_actif;
   if (p == annonce_p) {
      if (annonce == "") annonce = "&annonce=0";
   }
   else {
       annonce_actif = "";
       $('liste_annonces').style.display = "none";
   }
   bp = "";
   if (est_admin) {
      bp = adbp; adbp = "";
      ajaxContenu.doGet('zen_contenu_pages.php?p='+p+art+entr+annonce+bp, showContenu);
   }
   else {
      if ((p != art_p || art == "&art=0") && (p != entr_p || entr == "&entr=0") && (p != annonce_p || annonce == "&annonce=0") && cache_pages[p]) {
         showContenu(cache_pages[p]);
         ajaxHisto.doGet('zen_historique.php?session=1&p='+p+art+entr,backHisto);
      }
      else if (p == art_p && article_actif > 0 && cache_art[article_actif]){
         showContenu(cache_art[article_actif]);
         ajaxHisto.doGet('zen_historique.php?session=1&p='+p+art,backHisto);
      }
      else if (p == entr_p && entr_actif > 0 && cache_entr[entr_actif]){
         showContenu(cache_entr[entr_actif]);
         ajaxHisto.doGet('zen_historique.php?session=1&p='+p+entr,backHisto);
      }
      else if (p == annonce_p && annonce_actif > 0 && cache_ann[annonce_actif]){
         showContenu(cache_ann[annonce_actif]);
         ajaxHisto.doGet('zen_historique.php?session=1&p='+p+annonce,backHisto);
      }
      else
        ajaxContenu.doGet('zen_contenu_pages.php?p='+p+art+entr+annonce+bp, showContenu);

      try { pageTracker._trackPageview(liste_fp[p]+'.php'+art+entr+annonce);  } catch(err) {}
   }

   
   if (!IEfader) {
      fade_out("contenu_pages",90,20);
   }
  
   $('sommaire_cal_ev').style.display = "none";

}

var alterne_img = 0;
var histo_iframe = true;
var capture_lien = false;

function getContenu(p) {
   
 //if (art_p && p == art_p) { page_active = -1;  article_actif = 0; } //bypass pour ré-afficher la page tout le temps !
 //if (entr_p && p == entr_p) { page_active = -1;  entr_actif = 0; } //bypass pour ré-afficher la page tout le temps !

 if (est_admin || page_active != p || (art_p && p == art_p) || (entr_p && p == entr_p) || (annonce_p && p == annonce_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;
   if (p == entr_p) entr_actif = 0;
   if (p == annonce_p) annonce_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) {
 
  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);
   getListeEntreprises(q);
   getListeAnnonces(q);
   pa_cc = page_active;
   page_active = -1;
   article_actif = -1;
   entr_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){
  
   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')) {
         $('bouton_q_art').value='recherche...';
         $('bouton_q_art').disabled=true;
      }
      q_ajax = encodeURIComponent(q);
      // n'est chargé que lorsqu'on en a besoin...
      ajaxArticles.doGet('zen_archives_articles.php?q='+q_ajax, showArchivesArticles);
   }
   //else
   if ($('archives_articles').style.display != "block")
      Ouvrir('archives_articles');

   dernier_q_art = q;
   /*
   if ($('archives_articles').innerHTML == "") {
      // n'est chargé qu'une seule fois !
      ajaxArticles.doGet('zen_archives_articles.php', showArchivesArticles);
   }
   //else
   //   $('archives_articles').style.display = "block";
   if ($('archives_articles').style.display != "block")
      Ouvrir('archives_articles');
  */
}

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);
  }
 }
}


var dernier_q_entr = "_toutes_";

var ajaxEntreprise = new Ajax();
var showListeEntreprises = function(str) {
   $('liste_entreprises').innerHTML = str;
   if (!est_admin) $("q_entr").focus();
}
function getListeEntreprises(q){
   if (q === undefined) {
      q = "_toutes_";
      if ($('q_entr')) {
       test = $('q_entr').value;
       if (test != "") q = test;
      }
   }
   if (dernier_q_entr != q || $('liste_entreprises').innerHTML == "") {

      if ($('bouton_q_entr')) {
         $('bouton_q_entr').value='recherche...';
         $('bouton_q_entr').disabled=true;
      }
      q = encodeURIComponent(q);
      // n'est chargé que lorsqu'on en a besoin...
      ajaxEntreprise.doGet('zen_liste_entreprises.php?q='+q, showListeEntreprises);
   }
   //else
   if ($('liste_entreprises').style.display != "block")
      Ouvrir('liste_entreprises');
   dernier_q_entr = q;
}


function getEntreprise(entr){
 if (est_admin || entr == 0 || entr != entr_actif) {
  if (capture_lien) {CaptureLien(entr_p,entr);}
  else if (CheckEdition()){
   histo_iframe = false;
   $('iframe_historique').src='zen_historique.php?p='+entr_p+'&entr='+entr;
   entr_actif = entr;
   if (entr==0 && $('q_entr')) $('q_entr').value = ""; //enleve la recherche si on fait "tout voir"
   getContenuPatch(entr_p);
  }
 }
}

var dernier_q_annonces = "_toutes_";
var show_iframe_annonce = "none";
var ajaxAnnonce = new Ajax();
var back_annonce_cat = -1;
var showListeAnnonces = function(str) {
   $('liste_annonces').innerHTML = str;
   if (!est_admin) $("q_annonces").focus();
   if (back_annonce_cat>0) ChangeOnglet(back_annonce_cat,'annonce');
   back_annonce_cat = -1;
}
function getListeAnnonces(q){
   if (q === undefined) {
      q = "_toutes_";
      if ($('q_annonces')) {
       test = $('q_annonces').value;
       if (test != "") q = test;
      }
   }
   if (dernier_q_annonces != q || $('liste_annonces').innerHTML == "") {

      if ($('bouton_q_annonces')) {
         $('bouton_q_annonces').value='recherche...';
         $('bouton_q_annonces').disabled=true;
      }
      q = encodeURIComponent(q);
      // n'est chargé que lorsqu'on en a besoin...
      ajaxAnnonce.doGet('zen_liste_annonces.php?q='+q, showListeAnnonces);
   }
   
   if ($('liste_annonces').style.display != "block") {
      Ouvrir('liste_annonces');      
   }
   dernier_q_annonces = q;
}


function getAnnonce(annonce){
 if (est_admin || annonce == 0 || annonce != annonce_actif) {
  if (capture_lien) {CaptureLien(annonce_p,annonce);}
  else if (CheckEdition()){
   histo_iframe = false;
   $('iframe_historique').src='zen_historique.php?p='+annonce_p+'&annonce='+annonce;
   annonce_actif = annonce;
   if (annonce==0 && $('q_annonce')) $('q_annonce').value = ""; //enleve la recherche si on fait "tout voir"
   getContenuPatch(annonce_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(); 
  }
}

/* ********************************** PETITES ANNONCES **************************************** */

ajaxAnnonce = new Ajax();
var backAnnonce = function(str) {
   if ($('msg_annonce')) {
      if (str.substring(0,2)=="OK") {
         $('form_annonce').style.display = 'none';

         // ouvrir le iframe pour ajouter une image, avec le bon code...
         // tout écrire ce qui suit dans le iframe, qui doit être dans "liste_annonces"
         code = str.substring(3,18);
         idannonce = str.substring(19);

         dernier_q_annonces = "";
         getAnnonce(idannonce);

         //alert(idannonce+"  ||  "+code);
         //$('msg_annonce').innerHTML = "<div class='note'>Un courriel a été envoyé à vous et à un responsable, votre annonce sera approuvée bientôt.  Si vous voulez ajouter une image, vous pouvez le faire maintenant ou utiliser le lien codé dans le courriel qui vous a été envoyé pour modifier ou effacer votre annonce plus tard.</div>";
         $('iframe_annonce').src = "modifier_annonce.php?code="+code;
         show_iframe_annonce = "block";
         Ouvrir('iframe_annonce');
      }
      else {
         $('msg_annonce').innerHTML = str;
         $('form_annonce').code.value="";
         $('img_captcha_annonce').src='securimage_show.php?sid='+(Math.random()*1000000000);
      }
   }
}


    function ValideAnnonce() {
      if (f = $('form_annonce')) {
        message = "";


        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 entrer un numéros de téléphone valide, à 10 chiffres,<br />par exemple (819) 555-5555 ou encore 8195555555.<br />";

        if (f.titre.value == "") message += "Vous devez entrer un titre.<br />";

        if (f.description.value == "") message += "Vous devez écrire une description.<br />";


        if (message == "") {
           code = encodeURIComponent(f.code.value);
           courriel = encodeURIComponent(f.courriel.value);
           telephone = encodeURIComponent(f.telephone.value);
           titre = encodeURIComponent(f.titre.value);
           description = encodeURIComponent(f.description.value);
           back_annonce_cat = f.cat.value;
           ajaxAnnonce.doPost('zen_traite_annonces.php',
               'annonce_go=1&code='+code+
               '&courriel='+courriel+
               '&telephone='+telephone+
               '&titre='+titre+
               '&cat='+back_annonce_cat+
               '&description='+description,backAnnonce);
        }
        else {
         message = '<div class="avertissement">'+message+'</div>';
         $('msg_annonce').innerHTML = message;
        }
      }
    }


/* ********************************** COMMENTAIRES ET SUGGESTIONS **************************************** */
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 entrer 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;         
        }
      }
    }

/* ********************************** Entreprises **************************************** */
ajaxVEntr = new Ajax();
var backVEntr = function(str) {
   if ($('msg_entreprise')) {
      if (str=="OK") {
         $('form_entreprise_modif').style.display = 'none';
         $('msg_entreprise').innerHTML = "<div class='note'>Un courriel a été envoyé à un responsable. Merci d'avoir utilisé ce service.</div>";
      }
      else {
         $('msg_entreprise').innerHTML = str;
         $('form_entreprise_modif').code.value="";
         $('img_captcha_plainte').src='securimage_show.php?sid='+(Math.random()*1000000000);
      }
   }
}



    function ValideEntreprise() {
      if (f = $('form_entreprise_modif')) {
        message = "";

        if (f.s_nom.value == "") message += "Vous devez entrer votre nom.<br />";

        testc = f.s_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.s_telephone.value;
        len = tel.replace(/[^0-9]/gi,'').length;
        if (len != 10)
           message += "Vous devez entrer un numéros de téléphone valide, à 10 chiffres,<br />par exemple (819) 555-5555 ou encore 8195555555.<br />";

        


        if (message == "") {

           code = encodeURIComponent(f.code.value);
           
           s_nom = encodeURIComponent(f.s_nom.value);
           s_courriel = encodeURIComponent(f.s_courriel.value);
           s_telephone = encodeURIComponent(f.s_telephone.value);
           s_lien = encodeURIComponent(f.s_lien.value);
           nom_entreprise = encodeURIComponent(f.nom_entreprise.value);
           nom_contact = encodeURIComponent(f.nom_contact.value);
           rue = encodeURIComponent(f.rue.value);
           ville = encodeURIComponent(f.ville.value);
           secteur = f.secteur.value;
           courriel = encodeURIComponent(f.courriel.value);
           telephone = encodeURIComponent(f.telephone.value);
           fax = encodeURIComponent(f.fax.value);
           site_web = encodeURIComponent(f.site_web.value);
           mots_cles = encodeURIComponent(f.mots_cles.value);
           description = encodeURIComponent(f.description.value);

           ajaxVEntr.doPost('zen_traite_entreprises.php',
           'go=1&code='+code+
           '&s_nom='+s_nom+
           '&s_courriel='+s_courriel+
           '&s_telephone='+s_telephone+
           '&s_lien='+s_lien+
           '&nom_entreprise='+nom_entreprise+
           '&nom_contact='+nom_contact+
           '&rue='+rue+
           '&ville='+ville+
           '&secteur='+secteur+
           '&courriel='+courriel+
           '&telephone='+telephone+
           '&fax='+fax+
           '&site_web='+site_web+
           '&mots_cles='+mots_cles+
           '&description='+description,backVEntr);
        }
        else {
         message = '<div class="avertissement">'+message+'</div>';
         $('msg_entreprise').innerHTML = message;
        }
      }
    }
/* ********************************************************************************
 *
 *  Animations de l'entête...
 */
function BougeEauEntete(ang) {   
    i = Math.sin(ang);
    //$(id).style.backgroundPosition = Math.round(Math.sin(ang)*280)+"px "+Math.round(Math.cos(ang)*20)+"px";
    $("animation").style.backgroundPosition = Math.round(ang*60)+"px "+Math.round(Math.cos(ang)*30)+"px";
    //document.body.style.backgroundPosition = Math.round(ang*30)+"px "+Math.round(Math.sin(ang/2)*50)+"px";
    
    setTimeout("BougeEauEntete("+(ang+0.02)+");",90);
}


/* ********************************************************************************
 *
 *  Barre de droite
 */


var bd_status = "ok";
var bd_n = -1;
//var nb_bd = 2;

function OuvreBarreDroite(n) {
 if (CheckEdition()) {
  edition_active = false;
  if (n == bd_n && bd_status == "ouverte") FermeBarreDroite();
  else {
    if (bd_status == "ok") {
        bd_status = "ouvre";        
        AnimBarre(0);
        fade_in('bdf',0,100);
        if (!IEfader) fade_out('contenu_pages',100,30);
    }
    bd_n = n;
    for (i=0; i<nb_bd; i++) {
       if (n == i) {
        if (bd_status == "ouverte") Ouvrir("bd"+i,0,100);
        // fade in 100 100 du boutons
        if (!IEfader) fade_in("bbd"+i,100,100);
       }
       else {
        $("bd"+i).style.display = "none";
        if (!IEfader) fade_out("bbd"+i,70,70);
        // fade out des autres boutons
       }
    }
  }
 }
}
function FermeBarreDroite() {
    if (bd_status == "ouverte") {
        fade_out('bdf',100,0);
        bd_status = "ferme";
        AnimBarre(0);
        if ($("bd"+bd_n)) $("bd"+bd_n).style.display = "none";
        if (!IEfader) {
            for (n=0; n<nb_bd; n++) fade_in("bbd"+n,100,100);        
            fade_in('contenu_pages',30,100);
        }
    }
    bd_n = -1;
}
var bd_left = 905;
function AnimBarre(ang) {
    i = Math.sin(ang);
    if (ang >= 1.4) i = 1;
    w = Math.round(i*540);
    if (bd_status == "ferme") w = 540 - w;
    $("barre_droite").style.left = (bd_left+12 - w)+"px";
    $("barre_droite").style.width = (23 + w)+"px";

    for (n=0; n<nb_bd; n++) $("bbd"+n).style.left = (bd_left - w)+"px";

    if (i < 1)
        setTimeout("AnimBarre("+(ang+0.15)+");",80);
    else {
        if (bd_status == "ferme") bd_status = "ok";
        else {
            bd_status = "ouverte";
            Ouvrir("bd"+bd_n,0,100);
        }
    }
}

