

/* moo 1.1
XHR.prototype.send = function(url, data){
		if (this.options.autoCancel) this.cancel();
		else if (this.running) return this;
		this.running = true;
		if (data && this.options.method == 'get') url = url + (url.contains('?') ? '&' : '?') + data, data = null;
		var transportMethod = this.options.method;
		if (transportMethod == 'post')	transportMethod = 'POST';
		this.transport.open(transportMethod, url, this.options.async);
		this.transport.onreadystatechange = this.onStateChange.bind(this);
		if ((this.options.method == 'post') && this.transport.overrideMimeType) this.setHeader('Connection', 'close');
		$extend(this.headers, this.options.headers);
		for (var type in this.headers) try {this.transport.setRequestHeader(type, this.headers[type]);} catch(e){};
		this.fireEvent('onRequest');
		this.transport.send($pick(data, null));
		return this;
	};

*/

/* moo 1.0 
*/
XHR.prototype.send = function(url, data){
                this.fireEvent('onRequest');
                var transportMethod = this.options.method;
				if (transportMethod == 'post')	transportMethod = 'POST';		
                this.transport.open(transportMethod, url, this.options.async);
                this.transport.onreadystatechange = this.onStateChange.bind(this);
                if (this.options.method == 'post'){
                        this.setHeader('Content-type', 'application/x-www-form-urlencoded');
                        if (this.transport.overrideMimeType) this.setHeader('Connection', 'close');
                }
                Object.extend(this.headers, this.options.headers);
                for (var type in this.headers) this.transport.setRequestHeader(type, this.headers[type]);
                this.transport.send(data);
                return this;
}


window.addEvent = function(type, fn){
				if (type == 'domready'){
	                        if (this.loaded) fn();
	                        else if (!this.events || !this.events.domready){
	                                var domReady = function(){
	                                        if (this.loaded) return;
	                                        this.loaded = true;
	                                        if (this.timer) this.timer = $clear(this.timer);
	                                        Element.prototype.fireEvent.call(this, 'domready');
	                                        this.events.domready = null;
	                                }.bind(this);
	                                if (document.readyState && this.khtml){ //safari and konqueror
	                                        this.timer = function(){
	                                                if (['loaded','complete'].test(document.readyState)) domReady();
	                                        }.periodical(50);
	                                }
	                                else if (document.readyState && this.ie){ //ie
	                                		//var srcFr = (window.location.protocol == 'https:') ? '://0' : 'javascript:void(0)';
	                                		var srcFr = '//:';
	                                        document.write('<script id="ie_ready" defer src="' + srcFr + '"><\/script>');
	                                        $('ie_ready').onreadystatechange = function(){
	                                                if (this.readyState == 'complete') domReady();
	                                        };
	                                } else { //others
	                                        this.addEvent("load", domReady);
	                                        document.addEvent("DOMContentLoaded", domReady);
	                                }
	                        }
	                }
	                Element.prototype.addEvent.call(this, type, fn);
	                return this;
}