//***************** diaporama mini à droite
function pospdiapomini()
{
    for (i=0;i<6;i++)
    {
    z=(document.getElementById("filmini").style.top.charAt(i));
    if (z == "p")
        {
        p=i;
        }
    }
return p;           
}                                                               


function defildiapominid()
{
var p=pospdiapomini();
v=5;
    x=document.getElementById("filmini").offsetHeight;
    y=document.getElementById("fenetremini").offsetHeight;
    h=(document.getElementById("filmini").style.top.substr(0,p));
    tdiapomini=setTimeout("defildiapominid()",50);

    //alert(" x= "+x+" y= "+y+" h= "+h);
    if ((parseInt(h))>=0)
    {
     clearTimeout(tdiapomini);
     
    }
    else
    {
     document.getElementById("filmini").style.top = (parseInt(h)+ parseInt(v))+"px";
    }
}

function defildiapominig()     //idem defildiapomini
{
var p=pospdiapomini();
v=5;
    x=document.getElementById("filmini").offsetHeight;
    y=document.getElementById("fenetremini").offsetHeight;
    h=(document.getElementById("filmini").style.top.substr(0,p));
    tdiapomini=setTimeout("defildiapominig()",50);

        //alert(" x= "+x+" y= "+y+" h= "+h);
    if ((parseInt(h)+parseInt(x))<=parseInt(y))
    {
     clearTimeout(tdiapomini);
    
    }
    else
    {
     document.getElementById("filmini").style.top = (parseInt(h)- parseInt(v))+"px";
    }
}


function defildiapominidL()
{
var p=pospdiapomini();
v=5;
    clearTimeout(tdiapomini);
    x=document.getElementById("filmini").offsetHeight;
    y=document.getElementById("fenetremini").offsetHeight;
    h=(document.getElementById("filmini").style.top.substr(0,p));
    tdiapomini=setTimeout("defildiapominidL()",50);

    //alert(" x= "+x+" y= "+y+" h= "+h);
    if ((parseInt(h))>=0)
    {
     clearTimeout(tdiapomini);
     
    }
    else
    {
     document.getElementById("filmini").style.top = (parseInt(h)+ parseInt(v))+"px";
    }
}

function defildiapominidV()
{
var p=pospdiapomini();
v=10;
    clearTimeout(tdiapomini);
    x=document.getElementById("filmini").offsetHeight;
    y=document.getElementById("fenetremini").offsetHeight;
    h=(document.getElementById("filmini").style.top.substr(0,p));
    tdiapomini=setTimeout("defildiapominidV()",10);

    //alert(" x= "+x+" y= "+y+" h= "+h);
    if ((parseInt(h))>=0)
    {
     clearTimeout(tdiapomini);
     
    }
    else
    {
     document.getElementById("filmini").style.top = (parseInt(h)+ parseInt(v))+"px";
    }
}


function defildiapominigL()     //idem defildiapomini
{

var p=pospdiapomini();
v=5;
    clearTimeout(tdiapomini);
    x=document.getElementById("filmini").offsetHeight;
    y=document.getElementById("fenetremini").offsetHeight;
    h=(document.getElementById("filmini").style.top.substr(0,p));
    tdiapomini=setTimeout("defildiapominigL()",50);

    //alert(" x= "+x+" y= "+y+" h= "+h);;
    if ((parseInt(h)+parseInt(x))<=parseInt(y))
    {
     clearTimeout(tdiapomini);
    
    }
    else
    {
     document.getElementById("filmini").style.top = (parseInt(h)- parseInt(v))+"px";
    }
}


function defildiapominigV()     //idem defildiapomini
{

var p=pospdiapomini();
v=10;
    clearTimeout(tdiapomini);
    x=document.getElementById("filmini").offsetHeight;
    y=document.getElementById("fenetremini").offsetHeight;
    h=(document.getElementById("filmini").style.top.substr(0,p));
    tdiapomini=setTimeout("defildiapominigV()",10);

    //alert(" x= "+x+" y= "+y+" h= "+h);;
    if ((parseInt(h)+parseInt(x))<=parseInt(y))
    {
     clearTimeout(tdiapomini);
    
    }
    else
    {
     document.getElementById("filmini").style.top = (parseInt(h)- parseInt(v))+"px";
    }
}

//************* fin du diaporam mini

//************* diaporama menu à gauche
function pospdiapo()
{
    for (i=0;i<6;i++)
    {
    z=(document.getElementById("film").style.top.charAt(i));
    if (z == "p")
        {
        p=i;
        }
    }
return p;           
}                                                               


function defildiapod()
{
var p=pospdiapo();
v=5;
    x=document.getElementById("film").offsetHeight;
    y=document.getElementById("fenetre").offsetHeight;
    h=(document.getElementById("film").style.top.substr(0,p));
    tdiapo=setTimeout("defildiapod()",50);

    //alert(" x= "+x+" y= "+y+" h= "+h);
    if ((parseInt(h))>=0)
    {
     clearTimeout(tdiapo);
     
    }
    else
    {
     document.getElementById("film").style.top = (parseInt(h)+ parseInt(v))+"px";
    }
}

function defildiapog()     //idem defildiapo
{
var p=pospdiapo();
v=5;
    x=document.getElementById("film").offsetHeight;
    y=document.getElementById("fenetre").offsetHeight;
    h=(document.getElementById("film").style.top.substr(0,p));
    tdiapo=setTimeout("defildiapog()",50);

        //alert(" x= "+x+" y= "+y+" h= "+h);
    if ((parseInt(h)+parseInt(x))<=parseInt(y))
    {
     clearTimeout(tdiapo);
    
    }
    else
    {
     document.getElementById("film").style.top = (parseInt(h)- parseInt(v))+"px";
    }
}


function defildiapodL()
{
var p=pospdiapo();
v=5;
    clearTimeout(tdiapo);
    x=document.getElementById("film").offsetHeight;
    y=document.getElementById("fenetre").offsetHeight;
    h=(document.getElementById("film").style.top.substr(0,p));
    tdiapo=setTimeout("defildiapodL()",50);

    //alert(" x= "+x+" y= "+y+" h= "+h);
    if ((parseInt(h))>=0)
    {
     clearTimeout(tdiapo);
     
    }
    else
    {
     document.getElementById("film").style.top = (parseInt(h)+ parseInt(v))+"px";
    }
}

function defildiapodV()
{
var p=pospdiapo();
v=10;
    clearTimeout(tdiapo);
    x=document.getElementById("film").offsetHeight;
    y=document.getElementById("fenetre").offsetHeight;
    h=(document.getElementById("film").style.top.substr(0,p));
    tdiapo=setTimeout("defildiapodV()",10);

    //alert(" x= "+x+" y= "+y+" h= "+h);
    if ((parseInt(h))>=0)
    {
     clearTimeout(tdiapo);
     
    }
    else
    {
     document.getElementById("film").style.top = (parseInt(h)+ parseInt(v))+"px";
    }
}


function defildiapogL()     //idem defildiapo
{

var p=pospdiapo();
v=5;
    clearTimeout(tdiapo);
    x=document.getElementById("film").offsetHeight;
    y=document.getElementById("fenetre").offsetHeight;
    h=(document.getElementById("film").style.top.substr(0,p));
    tdiapo=setTimeout("defildiapogL()",50);

    //alert(" x= "+x+" y= "+y+" h= "+h);;
    if ((parseInt(h)+parseInt(x))<=parseInt(y))
    {
     clearTimeout(tdiapo);
    
    }
    else
    {
     document.getElementById("film").style.top = (parseInt(h)- parseInt(v))+"px";
    }
}


function defildiapogV()     //idem defildiapo
{

var p=pospdiapo();
v=10;
    clearTimeout(tdiapo);
    x=document.getElementById("film").offsetHeight;
    y=document.getElementById("fenetre").offsetHeight;
    h=(document.getElementById("film").style.top.substr(0,p));
    tdiapo=setTimeout("defildiapogV()",10);

    //alert(" x= "+x+" y= "+y+" h= "+h);;
    if ((parseInt(h)+parseInt(x))<=parseInt(y))
    {
     clearTimeout(tdiapo);
    
    }
    else
    {
     document.getElementById("film").style.top = (parseInt(h)- parseInt(v))+"px";
    }
}

//************* fin du diaporama menu

function diapozoom(c)
{
    document.getElementById("debut").style.visibility='hidden';
       
    efface();
 
    image ="photo"+c ;
    document.getElementById("compteur").style.left = parseInt(c)+"px";
    document.getElementById(image).style.visibility='visible';

}

function efface()
{
        d=0;
        image ="photo"+d;
        while (document.getElementById(image))
        {
          document.getElementById(image).style.visibility='hidden';
          d++;
          image ="photo"+d ;
        }
}




function plus()
 {
 var c=document.getElementById("quantite").innerHTML;
 c++;
 document.getElementById("quantite").innerHTML = c ;
 }
 
function moins()
 {
 var c=document.getElementById("quantite").innerHTML;
 c--;
 if (c<=1) c=1;
 document.getElementById("quantite").innerHTML = c ;
 }

 
//ajax
function makeRequest(url)
		{
		//alert ('url ='+url);
		var xmlHttpReq = false;
    var self = this;
    
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', url, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 
    				'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) 
        {
            ActionRetourEnvoiPanier(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(valeurspost());
	
}
	
function valeurspost()
{
	var form = document.forms["panier"];
	if (form.article)
	{
	var quantite = document.getElementById("quantite").innerHTML;
	var nom = form.nom.value;
	var article = form.article.value;
	var couleur = form.couleur.value;
	var prix = form.prix.value;
	var poids = form.poids.value;
	 

	qstr = 'quantite=' + quantite + '&nom=' + nom + '&article=' + article + '&couleur=' + couleur + '&prix=' + prix + '&poids=' + poids; 
	//alert ('dans panier qstr ='+qstr);
	return qstr;
	}
}

function ActionRetourEnvoiPanier(retour) 
{
 if (retour == "plein")
 {
 alert ('article ajouté au panier');
 var c=document.getElementById("quantite").innerHTML="1";
 }
 if (retour == "vide")
 {
 alert ('aucun article sélectionné');
 }
}

function VoirPanierRequest(url,ope,ordre)
{
	//alert ('url ='+url);
	var xmlHttpReq = false;
  var self = this;
  
  // Mozilla/Safari
  if (window.XMLHttpRequest) {
      self.xmlHttpReq = new XMLHttpRequest();
  }
  // IE
  else if (window.ActiveXObject) {
      self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }
  self.xmlHttpReq.open('POST', url, true);
  self.xmlHttpReq.setRequestHeader('Content-Type', 
  				'application/x-www-form-urlencoded');
  self.xmlHttpReq.onreadystatechange = function() {
      if (self.xmlHttpReq.readyState == 4) 
      {
          ActionRetourVoirPanier(self.xmlHttpReq.responseText);
      }
  }
  self.xmlHttpReq.send( ActionVoirPanier(ope,ordre));
}

function ActionVoirPanier(ope,ordre)
{
	qstr = 'ope=' + ope + '&ordre=' + ordre; 
	//alert ('dans panier qstr ='+qstr);
	return qstr;
}

function ActionRetourVoirPanier(retour)
{
 var panier = eval('(' + retour + ')');
 //alert(panier.operation + ' ' + panier.ordre);
 
 var operation = panier.operation;
 var ordre =  panier.ordre;
 
 if (operation == "plus")
 {
 		//alert('plus');
 		document.getElementById('qte'+ordre).innerHTML = parseInt(document.getElementById('qte'+ordre).innerHTML)+1;
 		document.getElementById('total'+ordre).innerHTML = ajoutdecimales(parseInt(document.getElementById('total'+ordre).innerHTML) + parseInt(document.getElementById('prix'+ordre).innerHTML));
 		document.getElementById('totalcommande').innerHTML = ajoutdecimales(parseInt(document.getElementById('totalcommande').innerHTML ) + parseInt(document.getElementById('prix'+ordre).innerHTML ));
 		
 	}
 	
 	if ( (operation == "moins") && (document.getElementById('qte'+ordre).innerHTML>0) )
 {
 		//alert('moins');
 		document.getElementById('qte'+ordre).innerHTML = parseInt(document.getElementById('qte'+ordre).innerHTML)-1;
 		document.getElementById('total'+ordre).innerHTML = ajoutdecimales(parseInt(document.getElementById('total'+ordre).innerHTML) - parseInt(document.getElementById('prix'+ordre).innerHTML));
 		document.getElementById('totalcommande').innerHTML = ajoutdecimales(parseInt(document.getElementById('totalcommande').innerHTML ) - parseInt(document.getElementById('prix'+ordre).innerHTML ));
 		
 	}
 	
 	 	if ( (operation == "zero") || (document.getElementById('qte'+ordre).innerHTML=="0") )
 	{
 		//alert('zero');
 		//window.location.reload();
 		window.location.replace("panier.php");
 	}
 	
 	
}

function ajoutdecimales(nombre)
{
nombre += ""; //conversion de int en sting
//alert ("nombre = "+nombre);

var longueurdunombre = (nombre.length);
//alert ("longueurdunombre ="+longueurdunombre);
var positiondupoint = nombre.indexOf(".",0);
//alert ("positiondupoint ="+positiondupoint);
var longueuraprespoint= ((nombre.substr(positiondupoint + 1,longueurdunombre - positiondupoint)).length);

	if ( positiondupoint == "-1") nombre=nombre+'.00';
	else
	{
	if (longueuraprespoint == 1) nombre = nombre+'0';
	if (longueuraprespoint == 2) nombre = nombre ;
	}	
return nombre;
//alert ("nombre transformé = "+nombre);
}

function montre(elmt)
{
//alert (elmt);
document.getElementById(elmt).style.visibility = "visible";
document.getElementById('listecouleurs').style.visibility = "hidden";
}

function cache(elmt)
{
document.getElementById(elmt).style.visibility = "hidden";
document.getElementById('listecouleurs').style.visibility = "visible";
}


//montre les couleurs
function montrecouleursRequest(url,articlesansid,articleencode,prix,poids)
{
//alert (divid);
var xmlHttpReq = false;
  var self = this;
  
  // Mozilla/Safari
  if (window.XMLHttpRequest) {
      self.xmlHttpReq = new XMLHttpRequest();
  }
  // IE
  else if (window.ActiveXObject) {
      self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }
  self.xmlHttpReq.open('POST', url, true);
  self.xmlHttpReq.setRequestHeader('Content-Type', 
  				'application/x-www-form-urlencoded');
  self.xmlHttpReq.onreadystatechange = function() {
      if (self.xmlHttpReq.readyState == 4)
      {
          ActionRetourMontreCouleurs(self.xmlHttpReq.responseText,articlesansid,prix);
      }
  }
  self.xmlHttpReq.send(ActionMontreCouleurs(articlesansid,articleencode,prix,poids));
}


function ActionMontreCouleurs(articlesansid,articleencode,prix,poids)
{
	qstr = 'articlesansid=' + articlesansid + '&articleencode=' + articleencode + '&prix=' + prix + '&poids=' + poids; 
	//alert ('dans affichecouleurs qstr ='+qstr);
	return qstr;
}

function ActionRetourMontreCouleurs(retour,articlesansid,prix)
{
 document.getElementById('articlecouleur').style.visibility = "visible";
 document.getElementById('articlecouleur').innerHTML = articlesansid;
 document.getElementById('idprix').innerHTML = prix +"&euro;";
 document.getElementById('plusmoins').style.visibility = "visible";
 document.getElementById('listecouleurs').innerHTML = retour;
 document.getElementById('collection').style.visibility = "hidden";
 
}


//enregistre les coordonnées
function EnregCoordsRequest(url,objet)
{
//alert (objet);
var xmlHttpReq = false;
  var self = this;
  
  // Mozilla/Safari
  if (window.XMLHttpRequest) {
      self.xmlHttpReq = new XMLHttpRequest();
  }
  // IE
  else if (window.ActiveXObject) {
      self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }
  self.xmlHttpReq.open('POST', url, true);
  self.xmlHttpReq.setRequestHeader('Content-Type', 
  				'application/x-www-form-urlencoded');
  self.xmlHttpReq.onreadystatechange = function() {
      if (self.xmlHttpReq.readyState == 4)
      {
          ActionRetourEnregCoords(self.xmlHttpReq.responseText,objet);
      }
  }
  self.xmlHttpReq.send(ActionEnregCoords(objet));
}


function ActionEnregCoords(objet)
{
	if ((objet=='cheque') || (objet=='paypal')) {var valeur=objet;var objet='reglement';}
	
	var form = document.forms["infosclient"];
	if (objet=='nom') var valeur = form.nom.value;
	if (objet=='email') var valeur = form.email.value;
	if (objet=='tel') var valeur = form.tel.value;
	if (objet=='adresse') var valeur = form.adresse.value;
	if (objet=='message') var valeur = form.message.value;
	
	qstr = 'objet=' + escape(objet) + '&valeur=' + escape(valeur); 
	//alert ('dans ActionEnregCoords qstr ='+qstr);
	return qstr;
}

function ActionRetourEnregCoords(retour,objet)
{
 //alert(retour);
 //document.getElementById(eval(objet)).innerHTML = retour;
}


//envoi commande
function EnvoiCommandeRequest(url,objet)
{
//alert (objet);
var xmlHttpReq = false;
  var self = this;
  
  // Mozilla/Safari
  if (window.XMLHttpRequest) {
      self.xmlHttpReq = new XMLHttpRequest();
  }
  // IE
  else if (window.ActiveXObject) {
      self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }
  self.xmlHttpReq.open('POST', url, true);
  self.xmlHttpReq.setRequestHeader('Content-Type', 
  				'application/x-www-form-urlencoded');
  self.xmlHttpReq.onreadystatechange = function() {
      if (self.xmlHttpReq.readyState == 4)
      {
          ActionRetourEnvoiCommande(self.xmlHttpReq.responseText);
      }
  }
  self.xmlHttpReq.send(ActionEnvoiCommande(objet));
}


function ActionEnvoiCommande(objet)
{
	qstr = 'objet=' + objet; 
	//alert ('dans ActionEnvoiCommande qstr ='+qstr);
	return qstr;
}

function ActionRetourEnvoiCommande(retour)
{
 alert(retour);
 //document.getElementById(eval(objet)).innerHTML = retour;
}


function AffichePageRequest(pageactive,titre)
{
		
		var xmlHttpReq1 = false;
    var self = this;
    url1 = "page.php?a="+pageactive+"&titre="+titre;
    idpapillon = pageactive.substr(4,4);
    //alert (pageactive);
        
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq1 = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    
    self.xmlHttpReq1.open('GET', url1, true);
    self.xmlHttpReq1.setRequestHeader('Content-Type', 
    				'application/x-www-form-urlencoded');
    
    self.xmlHttpReq1.onreadystatechange = function() {
        if (self.xmlHttpReq1.readyState == 4) {
            actionretourPage(self.xmlHttpReq1.responseText,idpapillon);
        }
    }
    self.xmlHttpReq1.send(null);
}


function actionretourPage(page,idpapillon)
{
//alert (idpapillon);
	document.getElementById("page").innerHTML = page;
	papillon(idpapillon)
}


function papillon(idpapillon)
{

 //alert (idpapillon);
 switch(parseInt(idpapillon))
 {
 case 1000:
    document.getElementById("papillon").style.left = "22px";
    document.getElementById("papillon").style.top = "0px";
    break;

 case 1010:
    document.getElementById("papillon").style.left = "159px";
    document.getElementById("papillon").style.top = "0px";
    break;
    
 case 1110:
    document.getElementById("papillon").style.left = "482px";
    document.getElementById("papillon").style.top = "0px";
    break;
       
 case 1210:
    document.getElementById("papillon").style.left = "740px";
    document.getElementById("papillon").style.top = "0px";
    break;
    
 case 1310:
    document.getElementById("papillon").style.left = "891px";
    document.getElementById("papillon").style.top = "0px";
    break;
    
 case 1409:
    document.getElementById("papillon").style.left = "110px";
    document.getElementById("papillon").style.top = "38px";
    break;
    
 case 1510:
    document.getElementById("papillon").style.left = "470px";
    document.getElementById("papillon").style.top = "38px";
    break;
    
 case 1610:
    document.getElementById("papillon").style.left = "616px";
    document.getElementById("papillon").style.top = "0px";
    break;
    
 case 1710:
    document.getElementById("papillon").style.left = "259px";
    document.getElementById("papillon").style.top = "38px";
    break;
 
 case 2010:
    document.getElementById("papillon").style.left = "682px";
    document.getElementById("papillon").style.top = "38px";
    break;
 
 case 1810:
    document.getElementById("papillon").style.left = "832px";
    document.getElementById("papillon").style.top = "38px";
    break;

 case 1910:
    document.getElementById("papillon").style.left = "323px";
    document.getElementById("papillon").style.top = "0px";
    break;

 case 9010:
    document.getElementById("papillon").style.left = "251px";
    document.getElementById("papillon").style.top = "665px";
    break;

 case 9100:
    document.getElementById("papillon").style.left = "400px";
    document.getElementById("papillon").style.top = "665px";
    break;

 case 9500:
    document.getElementById("papillon").style.left = "579px";
    document.getElementById("papillon").style.top = "665px";
    break;

 case 9200:
    document.getElementById("papillon").style.left = "551px";
    document.getElementById("papillon").style.top = "695px";
    break;

 case 9300:
    document.getElementById("papillon").style.left = "340px";
    document.getElementById("papillon").style.top = "695px";
    break;

 case 9400:
    document.getElementById("papillon").style.left = "709px";
    document.getElementById("papillon").style.top = "665px";
    break;
	
 default :
		document.getElementById("papillon").style.left = "22px";
    document.getElementById("papillon").style.top = "0px";
  }
}

function papillonpanier()
{
	document.getElementById("papillonpanier").innerHTML =
	 	'<object height="56" width="59">\n'
	 +'<param name="movie" value="images/papillon volant.swf">\n'
	 +'<param name="quality" value="high">\n'
	 +'<param name="wmode" value="transparent">\n'
	 +'<embed src="images/papillon volant.swf" wmode="transparent" quality="high" type="application/x-shockwave-flash" width="59" height="56"></embed>\n'
	 +'</object>\n';
}


function survol(action,classe,nom)
{
	//alert ("classe = "+classe+", action = "+action+", page = "+nom);
	if (action=="over")
	{
		document.getElementById(nom).className = "actifM" ;
	}
	
	if (action=="out")
	{
		document.getElementById(nom).className = classe ;
	}
	
}
