var XML_Loaders = new Array();




function FindXmlLoaderById(id)  
{
  return XML_Loaders[id];
}







function XML_Loader()
{
  this.Load = function(xmlPath, async)
  {
    async = ((async == 'false') || (async == false)) ? false : true;

    if (window.XMLHttpRequest) 
      this.m_xmlDoc = new XMLHttpRequest();
    else
      if (window.ActiveXObject)
        this.m_xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

    XML_Loaders[this.m_id] = this;

    if (window.XMLHttpRequest) 
    { 
      var st = "var obj = FindXmlLoaderById('" + this.m_id + "');" + 
        "if (obj.m_xmlDoc.readyState == 4){ obj.m_xmlDoc = obj.m_xmlDoc.responseXML; obj.OnLoad();}";
      if (async)
        this.m_xmlDoc.onreadystatechange = Function(st);
      this.m_xmlDoc.open("GET", xmlPath, async);
      this.m_xmlDoc.send(null);

      if (!async)
      {
        this.m_xmlDoc = this.m_xmlDoc.responseXML;
        this.OnLoad();
      }
      return true;
    }
     


    if (window.ActiveXObject)
    {
      var st = "var obj = FindXmlLoaderById('" + this.m_id + "'); " + 
        "if (obj.m_xmlDoc.readyState == 4) obj.OnLoad();";
      if (async)
        this.m_xmlDoc.onreadystatechange = Function(st);
      this.m_xmlDoc.async = async;
      this.m_xmlDoc.load(xmlPath);
      if (!async)
        this.OnLoad();
    }
    return false;
  }



  this.OnLoad = function()
  {
    if (this.m_onXmlLoaded)
      this.m_onXmlLoaded(this.m_xmlDoc);
  }




  // member variable declarations ...

  this.m_xmlDoc = 0;
  this.m_id = 'XML_Loader_' + Math.random();
  this.m_onXmlLoaded = 0; 
}
