var starttime;
var endtime;
var difftime;
var kilobytetest;

var url = "uploadtest.php?param="; // The server-side script

function handleHttpResponse() {

  if (http.readyState == 4) {

  
  var d = new Date();
endtime = d.getMilliseconds();

difftime = (endtime - starttime);
difftime = Math.round(kilobytetest/difftime)

document.getElementById("testuploadN").innerHTML = "Upload brzina: " + Math.abs(difftime) + " kb/s";

    // Split the comma delimited response into an array

    //results = http.responseText.split(",");

    //document.getElementById('city').value = results[0];

    //document.getElementById('state').value = results[1];

  }

}






function updateCityState() {

var zipValue = document.getElementById("zip").value;

var d = new Date();
starttime = d.getMilliseconds();


  http.open("GET", url + escape(zipValue), true);

  http.onreadystatechange = handleHttpResponse;

  http.send(null);


}

var http = getHTTPObject(); // We create the HTTP Object


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();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
