AjaxAnywhere.defaultInstanceName="default";var pageName="";var calbackMethod="";function AjaxAnywhere(){this.id=AjaxAnywhere.defaultInstanceName;this.formName=null;this.loadingImageDiv=null;if(window.XMLHttpRequest){this.req=new XMLHttpRequest()}else{if(window.ActiveXObject){this.req=new ActiveXObject("Microsoft.XMLHTTP")}}}AjaxAnywhere.prototype.findForm=function(){var a;if(this.formName!=null){a=document.forms[this.formName]}else{if(document.forms.length>0){a=document.forms[0]}}return a};AjaxAnywhere.prototype.bindById=function(){var a="AjaxAnywhere."+this.id;window[a]=this};AjaxAnywhere.findInstance=function(b){var a="AjaxAnywhere."+b;return window[a]};AjaxAnywhere.prototype.submitAJAX=function(e,f){if(typeof e=="undefined"){e=""}if(typeof f=="undefined"){calbackMethod=""}else{calbackMethod=f}this.bindById();var d=this.findForm();var c=d.action;if(c==""){c=location.href}var b=this.getZonesToReaload(c);if(b==null){if(typeof d.submit_old=="undefined"){d.submit()}else{d.submit_old()}return}this.dropPreviousRequest();this.req.open("POST",c,true);this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");var a=this.preparePostData();if(b!=""){a="&aazones="+escape(b)+"&"+a+"&"+e}else{a+="&"+e}this.sendPreparedRequest(a)};AjaxAnywhere.prototype.getAJAX=function(b){this.bindById();var a=this.getZonesToReaload(b);this.dropPreviousRequest();b+=(b.indexOf("?")!=-1)?"&":"?";b+="aa_rand="+Math.random();if(a!=null&&a!=""){b+="&aazones="+escape(a)}this.req.open("GET",b,true);this.sendPreparedRequest("")};AjaxAnywhere.prototype.sendPreparedRequest=function(b){var a=this.id+"_callbackFunction";if(typeof window[a]=="undefined"){window[a]=new Function('AjaxAnywhere.findInstance("'+this.id+'").callback(); ')}this.req.onreadystatechange=window[a];this.showLoadingMessage();this.req.setRequestHeader("aaxmlrequest","true");this.req.send(b)};AjaxAnywhere.prototype.dropPreviousRequest=function(){if(this.req.readyState!=0&&this.req.readyState!=4){this.req.abort();this.handlePrevousRequestAborted()}};AjaxAnywhere.prototype.preparePostData=function(){var e=this.findForm();var a="";for(var c=0;c<e.elements.length;c++){var d=e.elements[c];if(typeof d.type!="undefined"){if(d.tagName.toLowerCase()=="select"){for(var b=0;b<d.options.length;b++){var f=d.options[b];if(f.selected){a+="&"+d.name+"="+escape(f.value)}}}else{if(d.type.toLowerCase()=="checkbox"||d.type.toLowerCase()=="radio"){if(d.checked){a+="&"+d.name+"="+escape(d.value)}}else{if(d.type.toLowerCase()!="submit"&&d.type.toLowerCase()!="button"){a+="&"+d.name+"="+escape(d.value)}}}}}return a};AjaxAnywhere.prototype.callback=function(){if(this.req.readyState==4){this.onBeforeResponseProcessing();this.hideLoadingMessage();if(this.req.status==200){var docs=this.req.responseXML.getElementsByTagName("document");var redirects=this.req.responseXML.getElementsByTagName("redirect");var zones=this.req.responseXML.getElementsByTagName("zone");var exceptions=this.req.responseXML.getElementsByTagName("exception");var scripts=this.req.responseXML.getElementsByTagName("script");flagForPopUp=this.req.responseXML.getElementsByTagName("result");if(redirects.length!=0){var newURL=redirects[0].firstChild.data;location.href=newURL}if(docs.length!=0){var newContent=docs[0].firstChild.data;delete this.req;document.close();document.write(newContent);document.close()}if(zones.length!=0){for(var i=0;i<zones.length;i++){var zoneNode=zones[i];var name=zoneNode.getAttribute("name");var fc=zoneNode.firstChild;if(fc==null){continue}var html=fc.data;var zoneHolder=document.getElementById("aazone."+name);if(typeof(zoneHolder)!="undefined"){zoneHolder.innerHTML=html}}}if(exceptions.length!=0){var e=exceptions[0];var type=e.getAttribute("type");var stackTrace=e.firstChild.data;this.handleException(type,stackTrace)}if(scripts.length!=0){for(var i=0;i<scripts.length;i++){var script=scripts[i].firstChild;if(script!=null){script=script.data;if(script.indexOf("document.write")!=-1){this.handleException("document.write","This script contains document.write(), which is not compatible with AjaxAnywhere : \n\n"+script)}else{eval(script)}}}var globals=this.getGlobalScriptsDeclarationsList(script);if(globals!=null){for(var i in globals){var objName=globals[i];try{window[objName]=eval(objName)}catch(e){}}}}}else{if(this.req.status!=0){this.handleHttpErrorCode(this.req.status)}}this.onAfterResponseProcessing();if(calbackMethod!=""){var fn=window[calbackMethod];if(typeof fn!=="function"){return}fn.apply(window,["nothing"])}}};AjaxAnywhere.prototype.showLoadingMessage=function(){var b=this.findForm();var c=b.name;var a=this.loadingImageDiv;var d=document.getElementById(a);if(d!=null&&d!=""){d.style.display=""}};AjaxAnywhere.prototype.hideLoadingMessage=function(){var a=this.loadingImageDiv;var b=document.getElementById(a);if(b!=null){b.style.display="none"}};AjaxAnywhere.prototype.substituteFormSubmitFunction=function(){this.bindById();var b=this.findForm();b.submit_old=b.submit;var a='var ajax = AjaxAnywhere.findInstance("'+this.id+"\"); if (typeof ajax !='object' || ! ajax.isFormSubmitByAjax() ) ajax.findForm().submit_old(); else ajax.submitAJAX();";b.submit=new Function(a)};AjaxAnywhere.prototype.isFormSubmitByAjax=function(){return true};AjaxAnywhere.prototype.handleException=function(b,a){};AjaxAnywhere.prototype.handleHttpErrorCode=function(a){};AjaxAnywhere.prototype.handlePrevousRequestAborted=function(){};AjaxAnywhere.prototype.getGlobalScriptsDeclarationsList=function(a){return null};AjaxAnywhere.prototype.getZonesToReaload=function(a){return""};AjaxAnywhere.prototype.onRequestSent=function(){};AjaxAnywhere.prototype.onBeforeResponseProcessing=function(){};AjaxAnywhere.prototype.onAfterResponseProcessing=function(){};ajaxAnywhere=new AjaxAnywhere();ajaxAnywhere.bindById();
