


function delete_module(id,zone)
        {
        confirmation = confirm("Voulez-vous vraiment envoyer ce module Ã  la corbeille ?"+id+"|")
        if (confirmation)
        parent.location.href='<? echo $var_url_site.$rep_admin_bo."organiser/organiser.php?del=";?>'+zone+'<? echo "&id_mes_modules=";?>'+id+'&ordre='+document.getElementById("ordre").value+'&id_categorie_menu='+document.getElementById("id_categorie_menu").value ;
        }






function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//     AJAX
function getXhr()
         {
         var xhr = null;
         if(window.XMLHttpRequest) // Firefox et autres
            xhr = new XMLHttpRequest();
         else if(window.ActiveXObject){ // Internet Explorer
              try {
                  xhr = new ActiveXObject("Msxml2.XMLHTTP");
                  } catch (e) {
                  xhr = new ActiveXObject("Microsoft.XMLHTTP");
                  }
              }
         else { // XMLHttpRequest non supporté par le navigateur
              alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
              xhr = false;
              }
         return xhr
         }

/**
* Méthode qui sera appelée sur le click du bouton
*/
function go(page,zone,param){
         var xhr = getXhr();
         // On défini ce qu'on va faire quand on aura la réponse
         xhr.onreadystatechange = function(){
             // On ne fait quelque chose que si on a tout reçu et que le serveur est ok
             if(xhr.readyState == 4 && xhr.status == 200){
                leselect = xhr.responseText;
                // On se sert de innerHTML pour rajouter les options a la liste
                //document.getElementById('livre').innerHTML = leselect;
                if  (document.getElementById(zone))
                     document.getElementById(zone).innerHTML = leselect;
                }
             }

         // Ici on va voir comment faire du post
         //xhr.open("POST","ajaxLivre.php",true);
         xhr.open("POST",page,true);
         // ne pas oublier ça pour le post
         xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         // ne pas oublier de poster les arguments
         // ici, l'id de l'auteur

         do {
             hue=parseInt(Math.random()*1000)
            } while (hue>240)
         do {
             sat=parseInt(Math.random()*1000)
            } while (sat>240)
         lum=215;
         HSLtoRGB();
         varcolor = DecToHex(red) + DecToHex(green) + DecToHex(blue)  ;

         if(document.all)
                {
                document.styleSheets[4].rules[0].style.backgroundColor='#' + varcolor ;
                }
         else
             {
                document.styleSheets[4].cssRules[0].style.backgroundColor='#' + varcolor ;
             }

         do {
             hue=parseInt(Math.random()*1000)
            } while (hue>240)
         do {
             sat=parseInt(Math.random()*1000)
            } while (sat>240)
         lum=215;
         HSLtoRGB();
         varcolor = DecToHex(red) + DecToHex(green) + DecToHex(blue)  ;

         if(document.all)
                {
                document.styleSheets[5].rules[0].style.backgroundColor='#' + varcolor ;
                }
         else
             {
                document.styleSheets[5].cssRules[0].style.backgroundColor='#' + varcolor ;
             }


         //sel = document.getElementById('auteur');
         //idauteur = sel.options[sel.selectedIndex].value;
         //xhr.send("idAuteur="+idauteur);
         xhr.send(param);
         }





function show(indice)

{
        if (document.getElementById(indice).style.display=="none")                // Si la zone indiqué par indice est est invisible
                document.getElementById(indice).style.display="block";                // On l'affiche
        else                                                                        // Sinon (elle est donc visible)
                document.getElementById(indice).style.display="none";                //On la crend invisible
}

function voir(indice)
{
                document.getElementById(indice).style.display="block";

}
function cache(indice)
{
                document.getElementById(indice).style.display="none";
}

function gestion_FO(param, action)
    {

    id_div="";
    page="../include/gestion_fo.php";
    switch (action)
       {
       case "annuaire_cat":
          id_div="annuaire_listetheme";
          param=param+"&action="+action;
          pos=param.indexOf("&action", 0);
          idtheme=param.substring(9, pos);
          // suprime si déja présent
          listeidcat=document.getElementById('liste_id_cat').value+",";
          //alert (listeidcat+"-"+idtheme);
          listeidcat=listeidcat.replace(","+idtheme+",",",");
          if ( listeidcat==document.getElementById('liste_id_cat').value+"," )
              document.getElementById('liste_id_cat').value=listeidcat+idtheme ;
          else
              document.getElementById('liste_id_cat').value=listeidcat+"0";

          param=param+"&action="+action+"&liste_id_cat="+document.getElementById('liste_id_cat').value;
          break;

       case "veilleadd":
          // ajout d'une veille
          id_div="zoneveillemess";
          param=param+"&action="+action;
          document.getElementById('zoneveillemess').style.display="block";
          break;
       case "inscription_newsletter":
          //
          id_div="newslettermess";
          email=document.getElementById('emailnewsletter').value;
          if (email)
              if(confirm("Confirmer votre inscription avec cet email : "+email))
                 param="email="+email+"&action="+action;
              else
                 param=NULL;


          break;
       }


    if(document.all)
                {
                //Internet Explorer
                var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
                }//fin if
    else
                {
                     //Mozilla
                var XhrObj = new XMLHttpRequest();
                }//fin else

        //définition de l'endroit d'affichage:
        if (id_div)
            var content = document.getElementById(id_div);

        XhrObj.open("POST", page);

        //Ok pour la page cible
        XhrObj.onreadystatechange = function()
                {
                if (XhrObj.readyState == 4 && XhrObj.status == 200)
                   {
                   //alert (XhrObj.responseText);
                   if (id_div)
                         content.innerHTML = XhrObj.responseText ;
                   }
                }
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(param);

    }//fin fonction SendData



// comptage
//var max=50;
function compter(zone,max,nbcar) {

        var txt=document.getElementById(zone).value;

        var nb=txt.length;
        if (nb>max) {
                //alert("Pas plus de "+max+" caractères dans ce champ");
                document.getElementById(zone).value=txt.substring(0,max);
                nb=max;
        }
        document.getElementById(nbcar).value=max-nb;
}




