var interval = 10;
var lastHour = -1;
var onprogress = false;

function startRequest()
{
  if(!onprogress){
    hour = (new Date()).getHours();
    if(hour == lastHour){
      setTimeout("startRequest()", interval * 1000);
      return;
    }
    lastHour = hour;

    url = "http://localhost/dane.php?hour=" + hour;
    onprogress = true;
    startGETRequest(url, onComplete, onEnd);
  }
  setTimeout("startRequest()", interval * 1000);
}

function onComplete(text, xml)
{
  if(text != "error"){
    var div = document.getElementById('mainDiv');
    div.style.backgroundImage = "url('" + text + "')";
  }
}

function onEnd(text, xml)
{
  onprogress = false;
}
