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;
}

var http = getXMLHTTPRequest();
  
function getUpsQuote() {
  var myurl = '/upsrateajax.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?action=quote&address_id="+ document.cart_quantity.id_2.options[document.cart_quantity.id_2.options.selectedIndex].value +"&products_id="+document.cart_quantity.products_id.value+"&rand="+myRand;
  http.open("GET", modurl, true);
  http.onreadystatechange = useHttpResponse;
  http.send(null);
}

function getUpsGuess() {
  var myurl = '/upsrateajax.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?action=guess&state="+ document.cart_quantity.state.options[document.cart_quantity.state.options.selectedIndex].value +"&zip="+document.cart_quantity.zip.value+"&products_id="+document.cart_quantity.products_id.value+"&rand="+myRand;
  http.open("GET", modurl, true);
  http.onreadystatechange = useHttpResponse;
  http.send(null);
}


function useHttpResponse() {
   if (http.readyState == 4) {
    if(http.status == 200) { 
       var timeValue = http.responseText; 
       document.getElementById('showtime').innerHTML = timeValue;
    }
  } else {
  document.getElementById('showtime').innerHTML = '<img src="anim.gif">';
  }
}
