/******************************************************************************* 
ALSPA.XmlHttp - XMLHTTP Interface
Copyright (c) 2005. ALSPA Consulting Corp. All Rights Reserver
Author: Michael S. Kolias - mikek@alspaconsulting.com
********************************************************************************/

function AlspaXmlHttp()
{
  var xmlhttp, complete = false;
	
	xmlhttp = GetXmlHttpObject();
	
  if (!xmlhttp) return null; //Failed to create XMLHttp Object
	
  this.Connect = function(url, method, parameters, fnCallback)
  {
    if (!xmlhttp) return false;
		complete = false;
    method = method.toUpperCase();

    try 
		{
      if (method == "GET")
      {
        xmlhttp.open(method, url+"?"+parameters, true);
        parameters = "";
      }
      else
      {
        xmlhttp.open(method, url, true);
        xmlhttp.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      }

			xmlhttp.onreadystatechange = function()
			{
        if (xmlhttp.readyState == 4 && !complete)
        {
          complete = true;
          fnCallback(xmlhttp);
        }
			};
			
      xmlhttp.send(parameters);
    }
		
    catch(ex) { return false; }
    
		return true;
  };
	
  return this;
}


function GetXmlHttpObject()
{
	var theObject;
	
	try { theObject = new ActiveXObject("Msxml2.XMLHTTP"); }
  
	catch (ex)
	{ 
		try { theObject = new ActiveXObject("Microsoft.XMLHTTP"); }
		
		catch (ex) 
		{
			try { theObject = new XMLHttpRequest(); }
	
			catch (ex) { theObject = false; }	
		}
		
	}
	
	return theObject;
}



