This file is indexed.

/usr/share/javascript/jsjac/jsjac.min.js is in libjs-jac 1.3.4+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

1
JSJAC_HAVEKEYS=true;JSJAC_NKEYS=16;JSJAC_INACTIVITY=300;JSJAC_ERR_COUNT=10;JSJAC_ALLOW_PLAIN=true;JSJAC_CHECKQUEUEINTERVAL=1;JSJAC_CHECKINQUEUEINTERVAL=1;JSJAC_TIMERVAL=2000;JSJACHBC_MAX_HOLD=1;JSJACHBC_MAX_WAIT=300;JSJACHBC_BOSH_VERSION="1.6";JSJACHBC_USE_BOSH_VER=true;JSJACHBC_MAXPAUSE=120;String.prototype.htmlEnc=function(){var a=this.replace(/&/g,"&amp;");a=a.replace(/</g,"&lt;");a=a.replace(/>/g,"&gt;");a=a.replace(/\"/g,"&quot;");a=a.replace(/\n/g,"<br />");return a};Date.jab2date=function(b){var a=new Date(Date.UTC(b.substr(0,4),b.substr(5,2)-1,b.substr(8,2),b.substr(11,2),b.substr(14,2),b.substr(17,2)));if(b.substr(b.length-6,1)!="Z"){var c=new Date();c.setTime(0);c.setUTCHours(b.substr(b.length-5,2));c.setUTCMinutes(b.substr(b.length-2,2));if(b.substr(b.length-6,1)=="+"){a.setTime(a.getTime()-c.getTime())}else{if(b.substr(b.length-6,1)=="-"){a.setTime(a.getTime()+c.getTime())}}}return a};Date.hrTime=function(a){return Date.jab2date(a).toLocaleString()};Date.prototype.jabberDate=function(){var b=function(c){if(c<10){return"0"+c}return c};var a=this.getUTCFullYear()+"-";a+=b(this.getUTCMonth()+1)+"-";a+=b(this.getUTCDate())+"T";a+=b(this.getUTCHours())+":";a+=b(this.getUTCMinutes())+":";a+=b(this.getUTCSeconds())+"Z";return a};Number.max=function(a,b){return(a>b)?a:b};Number.min=function(a,b){return(a<b)?a:b};var hexcase=0;var b64pad="=";var chrsz=8;function hex_sha1(a){return binb2hex(core_sha1(str2binb(a),a.length*chrsz))}function b64_sha1(a){return binb2b64(core_sha1(str2binb(a),a.length*chrsz))}function str_sha1(a){return binb2str(core_sha1(str2binb(a),a.length*chrsz))}function hex_hmac_sha1(a,b){return binb2hex(core_hmac_sha1(a,b))}function b64_hmac_sha1(a,b){return binb2b64(core_hmac_sha1(a,b))}function str_hmac_sha1(a,b){return binb2str(core_hmac_sha1(a,b))}function sha1_vm_test(){return hex_sha1("abc")=="a9993e364706816aba3e25717850c26c9cd0d89d"}function core_sha1(v,o){v[o>>5]|=128<<(24-o%32);v[((o+64>>9)<<4)+15]=o;var y=Array(80);var u=1732584193;var s=-271733879;var r=-1732584194;var q=271733878;var p=-1009589776;for(var l=0;l<v.length;l+=16){var n=u;var m=s;var k=r;var h=q;var f=p;for(var g=0;g<80;g++){if(g<16){y[g]=v[l+g]}else{y[g]=rol(y[g-3]^y[g-8]^y[g-14]^y[g-16],1)}var z=safe_add(safe_add(rol(u,5),sha1_ft(g,s,r,q)),safe_add(safe_add(p,y[g]),sha1_kt(g)));p=q;q=r;r=rol(s,30);s=u;u=z}u=safe_add(u,n);s=safe_add(s,m);r=safe_add(r,k);q=safe_add(q,h);p=safe_add(p,f)}return Array(u,s,r,q,p)}function sha1_ft(e,a,g,f){if(e<20){return(a&g)|((~a)&f)}if(e<40){return a^g^f}if(e<60){return(a&g)|(a&f)|(g&f)}return a^g^f}function sha1_kt(a){return(a<20)?1518500249:(a<40)?1859775393:(a<60)?-1894007588:-899497514}function core_hmac_sha1(c,f){var e=str2binb(c);if(e.length>16){e=core_sha1(e,c.length*chrsz)}var a=Array(16),d=Array(16);for(var b=0;b<16;b++){a[b]=e[b]^909522486;d[b]=e[b]^1549556828}var g=core_sha1(a.concat(str2binb(f)),512+f.length*chrsz);return core_sha1(d.concat(g),512+160)}function rol(a,b){return(a<<b)|(a>>>(32-b))}function str2binb(d){var c=Array();var a=(1<<chrsz)-1;for(var b=0;b<d.length*chrsz;b+=chrsz){c[b>>5]|=(d.charCodeAt(b/chrsz)&a)<<(32-chrsz-b%32)}return c}function binb2str(c){var d="";var a=(1<<chrsz)-1;for(var b=0;b<c.length*32;b+=chrsz){d+=String.fromCharCode((c[b>>5]>>>(32-chrsz-b%32))&a)}return d}function binb2hex(c){var b=hexcase?"0123456789ABCDEF":"0123456789abcdef";var d="";for(var a=0;a<c.length*4;a++){d+=b.charAt((c[a>>2]>>((3-a%4)*8+4))&15)+b.charAt((c[a>>2]>>((3-a%4)*8))&15)}return d}function binb2b64(d){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var f="";for(var b=0;b<d.length*4;b+=3){var e=(((d[b>>2]>>8*(3-b%4))&255)<<16)|(((d[b+1>>2]>>8*(3-(b+1)%4))&255)<<8)|((d[b+2>>2]>>8*(3-(b+2)%4))&255);for(var a=0;a<4;a++){if(b*8+a*6>d.length*32){f+=b64pad}else{f+=c.charAt((e>>6*(3-a))&63)}}}return f.replace(/AAA\=(\=*?)$/,"$1")}function hex_md5(a){return binl2hex(core_md5(str2binl(a),a.length*chrsz))}function b64_md5(a){return binl2b64(core_md5(str2binl(a),a.length*chrsz))}function str_md5(a){return binl2str(core_md5(str2binl(a),a.length*chrsz))}function hex_hmac_md5(a,b){return binl2hex(core_hmac_md5(a,b))}function b64_hmac_md5(a,b){return binl2b64(core_hmac_md5(a,b))}function str_hmac_md5(a,b){return binl2str(core_hmac_md5(a,b))}function md5_vm_test(){return hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72"}function core_md5(p,k){p[k>>5]|=128<<((k)%32);p[(((k+64)>>>9)<<4)+14]=k;var o=1732584193;var n=-271733879;var m=-1732584194;var l=271733878;for(var g=0;g<p.length;g+=16){var j=o;var h=n;var f=m;var e=l;o=md5_ff(o,n,m,l,p[g+0],7,-680876936);l=md5_ff(l,o,n,m,p[g+1],12,-389564586);m=md5_ff(m,l,o,n,p[g+2],17,606105819);n=md5_ff(n,m,l,o,p[g+3],22,-1044525330);o=md5_ff(o,n,m,l,p[g+4],7,-176418897);l=md5_ff(l,o,n,m,p[g+5],12,1200080426);m=md5_ff(m,l,o,n,p[g+6],17,-1473231341);n=md5_ff(n,m,l,o,p[g+7],22,-45705983);o=md5_ff(o,n,m,l,p[g+8],7,1770035416);l=md5_ff(l,o,n,m,p[g+9],12,-1958414417);m=md5_ff(m,l,o,n,p[g+10],17,-42063);n=md5_ff(n,m,l,o,p[g+11],22,-1990404162);o=md5_ff(o,n,m,l,p[g+12],7,1804603682);l=md5_ff(l,o,n,m,p[g+13],12,-40341101);m=md5_ff(m,l,o,n,p[g+14],17,-1502002290);n=md5_ff(n,m,l,o,p[g+15],22,1236535329);o=md5_gg(o,n,m,l,p[g+1],5,-165796510);l=md5_gg(l,o,n,m,p[g+6],9,-1069501632);m=md5_gg(m,l,o,n,p[g+11],14,643717713);n=md5_gg(n,m,l,o,p[g+0],20,-373897302);o=md5_gg(o,n,m,l,p[g+5],5,-701558691);l=md5_gg(l,o,n,m,p[g+10],9,38016083);m=md5_gg(m,l,o,n,p[g+15],14,-660478335);n=md5_gg(n,m,l,o,p[g+4],20,-405537848);o=md5_gg(o,n,m,l,p[g+9],5,568446438);l=md5_gg(l,o,n,m,p[g+14],9,-1019803690);m=md5_gg(m,l,o,n,p[g+3],14,-187363961);n=md5_gg(n,m,l,o,p[g+8],20,1163531501);o=md5_gg(o,n,m,l,p[g+13],5,-1444681467);l=md5_gg(l,o,n,m,p[g+2],9,-51403784);m=md5_gg(m,l,o,n,p[g+7],14,1735328473);n=md5_gg(n,m,l,o,p[g+12],20,-1926607734);o=md5_hh(o,n,m,l,p[g+5],4,-378558);l=md5_hh(l,o,n,m,p[g+8],11,-2022574463);m=md5_hh(m,l,o,n,p[g+11],16,1839030562);n=md5_hh(n,m,l,o,p[g+14],23,-35309556);o=md5_hh(o,n,m,l,p[g+1],4,-1530992060);l=md5_hh(l,o,n,m,p[g+4],11,1272893353);m=md5_hh(m,l,o,n,p[g+7],16,-155497632);n=md5_hh(n,m,l,o,p[g+10],23,-1094730640);o=md5_hh(o,n,m,l,p[g+13],4,681279174);l=md5_hh(l,o,n,m,p[g+0],11,-358537222);m=md5_hh(m,l,o,n,p[g+3],16,-722521979);n=md5_hh(n,m,l,o,p[g+6],23,76029189);o=md5_hh(o,n,m,l,p[g+9],4,-640364487);l=md5_hh(l,o,n,m,p[g+12],11,-421815835);m=md5_hh(m,l,o,n,p[g+15],16,530742520);n=md5_hh(n,m,l,o,p[g+2],23,-995338651);o=md5_ii(o,n,m,l,p[g+0],6,-198630844);l=md5_ii(l,o,n,m,p[g+7],10,1126891415);m=md5_ii(m,l,o,n,p[g+14],15,-1416354905);n=md5_ii(n,m,l,o,p[g+5],21,-57434055);o=md5_ii(o,n,m,l,p[g+12],6,1700485571);l=md5_ii(l,o,n,m,p[g+3],10,-1894986606);m=md5_ii(m,l,o,n,p[g+10],15,-1051523);n=md5_ii(n,m,l,o,p[g+1],21,-2054922799);o=md5_ii(o,n,m,l,p[g+8],6,1873313359);l=md5_ii(l,o,n,m,p[g+15],10,-30611744);m=md5_ii(m,l,o,n,p[g+6],15,-1560198380);n=md5_ii(n,m,l,o,p[g+13],21,1309151649);o=md5_ii(o,n,m,l,p[g+4],6,-145523070);l=md5_ii(l,o,n,m,p[g+11],10,-1120210379);m=md5_ii(m,l,o,n,p[g+2],15,718787259);n=md5_ii(n,m,l,o,p[g+9],21,-343485551);o=safe_add(o,j);n=safe_add(n,h);m=safe_add(m,f);l=safe_add(l,e)}return Array(o,n,m,l)}function md5_cmn(h,e,d,c,g,f){return safe_add(bit_rol(safe_add(safe_add(e,h),safe_add(c,f)),g),d)}function md5_ff(g,f,k,j,e,i,h){return md5_cmn((f&k)|((~f)&j),g,f,e,i,h)}function md5_gg(g,f,k,j,e,i,h){return md5_cmn((f&j)|(k&(~j)),g,f,e,i,h)}function md5_hh(g,f,k,j,e,i,h){return md5_cmn(f^k^j,g,f,e,i,h)}function md5_ii(g,f,k,j,e,i,h){return md5_cmn(k^(f|(~j)),g,f,e,i,h)}function core_hmac_md5(c,f){var e=str2binl(c);if(e.length>16){e=core_md5(e,c.length*chrsz)}var a=Array(16),d=Array(16);for(var b=0;b<16;b++){a[b]=e[b]^909522486;d[b]=e[b]^1549556828}var g=core_md5(a.concat(str2binl(f)),512+f.length*chrsz);return core_md5(d.concat(g),512+128)}function safe_add(a,d){var c=(a&65535)+(d&65535);var b=(a>>16)+(d>>16)+(c>>16);return(b<<16)|(c&65535)}function bit_rol(a,b){return(a<<b)|(a>>>(32-b))}function str2binl(d){var c=Array();var a=(1<<chrsz)-1;for(var b=0;b<d.length*chrsz;b+=chrsz){c[b>>5]|=(d.charCodeAt(b/chrsz)&a)<<(b%32)}return c}function binl2str(c){var d="";var a=(1<<chrsz)-1;for(var b=0;b<c.length*32;b+=chrsz){d+=String.fromCharCode((c[b>>5]>>>(b%32))&a)}return d}function binl2hex(c){var b=hexcase?"0123456789ABCDEF":"0123456789abcdef";var d="";for(var a=0;a<c.length*4;a++){d+=b.charAt((c[a>>2]>>((a%4)*8+4))&15)+b.charAt((c[a>>2]>>((a%4)*8))&15)}return d}function binl2b64(d){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var f="";for(var b=0;b<d.length*4;b+=3){var e=(((d[b>>2]>>8*(b%4))&255)<<16)|(((d[b+1>>2]>>8*((b+1)%4))&255)<<8)|((d[b+2>>2]>>8*((b+2)%4))&255);for(var a=0;a<4;a++){if(b*8+a*6>d.length*32){f+=b64pad}else{f+=c.charAt((e>>6*(3-a))&63)}}}return f}function utf8t2d(a){a=a.replace(/\r\n/g,"\n");var b=new Array;var g=String.fromCharCode(237);if(g.charCodeAt(0)<0){for(var f=0;f<a.length;f++){var e=a.charCodeAt(f);if(e>0){b[b.length]=e}else{b[b.length]=(((256+e)>>6)|192);b[b.length]=(((256+e)&63)|128)}}}else{for(var f=0;f<a.length;f++){var e=a.charCodeAt(f);if(e<128){b[b.length]=e}else{if((e>127)&&(e<2048)){b[b.length]=((e>>6)|192);b[b.length]=((e&63)|128)}else{b[b.length]=((e>>12)|224);b[b.length]=(((e>>6)&63)|128);b[b.length]=((e&63)|128)}}}}return b}function utf8d2t(c){var b=new Array;var a=0;while(a<c.length){if(c[a]<128){b[b.length]=String.fromCharCode(c[a]);a++}else{if((c[a]>191)&&(c[a]<224)){b[b.length]=String.fromCharCode(((c[a]&31)<<6)|(c[a+1]&63));a+=2}else{b[b.length]=String.fromCharCode(((c[a]&15)<<12)|((c[a+1]&63)<<6)|(c[a+2]&63));a+=3}}}return b.join("")}function b64arrays(){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b64=new Array();f64=new Array();for(var a=0;a<b.length;a++){b64[a]=b.charAt(a);f64[b.charAt(a)]=a}}function b64d2t(f){var e=new Array;var c=0;var a=f.length;if((a%3)==1){f[f.length]=0;f[f.length]=0}if((a%3)==2){f[f.length]=0}while(c<f.length){e[e.length]=b64[f[c]>>2];e[e.length]=b64[((f[c]&3)<<4)|(f[c+1]>>4)];e[e.length]=b64[((f[c+1]&15)<<2)|(f[c+2]>>6)];e[e.length]=b64[f[c+2]&63];c+=3}if((a%3)==1){e[e.length-1]=e[e.length-2]="="}if((a%3)==2){e[e.length-1]="="}var b=e.join("");return b}function b64t2d(b){var c=new Array;var a=0;b=b.replace(/\n|\r/g,"");b=b.replace(/=/g,"");while(a<b.length){c[c.length]=(f64[b.charAt(a)]<<2)|(f64[b.charAt(a+1)]>>4);c[c.length]=(((f64[b.charAt(a+1)]&15)<<4)|(f64[b.charAt(a+2)]>>2));c[c.length]=(((f64[b.charAt(a+2)]&3)<<6)|(f64[b.charAt(a+3)]));a+=4}if(b.length%4==2){c=c.slice(0,c.length-2)}if(b.length%4==3){c=c.slice(0,c.length-1)}return c}if(typeof(atob)=="undefined"||typeof(btoa)=="undefined"){b64arrays()}if(typeof(atob)=="undefined"){atob=function(a){return utf8d2t(b64t2d(a))}}if(typeof(btoa)=="undefined"){btoa=function(a){return b64d2t(utf8t2d(a))}}function cnonce(b){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var d="";for(var a=0;a<b;a++){d+=c.charAt(Math.round(Math.random(new Date().getTime())*(c.length-1)))}return d}function JSJaCJSON(){}JSJaCJSON.toString=function(c){var a={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},b={array:function(g){var j=["["],d,n,m,h=g.length,k;for(m=0;m<h;m+=1){k=g[m];n=b[typeof k];if(n){try{k=n(k);if(typeof k=="string"){if(d){j[j.length]=","}j[j.length]=k;d=true}}catch(o){}}}j[j.length]="]";return j.join("")},"boolean":function(d){return String(d)},"null":function(d){return"null"},number:function(d){return isFinite(d)?String(d):"null"},object:function(g){if(g){if(g instanceof Array){return b.array(g)}var h=["{"],d,l,k,j;for(k in g){if(g.hasOwnProperty(k)){j=g[k];l=b[typeof j];if(l){try{j=l(j);if(typeof j=="string"){if(d){h[h.length]=","}h.push(b.string(k),":",j);d=true}}catch(m){}}}}h[h.length]="}";return h.join("")}return"null"},string:function(d){if(/["\\\x00-\x1f]/.test(d)){d=d.replace(/([\x00-\x1f\\"])/g,function(f,e){var g=a[e];if(g){return g}g=e.charCodeAt();return"\\u00"+Math.floor(g/16).toString(16)+(g%16).toString(16)})}return'"'+d+'"'}};switch(typeof(c)){case"object":return b.object(c);case"array":return b.array(c)}};JSJaCJSON.parse=function(str){try{return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(str.replace(/"(\\.|[^"\\])*"/g,"")))&&eval("("+str+")")}catch(e){return false}};function XmlHttp(){}XmlHttp.create=function(){try{if(window.XMLHttpRequest){var b=new XMLHttpRequest();if(b.readyState==null){b.readyState=1;b.addEventListener("load",function(){b.readyState=4;if(typeof b.onreadystatechange=="function"){b.onreadystatechange()}},false)}return b}if(window.ActiveXObject){return new ActiveXObject(XmlHttp.getPrefix()+".XmlHttp")}}catch(a){}throw new Error("Your browser does not support XmlHttp objects")};XmlHttp.getPrefix=function(){if(XmlHttp.prefix){return XmlHttp.prefix}var c=["MSXML2","Microsoft","MSXML","MSXML3"];var d;for(var b=0;b<c.length;b++){try{d=new ActiveXObject(c[b]+".XmlHttp");return XmlHttp.prefix=c[b]}catch(a){}}throw new Error("Could not find an installed XML parser")};function XmlDocument(){}XmlDocument.create=function(b,d){b=b||"foo";d=d||"";try{var e;if(document.implementation&&document.implementation.createDocument){e=document.implementation.createDocument(d,b,null);if(e.readyState==null){e.readyState=1;e.addEventListener("load",function(){e.readyState=4;if(typeof e.onreadystatechange=="function"){e.onreadystatechange()}},false)}}else{if(window.ActiveXObject){e=new ActiveXObject(XmlDocument.getPrefix()+".DomDocument")}}if(!e.documentElement||e.documentElement.tagName!=b||(e.documentElement.namespaceURI&&e.documentElement.namespaceURI!=d)){try{if(d!=""){e.appendChild(e.createElement(b)).setAttribute("xmlns",d)}else{e.appendChild(e.createElement(b))}}catch(a){e=document.implementation.createDocument(d,b,null);if(e.documentElement==null){e.appendChild(e.createElement(b))}if(d!=""&&e.documentElement.getAttribute("xmlns")!=d){e.documentElement.setAttribute("xmlns",d)}}}return e}catch(c){}throw new Error("Your browser does not support XmlDocument objects")};XmlDocument.getPrefix=function(){if(XmlDocument.prefix){return XmlDocument.prefix}var c=["MSXML2","Microsoft","MSXML","MSXML3"];var d;for(var b=0;b<c.length;b++){try{d=new ActiveXObject(c[b]+".DomDocument");return XmlDocument.prefix=c[b]}catch(a){}}throw new Error("Could not find an installed XML parser")};if(typeof(Document)!="undefined"&&window.DOMParser){Document.prototype.loadXML=function(b){var c=(new DOMParser()).parseFromString(b,"text/xml");while(this.hasChildNodes()){this.removeChild(this.lastChild)}for(var a=0;a<c.childNodes.length;a++){this.appendChild(this.importNode(c.childNodes[a],true))}}}if(window.XMLSerializer&&window.Node&&Node.prototype&&Node.prototype.__defineGetter__){XMLDocument.prototype.__defineGetter__("xml",function(){return(new XMLSerializer()).serializeToString(this)});Document.prototype.__defineGetter__("xml",function(){return(new XMLSerializer()).serializeToString(this)});Node.prototype.__defineGetter__("xml",function(){return(new XMLSerializer()).serializeToString(this)})}var JSJaCBuilder={buildNode:function(d,a){var b,c=arguments[4];if(arguments[2]){if(JSJaCBuilder._isStringOrNumber(arguments[2])||(arguments[2] instanceof Array)){b=this._createElement(d,a,c);JSJaCBuilder._children(d,b,arguments[2])}else{c=arguments[2]["xmlns"]||c;b=this._createElement(d,a,c);for(attr in arguments[2]){if(arguments[2].hasOwnProperty(attr)&&attr!="xmlns"){b.setAttribute(attr,arguments[2][attr])}}}}else{b=this._createElement(d,a,c)}if(arguments[3]){JSJaCBuilder._children(d,b,arguments[3],c)}return b},_createElement:function(e,a,d){try{if(d){return e.createElementNS(d,a)}}catch(b){}var c=e.createElement(a);if(d){c.setAttribute("xmlns",d)}return c},_text:function(a,b){return a.createTextNode(b)},_children:function(h,c,b,d){if(typeof b=="object"){for(var a in b){if(b.hasOwnProperty(a)){var g=b[a];if(typeof g=="object"){if(g instanceof Array){var f=JSJaCBuilder.buildNode(h,g[0],g[1],g[2],d);c.appendChild(f)}else{c.appendChild(g)}}else{if(JSJaCBuilder._isStringOrNumber(g)){c.appendChild(JSJaCBuilder._text(h,g))}}}}}else{if(JSJaCBuilder._isStringOrNumber(b)){c.appendChild(JSJaCBuilder._text(h,b))}}},_attributes:function(a){var b=[];for(attribute in a){if(a.hasOwnProperty(attribute)){b.push(attribute+'="'+a[attribute].toString().htmlEnc()+'"')}}return b.join(" ")},_isStringOrNumber:function(a){return(typeof a=="string"||typeof a=="number")}};var NS_DISCO_ITEMS="http://jabber.org/protocol/disco#items";var NS_DISCO_INFO="http://jabber.org/protocol/disco#info";var NS_VCARD="vcard-temp";var NS_AUTH="jabber:iq:auth";var NS_AUTH_ERROR="jabber:iq:auth:error";var NS_REGISTER="jabber:iq:register";var NS_SEARCH="jabber:iq:search";var NS_ROSTER="jabber:iq:roster";var NS_PRIVACY="jabber:iq:privacy";var NS_PRIVATE="jabber:iq:private";var NS_VERSION="jabber:iq:version";var NS_TIME="jabber:iq:time";var NS_LAST="jabber:iq:last";var NS_XDATA="jabber:x:data";var NS_IQDATA="jabber:iq:data";var NS_DELAY="jabber:x:delay";var NS_EXPIRE="jabber:x:expire";var NS_EVENT="jabber:x:event";var NS_XCONFERENCE="jabber:x:conference";var NS_STATS="http://jabber.org/protocol/stats";var NS_MUC="http://jabber.org/protocol/muc";var NS_MUC_USER="http://jabber.org/protocol/muc#user";var NS_MUC_ADMIN="http://jabber.org/protocol/muc#admin";var NS_MUC_OWNER="http://jabber.org/protocol/muc#owner";var NS_PUBSUB="http://jabber.org/protocol/pubsub";var NS_PUBSUB_EVENT="http://jabber.org/protocol/pubsub#event";var NS_PUBSUB_OWNER="http://jabber.org/protocol/pubsub#owner";var NS_PUBSUB_NMI="http://jabber.org/protocol/pubsub#node-meta-info";var NS_COMMANDS="http://jabber.org/protocol/commands";var NS_STREAM="http://etherx.jabber.org/streams";var NS_STANZAS="urn:ietf:params:xml:ns:xmpp-stanzas";var NS_STREAMS="urn:ietf:params:xml:ns:xmpp-streams";var NS_TLS="urn:ietf:params:xml:ns:xmpp-tls";var NS_SASL="urn:ietf:params:xml:ns:xmpp-sasl";var NS_SESSION="urn:ietf:params:xml:ns:xmpp-session";var NS_BIND="urn:ietf:params:xml:ns:xmpp-bind";var NS_FEATURE_IQAUTH="http://jabber.org/features/iq-auth";var NS_FEATURE_IQREGISTER="http://jabber.org/features/iq-register";var NS_FEATURE_COMPRESS="http://jabber.org/features/compress";var NS_COMPRESS="http://jabber.org/protocol/compress";function STANZA_ERROR(c,b,a){if(window==this){return new STANZA_ERROR(c,b,a)}this.code=c;this.type=b;this.cond=a}var ERR_BAD_REQUEST=STANZA_ERROR("400","modify","bad-request");var ERR_CONFLICT=STANZA_ERROR("409","cancel","conflict");var ERR_FEATURE_NOT_IMPLEMENTED=STANZA_ERROR("501","cancel","feature-not-implemented");var ERR_FORBIDDEN=STANZA_ERROR("403","auth","forbidden");var ERR_GONE=STANZA_ERROR("302","modify","gone");var ERR_INTERNAL_SERVER_ERROR=STANZA_ERROR("500","wait","internal-server-error");var ERR_ITEM_NOT_FOUND=STANZA_ERROR("404","cancel","item-not-found");var ERR_JID_MALFORMED=STANZA_ERROR("400","modify","jid-malformed");var ERR_NOT_ACCEPTABLE=STANZA_ERROR("406","modify","not-acceptable");var ERR_NOT_ALLOWED=STANZA_ERROR("405","cancel","not-allowed");var ERR_NOT_AUTHORIZED=STANZA_ERROR("401","auth","not-authorized");var ERR_PAYMENT_REQUIRED=STANZA_ERROR("402","auth","payment-required");var ERR_RECIPIENT_UNAVAILABLE=STANZA_ERROR("404","wait","recipient-unavailable");var ERR_REDIRECT=STANZA_ERROR("302","modify","redirect");var ERR_REGISTRATION_REQUIRED=STANZA_ERROR("407","auth","registration-required");var ERR_REMOTE_SERVER_NOT_FOUND=STANZA_ERROR("404","cancel","remote-server-not-found");var ERR_REMOTE_SERVER_TIMEOUT=STANZA_ERROR("504","wait","remote-server-timeout");var ERR_RESOURCE_CONSTRAINT=STANZA_ERROR("500","wait","resource-constraint");var ERR_SERVICE_UNAVAILABLE=STANZA_ERROR("503","cancel","service-unavailable");var ERR_SUBSCRIPTION_REQUIRED=STANZA_ERROR("407","auth","subscription-required");var ERR_UNEXPECTED_REQUEST=STANZA_ERROR("400","wait","unexpected-request");function JSJaCConsoleLogger(a){this.level=a||4;this.start=function(){};this.log=function(c,d){d=d||0;if(d>this.level){return}if(typeof(console)=="undefined"){return}try{switch(d){case 0:console.warn(c);break;case 1:console.error(c);break;case 2:console.info(c);break;case 4:console.debug(c);break;default:console.log(c);break}}catch(b){try{console.log(c)}catch(b){}}};this.setLevel=function(b){this.level=b;return this};this.getLevel=function(){return this.level}}function JSJaCCookie(a,d,b,c,e){if(window==this){return new JSJaCCookie(a,d,b,c,e)}this.name=a;this.value=d;this.secs=b;this.domain=c;this.path=e;this.write=function(){if(this.secs){var g=new Date();g.setTime(g.getTime()+(this.secs*1000));var f="; expires="+g.toGMTString()}else{var f=""}var h=this.domain?"; domain="+this.domain:"";var i=this.path?"; path="+this.path:"; path=/";document.cookie=this.getName()+"="+JSJaCCookie._escape(this.getValue())+f+h+i};this.erase=function(){var f=new JSJaCCookie(this.getName(),"",-1);f.write()};this.getName=function(){return this.name};this.setName=function(f){this.name=f;return this};this.getValue=function(){return this.value};this.setValue=function(f){this.value=f;return this};this.setDomain=function(f){this.domain=f;return this};this.setPath=function(f){this.path=f;return this}}JSJaCCookie.read=function(b){var e=b+"=";var a=document.cookie.split(";");for(var d=0;d<a.length;d++){var f=a[d];while(f.charAt(0)==" "){f=f.substring(1,f.length)}if(f.indexOf(e)==0){return new JSJaCCookie(b,JSJaCCookie._unescape(f.substring(e.length,f.length)))}}throw new JSJaCCookieException("Cookie not found")};JSJaCCookie.get=function(a){return JSJaCCookie.read(a).getValue()};JSJaCCookie.remove=function(a){JSJaCCookie.read(a).erase()};JSJaCCookie._escape=function(a){return a.replace(/;/g,"%3AB")};JSJaCCookie._unescape=function(a){return a.replace(/%3AB/g,";")};function JSJaCCookieException(a){this.message=a;this.name="CookieException"}function JSJaCError(c,b,d){var a=XmlDocument.create("error","jsjac");a.documentElement.setAttribute("code",c);a.documentElement.setAttribute("type",b);if(d){a.documentElement.appendChild(a.createElement(d)).setAttribute("xmlns","urn:ietf:params:xml:ns:xmpp-stanzas")}return a.documentElement}var JSJACJID_FORBIDDEN=['"'," ","&","'","/",":","<",">","@"];function JSJaCJID(a){this._node="";this._domain="";this._resource="";if(typeof(a)=="string"){if(a.indexOf("@")!=-1){this.setNode(a.substring(0,a.indexOf("@")));a=a.substring(a.indexOf("@")+1)}if(a.indexOf("/")!=-1){this.setResource(a.substring(a.indexOf("/")+1));a=a.substring(0,a.indexOf("/"))}this.setDomain(a)}else{this.setNode(a.node);this.setDomain(a.domain);this.setResource(a.resource)}}JSJaCJID.prototype.getNode=function(){return this._node};JSJaCJID.prototype.getDomain=function(){return this._domain};JSJaCJID.prototype.getResource=function(){return this._resource};JSJaCJID.prototype.setNode=function(a){JSJaCJID._checkNodeName(a);this._node=a||"";return this};JSJaCJID.prototype.setDomain=function(a){if(!a||a==""){throw new JSJaCJIDInvalidException("domain name missing")}JSJaCJID._checkNodeName(a);this._domain=a;return this};JSJaCJID.prototype.setResource=function(a){this._resource=a||"";return this};JSJaCJID.prototype.toString=function(){var a="";if(this.getNode()&&this.getNode()!=""){a=this.getNode()+"@"}a+=this.getDomain();if(this.getResource()&&this.getResource()!=""){a+="/"+this.getResource()}return a};JSJaCJID.prototype.removeResource=function(){return this.setResource()};JSJaCJID.prototype.clone=function(){return new JSJaCJID(this.toString())};JSJaCJID.prototype.isEntity=function(a){if(typeof a=="string"){a=(new JSJaCJID(a))}a.removeResource();return(this.clone().removeResource().toString()===a.toString())};JSJaCJID._checkNodeName=function(a){if(!a||a==""){return}for(var b=0;b<JSJACJID_FORBIDDEN.length;b++){if(a.indexOf(JSJACJID_FORBIDDEN[b])!=-1){throw new JSJaCJIDInvalidException("forbidden char in nodename: "+JSJACJID_FORBIDDEN[b])}}};function JSJaCJIDInvalidException(a){this.message=a;this.name="JSJaCJIDInvalidException"}function JSJaCKeys(d,c){var a=Math.random();this._k=new Array();this._k[0]=a.toString();if(c){this.oDbg=c}else{this.oDbg={};this.oDbg.log=function(){}}if(d){for(var b=1;b<JSJAC_NKEYS;b++){this._k[b]=d(this._k[b-1]);c.log(b+": "+this._k[b],4)}}this._indexAt=JSJAC_NKEYS-1;this.getKey=function(){return this._k[this._indexAt--]};this.lastKey=function(){return(this._indexAt==0)};this.size=function(){return this._k.length};this._getSuspendVars=function(){return("_k,_indexAt").split(",")}}var JSJACPACKET_USE_XMLNS=true;function JSJaCPacket(a){this.name=a;if(typeof(JSJACPACKET_USE_XMLNS)!="undefined"&&JSJACPACKET_USE_XMLNS){this.doc=XmlDocument.create(a,"jabber:client")}else{this.doc=XmlDocument.create(a,"")}}JSJaCPacket.prototype.pType=function(){return this.name};JSJaCPacket.prototype.getDoc=function(){return this.doc};JSJaCPacket.prototype.getNode=function(){if(this.getDoc()&&this.getDoc().documentElement){return this.getDoc().documentElement}else{return null}};JSJaCPacket.prototype.setTo=function(a){if(!a||a==""){this.getNode().removeAttribute("to")}else{if(typeof(a)=="string"){this.getNode().setAttribute("to",a)}else{this.getNode().setAttribute("to",a.toString())}}return this};JSJaCPacket.prototype.setFrom=function(a){if(!a||a==""){this.getNode().removeAttribute("from")}else{if(typeof(a)=="string"){this.getNode().setAttribute("from",a)}else{this.getNode().setAttribute("from",a.toString())}}return this};JSJaCPacket.prototype.setID=function(a){if(!a||a==""){this.getNode().removeAttribute("id")}else{this.getNode().setAttribute("id",a)}return this};JSJaCPacket.prototype.setType=function(a){if(!a||a==""){this.getNode().removeAttribute("type")}else{this.getNode().setAttribute("type",a)}return this};JSJaCPacket.prototype.setXMLLang=function(a){if(!a||a==""){this.getNode().removeAttribute("xml:lang")}else{this.getNode().setAttribute("xml:lang",a)}return this};JSJaCPacket.prototype.getTo=function(){return this.getNode().getAttribute("to")};JSJaCPacket.prototype.getFrom=function(){return this.getNode().getAttribute("from")};JSJaCPacket.prototype.getToJID=function(){return new JSJaCJID(this.getTo())};JSJaCPacket.prototype.getFromJID=function(){return new JSJaCJID(this.getFrom())};JSJaCPacket.prototype.getID=function(){return this.getNode().getAttribute("id")};JSJaCPacket.prototype.getType=function(){return this.getNode().getAttribute("type")};JSJaCPacket.prototype.getXMLLang=function(){return this.getNode().getAttribute("xml:lang")};JSJaCPacket.prototype.getXMLNS=function(){return this.getNode().namespaceURI||this.getNode().getAttribute("xmlns")};JSJaCPacket.prototype.getChild=function(b,d){if(!this.getNode()){return null}b=b||"*";d=d||"*";if(this.getNode().getElementsByTagNameNS){return this.getNode().getElementsByTagNameNS(d,b).item(0)}var a=this.getNode().getElementsByTagName(b);if(d!="*"){for(var c=0;c<a.length;c++){if(a.item(c).namespaceURI==d||a.item(c).getAttribute("xmlns")==d){return a.item(c)}}}else{return a.item(0)}return null};JSJaCPacket.prototype.getChildVal=function(b,d){var e=this.getChild(b,d);var a="";if(e&&e.hasChildNodes()){for(var c=0;c<e.childNodes.length;c++){if(e.childNodes.item(c).nodeValue){a+=e.childNodes.item(c).nodeValue}}}return a};JSJaCPacket.prototype.clone=function(){return JSJaCPacket.wrapNode(this.getNode())};JSJaCPacket.prototype.isError=function(){return(this.getType()=="error")};JSJaCPacket.prototype.errorReply=function(a){var b=this.clone();b.setTo(this.getFrom());b.setFrom();b.setType("error");b.appendNode("error",{code:a.code,type:a.type},[[a.cond]]);return b};JSJaCPacket.prototype.xml=typeof XMLSerializer!="undefined"?function(){var a=(new XMLSerializer()).serializeToString(this.getNode());if(typeof(a)=="undefined"){a=(new XMLSerializer()).serializeToString(this.doc)}return a}:function(){return this.getDoc().xml};JSJaCPacket.prototype._getAttribute=function(a){return this.getNode().getAttribute(a)};if(document.ELEMENT_NODE==null){document.ELEMENT_NODE=1;document.ATTRIBUTE_NODE=2;document.TEXT_NODE=3;document.CDATA_SECTION_NODE=4;document.ENTITY_REFERENCE_NODE=5;document.ENTITY_NODE=6;document.PROCESSING_INSTRUCTION_NODE=7;document.COMMENT_NODE=8;document.DOCUMENT_NODE=9;document.DOCUMENT_TYPE_NODE=10;document.DOCUMENT_FRAGMENT_NODE=11;document.NOTATION_NODE=12}JSJaCPacket.prototype._importNode=function(f,b){switch(f.nodeType){case document.ELEMENT_NODE:if(this.getDoc().createElementNS){var e=this.getDoc().createElementNS(f.namespaceURI,f.nodeName)}else{var e=this.getDoc().createElement(f.nodeName)}if(f.attributes&&f.attributes.length>0){for(var d=0,c=f.attributes.length;d<c;d++){var a=f.attributes.item(d);if(a.nodeName=="xmlns"&&e.getAttribute("xmlns")!=null){continue}if(e.setAttributeNS&&a.namespaceURI){e.setAttributeNS(a.namespaceURI,a.nodeName,a.nodeValue)}else{e.setAttribute(a.nodeName,a.nodeValue)}}}if(b&&f.childNodes&&f.childNodes.length>0){for(var d=0,c=f.childNodes.length;d<c;d++){e.appendChild(this._importNode(f.childNodes.item(d),b))}}return e;break;case document.TEXT_NODE:case document.CDATA_SECTION_NODE:case document.COMMENT_NODE:return this.getDoc().createTextNode(f.nodeValue);break}};JSJaCPacket.prototype._setChildNode=function(g,b){var a=this.getChild(g);var d=this.getDoc().createTextNode(b);if(a){try{a.replaceChild(d,a.firstChild)}catch(f){}}else{try{a=this.getDoc().createElementNS(this.getNode().namespaceURI,g)}catch(c){a=this.getDoc().createElement(g)}this.getNode().appendChild(a);a.appendChild(d)}return a};JSJaCPacket.prototype.buildNode=function(a){return JSJaCBuilder.buildNode(this.getDoc(),a,arguments[1],arguments[2])};JSJaCPacket.prototype.appendNode=function(a){if(typeof a=="object"){return this.getNode().appendChild(a)}else{return this.getNode().appendChild(this.buildNode(a,arguments[1],arguments[2],null,this.getNode().namespaceURI))}};function JSJaCPresence(){this.base=JSJaCPacket;this.base("presence")}JSJaCPresence.prototype=new JSJaCPacket;JSJaCPresence.prototype.setStatus=function(a){this._setChildNode("status",a);return this};JSJaCPresence.prototype.setShow=function(a){if(a=="chat"||a=="away"||a=="xa"||a=="dnd"){this._setChildNode("show",a)}return this};JSJaCPresence.prototype.setPriority=function(a){this._setChildNode("priority",a);return this};JSJaCPresence.prototype.setPresence=function(b,a,c){if(b){this.setShow(b)}if(a){this.setStatus(a)}if(c){this.setPriority(c)}return this};JSJaCPresence.prototype.getStatus=function(){return this.getChildVal("status")};JSJaCPresence.prototype.getShow=function(){return this.getChildVal("show")};JSJaCPresence.prototype.getPriority=function(){return this.getChildVal("priority")};function JSJaCIQ(){this.base=JSJaCPacket;this.base("iq")}JSJaCIQ.prototype=new JSJaCPacket;JSJaCIQ.prototype.setIQ=function(c,a,b){if(c){this.setTo(c)}if(a){this.setType(a)}if(b){this.setID(b)}return this};JSJaCIQ.prototype.setQuery=function(c){var a;try{a=this.getDoc().createElementNS(c,"query")}catch(b){a=this.getDoc().createElement("query");a.setAttribute("xmlns",c)}this.getNode().appendChild(a);return a};JSJaCIQ.prototype.getQuery=function(){return this.getNode().getElementsByTagName("query").item(0)};JSJaCIQ.prototype.getQueryXMLNS=function(){if(this.getQuery()){return this.getQuery().namespaceURI||this.getQuery().getAttribute("xmlns")}else{return null}};JSJaCIQ.prototype.reply=function(d){var b=this.clone();b.setTo(this.getFrom());b.setFrom();b.setType("result");if(d){if(typeof d=="string"){b.getChild().appendChild(b.getDoc().loadXML(d))}else{if(d.constructor==Array){var c=b.getChild();for(var a=0;a<d.length;a++){if(typeof d[a]=="string"){c.appendChild(b.getDoc().loadXML(d[a]))}else{if(typeof d[a]=="object"){c.appendChild(d[a])}}}}else{if(typeof d=="object"){b.getChild().appendChild(d)}}}}return b};function JSJaCMessage(){this.base=JSJaCPacket;this.base("message")}JSJaCMessage.prototype=new JSJaCPacket;JSJaCMessage.prototype.setBody=function(a){this._setChildNode("body",a);return this};JSJaCMessage.prototype.setSubject=function(a){this._setChildNode("subject",a);return this};JSJaCMessage.prototype.setThread=function(a){this._setChildNode("thread",a);return this};JSJaCMessage.prototype.getThread=function(){return this.getChildVal("thread")};JSJaCMessage.prototype.getBody=function(){return this.getChildVal("body")};JSJaCMessage.prototype.getSubject=function(){return this.getChildVal("subject")};JSJaCPacket.wrapNode=function(b){var a=null;switch(b.nodeName.toLowerCase()){case"presence":a=new JSJaCPresence();break;case"message":a=new JSJaCMessage();break;case"iq":a=new JSJaCIQ();break}if(a){a.getDoc().replaceChild(a._importNode(b,true),a.getNode())}return a};function JSJaCConnection(a){if(a&&a.oDbg&&a.oDbg.log){this.oDbg=a.oDbg}else{this.oDbg=new Object();this.oDbg.log=function(){}}if(a&&a.timerval){this.setPollInterval(a.timerval)}else{this.setPollInterval(JSJAC_TIMERVAL)}if(a&&a.httpbase){this._httpbase=a.httpbase}if(a&&a.allow_plain){this.allow_plain=a.allow_plain}else{this.allow_plain=JSJAC_ALLOW_PLAIN}if(a&&a.cookie_prefix){this._cookie_prefix=a.cookie_prefix}else{this._cookie_prefix=""}this._connected=false;this._events=new Array();this._keys=null;this._ID=0;this._inQ=new Array();this._pQueue=new Array();this._regIDs=new Array();this._req=new Array();this._status="intialized";this._errcnt=0;this._inactivity=JSJAC_INACTIVITY;this._sendRawCallbacks=new Array()}JSJaCConnection.prototype.connect=function(a){this._setStatus("connecting");this.domain=a.domain||"localhost";this.username=a.username;this.resource=a.resource;this.pass=a.pass;this.register=a.register;this.authhost=a.authhost||this.domain;this.authtype=a.authtype||"sasl";if(a.xmllang&&a.xmllang!=""){this._xmllang=a.xmllang}this.host=a.host||this.domain;this.port=a.port||5222;if(a.secure){this.secure="true"}else{this.secure="false"}if(a.wait){this._wait=a.wait}this.jid=this.username+"@"+this.domain;this.fulljid=this.jid+"/"+this.resource;this._rid=Math.round(100000.5+(((900000.49999)-(100000.5))*Math.random()));var c=this._getFreeSlot();this._req[c]=this._setupRequest(true);var b=this._getInitialRequestString();this.oDbg.log(b,4);this._req[c].r.onreadystatechange=JSJaC.bind(function(){if(this._req[c].r.readyState==4){this.oDbg.log("async recv: "+this._req[c].r.responseText,4);this._handleInitialResponse(c)}},this);if(typeof(this._req[c].r.onerror)!="undefined"){this._req[c].r.onerror=JSJaC.bind(function(d){this.oDbg.log("XmlHttpRequest error",1);return false},this)}this._req[c].r.send(b)};JSJaCConnection.prototype.connected=function(){return this._connected};JSJaCConnection.prototype.disconnect=function(){this._setStatus("disconnecting");if(!this.connected()){return}this._connected=false;clearInterval(this._interval);clearInterval(this._inQto);if(this._timeout){clearTimeout(this._timeout)}var b=this._getFreeSlot();this._req[b]=this._setupRequest(false);request=this._getRequestString(false,true);this.oDbg.log("Disconnecting: "+request,4);this._req[b].r.send(request);try{JSJaCCookie.read(this._cookie_prefix+"JSJaC_State").erase()}catch(a){}this.oDbg.log("Disconnected: "+this._req[b].r.responseText,2);this._handleEvent("ondisconnect")};JSJaCConnection.prototype.getPollInterval=function(){return this._timerval};JSJaCConnection.prototype.registerHandler=function(event){event=event.toLowerCase();var eArg={handler:arguments[arguments.length-1],childName:"*",childNS:"*",type:"*"};if(arguments.length>2){eArg.childName=arguments[1]}if(arguments.length>3){eArg.childNS=arguments[2]}if(arguments.length>4){eArg.type=arguments[3]}if(!this._events[event]){this._events[event]=new Array(eArg)}else{this._events[event]=this._events[event].concat(eArg)}this._events[event]=this._events[event].sort(function(a,b){var aRank=0;var bRank=0;with(a){if(type=="*"){aRank++}if(childNS=="*"){aRank++}if(childName=="*"){aRank++}}with(b){if(type=="*"){bRank++}if(childNS=="*"){bRank++}if(childName=="*"){bRank++}}if(aRank>bRank){return 1}if(aRank<bRank){return -1}return 0});this.oDbg.log("registered handler for event '"+event+"'",2)};JSJaCConnection.prototype.unregisterHandler=function(e,d){e=e.toLowerCase();if(!this._events[e]){return}var a=this._events[e],c=new Array();for(var b=0;b<a.length;b++){if(a[b].handler!=d){c.push(a[b])}}if(a.length!=c.length){this._events[e]=c;this.oDbg.log("unregistered handler for event '"+e+"'",2)}};JSJaCConnection.prototype.registerIQGet=function(a,b,c){this.registerHandler("iq",a,b,"get",c)};JSJaCConnection.prototype.registerIQSet=function(a,b,c){this.registerHandler("iq",a,b,"set",c)};JSJaCConnection.prototype.resume=function(){try{var a=JSJaCCookie.read(this._cookie_prefix+"JSJaC_State").getValue();this.oDbg.log("read cookie: "+a,2);JSJaCCookie.read(this._cookie_prefix+"JSJaC_State").erase();return this.resumeFromData(JSJaCJSON.parse(a))}catch(b){}return false};JSJaCConnection.prototype.resumeFromData=function(c){try{this._setStatus("resuming");for(var b in c){if(c.hasOwnProperty(b)){this[b]=c[b]}}if(this._keys){this._keys2=new JSJaCKeys();var a=this._keys2._getSuspendVars();for(var b=0;b<a.length;b++){this._keys2[a[b]]=this._keys[a[b]]}this._keys=this._keys2}if(this._connected){this._handleEvent("onresume");setTimeout(JSJaC.bind(this._resume,this),this.getPollInterval());this._interval=setInterval(JSJaC.bind(this._checkQueue,this),JSJAC_CHECKQUEUEINTERVAL);this._inQto=setInterval(JSJaC.bind(this._checkInQ,this),JSJAC_CHECKINQUEUEINTERVAL)}return(this._connected===true)}catch(d){if(d.message){this.oDbg.log("Resume failed: "+d.message,1)}else{this.oDbg.log("Resume failed: "+d,1)}return false}};JSJaCConnection.prototype.send=function(d,b,a){if(!d||!d.pType){this.oDbg.log("no packet: "+d,1);return false}if(!this.connected()){return false}if(b){if(!d.getID()){d.setID("JSJaCID_"+this._ID++)}this._registerPID(d.getID(),b,a)}try{this._handleEvent(d.pType()+"_out",d);this._handleEvent("packet_out",d);this._pQueue=this._pQueue.concat(d.xml())}catch(c){this.oDbg.log(c.toString(),1);return false}return true};JSJaCConnection.prototype.sendIQ=function(e,c,a){if(!e||e.pType()!="iq"){return false}c=c||{};var b=c.error_handler||JSJaC.bind(function(g){this.oDbg.log(g.xml(),1)},this);var d=c.result_handler||JSJaC.bind(function(g){this.oDbg.log(g.xml(),2)},this);var f=function(h,g){switch(h.getType()){case"error":b(h);break;case"result":d(h,g);break}};return this.send(e,f,a)};JSJaCConnection.prototype.setPollInterval=function(a){if(a&&!isNaN(a)){this._timerval=a}return this._timerval};JSJaCConnection.prototype.status=function(){return this._status};JSJaCConnection.prototype.suspend=function(){var b=this.suspendToData();try{var f=new JSJaCCookie(this._cookie_prefix+"JSJaC_State",JSJaCJSON.toString(b));this.oDbg.log("writing cookie: "+f.getValue()+"\n(length:"+f.getValue().length+")",2);f.write();var a=JSJaCCookie.get(this._cookie_prefix+"JSJaC_State");if(f.getValue()!=a){this.oDbg.log("Suspend failed writing cookie.\nread: "+a,1);f.erase();return false}return true}catch(d){this.oDbg.log("Failed creating cookie '"+this._cookie_prefix+"JSJaC_State': "+d.message,1)}return false};JSJaCConnection.prototype.suspendToData=function(){clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);this._suspend();var c=("_connected,_keys,_ID,_inQ,_pQueue,_regIDs,_errcnt,_inactivity,domain,username,resource,jid,fulljid,_sid,_httpbase,_timerval,_is_polling").split(",");c=c.concat(this._getSuspendVars());var e=new Object();for(var d=0;d<c.length;d++){if(!this[c[d]]){continue}if(this[c[d]]._getSuspendVars){var a=this[c[d]]._getSuspendVars();var f=new Object();for(var b=0;b<a.length;b++){f[a[b]]=this[c[d]][a[b]]}}else{var f=this[c[d]]}e[c[d]]=f}this._connected=false;this._setStatus("suspending");return e};JSJaCConnection.prototype._abort=function(){clearTimeout(this._timeout);clearInterval(this._inQto);clearInterval(this._interval);this._connected=false;this._setStatus("aborted");this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect");this._handleEvent("onerror",JSJaCError("500","cancel","service-unavailable"))};JSJaCConnection.prototype._checkInQ=function(){for(var a=0;a<this._inQ.length&&a<10;a++){var b=this._inQ[0];this._inQ=this._inQ.slice(1,this._inQ.length);var c=JSJaCPacket.wrapNode(b);if(!c){return}this._handleEvent("packet_in",c);if(c.pType&&!this._handlePID(c)){this._handleEvent(c.pType()+"_in",c);this._handleEvent(c.pType(),c)}}};JSJaCConnection.prototype._checkQueue=function(){if(this._pQueue.length!=0){this._process()}return true};JSJaCConnection.prototype._doAuth=function(){if(this.has_sasl&&this.authtype=="nonsasl"){this.oDbg.log("Warning: SASL present but not used",1)}if(!this._doSASLAuth()&&!this._doLegacyAuth()){this.oDbg.log("Auth failed for authtype "+this.authtype,1);this.disconnect();return false}return true};JSJaCConnection.prototype._doInBandReg=function(){if(this.authtype=="saslanon"||this.authtype=="anonymous"){return}var a=new JSJaCIQ();a.setType("set");a.setID("reg1");a.appendNode("query",{xmlns:"jabber:iq:register"},[["username",this.username],["password",this.pass]]);this.send(a,this._doInBandRegDone)};JSJaCConnection.prototype._doInBandRegDone=function(a){if(a&&a.getType()=="error"){this.oDbg.log("registration failed for "+this.username,0);this._handleEvent("onerror",a.getChild("error"));return}this.oDbg.log(this.username+" registered succesfully",0);this._doAuth()};JSJaCConnection.prototype._doLegacyAuth=function(){if(this.authtype!="nonsasl"&&this.authtype!="anonymous"){return false}var a=new JSJaCIQ();a.setIQ(this.server,"get","auth1");a.appendNode("query",{xmlns:"jabber:iq:auth"},[["username",this.username]]);this.send(a,this._doLegacyAuth2);return true};JSJaCConnection.prototype._doLegacyAuth2=function(b){if(!b||b.getType()!="result"){if(b&&b.getType()=="error"){this._handleEvent("onerror",b.getChild("error"))}this.disconnect();return}var a=(b.getChild("digest")!=null);var b=new JSJaCIQ();b.setIQ(this.server,"set","auth2");query=b.appendNode("query",{xmlns:"jabber:iq:auth"},[["username",this.username],["resource",this.resource]]);if(a){query.appendChild(b.buildNode("digest",{xmlns:"jabber:iq:auth"},hex_sha1(this.streamid+this.pass)))}else{if(this.allow_plain){query.appendChild(b.buildNode("password",{xmlns:"jabber:iq:auth"},this.pass))}else{this.oDbg.log("no valid login mechanism found",1);this.disconnect();return false}}this.send(b,this._doLegacyAuthDone)};JSJaCConnection.prototype._doLegacyAuthDone=function(a){if(a.getType()!="result"){if(a.getType()=="error"){this._handleEvent("onerror",a.getChild("error"))}this.disconnect()}else{this._handleEvent("onconnect")}};JSJaCConnection.prototype._doSASLAuth=function(){if(this.authtype=="nonsasl"||this.authtype=="anonymous"){return false}if(this.authtype=="saslanon"){if(this.mechs.ANONYMOUS){this.oDbg.log("SASL using mechanism 'ANONYMOUS'",2);return this._sendRaw("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>",this._doSASLAuthDone)}this.oDbg.log("SASL ANONYMOUS requested but not supported",1)}else{if(this.mechs["DIGEST-MD5"]){this.oDbg.log("SASL using mechanism 'DIGEST-MD5'",2);return this._sendRaw("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/>",this._doSASLAuthDigestMd5S1)}else{if(this.allow_plain&&this.mechs.PLAIN){this.oDbg.log("SASL using mechanism 'PLAIN'",2);var a=this.username+"@"+this.domain+String.fromCharCode(0)+this.username+String.fromCharCode(0)+this.pass;this.oDbg.log("authenticating with '"+a+"'",2);a=btoa(a);return this._sendRaw("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>"+a+"</auth>",this._doSASLAuthDone)}}this.oDbg.log("No SASL mechanism applied",1);this.authtype="nonsasl"}return false};JSJaCConnection.prototype._doSASLAuthDigestMd5S1=function(e){if(e.nodeName!="challenge"){this.oDbg.log("challenge missing",1);this._handleEvent("onerror",JSJaCError("401","auth","not-authorized"));this.disconnect()}else{var d=atob(e.firstChild.nodeValue);this.oDbg.log("got challenge: "+d,2);this._nonce=d.substring(d.indexOf("nonce=")+7);this._nonce=this._nonce.substring(0,this._nonce.indexOf('"'));this.oDbg.log("nonce: "+this._nonce,2);if(this._nonce==""||this._nonce.indexOf('"')!=-1){this.oDbg.log("nonce not valid, aborting",1);this.disconnect();return}this._digest_uri="xmpp/";this._digest_uri+=this.domain;this._cnonce=cnonce(14);this._nc="00000001";var c=str_md5(this.username+":"+this.domain+":"+this.pass)+":"+this._nonce+":"+this._cnonce;var b="AUTHENTICATE:"+this._digest_uri;var a=hex_md5(hex_md5(c)+":"+this._nonce+":"+this._nc+":"+this._cnonce+":auth:"+hex_md5(b));var f='username="'+this.username+'",realm="'+this.domain+'",nonce="'+this._nonce+'",cnonce="'+this._cnonce+'",nc="'+this._nc+'",qop=auth,digest-uri="'+this._digest_uri+'",response="'+a+'",charset="utf-8"';this.oDbg.log("response: "+f,2);this._sendRaw("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"+binb2b64(str2binb(f))+"</response>",this._doSASLAuthDigestMd5S2)}};JSJaCConnection.prototype._doSASLAuthDigestMd5S2=function(e){if(e.nodeName=="failure"){if(e.xml){this.oDbg.log("auth error: "+e.xml,1)}else{this.oDbg.log("auth error",1)}this._handleEvent("onerror",JSJaCError("401","auth","not-authorized"));this.disconnect();return}var c=atob(e.firstChild.nodeValue);this.oDbg.log("response: "+c,2);var f=c.substring(c.indexOf("rspauth=")+8);this.oDbg.log("rspauth: "+f,2);var d=str_md5(this.username+":"+this.domain+":"+this.pass)+":"+this._nonce+":"+this._cnonce;var b=":"+this._digest_uri;var a=hex_md5(hex_md5(d)+":"+this._nonce+":"+this._nc+":"+this._cnonce+":auth:"+hex_md5(b));this.oDbg.log("rsptest: "+a,2);if(a!=f){this.oDbg.log("SASL Digest-MD5: server repsonse with wrong rspauth",1);this.disconnect();return}if(e.nodeName=="success"){this._reInitStream(this.domain,this._doStreamBind)}else{this._sendRaw("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>",this._doSASLAuthDone)}};JSJaCConnection.prototype._doSASLAuthDone=function(a){if(a.nodeName!="success"){this.oDbg.log("auth failed",1);this._handleEvent("onerror",JSJaCError("401","auth","not-authorized"));this.disconnect()}else{this._reInitStream(this.domain,this._doStreamBind)}};JSJaCConnection.prototype._doStreamBind=function(){var a=new JSJaCIQ();a.setIQ(null,"set","bind_1");a.appendNode("bind",{xmlns:"urn:ietf:params:xml:ns:xmpp-bind"},[["resource",this.resource]]);this.oDbg.log(a.xml());this.send(a,this._doXMPPSess)};JSJaCConnection.prototype._doXMPPSess=function(a){if(a.getType()!="result"||a.getType()=="error"){this.disconnect();if(a.getType()=="error"){this._handleEvent("onerror",a.getChild("error"))}return}this.fulljid=a.getChildVal("jid");this.jid=this.fulljid.substring(0,this.fulljid.lastIndexOf("/"));a=new JSJaCIQ();a.setIQ(this.domain,"set","sess_1");a.appendNode("session",{xmlns:"urn:ietf:params:xml:ns:xmpp-session"},[]);this.oDbg.log(a.xml());this.send(a,this._doXMPPSessDone)};JSJaCConnection.prototype._doXMPPSessDone=function(a){if(a.getType()!="result"||a.getType()=="error"){this.disconnect();if(a.getType()=="error"){this._handleEvent("onerror",a.getChild("error"))}return}else{this._handleEvent("onconnect")}};JSJaCConnection.prototype._handleEvent=function(d,a){d=d.toLowerCase();this.oDbg.log("incoming event '"+d+"'",3);if(!this._events[d]){return}this.oDbg.log("handling event '"+d+"'",2);for(var b=0;b<this._events[d].length;b++){var c=this._events[d][b];if(typeof c.handler=="function"){try{if(a){if(a.pType){if((!a.getNode().hasChildNodes()&&c.childName!="*")||(a.getNode().hasChildNodes()&&!a.getChild(c.childName,c.childNS))){continue}if(c.type!="*"&&a.getType()!=c.type){continue}this.oDbg.log(c.childName+"/"+c.childNS+"/"+c.type+" => match for handler "+c.handler,3)}if(c.handler(a)){break}}else{if(c.handler()){break}}}catch(f){if(f.fileName&&f.lineNumber){this.oDbg.log(c.handler+"\n>>>"+f.name+": "+f.message+" in "+f.fileName+" line "+f.lineNumber,1)}else{this.oDbg.log(c.handler+"\n>>>"+f.name+": "+f.message,1)}}}}};JSJaCConnection.prototype._handlePID=function(d){if(!d.getID()){return false}for(var b in this._regIDs){if(this._regIDs.hasOwnProperty(b)&&this._regIDs[b]&&b==d.getID()){var a=d.getID();this.oDbg.log("handling "+a,3);try{if(this._regIDs[b].cb.call(this,d,this._regIDs[b].arg)===false){return false}else{this._unregisterPID(a);return true}}catch(c){this.oDbg.log(c.name+": "+c.message,1);this._unregisterPID(a);return true}}}return false};JSJaCConnection.prototype._handleResponse=function(d){var c=this._parseResponse(d);if(!c){return}for(var b=0;b<c.childNodes.length;b++){if(this._sendRawCallbacks.length){var a=this._sendRawCallbacks[0];this._sendRawCallbacks=this._sendRawCallbacks.slice(1,this._sendRawCallbacks.length);a.fn.call(this,c.childNodes.item(b),a.arg);continue}this._inQ=this._inQ.concat(c.childNodes.item(b))}};JSJaCConnection.prototype._parseStreamFeatures=function(f){if(!f){this.oDbg.log("nothing to parse ... aborting",1);return false}var e;if(f.getElementsByTagNameNS){e=f.getElementsByTagNameNS("http://etherx.jabber.org/streams","error").item(0)}else{var g=f.getElementsByTagName("error");for(var b=0;b<g.length;b++){if(g.item(b).namespaceURI=="http://etherx.jabber.org/streams"){e=g.item(b);break}}}if(e){this._setStatus("internal_server_error");clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);this._handleEvent("onerror",JSJaCError("503","cancel","session-terminate"));this._connected=false;this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect");return false}this.mechs=new Object();var d=f.getElementsByTagName("mechanisms");this.has_sasl=false;for(var b=0;b<d.length;b++){if(d.item(b).getAttribute("xmlns")=="urn:ietf:params:xml:ns:xmpp-sasl"){this.has_sasl=true;var c=d.item(b).getElementsByTagName("mechanism");for(var a=0;a<c.length;a++){this.mechs[c.item(a).firstChild.nodeValue]=true}break}}if(this.has_sasl){this.oDbg.log("SASL detected",2)}else{this.oDbg.log("No support for SASL detected",2);return false}return true};JSJaCConnection.prototype._process=function(a){if(!this.connected()){this.oDbg.log("Connection lost ...",1);if(this._interval){clearInterval(this._interval)}return}this.setPollInterval(a);if(this._timeout){clearTimeout(this._timeout)}var d=this._getFreeSlot();if(d<0){return}if(typeof(this._req[d])!="undefined"&&typeof(this._req[d].r)!="undefined"&&this._req[d].r.readyState!=4){this.oDbg.log("Slot "+d+" is not ready");return}if(!this.isPolling()&&this._pQueue.length==0&&this._req[(d+1)%2]&&this._req[(d+1)%2].r.readyState!=4){this.oDbg.log("all slots busy, standby ...",2);return}if(!this.isPolling()){this.oDbg.log("Found working slot at "+d,2)}this._req[d]=this._setupRequest(true);this._req[d].r.onreadystatechange=JSJaC.bind(function(){if(!this.connected()){return}if(this._req[d].r.readyState==4){this._setStatus("processing");this.oDbg.log("async recv: "+this._req[d].r.responseText,4);this._handleResponse(this._req[d]);if(this._pQueue.length){this._timeout=setTimeout(JSJaC.bind(this._process,this),100)}else{this.oDbg.log("scheduling next poll in "+this.getPollInterval()+" msec",4);this._timeout=setTimeout(JSJaC.bind(this._process,this),this.getPollInterval())}}},this);try{this._req[d].r.onerror=JSJaC.bind(function(){if(!this.connected()){return}this._errcnt++;this.oDbg.log("XmlHttpRequest error ("+this._errcnt+")",1);if(this._errcnt>JSJAC_ERR_COUNT){this._abort();return false}this._setStatus("onerror_fallback");setTimeout(JSJaC.bind(this._resume,this),this.getPollInterval());return false},this)}catch(b){}var c=this._getRequestString();if(typeof(this._rid)!="undefined"){this._req[d].rid=this._rid}this.oDbg.log("sending: "+c,4);this._req[d].r.send(c)};JSJaCConnection.prototype._registerPID=function(c,b,a){if(!c||!b){return false}this._regIDs[c]=new Object();this._regIDs[c].cb=b;if(a){this._regIDs[c].arg=a}this.oDbg.log("registered "+c,3);return true};JSJaCConnection.prototype._sendEmpty=function JSJaCSendEmpty(){var b=this._getFreeSlot();this._req[b]=this._setupRequest(true);this._req[b].r.onreadystatechange=JSJaC.bind(function(){if(this._req[b].r.readyState==4){this.oDbg.log("async recv: "+this._req[b].r.responseText,4);this._getStreamID(b)}},this);if(typeof(this._req[b].r.onerror)!="undefined"){this._req[b].r.onerror=JSJaC.bind(function(c){this.oDbg.log("XmlHttpRequest error",1);return false},this)}var a=this._getRequestString();this.oDbg.log("sending: "+a,4);this._req[b].r.send(a)};JSJaCConnection.prototype._sendRaw=function(c,b,a){if(b){this._sendRawCallbacks.push({fn:b,arg:a})}this._pQueue.push(c);this._process();return true};JSJaCConnection.prototype._setStatus=function(a){if(!a||a==""){return}if(a!=this._status){this._status=a;this._handleEvent("onstatuschanged",a);this._handleEvent("status_changed",a)}};JSJaCConnection.prototype._unregisterPID=function(a){if(!this._regIDs[a]){return false}this._regIDs[a]=null;this.oDbg.log("unregistered "+a,3);return true};function JSJaCHttpBindingConnection(a){this.base=JSJaCConnection;this.base(a);this._hold=JSJACHBC_MAX_HOLD;this._inactivity=0;this._last_requests=new Object();this._last_rid=0;this._min_polling=0;this._pause=0;this._wait=JSJACHBC_MAX_WAIT}JSJaCHttpBindingConnection.prototype=new JSJaCConnection();JSJaCHttpBindingConnection.prototype.inherit=function(a){if(a.jid){var b=new JSJaCJID(a.jid);this.domain=b.getDomain();this.username=b.getNode();this.resource=b.getResource()}else{this.domain=a.domain||"localhost";this.username=a.username;this.resource=a.resource}this._sid=a.sid;this._rid=a.rid;this._min_polling=a.polling;this._inactivity=a.inactivity;this._setHold(a.requests-1);this.setPollInterval(this._timerval);if(a.wait){this._wait=a.wait}this._connected=true;this._handleEvent("onconnect");this._interval=setInterval(JSJaC.bind(this._checkQueue,this),JSJAC_CHECKQUEUEINTERVAL);this._inQto=setInterval(JSJaC.bind(this._checkInQ,this),JSJAC_CHECKINQUEUEINTERVAL);this._timeout=setTimeout(JSJaC.bind(this._process,this),this.getPollInterval())};JSJaCHttpBindingConnection.prototype.setPollInterval=function(a){if(a&&!isNaN(a)){if(!this.isPolling()){this._timerval=100}else{if(this._min_polling&&a<this._min_polling*1000){this._timerval=this._min_polling*1000}else{if(this._inactivity&&a>this._inactivity*1000){this._timerval=this._inactivity*1000}else{this._timerval=a}}}}return this._timerval};JSJaCHttpBindingConnection.prototype.isPolling=function(){return(this._hold==0)};JSJaCHttpBindingConnection.prototype._getFreeSlot=function(){for(var a=0;a<this._hold+1;a++){if(typeof(this._req[a])=="undefined"||typeof(this._req[a].r)=="undefined"||this._req[a].r.readyState==4){return a}}return -1};JSJaCHttpBindingConnection.prototype._getHold=function(){return this._hold};JSJaCHttpBindingConnection.prototype._getRequestString=function(b,e){b=b||"";var f="";if(this._rid<=this._last_rid&&typeof(this._last_requests[this._rid])!="undefined"){f=this._last_requests[this._rid].xml}else{var a="";while(this._pQueue.length){var d=this._pQueue[0];a+=d;this._pQueue=this._pQueue.slice(1,this._pQueue.length)}f="<body rid='"+this._rid+"' sid='"+this._sid+"' xmlns='http://jabber.org/protocol/httpbind' ";if(JSJAC_HAVEKEYS){f+="key='"+this._keys.getKey()+"' ";if(this._keys.lastKey()){this._keys=new JSJaCKeys(hex_sha1,this.oDbg);f+="newkey='"+this._keys.getKey()+"' "}}if(e){f+="type='terminate'"}else{if(this._reinit){if(JSJACHBC_USE_BOSH_VER){f+="xmpp:restart='true' xmlns:xmpp='urn:xmpp:xbosh'"}this._reinit=false}}if(a!=""||b!=""){f+=">"+b+a+"</body>"}else{f+="/>"}this._last_requests[this._rid]=new Object();this._last_requests[this._rid].xml=f;this._last_rid=this._rid;for(var c in this._last_requests){if(this._last_requests.hasOwnProperty(c)&&c<this._rid-this._hold){delete (this._last_requests[c])}}}return f};JSJaCHttpBindingConnection.prototype._getInitialRequestString=function(){var a="<body content='text/xml; charset=utf-8' hold='"+this._hold+"' xmlns='http://jabber.org/protocol/httpbind' to='"+this.authhost+"' wait='"+this._wait+"' rid='"+this._rid+"'";if(this.host||this.port){a+=" route='xmpp:"+this.host+":"+this.port+"'"}if(this.secure){a+=" secure='"+this.secure+"'"}if(JSJAC_HAVEKEYS){this._keys=new JSJaCKeys(hex_sha1,this.oDbg);key=this._keys.getKey();a+=" newkey='"+key+"'"}if(this._xmllang){a+=" xml:lang='"+this._xmllang+"'"}if(JSJACHBC_USE_BOSH_VER){a+=" ver='"+JSJACHBC_BOSH_VERSION+"'";a+=" xmlns:xmpp='urn:xmpp:xbosh'";if(this.authtype=="sasl"||this.authtype=="saslanon"){a+=" xmpp:version='1.0'"}}a+="/>";return a};JSJaCHttpBindingConnection.prototype._getStreamID=function(b){this.oDbg.log(this._req[b].r.responseText,4);if(!this._req[b].r.responseXML||!this._req[b].r.responseXML.documentElement){this._handleEvent("onerror",JSJaCError("503","cancel","service-unavailable"));return}var a=this._req[b].r.responseXML.documentElement;if(a.getAttribute("authid")){this.streamid=a.getAttribute("authid");this.oDbg.log("got streamid: "+this.streamid,2)}if(!this._parseStreamFeatures(a)||!this.streamid){this._timeout=setTimeout(JSJaC.bind(this._sendEmpty,this),this.getPollInterval());return}this._timeout=setTimeout(JSJaC.bind(this._process,this),this.getPollInterval());if(this.register){this._doInBandReg()}else{this._doAuth()}};JSJaCHttpBindingConnection.prototype._getSuspendVars=function(){return("host,port,secure,_rid,_last_rid,_wait,_min_polling,_inactivity,_hold,_last_requests,_pause").split(",")};JSJaCHttpBindingConnection.prototype._handleInitialResponse=function(c){try{this.oDbg.log(this._req[c].r.getAllResponseHeaders(),4);this.oDbg.log(this._req[c].r.responseText,4)}catch(b){this.oDbg.log("No response",4)}if(this._req[c].r.status!=200||!this._req[c].r.responseXML){this.oDbg.log("initial response broken (status: "+this._req[c].r.status+")",1);this._handleEvent("onerror",JSJaCError("503","cancel","service-unavailable"));return}var a=this._req[c].r.responseXML.documentElement;if(!a||a.tagName!="body"||a.namespaceURI!="http://jabber.org/protocol/httpbind"){this.oDbg.log("no body element or incorrect body in initial response",1);this._handleEvent("onerror",JSJaCError("500","wait","internal-service-error"));return}if(a.getAttribute("type")=="terminate"){this.oDbg.log("invalid response:\n"+this._req[c].r.responseText,1);clearTimeout(this._timeout);this._connected=false;this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect");this._handleEvent("onerror",JSJaCError("503","cancel","service-unavailable"));return}this._sid=a.getAttribute("sid");this.oDbg.log("got sid: "+this._sid,2);if(a.getAttribute("polling")){this._min_polling=a.getAttribute("polling")}if(a.getAttribute("inactivity")){this._inactivity=a.getAttribute("inactivity")}if(a.getAttribute("requests")){this._setHold(a.getAttribute("requests")-1)}this.oDbg.log("set hold to "+this._getHold(),2);if(a.getAttribute("ver")){this._bosh_version=a.getAttribute("ver")}if(a.getAttribute("maxpause")){this._pause=Number.min(a.getAttribute("maxpause"),JSJACHBC_MAXPAUSE)}this.setPollInterval(this._timerval);this._connected=true;this._inQto=setInterval(JSJaC.bind(this._checkInQ,this),JSJAC_CHECKINQUEUEINTERVAL);this._interval=setInterval(JSJaC.bind(this._checkQueue,this),JSJAC_CHECKQUEUEINTERVAL);this._getStreamID(c)};JSJaCHttpBindingConnection.prototype._parseResponse=function(c){if(!this.connected()||!c){return null}var b=c.r;try{if(b.status==404||b.status==403){this._abort();return null}if(b.status!=200||!b.responseXML){this._errcnt++;var g="invalid response ("+b.status+"):\n"+b.getAllResponseHeaders()+"\n"+b.responseText;if(!b.responseXML){g+="\nResponse failed to parse!"}this.oDbg.log(g,1);if(this._errcnt>JSJAC_ERR_COUNT){this._abort();return null}if(this.connected()){this.oDbg.log("repeating ("+this._errcnt+")",1);this._setStatus("proto_error_fallback");setTimeout(JSJaC.bind(this._resume,this),this.getPollInterval())}return null}}catch(d){this.oDbg.log("XMLHttpRequest error: status not available",1);this._errcnt++;if(this._errcnt>JSJAC_ERR_COUNT){this._abort()}else{if(this.connected()){this.oDbg.log("repeating ("+this._errcnt+")",1);this._setStatus("proto_error_fallback");setTimeout(JSJaC.bind(this._resume,this),this.getPollInterval())}}return null}var a=b.responseXML.documentElement;if(!a||a.tagName!="body"||a.namespaceURI!="http://jabber.org/protocol/httpbind"){this.oDbg.log("invalid response:\n"+b.responseText,1);clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);this._connected=false;this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect");this._setStatus("internal_server_error");this._handleEvent("onerror",JSJaCError("500","wait","internal-server-error"));return null}if(typeof(c.rid)!="undefined"&&this._last_requests[c.rid]){if(this._last_requests[c.rid].handled){this.oDbg.log("already handled "+c.rid,2);return null}else{this._last_requests[c.rid].handled=true}}if(a.getAttribute("type")=="terminate"){this.oDbg.log("session terminated:\n"+b.responseText,1);clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);var f=a.getAttribute("condition");if(f=="remote-stream-error"){if(a.getElementsByTagName("conflict").length>0){this._setStatus("session-terminate-conflict")}}if(f==null){f="session-terminate"}this._handleEvent("onerror",JSJaCError("503","cancel",f));this._connected=false;this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect");return null}this._errcnt=0;return b.responseXML.documentElement};JSJaCHttpBindingConnection.prototype._reInitStream=function(c,b,a){this._reinit=true;b.call(this,a)};JSJaCHttpBindingConnection.prototype._resume=function(){if(this._pause==0&&this._rid>=this._last_rid){this._rid=this._last_rid-1}this._process()};JSJaCHttpBindingConnection.prototype._setHold=function(a){if(!a||isNaN(a)||a<0){a=0}else{if(a>JSJACHBC_MAX_HOLD){a=JSJACHBC_MAX_HOLD}}this._hold=a;return this._hold};JSJaCHttpBindingConnection.prototype._setupRequest=function(a){var c=new Object();var b=XmlHttp.create();try{b.open("POST",this._httpbase,a);b.setRequestHeader("Content-Type","text/xml; charset=utf-8")}catch(d){this.oDbg.log(d,1)}c.r=b;this._rid++;c.rid=this._rid;return c};JSJaCHttpBindingConnection.prototype._suspend=function(){if(this._pause==0){return}var c=this._getFreeSlot();this._req[c]=this._setupRequest(false);var b="<body pause='"+this._pause+"' xmlns='http://jabber.org/protocol/httpbind' sid='"+this._sid+"' rid='"+this._rid+"'";if(JSJAC_HAVEKEYS){b+=" key='"+this._keys.getKey()+"'";if(this._keys.lastKey()){this._keys=new JSJaCKeys(hex_sha1,this.oDbg);b+=" newkey='"+this._keys.getKey()+"'"}}b+=">";while(this._pQueue.length){var a=this._pQueue[0];b+=a;this._pQueue=this._pQueue.slice(1,this._pQueue.length)}b+="</body>";this.oDbg.log("Disconnecting: "+b,4);this._req[c].r.send(b)};function JSJaCHttpPollingConnection(a){this.base=JSJaCConnection;this.base(a);JSJACPACKET_USE_XMLNS=false}JSJaCHttpPollingConnection.prototype=new JSJaCConnection();JSJaCHttpPollingConnection.prototype.isPolling=function(){return true};JSJaCHttpPollingConnection.prototype._getFreeSlot=function(){if(typeof(this._req[0])=="undefined"||typeof(this._req[0].r)=="undefined"||this._req[0].r.readyState==4){return 0}else{return -1}};JSJaCHttpPollingConnection.prototype._getInitialRequestString=function(){var b="0";if(JSJAC_HAVEKEYS){this._keys=new JSJaCKeys(b64_sha1,this.oDbg);key=this._keys.getKey();b+=";"+key}var a=this.domain;if(this.authhost){a=this.authhost}b+=",<stream:stream to='"+a+"' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'";if(this.authtype=="sasl"||this.authtype=="saslanon"){b+=" version='1.0'"}b+=">";return b};JSJaCHttpPollingConnection.prototype._getRequestString=function(a,b){var c=this._sid;if(JSJAC_HAVEKEYS){c+=";"+this._keys.getKey();if(this._keys.lastKey()){this._keys=new JSJaCKeys(b64_sha1,this.oDbg);c+=";"+this._keys.getKey()}}c+=",";if(a){c+=a}while(this._pQueue.length){c+=this._pQueue[0];this._pQueue=this._pQueue.slice(1,this._pQueue.length)}if(b){c+="</stream:stream>"}return c};JSJaCHttpPollingConnection.prototype._getStreamID=function(){if(this._req[0].r.responseText==""){this.oDbg.log("waiting for stream id",2);this._timeout=setTimeout(JSJaC.bind(this._sendEmpty,this),1000);return}this.oDbg.log(this._req[0].r.responseText,4);if(this._req[0].r.responseText.match(/id=[\'\"]([^\'\"]+)[\'\"]/)){this.streamid=RegExp.$1}this.oDbg.log("got streamid: "+this.streamid,2);var c;try{var a=this._req[0].r.responseText;if(!a.match(/<\/stream:stream>\s*$/)){a+="</stream:stream>"}c=XmlDocument.create("doc");c.loadXML(a);if(!this._parseStreamFeatures(c)){this.authtype="nonsasl";return}}catch(b){this.oDbg.log("loadXML: "+b.toString(),1)}this._connected=true;if(this.register){this._doInBandReg()}else{this._doAuth()}this._process(this._timerval)};JSJaCHttpPollingConnection.prototype._getSuspendVars=function(){return new Array()};JSJaCHttpPollingConnection.prototype._handleInitialResponse=function(){this.oDbg.log(this._req[0].r.getAllResponseHeaders(),4);var b=this._req[0].r.getResponseHeader("Set-Cookie");b=b.split(";");for(var a=0;a<b.length;a++){aArg=b[a].split("=");if(aArg[0]=="ID"){this._sid=aArg[1]}}this.oDbg.log("got sid: "+this._sid,2);this._connected=true;this._interval=setInterval(JSJaC.bind(this._checkQueue,this),JSJAC_CHECKQUEUEINTERVAL);this._inQto=setInterval(JSJaC.bind(this._checkInQ,this),JSJAC_CHECKINQUEUEINTERVAL);this._getStreamID()};JSJaCHttpPollingConnection.prototype._parseResponse=function(a){var h=a.r;if(!this.connected()){return null}if(h.status!=200){this.oDbg.log("invalid response ("+h.status+"):"+h.responseText+"\n"+h.getAllResponseHeaders(),1);this._setStatus("internal_server_error");clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);this._connected=false;this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect");this._handleEvent("onerror",JSJaCError("503","cancel","service-unavailable"));return null}this.oDbg.log(h.getAllResponseHeaders(),4);var b,j=h.getResponseHeader("Set-Cookie");if(j==null){b="-1:0"}else{j=j.split(";");var b;for(var d=0;d<j.length;d++){var g=j[d].split("=");if(g[0]=="ID"){b=g[1]}}}if(typeof(b)!="undefined"&&b.indexOf(":0")!=-1){switch(b.substring(0,b.indexOf(":0"))){case"0":this.oDbg.log("invalid response:"+h.responseText,1);break;case"-1":this.oDbg.log("Internal Server Error",1);break;case"-2":this.oDbg.log("Bad Request",1);break;case"-3":this.oDbg.log("Key Sequence Error",1);break}this._setStatus("internal_server_error");clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);this._handleEvent("onerror",JSJaCError("500","wait","internal-server-error"));this._connected=false;this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect");return null}if(!h.responseText||h.responseText==""){return null}try{var c=h.responseText.replace(/\<\?xml.+\?\>/,"");if(c.match(/<stream:stream/)){c+="</stream:stream>"}var k=JSJaCHttpPollingConnection._parseTree("<body>"+c+"</body>");if(!k||k.tagName=="parsererror"){this.oDbg.log("parsererror",1);k=JSJaCHttpPollingConnection._parseTree("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"+h.responseText);if(k&&k.tagName!="parsererror"){this.oDbg.log("stream closed",1);if(k.getElementsByTagName("conflict").length>0){this._setStatus("session-terminate-conflict")}clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);this._handleEvent("onerror",JSJaCError("503","cancel","session-terminate"));this._connected=false;this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect")}else{this.oDbg.log("parsererror:"+k,1)}return k}return k}catch(f){this.oDbg.log("parse error:"+f.message,1)}return null};JSJaCHttpPollingConnection.prototype._reInitStream=function(c,b,a){this._sendRaw("<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='"+c+"' version='1.0'>",b,a)};JSJaCHttpPollingConnection.prototype._resume=function(){this._process(this._timerval)};JSJaCHttpPollingConnection.prototype._setupRequest=function(a){var c=XmlHttp.create();try{c.open("POST",this._httpbase,a);if(c.overrideMimeType){c.overrideMimeType("text/plain; charset=utf-8")}c.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(d){this.oDbg.log(d,1)}var b=new Object();b.r=c;return b};JSJaCHttpPollingConnection.prototype._suspend=function(){};JSJaCHttpPollingConnection._parseTree=function(a){try{var b=XmlDocument.create("body","foo");if(typeof(b.loadXML)!="undefined"){b.loadXML(a);return b.documentElement}else{if(window.DOMParser){return(new DOMParser()).parseFromString(a,"text/xml").documentElement}}}catch(c){}return null};var JSJaC={Version:"$Rev$",require:function(a){document.write('<script type="text/javascript" src="'+a+'"><\/script>')},load:function(){var c=["xmlextras","jsextras","crypt","JSJaCConfig","JSJaCConstants","JSJaCCookie","JSJaCJSON","JSJaCJID","JSJaCBuilder","JSJaCPacket","JSJaCError","JSJaCKeys","JSJaCConnection","JSJaCHttpPollingConnection","JSJaCHttpBindingConnection","JSJaCConsoleLogger"];var a=document.getElementsByTagName("script");var d="./";for(var b=0;b<a.length;b++){if(a.item(b).src&&a.item(b).src.match(/JSJaC\.js$/)){d=a.item(b).src.replace(/JSJaC.js$/,"");break}}for(var b=0;b<c.length;b++){this.require(d+c[b]+".js")}},bind:function(b,c,a){return function(d){return b.apply(c,[d,a])}}};if(typeof JSJaCConnection=="undefined"){JSJaC.load()};