/*
	Copyright (c) 2004-2008, The Dojo Foundation
	All Rights Reserved.

	Licensed under the Academic Free License version 2.1 or above OR the
	modified BSD license. For more information on Dojo licensing, see:

		http://dojotoolkit.org/book/dojo-book-0-9/introduction/licensing
*/


var JSJAC_HAVEKEYS=true;var JSJAC_NKEYS=16;var JSJAC_INACTIVITY=300;var JSJAC_ERR_COUNT=10;var JSJAC_ALLOW_PLAIN=true;var JSJAC_CHECKQUEUEINTERVAL=1;var JSJAC_CHECKINQUEUEINTERVAL=1;var JSJACHBC_BOSH_VERSION="1.6";var JSJACHBC_USE_BOSH_VER=true;var JSJACHBC_MAX_HOLD=1;var JSJACHBC_MAX_WAIT=300;var JSJACHBC_MAXPAUSE=120;String.prototype.htmlEnc=function(){var _1=this.replace(/&/g,"&amp;");_1=_1.replace(/</g,"&lt;");_1=_1.replace(/>/g,"&gt;");_1=_1.replace(/\"/g,"&quot;");_1=_1.replace(/\n/g,"<br />");return _1;};Date.jab2date=function(ts){var _3=new Date(Date.UTC(ts.substr(0,4),ts.substr(5,2)-1,ts.substr(8,2),ts.substr(11,2),ts.substr(14,2),ts.substr(17,2)));if(ts.substr(ts.length-6,1)!="Z"){var _4=new Date();_4.setTime(0);_4.setUTCHours(ts.substr(ts.length-5,2));_4.setUTCMinutes(ts.substr(ts.length-2,2));if(ts.substr(ts.length-6,1)=="+"){_3.setTime(_3.getTime()-_4.getTime());}else{if(ts.substr(ts.length-6,1)=="-"){_3.setTime(_3.getTime()+_4.getTime());}}}return _3;};Date.hrTime=function(ts){return Date.jab2date(ts).toLocaleString();};Date.prototype.jabberDate=function(){var _6=function(i){if(i<10){return "0"+i;}return i;};var _8=this.getUTCFullYear()+"-";_8+=_6(this.getUTCMonth()+1)+"-";_8+=_6(this.getUTCDate())+"T";_8+=_6(this.getUTCHours())+":";_8+=_6(this.getUTCMinutes())+":";_8+=_6(this.getUTCSeconds())+"Z";return _8;};Number.max=function(A,B){return (A>B)?A:B;};var hexcase=0;var b64pad="=";var chrsz=8;function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length*chrsz));};function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length*chrsz));};function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length*chrsz));};function hex_hmac_sha1(_e,_f){return binb2hex(core_hmac_sha1(_e,_f));};function b64_hmac_sha1(key,_11){return binb2b64(core_hmac_sha1(key,_11));};function str_hmac_sha1(key,_13){return binb2str(core_hmac_sha1(key,_13));};function sha1_vm_test(){return hex_sha1("abc")=="a9993e364706816aba3e25717850c26c9cd0d89d";};function core_sha1(x,len){x[len>>5]|=128<<(24-len%32);x[((len+64>>9)<<4)+15]=len;var w=Array(80);var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;var e=-1009589776;for(var i=0;i<x.length;i+=16){var _1d=a;var _1e=b;var _1f=c;var _20=d;var _21=e;for(var j=0;j<80;j++){if(j<16){w[j]=x[i+j];}else{w[j]=rol(w[j-3]^w[j-8]^w[j-14]^w[j-16],1);}var t=safe_add(safe_add(rol(a,5),sha1_ft(j,b,c,d)),safe_add(safe_add(e,w[j]),sha1_kt(j)));e=d;d=c;c=rol(b,30);b=a;a=t;}a=safe_add(a,_1d);b=safe_add(b,_1e);c=safe_add(c,_1f);d=safe_add(d,_20);e=safe_add(e,_21);}return Array(a,b,c,d,e);};function sha1_ft(t,b,c,d){if(t<20){return (b&c)|((~b)&d);}if(t<40){return b^c^d;}if(t<60){return (b&c)|(b&d)|(c&d);}return b^c^d;};function sha1_kt(t){return (t<20)?1518500249:(t<40)?1859775393:(t<60)?-1894007588:-899497514;};function core_hmac_sha1(key,_2a){var _2b=str2binb(key);if(_2b.length>16){_2b=core_sha1(_2b,key.length*chrsz);}var _2c=Array(16),_2d=Array(16);for(var i=0;i<16;i++){_2c[i]=_2b[i]^909522486;_2d[i]=_2b[i]^1549556828;}var _2f=core_sha1(_2c.concat(str2binb(_2a)),512+_2a.length*chrsz);return core_sha1(_2d.concat(_2f),512+160);};function rol(num,cnt){return (num<<cnt)|(num>>>(32-cnt));};function str2binb(str){var bin=Array();var _34=(1<<chrsz)-1;for(var i=0;i<str.length*chrsz;i+=chrsz){bin[i>>5]|=(str.charCodeAt(i/chrsz)&_34)<<(32-chrsz-i%32);}return bin;};function binb2str(bin){var str="";var _38=(1<<chrsz)-1;for(var i=0;i<bin.length*32;i+=chrsz){str+=String.fromCharCode((bin[i>>5]>>>(32-chrsz-i%32))&_38);}return str;};function binb2hex(_3a){var _3b=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i<_3a.length*4;i++){str+=_3b.charAt((_3a[i>>2]>>((3-i%4)*8+4))&15)+_3b.charAt((_3a[i>>2]>>((3-i%4)*8))&15);}return str;};function binb2b64(_3e){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";for(var i=0;i<_3e.length*4;i+=3){var _42=(((_3e[i>>2]>>8*(3-i%4))&255)<<16)|(((_3e[i+1>>2]>>8*(3-(i+1)%4))&255)<<8)|((_3e[i+2>>2]>>8*(3-(i+2)%4))&255);for(var j=0;j<4;j++){if(i*8+j*6>_3e.length*32){str+=b64pad;}else{str+=tab.charAt((_42>>6*(3-j))&63);}}}return str;};function hex_md5(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz));};function b64_md5(s){return binl2b64(core_md5(str2binl(s),s.length*chrsz));};function str_md5(s){return binl2str(core_md5(str2binl(s),s.length*chrsz));};function hex_hmac_md5(key,_48){return binl2hex(core_hmac_md5(key,_48));};function b64_hmac_md5(key,_4a){return binl2b64(core_hmac_md5(key,_4a));};function str_hmac_md5(key,_4c){return binl2str(core_hmac_md5(key,_4c));};function md5_vm_test(){return hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72";};function core_md5(x,len){x[len>>5]|=128<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(var i=0;i<x.length;i+=16){var _54=a;var _55=b;var _56=c;var _57=d;a=md5_ff(a,b,c,d,x[i+0],7,-680876936);d=md5_ff(d,a,b,c,x[i+1],12,-389564586);c=md5_ff(c,d,a,b,x[i+2],17,606105819);b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);a=md5_ff(a,b,c,d,x[i+4],7,-176418897);d=md5_ff(d,a,b,c,x[i+5],12,1200080426);c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);b=md5_ff(b,c,d,a,x[i+7],22,-45705983);a=md5_ff(a,b,c,d,x[i+8],7,1770035416);d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);c=md5_ff(c,d,a,b,x[i+10],17,-42063);b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);a=md5_ff(a,b,c,d,x[i+12],7,1804603682);d=md5_ff(d,a,b,c,x[i+13],12,-40341101);c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);b=md5_ff(b,c,d,a,x[i+15],22,1236535329);a=md5_gg(a,b,c,d,x[i+1],5,-165796510);d=md5_gg(d,a,b,c,x[i+6],9,-1069501632);c=md5_gg(c,d,a,b,x[i+11],14,643717713);b=md5_gg(b,c,d,a,x[i+0],20,-373897302);a=md5_gg(a,b,c,d,x[i+5],5,-701558691);d=md5_gg(d,a,b,c,x[i+10],9,38016083);c=md5_gg(c,d,a,b,x[i+15],14,-660478335);b=md5_gg(b,c,d,a,x[i+4],20,-405537848);a=md5_gg(a,b,c,d,x[i+9],5,568446438);d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);c=md5_gg(c,d,a,b,x[i+3],14,-187363961);b=md5_gg(b,c,d,a,x[i+8],20,1163531501);a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);d=md5_gg(d,a,b,c,x[i+2],9,-51403784);c=md5_gg(c,d,a,b,x[i+7],14,1735328473);b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);a=md5_hh(a,b,c,d,x[i+5],4,-378558);d=md5_hh(d,a,b,c,x[i+8],11,-2022574463);c=md5_hh(c,d,a,b,x[i+11],16,1839030562);b=md5_hh(b,c,d,a,x[i+14],23,-35309556);a=md5_hh(a,b,c,d,x[i+1],4,-1530992060);d=md5_hh(d,a,b,c,x[i+4],11,1272893353);c=md5_hh(c,d,a,b,x[i+7],16,-155497632);b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);a=md5_hh(a,b,c,d,x[i+13],4,681279174);d=md5_hh(d,a,b,c,x[i+0],11,-358537222);c=md5_hh(c,d,a,b,x[i+3],16,-722521979);b=md5_hh(b,c,d,a,x[i+6],23,76029189);a=md5_hh(a,b,c,d,x[i+9],4,-640364487);d=md5_hh(d,a,b,c,x[i+12],11,-421815835);c=md5_hh(c,d,a,b,x[i+15],16,530742520);b=md5_hh(b,c,d,a,x[i+2],23,-995338651);a=md5_ii(a,b,c,d,x[i+0],6,-198630844);d=md5_ii(d,a,b,c,x[i+7],10,1126891415);c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);b=md5_ii(b,c,d,a,x[i+5],21,-57434055);a=md5_ii(a,b,c,d,x[i+12],6,1700485571);d=md5_ii(d,a,b,c,x[i+3],10,-1894986606);c=md5_ii(c,d,a,b,x[i+10],15,-1051523);b=md5_ii(b,c,d,a,x[i+1],21,-2054922799);a=md5_ii(a,b,c,d,x[i+8],6,1873313359);d=md5_ii(d,a,b,c,x[i+15],10,-30611744);c=md5_ii(c,d,a,b,x[i+6],15,-1560198380);b=md5_ii(b,c,d,a,x[i+13],21,1309151649);a=md5_ii(a,b,c,d,x[i+4],6,-145523070);d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);c=md5_ii(c,d,a,b,x[i+2],15,718787259);b=md5_ii(b,c,d,a,x[i+9],21,-343485551);a=safe_add(a,_54);b=safe_add(b,_55);c=safe_add(c,_56);d=safe_add(d,_57);}return Array(a,b,c,d);};function md5_cmn(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b);};function md5_ff(a,b,c,d,x,s,t){return md5_cmn((b&c)|((~b)&d),a,b,x,s,t);};function md5_gg(a,b,c,d,x,s,t){return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t);};function md5_hh(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t);};function md5_ii(a,b,c,d,x,s,t){return md5_cmn(c^(b|(~d)),a,b,x,s,t);};function core_hmac_md5(key,_7b){var _7c=str2binl(key);if(_7c.length>16){_7c=core_md5(_7c,key.length*chrsz);}var _7d=Array(16),_7e=Array(16);for(var i=0;i<16;i++){_7d[i]=_7c[i]^909522486;_7e[i]=_7c[i]^1549556828;}var _80=core_md5(_7d.concat(str2binl(_7b)),512+_7b.length*chrsz);return core_md5(_7e.concat(_80),512+128);};function safe_add(x,y){var lsw=(x&65535)+(y&65535);var msw=(x>>16)+(y>>16)+(lsw>>16);return (msw<<16)|(lsw&65535);};function bit_rol(num,cnt){return (num<<cnt)|(num>>>(32-cnt));};function str2binl(str){var bin=Array();var _89=(1<<chrsz)-1;for(var i=0;i<str.length*chrsz;i+=chrsz){bin[i>>5]|=(str.charCodeAt(i/chrsz)&_89)<<(i%32);}return bin;};function binl2str(bin){var str="";var _8d=(1<<chrsz)-1;for(var i=0;i<bin.length*32;i+=chrsz){str+=String.fromCharCode((bin[i>>5]>>>(i%32))&_8d);}return str;};function binl2hex(_8f){var _90=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i<_8f.length*4;i++){str+=_90.charAt((_8f[i>>2]>>((i%4)*8+4))&15)+_90.charAt((_8f[i>>2]>>((i%4)*8))&15);}return str;};function binl2b64(_93){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";for(var i=0;i<_93.length*4;i+=3){var _97=(((_93[i>>2]>>8*(i%4))&255)<<16)|(((_93[i+1>>2]>>8*((i+1)%4))&255)<<8)|((_93[i+2>>2]>>8*((i+2)%4))&255);for(var j=0;j<4;j++){if(i*8+j*6>_93.length*32){str+=b64pad;}else{str+=tab.charAt((_97>>6*(3-j))&63);}}}return str;};function utf8t2d(t){t=t.replace(/\r\n/g,"\n");var d=new Array;var _9b=String.fromCharCode(237);if(_9b.charCodeAt(0)<0){for(var n=0;n<t.length;n++){var c=t.charCodeAt(n);if(c>0){d[d.length]=c;}else{d[d.length]=(((256+c)>>6)|192);d[d.length]=(((256+c)&63)|128);}}}else{for(var n=0;n<t.length;n++){var c=t.charCodeAt(n);if(c<128){d[d.length]=c;}else{if((c>127)&&(c<2048)){d[d.length]=((c>>6)|192);d[d.length]=((c&63)|128);}else{d[d.length]=((c>>12)|224);d[d.length]=(((c>>6)&63)|128);d[d.length]=((c&63)|128);}}}}return d;};function utf8d2t(d){var r=new Array;var i=0;while(i<d.length){if(d[i]<128){r[r.length]=String.fromCharCode(d[i]);i++;}else{if((d[i]>191)&&(d[i]<224)){r[r.length]=String.fromCharCode(((d[i]&31)<<6)|(d[i+1]&63));i+=2;}else{r[r.length]=String.fromCharCode(((d[i]&15)<<12)|((d[i+1]&63)<<6)|(d[i+2]&63));i+=3;}}}return r.join("");};function b64arrays(){var _a1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b64=new Array();f64=new Array();for(var i=0;i<_a1.length;i++){b64[i]=_a1.charAt(i);f64[_a1.charAt(i)]=i;}};function b64d2t(d){var r=new Array;var i=0;var dl=d.length;if((dl%3)==1){d[d.length]=0;d[d.length]=0;}if((dl%3)==2){d[d.length]=0;}while(i<d.length){r[r.length]=b64[d[i]>>2];r[r.length]=b64[((d[i]&3)<<4)|(d[i+1]>>4)];r[r.length]=b64[((d[i+1]&15)<<2)|(d[i+2]>>6)];r[r.length]=b64[d[i+2]&63];i+=3;}if((dl%3)==1){r[r.length-1]=r[r.length-2]="=";}if((dl%3)==2){r[r.length-1]="=";}var t=r.join("");return t;};function b64t2d(t){var d=new Array;var i=0;t=t.replace(/\n|\r/g,"");t=t.replace(/=/g,"");while(i<t.length){d[d.length]=(f64[t.charAt(i)]<<2)|(f64[t.charAt(i+1)]>>4);d[d.length]=(((f64[t.charAt(i+1)]&15)<<4)|(f64[t.charAt(i+2)]>>2));d[d.length]=(((f64[t.charAt(i+2)]&3)<<6)|(f64[t.charAt(i+3)]));i+=4;}if(t.length%4==2){d=d.slice(0,d.length-2);}if(t.length%4==3){d=d.slice(0,d.length-1);}return d;};if(typeof (atob)=="undefined"||typeof (btoa)=="undefined"){b64arrays();}if(typeof (atob)=="undefined"){atob=function(s){return utf8d2t(b64t2d(s));};}if(typeof (btoa)=="undefined"){btoa=function(s){return b64d2t(utf8t2d(s));};}function cnonce(_ad){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var _af="";for(var i=0;i<_ad;i++){_af+=tab.charAt(Math.round(Math.random(new Date().getTime())*(tab.length-1)));}return _af;};function JSJaCJSON(){};JSJaCJSON.toString=function(obj){var m={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\"":"\\\"","\\":"\\\\"},s={array:function(x){var a=["["],b,f,i,l=x.length,v;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=="string"){if(b){a[a.length]=",";}a[a.length]=v;b=true;}}}a[a.length]="]";return a.join("");},"boolean":function(x){return String(x);},"null":function(x){return "null";},number:function(x){return isFinite(x)?String(x):"null";},object:function(x){if(x){if(x instanceof Array){return s.array(x);}var a=["{"],b,f,i,v;for(i in x){if(x.hasOwnProperty(i)){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=="string"){if(b){a[a.length]=",";}a.push(s.string(i),":",v);b=true;}}}}a[a.length]="}";return a.join("");}return "null";},string:function(x){if(/["\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}c=b.charCodeAt();return "\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16);});}return "\""+x+"\"";}};switch(typeof (obj)){case "object":return s.object(obj);case "array":return s.array(obj);}};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 req=new XMLHttpRequest();if(req.readyState==null){req.readyState=1;req.addEventListener("load",function(){req.readyState=4;if(typeof req.onreadystatechange=="function"){req.onreadystatechange();}},false);}return req;}if(window.ActiveXObject){return new ActiveXObject(XmlHttp.getPrefix()+".XmlHttp");}}catch(ex){}throw new Error("Your browser does not support XmlHttp objects");};XmlHttp.getPrefix=function(){if(XmlHttp.prefix){return XmlHttp.prefix;}var _ca=["MSXML2","Microsoft","MSXML","MSXML3"];var o;for(var i=0;i<_ca.length;i++){try{o=new ActiveXObject(_ca[i]+".XmlHttp");return XmlHttp.prefix=_ca[i];}catch(ex){}}throw new Error("Could not find an installed XML parser");};function XmlDocument(){};XmlDocument.create=function(_cd,ns){_cd=_cd||"foo";ns=ns||"";try{var doc;if(document.implementation&&document.implementation.createDocument){doc=document.implementation.createDocument(ns,_cd,null);if(doc.readyState==null){doc.readyState=1;doc.addEventListener("load",function(){doc.readyState=4;if(typeof doc.onreadystatechange=="function"){doc.onreadystatechange();}},false);}}else{if(window.ActiveXObject){doc=new ActiveXObject(XmlDocument.getPrefix()+".DomDocument");}}if(!doc.documentElement||doc.documentElement.tagName!=_cd||(doc.documentElement.namespaceURI&&doc.documentElement.namespaceURI!=ns)){try{if(ns!=""){doc.appendChild(doc.createElement(_cd)).setAttribute("xmlns",ns);}else{doc.appendChild(doc.createElement(_cd));}}catch(dex){doc=document.implementation.createDocument(ns,_cd,null);if(doc.documentElement==null){doc.appendChild(doc.createElement(_cd));}if(ns!=""&&doc.documentElement.getAttribute("xmlns")!=ns){doc.documentElement.setAttribute("xmlns",ns);}}}return doc;}catch(ex){alert(ex.name+": "+ex.message);}throw new Error("Your browser does not support XmlDocument objects");};XmlDocument.getPrefix=function(){if(XmlDocument.prefix){return XmlDocument.prefix;}var _d0=["MSXML2","Microsoft","MSXML","MSXML3"];var o;for(var i=0;i<_d0.length;i++){try{o=new ActiveXObject(_d0[i]+".DomDocument");return XmlDocument.prefix=_d0[i];}catch(ex){}}throw new Error("Could not find an installed XML parser");};if(typeof (Document)!="undefined"&&window.DOMParser){Document.prototype.loadXML=function(s){var _d4=(new DOMParser()).parseFromString(s,"text/xml");while(this.hasChildNodes()){this.removeChild(this.lastChild);}for(var i=0;i<_d4.childNodes.length;i++){this.appendChild(this.importNode(_d4.childNodes[i],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(doc,_d7){var _d8;if(arguments[2]){if(JSJaCBuilder._isStringOrNumber(arguments[2])||(arguments[2] instanceof Array)){_d8=doc.createElement(_d7);JSJaCBuilder._children(doc,_d8,arguments[2]);}else{if(arguments[2]["xmlns"]){try{_d8=doc.createElementNS(arguments[2]["xmlns"],_d7);}catch(e){_d8=doc.createElement(_d7);}}else{_d8=doc.createElement(_d7);}for(attr in arguments[2]){if(arguments[2].hasOwnProperty(attr)){if(attr=="xmlns"&&_d8.namespaceURI==attr){continue;}_d8.setAttribute(attr,arguments[2][attr]);}}}}else{_d8=doc.createElement(_d7);}if(arguments[3]){JSJaCBuilder._children(doc,_d8,arguments[3]);}return _d8;},_text:function(doc,_da){return doc.createTextNode(_da);},_children:function(doc,_dc,_dd){if(typeof _dd=="object"){for(var i in _dd){if(_dd.hasOwnProperty(i)){var e=_dd[i];if(typeof e=="object"){if(e instanceof Array){var _e0=JSJaCBuilder.buildNode(doc,e[0],e[1],e[2]);_dc.appendChild(_e0);}else{_dc.appendChild(e);}}else{if(JSJaCBuilder._isStringOrNumber(e)){_dc.appendChild(JSJaCBuilder._text(doc,e));}}}}}else{if(JSJaCBuilder._isStringOrNumber(_dd)){_dc.appendChild(JSJaCBuilder._text(doc,_dd));}}},_attributes:function(_e1){var _e2=[];for(attribute in _e1){if(_e1.hasOwnProperty(attribute)){_e2.push(attribute+"=\""+_e1[attribute].toString().htmlEnc()+"\"");}}return _e2.join(" ");},_isStringOrNumber:function(_e3){return (typeof _e3=="string"||typeof _e3=="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(_e4,_e5,_e6){if(window==this){return new STANZA_ERROR(_e4,_e5,_e6);}this.code=_e4;this.type=_e5;this.cond=_e6;};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 JSJaCConnection(_e7){if(_e7&&_e7.oDbg&&_e7.oDbg.log){this.oDbg=_e7.oDbg;}else{this.oDbg=new Object();this.oDbg.log=function(){};}if(_e7&&_e7.httpbase){this._httpbase=_e7.httpbase;}if(_e7&&_e7.allow_plain){this.allow_plain=_e7.allow_plain;}else{this.allow_plain=JSJAC_ALLOW_PLAIN;}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();if(_e7&&_e7.timerval){this.setPollInterval(_e7.timerval);}};JSJaCConnection.prototype.connect=function(_e8){this._setStatus("connecting");this.domain=_e8.domain||"localhost";this.username=_e8.username;this.resource=_e8.resource;this.pass=_e8.pass;this.register=_e8.register;this.authhost=_e8.authhost||this.domain;this.authtype=_e8.authtype||"sasl";if(_e8.xmllang&&_e8.xmllang!=""){this._xmllang=_e8.xmllang;}this.host=_e8.host||this.domain;this.port=_e8.port||5222;if(_e8.secure){this.secure="true";}else{this.secure="false";}if(_e8.wait){this._wait=_e8.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 _e9=this._getFreeSlot();this._req[_e9]=this._setupRequest(true);var _ea=this._getInitialRequestString();this.oDbg.log(_ea,4);this._req[_e9].r.onreadystatechange=JSJaC.bind(function(){if(this._req[_e9].r.readyState==4){this.oDbg.log("async recv: "+this._req[_e9].r.responseText,4);this._handleInitialResponse(_e9);}},this);if(typeof (this._req[_e9].r.onerror)!="undefined"){this._req[_e9].r.onerror=JSJaC.bind(function(e){this.oDbg.log("XmlHttpRequest error",1);return false;},this);}this._req[_e9].r.send(_ea);};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 _ec=this._getFreeSlot();this._req[_ec]=this._setupRequest(false);request=this._getRequestString(false,true);this.oDbg.log("Disconnecting: "+request,4);this._req[_ec].r.send(request);try{JSJaCCookie.read("JSJaC_State").erase();}catch(e){}this.oDbg.log("Disconnected: "+this._req[_ec].r.responseText,2);this._handleEvent("ondisconnect");};JSJaCConnection.prototype.getPollInterval=function(){return this._timerval;};JSJaCConnection.prototype.registerHandler=function(_ed){_ed=_ed.toLowerCase();var _ee={handler:arguments[arguments.length-1],childName:"*",childNS:"*",type:"*"};if(arguments.length>2){_ee.childName=arguments[1];}if(arguments.length>3){_ee.childNS=arguments[2];}if(arguments.length>4){_ee.type=arguments[3];}if(!this._events[_ed]){this._events[_ed]=new Array(_ee);}else{this._events[_ed]=this._events[_ed].concat(_ee);}this._events[_ed]=this._events[_ed].sort(function(a,b){var _f1=0;var _f2=0;with(a){if(type=="*"){_f1++;}if(childNS=="*"){_f1++;}if(childName=="*"){_f1++;}}with(b){if(type=="*"){_f2++;}if(childNS=="*"){_f2++;}if(childName=="*"){_f2++;}}if(_f1>_f2){return 1;}if(_f1<_f2){return -1;}return 0;});this.oDbg.log("registered handler for event '"+_ed+"'",2);};JSJaCConnection.prototype.unregisterHandler=function(_f3,_f4){_f3=_f3.toLowerCase();if(!this._events[_f3]){return;}var arr=this._events[_f3],res=new Array();for(var i=0;i<arr.length;i++){if(arr[i]!=_f4){res.push(arr[i]);}}if(arr.length!=res.length){this._events[_f3]=res;this.oDbg.log("unregistered handler for event '"+_f3+"'",2);}};JSJaCConnection.prototype.registerIQGet=function(_f8,_f9,_fa){this.registerHandler("iq",_f8,_f9,"get",_fa);};JSJaCConnection.prototype.registerIQSet=function(_fb,_fc,_fd){this.registerHandler("iq",_fb,_fc,"set",_fd);};JSJaCConnection.prototype.resume=function(){try{this._setStatus("resuming");var s=unescape(JSJaCCookie.read("JSJaC_State").getValue());this.oDbg.log("read cookie: "+s,2);var o=JSJaCJSON.parse(s);for(var i in o){if(o.hasOwnProperty(i)){this[i]=o[i];}}if(this._keys){this._keys2=new JSJaCKeys();var u=this._keys2._getSuspendVars();for(var i=0;i<u.length;i++){this._keys2[u[i]]=this._keys[u[i]];}this._keys=this._keys2;}try{JSJaCCookie.read("JSJaC_State").erase();}catch(e){}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(e){if(e.message){this.oDbg.log("Resume failed: "+e.message,1);}else{this.oDbg.log("Resume failed: "+e,1);}return false;}};JSJaCConnection.prototype.send=function(_102,cb,arg){if(!_102||!_102.pType){this.oDbg.log("no packet: "+_102,1);return false;}if(!this.connected()){return false;}if(cb){if(!_102.getID()){_102.setID("JSJaCID_"+this._ID++);}this._registerPID(_102.getID(),cb,arg);}try{this._handleEvent(_102.pType()+"_out",_102);this._handleEvent("packet_out",_102);this._pQueue=this._pQueue.concat(_102.xml());}catch(e){this.oDbg.log(e.toString(),1);return false;}return true;};JSJaCConnection.prototype.sendIQ=function(iq,_106,arg){if(!iq||iq.pType()!="iq"){return false;}_106=_106||{};var _108=_106.error_handler||function(aIq){this.oDbg.log(iq.xml(),1);};var _10a=_106.result_handler||function(aIq){this.oDbg.log(aIq.xml(),2);};var _10c=_106.default_handler||function(aIq){this.oDbg.log(aIq.xml(),2);};var _10e=function(aIq,arg){switch(aIq.getType()){case "error":_108(aIq);break;case "result":_10a(aIq,arg);break;default:_10c(aIq,arg);}};return this.send(iq,_10e,arg);};JSJaCConnection.prototype.setPollInterval=function(_111){if(_111&&!isNaN(_111)){this._timerval=_111;}return this._timerval;};JSJaCConnection.prototype.status=function(){return this._status;};JSJaCConnection.prototype.suspend=function(){clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);this._suspend();var u=("_connected,_keys,_ID,_inQ,_pQueue,_regIDs,_errcnt,_inactivity,domain,username,resource,jid,fulljid,_sid,_httpbase,_timerval,_is_polling").split(",");u=u.concat(this._getSuspendVars());var s=new Object();for(var i=0;i<u.length;i++){if(!this[u[i]]){continue;}if(this[u[i]]._getSuspendVars){var uo=this[u[i]]._getSuspendVars();var o=new Object();for(var j=0;j<uo.length;j++){o[uo[j]]=this[u[i]][uo[j]];}}else{var o=this[u[i]];}s[u[i]]=o;}var c=new JSJaCCookie("JSJaC_State",escape(JSJaCJSON.toString(s)),this._inactivity);this.oDbg.log("writing cookie: "+unescape(c.value)+"\n(length:"+unescape(c.value).length+")",2);c.write();try{var c2=JSJaCCookie.read("JSJaC_State");if(c.value!=c2.value){this.oDbg.log("Suspend failed writing cookie.\nRead: "+unescape(JSJaCCookie.read("JSJaC_State")),1);c.erase();}this._connected=false;this._setStatus("suspending");}catch(e){this.oDbg.log("Failed reading cookie 'JSJaC_State': "+e.message);}};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 i=0;i<this._inQ.length&&i<10;i++){var item=this._inQ[0];this._inQ=this._inQ.slice(1,this._inQ.length);var _11c=JSJaCPacket.wrapNode(item);if(!_11c){return;}this._handleEvent("packet_in",_11c);if(_11c.pType&&!this._handlePID(_11c)){this._handleEvent(_11c.pType()+"_in",_11c);this._handleEvent(_11c.pType(),_11c);}}};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 iq=new JSJaCIQ();iq.setType("set");iq.setID("reg1");iq.appendNode("query",{xmlns:"jabber:iq:register"},[["username",this.username],["password",this.pass]]);this.send(iq,this._doInBandRegDone);};JSJaCConnection.prototype._doInBandRegDone=function(iq){if(iq&&iq.getType()=="error"){this.oDbg.log("registration failed for "+this.username,0);this._handleEvent("onerror",iq.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 iq=new JSJaCIQ();iq.setIQ(this.server,"get","auth1");iq.appendNode("query",{xmlns:"jabber:iq:auth"},[["username",this.username]]);this.send(iq,this._doLegacyAuth2);return true;};JSJaCConnection.prototype._doLegacyAuth2=function(iq){if(!iq||iq.getType()!="result"){if(iq&&iq.getType()=="error"){this._handleEvent("onerror",iq.getChild("error"));}this.disconnect();return;}var _121=(iq.getChild("digest")!=null);var iq=new JSJaCIQ();iq.setIQ(this.server,"set","auth2");query=iq.appendNode("query",{xmlns:"jabber:iq:auth"},[["username",this.username],["resource",this.resource]]);if(_121){query.appendChild(iq.buildNode("digest",hex_sha1(this.streamid+this.pass)));}else{if(this.allow_plain){query.appendChild(iq.buildNode("password",this.pass));}else{this.oDbg.log("no valid login mechanism found",1);this.disconnect();return false;}}this.send(iq,this._doLegacyAuthDone);};JSJaCConnection.prototype._doLegacyAuthDone=function(iq){if(iq.getType()!="result"){if(iq.getType()=="error"){this._handleEvent("onerror",iq.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 _123=this.username+"@"+this.domain+String.fromCharCode(0)+this.username+String.fromCharCode(0)+this.pass;this.oDbg.log("authenticating with '"+_123+"'",2);_123=btoa(_123);return this._sendRaw("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>"+_123+"</auth>",this._doSASLAuthDone);}}this.oDbg.log("No SASL mechanism applied",1);this.authtype="nonsasl";}return false;};JSJaCConnection.prototype._doSASLAuthDigestMd5S1=function(el){if(el.nodeName!="challenge"){this.oDbg.log("challenge missing",1);this._handleEvent("onerror",JSJaCError("401","auth","not-authorized"));this.disconnect();}else{var _125=atob(el.firstChild.nodeValue);this.oDbg.log("got challenge: "+_125,2);this._nonce=_125.substring(_125.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 A1=str_md5(this.username+":"+this.domain+":"+this.pass)+":"+this._nonce+":"+this._cnonce;var A2="AUTHENTICATE:"+this._digest_uri;var _128=hex_md5(hex_md5(A1)+":"+this._nonce+":"+this._nc+":"+this._cnonce+":auth:"+hex_md5(A2));var _129="username=\""+this.username+"\",realm=\""+this.domain+"\",nonce=\""+this._nonce+"\",cnonce=\""+this._cnonce+"\",nc=\""+this._nc+"\",qop=auth,digest-uri=\""+this._digest_uri+"\",response=\""+_128+"\",charset=utf-8";this.oDbg.log("response: "+_129,2);this._sendRaw("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"+binb2b64(str2binb(_129))+"</response>",this._doSASLAuthDigestMd5S2);}};JSJaCConnection.prototype._doSASLAuthDigestMd5S2=function(el){if(el.nodeName=="failure"){if(el.xml){this.oDbg.log("auth error: "+el.xml,1);}else{this.oDbg.log("auth error",1);}this._handleEvent("onerror",JSJaCError("401","auth","not-authorized"));this.disconnect();return;}var _12b=atob(el.firstChild.nodeValue);this.oDbg.log("response: "+_12b,2);var _12c=_12b.substring(_12b.indexOf("rspauth=")+8);this.oDbg.log("rspauth: "+_12c,2);var A1=str_md5(this.username+":"+this.domain+":"+this.pass)+":"+this._nonce+":"+this._cnonce;var A2=":"+this._digest_uri;var _12f=hex_md5(hex_md5(A1)+":"+this._nonce+":"+this._nc+":"+this._cnonce+":auth:"+hex_md5(A2));this.oDbg.log("rsptest: "+_12f,2);if(_12f!=_12c){this.oDbg.log("SASL Digest-MD5: server repsonse with wrong rspauth",1);this.disconnect();return;}if(el.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(el){if(el.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 iq=new JSJaCIQ();iq.setIQ(this.domain,"set","bind_1");iq.appendNode("bind",{xmlns:"urn:ietf:params:xml:ns:xmpp-bind"},[["resource",this.resource]]);this.oDbg.log(iq.xml());this.send(iq,this._doXMPPSess);};JSJaCConnection.prototype._doXMPPSess=function(iq){if(iq.getType()!="result"||iq.getType()=="error"){this.disconnect();if(iq.getType()=="error"){this._handleEvent("onerror",iq.getChild("error"));}return;}this.fulljid=iq.getChildVal("jid");this.jid=this.fulljid.substring(0,this.fulljid.lastIndexOf("/"));iq=new JSJaCIQ();iq.setIQ(this.domain,"set","sess_1");iq.appendNode("session",{xmlns:"urn:ietf:params:xml:ns:xmpp-session"},[]);this.oDbg.log(iq.xml());this.send(iq,this._doXMPPSessDone);};JSJaCConnection.prototype._doXMPPSessDone=function(iq){if(iq.getType()!="result"||iq.getType()=="error"){this.disconnect();if(iq.getType()=="error"){this._handleEvent("onerror",iq.getChild("error"));}return;}else{this._handleEvent("onconnect");}};JSJaCConnection.prototype._handleEvent=function(_134,arg){_134=_134.toLowerCase();this.oDbg.log("incoming event '"+_134+"'",3);if(!this._events[_134]){return;}this.oDbg.log("handling event '"+_134+"'",2);for(var i=0;i<this._events[_134].length;i++){var _137=this._events[_134][i];if(_137.handler){try{if(arg){if(arg.pType){if((!arg.getNode().hasChildNodes()&&_137.childName!="*")||(arg.getNode().hasChildNodes()&&!arg.getChild(_137.childName,_137.childNS))){continue;}if(_137.type!="*"&&arg.getType()!=_137.type){continue;}this.oDbg.log(_137.childName+"/"+_137.childNS+"/"+_137.type+" => match for handler "+_137.handler,3);}if(_137.handler.call(this,arg)){break;}}else{if(_137.handler.call(this)){break;}}}catch(e){this.oDbg.log(_137.handler+"\n>>>"+e.name+": "+e.message,1);}}}};JSJaCConnection.prototype._handlePID=function(_138){if(!_138.getID()){return false;}for(var i in this._regIDs){if(this._regIDs.hasOwnProperty(i)&&this._regIDs[i]&&i==_138.getID()){var pID=_138.getID();this.oDbg.log("handling "+pID,3);try{if(this._regIDs[i].cb.call(this,_138,this._regIDs[i].arg)===false){return false;}else{this._unregisterPID(pID);return true;}}catch(e){this.oDbg.log(e.name+": "+e.message);this._unregisterPID(pID);return true;}}}return false;};JSJaCConnection.prototype._handleResponse=function(req){var _13c=this._parseResponse(req);if(!_13c){return;}for(var i=0;i<_13c.childNodes.length;i++){if(this._sendRawCallbacks.length){var cb=this._sendRawCallbacks[0];this._sendRawCallbacks=this._sendRawCallbacks.slice(1,this._sendRawCallbacks.length);cb.fn.call(this,_13c.childNodes.item(i),cb.arg);continue;}this._inQ=this._inQ.concat(_13c.childNodes.item(i));}};JSJaCConnection.prototype._parseStreamFeatures=function(doc){if(!doc){this.oDbg.log("nothing to parse ... aborting",1);return false;}var _140;if(doc.getElementsByTagNameNS){_140=doc.getElementsByTagNameNS("http://etherx.jabber.org/streams","error").item(0);}else{var _141=doc.getElementsByTagName("error");for(var i=0;i<_141.length;i++){if(_141.item(i).namespaceURI=="http://etherx.jabber.org/streams"){_140=_141.item(i);break;}}}if(_140){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 _143=doc.getElementsByTagName("mechanisms");this.has_sasl=false;for(var i=0;i<_143.length;i++){if(_143.item(i).getAttribute("xmlns")=="urn:ietf:params:xml:ns:xmpp-sasl"){this.has_sasl=true;var _144=_143.item(i).getElementsByTagName("mechanism");for(var j=0;j<_144.length;j++){this.mechs[_144.item(j).firstChild.nodeValue]=true;}break;}}if(this.has_sasl){this.oDbg.log("SASL detected",2);}else{this.authtype="nonsasl";this.oDbg.log("No support for SASL detected",2);}return true;};JSJaCConnection.prototype._process=function(_146){if(!this.connected()){this.oDbg.log("Connection lost ...",1);if(this._interval){clearInterval(this._interval);}return;}this.setPollInterval(_146);if(this._timeout){clearTimeout(this._timeout);}var slot=this._getFreeSlot();if(slot<0){return;}if(typeof (this._req[slot])!="undefined"&&typeof (this._req[slot].r)!="undefined"&&this._req[slot].r.readyState!=4){this.oDbg.log("Slot "+slot+" is not ready");return;}if(!this.isPolling()&&this._pQueue.length==0&&this._req[(slot+1)%2]&&this._req[(slot+1)%2].r.readyState!=4){this.oDbg.log("all slots busy, standby ...",2);return;}if(!this.isPolling()){this.oDbg.log("Found working slot at "+slot,2);}this._req[slot]=this._setupRequest(true);this._req[slot].r.onreadystatechange=JSJaC.bind(function(){if(!this.connected()){return;}if(this._req[slot].r.readyState==4){this._setStatus("processing");this.oDbg.log("async recv: "+this._req[slot].r.responseText,4);this._handleResponse(this._req[slot]);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[slot].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(e){}var _148=this._getRequestString();if(typeof (this._rid)!="undefined"){this._req[slot].rid=this._rid;}this.oDbg.log("sending: "+_148,4);this._req[slot].r.send(_148);};JSJaCConnection.prototype._registerPID=function(pID,cb,arg){if(!pID||!cb){return false;}this._regIDs[pID]=new Object();this._regIDs[pID].cb=cb;if(arg){this._regIDs[pID].arg=arg;}this.oDbg.log("registered "+pID,3);return true;};JSJaCConnection.prototype._sendEmpty=function JSJaCSendEmpty(){var slot=this._getFreeSlot();this._req[slot]=this._setupRequest(true);this._req[slot].r.onreadystatechange=JSJaC.bind(function(){if(this._req[slot].r.readyState==4){this.oDbg.log("async recv: "+this._req[slot].r.responseText,4);this._getStreamID(slot);}},this);if(typeof (this._req[slot].r.onerror)!="undefined"){this._req[slot].r.onerror=JSJaC.bind(function(e){this.oDbg.log("XmlHttpRequest error",1);return false;},this);}var _14e=this._getRequestString();this.oDbg.log("sending: "+_14e,4);this._req[slot].r.send(_14e);};JSJaCConnection.prototype._sendRaw=function(xml,cb,arg){if(cb){this._sendRawCallbacks.push({fn:cb,arg:arg});}this._pQueue.push(xml);this._process();return true;};JSJaCConnection.prototype._setStatus=function(_152){if(!_152||_152==""){return;}if(_152!=this._status){this._status=_152;this._handleEvent("onstatuschanged",_152);this._handleEvent("status_changed",_152);}};JSJaCConnection.prototype._unregisterPID=function(pID){if(!this._regIDs[pID]){return false;}this._regIDs[pID]=null;this.oDbg.log("unregistered "+pID,3);return true;};function JSJaCConsoleLogger(_154){this.level=_154||4;this.start=function(){};this.log=function(msg,_156){_156=_156||0;if(_156>this.level){return;}if(typeof (console)=="undefined"){return;}try{switch(_156){case 0:console.warn(msg);break;case 1:console.error(msg);break;case 2:console.info(msg);break;case 4:console.debug(msg);break;default:console.log(msg);break;}}catch(e){try{console.log(msg);}catch(e){}}};this.setLevel=function(_157){this.level=_157;return this;};this.getLevel=function(){return this.level;};};function JSJaCCookie(name,_159,secs){if(window==this){return new JSJaCCookie(name,_159,secs);}this.name=name;this.value=_159;this.expires=secs;this.write=function(){if(this.secs){var date=new Date();date.setTime(date.getTime()+(this.secs*1000));var _15c="; expires="+date.toGMTString();}else{var _15c="";}document.cookie=this.getName()+"="+this.getValue()+_15c+"; path=/";};this.erase=function(){var c=new JSJaCCookie(this.getName(),"",-1);c.write();};this.getName=function(){return this.name;};this.setName=function(name){this.name=name;return this;};this.getValue=function(){return this.value;};this.setValue=function(_15f){this.value=_15f;return this;};};JSJaCCookie.read=function(name){var _161=name+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length);}if(c.indexOf(_161)==0){return new JSJaCCookie(name,c.substring(_161.length,c.length));}}throw new JSJaCCookieException("Cookie not found");};JSJaCCookie.get=function(name){return JSJaCCookie.read(name).getValue();};JSJaCCookie.remove=function(name){JSJaCCookie.read(name).erase();};function JSJaCCookieException(msg){this.message=msg;this.name="CookieException";};function JSJaCError(code,type,_16a){var _16b=XmlDocument.create("error","jsjac");_16b.documentElement.setAttribute("code",code);_16b.documentElement.setAttribute("type",type);_16b.documentElement.appendChild(_16b.createElement(_16a)).setAttribute("xmlns","urn:ietf:params:xml:ns:xmpp-stanzas");return _16b.documentElement;};var JSJACJID_FORBIDDEN=["\""," ","&","'","/",":","<",">","@"];function JSJaCJID(jid){this._node="";this._domain="";this._resource="";if(typeof (jid)=="string"){if(jid.indexOf("@")!=-1){this.setNode(jid.substring(0,jid.indexOf("@")));jid=jid.substring(jid.indexOf("@")+1);}if(jid.indexOf("/")!=-1){this.setResource(jid.substring(jid.indexOf("/")+1));jid=jid.substring(0,jid.indexOf("/"));}this.setDomain(jid);}else{this.setNode(jid.node);this.setDomain(jid.domain);this.setResource(jid.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(node){JSJaCJID._checkNodeName(node);this._node=node||"";return this;};JSJaCJID.prototype.setDomain=function(_16e){if(!_16e||_16e==""){throw new JSJaCJIDInvalidException("domain name missing");}JSJaCJID._checkNodeName(_16e);this._domain=_16e;return this;};JSJaCJID.prototype.setResource=function(_16f){this._resource=_16f||"";return this;};JSJaCJID.prototype.toString=function(){var jid="";if(this.getNode()&&this.getNode()!=""){jid=this.getNode()+"@";}jid+=this.getDomain();if(this.getResource()&&this.getResource()!=""){jid+="/"+this.getResource();}return jid;};JSJaCJID.prototype.removeResource=function(){return this.setResource();};JSJaCJID.prototype.clone=function(){return new JSJaCJID(this.toString());};JSJaCJID.prototype.isEntity=function(jid){if(typeof jid=="string"){jid=(new JSJaCJID(jid));}jid.removeResource();return (this.clone().removeResource().toString()===jid.toString());};JSJaCJID._checkNodeName=function(_172){if(!_172||_172==""){return;}for(var i=0;i<JSJACJID_FORBIDDEN.length;i++){if(_172.indexOf(JSJACJID_FORBIDDEN[i])!=-1){throw new JSJaCJIDInvalidException("forbidden char in nodename: "+JSJACJID_FORBIDDEN[i]);}}};function JSJaCJIDInvalidException(_174){this.message=_174;this.name="JSJaCJIDInvalidException";};function JSJaCKeys(func,oDbg){var seed=Math.random();this._k=new Array();this._k[0]=seed.toString();if(oDbg){this.oDbg=oDbg;}else{this.oDbg={};this.oDbg.log=function(){};}if(func){for(var i=1;i<JSJAC_NKEYS;i++){this._k[i]=func(this._k[i-1]);oDbg.log(i+": "+this._k[i],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(name){this.name=name;if(typeof (JSJACPACKET_USE_XMLNS)!="undefined"&&JSJACPACKET_USE_XMLNS){this.doc=XmlDocument.create(name,"jabber:client");}else{this.doc=XmlDocument.create(name,"");}};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(to){if(!to||to==""){this.getNode().removeAttribute("to");}else{if(typeof (to)=="string"){this.getNode().setAttribute("to",to);}else{this.getNode().setAttribute("to",to.toString());}}return this;};JSJaCPacket.prototype.setFrom=function(from){if(!from||from==""){this.getNode().removeAttribute("from");}else{if(typeof (from)=="string"){this.getNode().setAttribute("from",from);}else{this.getNode().setAttribute("from",from.toString());}}return this;};JSJaCPacket.prototype.setID=function(id){if(!id||id==""){this.getNode().removeAttribute("id");}else{this.getNode().setAttribute("id",id);}return this;};JSJaCPacket.prototype.setType=function(type){if(!type||type==""){this.getNode().removeAttribute("type");}else{this.getNode().setAttribute("type",type);}return this;};JSJaCPacket.prototype.setXMLLang=function(_17e){if(!_17e||_17e==""){this.getNode().removeAttribute("xml:lang");}else{this.getNode().setAttribute("xml:lang",_17e);}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;};JSJaCPacket.prototype.getChild=function(name,ns){if(!this.getNode()){return null;}name=name||"*";ns=ns||"*";if(this.getNode().getElementsByTagNameNS){return this.getNode().getElementsByTagNameNS(ns,name).item(0);}var _181=this.getNode().getElementsByTagName(name);if(ns!="*"){for(var i=0;i<_181.length;i++){if(_181.item(i).namespaceURI==ns){return _181.item(i);}}}else{return _181.item(0);}return null;};JSJaCPacket.prototype.getChildVal=function(name,ns){var node=this.getChild(name,ns);if(node&&node.firstChild){return node.firstChild.nodeValue;}else{return "";}};JSJaCPacket.prototype.clone=function(){return JSJaCPacket.wrapNode(this.getNode());};JSJaCPacket.prototype.isError=function(){return (this.getType()=="error");};JSJaCPacket.prototype.errorReply=function(_186){var _187=this.clone();_187.setTo(this.getFrom());_187.setFrom();_187.setType("error");_187.appendNode("error",{code:_186.code,type:_186.type},[[_186.cond]]);return _187;};JSJaCPacket.prototype.xml=function(){if(this.getDoc().xml){return this.getDoc().xml;}var xml=(new XMLSerializer()).serializeToString(this.getNode());if(typeof (xml)!="undefined"){return xml;}return (new XMLSerializer()).serializeToString(this.doc);};JSJaCPacket.prototype._getAttribute=function(attr){return this.getNode().getAttribute(attr);};JSJaCPacket.prototype._replaceNode=function(_18a){for(var i=0;i<_18a.attributes.length;i++){if(_18a.attributes.item(i).nodeName!="xmlns"){this.getNode().setAttribute(_18a.attributes.item(i).nodeName,_18a.attributes.item(i).nodeValue);}}for(var i=0;i<_18a.childNodes.length;i++){if(this.getDoc().importNode){this.getNode().appendChild(this.getDoc().importNode(_18a.childNodes.item(i),true));}else{this.getNode().appendChild(_18a.childNodes.item(i).cloneNode(true));}}};JSJaCPacket.prototype._setChildNode=function(_18c,_18d){var _18e=this.getChild(_18c);var _18f=this.getDoc().createTextNode(_18d);if(_18e){try{_18e.replaceChild(_18f,_18e.firstChild);}catch(e){}}else{_18e=this.getNode().appendChild(this.getDoc().createElement(_18c));_18e.appendChild(_18f);}return _18e;};JSJaCPacket.prototype.buildNode=function(_190){return JSJaCBuilder.buildNode(this.getDoc(),_190,arguments[1],arguments[2]);};JSJaCPacket.prototype.appendNode=function(_191){if(typeof _191=="object"){return this.getNode().appendChild(_191);}else{return this.getNode().appendChild(this.buildNode(_191,arguments[1],arguments[2]));}};function JSJaCPresence(){this.base=JSJaCPacket;this.base("presence");};JSJaCPresence.prototype=new JSJaCPacket;JSJaCPresence.prototype.setStatus=function(_192){this._setChildNode("status",_192);return this;};JSJaCPresence.prototype.setShow=function(show){if(show=="chat"||show=="away"||show=="xa"||show=="dnd"){this._setChildNode("show",show);}return this;};JSJaCPresence.prototype.setPriority=function(prio){this._setChildNode("priority",prio);return this;};JSJaCPresence.prototype.setPresence=function(show,_196,prio){if(show){this.setShow(show);}if(_196){this.setStatus(_196);}if(prio){this.setPriority(prio);}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(to,type,id){if(to){this.setTo(to);}if(type){this.setType(type);}if(id){this.setID(id);}return this;};JSJaCIQ.prototype.setQuery=function(_19b){var _19c;try{_19c=this.getDoc().createElementNS(_19b,"query");}catch(e){_19c=this.getDoc().createElement("query");}if(_19c&&_19c.getAttribute("xmlns")!=_19b){_19c.setAttribute("xmlns",_19b);}this.getNode().appendChild(_19c);return _19c;};JSJaCIQ.prototype.getQuery=function(){return this.getNode().getElementsByTagName("query").item(0);};JSJaCIQ.prototype.getQueryXMLNS=function(){if(this.getQuery()){return this.getQuery().namespaceURI;}else{return null;}};JSJaCIQ.prototype.reply=function(_19d){var rIQ=this.clone();rIQ.setTo(this.getFrom());rIQ.setType("result");if(_19d){if(typeof _19d=="string"){rIQ.getChild.appendChild(rIQ.getDoc().loadXML(_19d));}else{if(_19d.constructor==Array){var node=rIQ.getChild();for(var i=0;i<_19d.length;i++){if(typeof _19d[i]=="string"){node.appendChild(rIQ.getDoc().loadXML(_19d[i]));}else{if(typeof _19d[i]=="object"){node.appendChild(_19d[i]);}}}}else{if(typeof _19d=="object"){rIQ.getChild().appendChild(_19d);}}}}return rIQ;};function JSJaCMessage(){this.base=JSJaCPacket;this.base("message");};JSJaCMessage.prototype=new JSJaCPacket;JSJaCMessage.prototype.setBody=function(body){this._setChildNode("body",body);return this;};JSJaCMessage.prototype.setSubject=function(_1a2){this._setChildNode("subject",_1a2);return this;};JSJaCMessage.prototype.setThread=function(_1a3){this._setChildNode("thread",_1a3);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(node){var _1a5;switch(node.nodeName.toLowerCase()){case "presence":_1a5=new JSJaCPresence();break;case "message":_1a5=new JSJaCMessage();break;case "iq":_1a5=new JSJaCIQ();break;default:return null;}_1a5._replaceNode(node);return _1a5;};function JSJaCHttpBindingConnection(oArg){this.base=JSJaCConnection;this.base(oArg);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(oArg){this.domain=oArg.domain||"localhost";this.username=oArg.username;this.resource=oArg.resource;this._sid=oArg.sid;this._rid=oArg.rid;this._min_polling=oArg.polling;this._inactivity=oArg.inactivity;this._setHold(oArg.requests-1);this.setPollInterval(this._timerval);if(oArg.wait){this._wait=oArg.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(_1a8){if(_1a8&&!isNaN(_1a8)){if(!this.isPolling()){this._timerval=100;}else{if(this._min_polling&&_1a8<this._min_polling*1000){this._timerval=this._min_polling*1000;}else{if(this._inactivity&&_1a8>this._inactivity*1000){this._timerval=this._inactivity*1000;}else{this._timerval=_1a8;}}}}return this._timerval;};JSJaCHttpBindingConnection.prototype.isPolling=function(){return (this._hold==0);};JSJaCHttpBindingConnection.prototype._getFreeSlot=function(){for(var i=0;i<this._hold+1;i++){if(typeof (this._req[i])=="undefined"||typeof (this._req[i].r)=="undefined"||this._req[i].r.readyState==4){return i;}}return -1;};JSJaCHttpBindingConnection.prototype._getHold=function(){return this._hold;};JSJaCHttpBindingConnection.prototype._getRequestString=function(raw,last){raw=raw||"";var _1ac="";if(this._rid<=this._last_rid&&typeof (this._last_requests[this._rid])!="undefined"){_1ac=this._last_requests[this._rid].xml;}else{var xml="";while(this._pQueue.length){var _1ae=this._pQueue[0];xml+=_1ae;this._pQueue=this._pQueue.slice(1,this._pQueue.length);}_1ac="<body rid='"+this._rid+"' sid='"+this._sid+"' xmlns='http://jabber.org/protocol/httpbind' ";if(JSJAC_HAVEKEYS){_1ac+="key='"+this._keys.getKey()+"' ";if(this._keys.lastKey()){this._keys=new JSJaCKeys(hex_sha1,this.oDbg);_1ac+="newkey='"+this._keys.getKey()+"' ";}}if(last){_1ac+="type='terminate' ";}else{if(this._reinit){if(JSJACHBC_USE_BOSH_VER){_1ac+="xmpp:restart='true' ";}this._reinit=false;}}if(xml!=""||raw!=""){_1ac+=">"+raw+xml+"</body>";}else{_1ac+="/>";}this._last_requests[this._rid]=new Object();this._last_requests[this._rid].xml=_1ac;this._last_rid=this._rid;for(var i in this._last_requests){if(this._last_requests.hasOwnProperty(i)&&i<this._rid-this._hold){delete (this._last_requests[i]);}}}return _1ac;};JSJaCHttpBindingConnection.prototype._getInitialRequestString=function(){var _1b0="<body hold='"+this._hold+"' xmlns='http://jabber.org/protocol/httpbind' to='"+this.authhost+"' wait='"+this._wait+"' rid='"+this._rid+"'";if(this.host||this.port){_1b0+=" route='xmpp:"+this.host+":"+this.port+"'";}if(this.secure){_1b0+=" secure='"+this.secure+"'";}if(JSJAC_HAVEKEYS){this._keys=new JSJaCKeys(hex_sha1,this.oDbg);key=this._keys.getKey();_1b0+=" newkey='"+key+"'";}if(this._xmllang){_1b0+=" xml:lang='"+this._xmllang+"'";}if(JSJACHBC_USE_BOSH_VER){_1b0+=" ver='"+JSJACHBC_BOSH_VERSION+"'";_1b0+=" xmpp:xmlns='urn:xmpp:xbosh'";if(this.authtype=="sasl"||this.authtype=="saslanon"){_1b0+=" xmpp:version='1.0'";}}_1b0+="/>";return _1b0;};JSJaCHttpBindingConnection.prototype._getStreamID=function(slot){this.oDbg.log(this._req[slot].r.responseText,4);if(!this._req[slot].r.responseXML||!this._req[slot].r.responseXML.documentElement){this._handleEvent("onerror",JSJaCError("503","cancel","service-unavailable"));return;}var body=this._req[slot].r.responseXML.documentElement;if(body.getAttribute("authid")){this.streamid=body.getAttribute("authid");this.oDbg.log("got streamid: "+this.streamid,2);}else{this._timeout=setTimeout(JSJaC.bind(this._sendEmpty,this),this.getPollInterval());return;}this._timeout=setTimeout(JSJaC.bind(this._process,this),this.getPollInterval());if(!this._parseStreamFeatures(body)){return;}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(slot){try{this.oDbg.log(this._req[slot].r.getAllResponseHeaders(),4);this.oDbg.log(this._req[slot].r.responseText,4);}catch(ex){this.oDbg.log("No response",4);}if(this._req[slot].r.status!=200||!this._req[slot].r.responseXML){this.oDbg.log("initial response broken (status: "+this._req[slot].r.status+")",1);this._handleEvent("onerror",JSJaCError("503","cancel","service-unavailable"));return;}var body=this._req[slot].r.responseXML.documentElement;if(!body||body.tagName!="body"||body.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(body.getAttribute("type")=="terminate"){this.oDbg.log("invalid response:\n"+this._req[slot].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=body.getAttribute("sid");this.oDbg.log("got sid: "+this._sid,2);if(body.getAttribute("polling")){this._min_polling=body.getAttribute("polling");}if(body.getAttribute("inactivity")){this._inactivity=body.getAttribute("inactivity");}if(body.getAttribute("requests")){this._setHold(body.getAttribute("requests")-1);}this.oDbg.log("set hold to "+this._getHold(),2);if(body.getAttribute("ver")){this._bosh_version=body.getAttribute("ver");}if(body.getAttribute("maxpause")){this._pause=Number.max(body.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(slot);};JSJaCHttpBindingConnection.prototype._parseResponse=function(req){if(!this.connected()||!req){return null;}var r=req.r;try{if(r.status==404||r.status==403){this._abort();return null;}if(r.status!=200||!r.responseXML){this._errcnt++;var _1b7="invalid response ("+r.status+"):\n"+r.getAllResponseHeaders()+"\n"+r.responseText;if(!r.responseXML){_1b7+="\nResponse failed to parse!";}this.oDbg.log(_1b7,1);if(this._errcnt>JSJAC_ERR_COUNT){this._abort();return null;}this.oDbg.log("repeating ("+this._errcnt+")",1);this._setStatus("proto_error_fallback");setTimeout(JSJaC.bind(this._resume,this),this.getPollInterval());return null;}}catch(e){this.oDbg.log("XMLHttpRequest error: status not available",1);this._errcnt++;if(this._errcnt>JSJAC_ERR_COUNT){this._abort();}else{this.oDbg.log("repeating ("+this._errcnt+")",1);this._setStatus("proto_error_fallback");setTimeout(JSJaC.bind(this._resume,this),this.getPollInterval());}return null;}var body=r.responseXML.documentElement;if(!body||body.tagName!="body"||body.namespaceURI!="http://jabber.org/protocol/httpbind"){this.oDbg.log("invalid response:\n"+r.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 (req.rid)!="undefined"&&this._last_requests[req.rid]){if(this._last_requests[req.rid].handled){this.oDbg.log("already handled "+req.rid,2);return null;}else{this._last_requests[req.rid].handled=true;}}if(body.getAttribute("type")=="terminate"){this.oDbg.log("session terminated:\n"+r.responseText,1);clearTimeout(this._timeout);clearInterval(this._interval);clearInterval(this._inQto);if(body.getAttribute("condition")=="remote-stream-error"){if(body.getElementsByTagName("conflict").length>0){this._setStatus("session-terminate-conflict");}}this._handleEvent("onerror",JSJaCError("503","cancel",body.getAttribute("condition")));this._connected=false;this.oDbg.log("Disconnected.",1);this._handleEvent("ondisconnect");return null;}this._errcnt=0;return r.responseXML.documentElement;};JSJaCHttpBindingConnection.prototype._reInitStream=function(to,cb,arg){this._reinit=true;cb.call(this,arg);};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(hold){if(!hold||isNaN(hold)||hold<0){hold=0;}else{if(hold>JSJACHBC_MAX_HOLD){hold=JSJACHBC_MAX_HOLD;}}this._hold=hold;return this._hold;};JSJaCHttpBindingConnection.prototype._setupRequest=function(_1bd){var req=new Object();var r=XmlHttp.create();try{r.open("POST",this._httpbase,_1bd);r.setRequestHeader("Content-Type","text/xml; charset=utf-8");}catch(e){this.oDbg.log(e,1);}req.r=r;this._rid++;req.rid=this._rid;return req;};JSJaCHttpBindingConnection.prototype._suspend=function(){if(this._pause==0){return;}var slot=this._getFreeSlot();this._req[slot]=this._setupRequest(false);var _1c1="<body pause='"+this._pause+"' xmlns='http://jabber.org/protocol/httpbind' sid='"+this._sid+"' rid='"+this._rid+"'";if(JSJAC_HAVEKEYS){_1c1+=" key='"+this._keys.getKey()+"'";if(this._keys.lastKey()){this._keys=new JSJaCKeys(hex_sha1,this.oDbg);_1c1+=" newkey='"+this._keys.getKey()+"'";}}_1c1+=">";while(this._pQueue.length){var _1c2=this._pQueue[0];_1c1+=_1c2;this._pQueue=this._pQueue.slice(1,this._pQueue.length);}_1c1+="</body>";this.oDbg.log("Disconnecting: "+_1c1,4);this._req[slot].r.send(_1c1);};function JSJaCHttpPollingConnection(oArg){this.base=JSJaCConnection;this.base(oArg);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 _1c4="0";if(JSJAC_HAVEKEYS){this._keys=new JSJaCKeys(b64_sha1,this.oDbg);key=this._keys.getKey();_1c4+=";"+key;}var _1c5=this.domain;if(this.authhost){_1c5=this.authhost;}_1c4+=",<stream:stream to='"+_1c5+"' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'";if(this.authtype=="sasl"||this.authtype=="saslanon"){_1c4+=" version='1.0'";}_1c4+=">";return _1c4;};JSJaCHttpPollingConnection.prototype._getRequestString=function(raw,last){var _1c8=this._sid;if(JSJAC_HAVEKEYS){_1c8+=";"+this._keys.getKey();if(this._keys.lastKey()){this._keys=new JSJaCKeys(b64_sha1,this.oDbg);_1c8+=";"+this._keys.getKey();}}_1c8+=",";if(raw){_1c8+=raw;}while(this._pQueue.length){_1c8+=this._pQueue[0];this._pQueue=this._pQueue.slice(1,this._pQueue.length);}if(last){_1c8+="</stream:stream>";}return _1c8;};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 doc;try{var _1ca=this._req[0].r.responseText;if(!_1ca.match(/<\/stream:stream>\s*$/)){_1ca+="</stream:stream>";}doc=XmlDocument.create("doc");doc.loadXML(_1ca);if(!this._parseStreamFeatures(doc)){return;}}catch(e){this.oDbg.log("loadXML: "+e.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 _1cb=this._req[0].r.getResponseHeader("Set-Cookie");_1cb=_1cb.split(";");for(var i=0;i<_1cb.length;i++){aArg=_1cb[i].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(r){var req=r.r;if(!this.connected()){return null;}if(req.status!=200){this.oDbg.log("invalid response ("+req.status+"):"+req.responseText+"\n"+req.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(req.getAllResponseHeaders(),4);var sid,_1d0=req.getResponseHeader("Set-Cookie");if(_1d0==null){sid="-1:0";}else{_1d0=_1d0.split(";");var sid;for(var i=0;i<_1d0.length;i++){var aArg=_1d0[i].split("=");if(aArg[0]=="ID"){sid=aArg[1];}}}if(typeof (sid)!="undefined"&&sid.indexOf(":0")!=-1){switch(sid.substring(0,sid.indexOf(":0"))){case "0":this.oDbg.log("invalid response:"+req.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(!req.responseText||req.responseText==""){return null;}try{var _1d3=req.responseText.replace(/\<\?xml.+\?\>/,"");if(_1d3.match(/<stream:stream/)){_1d3+="</stream:stream>";}var doc=JSJaCHttpPollingConnection._parseTree("<body>"+_1d3+"</body>");if(!doc||doc.tagName=="parsererror"){this.oDbg.log("parsererror",1);doc=JSJaCHttpPollingConnection._parseTree("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"+req.responseText);if(doc&&doc.tagName!="parsererror"){this.oDbg.log("stream closed",1);if(doc.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:"+doc,1);}return doc;}return doc;}catch(e){this.oDbg.log("parse error:"+e.message,1);}return null;};JSJaCHttpPollingConnection.prototype._reInitStream=function(to,cb,arg){this._sendRaw("<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='"+to+"' version='1.0'>",cb,arg);};JSJaCHttpPollingConnection.prototype._resume=function(){this._process(this._timerval);};JSJaCHttpPollingConnection.prototype._setupRequest=function(_1d8){var r=XmlHttp.create();try{r.open("POST",this._httpbase,_1d8);if(r.overrideMimeType){r.overrideMimeType("text/plain; charset=utf-8");}r.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}catch(e){this.oDbg.log(e,1);}var req=new Object();req.r=r;return req;};JSJaCHttpPollingConnection.prototype._suspend=function(){};JSJaCHttpPollingConnection._parseTree=function(s){try{var r=XmlDocument.create("body","foo");if(typeof (r.loadXML)!="undefined"){r.loadXML(s);return r.documentElement;}else{if(window.DOMParser){return (new DOMParser()).parseFromString(s,"text/xml").documentElement;}}}catch(e){}return null;};var JSJaC={Version:"1.3",require:function(_1dd){document.write("<script type=\"text/javascript\" src=\""+_1dd+"\"></script>");},load:function(){var _1de=["xmlextras","jsextras","crypt","JSJaCConfig","JSJaCConstants","JSJaCCookie","JSJaCJSON","JSJaCJID","JSJaCBuilder","JSJaCPacket","JSJaCError","JSJaCKeys","JSJaCConnection","JSJaCHttpPollingConnection","JSJaCHttpBindingConnection","JSJaCConsoleLogger"];var _1df=document.getElementsByTagName("script");var path="./";for(var i=0;i<_1df.length;i++){if(_1df.item(i).src&&_1df.item(i).src.match(/JSJaC\.js$/)){path=_1df.item(i).src.replace(/JSJaC.js$/,"");break;}}for(var i=0;i<_1de.length;i++){this.require(path+_1de[i]+".js");}},bind:function(fn,obj,arg){return function(){if(arg){fn.apply(obj,arg);}else{fn.apply(obj);}};}};if(typeof JSJaCConnection=="undefined"){JSJaC.load();}