if(typeof d4m_ajax_engine_included=='undefined'){function d4m_ajax_engine(){var settings=new Array();settings['menthod']='GET';settings['response_type']='XML';settings['response_node']='ajaxResponse';settings['response_update']='innerHTML';settings['loading_status']=false;settings['loading_text']='Loading...';settings['persistent']=false;settings['async']=true;settings['call_outside']=false;settings['debug']=false;this.setMenthod=function(menthod){if(menthod.toUpperCase()=='GET'||menthod.toUpperCase()=='POST')settings['menthod']=menthod.toUpperCase();} this.setResponseType=function(responseType){if(responseType.toUpperCase()=='XML'||responseType.toUpperCase()=='TEXT')settings['response_type']=responseType.toUpperCase();} this.setResponseNode=function(responseNode){settings['response_node']=responseNode;} this.setResponseUpdate=function(responseUpdate){if(responseUpdate=='innerHTML'||responseUpdate=='function')settings['response_update']=responseUpdate;} this.setLoadingStatus=function(show){if(typeof show=='boolean')settings['loading_status']=show;} this.setLoadingText=function(txt){settings['loading_text']=txt;} this.setPersistent=function(persistent){if(typeof persistent=='boolean')settings['persistent']=persistent;} this.setAsync=function(async){if(typeof async=='boolean')settings['async']=async;} this.setCallOutside=function(set){if(typeof set=='boolean')settings['call_outside']=set;} this.setDebug=function(set){if(typeof set=='boolean')settings['debug']=set;} this.sendRequest=function(){if(settings['loading_status']&&typeof swapLoading=='function')swapLoading(settings['loading_text'],true);if(settings['debug'])alert('d4m_ajax_engine.sendRequest: Preparing to send request...');var this_stack_index=-1;if(settings['persistent']==true&&typeof __ajax_engine_stack[0]=='object'){switch(__ajax_engine_stack[0].getState()){case-1:this_stack_index=0;if(settings['debug'])alert('d4m_ajax_engine.sendRequest: No any persistent connection created');break;case 4:this_stack_index=0;if(settings['debug'])alert('d4m_ajax_engine.sendRequest: Persistent connection created and ready to use');break;default:if(settings['debug'])alert('d4m_ajax_engine.sendRequest: Persistent connection currently in use, skip this request');}}else if(settings['persistent']==true){this_stack_index=0;__ajax_engine_stack[this_stack_index]=new d4m_ajax_call(this_stack_index);if(settings['debug'])alert('d4m_ajax_engine.sendRequest: No "d4m_ajax_call" object available for re-use, created new one');}else{this_stack_index=__stack_index;__ajax_engine_stack[this_stack_index]=new d4m_ajax_call(this_stack_index);if(settings['debug'])alert('d4m_ajax_engine.sendRequest: Created new "d4m_ajax_call" object');} if(this_stack_index>-1){__ajax_engine_stack[this_stack_index].setMenthod(settings['menthod']);__ajax_engine_stack[this_stack_index].setResponseType(settings['response_type']);__ajax_engine_stack[this_stack_index].setResponseNode(settings['response_node']);__ajax_engine_stack[this_stack_index].setResponseUpdate(settings['response_update']);__ajax_engine_stack[this_stack_index].setLoadingStatus(settings['loading_status']);__ajax_engine_stack[this_stack_index].setLoadingText(settings['loading_text']);__ajax_engine_stack[this_stack_index].setPersistent(settings['persistent']);__ajax_engine_stack[this_stack_index].setAsync(settings['async']);__ajax_engine_stack[this_stack_index].setCallOutside(settings['call_outside']);__ajax_engine_stack[this_stack_index].setDebug(settings['debug']);__ajax_engine_stack[this_stack_index].sendRequest(arguments);__stack_index++;if(settings['debug'])alert('d4m_ajax_engine.sendRequest: Current stack index = '+__stack_index);}}} var __stack_index=0;var __ajax_engine_stack=new Array();function d4m_ajax_call(){var settings=new Array();settings['menthod']='GET';settings['response_type']='XML';settings['response_node']='ajaxResponse';settings['response_update']='innerHTML';settings['loading_status']=false;settings['loading_text']='Loading...';settings['persistent']=false;settings['async']=true;settings['call_outside']=false;settings['debug']=false;var __stack_index=arguments[0];var http=false;var responseHandler='';this.setMenthod=function(menthod){if(menthod.toUpperCase()=='GET'||menthod.toUpperCase()=='POST')settings['menthod']=menthod.toUpperCase();} this.setResponseType=function(responseType){if(responseType.toUpperCase()=='XML'||responseType.toUpperCase()=='TEXT')settings['response_type']=responseType.toUpperCase();} this.setResponseNode=function(responseNode){settings['response_node']=responseNode;} this.setResponseUpdate=function(responseUpdate){if(responseUpdate=='innerHTML'||responseUpdate=='function')settings['response_update']=responseUpdate;} this.setLoadingStatus=function(show){if(typeof show=='boolean')settings['loading_status']=show;} this.setLoadingText=function(txt){settings['loading_text']=txt;} this.setPersistent=function(persistent){if(typeof persistent=='boolean')settings['persistent']=persistent;} this.setAsync=function(async){if(typeof async=='boolean')settings['async']=async;} this.setCallOutside=function(set){if(typeof set=='boolean')settings['call_outside']=set;} this.setDebug=function(set){if(typeof set=='boolean')settings['debug']=set;} this.getState=function(){var return_value=-1;if(typeof http=='object'){return_value=http.readyState;} return return_value;} function createRequestObject(){var new_connection=false;if(settings['persistent']==false){if(settings['debug'])alert('d4m_ajax_call.createRequestObject: Using new connection object...');new_connection=true;}else{if(settings['debug'])alert('Using shared connection object.',1);if(typeof http!='object'){if(settings['debug'])alert('d4m_ajax_call.createRequestObject: Getting new persistent connection object...');new_connection=true;}} if(new_connection==true){try{http=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{http=new ActiveXObject('Microsoft.XMLHTTP');}catch(oc){http=null;}} if(!http&&typeof XMLHttpRequest!='undefined'){http=new XMLHttpRequest();} if(!http){if(settings['debug'])alert('d4m_ajax_call.createRequestObject: Could not create XML HTTP request object.');http=false;}} if(http.readyState!=4){http.abort();}} this.sendRequest=function(passed_arguments){backendURL=passed_arguments[0];responseHandle=passed_arguments[1];var query_string='';if(passed_arguments.length>2){for(var i=2;i2){for(var k=2;k-1)backendURL+='&'+query_string;else backendURL+='?'+query_string;if(settings['debug'])alert('d4m_ajax_call.sendRequest: Updated URL: '+backendURL);} createRequestObject();http.open(settings['menthod'],backendURL,settings['async']);if(settings['menthod']=='POST'){try{http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}catch(error){if(settings['debug'])alert('d4m_ajax_call.sendRequest: POST cannot be completed due to incompatible browser. Use GET as your request method.');}} if(settings['debug'])alert('d4m_ajax_call.sendRequest: Update response handler to: '+responseHandle);responseHandler=responseHandle;http.onreadystatechange=handleResponse;if(settings['menthod']=='GET'){http.send(null);}else{http.send(query_string);} if(settings['async']==false)handleResponse();if(settings['debug'])alert('d4m_ajax_call.sendRequest: Request sending completed.');} function handleResponse(){if(http.readyState==4){if(settings['debug'])alert('d4m_ajax_call.handleResponse: Processing response...');var response=(settings['response_type']=='XML')?http.responseXML:http.responseText;if(settings['debug'])alert('d4m_ajax_call.handleResponse: Response data: '+http.responseText);if(settings['response_update']=='innerHTML'){if(settings['debug'])alert('d4m_ajax_call.handleResponse: Update type is: innerHTML.');if(typeof responseHandler!='object'&&!document.getElementById(responseHandler)){if(settings['debug'])alert('d4m_ajax_call.handleResponse: Cannot update innerHTML for "'+responseHandler+'".');}else{responseHandler=typeof responseHandler=='object'?responseHandler:document.getElementById(responseHandler);if(settings['response_type']=='XML')responseHandler.innerHTML=response.getElementsByTagName(settings['response_node']).item(0).firstChild.data;else responseHandler.innerHTML=response;if(settings['debug'])alert('d4m_ajax_call.handleResponse: Updated innerHTML of destination element to: '+responseHandler.innerHTML);}}else{if(settings['debug'])alert('d4m_ajax_call.handleResponse: Update type is: function.');if(typeof responseHandler!='function'){if(settings['debug'])alert('d4m_ajax_call.handleResponse: Cannot call "'+responseHandler+'" to update HTML document cause it is not a function.');}else{responseHandler(response);if(settings['debug'])alert('d4m_ajax_call.handleResponse: Called registered function to handle response.');}} destroyStackEntry();if(settings['loading_status']&&typeof swapLoading=='function')swapLoading(settings['loading_text'],false);}} var destroyStackEntry=function(){if(typeof __stack_index=='number'&&__ajax_engine_stack[__stack_index]&&settings['persistent']==false){__ajax_engine_stack[__stack_index]=null;}}} var d4m_ajax_engine_included=1;}