var g_AjaxUpdate;

///////////////////////////////////////////////////////////////////////////////
// AJAX UPDATE
///////////////////////////////////////////////////////////////////////////////
function AjaxUpdate (url, callBack)
{
  this._url      = url;
  this._callBack = callBack;
  
  // Start to download the Google logo
  try
  {
    // Firefox, Opera 8.0+, Safari
    this._request = new XMLHttpRequest ();
  }
  catch (e)
  {
    // Internet Explorer
    try
    {
      this._request = new ActiveXObject ("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      this._request = new ActiveXObject ("Microsoft.XMLHTTP");
    }
  }

  if (this._request == null)
  {
    return;
  }

  try
  {
    this._request.open ("GET", this._url, true);
  }
  catch (e)
  {
    // Catch invalid URLs
    this._request = null;
    return;
  }

  // Set the callback for when the downloading is completed (or failed)
  g_AjaxUpdate = this;
  this._request.onreadystatechange = this.onStateChanged;
    
  // Start the download
  try
  {
    this._request.send ("");
  }
  catch (e)
  {
    // Catch errors sending the request
    this._request = null;
    return;
  }
}

AjaxUpdate.prototype._url;
AjaxUpdate.prototype._callBack;
AjaxUpdate.prototype._request;
AjaxUpdate.prototype._response;

///////////////////////////////////////////////////////////////////////////////
AjaxUpdate.prototype.onStateChanged = function () 
{ 
  if (g_AjaxUpdate._request.readyState != 4)
  {
    return;
  }

  g_AjaxUpdate._response = g_AjaxUpdate._request.responseXML;
  g_AjaxUpdate._callBack ();
}

///////////////////////////////////////////////////////////////////////////////
AjaxUpdate.prototype.getResponseXml = function () 
{ 
  return g_AjaxUpdate._response;
}

var g_AjaxUpdate = null;

