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");
   
   function trans(element,op) {
       if (IEfader)
            element.style.filter = "alpha(opacity="+op+")";
          else {
            element.style.opacity = (op / 100);
            element.style.MozOpacity = (op / 100);
          }
   }

   var fadings = new Array();

   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);
      }
     }
   }
function vidSeance(vid,titre) {
     window.scroll(0,400);
     vid = "medias/vid_seances/"+encodeURIComponent(vid); // à tester !! inutile ?
     w = 480;//640;
     h = 360;//480; // proportion 4:3...
     //h += 20; // pour la barre de menu en bas ??
     code_swf = '<object style="position:relative;" type="application/x-shockwave-flash" data="player_flv_maxi.swf" height="'+h+'" width="'+w+'"><param name="movie" value="player_flv_maxi.swf"><param name="wmode" value="transparent"><param name="allowScriptAccess" value="*" /><param name="allowFullScreen" value="true"><param name="FlashVars" value="flv='+vid+'&amp;showvolume=1&amp;showtime=1&amp;showfullscreen=1&amp;buffermessage=Chargement _n_&amp;ondoubleclick=fullscreen&amp;showiconplay=1&amp;iconplaybgalpha=25&amp;showtitleandstartimage=1&amp;autoplay=1">Plugin flash requis<br /><br /><br /><br /><a style="padding:10px;" href="'+vid+'">Télécharger le vidéo de la séance sélectionnée au format FLV <br />pour l\'écouter dans votre ordinateur</a></object>';
     $('vid_seances').innerHTML = "<h4>"+titre+'</h4><br />'+code_swf;

  }
   function Traduit(obj,ln) {
     if (obj) {
      for (i in obj.childNodes) {
         Traduit(obj.childNodes[i],ln);
      }
      if (obj.value) {
       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;
function AfficheAlbumPhoto(idphoto) {
  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:-16px; 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:-16px; 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.65 || IEfader) i=1;
    if (i<1) {
        p.style.width = Math.ceil(i*w1)+"px";
        p.style.height =  Math.ceil(i*h1)+"px";
        inc = 0.28;
        if (v==apv) setTimeout("ap("+v+","+(ang+inc)+","+w1+","+h1+");",75)
    }
    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',0,100);
            fade_in('album_pres_contenu',0,100);
        }
        $('album_pres_titre').style.display = "block";
        $('album_pres_contenu').style.display = "block";
    }

    c = $('album_pres_conteneur');
    l = getClientSize()[0] - c.offsetWidth;
    if (l<0) l = 15;
    t = getClientSize()[1] - c.offsetHeight;
    if (t<0) t = 15;
    c.style.top = (getScrollXY()[1]+t/2)+"px";
    c.style.left = (getScrollXY()[0]+l/2)+"px";
  }
}

function AlbumPhotoLoaded() {
   p =  $('app');
   $('album_pres_conteneur').style.display = "inline";
   apv++;
   ap(apv,0.8,p.width,p.height);
   setTimeout("fade_in('album_pres_photo',0,100);",40);
   fadings['loading_img'] = "out";
   fade_out('loading_img',60,0);
}

/*function AlbumPhotoLoaded() {
   c = $('album_pres_conteneur');
   c.style.display = "inline";
   l = getClientSize()[0] - c.offsetWidth;
   if (l<0) l = 15;
   t = getClientSize()[1] - c.offsetHeight;
   if (t<0) t = 15;
   c.style.top = (getScrollXY()[1]+t/2)+"px";
   c.style.left = (getScrollXY()[0]+l/2)+"px";
   setTimeout("fade_in('album_pres_photo',0,100);",120);
   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) {

  if (est_admin || cat > 0) $('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,80,35);
     $('titre_cat'+menu_cat_ouvert).style.color = "#ffffff";
  }
     
  if (cat != menu_cat_ouvert && (est_admin || cat > 0)) {
     //alert("Ouvre : "+cat+"\nHauteur : "+menu_cat_hauteurs[cat]);
     sens_cat[cat] = 1;
     menu_cat_ouvert = cat;
     DerouleCat(cat,80,66);
     $('titre_cat'+cat).style.color = "#000000";
  }
  else menu_cat_ouvert = -1;    
}

function DerouleCat(cat,ms,dy) {
 if (sens_cat[cat] == 1)
  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 > 44) dy-= 4;
      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 (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 < 80) dy+= 8;
      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 pompe = 1;              // menu déroulants: contourne des petits problèmes (diff. IE vs FIREFOX)..

var hauteurs = Array();
var go_sousmenu = true;

function Enlever(Sousmenu) {
  if (sm_actif != Sousmenu) {
     $(Sousmenu).style.visibility="hidden";
     $(Sousmenu).style.display="none";
  }
}
function Apparait(Sousmenu) {
  if (go_sousmenu && Sousmenu != sm_actif) {
    sm_actif = Sousmenu;
    
    for (i = 1; i <= nombre_items_menu; i++) {if (("sm_"+i) != sm_actif) Enlever("sm_"+i);}  
    
    if (Sousmenu != "aucun") {

      /* mettre en commentaire pour enlever l'effet déroulant : */
      if ($(Sousmenu).style.visibility != "visible") {
        $(Sousmenu).style.visibility="visible";
        $(Sousmenu).style.display="block";
        if (!hauteurs[Sousmenu])
           hauteurs[Sousmenu] = $(Sousmenu).scrollHeight;

        maxy = hauteurs[Sousmenu];
        pompe = 20;
        $(Sousmenu).style.height = pompe+"px";

        // 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,40,30,maxy-2);            
         }
         else {
             Deroule(Sousmenu,40,30,maxy);
             fade_in(Sousmenu,50,95);
         }
         
      }
    	
    }
  }
}
function Deroule(Sousmenu,ms,dy,maxy) {
    Numero = Sousmenu;
    milisec = ms;
    deltay = dy+12; // accélération !
    max = maxy;
    //if (Sousmenu == sm_actif) {
        if ((pompe + dy) >= maxy)
            $(Sousmenu).style.height = maxy+"px";
        else {
            pompe = pompe+dy;
            $(Sousmenu).style.height = pompe+"px";
            setTimeout("Deroule(Numero,milisec,deltay,max)",milisec);
        }
    //}
}
function Disparait(Sousmenu) {
	sm_actif = "aucun";   
   if (IEfader) {setTimeout("Enlever('"+Sousmenu+"')",900);}
		else {setTimeout("Enlever('"+Sousmenu+"')",600);}

}

function OverMenu(Sousmenu)	{
    sm_actif = Sousmenu;
}


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 {
    if (liste_fp[page_active]) window.open('print.php?p='+page_active+'&s='+liste_fp[page_active]+'.php');
    else 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';            
        }
     }     
   }
}

function HighlightContenu() {
  q = '';
  if (!q_cc_vide)
   q = $('q_cc').value;

  if (q.replace(/\s{1,}/g,'').length > 2) {
      question = PrepareQ(q);
      Highlight($("contenu_pages"),question);
  }
}

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();

  HighlightContenu();

  if (!IEfader) {
      fadings['contenu_pages'] = "in"; // stop explicitement le fade-out ! :)
      fade_in('contenu_pages',40,100);
  }

  
  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);    
  }


  effacer_photo = false;
  setTimeout("ColonnesAuto();",40);
  setTimeout("NettoieContenu();",200);
  

  if ($('album_premiere_page')) {
    if (album_page_back_admin == "") {
      setTimeout("AfficheAlbumThumbs($('album_premiere_page').innerHTML);",150);
      //AfficheAlbumPhoto($('album_premiere_photo').innerHTML);
    }
    else {
      setTimeout("AfficheAlbumThumbs(album_page_back_admin);",150);
      if (album_photo_back_admin != "")
         setTimeout("AfficheAlbumPhoto(album_photo_back_admin);",500);      
    }
  }
  
  if (IE6 && !est_admin) supersleight.run();
}

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;
   
   if (cat_active != menu_cat_ouvert) OuvreCat(cat_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";
   }

   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]);
         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]);
         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",90,20);
   }
   FermeCalEv();
   $('sommaire_cal_ev').style.display = "none";

}

var alterne_img = 0;
var histo_iframe = true;
var capture_lien = false;
var imprime = false;
function CheckImprime() {if (imprime) alert("Vous ne pouvez pas changer de page dans les version imprimables..."); return !imprime;}
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 (CheckImprime() && (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')) {
         $('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);
   }
   
   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";
      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  exception_accueil = false; // pour Ville de Drummondville...
var  c1a = 0;
var  c2a = 0;

function ColonnePlace(){
  if ((obj = $('colonnes_auto_cachette').childNodes[0])) {

   c1 = $('ca1');
   c2 = $('ca2');

    if (c1.offsetHeight <= c2.offsetHeight || exception_accueil) {
      exception_accueil = false;
      if (page_active == 1 && obj.style) {
         obj.style.borderRight = "1px dashed #555555";
         obj.style.marginBottom = "10px";
         //obj.style.marginLeft = "10px";
         if (c1a == 0) {
            obj.style.borderBottom = "1px dashed #5f5f5f";
           // exception_accueil = true;
         }
         if (c1a > 0) obj.style.borderTop = "1px dashed #6f6f6f";
         c1a++;
      }
      c1.appendChild(obj);
      c1.style.display = "block"; // puisque probablement traité comme vide dans NettoieContenu()
    }
    else {
      if (page_active == 1 && obj.style) {
         obj.style.borderLeft = "1px dashed #666666";
         obj.style.marginBottom = "10px";
         //obj.style.marginRight = "10px";
         if (c2a == 0) obj.style.borderBottom = "1px dashed #5f5f5f";
         if (c2a > 0) obj.style.borderTop = "1px dashed #6f6f6f";
         c2a++;
      }
      c2.appendChild(obj);
      c2.style.display = "block"; // puisque probablement traité comme vide dans NettoieContenu()
    }

    to = 30;
    if (obj.innerHTML && obj.innerHTML.indexOf('<img ') >= 0 ) to = 220; // 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+
               '&type='+type+
               '&nom='+nom+
               '&courriel='+courriel+               
               '&telephone='+telephone+
               '&objet='+objet+
               '&description='+description,backPlainte);


           try { type_event = f.type.options[f.type.selectedIndex].text;  pageTracker._trackEvent("Commentaire envoyé par le site","Service: "+type_event);  } catch(err) {}
        }
        else {
         message = '<div class="avertissement">'+message+'</div>';
         $('msg_plainte').innerHTML = message;         
        }
      }
    }

   var back200e = function(str) {
   if ($('msg_200e')) {
       i1 = $('form_220_idee1');
       i2 = $('form_220_idee2');
      if (str=="OK") {         
         $('form_200e').style.display = 'none';
         $('msg_200e').innerHTML = "<div class='note'><br /><h4>Un courriel a été envoyé.</h4> <br /><br />Merci d'avoir utilisé ce service.<br /><br /></div>";
         $('msg_200e').style.marginLeft = "10px";
      }
      else {
         i1.disabled = false;
         i2.disabled = false;
         $('msg_200e').innerHTML = str;
         $('msg_200e').style.marginLeft = "240px";
         $('form_220_code').value="";
         $('img_captcha_200e').src='securimage_show.php?sid='+(Math.random()*1000000000);
      }
   }
}

    function Valide200e() {
        
      if ($('form_220_idee1') && $('form_220_idee2')) {
          i1 = $('form_220_idee1');
          i2 = $('form_220_idee2');
          f_code = $('form_220_code');
        message = "";
        
        //if (gteIE7) alert(f_code.value);
        if (i1.value.length < 3) message += "Vous devez entrer une idée à soumettre.<br />";
        if (f_code.value.length == 0) message += "CAPTCHA requis !<br />";
        else if (f_code.value.length != 5) message += "Le CAPTCHA doit avoit exactement 5 caractères !<br />";

        if (message == "") {
            //c = "asdfg";
           c = ""+f_code.value;
           c = encodeURIComponent(c);
           i1_enc = ""+i1.value;
           i1_enc = encodeURIComponent(i1_enc);
           i2_enc = ""+i2.value;
           i2_enc = encodeURIComponent(i2_enc);
           ajaxPlainte.doPost('zen_traite_200e.php',
               '200e_go=1&code='+c+
               '&i1='+i1_enc+
               '&i2='+i2_enc
             ,back200e);
             i1.disabled = true;
             i2.disabled = true;
             try { pageTracker._trackEvent("Commentaire envoyé par le site","Idée pour le 200e");  } catch(err) {}
        
        }
        else {
         message = '<div class="avertissement">'+message+'</div>';
         $('msg_200e').style.marginLeft = "240px";
         $('msg_200e').innerHTML = message;
        }
      }
    }


   var backSondageEnviro = function(str) {
   if ($('msg_sondage_enviro')) {
       //i1 = $('form_220_idee1');
       //i2 = $('form_220_idee2');
      if (str=="OK") {
         $('div_sondage_enviro').style.display = 'none';
         $('msg_sondage_enviro').innerHTML = "<div class='note'><br /><h4>Un courriel a été envoyé.</h4> <br /><br />Merci d'avoir utilisé ce service.<br /><br /></div>";
         $('msg_sondage_enviro').style.marginLeft = "10px";
      } else {
        // i1.disabled = false;
        // i2.disabled = false;
         $('msg_sondage_enviro').innerHTML = str;
         $('msg_sondage_enviro').style.marginLeft = "240px";
         $('form_sondage_enviro_code').value="";
         $('img_captcha_sondage_enviro').src='securimage_show.php?sid='+(Math.random()*1000000000);
      }
   }
}

    function ValideRadioChecked(test,lstr) {        
        testlen = test.length;
        for (var i = 0; i<testlen; i++) {
           if (test[i].checked) {
            lstr.style.backgroundColor = 'transparent';
            lstr.style.color = '#000000';
            return true
           }
        }
        lstr.style.backgroundColor = '#eecccc';
        lstr.style.color = '#660000';
        return false;
    }
    function Rval(radioObj) {
	if(!radioObj) return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
            if(radioObj.checked) return radioObj.value;
	    else return "";
	for(var i = 0; i < radioLength; i++) if(radioObj[i].checked) return radioObj[i].value;
	return "";
    }
    function ValideSondageEnviro() {
      if (f = $('form_sondage_enviro')) {
        f_code = f.code.value;
        message = "";

        //radios ...
        if (!ValideRadioChecked(f.logement,$('lstr_logement'))) message = "Veuillez répondre à toutes les questions.<br />";
        if (!ValideRadioChecked(f.utilisation_frequente,$('lstr_utilisation_frequente'))) message = "Veuillez répondre à toutes les questions.<br />";
        if (!ValideRadioChecked(f.dispose,$('lstr_dispose'))) message = "Veuillez répondre à toutes les questions.<br />";
        if (!ValideRadioChecked(f.odeurs,$('lstr_odeurs'))) message = "Veuillez répondre à toutes les questions.<br />";
        if (!ValideRadioChecked(f.dimension,$('lstr_dimension'))) message = "Veuillez répondre à toutes les questions.<br />";
        if (!ValideRadioChecked(f.proportion,$('lstr_proportion'))) message = "Veuillez répondre à toutes les questions.<br />";
        if (!ValideRadioChecked(f.minibac,$('lstr_minibac'))) message = "Veuillez répondre à toutes les questions.<br />";
        if (!ValideRadioChecked(f.campagne,$('lstr_campagne'))) message = "Veuillez répondre à toutes les questions.<br />";
        if (!ValideRadioChecked(f.plusinfo,$('lstr_plusinfo'))) message = "Veuillez répondre à toutes les questions.<br />";
//        message = "Veuillez répondre à toutes les questions.<br />";
       // !ValideRadioChecked(f.ordures2sem,$('lstr_ordures2sem')) ||
        

        if (f_code.length == 0) message += "CAPTCHA requis !";
        else if (f_code.length != 5) message += "Le CAPTCHA doit avoit exactement 5 caractères !";

        if (message == "") {

           ajaxPlainte.doPost('zen_traite_sondage_enviro.php',
               'sondage_go=1&code='+encodeURIComponent(f_code)+
               '&logement='+encodeURIComponent(Rval(f.logement))+
               '&logement_autre='+encodeURIComponent(f.logement_autre.value)+
                '&nb019='+encodeURIComponent(f.nb019.value)+
                '&nb2034='+encodeURIComponent(f.nb2034.value)+
                '&nb3549='+encodeURIComponent(f.nb3549.value)+
                '&nb5064='+encodeURIComponent(f.nb5064.value)+
                '&nb65plus='+encodeURIComponent(f.nb65plus.value)+
                '&utilisation_frequente='+encodeURIComponent(Rval(f.utilisation_frequente))+
                '&dispose='+encodeURIComponent(Rval(f.dispose))+
                '&dispose_autre='+encodeURIComponent(f.dispose_autre.value)+
                '&odeurs='+encodeURIComponent(Rval(f.odeurs))+
                '&dimension='+encodeURIComponent(Rval(f.dimension))+
                '&proportion='+encodeURIComponent(Rval(f.proportion))+
                '&proportion_autre='+encodeURIComponent(f.proportion_autre.value)+
                '&minibac='+encodeURIComponent(Rval(f.minibac))+
                '&frequence='+encodeURIComponent(Rval(f.frequence))+
                '&frequence_autre='+encodeURIComponent(f.frequence_autre.value)+               
                '&campagne='+encodeURIComponent(Rval(f.campagne))+
                '&plusinfo='+encodeURIComponent(Rval(f.plusinfo))+
                '&non_freq_autre='+encodeURIComponent(f.non_freq_autre.value)+
                '&non_freq1='+(f.non_freq1.checked?'1':'0')+
                '&non_freq2='+(f.non_freq2.checked?'1':'0')+
                '&non_freq3='+(f.non_freq3.checked?'1':'0')+
                '&non_freq4='+(f.non_freq4.checked?'1':'0')+
                '&pp_autre='+encodeURIComponent(f.pp_autre.value)+
                '&pp1='+(f.pp1.checked?'1':'0')+
                '&pp2='+(f.pp2.checked?'1':'0')+
                '&pp3='+(f.pp3.checked?'1':'0')+
                '&pp4='+(f.pp4.checked?'1':'0')+
                '&pp5='+(f.pp5.checked?'1':'0')+
                '&tm_autre='+encodeURIComponent(f.tm_autre.value)+
                '&tm1='+(f.tm1.checked?'1':'0')+
                '&tm2='+(f.tm2.checked?'1':'0')+
                '&tm3='+(f.tm3.checked?'1':'0')+
                '&tm4='+(f.tm4.checked?'1':'0')+
                '&info_autre='+encodeURIComponent(f.info_autre.value)+
                '&info1='+(f.info1.checked?'1':'0')+
                '&info2='+(f.info2.checked?'1':'0')+
                '&info3='+(f.info3.checked?'1':'0')+
                '&info4='+(f.info4.checked?'1':'0')+
                '&info5='+(f.info5.checked?'1':'0')+
                '&info6='+(f.info6.checked?'1':'0')+
                '&commentaires='+encodeURIComponent(f.commentaires.value)
             ,backSondageEnviro);
// '&ordures2sem='+encodeURIComponent(Rval(f.ordures2sem))+
             try { pageTracker._trackEvent("Commentaire envoyé par le site","Sondage environnement (bac brun)");  } catch(err) {}
        }
        else {
         message = '<div class="avertissement">'+message+'</div>';
         $('msg_sondage_enviro').style.marginLeft = "240px";
         $('msg_sondage_enviro').innerHTML = message;
        }
      }
         
    }


/* ********************************************************************************
 *
 *  Animations de l'entête...
 */

var top_origin = 49;
var left_origin = 10;
var mask_width = 1040;
var mask_height = 255;
var alterne = 1;
var increment = 0.01;
var speed = 120;
var zoom_prop = 1.002;
var cur = Array();
cur['img_0'] = 0;
cur['img_1'] = 0;

var last_hasard = 0;


//$('img_0').style.background = 'url("'+img_src[initial_img][0]+'") '+(left_origin-img_src[initial_img][1])+'px '+(top_origin-img_src[initial_img][2])+'px';


function AnimeEnteteTL(id,c,ang,left,top) {
  i = Math.sin(ang);
  $(id).style.left = (left_origin-Math.round(i*left))+"px";
  $(id).style.top = (top_origin-Math.round(i*top))+"px";
  if (c == cur[id] && ang <= (1.40)) { //1.5707963267948965 = Math.PI/2
    setTimeout('AnimeEnteteTL("'+id+'",'+c+','+(ang+increment)+','+left+','+top+');',speed);
  }
}

function AnimeEnteteTR(id,c,ang,left,top,max_right) {
  i = Math.sin(ang);
  $(id).style.left = ((left_origin-max_right+mask_width)+Math.round(i*(max_right-left-mask_width)))+"px";
  $(id).style.top = (top_origin-Math.round(i*top))+"px";
  if (c == cur[id] && ang <= (1.40)) {
    setTimeout('AnimeEnteteTR("'+id+'",'+c+','+(ang+increment)+','+left+','+top+','+max_right+');',speed);
  }
}
function AnimeEnteteBL(id,c,ang,left,top,max_bottom) {
  i = Math.sin(ang);
  $(id).style.left = (left_origin-Math.round(i*left))+"px";
  $(id).style.top = ((top_origin-max_bottom+mask_height)+Math.round(i*(max_bottom-top-mask_height)))+"px";
  if (c == cur[id] && ang <= (1.40)) {
    setTimeout('AnimeEnteteBL("'+id+'",'+c+','+(ang+increment)+','+left+','+top+','+max_bottom+');',speed);
  }
}
function AnimeEnteteBR(id,c,ang,left,top,max_right,max_bottom) {
  i = Math.sin(ang);
  $(id).style.left = ((left_origin-max_right+mask_width)+Math.round(i*(max_right-left-mask_width)))+"px";
  $(id).style.top = ((top_origin-max_bottom+mask_height)+Math.round(i*(max_bottom-top-mask_height)))+"px";
  if (c == cur[id] && ang <= (1.40)) {
    setTimeout('AnimeEnteteBR("'+id+'",'+c+','+(ang+increment)+','+left+','+top+','+max_right+','+max_bottom+');',speed);
  }
}


function ChangeEntete() {

   var coin = Math.floor(Math.random()*4);
   var depart = 1.41;
   //var depart = Math.random() * 0.4; /* l'animation va de 0 à PI/2 (environ 1.58)*/
   //var hasard = Math.floor(Math.random()*nb_img);

   //if (nb_img > 2) while (last_hasard == hasard) hasard = Math.floor(Math.random()*nb_img);
   var hasard = last_hasard+1;
   if (hasard == nb_img) hasard = 0;


   last_hasard = hasard;
   //zoom_prop = 0.999 + Math.random() * 0.005;

   var image = url_base+img_src[hasard];
   //var left = 30+ Math.floor(Math.random()*130); //img_src[hasard][1];
   //var top =  30+ Math.floor(Math.random()*80); //img_src[hasard][2];
   var left = 0; //img_src[hasard][1];
   var top =  0; //img_src[hasard][2];

   //$('img_'+alterne).style.background = "url("+image+") "+left_origin+"px "+top_origin+"px";


   var id = 'img_'+alterne;
   cur[id] = cur[id]+1;
   $(id).style.visibility = "hidden";
   switch (coin) {
   case 0 :
        $(id).onload = function () { AnimeEnteteTL(id,cur[id],depart,left,top); fade_in(id,0,100,75,3);}
        break;
   case 1 :
        $(id).onload = function () { AnimeEnteteTR(id,cur[id],depart,left,top,$(id).width); fade_in(id,0,98,70,3);}
        break;
   case 2 :
        $(id).onload = function () { AnimeEnteteBL(id,cur[id],depart,left,top,$(id).height); fade_in(id,0,98,70,2);}
        break;
   case 3 :
        $(id).onload = function () { AnimeEnteteBR(id,cur[id],depart,left,top,$(id).width,$(id).height); fade_in(id,0,100,70,3);} //80+ Math.floor(Math.random()*20)
        break;
   }
   $(id).src = image;

   alterne = (alterne+1)%2;
   fade_out('img_'+alterne,96,0,100,2);
   cur['img_'+alterne] = cur['img_'+alterne]+1;// stop celui qui est en court...
   var nextswitch = Math.floor(Math.random()* 10000) + 11000;  // on attend 10-30 secondes pour changer
   setTimeout('ChangeEntete();',nextswitch);
}

function ChangeStyle(fs) {
    $('iframe_historique').src="zen_fontsize.php?fs="+fs;
}
