var $ = function() {};

$.prototype.ajax = { 
  createXHR: function() { 
    return new XMLHttpRequest(); 
  }, 
  configXHR: function(connector, callback) { 
    connector.onreadystatechange = function() { 
      if (connector.readyState == 4) { 
        if (connector.status == 200) { 
          callback.call(connector, { 
            text: connector.responseText, 
            xml: connector.responseXML 
            // need to add JSON support
          }); 
        } 
      } 
    } 
  }, 
  get: function(request) { 
    var url       = request.url || ''; 
    var callback  = request.callback || function() {}; 
    var xhr = this.createXHR(); 

    if (xhr) { 
      this.configXHR(xhr, callback); 
      xhr.open('GET', url, true); 
      xhr.send(''); 
    } 
  }, 
  post: function(request) { 
    var url       = request.url || ''; 
    var callback  = request.callback || function() {}; 
    var data      = request.data || ''; 
    var xhr       = this.createXHR(); 

    if (xhr) { 
      this.configXHR(xhr, callback); 
      xhr.open('POST', url, true); 
      xhr.setRequestHeader('Content type', 'application/x-www-form-urlencoded'); 
      xhr.setRequestHeader('Content-length', data.length); 
      xhr.setRequestHeader('Connection', 'close'); 
      xhr.send(data); 
    } 
  } 
} 
$ = new $(); 


/*
$.ajax.get({ 
    url: '/index.html', 
    callback: function(response) { 
        var text = response.text; 
        alert(text); 
    } 
});

$.ajax.post({ 
    url: '/post.php', 
    data: 'x=foo&y=bar', 
    callback: function(response) { 
        alert(response.text); 
    } 
}); 
*/