var PHP2Ajax=new Object();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(A,B){this.parameters[this.parametersCount]=new PHP2Ajax.ParametersPair(A,B);this.parametersCount++};PHP2Ajax.clearRequest=function(){this.parameters=new Object();this.parametersCount=0};PHP2Ajax.call=function(A){this.add(PHP2Ajax.CALL_REQUEST_PARAMETER,A)};PHP2Ajax.execute=function(){var B=this;try{this.httpRequest=this.createXMLHttp()}catch(E){alert("Error creating the connection to the Server!");return false}try{var C="1";for(var D in this.parameters){var A=new String(this.parameters[D].value);if((A.indexOf("&")!=-1)||(A.indexOf("+")!=-1)){this.parameters[D].value=encodeURIComponent(A)}C=C+"&"+this.parameters[D].name+"="+this.parameters[D].value}if(typeof (B.onReadyStateChange)=="function"){this.httpRequest.onreadystatechange=function(){B.onReadyStateChange()}}if(this.requestMethod==PHP2Ajax.REQUEST_METHOD_GET){this.httpRequest.open(PHP2Ajax.REQUEST_METHOD_GET,this.server+"?"+C,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(C)}}catch(F){alert("An error has occured calling the external site: "+F);return false}};PHP2Ajax.setRequestMethod=function(A){if(A==PHP2Ajax.REQUEST_METHOD_GET){this.requestMethod=PHP2Ajax.REQUEST_METHOD_GET}else{this.requestMethod=PHP2Ajax.REQUEST_METHOD_POST}};PHP2Ajax.setHandler=function(A){this.responseHandler=A};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(A,B){this.name=A;this.value=B};PHP2Ajax.toStringSimple=function(D,E){var C=((D!=null)?D:this);var B=((E!=null)?E+"    ":"    ");result="{\n";for(var A in C){if(typeof (C[A])=="string"){result+=B+'"'+A+'": "'+C[A]+'",\n'}else{if((typeof (C[A])!="function")&&(typeof (C[A])=="object")){result+=B+'"'+A+'":\n'+B+this.toStringSimple(C[A],B)+",\n"}}}result=new String(result);result=result.substr(0,result.length-2)+"\n";result+=((E!=null)?E:"")+"}";return result};PHP2Ajax.trace=function(A){var B=document.getElementById("mainTraceDiv");if(B==null){document.body.insertAdjacentHTML("beforeEnd",'<center><div id="mainTraceDiv" style="width: 800px; background-color: #fff; text-align: left;"></div></center>');B=document.getElementById("mainTraceDiv")}if(A){B.innerHTML="<pre>"+PHP2Ajax.toStringSimple(this)+"</pre>"}else{B.innerHTML+="<pre>"+PHP2Ajax.toStringSimple(this)+"</pre>"}};PHP2Ajax.XMLRequest=function(B,A){this.id=A;this.httpRequest=null;this.parameters=new Array();this.parametersCount=0;this.responseHandler=null;this.responseXML=null;this.server=B;this.setRequestMethod(PHP2Ajax.REQUEST_METHOD_POST)};PHP2Ajax.XMLRequest.prototype.onReadyStateChange=function(){if(this.httpRequest.readyState!=PHP2Ajax.READY_STATE_COMPLETE){return }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}if(typeof (this.responseHandler)=="function"){this.responseHandler()}return this.responseXML};PHP2Ajax.XMLRequest.prototype.getXML=function(){};PHP2Ajax.XMLRequest.prototype.getNodes=function(E,D){var B=this.responseXML.getElementsByTagName(E);var A=new PHP2Ajax.RResultArray();for(i=0;i<B.length;i++){var C=new PHP2Ajax.RResultObject();for(j=0;j<B[i].attributes.length;j++){C[B[i].attributes[j].name]=B[i].attributes[j].value}if((B[i].firstChild!=null)&&(B[i].firstChild.data!=null)){C.text=B[i].firstChild.data}else{C.text=null}if((typeof (D)!=undefined)&&(idAttributeValue=B[i].getAttribute(D))){A.add(idAttributeValue,C)}else{A.add(i,C)}}return A};PHP2Ajax.XMLRequest.prototype.getUNodeText=function(B,A){nodesArray=(A)?A:this.responseXML.getElementsByTagName(B);if((nodesArray!=null)&&(nodesArray[0]!=null)&&(nodesArray[0].firstChild!=null)&&(nodesArray[0].firstChild.data!=null)){return nodesArray[0].firstChild.data}else{return 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=new Array();this.parametersCount=0;this.responseHandler=null;this.response=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){return }if(this.httpRequest.status==PHP2Ajax.HTTP_STATUS_OK){try{this.response=eval("("+this.httpRequest.responseText+")")}catch(eEvalException){var errorEvalData=new String(this.httpRequest.responseText);this.response=new Object();this.response.Error=new 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;">'+errorEvalData.substr(0,4095)+((errorEvalData.length>4096)?" ...":"")+"</div>"}if(this.response.Error.Code>0){if(typeof (this.onResponseError)=="function"){this.onResponseError()}return false}this.response.toStringSimple=PHP2Ajax.toStringSimple;this.response.trace=PHP2Ajax.trace}else{if(typeof (this.onHTTPError)=="function"){this.onHTTPError()}return false}if(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(C){var B=C;for(var A in C){if(typeof (C[A])=="string"){B[A]=String(C[A]).replace(/\{\{rn\}\}/g,"\r\n");B[A]=String(B[A]).replace(/\{\{n\}\}/g,"\n")}else{if((typeof (C[A])!="function")&&(typeof (C[A])=="object")){B[A]=this.prepareJSONData(C[A])}}}return B};PHP2Ajax.JSONRequest.prototype.getResponse=function(){return this.response};PHP2Ajax.JSONRequest.prototype.setPageCallBackHandler=function(A){this.add(PHP2Ajax.CALLBACK_HANDLER_PARAMETER,A)};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=new Array()};PHP2Ajax.RResultArray.prototype.add=function(A,B){this.data[A]=B};PHP2Ajax.RResultArray.prototype.getData=function(){return this.data};PHP2Ajax.RResultArray.prototype.toStringSimple=PHP2Ajax.toStringSimple;PHP2Ajax.RResultObject=function(){};PHP2Ajax.RResultObject.prototype.toStringSimple=PHP2Ajax.toStringSimple;
