var url = "../../phtml/GuardarCesta.php"; // The server-side script
var pedido = "" ;
var accio = 0 ;

function handleHttpResponse() {
  if (http.readyState == 4) {
    if (http.responseText.indexOf('invalid') == -1) {
      // Use the XML DOM to unpack the city and state data
      var xmlDocument = http.responseXML;
			
     	var resposta = xmlDocument.getElementsByTagName('resposta').item(0).firstChild.data;
			if (resposta == "ko")
      	alert('No se pudo guardar la cantidad') ;
//			else	
//      	alert('Cantidad guardada correctamente') ;
				
      isWorking = false;
    } // if (http.responseText.indexOf('invalid') == -1)
  } // if (http.readyState == 4)
} // function handleHttpResponse()
var isWorking = false;

function actualitzaCantidad(PED_Codigo,PRO_ID,CES_COLOR,CES_COLORAUX,CES_COLORAUX2,CES_COLORAUX3) {
  accio = 0 ;
  if (!isWorking && http) {
    var Cantidad = document.form1["Cantidad"+PRO_ID+CES_COLOR+CES_COLORAUX+CES_COLORAUX2+CES_COLORAUX3].value;
    http.open("POST", url, true) ;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') ;
    http.onreadystatechange = handleHttpResponse ;
    var postcad = 'PED_Codigo=' + escape(PED_Codigo) + '&PRO_ID=' + escape(PRO_ID) + '&Cantidad=' + escape(Cantidad) + '&CES_COLOR=' + escape(CES_COLOR) + '&CES_COLORAUX=' + escape(CES_COLORAUX) + '&CES_COLORAUX2=' + escape(CES_COLORAUX2) + '&CES_COLORAUX3=' + escape(CES_COLORAUX3)  ;
    isWorking = true;
    http.send(postcad);
  }
}


function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml");
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
