function getHTTPObject() // Function pour créer l'objet xmlhttprequest //
     {
         var xmlhttp=false;
         try
         {
               xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
         }
         catch (e)
         {
             try
             {
                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
             }
             catch (e)
             {
                 xmlhttp = false;
             }
         }

         if (!xmlhttp && typeof XMLHttpRequest != "undefined")
         {
             xmlhttp = new XMLHttpRequest();
         }
         return xmlhttp;
     }
//fonction permettant de vider le cache
// résolvant un bug sous IE
function vider_cache(xmlhttp){
  var xmlhttp = xmlhttp;
  xmlhttp.setRequestHeader("Pragma","no-cache");
  xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}

function input_ajout_panier(pid,input_id,osCsid )
{
//ici on va recupere la valeur de l input ajouter les param pour la foo "ajout_panier" 
//alert('pid->'+pid+'| input_id->'+input_id+'|osCsid ->'+osCsid );
var input_quant = document.getElementById(input_id);
var quant = parseInt(input_quant.value); 
ajout_panier(pid,quant,osCsid );

// HACK IE 

nav = navigator.appName.substring(0,3);
if (nav == "Mic" ){ 
//alert('mic'); 
document.getElementById('c_img_'+input_id).innerHTML ='<img  style="position:relative;bottom:90px;left:120px"  src="article_ajoute.gif"  />';} 
else {
document.getElementById('c_img_'+input_id).innerHTML ='<img  style="position:relative;bottom:90px;left:120px"  src="article_ajoute.gif"  />';
}
//alert('c_img_+input_id ->'+'c_img_'+ input_id );
setTimeout (function(){ document.getElementById('c_img_'+input_id).innerHTML =' ';valider_commande(); } , 1000);
}

//products_id=148&quant=2&action=buy_now&sort=2a&osCsid=08f63cde02b9ad6a583754c74421b923
function ajout_quant(input_id,operateur)
{
var input_quant = document.getElementById(input_id);
if(operateur=='plus') {input_quant.value = parseInt(input_quant.value) + 1 };
if( (operateur=='min') && ( parseInt(input_quant.value)!=1) ){input_quant.value = parseInt(input_quant.value) - 1 };
; }

function valider_commande(){
document.getElementById('valider_commande').style.display ='block';
}

function ajout_panier(pid,quant,osCsid ) {
	
    var xmlhttp = getHTTPObject();
    var span_cart_box = document.getElementById('span_cart_box');
    span_cart_box.innerHTML = "<img  style='position:relative; top:3px'   src='cart-loader.gif' />";
    xmlhttp.open("GET", 'getCartBox.php?products_id='+pid+'&quant='+quant+'&action=buy_now&osCsid='+osCsid+'&Cart=true');
    vider_cache(xmlhttp);
    xmlhttp.onreadystatechange = function() {
           if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
           span_cart_box.innerHTML = xmlhttp.responseText;
           }
       }
     xmlhttp.send(null);

}



