var ntElement=1,ntAttribute=2,ntText=3,ntCData=4,ntComment=8,ntDocument=9,charCodes=[160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,338,339,352,353,376,402,710,732,
8211,8212,8216,8217,8218,8220,8221,8222,8224,8225,8226,8230,8240,8249,8250,8364,8482],specialChar=["&nbsp;","&iexcl;","&cent;","&pound;","&curren;","&yen;","&brvbar;","&sect;","&uml;","&copy;","&ordf;","&laquo;","&not;","&shy;","&reg;","&macr;","&deg;","&plusmn;","&sup2;","&sup3;","&acute;","&micro;","&para;","&middot;","&cedil;","&sup1;","&ordm;","&raquo;","&frac14;","&frac12;","&frac34;","&iquest;","&Agrave;","&Aacute;","&Acirc;","&Atilde;","&Auml;","&Aring;","&AElig;","&Ccedil;","&Egrave;","&Eacute;",
"&Ecirc;","&Euml;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&ETH;","&Ntilde;","&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&times;","&Oslash;","&Ugrave;","&Uacute;","&Ucirc;","&Uuml;","&Yacute;","&THORN;","&szlig;","&agrave;","&aacute;","&acirc;","&atilde;","&auml;","&aring;","&aelig;","&ccedil;","&egrave;","&eacute;","&ecirc;","&euml;","&igrave;","&iacute;","&icirc;","&iuml;","&eth;","&ntilde;","&ograve;","&oacute;","&ocirc;","&otilde;","&ouml;","&divide;","&oslash;","&ugrave;","&uacute;",
"&ucirc;","&uuml;","&yacute;","&thorn;","&yuml;"];specialChar[178]="&OElig;";specialChar[179]="&oelig;";specialChar[192]="&Scaron;";specialChar[193]="&scaron;";specialChar[216]="&Yuml;";specialChar[242]="&fnof;";specialChar[550]="&circ;";specialChar[572]="&tilde;";specialChar[8051]="&ndash;";specialChar[8052]="&mdash;";specialChar[8056]="&lsquo;";specialChar[8057]="&rsquo;";specialChar[8058]="&sbquo;";specialChar[8060]="&ldquo;";specialChar[8061]="&rdquo;";specialChar[8062]="&bdquo;";
specialChar[8064]="&dagger;";specialChar[8065]="&Dagger;";specialChar[8066]="&bull;";specialChar[8070]="&hellip;";specialChar[8080]="&permil;";specialChar[8089]="&lsaquo;";specialChar[8090]="&rsaquo;";specialChar[8204]="&euro;";specialChar[8322]="&trade;";var Xml={Class:"Xml"};
Xml.compare=function(a,b){if(typeof a=="undefined")throw new Error("Illegal argument. First argument is not defined.");if(typeof b=="undefined")throw new Error("Illegal argument. Second argument is not defined.");if(a==null&&b==null)return null;else if(a==null&&b!=null)return{node1:a,node2:b,reason:"First node is null, second is not null.",reasons:[]};else if(a!=null&&b==null)return{node1:a,node2:b,reason:"First node is not null, second is null.",reasons:[]};if(typeof a.ownerDocument=="undefined"&&
a.documentElement=="undefined")throw new Error("Illegal argument. First argument is not an XmlNode ("+valueString(a)+").");if(typeof b.ownerDocument=="undefined"&&b.documentElement=="undefined")throw new Error("Illegal argument. Second argument is not an XmlNode ("+valueString(b)+").");var c,d=function(h,f){for(var j=0;j<h.childNodes.length;j++)if(h.childNodes[j].nodeType==f)return h.childNodes[j];return null};getXPath=function(h){for(var f="",j=0;j<h.attributes.length;j++){var k=h.attributes.item(j);
f+=" and @"+k.nodeName+" = '"+String(k.value).replace(/\'/gi,"&#39;")+"'"}return f=f!=""?h.nodeName+"["+f.substr(5)+"]":h.nodeName};compare=function(h,f){for(var j=[],k=0;k<h.childNodes.length;k++){var l=h.childNodes[k],i=null;switch(l.nodeType){case ntElement:var o=getXPath(l),m=Xml.selectNodes(f,o);if(m.length==0)return{node1:h,node2:f,reason:"Couldn't find child: \""+o+'".',reasons:j};for(var n=0;n<m.length&&i==null;n++){var p=compare(l,m[n]);if(p==null)i=m[n];else j.add(p)}if(i==null)return j.length==
1?j[0]:{node1:h,node2:f,reason:"Couldn't find correct child: \""+o+'".',reasons:j};break;case ntText:case ntCData:i=d(f,l.nodeType);if(i==null)return{node1:h,node2:f,reason:"Couldn't find text or CDATA node.",reasons:j};if(l.nodeValue!=i.nodeValue)return{node1:l,node2:i,reason:"text or CDATA nodes are not the same.",reasons:j};break}}return null};if(typeof a.documentElement!="undefined"){c=a;a=c.documentElement}else c=a.ownerDocument;if(typeof b.documentElement!="undefined"){c=b;b=c.documentElement}else c=
b.ownerDocument;if(a.nodeName!=b.nodeName)return{node1:a,node2:b,reason:"Root nodes are not the same.",reasons:[]};if(a.nodeType!=b.nodeType)return{node1:a,node2:b,reason:"Root nodes are not of the same type.",reasons:[]};if(a.nodeType==ntElement){for(c=0;c<a.attributes.length;c++){var e=a.attributes.item(c),g=b.getAttributeNode(e.nodeName);if(g==null)return{node1:a,node2:b,reason:'Attribute "'+e.nodeName+'" does not exists in second node.',reasons:[]};if(e.value!=g.value)return{node1:e,node2:g,reason:'The values of the "'+
e.nodeName+'" attributes are not the same ("'+e.value+'" and "'+g.value+'").',reasons:[]}}for(c=0;c<b.attributes.length;c++){g=b.attributes.item(c);e=a.getAttributeNode(g.nodeName);if(e==null)return{node1:a,node2:b,reason:'Attribute "'+g.nodeName+'" does not exists in first node.',reasons:[]};if(e.value!=g.value)return{node1:e,node2:g,reason:'The values of the "'+e.nodeName+'" attributes are not the same ("'+e.value+'" and "'+g.value+'").',reasons:[]}}}c=compare(a,b);if(c!=null)return c;return compare(b,
a)};
Xml.create=function(a,b,c){function d(k){var l=Xml.create(Xml.toString(k.responseXML));c({status:k.status,statusText:k.statusText,responseText:k.responseText,responseXML:l})}var e=null;if(typeof a!="undefined"&&a!=null)if(Url.isUrl(a)){if(typeof c=="string")c=new Function("request",c);if(typeof c=="function"){a.onreadystatechange=d;typeof b!="undefined"&&b!=null?a.async("post",Xml.toString(b)):a.async();return}else{e=null;e=(e=typeof b!="undefined"?a.request("post",Xml.toString(b),true,true):a.request("get",
null,true,true))?Xml.create(Xml.toString(e)):Xml.create()}}else if(typeof a.documentElement!="undefined")e=a;else if(typeof a.ownerDocument!="undefined")return Xml.create(Xml.toString(a));else if(typeof a!="string")throw new Error("Illegal argument. First argument is not an Xml object, a string or an url ("+valueString(a)+").");try{if(e==null||typeof e.documentElement=="undefined")if(window.ActiveXObject){b=0;for(var g=["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument",
"Microsoft.XMLDOM"];e==null&&b<g.length;){try{e=new ActiveXObject(g[b])}catch(h){}b++}if(e==null)throw new Error("Capability not supported. Cannot create DOMDocument object.");typeof a=="string"&&e.loadXML(a)}else e=typeof a=="string"?(new DOMParser).parseFromString(a,"text/xml"):document.implementation.createDocument("","",null)}catch(f){Log.error(f);e=typeof a!="undefined"?new Xml(a):new Xml}try{e.setProperty("SelectionLanguage","XPath")}catch(j){Log.write('doc.setProperty("SelectionLanguage", "XPath"); not supported...')}return e};
Xml.createPath=function(a,b,c,d){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(typeof b!="string")throw new Error("Illegal argument. xPath expression expected to be of type string ("+valueString(b)+").");if(b.length==0)throw new Error("Illegal argument. xPath expression's length is zero.");if(typeof c=="undefined")return null;if(a.nodeType==ntDocument){if(b.contains("/"))b=b.substr(b.indexOf("/")+
1);return Xml.createPath(a.documentElement,b,c,d)}var e=a.ownerDocument;b=b.split("/");if(a.nodeType==ntDocument)e=a;for(var g=0;g<b.length;g++){var h=Xml.selectSingleNode(a,b[g]);if(h==null)if(b[g].startsWith("@")){h=b[g].substr(1);h=e.createAttribute(h);a.setAttributeNode(h)}else h=a.appendChild(function(f){var j=null;if(f.indexOf("[")>-1){var k=f.substr(f.indexOf("[")+1);f=f.substr(0,f.indexOf("["));j=e.createElement(f);k=k.substr(0,k.length-1);k=k.replace(/(\s+or\s+|\s+and\s+)/gi,"|");k=k.split("|");
for(var l=0;l<k.length;l++){var i=k[l];if(i.contains("=")){i=i.split("=");f=i[0].trim();i=i.length>1?i[1].trim():null;if(f.startsWith("@"))f=f.substr(1);if(i!=null){if(i.startsWith('"')||i.startsWith("'"))i=i.substr(1);if(i.endsWith('"')||i.endsWith("'"))i=i.substr(0,i.length-1)}j.setAttribute(f,i)}}}else j=e.createElement(f);return j}(b[g]));a=h}if(a.nodeType==ntElement&&d==ntCData){for(;a.firstChild!=null;)a.removeChild(a.firstChild);a.appendChild(e.createCDATASection(c))}else Xml.setText(a,c);
return a};Xml.find=function(a,b){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(typeof a.childNodes!="undefined")for(var c=0;c<a.childNodes.length;c++)if(a.childNodes[c].nodeType==b)return a.childNodes[c];return null};
Xml.getText=function(a){if(a==null)return null;if(typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(a.nodeType==ntElement){var b=Xml.find(a,ntText);if(b==null)b=Xml.find(a,ntCData);return b!=null?b.nodeValue:null}else return a.nodeValue};
Xml.moveBottom=function(a){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(a.nextSibling){a.parentNode.appendChild(a);return true}return false};
Xml.moveDown=function(a){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(a.nextSibling){a.nextSibling.nextSibling?a.parentNode.insertBefore(a,a.nextSibling.nextSibling):a.parentNode.appendChild(a);return true}return false};
Xml.moveTop=function(a){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(a.previousSibling){a.parentNode.insertBefore(a,a.parentNode.firstChild);return true}return false};
Xml.moveUp=function(a){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(a.previousSibling){a.parentNode.insertBefore(a,a.previousSibling);return true}return false};
Xml.removeNode=function(a){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(a.parentNode)a.parentNode.removeChild(a);else throw new Error("Illegal argument. The given node has no parent.");};
Xml.selectNodes=function(a,b){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(typeof b!="string")throw new Error("Illegal argument. Second argument is not a string ("+valueString(b)+").");if(typeof a.selectNodes!="undefined")return a.selectNodes(b);var c=a.ownerDocument;if(a.nodeType==ntDocument)c=a;var d=[];a=c.evaluate(b,a,null,XPathResult.ANY_TYPE,null);for(b=a.iterateNext();b;){d.add(b);b=
a.iterateNext()}return d};
Xml.selectSingleNode=function(a,b){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(typeof b!="string")throw new Error("Illegal argument. Second argument is not a string ("+valueString(b)+").");if(typeof a.selectSingleNode!="undefined")return a.selectSingleNode(b);var c=a.ownerDocument;if(a.nodeType==ntDocument)c=a;return(a=c.evaluate(b,a,null,XPathResult.ANY_TYPE,null).iterateNext())?a:null};
Xml.setText=function(a,b){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(a.nodeType==ntElement){for(var c=a.firstChild?a.firstChild.nodeType:ntText,d=0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(e.nodeType==ntText||e.nodeType==ntCData){a.removeChild(e);d--}}if(b!=null&&String(b)!="")c==ntCData?a.insertBefore(a.ownerDocument.createCDATASection(b),a.firstChild):a.insertBefore(a.ownerDocument.createTextNode(b),
a.firstChild)}else a.nodeValue=b!=null&&String(b)!=""?b:""};
Xml.setValue=function(a,b,c,d,e){if(a==null||typeof a.ownerDocument=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");var g=Xml.selectSingleNode(a,b),h=a,f=b;if(b.contains("/")){f=b.substr(b.lastIndexOf("/")+1);h=Xml.selectSingleNode(a,b.substr(0,b.lastIndexOf("/")))}if(f.startsWith("@")){f=f.substr(1);e=ntAttribute}if(c==null||String(c)==""){if(g!=null){if(e==ntAttribute)h.removeAttribute(f);else a!=null&&h.removeChild(g);g=null}}else{if(typeof e==
"undefined")e=ntElement;c=d==dtString?c:toXml(c,d);if(g==null)g=Xml.createPath(a,b,c,e);else Xml.setText(g,c)}return g};Xml.show=function(a,b){if(a==null||typeof a!="string"&&typeof a.childNodes=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode or a string containing Xml ("+valueString(a)+").");showXml(Xml.create(a),b)};Xml.strToXPath=function(a){if(a==null)return"''";var b=a.split("'");return b.length>1?"concat('"+b.join("', \"'\", '")+"')":"'"+a+"'"};
Xml.toString=function(a){if(a==null||typeof a.childNodes=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");return typeof a.xml!="undefined"?a.xml:(new XMLSerializer).serializeToString(a)};
Xml.toHtml=function(a){if(a==null)return"";if(a==null||typeof a!="string"&&typeof a.childNodes=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode or a string containing Xml ("+valueString(a)+").");var b=new RegExp("<(a|b|blockquote|body|button|center|code|colgroup|div|em|fieldset|font|frame|frameset|head|h[dn]|html|iframe|label|legend|li|object|ol|optgroup|option|p|q|s|script|select|span|strike|strong|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|u|ul)(\\b[^>]*?)?\\s*/>","gi"),
c=new RegExp('<\\?xml version="1\\.0" encoding="[^"]*"\\?>',"gi");return(typeof a=="string"?a:Xml.toString(a)).replace(b,"<$1$2></$1>").replace(c,"")};
Xml.transform=function(a,b){if(a==null||typeof a.childNodes=="undefined")throw new Error("Illegal argument. First argument is expected to be a XmlNode ("+valueString(a)+").");if(b!=null&&typeof b=="string")b=Xml.create(new Url(b));if(b==null||typeof b.documentElement=="undefined")throw new Error("Illegal argument. Second argument is expected to be a XmlDocument or a string containing the path to a valid Xsl file ("+valueString(b)+").");if(typeof a.transformNode!="undefined")return a.transformNode(b);
else{var c=new XSLTProcessor;c.importStylesheet(b);return Xml.toString(c.transformToFragment(a,a.ownerDocument))}};
function toXml(a,b){if(typeof b!="undefined")switch(b){case dtBoolean:return a?"1":"0";case dtDateTime:return a.formatString("s");case dtDouble:case dtMoney:case dtPercentage:return a.formatString("0.0#########").replace(",",".");case dtInteger:case dtLong:break;case dtString:case dtGuid:a=a.replace(/\&/gi,"&amp;");a=a.replace(/\"/gi,"&quot;");a=a.replace(/\</gi,"&lt;");a=a.replace(/\>/gi,"&gt;");break;default:throw new Error('Illegal assignment to parameter "type" ('+b+").");}else{b=typeof a;if(b==
"boolean")return toXml(a,dtBoolean);else if(b=="number")return toXml(a,dtDouble);else if(b=="string")return toXml(a,dtString);else if(a instanceof Date)return toXml(a,dtDateTime);else throw new Error('Illegal assignment to parameter "value" ('+valueString(a)+"). The value is of an illegal type.");}return a}
function fromXml(a,b){if(typeof a!="undefined"&&typeof a.firstChild!="undefined")a=Xml.getText(a);if(a==null||String(a)=="")return null;if(typeof b=="undefined")return a;switch(b){case dtBoolean:return String(a)=="0"||String(a).toLowerCase()=="false"||String(a).toLowerCase()=="no"?false:true;case dtDateTime:a=parseXmlDate(a);return isNaN(a)?null:a;case dtDouble:case dtMoney:case dtPercentage:a=parseFloat(a);return isNaN(a)?null:a;case dtInteger:case dtLong:a=parseInt(a);return isNaN(a)?null:a;case dtString:case dtGuid:a=
a.replace(/\r+\n/gi,"\n");a=a.replace(/\n/gi,"\r\n");a=a.replace(/&amp;/gi,"&");a=a.replace(/&quot;/gi,'"');a=a.replace(/&lt;/gi,"<");return a=a.replace(/&gt;/gi,">");default:throw new Error('Illegal assignment to parameter "type" ('+b+").");}}
function parseXmlDate(a){if(/^(\d{4}-\d{2}-\d{2})(T\d{2}:\d{2}:\d{2}(\.\d{1,7})?)?$/i.test(a)){a=a.split(/[-T:\.]/g);for(var b=0;b<a.length;b++)for(;a[b].startsWith("0")&&String(a[b]).length>1;)a[b]=a[b].substr(1);b=parseInt(a[0]);month=parseInt(a[1]);day=parseInt(a[2]);hour=parseInt(a[3]);minute=parseInt(a[4]);second=parseInt(a[5]);if(isNaN(hour))hour=0;if(isNaN(minute))minute=0;if(isNaN(second))second=0;return new Date(b,month-1,day,hour,minute,second)}else return parseInt("knaag")}
function htmlEncode(a){var b;try{b=new String(a);b=b.replace(/&/g,"&amp;");for(var c=0;c<charCodes.length;c++){var d=charCodes[c],e=specialChar[d-160];b=b.replace(new RegExp(String.fromCharCode(d),"g"),"&amp;"+e.substr(1))}b=b.replace(/</g,"&lt;");b=b.replace(/>/g,"&gt;");b=b.replace(/"/g,"&quot;")}catch(g){try{b=a.join(", ")}catch(h){b=a}}return b}
function showXml(a,b){if(typeof b=="undefined"||b==null)b="";if(typeof a!="object"||typeof a.childNodes=="undefined")throw new Error("Illegal argument. First argument is not an XmlNode.");if(typeof a.documentElement!="undefined")a=a.documentElement;var c=String('<?xml version="1.0" encoding="utf-8"?>\r\n').length,d=window.open("","frmXML"+b,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=788,height=570");if(typeof Xml!="undefined"&&typeof Xml.toString=="function")c+=
Xml.toString(a).length;if(d){d.document.open();d.document.writeln("<html><head><title>Xml "+b+'</title></head><body style="font-family: Lucida Console, Courier New; font-size:11px; color:navy; margin:5px; background-color:white;">&lt;?xml version="1.0" encoding="Windows-1252"?&gt;');d.document.writeln(buildXml(a));if(typeof Xml!="undefined"&&typeof Xml.toString=="function")if(c<2048)d.document.writeln('<div style="clear:both; margin-top:10px; font-family:Verdana; color:black;"><b>XML size:</b> '+
c+" bytes</div></html>");else if(c/1024<2048)d.document.writeln('<div style="clear:both; margin-top:10px; font-family:Verdana; color:black;"><b>XML size:</b> '+Math.round(c/1024*100)/100+" kB</div></html>");else c/1024/1024<2048&&d.document.writeln('<div style="clear:both; margin-top:10px; font-family:Verdana; color:black;"><b>XML size:</b> '+Math.round(c/1024/1024*100)/100+" MB</div></html>");d.document.writeln("</body></html>");d.document.close();d.focus()}}
function nodeName(a){var b=a.nodeName;if(a.attributes)for(var c=0;c<a.attributes.length;c++){var d=a.attributes.item(c);if(d.nodeName!="xmlns:sql"&&d.value!="null"&&d.value!=""&&d.value!=null)b+=" "+d.nodeName+'=<font color="blue">"'+d.value.replace(/\"/g,"&amp;quot;")+'"</font>'}return b}
function buildXml(a,b){var c="";if(b==undefined)b="";if(a.childNodes.length){c+="<br/>"+b+"&lt;"+nodeName(a)+"&gt;";for(var d=0;d<a.childNodes.length;d++)c+=buildXml(a.childNodes[d],b+"&nbsp;&nbsp;&nbsp;");var e=a.childNodes.length;for(d=0;d<a.childNodes.length;d++)if(a.childNodes[d].nodeType==ntText||a.childNodes[d].nodeType==ntCData)e--;if(e>0)c+="<br/>"+b;c+="&lt;/"+a.nodeName+"&gt;"}else if(a.nodeType==ntText){d=null;if(typeof a.value!="undefined")d=a.value;else if(typeof a.text!="undefined")d=
a.text;else if(typeof a.nodeValue!="undefined")d=a.nodeValue;if(typeof d!="undefined"&&d!=""&&d!=null)c+='<font color="black"><b>'+toXml(d,dtString).htmlEncode().replace(/[\r\n]/gi,"<br/>")+"</b></font>"}else if(a.nodeType==ntCData){d=null;if(typeof a.value!="undefined")d=a.value;else if(typeof a.text!="undefined")d=a.text;else if(typeof a.nodeValue!="undefined")d=a.nodeValue;c+='<font color="red">&lt;![CDATA[<br/><div style="margin-left:'+b.length/6*7+'px; padding-left:3px; border-left:1px solid #C00000;"><font color="black">';
c+=toXml(d,dtString).replace(/[\r\n]/gi,"<br/>").replace(/[\t]/gi,"&nbsp;&nbsp;&nbsp;");c+="</font><br/></div>"+b+"]]&gt;</font>"}else if(a.nodeType==ntElement)c+="<br/>"+b+"&lt;"+nodeName(a)+"/&gt;";return c};
