function zwAjax(sUrl, oProcess)
{
	this.url=sUrl;
	this.target=null;
	this.method='POST';
	this.tag=null;
	this.parameters='';
	this.info=null;
	this.req=null;
	this.call=_ajaxCall;
	this.callBack=_ajaxCallBack;
	this.process=oProcess;
}

function zwAhah(sUrl, oTarget)
{
	var oAhah=new zwAjax(sUrl, null);
	oAhah.target=oTarget;
	
	return oAhah;
}

function _ajaxCall()
{
	if(this.info) this.info.innerHTML = 'Loading...';
	
	if(window.XMLHttpRequest)
	{
		this.req=new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		this.req=new ActiveXObject('Microsoft.XMLHTTP');
	}
	
	if(this.req)
	{
		var oAjax=this.req;
		var oFunc=this.callBack;
		this.req.obj=this;
		this.req.onreadystatechange=function () { oFunc.call(oAjax); };
		this.req.open(this.method, this.url, true);

		if(this.method.toLowerCase()=='post')
		{
			//this.req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			this.req.send(this.parameters);
		} else {
			this.req.send('');
		}
	} else {
		if(this.info) this.info.innerHTML = 'Error, could not send request.';
	}	
}

function _ajaxCallBack(oReq)
{	
	if(!oReq) oReq=this;		
	
	switch(oReq.readyState)
	{
		case 3:
			
			break;
		case 4:
			if (oReq.status==200)
			{
				if(oReq.obj.info) oReq.obj.info.innerHTML = '';
				if(oReq.process) oReq.process.call(oReq);
				if(oReq.obj.target) oReq.obj.target.innerHTML = oReq.responseText;
			} else {
				if(oReq.obj.info) oReq.obj.info.innerHTML = 'ERROR: '+oReq.statusText;
			}
			break;
	}
}