function CAjax(method,asyncMode) {
  this.method = "POST";
  this.asyncMode = true;
  this.onReadyStateChange = null;

  this.init = function() {
    if (method)
      this.method = method;
    if (typeof(asyncMode)!="undefined")
      this.asyncMode = asyncMode;
  } // end init

  this.sendRequest = function(url) {
    var func = this.onReadyStateChange?this.onReadyStateChange:this.sampleParser;
    var req = window.XMLHttpRequest? 
      new XMLHttpRequest(): 
      new ActiveXObject("Microsoft.XMLHTTP");
    req.onreadystatechange = function() {
      if (req.readyState==4) {
        func(req.responseText);
        this.onReadyStateChange = null;
      }
    }
    if (this.method=="GET") {
      req.open("GET",url,this.asyncMode);
      req.send(null);
    } else {
      var post = url.split("?",2);
      if (post.length==1) post[1] = "";
      req.open("POST",post[0],this.asyncMode);
      req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
      req.setRequestHeader("Content-length", post[1].length);
      req.send(post[1]);
    }
  } // end sendRequest

  this.sampleParser = function(response) {
    alert("Response:\n"+response);
  } // sampleParser

  this.init();
}
