// JavaScript Document
function getPHPContent(url, div, before, after)
{
  var ac = new ajaxCaller(url, div, before, after);
  ac.load();
}


/*
* konstruktor
*/
function ajaxCaller(klic, div, before, after)
{
  this._klic = klic;
  this._div  = div;
  this._before = before;
  this._after = after;
}


ajaxCaller.prototype.load = function()
{
  this._xhr = this._getXMLHTTPRequest();
  var _this = this;
  
  
  if (this._before)
  {
    //prikazi("shader");
    //prikazi("loading");
  }
  
  this._xhr.onreadystatechange = function(){_this._onData()};
  this._xhr.open("GET", this._generateDataUrl(), true);
  this._xhr.send(null);
}


ajaxCaller.prototype._generateDataUrl = function()
{
  return this._klic;
}

ajaxCaller.prototype._onData = function()
{
  if (this._xhr.readyState == 4)
  {
    if (this._xhr.status == "200")
    {
      document.getElementById(this._div).style.display = "block";
      document.getElementById(this._div).innerHTML = this._xhr.responseText;
      
      if (this._after)
      {
        //skrij("shader");
        //skrij("loading");
      }
    }
  }
}

ajaxCaller.prototype._getXMLHTTPRequest = function()
{
  var xmlHttp;
  try
  {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    //xmlHttp = new ActiveXObject("Msxml2.XMLHttp");
  }
  catch (e)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
    }
    catch (e2)
    {}
  }
  
  if (xmlHttp == undefined && (typeof XMLHttpRequest != 'undefined'))
  {
    xmlHttp = new XMLHttpRequest();
  }
  
  return xmlHttp;
}