/* ajax functions */
function ajaxRequest(url, obj)
{
    var httpRequest;
    try {
      if(typeof window.ActiveXObject != 'undefined')
      {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      }
      else
      {  
          httpRequest = new XMLHttpRequest();
      }
      httpRequest.open("GET", url, true);
      httpRequest.onreadystatechange= function () 
      {
          processRequest(httpRequest, obj) 
      }
      httpRequest.send(null);
  }
  catch(err) {}      
}


function processRequest(httpRequest, obj) 
{
    if (httpRequest.readyState == 4)
    {
        if(httpRequest.status == 200)
        {
            if (typeof obj == 'string') 
            {
                document.getElementById(obj).innerHTML = httpRequest.responseText;
            }
            if (typeof obj == 'function') 
            {
                obj(httpRequest.responseText);
            }
        }
        else
        {
			if(httpRequest.status)
            	alert("Chyba pri nacitani stanky " + httpRequest.status +" : "+ httpRequest.statusText);
        }
    }
    else
    {
        if (typeof obj == 'string' && obj != '') 
        {
            document.getElementById(obj).innerHTML = '<img src="/gfx/loading.gif" />';           
        }
    }       
} 
