function XmlHttpCommunicatorDef(a){this.OnGetReply=null;this.OnComplete=null;this.OnTimeout=null;this._xmlHttp=null;this._url=a;this._responseHeaders=null;this._innerOnReply=null;this.TimeOut=10000;this.CustomParameters=null;this.IsOpened=function(){try{return this._xmlHttp.readyState==1}catch(b){return false}};this.IsSent=function(){try{return this._xmlHttp.readyState==2}catch(b){return false}};this.IsRecieving=function(){try{return this._xmlHttp.readyState==3}catch(b){return false}};this.IsLoaded=function(){try{return this._xmlHttp.readyState==4}catch(b){return false}};this.Abort=function(){return this._xmlHttp.Abort()};this._onTimeOut=function(){if(this.OnTimeout!=null){this.OnTimeout()}};this.Dispose=function(){if(this._xmlHttp!=null){try{this._xmlHttp.onreadystatechange=null;this._xmlHttp=null}catch(b){}}};this._encode=function(b){if(b==null){return b}return encodeURIComponent(b)};this._handleException=function(b,c){if((c==null)||(c.number==-2147467259)){return}if((c.message==null)&&(c.name==null)&&(c.number==null)){alert(b+c)}else{alert(b+"\r\n"+c.name+":"+c.message+"("+c.number+")")}};this._onReadyStateChange=function(){switch(this._xmlHttp.readyState){case 0:break;case 1:break;case 2:break;case 3:try{this._responseHeaders=this._xmlHttp.getAllResponseHeaders()}catch(c){this._handleException("Recieving error occured! Error: ",c)}break;case 4:var b;try{b=this._xmlHttp.status}catch(c){b=null}if(this._innerOnReply!=null){this._innerOnReply(b,this._xmlHttp.responseXML,this._xmlHttp.responseText,this._xmlHttp.responseBody)}if(this.OnGetReply!=null){this.OnGetReply(b,this._xmlHttp.responseXML,this._xmlHttp.responseText,this._xmlHttp.responseBody,this.CustomParameters)}if(this.OnComplete!=null){this.OnComplete({Status:b,Xml:this._xmlHttp.responseXML,Text:this._xmlHttp.responseText,Body:this._xmlHttp.responseBody},this.CustomParameters)}break}};this.ReCreate=function(){this._xmlHttp=null;try{this._xmlHttp=new XMLHttpRequest()}catch(f){var b=new Array("Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP");for(var c=0;c<b.length;++c){try{this._xmlHttp=new ActiveXObject(b[c]);if(this._xmlHttp!=null){break}}catch(f){}}}if(this._xmlHttp==null){alert("Cannot create XmlHttp object!")}var d=this;this._xmlHttp.onreadystatechange=function(){d._onReadyStateChange()};if(this._xmlHttp.ontimeout!=null){this._xmlHttp.ontimeout=this._onTimeOut}};this.CallSimpleMethod=function(j,c,g,b,f){var e,d=(c!=null)?c.length:0;var h={};for(e=0;e<d;e++){h[c[e].Name]=this._encode(c[e].Value)}return this.MakeCall(j,h,g,b,f)};this.MakeCall=function(g,k,h,b,f){var j="";var d,c=(k!=null)?k.length:0;for(ParamName in k){j+=this._encode(ParamName)+"="+this._encode(k[ParamName])+"&"}if(j.length>0){j=j.substring(0,j.length-1)}j="Arguments="+this._encode(j)+"&IsCallback=1";var e={"Content-Type":"application/x-www-form-urlencoded","A-Method":g};return this.Post(e,j,h,b,f)};this.CallSoapMethod=function(f,c,e,b,d){};this.Get=function(e,d,b,c){return this._sendRequest("GET",this._url,e,null,d,b,c)};this.Post=function(f,d,e,b,c){return this._sendRequest("POST",this._url,f,d,e,b,c)};this.IsProcessing=function(){return this.IsOpened()||this.IsSent()||this.IsRecieving()};this._sendRequest=function(b,c,i,n,l,f,k){if(l==null){l=true}if(i==null){i={}}this._responseHeaders=null;if(this.IsRecieving()){throw new Error("Recieving reply");return null}if(this.IsSent()){throw new Error("Waiting for reply");return null}if(this.IsOpened()){throw new Error("Already opened");return null}this.ReCreate();try{if(f!=null){if(k!=null){this._xmlHttp.open(b,c,l,f,k)}else{this._xmlHttp.open(b,c,l,f)}}else{this._xmlHttp.open(b,c,l)}}catch(j){this._handleException("XmlHTTPRequest.Open error: ",j);return null}if(!this.IsOpened()){throw new Error("INVALID_STATE_ERR")}for(ParamName in i){this._xmlHttp.setRequestHeader(ParamName,i[ParamName])}try{if(!l){var h;var d;var m;var g;var o=false;this._innerOnReply=function(p,q,r,e){h=p;d=q;m=r;g=e;o=true};this._xmlHttp.send(n);if(!o){alert("Couldn't get reply!");return{Status:"",Xml:null,Text:"",Body:""}}return{Status:h,Xml:d,Text:m,Body:g}}else{this._xmlHttp.send(n)}}catch(j){this._handleException("XmlHTTPRequest.Send error: ",j)}};this.ReCreate()};
