// Copyright (c) 2003-2007 Mira Software, Inc. All rights reserved.
// $Id: ajax.js, Version 1.00 2007/09/02 15:45:00 Mira Software, Inc. Exp $

function XMLObject()
  {
  var xmlObject;
  var XMLObjects = new Array(
    function() {return new ActiveXObject('Msxml2.XMLHTTP')},
    function() {return new ActiveXObject('Microsoft.XMLHTTP')},
    function() {return new XMLHttpRequest()});
  var Count = XMLObjects.length;
  while (Count--)
    {
    try
      {
      xmlObject = XMLObjects[Count]();
      break;
      }
    catch (exception) {xmlObject = null}
    }
  return xmlObject;
  }

function ajaxGet(url, callback)
  {
  var http = XMLObject();
  if (http != null)
    {
    http.open('GET', url, true);
    http.onreadystatechange = function()
      {
      if (http.readyState == 4)
        callback(http.responseText);
      }
    http.send(null);
    return true;
    }
  return false;
  }
  
function ajaxPost(url, params, callback)
  {
  var http = XMLObject();
  if (http != null)
    {
    http.open('POST', url, true);
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");
    http.onreadystatechange = function()
      {
      if (http.readyState == 4)
        callback(http.responseText);
      }
    http.send(params);
    return true;
    }
  return false;
  }
  
function ajaxEncode(value)
  {
  return escape(encodeURI(value));
  }
  

