var ReadyStateEnum={UNINITIALIZED:0,LOADING:1,LOADED:2,INTERACTIVE:3,COMPLETE:4};var httpStatusToDescMap={100:"OK to continue with request.",101:"Server has switched protocols in upgrade header.",200:"Request complete.",201:"Object created, reason = new URI.",202:"Async completion (TBS).",203:"Partial completion.",204:"No information to return.",205:"Request complete, clear form.",206:"Partial GET fulfilled.",300:"Server could not determinewhat to return.",301:"Object permanently moved.",302:"Object temporarily moved.",303:"Redirection with new access method.",304:"If-modified-since was not modified.",305:"Redirection to proxy, location header specifies proxy to use.",307:"HTTP/1.1: keep same verb.",400:"Invalid syntax.",401:"Access denied.",402:"Payment required.",403:"Request forbidden.",404:"Object not found.",405:"Method is not allowed.",406:"No response acceptable to client found.",407:"Proxy authentication required.",408:"Server timed out waiting for request.",409:"User should resubmit with more information.",410:"The resource is no longer available.",411:"The server refused to accept request without a length.",412:"Precondition given in request failed.",413:"Request entity was too large.",414:"Request URI too long.",415:"Unsupported media type.",449:"Retry after doing the appropriate action.",500:"Internal server error.",501:"Required not supported.",502:"Error response received from gateway.",503:"Temporarily overloaded.",504:"Timed out waiting for gateway.",505:"HTTP version not supported.",12002:"The request has timed out.",12005:"The URL is invalid.",12007:"The server name could not be resolved.",12013:"The request to connect and log on to an FTP server could not be completed because the supplied user name is incorrect.",12014:"The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect.",12015:"The request to connect to and log on to an FTP server failed.",12029:"The attempt to connect to the server failed.",12030:"The connection with the server has been terminated.",12031:"The connection with the server has been reset.",12037:"SSL certificate date that was received from the server is bad. The certificate is expired.",12038:"SSL certificate common name (host name field) is incorrect. For example, if you entered www.server.com and the common name on the certificate says www.different.com.",12039:"The application is moving from a non-SSL to an SSL connection because of a redirect.",12040:"The application is moving from an SSL to a non-SSL connection because of a redirect.",12041:"Indicates that the content is not entirely secure. Some of the content being viewed may have come from unsecured servers.",12150:"The requested header was not found.",12151:"The server does not support the requested protocol level.",12152:"The server returned an invalid or unrecognized response.",12153:"The supplied HTTP header is invalid.",12154:"The request for a HTTP header is invalid.",12155:"The HTTP header already exists.",12201:"A chained proxy server or array member requires proxy-to-proxy authentication.",12202:"The ISA Server denies the specified URL.",12204:"SSL port specified is not allowed.",12206:"The ISA Server detected a proxy chain loop.",12209:"The ISA Server requires authorization to fulfill the request.",12210:"An ISAPI filter has finished handling the request.",12211:"The ISA Server requires a secure channel connection to fulfill the request.",12212:"The ISA Server requires a high-security connection to fulfill the request.",12213:"The ISA Server requires a client certificate to fulfill the request.",12214:"An ISAPI filter has caused an error or terminated with an error.",12221:"A chained server requires authentication.",12227:"The dial-out connection failed.",12228:"The server is too busy to handle this request.",12229:"The server requires authorization to fulfill the request.",12230:"An ISAPI filter has finished handling the request.",12231:"The page must be viewed over a secure channel.",12232:"The page must be viewed with a high-security Web browser.",12233:"The page requires a client certificate.",12234:"An ISAPI filter has caused an error or terminated with an error."};var MAX_TOTAL_OPEN_CALLS=10;var MAX_CALL_QUEUE_SIZE=1000;var DEFAULT_HTTP_RETRIES=3;var DEFAULT_HTTP_TIMEOUT=30000;var DEFAULT_HTTP_ASYNC=true;var DEFAULT_PRIORITY=0;var totalOpenCalls=0;var callQueue=[];var openCallsAtPriority=[];function httpRequestReadyStateChanged(c,e,b){try{var a=c.status;if(c.readyState==ReadyStateEnum.COMPLETE){if(b!=null){clearTimeout(b)}try{switch(a){case 0:case 100:case 101:break;case 200:case 201:case 202:case 203:case 204:case 205:case 206:e.respHandle(c);break;default:if(typeof logger=="object"){logger.warn("An HTTP request resulted in an unexpected HTTP response:\nHTTP Request Status = "+a+"\nHTTP Request Status Text = "+c.statusText+"\nHTTP Request Status Translation = "+httpStatusToDescMap[c.status])}resendHttpRequest(c,e);break}}catch(d){if(typeof logger=="object"){logger.err(d,"http_request.js::httpRequestReadyStateChanged")}abortHttpRequest(c,e)}totalOpenCalls--;openCallsAtPriority[e.priority]--;sendStoredHttpRequest()}}catch(d){}}function comparePriorities(b,a){if(a.priority<=0){return -1}else{if(b.priority<=0){return 1}else{if(b.priority<=a.priority){return -1}else{return 1}}}}function sendHttpRequest(b,c,j,n,e,m,i,o){var h=null;var g;if(typeof e!="boolean"){e=DEFAULT_HTTP_ASYNC}if(typeof n=="undefined"){n=DEFAULT_PRIORITY}if(typeof m!="number"){m=DEFAULT_HTTP_RETRIES}if(typeof i!="number"){i=DEFAULT_HTTP_TIMEOUT}var a=new Object();a.reqType=b;a.url=c;a.respHandle=j;a.priority=n;a.async=e;a.maxRetries=m;a.timeoutMillis=i;a.numOfRetries=o;if((totalOpenCalls>=MAX_TOTAL_OPEN_CALLS)||((typeof maxOpenCallsAtPriority=="object")&&(typeof openCallsAtPriority[n]!="undefined")&&(openCallsAtPriority[n]>=maxOpenCallsAtPriority[n]))){if(callQueue.length==0){callQueue.push(a)}else{if((n<=0)||(n>=callQueue[callQueue.length-1].priority)){callQueue.push(a)}else{if((n==1)||(n<=callQueue[0].priority)){callQueue.unshift(a)}else{callQueue.push(a);callQueue.sort(comparePriorities)}}}if(callQueue.length>MAX_CALL_QUEUE_SIZE){callQueue.pop()}}else{if(typeof a.numOfRetries!="number"){a.numOfRetries=0}do{try{if(window.XMLHttpRequest){h=new XMLHttpRequest()}else{if(window.ActiveXObject){h=new ActiveXObject("Msxml2.XMLHTTP")}else{h=new ActiveXObject("Microsoft.XMLHTTP")}}if(h){if((typeof i=="number")&&(i>0)){g=window.setTimeout(function(p,q){return function(){httpRequestTimedOut(p,q)}}(h,a),i)}else{g=null}h.onreadystatechange=function(q,r,p){return function(){httpRequestReadyStateChanged(q,r,p)}}(h,a,g);if(b.toLowerCase()=="post"){var k;var d;var l=c.indexOf("?");if(l>=0){k=c.substring(0,l);d=c.substring(l+1)}else{k=c;d=""}h.open(b,k,e);h.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");h.send(d)}else{h.open(b,c,e);h.send(null)}totalOpenCalls++;if(typeof openCallsAtPriority[n]=="undefined"){openCallsAtPriority[n]=1}else{openCallsAtPriority[n]++}return true}}catch(f){}a.numOfRetries++}while((a.maxRetries<=0)||(a.numOfRetries<=a.maxRetries));if(!h){alert("Your web browser is not currently allowing the creation of an AJAX HTTP request.\nIt may be necessary to upgrade the browser.");return false}}}function httpRequestTimedOut(a,b){resendHttpRequest(a,b)}function resendHttpRequest(a,b){abortHttpRequest(a,b);b.numOfRetries++;if((b.maxRetries<=0)||(b.numOfRetries<=b.maxRetries)){sendHttpRequest(b.reqType,b.url,b.respHandle,b.priority,b.async,b.maxRetries,b.timeoutMillis,b.numOfRetries)}}function sendStoredHttpRequest(){var c=null;if(typeof maxOpenCallsAtPriority=="object"){for(var b=0;b<callQueue.length;b++){var a=callQueue[b].priority;if((typeof openCallsAtPriority[a]=="undefined")||(openCallsAtPriority[a]<maxOpenCallsAtPriority[a])){c=callQueue.splice(b,1)[0];break}}}else{c=callQueue.shift()}if((typeof c=="object")&&(c!==null)){sendHttpRequest(c.reqType,c.url,c.respHandle,c.priority,c.async,c.maxRetries,c.timeoutMillis,c.numOfRetries)}}function abortHttpRequest(a,c){if(typeof a=="object"){try{a.abort();a=null;totalOpenCalls--;openCallsAtPriority[c.priority]--;sendStoredHttpRequest()}catch(b){}}};
