/*
	Really Simple AJAX™
	v2.3
	ale@sofanaranja.com

	More info: http://sofanaranja.com/reallysimpleajax/
*/

var Ajax = {
	version: "2.3",
	copyright: "© 2006 SofaNaranja.com",
	toString: function(){
		var d = "Really Simple AJAX™ v"+this.version + "\n"
		+ this.copyright + "\n"
		+ this.queue.length + " requests processed"
		return d;
	},
	/* An array where we'll store requests (currently unused) */
	queue : new Array(),
	isIE : function (){
		/* Find out if browser is Internet Explorer */
		if(window.XMLHttpRequest){
			return false;
		} else {
			return true;
		}
	},
	fillDiv : function (target,req,processReqChange){
		if(req.readyState == 4){
			var targetDiv = document.getElementById(target);
			targetDiv.innerHTML = req.responseText;
			processReqChange();
		}
	},
	load : function (url,target,oncomplete,onstart){
		/* Loads url into target.innerHtml */
		/* url = String */
		/* target = String */
		/* oncomplete = function */
		/* onstart = function */
		if(oncomplete == undefined){
			oncomplete = function(){};
		}
		if(onstart == undefined){
			onstart = function(){};
		}
		if(this.isIE()){
			var req = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			var req = new XMLHttpRequest();
		}
		req.onreadystatechange = function(){
			Ajax.fillDiv(target,req,oncomplete);
		}
		this.queue.push(req);
		onstart();
		req.open("GET",url,true);
		req.send(null);
	}
}
