var PHP2Ajax={};PHP2Ajax.REQUEST_METHOD_POST="POST";PHP2Ajax.REQUEST_METHOD_GET="GET";PHP2Ajax.READY_STATE_UNINITIALIZED=0;PHP2Ajax.READY_STATE_LOADING=1;PHP2Ajax.READY_STATE_LOADED=2;PHP2Ajax.READY_STATE_INTERACTIVE=3;PHP2Ajax.READY_STATE_COMPLETE=4;PHP2Ajax.HTTP_STATUS_OK=200;PHP2Ajax.HTTP_STATUS_FOUND=302;PHP2Ajax.CALL_REQUEST_PARAMETER="__callHandler";PHP2Ajax.CALLBACK_HANDLER_PARAMETER="__callbackHandler";
PHP2Ajax.add=function(b,a){this.parameters[this.parametersCount]=new PHP2Ajax.ParametersPair(b,a);this.parametersCount++};PHP2Ajax.clearRequest=function(){this.parameters={};this.parametersCount=0};PHP2Ajax.call=function(b){this.add(PHP2Ajax.CALL_REQUEST_PARAMETER,b)};
PHP2Ajax.execute=function(){currentObject=this;try{this.httpRequest=this.createXMLHttp()}catch(b){alert("Error creating the connection to the Server!");return false}try{var a="1",c;for(c in this.parameters){var e=new String(this.parameters[c].value);if(e.indexOf("&")!=-1||e.indexOf("+")!=-1)this.parameters[c].value=encodeURIComponent(e);a=a+"&"+this.parameters[c].name+"="+this.parameters[c].value}if(typeof currentObject.onReadyStateChange=="function")this.httpRequest.onreadystatechange=function(){currentObject.onReadyStateChange()};
if(this.requestMethod==PHP2Ajax.REQUEST_METHOD_GET){this.httpRequest.open(PHP2Ajax.REQUEST_METHOD_GET,this.server+"?"+a,true);this.httpRequest.setRequestHeader("content-type","text/xml");this.httpRequest.send("")}else{this.httpRequest.open(PHP2Ajax.REQUEST_METHOD_POST,this.server,true);this.httpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");this.httpRequest.send(a)}}catch(d){alert("An error has occured calling the external site: "+d);return false}};
PHP2Ajax.setRequestMethod=function(b){this.requestMethod=b==PHP2Ajax.REQUEST_METHOD_GET?PHP2Ajax.REQUEST_METHOD_GET:PHP2Ajax.REQUEST_METHOD_POST};PHP2Ajax.setHandler=function(b){this.responseHandler=b};PHP2Ajax.createXMLHttp=function(){try{httpRequest=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{httpRequest=new ActiveXObject("Microsoft.XMLHTTP")}catch(a){httpRequest=null}}if(!httpRequest&&typeof XMLHttpRequest!=undefined)httpRequest=new XMLHttpRequest;return httpRequest};
PHP2Ajax.ParametersPair=function(b,a){this.name=b;this.value=a};PHP2Ajax.toStringSimple=function(b,a){var c=b!=null?b:this,e=a!=null?a+"    ":"    ";result="{\n";for(var d in c)if(typeof c[d]=="string")result+=e+'"'+d+'": "'+c[d]+'",\n';else if(typeof c[d]!="function"&&typeof c[d]=="object")result+=e+'"'+d+'":\n'+e+this.toStringSimple(c[d],e)+",\n";result=new String(result);result=result.substr(0,result.length-2)+"\n";result+=(a!=null?a:"")+"}";return result};
PHP2Ajax.trace=function(b){var a=document.getElementById("mainTraceDiv");if(a==null){document.body.insertAdjacentHTML("beforeEnd",'<center><div id="mainTraceDiv" style="width: 800px; background-color: #fff; text-align: left;"></div></center>');a=document.getElementById("mainTraceDiv")}if(b)a.innerHTML="<pre>"+PHP2Ajax.toStringSimple(this)+"</pre>";else a.innerHTML+="<pre>"+PHP2Ajax.toStringSimple(this)+"</pre>"};
PHP2Ajax.XMLRequest=function(b,a){this.id=a;this.httpRequest=null;this.parameters=[];this.parametersCount=0;this.responseXML=this.responseHandler=null;this.server=b;this.setRequestMethod(PHP2Ajax.REQUEST_METHOD_POST)};
PHP2Ajax.XMLRequest.prototype.onReadyStateChange=function(){if(this.httpRequest.readyState==PHP2Ajax.READY_STATE_COMPLETE){if(this.httpRequest.status==PHP2Ajax.HTTP_STATUS_OK)if(typeof this.httpRequest.responseXML.documentElement!=undefined)this.responseXML=this.httpRequest.responseXML.documentElement;else{XMLDocument=new ActiveXObject("Microsoft.XMLDOM");XMLDocument.loadXML(this.httpRequest.responseText);this.responseXML=XMLDocument.documentElement}else{alert("The server respond with a bad status code: "+
this.httpRequest.status);return false}typeof this.responseHandler=="function"&&this.responseHandler();return this.responseXML}};PHP2Ajax.XMLRequest.prototype.getXML=function(){};
PHP2Ajax.XMLRequest.prototype.getNodes=function(b,a){var c=this.responseXML.getElementsByTagName(b),e=new PHP2Ajax.RResultArray;for(i=0;i<c.length;i++){var d=new PHP2Ajax.RResultObject;for(j=0;j<c[i].attributes.length;j++)d[c[i].attributes[j].name]=c[i].attributes[j].value;d.text=c[i].firstChild!=null&&c[i].firstChild.data!=null?c[i].firstChild.data:null;typeof a!=undefined&&(idAttributeValue=c[i].getAttribute(a))?e.add(idAttributeValue,d):e.add(i,d)}return e};
PHP2Ajax.XMLRequest.prototype.getUNodeText=function(b,a){nodesArray=a?a:this.responseXML.getElementsByTagName(b);return nodesArray!=null&&nodesArray[0]!=null&&nodesArray[0].firstChild!=null&&nodesArray[0].firstChild.data!=null?nodesArray[0].firstChild.data:null};PHP2Ajax.XMLRequest.prototype.add=PHP2Ajax.add;PHP2Ajax.XMLRequest.prototype.call=PHP2Ajax.call;PHP2Ajax.XMLRequest.prototype.clear=PHP2Ajax.clearRequest;PHP2Ajax.XMLRequest.prototype.trace=PHP2Ajax.trace;
PHP2Ajax.XMLRequest.prototype.createXMLHttp=PHP2Ajax.createXMLHttp;PHP2Ajax.XMLRequest.prototype.setRequestMethod=PHP2Ajax.setRequestMethod;PHP2Ajax.XMLRequest.prototype.setHandler=PHP2Ajax.setHandler;PHP2Ajax.XMLRequest.prototype.execute=PHP2Ajax.execute;PHP2Ajax.JSONRequest=function(b,a){this.id=a;this.httpRequest=null;this.parameters=[];this.parametersCount=0;this.response=this.responseHandler=null;this.reportAJAXErrors=true;this.server=b;this.setRequestMethod(PHP2Ajax.REQUEST_METHOD_POST)};
PHP2Ajax.JSONRequest.prototype.onReadyStateChange=function(){if(this.httpRequest.readyState==PHP2Ajax.READY_STATE_COMPLETE){if(this.httpRequest.status==PHP2Ajax.HTTP_STATUS_OK){try{this.response=eval("("+this.httpRequest.responseText+")")}catch(b){var a=new String(this.httpRequest.responseText);this.response={};this.response.Error=Object({Code:1501,Message:""});this.response.Error.Message="Server returns Invalid Request! Please contact to the System Administrator. \n <br /> <br /> ";this.response.Error.Message+=
'Response trace: <div style="padding: 7px 3px; font-weight: normal;">'+a.substr(0,2047)+(a.length>2048?" ...":"")+"</div>"}if(this.response.Error.Code>0){typeof this.onResponseError=="function"&&this.onResponseError();return false}this.response.toStringSimple=PHP2Ajax.toStringSimple;this.response.trace=PHP2Ajax.trace}else{typeof this.onHTTPError=="function"&&this.onHTTPError();return false}typeof this.responseHandler=="function"&&this.responseHandler();return this.response}};
PHP2Ajax.JSONRequest.prototype.onResponseError=function(){this.alert=new PHP2Controls.Alert("Error: "+this.response.Error.Code+". "+this.response.Error.Message)};PHP2Ajax.JSONRequest.prototype.prepareJSONData=function(b){for(var a in b)if(typeof b[a]=="string"){b[a]=String(b[a]).replace(/\{\{rn\}\}/g,"\r\n");b[a]=String(b[a]).replace(/\{\{n\}\}/g,"\n")}else if(typeof b[a]!="function"&&typeof b[a]=="object")b[a]=this.prepareJSONData(b[a]);return b};PHP2Ajax.JSONRequest.prototype.getResponse=function(){return this.response};
PHP2Ajax.JSONRequest.prototype.setPageCallBackHandler=function(b){this.add(PHP2Ajax.CALLBACK_HANDLER_PARAMETER,b)};PHP2Ajax.JSONRequest.prototype.add=PHP2Ajax.add;PHP2Ajax.JSONRequest.prototype.call=PHP2Ajax.call;PHP2Ajax.JSONRequest.prototype.clear=PHP2Ajax.clearRequest;PHP2Ajax.JSONRequest.prototype.trace=PHP2Ajax.trace;PHP2Ajax.JSONRequest.prototype.createXMLHttp=PHP2Ajax.createXMLHttp;PHP2Ajax.JSONRequest.prototype.setRequestMethod=PHP2Ajax.setRequestMethod;
PHP2Ajax.JSONRequest.prototype.setHandler=PHP2Ajax.setHandler;PHP2Ajax.JSONRequest.prototype.execute=PHP2Ajax.execute;PHP2Ajax.RResultArray=function(){this.data=[]};PHP2Ajax.RResultArray.prototype.add=function(b,a){this.data[b]=a};PHP2Ajax.RResultArray.prototype.getData=function(){return this.data};PHP2Ajax.RResultArray.prototype.toStringSimple=PHP2Ajax.toStringSimple;PHP2Ajax.RResultObject=function(){};PHP2Ajax.RResultObject.prototype.toStringSimple=PHP2Ajax.toStringSimple;
