function PoiAjaxBase()
{
  var url  = '';
  var xmlhttp = null;
  var busy    = false;
  
  function ajaxRequest()
  {
    var xmlhttp=false;
  
    try 
    {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
  
    catch (e) 
    {
      try 
      {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } 
  
      catch (e) 
      {
        xmlhttp = false;
      }
    }
  
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
    {
  	  try 
      {
  		  xmlhttp = new XMLHttpRequest();
    	} 
      catch (e) 
      {
  		  xmlhttp=false;
    	}
    }
  
    if (!xmlhttp && window.createRequest) 
    {
  	  try 
      {
  		  xmlhttp = window.createRequest();
    	} 
      catch (e) 
      {
    		xmlhttp=false;
  	  }
    }
  
    return xmlhttp;
  }

  return {
    isBusy: function()
    {
      return busy;
    },

    getURL: function()
    {
      return url;
    },
    
    setURL: function(aurl)
    {
      url = aurl;
    },

    Ajax: function(resultcallback,progresscallback) // both parameters optional
    {
      if (busy)
      {
        alert('Error. Already busy with call: '+url);
        return false;
      }

      busy = true;

      xmlhttp = ajaxRequest();

      if (xmlhttp == null)
      {
        alert('Error. No Ajax available');
        return false;
      }

      xmlhttp.open('GET', url, true);

      xmlhttp.onreadystatechange = function() 
      {
        if (progresscallback != null)
        {
          progresscallback(xmlhttp.readyState);
        }
      
        if (xmlhttp.readyState==4) 
        {
          busy = false;

          if (xmlhttp.status==200) 
          {
            resultcallback(xmlhttp);
          }
          else
          {
            resultcallback(null);
          }

          delete xmlhttp;
        }
      }

      xmlhttp.send(null);

      return true;
    },
    
    // only for small xml files, gets really slow otherwise
    getXMLElement: function(name,index) // index is optional
    {
      if (!xmlhttp) return '';
    
      var ele = xmlhttp.responseXML.getElementsByTagName(name)[index || 0];
    
      if (ele && ele.firstChild) 
      {
        return ele.firstChild.nodeValue;
      }

      return '';
    }
  };
}


