function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}



http = getXMLHTTPRequest();


function doCos(item, id, variabila) {
  var bucati = document.getElementById(variabila).value;
  if (bucati != "" && bucati != 0) {
	  if (!isNaN(bucati)){
		  var myurl = 'intermediar.php?item='+item+'&id='+id+'&bucati='+bucati;
		  myRand = parseInt(Math.random()*999999999999999);
		  // add random number to URL to avoid cache problems
		  var modurl = myurl+"&rand="+myRand;
		  http.open("GET", modurl, true);
		  // set up the callback function
		  http.onreadystatechange = useHttpResponse;
		  http.send(null);
	  }
  }
}


function useHttpResponse() {
   if (http.readyState == 4) {
    if(http.status == 200) {
       var valoare = http.responseXML.getElementsByTagName("suma_totala")[0];
       document.getElementById('total_final_cos').value = valoare.childNodes[0].nodeValue;
       var nr_produse = http.responseXML .getElementsByTagName("numar_produse")[0];
       document.getElementById('total_produse').value = nr_produse.childNodes[0].nodeValue;
       //document.getElementById('loader').innerHTML = "";
    }
  } else {
   	//document.getElementById('loader').innerHTML = '<img src="./img/ajax_loader.gif">';
  }
}



