function startRequest()
{
  tfUserText = document.getElementById('tfUser').value;
  tfPassText = document.getElementById('tfPass').value;
  btnWejdz = document.getElementById('btnWejdz');
  btnWejdz.disabled = true;

  passHash = hex_sha1(tfPassText);
  url = "http://localhost/dane.php?user=" + tfUserText;
  url += "&pass=" + passHash;
  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;
}