/** Ajax方式提交请求，成功后执行回调函数
	* 请求页面需返回一个JSON，成功返回：“{"status":true, "message":"信息"}>”，失败返回：“{"status":false, "message":"信息"}”
	* @param string method			GET或POST
	* @param string URL					访问地址
	* @param bool async					是否异步模式
	* @param string body				传送的值
	* @param string callback		回调函数名。如：alert。注意：不带“()”
	* @param string param				（可选参数）回调函数的参数。如无参数，则默认用responseText中的message字段代替
	*/
function AjaxRequest(method, URL, async, body, callback)
{
	var response;

	//获取变长参数，转换成字符串
	index = 5;
	param = new Array();
	while(typeof(arguments[index]) != "undefined")
	{
		value = arguments[index];
		if(typeof(arguments[index])=="string") value="\""+value+"\"";
		param.push(value);
		index++;
	}
	param = param.join(", ");

	Ajax = createAjax();
	Ajax.open(method, URL, async);
	if(method=="POST") Ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	Ajax.onreadystatechange = function()
	{
		if(Ajax.readyState==4 && Ajax.status==200)
		{
			eval("response = "+Ajax.responseText+";");
			if(response['status'])
			{
				if(callback) eval(callback+"("+param+")");
			}
			else alert("请求失败："+response['message']);
		}
	}
	Ajax.send(body);
}


//初始化一个xmlhttprequest对象
function createAjax()
{
	ajax = false;
	try
	{
		ajax = new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch(e)
	{
		try
		{
			ajax = new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(e)
		{
		}
	}
	if(!ajax && typeof(XMLHttpRequest) != 'undefined') ajax = new XMLHttpRequest();
	return ajax;
}