function freeDOMAjax(){this.queue=[];this.requested=[];this.saveRequests=true;this.currentRequest=false;this.debug=false;this.createXHR=function(){var B=["MSXML2","Microsoft","MSXML","MSXML3"];for(var A=0;A<B.length;A++){try{return new ActiveXObject(B[A]+".XmlHttp");}catch(C){continue;}}try{return new XMLHttpRequest();}catch(C){return false;}};this.XHR=this.createXHR();this.request=function(G,E,C,D,A,I,B,H,F){this.aborted=0;this.strUrl=G;this.fnReturn=E;this.isReturnEscaped=(A==1)?1:0;this.isUrlEscaped=(D==0)?0:1;this.strData=freeDOMAjax.getDados(C,this.isUrlEscaped);this.method=(typeof H=="undefined"||H==""||H==0)?((this.strData==null)?"GET":"POST"):H;this.readyState=false;this.status=false;this.requestHeaders=(F instanceof Array)?F:[];this.responseHeaders="";this.responseText="";this.startLoading=(typeof I!="function")?freeDOMAjax.startLoading:I;this.finishLoading=(typeof B!="function")?freeDOMAjax.finishLoading:B;if(this.method=="POST"){this.requestHeaders.push("Content-type=application/x-www-form-urlencoded");this.requestHeaders.push("encoding=ISO-8859-1");}return this;};this.abort=function(){this.currentRequest.aborted=1;return this.XHR.abort();};this.addRequest=function(G,E,C,D,A,I,B,H,F){if(arguments.length==1){this.queue.push(arguments[0]);}else{this.queue.push(new this.request(G,E,C,D,A,I,B,H,F));}if(this.queue.length==1&&!this.currentRequest){this.doRequest();}};this.doRequest=function(){if(this.currentRequest=this.queue.pop()){try{this.currentRequest.startLoading();this.XHR.open(this.currentRequest.method,this.currentRequest.strUrl+(this.currentRequest.strUrl.indexOf("?")==-1?"?":"&")+Math.random(),true);this.XHR.onreadystatechange=function(){var D=this;return function(){D.doReturn.apply(D,[D.XHR]);};}.apply(this);if(this.currentRequest.requestHeaders.length>0){for(var C=0,A;C<this.currentRequest.requestHeaders.length&&(A=this.currentRequest.requestHeaders[C].split("="));C++){this.XHR.setRequestHeader(A[0],A[1]);}}this.XHR.send(this.currentRequest.strData);}catch(B){this.currentRequest.finishLoading(false);if(this.debug){alert(this.debugRequest(this.currentRequest));}}}};this.doReturn=function(){this.currentRequest.readyState=this.XHR.readyState;if(this.currentRequest.readyState==4){this.currentRequest.finishLoading();if(!this.currentRequest.aborted){this.currentRequest.status=this.XHR.status;this.currentRequest.responseText=this.XHR.responseText;this.currentRequest.responseHeaders=this.XHR.getAllResponseHeaders();if(this.currentRequest.isReturnEscaped){this.currentRequest.responseText=unescape(this.currentRequest.responseText.replace(/\+/g," "));}this.currentRequest.fnReturn(this.currentRequest.responseText,this.currentRequest);}if(this.saveRequests){this.requested.push(this.currentRequest);}this.currentRequest=false;if(this.queue.length>0){this.doRequest();}}};this.getDados=function(H,B){var E="";var D;if(H==null||H.length==0){return null;}if(H instanceof Array){for(D=0;D<H.length;D++){if(D>0){E+="&";}E+=this.getDados(H[D],B);}return E;}if(typeof (H)=="string"){return H;}if(H.nodeName.toLowerCase()=="form"){var G,C,F;var A=new Array();G=$tags("input",H);C=$tags("select",H);F=$tags("textarea",H);for(D=0;D<F.length;D++){if(!F[D].disabled){A.push([F[D].name,F[D].value]);}}for(D=0;D<G.length;D++){if(G[D].type=="text"&&!G[D].disabled){A.push([G[D].name,G[D].value]);}if(G[D].type=="file"&&!G[D].disabled){A.push([G[D].name,G[D].value]);}if(G[D].type=="password"&&!G[D].disabled){A.push([G[D].name,G[D].value]);}if(G[D].type=="hidden"&&!G[D].disabled){A.push([G[D].name,G[D].value]);}if((G[D].type=="radio"||G[D].type=="checkbox")&&G[D].checked&&!G[D].disabled){A.push([G[D].name,G[D].value]);}}for(D=0;D<C.length;D++){if(C[D].selectedIndex==-1){A.push(C[D].name,"");}else{A.push(new Array(C[D].name,C[D].options[C[D].selectedIndex].value));}}for(D=0;D<A.length;D++){if(D>0){E+="&";}if(B){E+=encodeURIComponent(A[D][0])+"="+encodeURIComponent(A[D][1]);}else{E+=A[D][0]+"="+A[D][1];}}return E;}};this.startLoading=function(){try{if(showProcessing){startProcessing();}}catch(A){}return true;};this.finishLoading=function(){try{stopProcessing();}catch(A){}try{stopPopupProcessing();}catch(A){}return true;};this.debugRequest=function(D){var C;var A=["aborted","strUrl","fnReturn","strData","method","readyState","status","requestHeaders","responseHeaders","responseText","isReturnEscaped","isUrlEscaped","startLoading","finishLoading"];if(typeof D=="undefined"){D=this.requested[this.requested.length-1];}if(D){C="Request Debug";for(var B=0;B<A.length;B++){C+="\n\t"+A[B]+': "'+D[A[B]].toString().replace("\n","")+'"';}}else{C=false;}return C;};}freeDOMAjax=new freeDOMAjax();