


function MM_openBrWindow(theURL,winName,features) { //v2.0
  popupWin=window.open(theURL,winName,features);
}
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);


                       //   rouge / noir
function clignotement(id,rgb1,rgb2){
// alert ("coucou : "+color);
if (rgb1 && rgb2)
    {
    // alert ("couleur : "+ document.getElementById(id).style.color + " | "+rgb1 );
    if (document.getElementById(id).style.color=="rgb("+rgb1+")" )
       document.getElementById(id).style.color="rgb("+rgb2+")";
    else
       document.getElementById(id).style.color="rgb("+rgb1+")";

    }
else
    {
    if (document.getElementById(id).style.display=="block")
       document.getElementById(id).style.display="none";
    else
       document.getElementById(id).style.display="block";
    }
}




function voir(indice,visibility)
{
//alert ("indice: "+indice);
if (document.getElementById(indice))
                if (visibility)
                    document.getElementById(indice).style.visibility="visible";
                else
                    document.getElementById(indice).style.display="block";

}
function cache(indice,visibility)
         {
if (document.getElementById(indice))
         if (visibility)
             document.getElementById(indice).style.visibility="hidden";
         else
             document.getElementById(indice).style.display="none";


}




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 show2(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
}

 //  *******************************************************
 //           GESTION CALENDRIER
 //*****************************************************

function gestioncalendrier(param, zone,zone2)
    {

    if (zone)
        {
            if (document.getElementById(zone).style.visibility=="visible")
                {
                document.getElementById(zone).style.visibility="hidden";
                }
            else
                {
                document.getElementById(zone).style.visibility="visible";
                }
        }
    else
        {
        if (zone2) zone=zone2;
        }
    param=param+"&zone="+zone;

        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:
        var content = document.getElementById(zone);

        XhrObj.open("POST", '../inc/calendrier.inc.php');

        //Ok pour la page cible
        XhrObj.onreadystatechange = function()
                {

                if (XhrObj.readyState == 4 && XhrObj.status == 200)
                   {
                   content.innerHTML = XhrObj.responseText ;
                   }
                }






        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(param);

    }//fin fonction SendData

function calendrierselection(date, zone)
    {
    switch (zone)
            {
            case "date1":
                // date_debut
                document.getElementById("date_debut").value=date;

                break;
            case "date2":
                // date_fin
                document.getElementById("date_fin").value=date;
                break;

            }
    document.getElementById("date1").style.visibility="hidden";
    document.getElementById("date2").style.visibility="hidden";

    }



function calendrierselection(date, zone)
    {
    switch (zone)
            {
            case "date1":
                // date_debut
                document.getElementById("date_debut").value=date;

                break;
            case "date2":
                // date_fin
                document.getElementById("date_fin").value=date;
                break;

            }
    document.getElementById("date1").style.visibility="hidden";
    document.getElementById("date2").style.visibility="hidden";

    }






function gestion_FO(param, action)
    {
    id_div="";
    page="inc/gestion_fo.php";
    var page2;
    switch (action)
       {


       case "gestion_theme_etat":
       case "gestion_page_etat":
       case "gestion_textinplace":
          param=param+"&action="+action;
          break;
       case "accessibilite":
          tab=param.split('|');
          id=tab[0];
          url=tab[1];          //
          param="param="+param+"&action="+action;
          break;
       case "pdf":
          //popupWin=window.open('pdf.php,'pdf','');
          param="contenu="+encodeURIComponent(param)+"&action="+action;
          //alert (param);
          break;

       case "update_textinplace":
          tab=param.split('|');
          table=tab[0];
          champ=tab[1];          //
          id_champ_donnee=tab[2];          //
          id_valeur_donnee=tab[3];
          type=tab[4];
          id_module=tab[5];
          fck=tab[6];
          //valeur=document.getElementById(champ).value;         //
          switch (type)
              {
              case 'text':
                  //
                  var valeur = document.getElementById(champ).value;
                  break;
              case 'textarea':
                  if (fck==1)
                      {
                      //var oEditor = FCKeditorAPI.GetInstance(champ) ;
                      //var valeur = oEditor.GetHTML() ;
					  var test="CKEDITOR.instances."+champ+".getData()";
					  var valeur=eval(test);
						}
                  else
                      var valeur = document.getElementById(champ).value;

                  break;
              }
          param=param+"|"+encodeURIComponent(valeur);
          param="param="+param+"&action="+action;
          //  alert (param);
          document.getElementById('show_'+champ+'_'+id_champ_donnee+'_'+id_valeur_donnee).innerHTML=valeur;
          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);

            chemin= String(document.location).split('/');
            if (chemin[3])
                {
                }
            else
                {
                chemin[3]="fr";
                }

       // alert ("location : "+document.location+" | "+chemin[3]);

        if (page2)
            {
            XhrObj.open("POST", '/'+chemin[3]+'/'+page2);
            }
        else
            {
            XhrObj.open("POST", '/'+chemin[3]+'/'+page);
            }

        //Ok pour la page cible
        XhrObj.onreadystatechange = function()
                {
                if (XhrObj.readyState == 4 && XhrObj.status == 200)
                   {
                   //alert (XhrObj.responseText);
                   retourajax=XhrObj.responseText;
                   if (id_div)
                         content.innerHTML = XhrObj.responseText ;



    switch (action)
       {
       case "accessibilite":
           // accessibilite

           setTimeout("window.location='"+url+"'", 500);
           break;
       case "pdf":

          //setTimeout("pdf_open()", 5000);
         //popupWin=window.location.href("/"+chemin[3]+"/pdf.php",'pdf','');
          if (retourajax)
              window.location.href="/"+chemin[3]+"/pdf.php";
              //window.open("/"+chemin[3]+"/pdf.php",'pdf','');
          else
              alert ("pas de donné de session");

          break;


       }




                   }
                }



        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(param);

    }//fin fonction SendData

/*
 function pdf_open()
          {
          chemin= String(document.location).split('/');
            if (chemin[3])
                {
                }
            else
                {
                chemin[3]="fr";
                }
          window.open("/"+chemin[3]+"/pdf.php",'pdf','');
          }
  */
function printDoc (laPage) {
var w = screen.width / 1.5;
var h = screen.height / 1.5;
var winl = (screen.width - w) / 2;
printWin=window.open(laPage, 'print', 'width='+w+',height='+h+',top=0,left='+winl+',scrollbars=yes,menubar=yes')
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length;
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

