function $(id){return document.getElementById(id);}
function get(url){var ajax=new Ajax(function(){eval(ajax.Data);});ajax.get(url,"reqTime="+new Date().getTime());}
function hide(id){$(id).style.display='none';}
function show(id){$(id).style.display='';}
function frmval(frm,url){var data='',i=0,e='',ev='',and='';for(i=0;i<$(frm).length;i++){var e=$(frm)[i];if(e.name!=''){if(e.type=='select-one'&&e.selectedIndex>-1){ev=e.options[e.selectedIndex].value;}else if(e.type=='checkbox' || e.type=='radio'){if(e.checked==false){continue;}ev=e.value;}else{ev=e.value;}ev=escape(ev);data+=and+e.name+'='+ev;and='&';}}if(url){if(url.indexOf("?")>0){data=url+'&'+data;}else{data=url+'?'+data;}}return data;}
function msgbox(obj,maxbox){var width=0,b='msgbox',t='msgtitle',m='msgcontent';var tit=obj.getAttribute("title"),url=obj.getAttribute("url"),frm=obj.getAttribute("frm");if(!tit){tit="&nbsp;";}if(!maxbox){width=450;}else{width=650;}$(b).style.display='block';$(b).style.top=document.documentElement.scrollTop+100+'px';$(b).style.left=document.body.scrollWidth/2-(width/2)+'px';$(b).style.width=width+'px';$(t).innerHTML='<span onclick="msgboxclose();" title="close"></span>'+tit;if(frm){url=frmval(frm,url);}$(m).innerHTML='<div id="loading">加载中,请稍等...</div>';var ajax=new Ajax(function(){$(m).innerHTML=ajax.Data;setTimeout("msgboxmove()",1);},function(){$(m).innerHTML='服务器无响应,请稍后再试';});ajax.get(url,"reqTime="+new Date().getTime());}
function msgboxmove(){$('msgbox').style.top=document.documentElement.scrollTop+100+'px';$('msgbox').style.left=document.body.scrollWidth/2-(parseInt($('msgbox').style.width)/2)+'px';setTimeout("msgboxmove()",1);}
function msgboxclose(){$('msgcontent').innerHTML='';$('msgbox').style.display='none';}
function Ajax(onSuccess,onFail){this.OnSuccess=onSuccess;if(onFail){this.OnFail=onFail;}if(window.XMLHttpRequest){this.xhr=new XMLHttpRequest();}else{try{this.xhr=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){this.xhr=new ActiveXObject("Microsoft.XMLHTTP");}}this.async=true;this.dataType="text";}
Ajax.prototype={setXML:function(){this.dataType="xml";},send:function(url,data,method,encoding){var meth="get",contentType="application/x-www-form-urlencoded";if(method&&method=="post"){meth="post";}if(meth=="post"){if(encoding){contentType+=''+encoding;}else{contentType+=";charset=GBK";}}else if(data){url+=(url.indexOf("?")>-1?"&":"?");url=url+data;data=null;}var me=this;this.xhr.open(meth.toUpperCase(),url,this.async);this.xhr.onreadystatechange=function(){me.onStateChg.call(me);};if(meth=="post"){this.xhr.setRequestHeader("Content-Type", contentType);}this.xhr.send(data);},post:function(url,data,encoding){this.send(url,data,"post",encoding);},get:function(url,data){this.send(url,data);},onStateChg:function(){if(this.xhr.readyState!=4){return;}if(this.xhr.status>=200&&this.xhr.status<300){if(this.dataType=="xml"){this.Data=this.xhr.responseXML;}else{this.Data=this.xhr.responseText;}this.OnSuccess();}else if(this.OnFail){this.OnFail();}}}