if( !window.XMLHttpRequest ) XMLHttpRequest = function()
{
  try{ return new ActiveXObject("Msxml2.XMLHTTP.6.0") }catch(e){}
  try{ return new ActiveXObject("Msxml2.XMLHTTP.3.0") }catch(e){}
  try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
  try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
  throw new Error("Could not find an XMLHttpRequest alternative.")
};

function Majax()
{
    var self = this;
    self.xmlHttp = new XMLHttpRequest();
    self.xmlHttp.onreadystatechange = function()
    {
        if ( self.xmlHttp.readyState == 4 )
        {
            //was the request successful
            if ( self.xmlHttp.status == 200 )
            {
                self.onSuccess( self.xmlHttp );
            }
            else//error
            {
                self.onFail( self.xmlHttp );
            }
        }
    }

    self.get = function( page, onSuccess, onFail )
    {
        self.onSuccess = onSuccess;
        self.onFail = onFail;
        self.xmlHttp.open( "GET", page, true );
        self.xmlHttp.send( null );
    }

    self.post = function( page, params, onSuccess, onFail )
    {
        self.onSuccess = onSuccess;
        self.onFail = onFail;
        self.xmlHttp.open( "POST", page, true );
        self.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        //self.xmlHttp.setRequestHeader("Content-length", params.length);
        //self.xmlHttp.setRequestHeader("Connection", "close");
        self.xmlHttp.send( params );
    }
}
