


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 calculprix(option)
         {
         prixbaseventettc=document.getElementById("prix_base_vente_ttc").value;
         prixmodele=document.getElementById("prix_modele").value;
         idproduit=document.getElementById("id_produit2").value;
         pos=option.indexOf("|", 0);
         idtypeoption=option.substring(0, pos);
         option=option.substring( (pos+1),option.length);
         pos=option.indexOf("|", 0);
         id_option=option.substring(0, pos);
         option=option.substring( (pos+1),option.length);
         pos=option.indexOf("|", 0);
         prix_option=option.substring(0, pos);
         photo_option=option.substring( (pos+1),option.length);
         //alert("id_type : "+idtypeoption+" | id : "+id_option+" | prix : "+prix_option+" | photo : "+photo_option);

         // maj liste id option
         id_option_old=document.getElementById("id_option_"+idtypeoption).value;
         listeidoption=document.getElementById("liste_id_option").value;
         listeidoption=listeidoption.replace(","+id_option_old+",",","+id_option+",");
         document.getElementById("liste_id_option").value=listeidoption;
         // fin  maj liste id option

         prix_option_old=document.getElementById("prix_option_"+idtypeoption).value;
         document.getElementById("id_option_"+idtypeoption).value=id_option;


         document.getElementById("photooption").style.display="none";
         document.getElementById("photoproduit").style.display="none";

         // affichage  icone photo
         if (photo_option)
            {
            document.getElementById("photoproduit").style.display="hidden";
            document.getElementById("photo"+idtypeoption).style.visibility="visible";
            document.getElementById("photooption").style.display="block";
            toto=1;
            photoafficheoption(idtypeoption,idproduit);
            toto=2;
            }
         else
             {
             document.getElementById("photo"+idtypeoption).style.visibility="hidden";
            document.getElementById("photooption").style.display="hidden";
             document.getElementById("photoproduit").style.display="block";
             if (document.getElementById("id_type_option_photo"))
                 {

                 idtypeoptionphoto=document.getElementById("id_type_option_photo").value;
                 if (idtypeoptionphoto==idtypeoption)
                     {
                     toto=1;
                     photoafficheoption(idtypeoption,idproduit);
                     toto=2;
                     }
                 }

             }



         prixmodele=(prixmodele*1 - prix_option_old*1) + prix_option*1;

         document.getElementById("prix_modele").value=prixmodele;

         document.getElementById("prix_modele_txt").innerHTML=format(prixmodele,2,"")+" &euro; TTC";

         document.getElementById("prix_option_"+idtypeoption).value=prix_option;




         }
var toto;

function photoafficheoption(idtypeoption, idproduit)
    {
    //alert ("toto : "+toto);
    id_option=document.getElementById("id_option_"+idtypeoption).value;
    if (toto!=1)
        {
        document.getElementById("photooption").style.display="block";
        document.getElementById("photoproduit").style.display="none";
        toto='2';
        }

    param="id_option="+id_option+"&id_produit="+idproduit;
        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("photooption");

        XhrObj.open("POST", 'produit-option.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



//format('1',2,'');
function format(valeur,decimal,separateur) {
// formate un chiffre avec 'decimal' chiffres après la virgule et un separateur
        var deci=Math.round( Math.pow(10,decimal)*(Math.abs(valeur)-Math.floor(Math.abs(valeur)))) ;
        var val=Math.floor(Math.abs(valeur));
        //alert ("val : "+val+" | deci : "+deci);
        //if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.floor(Math.abs(valeur)); deci=0;}

        if ( (decimal==0) ) {val=Math.floor(Math.abs(valeur)); deci=0;}
        if ( (deci==Math.pow(10,decimal)) ) {val=Math.round(Math.abs(valeur)); deci=0;}
        if (deci>99)
            {
            //val=val+1;
            }
        //alert ("val : "+val+" | deci : "+deci);
        var val_format=val+"";
        var nb=val_format.length;
        for (var i=1;i<4;i++) {
                if (val>=Math.pow(10,(3*i))) {
                        val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
                }
        }
        if (decimal>0) {
                var decim="";
                for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
                deci=decim+deci.toString();
                val_format=val_format+"."+deci;
        }
        if (parseFloat(valeur)<0) {val_format="-"+val_format;}
        //alert ("val_format : "+val_format);

        return val_format;
}

function panier(param,action)
    {

    switch (action)
       {
       case "add":
         if (param)
             {
             // liste produit
             idproduit=param;
             listeidoption=document.getElementById("liste_id_option"+idproduit).value;
             qte2=document.getElementById("qte"+idproduit).value;
             }
         else
             {
             // fiche produit
             idproduit=document.getElementById("id_produit2").value;
             listeidoption=document.getElementById("liste_id_option").value;
             qte2=document.getElementById("qte").value;
             }
         param="liste_id_option="+listeidoption+"&id_produit="+idproduit+"&qte="+qte2+"&action="+action+"&id="+param;

         //addToBasket(id_produit);
         break;
       case "addpanier":
          //

          param="action=add&"+param;
         break;
       case "portpanier":
          //

          param="action=portpanier&"+param;
         break;

       default :

         param="&action="+action+"&id="+param;

        }

        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("panier");
        chemin= String(document.location).split('/');
        //alert ("location : "+document.location+" | "+chemin[3]);
        if (chemin[3])
            {
            }
        else
            {
            chemin[3]="fr";
            }
        XhrObj.open("POST", '/'+chemin[3]+'/boutique/inc/panier.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 panier2(param,action)
    {
    switch (action)
       {
       case "add":
          //

         idproduit=document.getElementById("id_produit2").value;
         listeidoption=document.getElementById("liste_id_option").value;
         qte2=document.getElementById("qte").value;
         param="liste_id_option="+listeidoption+"&id_produit="+idproduit+"&qte="+qte2+"&action="+action+"&id="+param;
         break;
       case "addpanier":
          //
          param="action=add&"+param;
         break;
       case "portpanier":
          //

          param="action=portpanier&"+param;
         break;
       case "paiement":
          //

            id=param;
            idtypepaiement=document.getElementById("id_type_paiement2").value;
            param="&action="+action+"&id="+param+"&id_type_paiement="+idtypepaiement;
            break;
       default:
            param="&action="+action+"&id="+param;

        }
   //  alert ("param : "+param);

        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  (action!='paiement')
             var content = document.getElementById("panier");

        var content = document.getElementById("panier");
        chemin= String(document.location).split('/');
        XhrObj.open("POST", '/'+chemin[3]+'/boutique/inc/panier2.inc.php');


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

                if (XhrObj.readyState == 4 && XhrObj.status == 200 )
                   {
                   if (action=='paiement')
                       {
                       //alert ("panier : "+XhrObj.responseText);
                       if  (action=='paiement')
                            {
                            if (id=="cb.php")
                               window.location="paiement2.php?chaine="+XhrObj.responseText;   //  window.location="/"+chemin[3]+"/boutique/paiement2.php?chaine="+XhrObj.responseText;
                            else
                                window.location="confirmation.php?chaine="+XhrObj.responseText;  //  window.location="/"+chemin[3]+"/boutique/confirmation.php?chaine="+XhrObj.responseText;
                            }

                       }
                   else
                       content.innerHTML = XhrObj.responseText ;


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


    }//fin fonction SendData


function gestionadresse(param,action)
    {
    id=param;
    param="action="+action+"&"+param;
     //alert("param : "+id);

    if (action=="del" && id)
        {
        if(confirm("Confirmer la suppression ?") )
           {
           document.getElementById("optiondel"+id).style.display="none";
           document.getElementById("optiondel"+id).style.visibility="hidden";
           document.getElementById('id_adresse_livraison').options[document.getElementById('id_adresse_livraison').selectedIndex].innerHTML="";
           document.getElementById('id_adresse_livraison').options[document.getElementById('id_adresse_livraison').selectedIndex].value="";

           document.getElementById("id_adresse_livraison").selectedIndex=0;
           document.getElementById("adresselivraison").innerHTML="";
           param="action="+action+"&id_del="+id;

           }
        else
            {
            param="action=&id_del=";
            }
        }
    if (action=="view")
        {
        id_adresse=id.substring(11, id.length);
        document.getElementById("adresse_livraison").value=id_adresse;
        if (document.getElementById("adresse_livraison2"))
          document.getElementById("adresse_livraison2").value=id_adresse;
        }

        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 (action!="del")
            var content = document.getElementById("adresselivraison");

        chemin= String(document.location).split('/');
        XhrObj.open("POST", '/'+chemin[3]+'/boutique/inc/adresselivraison.inc.php');


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

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

                if (XhrObj.readyState == 4 && XhrObj.status == 200)
                   {
                    if (action!="del")
                        content.innerHTML = XhrObj.responseText ;
                   }
                }
        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);  //"");
    }

function gestion_FO(param, action)
    {
    id_div="";
    page="inc/gestion_fo.php";
    var page2;
    switch (action)
       {
       case "gestion_produit_avis_add2":
          // gestion calque transaprent
          id_div="page_transparente";
          page2="boutique/inc/avis-produit-add.inc.php";

          for (var j=0; j<=10;j++) {

                        if (document.getElementById('note'+j).checked) note=j;

                       }



          identite=document.getElementById('identite').value;
          lieu=document.getElementById('lieu').value;
          titre=document.getElementById('titre').value;
          avis=document.getElementById('avis').value;
          param="ok=1&id_produit="+param+"&note="+note+"&identite="+identite+"&lieu="+lieu+"&titre="+titre+"&avis="+avis+"&action="+action;

         // alert (param);

          break;


       case "gestion_produit_avis_add":
          // gestion calque transaprent
          id_div="page_transparente";
          page2="boutique/inc/avis-produit-add.inc.php";
          id_div2="pagetransparente";

          // gestion transparence
          document.getElementById(id_div2).style.left=0;
          document.getElementById(id_div2).style.top=0;
          document.getElementById(id_div2).style.display ='block';
          document.getElementById(id_div2).style.margin ='100px';
          document.getElementById(id_div2).style.position ='absolute';
          document.getElementById(id_div2).style.width =(document.body.clientWidth-200)+"px";
          document.getElementById(id_div2).style.height =(document.body.clientHeight-200)+"px";
          document.getElementById(id_div2).style.backgroundColor='#999999';
          document.getElementById(id_div2).style.opacity ='0.5';/* CSS3 et Mozilla récents */
          document.getElementById(id_div2).style.mozopacity ='0.5';           /* Mozilla 1.6 et infér.   */
          document.getElementById(id_div2).style.filter ='alpha(opacity=50)';  /* Internet Explorer 6     */


          document.getElementById(id_div).style.left=0;
          document.getElementById(id_div).style.top=0;
          document.getElementById(id_div).style.display ='block';
          document.getElementById(id_div).style.margin ='100px';
          document.getElementById(id_div).style.position ='absolute';
          document.getElementById(id_div).style.width =(document.body.clientWidth-200)+"px";
          document.getElementById(id_div).style.height =(document.body.clientHeight-200)+"px";




          param="id_produit="+param+"&action="+action;
          break;
       case "gestion_theme_etat":
       case "gestion_page_etat":
          param=param+"&action="+action;
          break;
       case "produitoption":
          //
          id_div="produitoption";
          var idoption1,idoption2,id_type_option_1,id_type_option_2;
          if (document.getElementById('option'+id_type_option_1))
              {
              //idoption1=document.getElementById('option'+id_type_option_1).options[document.getElementById('option'+id_type_option_1).selectedIndex].value;
              //idoption2=document.getElementById('option'+id_type_option_2).options[document.getElementById('option'+id_type_option_2).selectedIndex].value;
              }

          param=param+"&action="+action; //+"&id_option1="+idoption1+"&id_option2="+idoption2;
          //alert (param);
          break;
       case "FO_produitoption_liste":
          // recupere id_produit
          tab=param.split('&');
          tab2=tab[0].split('=');
          idproduit=tab2[1];

          page2="boutique/inc/aj-produit-option.inc.php";
          id_div="produitoption"+idproduit;
          param=param+"&action="+action;
          //alert (param);
          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);

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

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

    }//fin fonction SendData
