function changeImg(iId)
{
  url = "http://localhost/galeria.php?iid=" + iId;
  url = encodeURI(url);
  startGETRequest(url, onImgComplete, onEnd);
}

function changeThPage(pId)
{
  url = "http://localhost/galeria.php?pid=" + pId;
  url = encodeURI(url);
  startGETRequest(url, onThComplete, onEnd);
}

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

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

function onEnd()
{
}
