
function CallBackObject()
{
  this.XmlHttp = this.GetHttpObject();
}

CallBackObject.prototype.WhichPage=0

CallBackObject.prototype.GetHttpObject = function()
{
    var obj;
    try {
      // For Internet Explorer.
      obj = new ActiveXObject('Microsoft.XMLHTTP');
    }
    catch(e) {
      try {
        // Gecko-based browsers, Safari, and Opera.
        obj = new XMLHttpRequest();
      }
      catch (e) {
        // Browser supports Javascript but not XMLHttpRequest.
        obj = false;
      }
    }

  return obj;
}

CallBackObject.prototype.DoCallBack = function(FileName,Data)
{
  try{
    if( this.XmlHttp )
    {
      if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
      {
        var oThis = this;
     //this.XmlHttp.open("GET", "GetSearchResult?XML="+fnSetData(DS)+"&DS="+DS,true);//open('POST', thePage, true);
     //this.XmlHttp.open("GET", "DoSearch?XML="+fnSetData(DS),true);

        this.XmlHttp.open("GET", FileName+"?"+Data,true);
        this.XmlHttp.onreadystatechange = function(){ oThis.canUpdate="Y"; oThis.ReadyStateChange(oThis.XmlHttp); };
        this.XmlHttp.setRequestHeader('Content-Type', 'text/html;application/x-www-form-urlencoded');

        this.XmlHttp.send(null)//send(theData);
      }
    }
  }catch(e){alert(e.message)}
}

CallBackObject.prototype.DoCallBackPost = function(FileName,Data)
{
	try
	{
		if( this.XmlHttp )
		{
			if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
			{
			var oThis = this;
			this.XmlHttp.open("POST", FileName,true);
			this.XmlHttp.onreadystatechange = function(){ oThis.canUpdate="Y"; oThis.ReadyStateChange(oThis.XmlHttp); };
			this.XmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			this.XmlHttp.setRequestHeader("Content-length", Data.length);
			this.XmlHttp.setRequestHeader("Connection", "close");
			this.XmlHttp.send(Data);
			}
		}
	}catch(e)
	{
		alert(e.message)
	}
}

CallBackObject.prototype.DoCallBackFileUpload = function(FileName,Data)
{
  if( this.XmlHttp )
  {
    if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
    {
      var oThis = this;


      this.XmlHttp.open("POST", FileName,true);
      this.XmlHttp.onreadystatechange = function(){ oThis.canUpdate="Y"; oThis.ReadyStateChange(oThis.XmlHttp); };
      this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      this.XmlHttp.setRequestHeader("Content-length", Data.length);
      this.XmlHttp.setRequestHeader("Connection", "close");

      this.XmlHttp.send(Data);
    }
  }
}

CallBackObject.prototype.AbortCallBack = function()
{
  if( this.XmlHttp )
    this.XmlHttp.abort();
}

CallBackObject.prototype.OnLoading = function()
{
}

CallBackObject.prototype.OnLoaded = function()
{
}

CallBackObject.prototype.OnInteractive = function()
{
}

CallBackObject.prototype.OnComplete = function(obj)
{
 }

CallBackObject.prototype.OnAbort = function()
{
}

CallBackObject.prototype.OnError = function(status, statusText)
{
}

CallBackObject.prototype.ReadyStateChange = function(obj)
{

  if( this.XmlHttp.readyState == 1 )
  {
    this.OnLoading();
  }
  else if( this.XmlHttp.readyState == 2 )
  {
    this.OnLoaded();
  }
  else if( this.XmlHttp.readyState == 3 )
  {
    this.OnInteractive();
  }
  else if( this.XmlHttp.readyState == 4 )
  {
    if( this.XmlHttp.status == 0 )
      this.OnAbort();
    else if( this.XmlHttp.status == 200 && this.XmlHttp.statusText == "OK" ){

       this.OnComplete(obj.responseText);
    }
    else
      this.OnError(this.XmlHttp.status, this.XmlHttp.statusText, this.XmlHttp.responseText);
  }
}


