var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject()
{
  var xmlHttp;
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  else
  {
    try
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  if (!xmlHttp)
    alert("BÅ?Ä?d podczas tworzenia obiektu XMLHttpRequest.");
  else
    return xmlHttp;
}
i=0;
setInterval("pokaz();", 10000);
function pokaz()
{
var img=document.getElementById("obrazek");
i++;
}
function process()
{
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    xmlHttp.open("GET", "index2.php?name=" + i, true);
    xmlHttp.onreadystatechange = handleServerResponse;
    xmlHttp.send(null);
  }
  else
    setTimeout('process()', 1000);
}
function handleServerResponse()
{
    myDiv = document.getElementById("divMessage");
  if (xmlHttp.readyState == 4)
  {
    if (xmlHttp.status == 200)
    {
      xmlResponse = xmlHttp.responseText;
      document.getElementById("divMessage").innerHTML =  xmlResponse;
      setTimeout('process()', 1000);
    }
    else
    {
      alert("WystÄ?piÅ? bÅ?Ä?d podczas uzyskiwania dostÄ?pu do serwera: " + xmlHttp.statusText);
    }
  }
}
