// JavaScript Document
function permutPhoto (id, nom_photo, mtop, mlefet) {
	
		//alert(mtop);
	if (elem = document.getElementById(id)) {
		elem.src = 'images/produits_images/Grandes/'+nom_photo;
		
		elem.style.marginTop = mtop+'px';
		elem.style.marginLeft = mlefet+'px';
	}
}





/************** ajax ***************/



function getXMLHTTP(){
	
	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) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e1) {
				xhr = null;
			}
		}
	}
	else { // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	}
	return xhr;
}


/* ....................... Changer select niveau 4 ............................*/

function getNiv3 (id_select, id_res_div, id_rub, id_srub) {
	
	var id_niv3 = document.getElementById(id_select).value;
	
	if (!id_niv3) return false;
	
	var xhr = getXMLHTTP();
	
	xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) {
				  
				  eval('var tabres ='+xhr.responseText);
				
				  //alert(tabres['txt']);
				  
				 
				 /****   panier   ****/
				 /* if (tabres['disponibilite'] == 'non')
				  document.getElementById('id_div_pan').innerHTML = 'Actuellement indisponible';
				  else if (tabres['disponibilite'] == 'oui')
				  document.getElementById('id_div_pan').innerHTML = '<a href="javascript:VerifFormFiche();"><img src="images/panier.gif" width="120" height="25" border="0"  /></a>'; */
				 /*********************/
				  
				 
                 document.getElementById(id_res_div).innerHTML = tabres['txt']; 
			  }
              /*else 
                 document.ajax.dyn="Error code " + xhr.status;*/
         }
    }; 

    xhr.open("POST", "ajax-post-niv4.php", true);
 	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
 	xhr.send("id_niv3="+id_niv3+"&id_rub="+id_rub+"&id_srub="+id_srub);
} 


/* ....................... Changer liste produit de niveau 3............................*/

function getProd3 (id_select, id_res_div, rub, srub, id_niv3) {
	
	var niveau4 = document.getElementById(id_select).value;
	
	if (!niveau4) return false;
	
	var xhr = getXMLHTTP();
	
	xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) {
				  
				  eval('var tabres ='+xhr.responseText);
				
				  //alert(tabres['txt']);
				  
				 
				 /****   panier   ****/
				 /* if (tabres['disponibilite'] == 'non')
				  document.getElementById('id_div_pan').innerHTML = 'Actuellement indisponible';
				  else if (tabres['disponibilite'] == 'oui')
				  document.getElementById('id_div_pan').innerHTML = '<a href="javascript:VerifFormFiche();"><img src="images/panier.gif" width="120" height="25" border="0"  /></a>'; */
				 /*********************/
				  
				 
                 document.getElementById(id_res_div).innerHTML = tabres['txt']; 
			  }
              /*else 
                 document.ajax.dyn="Error code " + xhr.status;*/
         }
    }; 

    xhr.open("POST", "ajax-post-prod3.php", true);
 	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
 	xhr.send("niveau4="+niveau4+"&rub_id="+rub+"&srub_id="+srub+"&niveau3"+id_niv3);
} 



function getPrixDis (id_select_cond, id_prod, id_res_div_prix, barre) {
	
	//alert(id_select_cond);
 
	//alert(id_select_cont+"::::"+id_select_cond+"::::"+id_prod+"::::"+id_res_div_prix+"::::"+id_div_pan);
	
	
	var id_conditionnement = document.getElementById(id_select_cond).value;
	
	
	if (!id_conditionnement) return false;
	
	var xhr = getXMLHTTP();
	
	xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) {
				  //alert(xhr.responseText);
				  eval('var tabres ='+xhr.responseText);
				 // alert(tabres['disponibilite']);
				  
				 
				 /****   panier   ****/
				/*  if (tabres['disponibilite'] == 'non')
				  document.getElementById(id_div_pan).innerHTML = 'Actuellement indisponible';
				  else if (tabres['disponibilite'] == 'oui')
				  document.getElementById(id_div_pan).innerHTML = '<a href="javascript:VerifFormFiche();"><img src="images/panier.gif" width="120" height="25" border="0"  /></a>';
				 /*********************/
				 
				 
				 
				 
				 
				 /**** prix ****/
				  document.getElementById(id_res_div_prix).innerHTML = tabres['prix_reel'];
				  document.getElementById(barre).innerHTML = tabres['minprix']; 
				 
				 /**************/
				 
				 
				  
                 //document.getElementById(id_res_div).innerHTML = xhr.responseText; 
			  }
              /*else 
                 document.ajax.dyn="Error code " + xhr.status;*/
         }
    }; 

    xhr.open("POST", "ajax-post-fiche_prod2.php", true);
 	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
 	xhr.send("id="+id_prod+"&id_conditionnement="+id_conditionnement);
} 




/************************************/
