var Transport={filename:"transport.js",debugging:{isDebugging:0,debuggingMode:0,linefeed:"",containerId:0},debug:function(b,a){this.debugging={isDebugging:b,debuggingMode:a,linefeed:a?"<br />":"\n",containerId:"dubugging-container"+new Date().getTime()}},onComplete:function(){},onRunning:function(){},run:function(b,e,j,a,f,i,c){e=this.parseParams(e);a=typeof(a)==="string"&&a.toUpperCase()==="GET"?"GET":"POST";if(a==="GET"){var h=new Date();b+=e?(b.indexOf("?")===-1?"?":"&")+e:"";b=encodeURI(b)+(b.indexOf("?")===-1?"?":"&")+h.getTime()+h.getMilliseconds();e=null}f=typeof(f)==="string"&&((f=f.toUpperCase())==="JSON"||f==="XML")?f:"TEXT";i=i===false?false:true;var l=this.createXMLHttpRequest();try{var k=this;if(typeof(k.onRunning)==="function"&&!c){k.onRunning()}l.open(a,b,i);if(a==="POST"){l.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}if(i){l.onreadystatechange=function(){if(l.readyState==4){switch(l.status){case 0:case 200:if(typeof(k.onComplete)==="function"){k.onComplete()}if(typeof(j)==="function"){j.call(k,k.parseResult(f,l),l.responseText)}break;case 304:break;case 400:alert("XmlHttpRequest status: [400] Bad Request");break;case 404:alert("XmlHttpRequest status: [404] \nThe requested URL "+b+" was not found on this server.");break;case 409:break;case 503:alert("XmlHttpRequest status: [503] Service Unavailable");break;default:alert("XmlHttpRequest status: ["+l.status+"] Unknow status.")}l=null}};if(l!=null){l.send(e)}}else{if(typeof(k.onRunning)==="function"){k.onRunning()}l.send(e);var m=k.parseResult(f,l);if(typeof(k.onComplete)==="function"){k.onComplete()}if(typeof(j)==="function"){j.call(k,m,l.responseText)}return m}}catch(g){if(typeof(k.onComplete)==="function"){k.onComplete()}alert(this.filename+"/run() error:"+g.description)}},displayDebuggingInfo:function(c,a){if(!this.debugging.debuggingMode){alert(c)}else{var e=this.debugging.containerId;if(!document.getElementById(e)){div=document.createElement("DIV");div.id=e;div.style.position="absolute";div.style.width="98%";div.style.border="1px solid #f00";div.style.backgroundColor="#eef";var b=document.body.scrollTop||window.pageYOffset||0;div.style.top=document.body.clientHeight*0.6+b+"px";document.body.appendChild(div);div.innerHTML="<div></div><hr style='height:1px;border:1px dashed red;'><div></div>"}var d=div.getElementsByTagName("DIV");if(a==="param"){d[0].innerHTML=c}else{d[1].innerHTML=c}}},createXMLHttpRequest:function(){var d=null;if(window.ActiveXObject){var a=["Microsoft.XMLHTTP","MSXML6.XMLHTTP","MSXML5.XMLHTTP","MSXML4.XMLHTTP","MSXML3.XMLHTTP","MSXML2.XMLHTTP","MSXML.XMLHTTP"];for(var c=0;c<a.length;c++){try{d=new ActiveXObject(a[c]);break}catch(b){continue}}}else{d=new XMLHttpRequest()}return d},onXMLHttpRequestError:function(b,a){throw"URL: "+a+"\nreadyState: "+b.readyState+"\nstate: "+b.status+"\nheaders: "+b.getAllResponseHeaders()},parseParams:function(d){var e="";d=d?d:"";if(typeof(d)==="string"){e=d}else{if(typeof(d)==="object"){try{e="JSON="+d.toJSONString()}catch(b){alert("Can't stringify JSON!");return false}}else{alert("Invalid parameters!");return false}}if(this.debugging.isDebugging){var a=this.debugging.linefeed,c="[Original Parameters]"+a+d+a+a+"[Parsed Parameters]"+a+e;this.displayDebuggingInfo(c,"param")}return e},preFilter:function(a){return a.replace(/\xEF\xBB\xBF/g,"")},parseResult:function(c,f){var a=null;switch(c){case"JSON":a=this.preFilter(f.responseText);try{a=a.parseJSON()}catch(d){throw this.filename+"/parseResult() error: can't parse to JSON.\n\n"+f.responseText}break;case"XML":a=f.responseXML;break;case"TEXT":a=this.preFilter(f.responseText);break;default:throw this.filename+"/parseResult() error: unknown response type:"+c}if(this.debugging.isDebugging){var b=this.debugging.linefeed,e="[Response Result of "+c+" Format]"+b+a;if(c==="JSON"){e="[Response Result of TEXT Format]"+b+f.responseText+b+b+e}this.displayDebuggingInfo(e,"result")}return a}};var Ajax=Transport;Ajax.call=Transport.run;