var pbcheckBrowserScript=true,pbshowAlertMsgs=true,pbshowStartUpIcon=true,pbCoreLibReady=false,pbXMLLibReady=false,pbXSLLibReady=false,pbJSONLibReady=false,pbChartLibReady=false,pbMyLibReady=false,pbstateComplete=4,pbstatusOk=200,pbstatusNotFound=404,pbCoreLibHeader="[AjaMyAjax Core Lib]",AjaMyAjax=function(){this.processResponse=function(a,c,b,g,d,i,h,k){c=c?c:null;b=b?b:null;g=g?g:null;d=d?d:null;i=i?i:null;h=h?h:null;k=k?k:null;if(!(!a||a.readyState<pbstateComplete))try{if(a.readyState==pbstateComplete)if(a.status==
pbstatusOk)if(b&&g){if(h)if(!isNaN(h)){var l=false,n=0,p="";if(g.substr(0,1)==="X"){var j=a.responseXML.getElementsByTagName("*").item(0);p=aja_getXmlNodeText(j)}else p=a.responseText;n=aja_sumAlphaNumChars(p);if(n==h)l=true;if(!l){if(k){if(aja_encodeNum(n,k)==h)l=true}else if(aja_encodeNum(n)==h)l=true;if(!l){a.abort();aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Security check failed for "+c);if(a)a=null;return}}}switch(g){case "XML":if(pbXMLLibReady)if(d==="CHART")if(pbChartLibReady)processChart(a.responseXML,
b,d,i,"XML");else{a.abort();aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Error in Chart Lib load")}else processXML(a.responseXML,c,b,d,i);else{a.abort();aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Error in XML Lib load")}break;case "XSL":if(pbXSLLibReady)processXSL(a.responseXML,c,b,d);else{a.abort();aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Error in XSL Lib load")}break;case "JSON":if(pbJSONLibReady)if(d==="CHART")if(pbChartLibReady)processChart(a.responseText,
b,d,i,"JSON");else{a.abort();aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Error in Chart Lib load")}else processJSON(a.responseText,b,i,d);else{a.abort();aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Error in JSON Lib load")}break;case "MYLIB":if(pbMyLibReady)processMyFunctions(a.responseXML,a.responseText,c,b,d,i,h,k);else{a.abort();aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Error in Custom Lib load")}break;default:aja_fill(b,a.responseText)}}else{a.abort();
aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Data destination or output unspecified for "+c)}else if(a.status==pbstatusNotFound){a.abort();aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,c+" not found for data request")}else{a.abort();aja_empty(b);if(pbshowAlertMsgs)g==="PHP"?aja_alertMsg(pbCoreLibHeader,"No data found for this selection"):aja_alertMsg(pbCoreLibHeader,"Sorry, cannot retrieve data requested for "+c)}}catch(r){a.abort();b&&aja_empty(b);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,
"Sorry, an unexpected error occurred during processing of "+c);r.description&&pbshowAlertMsgs&&aja_alertMsg("Gen Error",r.description)}};aja_fill=function(a,c){if(c)if(a!=="none")document.getElementById(a).innerHTML=c};aja_empty=function(a){if(a!=="none")document.getElementById(a).innerHTML=""};aja_cloak=function(a){if(a)document.getElementById(a).style.visibility="hidden"};aja_reveal=function(a){if(a)document.getElementById(a).style.visibility="visible"};aja_alertMsg=function(a,c){alert((a?a:"Unknown Error")+
"\r\n"+(c?c:"program id #501"))};aja_sumAlphaNumChars=function(a){for(var c=/[a-zA-Z0-9]/,b=0,g=a.length,d=0;d<g;d++)if(c.test(a.charAt(d)))b+=a.charCodeAt(d);return b};aja_encodeNum=function(a,c){if(a){if(isNaN(a))return-1;if(c){if(isNaN(c))return-1;a=Math.round(a*c)}else a=Math.round(a*Math.PI)}return a};aja_getXmlNodeText=function(a){try{return a.textContent?a.textContent:a.text}catch(c){return null}};this.ajaxRequest=function(a,c,b,g,d,i,h,k,l,n,p){if(pbcheckBrowserScript){if(!document.getElementById){pbshowAlertMsgs&&
aja_alertMsg(pbCoreLibHeader,"JavaScript error, browser upgrade or fix needed to run this");return}try{var j=[];j.push("*");j=null}catch(r){pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"JavaScript error, browser upgrade probably needed");r.description&&pbshowAlertMsgs&&aja_alertMsg("Gen Error",r.description);return}}j=true;var f=a?a:null;a=c?c:null;var o=b?b:null,m=g?g:null,q=d?d:null,s=i?i:null,t=h?h:null,u=k?k:null;pbshowAlertMsgs=l!=null?l:pbshowAlertMsgs;pbshowStartUpIcon=n!=null?n:pbshowStartUpIcon;
j=p!=null?p:j;if(!f||!o)pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Required parameters are missing");else{if(m)m=m.toUpperCase();if(q)q=q.toUpperCase();if(f)f=f.toLowerCase();if(a)f+=a;try{pbshowStartUpIcon?aja_fill(o,"*"):aja_empty(o)}catch(v){pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Invalid container, check parameter list for "+f);v.description&&pbshowAlertMsgs&&aja_alertMsg("Gen Error",v.description);return}if(f.indexOf(".xml")!=-1&&m==="XSL")if(navigator.userAgent.indexOf("Chrome")!=
-1||navigator.userAgent.indexOf("Safari")!=-1){f="phpxsl.php?url="+f.replace(".xml",".xsl");m="PHP"}pbCoreLibReady=true;var e=null;if(window.XMLHttpRequest)e=new XMLHttpRequest;else if(window.ActiveXObject){j=false;(e=new ActiveXObject("Msxml2.XMLHTTP"))||(e=new ActiveXObject("Microsoft.XMLHTTP"))}if(e){e.open("GET",f,j);if(window.XMLHttpRequest){e.source=this;e.onreadystatechange=function(){e.source.processResponse(e,f,o,m,q,s,t,u)}}else e.onreadystatechange=function(){AjaMyAjax.apply(this);this.processResponse(e,
f,o,m,q,s,t,u)};e&&e.send(null);!j&&navigator.userAgent.indexOf("Firefox")!=-1&&this.processResponse(e,f,o,m,q,s,t,u)}else{aja_empty(o);pbshowAlertMsgs&&aja_alertMsg(pbCoreLibHeader,"Sorry, browser does not support XMLHttpRequest")}}}};
