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;".split(",");
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",appendChild:function(a,b){if("undefined"==typeof a)throw Error("Illegal argument. First argument is not defined.");if("undefined"==typeof b)throw Error("Illegal argument. Second argument is not defined.");if("undefined"==typeof a.ownerDocument&&"undefined"==a.documentElement)throw Error("Illegal argument. First argument is not an XmlNode ("+valueString(a)+").");if("undefined"==typeof b.ownerDocument&&"undefined"==b.documentElement)throw Error("Illegal argument. Second argument is not an XmlNode ("+
valueString(b)+").");var c=null!=a.ownerDocument?a.ownerDocument:a,d=null!=b.ownerDocument?b.ownerDocument:b;null!=c&&"undefined"!=typeof c.importNode&&c!=d?b==d?a.appendChild(c.importNode(b.documentElement,!0)):a.appendChild(c.importNode(b,!0)):b==d?a.appendChild(b.documentElement):a.appendChild(b)},checkIsNode:function(a,b){var c="undefined"==typeof b?"Argument":null;if(null==c){switch(b){case 1:c="First";break;case 2:c="Second";break;case 3:c="Third"}c+=" argument"}if(null==a||"undefined"==typeof a.ownerDocument)throw Error("Illegal argument. "+
c+" is expected to be a XmlNode ("+valueString(a)+").");},compare:function(a,b){if("undefined"==typeof a)throw Error("Illegal argument. First argument is not defined.");if("undefined"==typeof b)throw Error("Illegal argument. Second argument is not defined.");if(null==a&&null==b)return null;if(null==a&&null!=b)return{node1:a,node2:b,reason:"First node is null, second is not null.",reasons:[]};if(null!=a&&null==b)return{node1:a,node2:b,reason:"First node is not null, second is null.",reasons:[]};if("undefined"==
typeof a.ownerDocument&&"undefined"==a.documentElement)throw Error("Illegal argument. First argument is not an XmlNode ("+valueString(a)+").");if("undefined"==typeof b.ownerDocument&&"undefined"==b.documentElement)throw Error("Illegal argument. Second argument is not an XmlNode ("+valueString(b)+").");var c,d=function(a,b){var g;for(var c=[],e=0;e<a.childNodes.length;e++){var f=a.childNodes[e],h=null;switch(f.nodeType){case ntElement:var j;j=f;for(var i="",k=0;k<j.attributes.length;k++)var m=j.attributes.item(k),
i=i+(" and @"+m.nodeName+" = '"+(""+m.value).replace(/\'/gi,"&#39;")+"'");g=i=""!=i?j.nodeName+"["+i.substr(5)+"]":j.nodeName,j=g;i=Xml.selectNodes(b,j);if(0==i.length)return{node1:a,node2:b,reason:"Couldn't find child: \""+j+'".',reasons:c};for(k=0;k<i.length&&null==h;k++)m=d(f,i[k]),null==m?h=i[k]:c.add(m);if(null==h)return 1==c.length?c[0]:{node1:a,node2:b,reason:"Couldn't find correct child: \""+j+'".',reasons:c};break;case ntText:case ntCData:a:{for(h=0;h<b.childNodes.length;h++)if(b.childNodes[h].nodeType==
f.nodeType){h=b.childNodes[h];break a}h=null}if(null==h)return{node1:a,node2:b,reason:"Couldn't find text or CDATA node.",reasons:c};if(f.nodeValue!=h.nodeValue)return{node1:f,node2:h,reason:"text or CDATA nodes are not the same.",reasons:c}}}return null};"undefined"!=typeof a.documentElement?a=a.documentElement:c=a.ownerDocument;"undefined"!=typeof b.documentElement?b=b.documentElement: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),f=b.getAttributeNode(e.nodeName);if(null==f)return{node1:a,node2:b,reason:'Attribute "'+e.nodeName+'" does not exists in second node.',reasons:[]};if(e.value!=f.value)return{node1:e,node2:f,reason:'The values of the "'+e.nodeName+'" attributes are not the same ("'+e.value+'" and "'+f.value+'").',reasons:[]}}for(c=
0;c<b.attributes.length;c++){f=b.attributes.item(c);e=a.getAttributeNode(f.nodeName);if(null==e)return{node1:a,node2:b,reason:'Attribute "'+f.nodeName+'" does not exists in first node.',reasons:[]};if(e.value!=f.value)return{node1:e,node2:f,reason:'The values of the "'+e.nodeName+'" attributes are not the same ("'+e.value+'" and "'+f.value+'").',reasons:[]}}}c=d(a,b);return null!=c?c:d(b,a)}};
Xml.create=function(a,b,c){function d(a){var b=Xml.create(Xml.toString(a.responseXML));c({status:a.status,statusText:a.statusText,responseText:a.responseText,responseXML:b})}var e=null;if("undefined"!=typeof a&&null!=a)if(Url.isUrl(a)){"string"==typeof c&&(c=new Function("request",c));if("function"==typeof c){a.onreadystatechange=d;"undefined"!=typeof b&&null!=b?a.async("post",Xml.toString(b)):a.async();return}e=null;e=(e="undefined"!=typeof b?a.request("post",Xml.toString(b),!0,!0):a.request("get",
null,!0,!0))?Xml.create(Xml.toString(e)):Xml.create()}else if("undefined"!=typeof a.documentElement)e=a;else{if("undefined"!=typeof a.ownerDocument)return Xml.create(Xml.toString(a));if("string"!=typeof a)throw Error("Illegal argument. First argument is not an Xml object, a string or an url ("+valueString(a)+").");}try{if(null==e||"undefined"==typeof e.documentElement)if(window.ActiveXObject){for(var b=0,f=["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument",
"Microsoft.XMLDOM"];null==e&&b<f.length;){try{e=new ActiveXObject(f[b])}catch(g){}b++}if(null==e)throw Error("Capability not supported. Cannot create DOMDocument object.");"string"==typeof a&&e.loadXML(a)}else e="string"==typeof a?(new DOMParser).parseFromString(a,"text/xml"):document.implementation.createDocument("","",null)}catch(l){Log.error(l),e="undefined"!=typeof a?new Xml(a):new Xml}try{e.setProperty("SelectionLanguage","XPath")}catch(n){Log.write('doc.setProperty("SelectionLanguage", "XPath"); not supported...')}return e};
Xml.createPath=function(a,b,c,d){Xml.checkIsNode(a);if("string"!=typeof b)throw Error("Illegal argument. xPath expression expected to be of type string ("+valueString(b)+").");if(0==b.length)throw Error("Illegal argument. xPath expression's length is zero.");if("undefined"==typeof c)return null;if(a.nodeType==ntDocument)return b.contains("/")&&(b=b.substr(b.indexOf("/")+1)),Xml.createPath(a.documentElement,b,c,d);var e=a.ownerDocument,b=b.split("/");a.nodeType==ntDocument&&(e=a);for(var f=0;f<b.length;f++){var g=
Xml.selectSingleNode(a,b[f]);null==g&&(b[f].startsWith("@")?(g=b[f].substr(1),g=e.createAttribute(g),a.setAttributeNode(g)):g=a.appendChild(function(a){var b=null;if(-1<a.indexOf("["))for(var c=a.substr(a.indexOf("[")+1),a=a.substr(0,a.indexOf("[")),b=e.createElement(a),c=c.substr(0,c.length-1),c=c.replace(/(\s+or\s+|\s+and\s+)/gi,"|"),c=c.split("|"),d=0;d<c.length;d++){var f=c[d];if(f.contains("=")){f=f.split("=");a=f[0].trim();f=1<f.length?f[1].trim():null;a.startsWith("@")&&(a=a.substr(1));if(null!=
f){if(f.startsWith('"')||f.startsWith("'"))f=f.substr(1);if(f.endsWith('"')||f.endsWith("'"))f=f.substr(0,f.length-1)}b.setAttribute(a,f)}}else b=e.createElement(a);return b}(b[f])));a=g}if(a.nodeType==ntElement&&d==ntCData){for(;null!=a.firstChild;)a.removeChild(a.firstChild);a.appendChild(e.createCDATASection(c))}else Xml.setText(a,c);return a};
Xml.find=function(a,b){Xml.checkIsNode(a,1);if("undefined"!=typeof a.childNodes)for(var c=0;c<a.childNodes.length;c++)if(a.childNodes[c].nodeType==b)return a.childNodes[c];return null};Xml.findAll=function(a,b){Xml.checkIsNode(a,1);var c=[];if("undefined"!=typeof a.childNodes)for(var d=0;d<a.childNodes.length;d++)a.childNodes[d].nodeType==b&&c.add(a.childNodes[d]);return c};
Xml.getText=function(a){if(null==a)return null;Xml.checkIsNode(a,1);return a.nodeType==ntElement?browser==browsers.IE?a.text:a.textContent:a.nodeValue};Xml.getValue=function(a){if(null==a)return null;Xml.checkIsNode(a,1);return a.nodeType==ntElement?null!=a.firstChild?a.firstChild.nodeValue:null:a.nodeValue};Xml.moveBottom=function(a){Xml.checkIsNode(a,1);return a.nextSibling?(a.parentNode.appendChild(a),!0):!1};
Xml.moveDown=function(a){Xml.checkIsNode(a,1);return a.nextSibling?(a.nextSibling.nextSibling?a.parentNode.insertBefore(a,a.nextSibling.nextSibling):a.parentNode.appendChild(a),!0):!1};Xml.moveTop=function(a){Xml.checkIsNode(a,1);return a.previousSibling?(a.parentNode.insertBefore(a,a.parentNode.firstChild),!0):!1};Xml.moveUp=function(a){Xml.checkIsNode(a,1);return a.previousSibling?(a.parentNode.insertBefore(a,a.previousSibling),!0):!1};
Xml.removeNode=function(a){Xml.checkIsNode(a,1);if(a.parentNode)a.parentNode.removeChild(a);else throw Error("Illegal argument. The given node has no parent.");};
Xml.selectNodes=function(a,b){Xml.checkIsNode(a,1);if("string"!=typeof b)throw Error("Illegal argument. Second argument is not a string ("+valueString(b)+").");if("undefined"!=typeof a.selectNodes)return a.selectNodes(b);var c=a.ownerDocument;a.nodeType==ntDocument&&(c=a);for(var d=[],c=c.evaluate(b,a,null,XPathResult.ANY_TYPE,null),e=c.iterateNext();e;)d.add(e),e=c.iterateNext();return d};
Xml.selectSingleNode=function(a,b){Xml.checkIsNode(a,1);if("string"!=typeof b)throw Error("Illegal argument. Second argument is not a string ("+valueString(b)+").");if("undefined"!=typeof a.selectSingleNode)return a.selectSingleNode(b);var c=a.ownerDocument;a.nodeType==ntDocument&&(c=a);return(c=c.evaluate(b,a,null,XPathResult.ANY_TYPE,null).iterateNext())?c:null};
Xml.setText=function(a,b){Xml.checkIsNode(a,1);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--}null!=b&&""!=""+b&&(c==ntCData?a.insertBefore(a.ownerDocument.createCDATASection(b),a.firstChild):a.insertBefore(a.ownerDocument.createTextNode(b),a.firstChild))}else a.nodeValue=null!=b&&""!=""+b?b:""};
Xml.setValue=function(a,b,c,d,e){Xml.checkIsNode(a,1);var f=Xml.selectSingleNode(a,b),g=a,l=b;b.contains("/")&&(l=b.substr(b.lastIndexOf("/")+1),g=Xml.selectSingleNode(a,b.substr(0,b.lastIndexOf("/"))));l.startsWith("@")&&(l=l.substr(1),e=ntAttribute);null==c||""==""+c?null!=f&&(e==ntAttribute?g.removeAttribute(l):null!=a&&g.removeChild(f),f=null):("undefined"==typeof e&&(e=ntElement),c=d==dtString?c:toXml(c,d),null==f?f=Xml.createPath(a,b,c,e):Xml.setText(f,c));return f};
Xml.show=function(a,b){if(null==a||"string"!=typeof a&&"undefined"==typeof a.childNodes)throw Error("Illegal argument. First argument is expected to be a XmlNode or a string containing Xml ("+valueString(a)+").");a=Xml.create(a);if("undefined"==typeof b||null==b)b="";if("undefined"!=typeof a.documentElement)a=a.documentElement;var c=40,d=window.open("","frmXML"+b,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=788,height=570");"undefined"!=typeof Xml&&"function"==
typeof Xml.toString&&(c+=Xml.toString(a).length);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(Xml.format(a)),"undefined"!=typeof Xml&&"function"==typeof Xml.toString&&(2048>c?d.document.writeln('<div style="clear:both; margin-top:10px; font-family:Verdana; color:black;"><b>XML size:</b> '+
c+" bytes</div></html>"):2048>c/1024?d.document.writeln('<div style="clear:both; margin-top:10px; font-family:Verdana; color:black;"><b>XML size:</b> '+Math.round(100*(c/1024))/100+" kB</div></html>"):2048>c/1024/1024&&d.document.writeln('<div style="clear:both; margin-top:10px; font-family:Verdana; color:black;"><b>XML size:</b> '+Math.round(100*(c/1024/1024))/100+" MB</div></html>")),d.document.writeln("</body></html>"),d.document.close(),d.focus())};
Xml.format=function(a,b){var c="";void 0==b&&(b="");if(a.childNodes.length){for(var c=c+("<br/>"+b+"&lt;"+Xml.writeElement(a)+"&gt;"),d=0;d<a.childNodes.length;d++)c+=Xml.format(a.childNodes[d],b+"&nbsp;&nbsp;&nbsp;");for(var e=a.childNodes.length,d=0;d<a.childNodes.length;d++)(a.childNodes[d].nodeType==ntText||a.childNodes[d].nodeType==ntCData)&&e--;0<e&&(c+="<br/>"+b);c+="&lt;/"+a.nodeName+"&gt;"}else if(a.nodeType==ntText){d=null;if("undefined"!=typeof a.value)d=a.value;else if("undefined"!=typeof a.text)d=
a.text;else if("undefined"!=typeof a.nodeValue)d=a.nodeValue;"undefined"!=typeof d&&""!=d&&null!=d&&(c+='<font color="black"><b>'+toXml(d,dtString).htmlEncode().replace(/[\r\n]/gi,"<br/>")+"</b></font>")}else if(a.nodeType==ntCData){d=null;if("undefined"!=typeof a.value)d=a.value;else if("undefined"!=typeof a.text)d=a.text;else if("undefined"!=typeof a.nodeValue)d=a.nodeValue;c+='<font color="red">&lt;![CDATA[<br/><div style="margin-left:'+7*(b.length/6)+'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 a.nodeType==ntElement&&(c+="<br/>"+b+"&lt;"+Xml.writeElement(a)+"/&gt;");return c};Xml.writeElement=function(a){var b=a.nodeName;if(a.attributes)for(var c=0;c<a.attributes.length;c++){var d=a.attributes.item(c);"xmlns:sql"!=d.nodeName&&"null"!=d.value&&""!=d.value&&null!=d.value&&(b+=" "+d.nodeName+'=<font color="blue">"'+d.value.replace(/\"/g,"&amp;quot;")+'"</font>')}return b};
Xml.strToXPath=function(a){if(null==a)return"''";var b=a.split("'");return 1<b.length?"concat('"+b.join("', \"'\", '")+"')":"'"+a+"'"};Xml.toString=function(a){Xml.checkIsNode(a,1);return"undefined"!=typeof a.xml?a.xml:(new XMLSerializer).serializeToString(a)};
Xml.toHtml=function(a){if(null==a)return"";Xml.checkIsNode(a,1);return("string"==typeof a?a:Xml.toString(a)).replace(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"),"<$1$2></$1>").replace(RegExp('<\\?xml version="1\\.0" encoding="[^"]*"\\?>',"gi"),"")};
Xml.transform=function(a,b){Xml.checkIsNode(a,1);null!=b&&"string"==typeof b&&(b=Xml.create(new Url(b)));if(null==b||"undefined"==typeof b.documentElement)throw 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("undefined"!=typeof a.transformNode)return a.transformNode(b);var c=new XSLTProcessor;c.importStylesheet(b);return(c=c.transformToFragment(a,a.ownerDocument))?Xml.toString(c):null};
function toXml(a,b){if("undefined"!=typeof b)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 Error('Illegal assignment to parameter "type" ('+b+").");}else{b=typeof a;if("boolean"==
b)return toXml(a,dtBoolean);if("number"==b)return toXml(a,dtDouble);if("string"==b)return toXml(a,dtString);if(a instanceof Date)return toXml(a,dtDateTime);throw Error('Illegal assignment to parameter "value" ('+valueString(a)+"). The value is of an illegal type.");}return a}
function fromXml(a,b){"undefined"!=typeof a&&"undefined"!=typeof a.firstChild&&(a=Xml.getText(a));if(null==a||""==""+a)return null;if("undefined"==typeof b)return a;switch(b){case dtBoolean:return"0"==""+a||"false"==(""+a).toLowerCase()||"no"==(""+a).toLowerCase()?!1:!0;case dtDateTime:return a=parseXmlDate(a),isNaN(a)?null:a;case dtDouble:case dtMoney:case dtPercentage:return a=parseFloat(a),isNaN(a)?null:a;case dtInteger:case dtLong:return a=parseInt(a),isNaN(a)?null:a;case dtString:case dtGuid:return 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,"<"),a=a.replace(/&gt;/gi,">");default:throw 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)){for(var a=a.split(/[-T:\.]/g),b=0;b<a.length;b++)for(;a[b].startsWith("0")&&1<(""+a[b]).length;)a[b]=a[b].substr(1);var b=parseInt(a[0]),c=parseInt(a[1]),d=parseInt(a[2]),e=parseInt(a[3]),f=parseInt(a[4]),a=parseInt(a[5]);isNaN(e)&&(e=0);isNaN(f)&&(f=0);isNaN(a)&&(a=0);return new Date(b,c-1,d,e,f,a)}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(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(f){try{b=a.join(", ")}catch(g){b=a}}return b};

