/**
 * @version $Id: ajax.js 1070 2007-08-28 11:21:18Z stu.goff $
 * @copyright Soup Ltd
 * @package ooCMS
 */
	function AjaxOb(){
		this.xmlReqOb=false;
		this.xmlResponse=false;
		this.callBack=false;
	}

	AjaxOb.prototype.sendRequest=function(url,xmlDoc,callbackFunction) {
		if (window.XMLHttpRequest)
			this.xmlReqOb=new XMLHttpRequest();
		else if(window.ActiveXObject)
			this.xmlReqOb=new ActiveXObject("Microsoft.XMLHTTP");
		else
			return false;
		this.callBack=callbackFunction;
		this.xmlReqOb.open('get',url,true);
		this.xmlReqOb.setRequestHeader('content-type','text/xml');
		this.xmlReqOb.onreadystatechange=ajaxOb.reponseDispatcher;
		this.xmlReqOb.send(xmlDoc);
	}

	AjaxOb.prototype.postRequest=function(url,data,callbackFunction) {
		if (window.XMLHttpRequest)
			this.xmlReqOb=new XMLHttpRequest();
		else if(window.ActiveXObject)
			this.xmlReqOb=new ActiveXObject("Microsoft.XMLHTTP");
		else
			return false;
		this.callBack=callbackFunction;
		var p,kv='';
		for(p in data){
			kv+=(kv==''?'':'&')+p+'='+encodeURIComponent(data[p]);
		}
		this.xmlReqOb.open('post',url,true);
		this.xmlReqOb.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
      	this.xmlReqOb.setRequestHeader("Content-length", kv.length);
		this.xmlReqOb.setRequestHeader("Connection", "close");
		this.xmlReqOb.onreadystatechange=ajaxOb.reponseDispatcher;
		this.xmlReqOb.send(kv);
	}

	AjaxOb.prototype.reponseDispatcher=function(){
		ajaxOb.xmlResp();
	}

	AjaxOb.prototype.xmlResp=function(){
		if(this.xmlReqOb.readyState!=4)
			return;
		if(this.xmlReqOb.status==200 || this.xmlReqOb.status==404){
			this.xmlResponse=this.xmlReqOb.responseXML;
			this.xmlResponseText=this.xmlReqOb.responseText;
			if(this.callBack)
				this.callBack();
		} else {	// Something's wrong!
		}
	}
	
	ajaxOb=new AjaxOb();