function startRequest()
{
  tfKodText = document.getElementById('tfKod').value;
  var btnWejdz = document.getElementById('btnWejdz');
  btnWejdz.disabled = true;

  hash = hex_sha1(tfKodText);
  url = "http://localhost/dane.php?hash=" + hash;
  url = encodeURI(url);

  startGETRequest(url, onComplete, onEnd);
}

function onComplete(text, xml)
{
  if(text.substr(0, 5) == "error"){
    arr = text.split("\n");
    if(arr.length != 2){
      alert("Nieprawidłowa odpowied serwera.");
    }
    else{
      alert(arr[1]);
    }
  }
  else{
    var mainDiv = document.getElementById('mainDiv');
    mainDiv.innerHTML = text;
  }
}

function onEnd()
{
  var btnWejdz = document.getElementById('btnWejdz');
  if(btnWejdz)
    btnWejdz.disabled = false;
}