resumeError=function(){return true;}
reportError=function(msg,url,line){var str = "You have found an error as below: \n\n";str += "Err: " + msg + " on line: " + line;alert(str);return true;}
//window.onerror = resumeError;
$=function(obj){return document.getElementById(obj);}
$i=function(obj){return document.getElementById(obj);}
$n=function(obj){return document.getElementsByName(obj);}
$v=function(obj){return document.getElementById(obj).value;}
$f=function(obj){return document.getElementById(obj).focus();}
$c=function(obj){for(var i=0;i<document.getElementsByName(obj).length;i++){if(document.getElementsByName(obj)[i].checked){return document.getElementsByName(obj)[i].value;break;}}}
var XMLHttp=function(){
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 show(div,inner){
$(div).style.display='';
$(div).innerHTML=inner;
};
function DecideValue(div,TPx,ajax,inString){
if (TPx==1){
if (inString=='0'||inString==''){
	$(div).style.display='none';
	}else if (inString=='1'){
		show(div,ajax.responseText);
		}else{
			inString = inString.replace("*.*",ajax.responseText)
			eval(inString);
			}
}
else if (TPx==2){
if (inString=='0'||inString==''){
	$(div).style.display='none';
	}
	else if (inString=='1'){
		show(div,getErrorText(ajax.status));
		}else{
			eval(inString);
			}
}
else if (TPx==3){
if (inString=='0'||inString==''){
	$(div).style.display='none';
	}else if (inString=='1'){
		show(div,"Loading,Please wait a second···");
		}else{
			eval(inString);
		}
}
};
function iRequest(method,url,params,StatusBox,errFun,statFun,rsFun){
//	onerror=reportError;
genElement(StatusBox,"div","none","");
var ajaxOBJ=new XMLHttp();
if (ajaxOBJ!=null){
ajaxOBJ.onreadystatechange=function(){
	if(ajaxOBJ.readyState == 4){
		if(ajaxOBJ.status == 200){
			DecideValue(StatusBox,1,ajaxOBJ,rsFun);
			}
		else{
			DecideValue(StatusBox,2,ajaxOBJ,errFun);
			}
	}else{
		DecideValue(StatusBox,3,ajaxOBJ,statFun);
		}
};
if(method=="get"){
url=url+"?"+params;
params=null;
}
ajaxOBJ.open(method,url,true);
ajaxOBJ.setRequestHeader("cache-control","no-cache");
if(method=="post"){
ajaxOBJ.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajaxOBJ.send(params);
}
}else{
alert("An unsuccessful to create XMLHttp Request Object.");
}
};
function genElement(gId,gObj,gDsp,gCnt){
if (!$(gId)){
var mObj=document.createElement(gObj);
mObj.id = gId;
mObj.style.display = gDsp;
mObj.innerHTML = gCnt;
document.body.appendChild(mObj);
}
}
function getErrorText(Stat){
	var EC;
	switch (Stat){
		case 400:{EC = "HTTP 错误 400 - 请求格式错误";break;}
		case 401:{EC = "HTTP 错误 401 - 未经授权：访问由于凭据无效被拒绝";break;}
		case 403:{EC = "HTTP 错误 403 - 禁止访问：访问被拒绝";break;}
		case 404:{EC = "HTTP 错误 404 - 文件或目录未找到";break;}
		case 405:{EC = "HTTP 错误 405 - 用于访问该页的 HTTP 动作未被许可";break;}
		case 406:{EC = "HTTP 错误 406 - 客户端浏览器不接受所请求页面的 MIME 类型";break;}
		case 407:{EC = "HTTP 错误 407 - 服务器需要初始的代理验证";break;}
		case 408:{EC = "HTTP 错误 408 - 请求超时";break;}
		case 410:{EC = "HTTP 错误 410 - 请求文件已删除";break;}
		case 412:{EC = "HTTP 错误 412 - 前提条件失败";break;}
		case 414:{EC = "HTTP 错误 414 - 请求 URI 太大";break;}
		case 415:{EC = "HTTP 错误 415 - 不支持的媒体类型";break;}
		case 500:{EC = "HTTP 错误 500 - 服务器内部错误";break;}
		case 501:{EC = "错误 501 - 方法未在 Web 服务器上实现";break;}
		case 502:{EC = "HTTP 错误 502 - 服务器作为网关或代理服务器时收到无效的响应";break;}
		case 503:{EC = "HTTP 错误 503 - 链接人数过多或者系统产生错误";break;}
		default :{EC = "HTTP 错误 500 - 服务器内部错误";break;}
	}
	return(EC);
};
function sAlert(str){
	var msgw,msgh,bordercolor;
	msgw=400;//提示窗口的宽度
	msgh=100;//提示窗口的高度
	titleheight=25 //提示窗口标题高度
	bordercolor="#336699";//提示窗口的边框颜色
	titlecolor="#99CCFF";//提示窗口的标题颜色

	var sWidth,sHeight;
	sWidth=document.body.offsetWidth;
	sHeight=screen.height;
	var bgObj=document.createElement("div");
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#777";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
	bgObj.style.opacity="0.6";
	bgObj.style.left="0";
	bgObj.style.width=sWidth + "px";
	bgObj.style.height=sHeight + "px";
	bgObj.style.zIndex = "10000";
	document.body.appendChild(bgObj);

	var msgObj=document.createElement("div")
	msgObj.setAttribute("id","msgDiv");
	msgObj.setAttribute("align","left");
	msgObj.style.background="white";
	msgObj.style.border="1px solid " + bordercolor;
	msgObj.style.position = "absolute";
	msgObj.style.left = "50%";
	msgObj.style.top = "50%";
	msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
	msgObj.style.marginLeft = "-225px" ;
	msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
	msgObj.style.width = msgw + "px";
	msgObj.style.height =msgh + "px";
	msgObj.style.textAlign = "center";
	msgObj.style.lineHeight ="25px";
	msgObj.style.zIndex = "10001";

   var title=document.createElement("h4");
   title.setAttribute("id","msgTitle");
   title.setAttribute("align","right");
   title.style.margin="0";
   title.style.padding="3px";
   title.style.background=bordercolor;
   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
   title.style.opacity="0.75";
   title.style.border="1px solid " + bordercolor;
   title.style.height="18px";
   title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
   title.style.color="white";
   title.style.cursor="pointer";
   title.innerHTML="关闭";
   title.onclick=function(){
		document.body.removeChild(bgObj);
		document.getElementById("msgDiv").removeChild(title);
		document.body.removeChild(msgObj);
		}
   document.body.appendChild(msgObj);
   document.getElementById("msgDiv").appendChild(title);
   var txt=document.createElement("p");
   txt.style.margin="1em 0"
   txt.setAttribute("id","msgTxt");
   txt.innerHTML=str;
   document.getElementById("msgDiv").appendChild(txt);
}
function isNull(variable) {
	return typeof variable == 'undefined'||variable == "" || variable == null ? true : false;
}
function trim(str) {
	return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
}
function left(mainStr,lngLen) {
	if (lngLen>0) {
		return mainStr.substring(0,lngLen)
	}
	else{
		return null
	}
}
function right(mainStr,lngLen) {
	if (mainStr.length-lngLen>=0 && mainStr.length>=0 && mainStr.length-lngLen<=mainStr.length) {
		return mainStr.substring(mainStr.length-lngLen,mainStr.length)
	}
	else{
		return null;
	}
}
function mid(mainStr,starnum,endnum){
	if (mainStr.length()>=0){
		return mainStr.substr(starnum,endnum)
	}
	else{
		return null
		}
}
function getQuery(name){
	var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)");
	var r=window.location.search.substr(1).match(reg);
	if (r!=null) return unescape(r[2]);
	return "";
}
function getCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c =ca[i].replace( /^\s*/,"");
		if (c.indexOf(nameEQ) == 0){
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}
function createCookie(name,value,days){
	var expires = "";
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+value+expires+"; path=/";
}