Function.prototype.bind = function(object){
    var __self = this
    return function() {
	return __self.apply(object, arguments);
    }
}

function XML() {}

XML.Request = function(onLoad){
  this.request = this.__create()
  this.onLoad = onLoad
  this.request.onreadystatechange = this.__receive.bind(this)
}

XML.Request.prototype.__create = function(){
    if (window.XMLHttpRequest) return new XMLHttpRequest();
    else if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
}

XML.Request.prototype.__receive = function(){
  if ( this.request.readyState == 4 ){
    try{
      if( this.request.status == 200 ) {
        if(this.onLoad) {
          this.onLoad(this.request.responseText)
        }  
      } 
    } catch(e){}
  }
}

XML.Request.prototype.get = function(url){
  this.request.open('GET', url, true);
  this.request.send(null);
}

XML.Request.prototype.post = function(url,content) {
  this.request.open('POST', url, true);
  this.request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  this.request.setRequestHeader("Content-length", content.length);
  this.request.setRequestHeader("Connection", "close");
  this.request.send(content);
}
