String.prototype.trim=function(){
	return this.replace(/(^\s*)|(\s*$)/g,"");
}
if(typeof $=="undefined")$=document.getElementById;
function $F(objID) {
  return document.getElementById(objID).value
}
var web_ErrInfo="";
var XMLHttp=function(){
	try {return new ActiveXObject("Msxml5.XMLHTTP");}catch(e){}
	try {return new ActiveXObject("Msxml4.XMLHTTP");}catch(e){}
	try {return new ActiveXObject("Msxml3.XMLHTTP");}catch(e){}
	try {return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){}
	try {return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
	try {return new XMLHttpRequest();}catch(e){}
	return null;
}

function updater(objid,url,method,parameters,loading,async){
	web_ErrInfo="";
	var req=new XMLHttp();
	var objid=objid;
	var url=url;
	var method=method;
	var parameters=parameters;
	var loading=loading;
	var async=async;
	if (req!=null){
		req.onreadystatechange = function(){
			if (req.readyState==4){
				if(req.status==200){
					window.status=""
					if($(loading)){
					$(loading).style.display="none";
					}
					var objhtml=req.responseText;
					objhtml=objhtml.trim();//去除空格
					if(objhtml.indexOf("$sky")==0)  //返回的数据如果是脚本代码前面加个$sky
					eval(objhtml.replace("$sky",""));//然后去掉再用JS的eval函数执行代码就行了
					else if(objhtml.indexOf("<script>")==0){
					var re=/<script>([\s|\S]+?)<\/script>/;
					eval(objhtml.replace(re,"$1"));
					}
					else if(objhtml) {
						$(objid).innerHTML=objhtml;//是字符串就显示到dom里面
						web_ErrInfo="yes";
					}
				}else{
					window.status="服务器出错,错误代码："+req.statusText
					alert("服务器出错,错误代码："+req.statusText)
				}
			}else{
				 window.status="正在加载......"
				 if($(loading))
				 $(loading).style.display="block";
			}
		}
		if (parameters=="") url=url;
		else url+="?"+parameters;
		url+=(url.indexOf("?") >= 0)?"&nowtime="+new Date().getTime():"?nowtime=" + new Date().getTime();
		if (method=='get'){
			req.open('GET',url,async);
			req.send(null);
		}else if (method=='post'){
			req.open('POST',url,async);
			req.setRequestHeader("Content-Length",parameters.length); 
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
			req.send(parameters);
		}else{
		    alert("请至少使用一种传送方式");
		}
	}else{
		alert("无法创建xmlhttp");
	}
}

