


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":
          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() ;
                      }
                  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;

//********************************************************
//       boutique
//********************************************************
       case "panier_simple":
       case "panier_simple_add":
          id_div="panier_simple";
          page="boutique/inc/panier-simple.inc.php";
          param=param+"&action="+action;
          break;
       case "panier_complet":
       case "panier_complet_add":
       case "panier_complet_reset":
       case "panier_complet_del":
       case "portpanier":

          id_div="panier_complet";
          page="boutique/inc/panier-complet.inc.php";
          param=param+"&action="+action;
          break;
       case "commande_add":
          //id_div="commande_add";
		  
          page="boutique/inc/commande.inc.php";
          param=param+"&action="+action;
          break;
       case "commande_adresse_livraison":
       case "commande_type_paiement":
       case "commande_mode_livraison":
          param=param+"&action="+action;
          break;
       case "motdepasseoublie":
          //
          id_div="oubliemess";

          email=document.getElementById('emailoublie').value;
          param="email="+email+"&action="+action;
          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].length==2)
            {
            
            }
        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);
                   if (id_div)
                         content.innerHTML = XhrObj.responseText ;
                   }
                }
    switch (action)
       {
       case "accessibilite":
           // accessibilite

           setTimeout("window.location='"+url+"'", 500);
           break;
       case "pdf":
             setTimeout("window.open('/"+chemin[3]+"/pdf.php','pdf','')", 500);
          //popupWin=window.open('pdf.php','pdf','');
          break;
       case "panier_simple_add":
	   if (chemin[3]=="it")
          alert ("L'articolo é stato agiunto nel carrelo") ;
	   else
          if (chemin[3]=="es")
			  alert("El artículo ha sido añadido a tu cesta");
	      else
		  		if (chemin[3]=="nl")
			  		alert("Het artikel is toegevoegd aan uw mandje");
	      		else
					alert ("L'article a été ajouté à votre panier") ;

          break;
       case "commande_add":
          setTimeout("window.location=('/"+chemin[3]+"/boutique/paiement2.php')", 500);
          break;


       }


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

    }//fin fonction SendData

function paniercgv()
    {
    chemin= String(document.location).split('/');

    if (document.getElementById("cgv").checked  )
        window.location='/'+chemin[3]+'/boutique/compte.php';
    else
        alert (document.getElementById("message_cgv").value);  //"");
    }


// fonction de traitement taille des texte (accessibilite)
function change(tag)
{
var taille
                        switch(tag)
                        {


                                case "plus":
                                                if(parseInt(document.getElementById('FOcontenupage').style.fontSize)<24)
                                                {
                                                taille = parseInt(document.getElementById('FOcontenupage').style.fontSize)
                                                taille = taille+1
                                                document.getElementById('FOcontenupage').style.fontSize=taille + 'px';
                                                SetCookie('wi',document.getElementById('FOcontenupage').style.fontFamily+';'+document.getElementById('FOcontenupage').style.fontSize,'365');
                                                }
                                                break;

                                case "moins":
                                                if(parseInt(document.getElementById('FOcontenupage').style.fontSize)>9)
                                                {
                                                taille = parseInt(document.getElementById('FOcontenupage').style.fontSize)
                                                taille = taille-1
                                                        document.getElementById('FOcontenupage').style.fontSize=taille + 'px';
                                                        SetCookie('wi',document.getElementById('FOcontenupage').style.fontFamily+';'+document.getElementById('FOcontenupage').style.fontSize,'365');
                                                }
                                        break;
                        }
}

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));
}
