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;
	this.sending=jslng.loading;
}

function zwAhah(sUrl, oTarget)
{
	var oAhah=new zwAjax(sUrl, null);
	oAhah.target=oTarget;

	return oAhah;
}

function _ajaxCall()
{
	if(this.info)
	{
		this.info.innerHTML=this.sending;
		this.info.style.display='block';
	}

	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 = ajslng.reqerr;
	}
}

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.obj.process) oReq.obj.process.call(oReq, oReq);
				if(oReq.obj.target) oReq.obj.target.innerHTML = (oReq.responseText==undefined?'':oReq.responseText);
			} else {
				if(oReq.obj.info) oReq.obj.info.innerHTML = jslng.errtext+': '+oReq.statusText;
			}
			break;
	}
}

function _ajaxXMLToArray(oXML)
{
	var oResult=new Array();

	if(oXML) for(i=0;i<oXML.childNodes.length;i++)
		if(oXML.childNodes[i].nodeType==1)
			oResult[i]=oXML.childNodes[i].text;

	return oResult;
}

if( document.implementation.hasFeature("XPath", "3.0") ){
	if( typeof XMLDocument == "undefined" ){ XMLDocument = Document; }
	XMLDocument.prototype.selectNodes = function(cXPathString, xNode){
	if( !xNode ) { xNode = this; }
		var oNSResolver = this.createNSResolver(this.documentElement)
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
		var aResult = [];
		for( var i = 0; i < aItems.snapshotLength; i++){aResult[i] =  aItems.snapshotItem(i);	}
		return aResult;
	}
	XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode){
		if( !xNode ) { xNode = this; }
		var xItems = this.selectNodes(cXPathString, xNode);
		if( xItems.length > 0 ){return xItems[0];	}
		else{return null;	}
	}
	Element.prototype.selectNodes = function(cXPathString){
		if(this.ownerDocument.selectNodes){	return this.ownerDocument.selectNodes(cXPathString, this);}
		else{throw "For XML Elements Only";}
	}
	Element.prototype.selectSingleNode = function(cXPathString){
		if(this.ownerDocument.selectSingleNode){return this.ownerDocument.selectSingleNode(cXPathString, this);	}
		else{throw "For XML Elements Only";}
	}
}