 /**
 * Simple AJAX for Action.
 * 
 * @author Jim Huang
 */

function _call(url, receiveMethod)
{
	var _xmlHttp = _getXMLHttpRequest();
	_xmlHttp.open("GET", url, true);
	_xmlHttp.onreadystatechange =  function()
	{
		if (_xmlHttp.readyState == 4)
			receiveMethod(_xmlHttp.responseText);
	};
	_xmlHttp.send(null);
}

function _callSynchr(url, receiveMethod)
{
		var _xmlHttp = _getXMLHttpRequest();
	_xmlHttp.open("GET", url, false);
	alert('after open');
	_xmlHttp.onreadystatechange =  function()
	{
		alert('readystate=' + _xmlHttp.readyState);
		if (_xmlHttp.readyState == 4)
			receiveMethod(_xmlHttp.responseText);
	};
	_xmlHttp.send(null);
}

function _callPost(url, formObj, receiveMethod)
{
	var param = '';
	if (formObj)
	{
		for(var i=0; i<formObj.elements.length; i++)
		{
			if (i != 0)
				param += '&';
			param += formObj.elements[i].name + '=' + formObj.elements[i].value;
		}
	}
	var _xmlHttp = _getXMLHttpRequest();
	_xmlHttp.open("POST", url, true);
	_xmlHttp.onreadystatechange =  function()
	{
		if (_xmlHttp.readyState == 4)
			receiveMethod(_xmlHttp.responseText);
	};
	_xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
	_xmlHttp.send(param);
}

function _callNreload(url)
{
	var _xmlHttp = _getXMLHttpRequest();
	_xmlHttp.open("GET", url, true);
	_xmlHttp.onreadystatechange =  function()
	{
		if (_xmlHttp.readyState == 4)
			window.location.reload();
	};
	_xmlHttp.send(null);
}

function _getXMLHttpRequest()
{
	var xmlHttp;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try {
	xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
		xmlHttp = null;
		}
	}
	@end @*/
	if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
	xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}