var Ajax={getTransport:function(){return Try.these(function(){return new ActiveXObject('Msxml2.XMLHTTP')},function(){return new ActiveXObject('Microsoft.XMLHTTP')},function(){return new XMLHttpRequest()})||false;},f:0};Ajax.Responders={B:[],_each:function(k){this.B._each(k);},register:function(w){if(!this.include(w))this.B.push(w);},unregister:function(A){this.B=this.B.without(A);},dispatch:function(v,request,d,m){this.each(function(r){if(r[v]&&typeof r[v]=='function'){try{r[v].apply(r,[request,d,m]);}catch(e){}}});}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.f++;},onComplete:function(){Ajax.f--;}});Ajax.Base=function(){};Ajax.Base.prototype={K:function(options){this.options={method:'post',G:true,D:''};Object.extend(this.options,options||{});},I:function(){return this.d.status==undefined||this.d.status==0||(this.d.status>=200&&this.d.status<300);},H:function(){return!this.I();}};Ajax.Request=Class.create();Ajax.Request.Events=['Uninitialized','Loading','Loaded','Interactive','Complete'];Ajax.Request.prototype=Object.extend(new Ajax.Base(),{initialize:function(url,options){this.d=Ajax.getTransport();this.K(options);this.request(url);},request:function(url){var D=this.options.D||'';if(D.length>0)D+='&_=';try{this.url=url;if(this.options.method=='get'&&D.length>0)this.url+=(this.url.match(/\?/)?'&':'?')+D;Ajax.Responders.dispatch('onCreate',this,this.d);this.d.open(this.options.method,this.url,this.options.G);if(this.options.G){this.d.onreadystatechange=this.onStateChange.bind(this);setTimeout((function(){this.n(1)}).bind(this),10);}this.L();var body=this.options.postBody?this.options.postBody:D;this.d.send(this.options.method=='post'?body:null);}catch(e){this.dispatchException(e);}},L:function(){var c=['X-Requested-With','XMLHttpRequest','X-Prototype-Version',Prototype.Version];if(this.options.method=='post'){c.push('Content-type','application/x-www-form-urlencoded');if(this.d.overrideMimeType)c.push('Connection','close');}if(this.options.c)c.push.apply(c,this.options.c);for(var i=0;i<c.length;i+=2)this.d.setRequestHeader(c[i],c[i+1]);},onStateChange:function(){var readyState=this.d.readyState;if(readyState!=1)this.n(this.d.readyState);},header:function(name){try{return this.d.getResponseHeader(name);}catch(e){}},evalJSON:function(){try{return eval(this.header('X-JSON'));}catch(e){}},evalResponse:function(){try{return eval(this.d.responseText);}catch(e){this.dispatchException(e);}},n:function(readyState){var event=Ajax.Request.Events[readyState];var d=this.d,m=this.evalJSON();if(event=='Complete'){try{(this.options['on'+this.d.status]||this.options['on'+(this.I()?'Success':'Failure')]||Prototype.emptyFunction)(d,m);}catch(e){this.dispatchException(e);}if((this.header('Content-type')||'').match(/^text\/javascript/i))this.evalResponse();}try{(this.options['on'+event]||Prototype.emptyFunction)(d,m);Ajax.Responders.dispatch('on'+event,this,d,m);}catch(e){this.dispatchException(e);}if(event=='Complete')this.d.onreadystatechange=Prototype.emptyFunction;},dispatchException:function(exception){(this.options.onException||Prototype.emptyFunction)(this,exception);Ajax.Responders.dispatch('onException',this,exception);}});Ajax.Updater=Class.create();Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(container,url,options){this.containers={success:container.success?$(container.success):$(container),failure:container.failure?$(container.failure):(container.success?null:$(container))};this.d=Ajax.getTransport();this.K(options);var onComplete=this.options.onComplete||Prototype.emptyFunction;this.options.onComplete=(function(d,object){this.updateContent();onComplete(d,object);}).bind(this);this.request(url);},updateContent:function(){var F=this.I()?this.containers.success:this.containers.failure;var C=this.d.responseText;if(!this.options.evalScripts)C=C.stripScripts();if(F){if(this.options.insertion){new this.options.insertion(F,C);}else{Element.update(F,C);}}if(this.I()){if(this.onComplete)setTimeout(this.onComplete.bind(this),10);}}});Ajax.PeriodicalUpdater=Class.create();Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(container,url,options){this.K(options);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=container;this.url=url;this.start();},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent();},stop:function(){this.updater.onComplete=undefined;clearTimeout(this.M);(this.onComplete||Prototype.emptyFunction).apply(this,arguments);},updateComplete:function(request){if(this.options.decay){this.decay=(request.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=request.responseText;}this.M=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});Ajax.begin=function(tip){if((typeof(tip)!="undefined")&&tip==null)return;if($("Sys_Loading_Tip")){tip=(typeof(tip)!="undefined")?tip:Ajax.tip;$("Sys_Loading_Tip").innerHTML=tip;}if($('Sys_Loading')){if($('Sys_Loading').style.display=="none"){var O=getBody();Element.show($("Sys_Loading"));var l=parseInt(O.clientWidth/2+O.scrollLeft-$('Sys_Loading').offsetWidth/2);var t=parseInt(O.clientHeight/2+O.scrollTop-Element.getHeight("Sys_Loading")/2);$('Sys_Loading').style.left=(l>0)?l+"px":"0px";$('Sys_Loading').style.top=(t>0)?t+"px":"0px";if($S($("Sys_Loading"),"_autoScroll")!="1"){setObjectAutoScroll("Sys_Loading",O.scrollLeft,O.scrollTop);$S($("Sys_Loading"),"_autoScroll","1")}else{$S($("Sys_Loading"),"_autoX",O.scrollLeft);$S($("Sys_Loading"),"_autoY",O.scrollTop);}}}};Ajax.end=function(o){if($('Sys_Loading')&&Ajax.f==0){Element.hide($("Sys_Loading"));}};Ajax.failure=function(o){Ajax.end();var J=(o.status==404)?"访问页面不存在！":(o.status==500)?"访问页面存在错误！":(typeof(o.text)=="undefined")?"可能是网络中断等原因，请检查！":"发生错误："+o.status+"\n原因："+o.text;alert(J);};Ajax.defaultPage="Default.aspx";Ajax.Call=function(){var o,url,option;if(arguments.length>0){var g=arguments[0];url=location.toString();if(typeof(g.url)!="undefined"&&g.url!=null){if(g.url.indexOf("??")==0)url=location.pathname+g.url.replace(/\?\?/i,"?");else if(g.url.indexOf("?")==0)url+=(url.indexOf("?")>0)?g.url.replace(/\?/i,"&"):g.url;else url=g.url;}else url=location.toString();if(url.indexOf("/?")>0)url=url.replace(/\/\?([^\?]*)$/,"/"+Ajax.defaultPage+"?$1");if(typeof(g.tip)=="undefined")g.tip=this.tip;if(g.action=="exec"||!g.action){option={evalScripts:true,onCreate:(g.begin)?g.begin.apply():Ajax.begin(g.tip),D:(typeof(g.pars)!="undefined")?"x="+$escape(g.pars):"",method:"post",onComplete:function(o){window.setTimeout("Ajax.end()",0);if(g.end){var j=$A(arguments);g.end.apply(null,j)}},onSuccess:function(d){if(typeof(g.receive)=="function"){var j=$A(arguments);g.receive.apply(null,j);}},onFailure:function(d){Ajax.failure(d);}};o=new Ajax.Updater({success:g.oHtml},url,option);}else if(g.action=="html"){option={onCreate:(g.begin)?g.begin.apply():Ajax.begin(g.tip),D:(typeof(g.pars)!="undefined")?"x="+$escape(g.pars):"",method:"post",onComplete:function(o){window.setTimeout("Ajax.end()",0);if(g.end){var j=$A(arguments);g.end.apply(null,j)}},onSuccess:function(d){if(typeof(g.receive)=="function"){var j=$A(arguments);g.receive.apply(null,j);}},onFailure:function(d){Ajax.failure(d);}};o=new Ajax.Updater({success:g.oHtml},url,option);}else if(g.action=="webservice"){option={onCreate:(g.begin)?g.begin.apply():Ajax.begin(g.tip),D:(typeof(g.pars)!="undefined")?$escape(g.pars,1):"",method:"post",onComplete:function(o){window.setTimeout("Ajax.end()",0);if(g.end){var j=$A(arguments);g.end.apply(null,j)}},onSuccess:function(d){if(typeof(g.receive)=="function"){var j=$A(arguments);g.receive.apply(null,j);}},onFailure:function(d){alert(d.responseText);Ajax.failure(d);}};o=new Ajax.Request(url,option);}else{option={onCreate:(g.begin)?g.begin.apply():Ajax.begin(g.tip),D:(typeof(g.pars)!="undefined")?"x="+$escape(g.pars):"",method:"post",onComplete:function(o){window.setTimeout("Ajax.end()",0);if(g.end){var j=$A(arguments);g.end.apply(null,j)}},onSuccess:function(d){if(typeof(g.receive)=="function"){var j=$A(arguments);g.receive.apply(null,j);}},onFailure:function(d){alert(d.responseText);Ajax.failure(d);}};o=new Ajax.Request(url,option);}}else{alert("no arguments!");return};} 