// CXALoader

function CXALoaderItem(u,o){this.u=u;this.o=o;}
function CXALoaderRet(){this.b=false;this.o=this.t=this.x=null;}

function CXGetObj()
{
  var r=null;
  if(!r)try{r=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){}
  if(!r)try{r=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
  if(!r)try{r=new XMLHttpRequest();}catch(e){r=null;}
  return r;
}

function CXSGetX(url,data)
{
  var r=CXGetObj();
  r.open((data)?"POST":"GET",url,false);
  r.send(data);
  return r.responseXML; 
}

function CXSGet(url,data)
{
  var r=CXGetObj();
  r.open((data)?"POST":"GET",url,false);
  r.send(data);
  var x=r.responseXML; 
  var t=x.getElementsByTagName("t");
  if(t.length>0) return t[0].firstChild.nodeValue;
  return "["+r.status+":"+r.statusText+"] Error in data format.";
}

function CXALoader(func)
{
  this.Load=CXALoader_Load;
  this.Start=CXALoader_Start;
  this.LoadHandler=CXALoader_LoadHandler;
  this.LoadXHndl=CXALoader_LoadXHndl;
  this.l=false;
  this.r=CXGetObj();
  this.f=func;
  this.a=new Array();
}

function CXALoader_Load(sURL,o)
{
  if(!this.r)return false;
  this.a.push(new CXALoaderItem(sURL,o));
  this.Start();
  return true;
}

function CXALoader_Start()
{
  if((this.a.length>0)&&(!(this.l)))
  {
    this.l=true;
    this.r.open("GET", this.a[0].u, true);
    this.r.onreadystatechange = this.f;
    this.r.send(null);
  }
}

function CXALoader_LoadHandler()
{
  var ret=new CXALoaderRet();
  if(this.r.readyState!=4)return null;
  var a=this.a.shift();
  ret.o = a.o;
  var st=this.r.status;
  if(st==200||st==207)
  {
    var t=this.r.responseXML.getElementsByTagName("t");
    if(t.length>0) { ret.b=true; ret.t=t[0].firstChild.nodeValue; }
    else ret.t="Error in data format.";
  }
  else ret.t="Error loading data "+st+": "+this.r.statusText;
  this.l=false;
  this.Start();
  return ret;
}

function CXALoader_LoadXHndl()
{
  var ret=new CXALoaderRet();
  if(this.r.readyState!=4)return null;
  var a=this.a.shift();
  ret.o = a.o;
  var st=this.r.status;
  if(st==200||st==207)
  {
    ret.x=this.r.responseXML;
    ret.b=true;
  }
  else ret.t="Error loading data "+st+": "+this.r.statusText;
  this.l=false;
  this.Start();
  return ret;
}

