
var oXHR = null;

function aggiungi_carrello(id_articolo_ordine) 
{

	

if(zXmlHttp.isSupported()) 
{
        

	
	
    oXHR = zXmlHttp.createRequest();
	
	
	var qnt=document.getElementById('qnt').value;

	  if(qnt=="")
	   {
		 qnt=1;

	   }



    oXHR.open('GET', './php/aggiungi_carrello.php?ID='+id_articolo_ordine + '&qnt=' + qnt, true);
   
   
   oXHR.onreadystatechange = function () 
   {               
   
        if (oXHR.readyState == 4)
		{

			
            if (oXHR.status == 200) 
			{
			   var resp = oXHR.responseText;
               
//alert('risp' + resp);		   
//alert(resp);
				
				if( (resp==0) || (resp==2) )
				{
				 	  // modifico il contenuto del carrello  
                  var val=document.getElementById('el_nel_car').innerHTML;

                  // alert('dentro val '+ val);

				  document.getElementById('el_nel_car').innerHTML="";
				  document.getElementById('el_nel_car').innerHTML=parseInt(val) + 1;
				  
				  if(resp==0)
				  {
				    alert('Prodotto aggiunto al tuo carrello');
				  }
				  
				if(resp==2)
				  {
				    alert('ATTENZIONE : IL Prodotto e\' stato aggiunto al tuo carrello ma ti ricordiamo che e\' IN ARRIVO e non immediatamente disponibile in magazzino.');
				  }			  
				  
				}
				else
				{
				
 						
						
				  
				if(resp==3)
				  {
				    alert('ATTENZIONE : IL Prodotto e\' stato aggiornato ma ti ricordiamo che e\' IN ARRIVO e non immediatamente disponibile in magazzino.');
				  }	
				  else
				  {
					  alert('Prodotto aggiornato');
				  }
						
						
				}
			 } 
			else 
			{
                alert("An error occurred while trying to contact the server."+oXHR.status);
            }
        }
    };
    
    iTimeoutId = setTimeout(function () {
        oXHR.send(null);
    }, 500);
};

};
