function AJAXRequest(pURL, pMethod, pParam, pCallback)
{
	this.vURL = pURL;
	this.vParam = '';
	this.vMethod = pMethod;
	this.vCallback = pCallback;
	this.objHTTPRequest = this.GetHTTPRequest();
	//alert(pParam.length);
	for(var i=0; i<pParam.length; i++) this.vParam += (pParam[i][0] + '=' + encodeURIComponent(pParam[i][1]) + (i+1==pParam.length ? '' : '&'));
	//	for(var i=0; i<pParam.length; i++) this.vParam += (pParam[i][0] + '=' + escape(encodeURI(pParam[i][1])) + (i+1==pParam.length ? '' : '&'));

	if(this.objHTTPRequest)
	{
		var instanceOfThis = this;
		this.objHTTPRequest.onreadystatechange = function() { instanceOfThis.stateChanged(); };
		
		if(this.vMethod==1)
		{
			this.objHTTPRequest.open('GET', this.vURL + '?' + this.vParam, true);
			this.objHTTPRequest.send(null);
		}
		else if(this.vMethod==2)
		{
			this.objHTTPRequest.open('POST', this.vURL, true);
			this.objHTTPRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
//			this.objHTTPRequest.setRequestHeader('Content-length', this.vParam.length);
//			this.objHTTPRequest.setRequestHeader('Connection', 'close');
			this.objHTTPRequest.send(this.vParam);
		}
	}
	else
	{
		eval(this.vCallback + '(true, "Failed to create AJAX object... Contact system administrator...", 1)');
		return null;
	}
}

AJAXRequest.prototype.GetHTTPRequest = function ()
{
	var objHTTPRequest = null;
    
	if(window.ActiveXObject)
	{
    	try { objHTTPRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch(e) { try { objHTTPRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} }
	}
	else if (window.XMLHttpRequest)
	{
		objHTTPRequest = new XMLHttpRequest();
        if(objHTTPRequest.overrideMimeType) { objHTTPRequest.overrideMimeType('text/xml'); }
	}
	
	return objHTTPRequest;
}

AJAXRequest.prototype.stateChanged = function ()
{
	if (this.objHTTPRequest.readyState==4)
	{
		if (this.objHTTPRequest.status==200)
		{
			if(!this.objHTTPRequest.responseXML.documentElement && this.objHTTPRequest.responseStream) this.objHTTPRequest.responseXML.load(this.objHTTPRequest.responseStream);

			var result = this.objHTTPRequest.responseXML;
//			alert(this.objHTTPRequest.responseText);
			
			if(result.getElementsByTagName("ERROR").length>0) eval(this.vCallback + '(true, "' + result.getElementsByTagName("ERROR")[0].firstChild.nodeValue + '", ' + result.getElementsByTagName("ERROR")[0].getAttribute("code") + ')');
			else eval(this.vCallback + '(false, result.getElementsByTagName("SUCCESS")[0], 0)');
        }
        else
        {
			eval(this.vCallback + '(true, "Failed to retrive data... Please retry...", 2)');
        }
	}
}
