var s_nReq = 0;
var s_arReq = new Array;

function XMLRequest_onreadystatechange(idx)
{
	var XMLReq;

	XMLReq = s_arReq[idx];
	if(!XMLReq)
		return;

	if(XMLReq.Req.readyState != 4)
		return;

	if(XMLReq.Req.status != 200)
	{
		alert("XMLReq error "+XMLReq.Req.status);
		return;
	}
	if(!XMLReq.Req.responseXML)
	{
		alert("XMLReq error, empty response");
		return;
	}

	XMLReq.CallBack(XMLReq);
}

function XMLRequest(CallBack)
{
	this.idx = -1;

	if(window.XMLHttpRequest)
	{
		this.Req = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		var msxmls = new Array
		(
			'Msxml2.XMLHTTP.5.0',
			'Msxml2.XMLHTTP.4.0',
			'Msxml2.XMLHTTP.3.0',
			'Msxml2.XMLHTTP',
			'Microsoft.XMLHTTP'
		);
		for(var i = 0; i < msxmls.length; i++)
		{
			try
			{
				this.Req = new ActiveXObject(msxmls[i]);
			}
			catch(e){}
		}
	}
	if(!this.Req)
		return;

	this.idx = s_nReq;
	s_nReq++;
	s_arReq[this.idx] = this;

	this.CallBack = CallBack;
	this.Req.onreadystatechange = new Function("XMLRequest_onreadystatechange("+this.idx+")");
}

function LoadXML(sUrl, OnComplete, Param, Param2, Param3)
{
	XMLReq = new XMLRequest(OnComplete);
	if(Param)
		XMLReq.Param = Param;
	if(Param2)
		XMLReq.Param2 = Param2;
	if(Param3)
		XMLReq.Param3 = Param3;
	XMLReq.Req.open("GET", sUrl, true);
	XMLReq.Req.send(null);
}

function GetField(Record, sField)
{
	FeildList = Record.getElementsByTagName(sField);
	if(FeildList.length <= 0)
		return null;

	TextNode = FeildList[0].firstChild;
	if(!TextNode || (TextNode.nodeType != 3))
		return null;

	return TextNode.nodeValue;
}

