<!--
var ajax = {};
ajax.xhr = {};

ajax.xhr.Request = function(method, url, param, callback, sync){
  this.method = method;
  this.url = url;
  this.param = param;
  this.callback = callback;
  this.sync = sync;
  
  this.sendRequest();
}

ajax.xhr.Request.prototype = {
  getXMLHttpRequest: function(){ 
    if (window.ActiveXObject) {
      try {
        return new ActiveXObject("Msxml2.XMLHTTP");
      } 
      catch (e1) {
        try {
          return new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (e2) {
          return null;
        }
      }
    }
    else if (window.XMLHttpRequest) {
      return new XMLHttpRequest();
    }
    else{
      return null;
    }
  },

  sendRequest: function(){
    this.req = this.getXMLHttpRequest();
    
    var httpMethod = this.method != '' ? this.method : 'POST';
    if(httpMethod != 'GET' && httpMethod != 'POST'){
      httpMethod = 'POST';
    }

    var httpParam = (this.param != '' || this.param != null) ? this.param : null;
    var httpUrl = this.url;

    var httpSync = (this.sync != '' || this.sync != null) ? this.sync : true;
    if(httpSync != true && httpSync != false){
      httpSync = true;
    }

    if(httpMethod == 'GET' && httpParam != null){
      httpUrl = httpUrl + "?" + httpParam;
    }

    this.req.open(httpMethod, httpUrl, httpSync);
    this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    var request = this;
    this.req.onreadystatechange = function(){
      request.onStateChange.call(request);
    }

    this.req.send(httpMethod == 'POST' ? httpParam : null);
  },
  
  onStateChange: function(){
    if(this.callback != null){
      this.callback(this.req);
    }
  }
}
//-->