function sack(n){this.xmlhttp=null,this.resetData=function(){this.method="POST",this.queryStringSeparator="?",this.argumentSeparator="&",this.URLString="",this.encodeURIString=!0,this.execute=!1,this.element=null,this.elementObj=null,this.requestFile=n,this.vars={},this.responseStatus=new Array(2)},this.resetFunctions=function(){this.onLoading=function(){},this.onLoaded=function(){},this.onInteractive=function(){},this.onCompletion=function(){},this.onError=function(){},this.onFail=function(){}},this.reset=function(){this.resetFunctions(),this.resetData()},this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(n){this.xmlhttp=null}}this.xmlhttp||(typeof XMLHttpRequest!="undefined"?this.xmlhttp=new XMLHttpRequest:this.failed=!0)},this.setVar=function(n,t){this.vars[n]=Array(t,!1)},this.encVar=function(n,t,i){if(!0==i)return Array(encodeURIComponent(n),encodeURIComponent(t));this.vars[encodeURIComponent(n)]=Array(encodeURIComponent(t),!0)},this.processURLString=function(n,t){for(encoded=encodeURIComponent(this.argumentSeparator),regexp=new RegExp(this.argumentSeparator+"|"+encoded),varArray=n.split(regexp),i=0;i<varArray.length;i++)urlVars=varArray[i].split("="),!0==t?this.encVar(urlVars[0],urlVars[1]):this.setVar(urlVars[0],urlVars[1])},this.createURLString=function(n){this.encodeURIString&&this.URLString.length&&this.processURLString(this.URLString,!0),n&&(this.URLString.length?this.URLString+=this.argumentSeparator+n:this.URLString=n),this.setVar("rndval",+new Date),urlstringtemp=[];for(key in this.vars)!1==this.vars[key][1]&&!0==this.encodeURIString&&(encoded=this.encVar(key,this.vars[key][0],!0),delete this.vars[key],this.vars[encoded[0]]=Array(encoded[1],!0),key=encoded[0]),urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0];this.URLString+=n?this.argumentSeparator+urlstringtemp.join(this.argumentSeparator):urlstringtemp.join(this.argumentSeparator)},this.runResponse=function(){eval(this.response)},this.runAJAX=function(n){if(this.failed)this.onFail();else{this.createURLString(n),this.element&&(this.elementObj=document.getElementById(this.element));if(this.xmlhttp){var t=this;if(this.method=="GET")totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString,this.xmlhttp.open(this.method,totalurlstring,!0);else{this.xmlhttp.open(this.method,this.requestFile,!0);try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(i){}}this.xmlhttp.onreadystatechange=function(){switch(t.xmlhttp.readyState){case 1:t.onLoading();break;case 2:t.onLoaded();break;case 3:t.onInteractive();break;case 4:t.response=t.xmlhttp.responseText,t.responseXML=t.xmlhttp.responseXML,t.responseStatus[0]=t.xmlhttp.status,t.responseStatus[1]=t.xmlhttp.statusText,t.execute&&t.runResponse(),t.elementObj&&(elemNodeName=t.elementObj.nodeName,elemNodeName.toLowerCase(),elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"?t.elementObj.value=t.response:t.elementObj.innerHTML=t.response),t.responseStatus[0]=="200"?t.onCompletion():t.onError(),t.URLString=""}},this.xmlhttp.send(this.URLString)}}},this.reset(),this.createAJAX()}
