function Ajax() {
  this.req = null;
  this.url = null;
  this.method = 'GET';
  this.async = true;
  this.status = null;
  this.statusText = '';
  this.postData = null;
  this.readyState = null;
  this.responseText = null;
  this.responseXML = null;
  this.handleResp = null;
  this.responseFormat = 'text'; // 'text', 'xml' or 'object'
  this.mimeType = null;
  
  this.init = function() {
    if (!this.req) {
      try {
        // for FF, Safari, IE7
        this.req = new XMLHttpRequest();
      }
      catch(e) {
        try {
          // later versions of IE
          this.req = new ActiveXObject('MSXML2.XMLHTTP');
        }
        catch(e) {
          try {
            // earlyer versions of IE
            this.req = new ActiveXObject('Microsoft.XMLHTTP');
          }
          catch(e) {
            // error
            return false;
          }
        }
      }
    }
    return this.req;
  };
  
  this.doReq = function() {
    var self = this;
  
    // versuche XMLHttpRequest-Objekt zu erzeugen
    if (!this.init()) {
      alert('Could not create XMLHttpRequest object.');
      return;
    }
    
    // öffne request
    this.req.open(this.method, this.url, this.async);
    
    if (this.method == 'POST') {
      this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }

    // korrekten mimeType setzen
    if (this.mimeType) {
      try {
        req.overrideMimeType(this.mimeType);
      }
      catch(e) {
        // Fehler, IE6 oder Opera?
      }
    }
    
    // wenn sich Request Status ändert
    this.req.onreadystatechange = function() {
      var resp = null;
      
      // bei 4 ist die Anfrage fertig
      if (self.req.readyState == 4) { // 0 uninit, 1 loading, 2 loaded, 3 interactive, 4 completed
      
        // Fallunterscheidung für unterschiedliche Response-Formate
        switch(self.responseFormat) {
          case 'text':
            resp = self.req.responseText;
            break;
          case 'xml':
            resp = self.req.responseXML;
            break;
          case 'object':
            resp = req;
            break;
        }
        
        // wenn kein Fehler aufgetreten ist
        if (self.req.status >= 200 && self.req.status <= 299) 
          self.handleResp(resp);
        else
          self.handleErr(resp);
      }
    }
    
    // Anfrage ausführen
    this.req.send(this.postData);
  };
  
  this.setMimeType = function(mimeType) {
    this.mimeType = mimeType;
  };
  
  this.handleErr = function() {
    var errorWin;
    try {
      errorWin = window.open('', 'errorWin');
      errorWin.document.body.innerHTML = this.responseText;
    }
    catch(e) {
      alert('An error occurred, but the error message cannot be displayed' + 
        'This is probably because of your browser\'s pop-up blocker.\n' + 
        'Please allow pop-ups from this web site if you want to see the full error message.\n' + 
        '\n' +
        'Status Code: ' + this.req.status + '\n' + 
        'Status Description: ' + this.req.statusText + '\n');
    }
  };
  
  this.setHandlerErr = function(funcRef) {
    this.handleErr = funcRef;
  };
  
  this.setHandlerBoth = function(funcRef) {
    this.handleResp = funcRef;
    this.handleErr = funcRef;
  };
  
  this.abort = function() {
    if (this.req) {
      this.req.onreadystatechange = function() { };
      this.req.abort();
      this.req = null;
    }
  };
  
  this.doGet = function(url, hand, format) {
    this.url = url;
    this.handleResp = hand;
    this.responseFormat = format || 'text';
    this.method = 'GET';
    this.doReq();
  };
  
  this.doPost = function (url, postData, hand, format) {
    this.url = url;
    this.handleResp = hand;
    this.responseFormat = format || 'text';
    this.method = 'POST';
    this.postData = postData;
    this.doReq();
  };
  
  this.parseYamlResult = function(str) {
    var arr = [];
    var res = [];
    var pat = /(\S+)\s*: (.+)\n/g;
    while(arr = pat.exec(str)) {
      res[arr[1]] = arr[2];
    }
    return res;
  };

}