var timeout = 5;

function startRequest()
{
  id = (new Date()).getTime();
  url = "http://localhost/adv.php?id" + id;
  startGETRequest(url, onComplete, onEnd);
}

function onEnd()
{
}

function onComplete(text, xml)
{
  arr = text.split("\n");
  if(arr.length == 2){
    var imgEl = document.getElementById("advImg");
    var linkEl = document.getElementById("advLink");
    imgEl.src = arr[0];
    linkEl.href = arr[1];
  }
  setTimeout("startRequest();", timeout * 1000);
}