var a;try{var testCommons=new MQObject;testCommons=null}catch(error){throw"You must include mqcommon.js or toolkit api script prior to mqexec.js.";}
function MQExec(b,e,d,c,f,g){var i,j,k,l,m,n,o="";if(typeof b=="string"){i=b||"localhost";j=e||"mq";k=d||80;l=f||"";m=c||"";n=g||0;b=0}else if(b.getClassName()&&b.getClassName()=="MQExec"){i=b.getServerName();j=b.getServerPath();k=b.getServerPort();m=b.getProxyServerName();n=b.getProxyServerPort();l=b.getProxyServerPath();b=b.m_lSocketTimeout}this.setServerName=function(h){i=h};this.getServerName=function(){return i};this.setServerPath=function(h){j=h};this.getServerPath=function(){return j};this.setServerPort=
function(h){k=h};this.getServerPort=function(){return k};this.setProxyServerName=function(h){m=h};this.getProxyServerName=function(){return m};this.setProxyServerPath=function(h){l=h};this.getProxyServerPath=function(){return l};this.setProxyServerPort=function(h){n=h};this.getProxyServerPort=function(){return n};this.setTransactionInfo=function(h){o=h.length>32?h.substring(0,32):h};this.getTransactionInfo=function(){return o}}a=MQExec.prototype;a.ROUTE_VERSION="2";a.SEARCH_VERSION="0";
a.GEOCODE_VERSION="1";a.ROUTEMATRIX_VERSION="0";a.GETRECORDINFO_VERSION="0";a.REVERSEGEOCODE_VERSION="0";a.GETSESSION_VERSION="1";a.getRequestXml=function(b,e,d){var c=[];d=d||"0";c.push('<?xml version="1.0" encoding="ISO-8859-1"?>\n');c.push("<"+b+' Version="'+d+'">\n');for(d=0;d<e.length;d++){c.push(e[d].saveXml());c.push("\n")}c.push("</"+b+">");return c.join("")};
a.doTransaction=function(b,e,d){var c;c=mqXMLHttpRequest();var f="";e.push(new MQAuthentication(this.getTransactionInfo()));b=this.getRequestXml(b,e,d);if(this.getProxyServerName()!=""){f+="http://"+this.getProxyServerName();if(this.getProxyServerPort()!=0)f+=":"+this.getProxyServerPort();f+="/"}f+=this.getProxyServerPath();f+="?sname="+this.getServerName();f+="&spath="+this.getServerPath();f+="&sport="+this.getServerPort();display("mqXmlLogs","Request URL: ",f,"rURL","mqDisplay");display("mqXmlLogs",
"Request XML: ",b,"","mqDisplay");c.open("POST",f,false);c.send(b);if(c.status==200)c=c.responseXML;else{alert("HTTP Status: "+c.status+" ("+c.statusText+")\nDetails: \n"+c.responseText);c=null}display("mqXmlLogs","Response XML: ",mqXmlToStr(c),"resXML","mqDisplay");return c};
a.geocode=function(b,e,d){var c=[];if(b==null||b.getClassName()!=="MQAddress"&&b.getClassName()!=="MQSingleLineAddress")throw"Null or Illegal Argument passed for MQAddress";else c.push(b);if(e==null||e.getClassName()!=="MQLocationCollection")throw"Null or Illegal Argument passed for MQLocationCollection";if(d!=null)if(d.getClassName()!=="MQAutoGeocodeCovSwitch"&&d.getClassName()!=="MQGeocodeOptionsCollection")throw"Illegal Argument passed for Geocode Options";else c.push(d);mqLogTime("MQExec.geocode: Transaction Start");
b=this.doTransaction("Geocode",c,this.GEOCODE_VERSION);mqLogTime("MQExec.geocode: Transaction End");mqLogTime("MQExec.geocode: Loading of GeocodeResponse Start");d=mqXmlToStr(mqGetNode(b,"/GeocodeResponse/LocationCollection"));e.loadXml(d);mqLogTime("MQExec.geocode: Loading of GeocodeResponse End");display("results","Response",mqXmlToStr(b),"","mqDisplay")};
a.batchGeocode=function(b,e,d){var c=[];if(b==null||b.getClassName()!=="MQLocationCollection")throw"Null or Illegal Argument passed for MQLocationCollection";else c.push(b);if(e==null||e.getClassName()!=="MQLocationCollectionCollection")throw"Null or Illegal Argument passed for MQLocationCollectionCollection";if(d!=null)if(d.getClassName()!=="MQAutoGeocodeCovSwitch"&&d.getClassName()!=="MQGeocodeOptionsCollection")throw"Illegal Argument passed for Geocode Options";else c.push(d);mqLogTime("MQExec.batchGeocode: Transaction Start");
b=this.doTransaction("BatchGeocode",c,this.GEOCODE_VERSION);mqLogTime("MQExec.batchGeocode: Transaction End");mqLogTime("MQExec.batchGeocode: Loading of GeocodeResponse Start");d=mqXmlToStr(mqGetNode(b,"/BatchGeocodeResponse/LocationCollectionCollection"));e.loadXml(d);mqLogTime("MQExec.batchGeocode: Loading of GeocodeResponse End");display("results","Response",mqXmlToStr(b),"","mqDisplay")};
a.doRoute=function(b,e,d,c,f){var g;g=[];if(b==null||b.getClassName()!=="MQLocationCollection")throw"Null or Illegal Argument passed for MQLocationCollection";else g.push(b);if(e==null||e.getClassName()!=="MQRouteOptions")throw"Null or Illegal Argument passed for MQRouteOptions";else g.push(e);if(d==null||d.getClassName()!=="MQRouteResults")throw"Null or Illegal Argument passed for MQRouteResults";else{b=c||"";g.push(new MQXmlNodeObject("SessionID",b))}mqLogTime("MQExec.doRoute: Transaction Start");
g=this.doTransaction("DoRoute",g,this.ROUTE_VERSION);mqLogTime("MQExec.doRoute: Transaction End");mqLogTime("MQExec.doRoute: Loading of RouteResults Start");e=mqXmlToStr(mqGetNode(g,"/DoRouteResponse/RouteResults"));d.loadXml(e);mqLogTime("MQExec.doRoute: Loading of RouteResults End");display("results","Response",mqXmlToStr(g),"","mqDisplay");f!==null&&b!==""&&this.getRouteBoundingBoxFromSessionResponse(b,f)};
a.createSessionEx=function(b){var e=[];if(b==null||b.getClassName()!=="MQSession")throw"Null or Illegal Argument passed for MQSession";else e.push(b);b=this.doTransaction("CreateSession",e);return b=mqGetNodeText(mqGetNode(b,"/CreateSessionResponse/SessionID"))};
a.getSession=function(b,e){b=b||"";var d=[];d.push(new MQXmlNodeObject("SessionID",b));b=this.doTransaction("GetSession",d,this.GETSESSION_VERSION);if(e.getClassName()==="MQMapState"){b=mqXmlToStr(mqGetNode(b,"/GetSessionResponse/Session/MapState"));e.loadXml(b)}else if(e.getClassName()==="MQSession"){b=mqXmlToStr(mqGetNode(b,"/GetSessionResponse/Session"));e.loadXml(b)}};
a.doRouteMatrix=function(b,e,d,c){var f;f=[];if(b==null||b.getClassName()!=="MQLocationCollection")throw"Null or Illegal Argument passed for MQLocationCollection";else f.push(b);if(e==null||typeof e!="boolean")throw"Null or Illegal Argument passed for bAllToAll";else{b=e?1:0;f.push(new MQXmlNodeObject("AllToAll",b))}if(d==null||d.getClassName()!=="MQRouteOptions")throw"Null or Illegal Argument passed for MQRouteOptions";else f.push(d);if(c==null||c.getClassName()!=="MQRouteMatrixResults")throw"Null or Illegal Argument passed for MQRouteMatrixResults";
mqLogTime("MQExec.doRoute: Transaction Start");d=this.doTransaction("DoRouteMatrix",f,this.ROUTEMATRIX_VERSION);mqLogTime("MQExec.doRoute: Transaction End");mqLogTime("MQExec.doRoute: Loading of RouteResults Start");f=mqXmlToStr(mqGetNode(d,"/DoRouteMatrixResponse/RouteMatrixResults"));c.loadXml(f);mqLogTime("MQExec.doRoute: Loading of RouteResults End");display("results","Response",mqXmlToStr(d),"","mqDisplay")};
a.getRecordInfo=function(b,e,d,c){var f;f=[];if(b==null||b.getClassName()!=="MQStringCollection")throw"Null or Illegal Argument passed for MQStringCollection";else{var g=new MQStringCollection;g.setM_Xpath("Fields");g.append(b);f.push(g)}if(e==null||e.getClassName()!=="MQDBLayerQuery")throw"Null or Illegal Argument passed for MQDBLayerQuery";else f.push(e);if(d==null||d.getClassName()!=="MQRecordSet")throw"Null or Illegal Argument passed for MQRecordSet";if(c==null||c.getClassName()!=="MQStringCollection")throw"Null or Illegal Argument passed for MQStringCollection";
else{b=new MQStringCollection;b.setM_Xpath("RecordIds");b.append(c);f.push(b)}mqLogTime("MQExec.getRecordInfo: Transaction Start");c=this.doTransaction("GetRecordInfo",f,this.GETRECORDINFO_VERSION);mqLogTime("MQExec.getRecordInfo: Transaction End");mqLogTime("MQExec.getRecordInfo: Loading of RecordSet Start");f=mqXmlToStr(mqGetNode(c,"/GetRecordInfoResponse/RecordSet"));d.loadXml(f);mqLogTime("MQExec.getRecordInfo: Loading of RecordSet End");display("results","Response",mqXmlToStr(c),"","mqDisplay")};
a.reverseGeocode=function(b,e,d,c){var f;f=[];if(b==null||b.getClassName()!=="MQLatLng")throw"Null or Illegal Argument passed for MQLatLng";else f.push(b);if(e==null||e.getClassName()!=="MQLocationCollection")throw"Null or Illegal Argument passed for MQLocationCollection";b=d||"";f.push(new MQXmlNodeObject("MapPool",b));c=c||"";f.push(new MQXmlNodeObject("GeocodePool",c));mqLogTime("MQExec.reverseGeocode: Transaction Start");f=this.doTransaction("ReverseGeocode",f,this.REVERSEGEOCODE_VERSION);mqLogTime("MQExec.reverseGeocode: Transaction End");
mqLogTime("MQExec.reverseGeocode: Loading of Response Start");c=mqXmlToStr(mqGetNode(f,"/ReverseGeocodeResponse/LocationCollection"));e.loadXml(c);mqLogTime("MQExec.reverseGeocode: Loading of Response End");display("results","Response",mqXmlToStr(f),"","mqDisplay")};
a.search=function(b,e,d,c,f,g){var i=[],j=b?b.getClassName():null;if(j==null||j!=="MQSearchCriteria"&&j!=="MQRadiusSearchCriteria"&&j!=="MQRectSearchCriteria"&&j!=="MQPolySearchCriteria"&&j!=="MQCorridorSearchCriteria")throw"Null or Illegal Argument passed for Search Criteria";else i.push(b);if(e==null||e.getClassName()!=="MQFeatureCollection")throw"Null or Illegal Argument passed for MQFeatureCollection";if(typeof d!=="string")throw"Illegal Argument passed for strCoverageName";else i.push(new MQXmlNodeObject("CoverageName",
d));if(c!=null&&c.getClassName()!=="MQDBLayerQueryCollection")throw"Illegal Argument passed for MQRouteOptions";else if(c==null)c=new MQDBLayerQueryCollection;i.push(c);if(f!=null&&f.getClassName()!=="MQFeatureCollection")throw"Illegal Argument passed for MQFeatureCollection";else if(f==null)f=new MQFeatureCollection;i.push(f);if(g!=null&&g.getClassName()!=="MQDTCollection")throw"Illegal Argument passed for MQDTCollection";else if(g==null)g=new MQDTCollection;i.push(g);mqLogTime("MQExec.Search: Transaction Start");
b=this.doTransaction("Search",i,this.SEARCH_VERSION);mqLogTime("MQExec.Search: Transaction End");mqLogTime("MQExec.Search: Loading of Search results Start");d=mqXmlToStr(mqGetNode(b,"/SearchResponse/FeatureCollection"));e.loadXml(d);mqLogTime("MQExec.Search: Loading of Search results End");display("results","Response",mqXmlToStr(b),"","mqDisplay")};
a.getRouteBoundingBoxFromSessionResponse=function(b,e){var d=[];if(e==null)throw"Null or Illegal Argument passed for MQRectLL";d.push(new MQXmlNodeObject("SessionID",b));b=this.doTransaction("GetRouteBoundingBoxFromSession",d);mqLogTime("MQExec.doRoute: Loading of MQRectLL Start");b=b.documentElement.childNodes;d=new MQLatLng;d.loadXml(mqXmlToStr(b[0]));var c=new MQLatLng;c.loadXml(mqXmlToStr(b[1]));e.setUpperLeft(d);e.setLowerRight(c);mqLogTime("MQExec.doRoute: Loading of MQRectLL End")};
a.isAlive=function(){if(this.getServerPort()==-1||this.getServerName()=="")return false;return true};a.getServerInfo=function(b){if(!this.isAlive())return null;b=b||0;var e=[];if(typeof b!=="number")throw"Illegal Argument passed for lType";else e.push(new MQXmlNodeObject("Type",b));mqLogTime("MQExec.GetServerInfo: Transaction Start");b=this.doTransaction("GetServerInfo",e);mqLogTime("MQExec.GetServerInfo: Transaction End");display("results","Response",mqXmlToStr(b),"","mqDisplay");return b};