/*
  参数一：ajax请示的url
  参数二：但正在读取时执行的用户自定义函数
  参数三：但请求完成时执行的用户自定义函数
  参数四：同步/异步
  参数五：给请求完成时执行的用户自定义函数附加一个参数
*/
function noresFun(){
        //alert('没有定义完成时执行的函数');
}

function  noloadFun(){
	//alert('没有定义等待时执行的函数');
}

function ajaxRequest(url,loadFun,resFun,common,arg)
{
	if (!common) common = false;
	if (!loadFun) loadFun = noloadFun();
	if (!resFun) resFun = noresFun();
	if (!arg) arg = '';
	var httpRequest;
	httpRequest = null;
	if(window.XMLHttpRequest)
	{
		httpRequest = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if(httpRequest == null)
	{
		alert("您的浏览器版本过低，请升级浏览器之后再试！");
		return false;
	}
	var responsetexts = '';
	httpRequest.onreadystatechange = function()
	{
		if(httpRequest.readyState>=0 && httpRequest.readyState<=3)
		{
			eval(loadFun+'(responsetexts)');		
		}
		if(httpRequest.readyState==4)
		{
			responsetexts = httpRequest.responseText;
			if (arg && arg!='')
				eval(resFun+'(responsetexts,arg)');
			else
				eval(resFun+'(responsetexts)');
		}
	};
	httpRequest.open("GET", url, common);
	httpRequest.send(null);
}

//去空格函数
String.prototype.Trim = function() 
{ 
	return this.replace(/(^\\s*)|(\\s*$)/g,""); 
}

