Index: /branches/2.2/jabberit_messenger/jmessenger/js/strophe.mini.js
===================================================================
--- /branches/2.2/jabberit_messenger/jmessenger/js/strophe.mini.js	(revision 4475)
+++ /branches/2.2/jabberit_messenger/jmessenger/js/strophe.mini.js	(revision 4481)
@@ -1,467 +1,254 @@
-DOMObjects={xmlParse:function(xmlString){var xmlObj=this.xmlRender(xmlString);if(xmlObj){try{if(this.processor==undefined){this.processor=new XSLTProcessor();this.processor.importStylesheet(this.xmlRender('<xsl:stylesheet version="1.0"\
-                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\
-                    <xsl:output method="html" indent="yes"/><xsl:template\
-                    match="@*|node()"><xsl:copy><xsl:copy-of\
-                    select="@*|node()"/></xsl:copy></xsl:template>\
-                    </xsl:stylesheet>'));}
-var htmlObj=this.processor.transformToDocument(xmlObj).documentElement;if(htmlObj.tagName.toLowerCase()=='html'){htmlObj=htmlObj.firstChild.firstChild;}
-return document.importNode(htmlObj,true);}catch(e){try{var htmlObj=document.importNode(xmlObj.documentElement,true);if(htmlObj.tagName.toLowerCase()=="div"){var div_wrapper=document.createElement('div');div_wrapper.appendChild(htmlObj);if(div_wrapper.innerHTML){div_wrapper.innerHTML=div_wrapper.innerHTML;}
-htmlObj=div_wrapper.firstChild;}
-return htmlObj;}catch(e){alert("TrophyIM Error: Cannot add html to page "+e.message);}}}},xmlRender:function(xmlString){try{var renderObj=new ActiveXObject("Microsoft.XMLDOM");renderObj.async="false";if(xmlString){renderObj.loadXML(xmlString);}}catch(e){try{if(this.parser==undefined){this.parser=new DOMParser();}
-var renderObj=this.parser.parseFromString(xmlString,"application/xml");}catch(e){alert("TrophyIM Error: Cannot create new html for page");}}
-return renderObj;},getHTML:function(page)
-{return this.xmlParse(HTMLSnippets[page]);},getScript:function(script)
-{var newscript=document.createElement('script');newscript.setAttribute('src',script);newscript.setAttribute('type','text/javascript');return newscript;}};TrophyIM={controll:{notificationNewUsers:0},autoConnection:{connect:true},activeChatRoom:{name:[]},chatHistory:{},constants:{stale_roster:false},posWindow:{left:400,top:100},statusConn:{connected:false},_timeOut:{renderRoster:null},removeResult:{idResult:[]},setCookie:function(name,value)
-{var expire=new Date();expire.setDate(expire.getDate()+365);document.cookie=name+"="+value+"; expires="+expire.toGMTString();},delCookie:function(name)
-{var expire=new Date();expire.setDate(expire.getDate()-365);document.cookie=name+"= ; expires="+expire.toGMTString();delete TrophyIM.cookies[name];},getCookies:function()
-{var cObj={};var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++)
-{while(cookies[i].charAt(0)==' ')
-{cookies[i]=cookies[i].substring(1,cookies[i].length);}
-if(cookies[i].substr(0,8)=="trophyim")
-{var nvpair=cookies[i].split("=",2);cObj[nvpair[0]]=nvpair[1];TrophyIM.setCookie(nvpair[0],nvpair[1]);}}
-return cObj;},load:function()
-{if(loadscript.getUserCurrent()==null)
-{loadscript.setUserCurrent();}
-if(!TrophyIM.statusConn.connected)
-{TrophyIM.cookies=TrophyIM.getCookies();setTimeout("TrophyIM.showLogin()",550);}
-else
-{loadscript.rosterDiv();}},storeData:function()
-{if(TrophyIM.connection&&TrophyIM.connection.connected)
-{TrophyIM.setCookie('trophyim_bosh_xid',TrophyIM.connection.jid+"|"+
-TrophyIM.connection.sid+"|"+TrophyIM.connection.rid);TrophyIM.rosterObj.save();}},showLogin:function()
-{if(typeof(JSON)!=undefined&&typeof(Strophe)!=undefined)
-{TrophyIM.JSONStore=new TrophyIMJSONStore();if(TrophyIM.JSONStore.store_working&&TrophyIM.cookies['trophyim_bosh_xid'])
-{var xids=TrophyIM.cookies['trophyim_bosh_xid'].split("|");TrophyIM.delCookie('trophyim_bosh_xid');TrophyIM.constants.stale_roster=true;TrophyIM.connection=new Strophe.Connection(TROPHYIM_BOSH_SERVICE);TrophyIM.connection.rawInput=TrophyIM.rawInput;TrophyIM.connection.rawOutput=TrophyIM.rawOutput;Strophe.info('Attempting Strophe attach.');TrophyIM.connection.attach(xids[0],xids[1],xids[2],TrophyIM.onConnect);TrophyIM.onConnect(Strophe.Status.CONNECTED);}
-else
-{loadscript.rosterDiv();var _getUserCurrent=null;_getUserCurrent=loadscript.getUserCurrent();if(_getUserCurrent==null)
-{setTimeout("TrophyIM.showLogin()",500);}
-else
-{TrophyIM.login(Base64.decode(_getUserCurrent.jid),Base64.decode(_getUserCurrent.password));}}}
-else
-{setTimeout("TrophyIM.showLogin()",500);}},log:function(level,msg)
-{if(TrophyIM.logging_div&&level>=TROPHYIM_LOGLEVEL)
-{while(TrophyIM.logging_div.childNodes.length>TROPHYIM_LOG_LINES)
-{TrophyIM.logging_div.removeChild(TrophyIM.logging_div.firstChild);}
-var msg_div=document.createElement('div');msg_div.className='trophyimlogitem';msg_div.appendChild(document.createTextNode(msg));TrophyIM.logging_div.appendChild(msg_div);TrophyIM.logging_div.scrollTop=TrophyIM.logging_div.scrollHeight;}},rawInput:function(data)
-{Strophe.debug("RECV: "+data);},rawOutput:function(data)
-{Strophe.debug("SEND: "+data);},login:function()
-{if(TrophyIM.JSONStore.store_working)
-{TrophyIM.JSONStore.delData(['groups','roster','active_chat','chat_history']);}
-TrophyIM.connection=new Strophe.Connection(TROPHYIM_BOSH_SERVICE);TrophyIM.connection.rawInput=TrophyIM.rawInput;TrophyIM.connection.rawOutput=TrophyIM.rawOutput;if(arguments.length>0)
-{var barejid=arguments[0];var password=arguments[1];TrophyIM.connection.connect(barejid+TROPHYIM_RESOURCE,password,TrophyIM.onConnect);}
-else
-{var barejid=document.getElementById('trophyimjid').value
-var fulljid=barejid+TROPHYIM_RESOURCE;var password=document.getElementById('trophyimpass').value;var button=document.getElementById('trophyimconnect');loadscript.setUserCurrent(barejid,password);if(button.value=='connect')
-{button.value='disconnect';TrophyIM.login(barejid,password);_winBuild('window_login_page','remove');}}
-TrophyIM.setCookie('trophyimjid',barejid);},logout:function()
-{TrophyIM.autoConnection.connect=false;TrophyIM.delCookie('trophyim_bosh_xid');delete TrophyIM['cookies']['trophyim_bosh_xid'];TrophyIM.connection.disconnect();},onConnect:function(status)
-{var loading_gif=document.getElementById("JabberIMRosterLoadingGif");if(status==Strophe.Status.CONNECTING)
-{loading_gif.style.display="block";Strophe.info('Strophe is connecting.');}
-if(status==Strophe.Status.CONNFAIL)
-{TrophyIM.delCookie('trophyim_bosh_xid');TrophyIM.statusConn.connected=false;loading_gif.style.display="block";}
-if(status==Strophe.Status.DISCONNECTING)
-{TrophyIM.statusConn.connected=false;}
-if(status==Strophe.Status.DISCONNECTED)
-{if(TrophyIM.autoConnection.connect)
-{loading_gif.style.display="block";TrophyIM.delCookie('trophyim_bosh_xid');TrophyIM.statusConn.connected=false;setTimeout(function()
-{TrophyIM.showLogin();},10000);loadscript.clrAllContacts();loadscript.setStatusJabber(i18n.STATUS_ANAVAILABLE,"unavailable");delete TrophyIM.rosterObj.roster;delete TrophyIM.rosterObj.groups;}}
-if(status==Strophe.Status.CONNECTED)
-{loadscript.setStatusJabber(i18n.STATUS_AVAILABLE,'available');TrophyIM.statusConn.connected=true;TrophyIM.showClient();}},showClient:function()
-{TrophyIM.setCookie('trophyim_bosh_xid',TrophyIM.connection.jid+"|"+
-TrophyIM.connection.sid+"|"+TrophyIM.connection.rid);TrophyIM.rosterObj=new TrophyIMRoster();TrophyIM.connection.addHandler(TrophyIM.onVersion,Strophe.NS.VERSION,'iq',null,null,null);TrophyIM.connection.addHandler(TrophyIM.onRoster,Strophe.NS.ROSTER,'iq',null,null,null);TrophyIM.connection.addHandler(TrophyIM.onPresence,null,'presence',null,null,null);TrophyIM.connection.addHandler(TrophyIM.onMessage,null,'message',null,null,null);TrophyIM.connection.send($iq({type:'get',xmlns:Strophe.NS.CLIENT}).c('query',{xmlns:Strophe.NS.ROSTER}).tree());TrophyIM.connection.send($pres().tree());setTimeout(TrophyIM.renderRoster,1000);},clearClient:function()
-{if(TrophyIM.logging_div)
-{var logging_div=TrophyIM.client_div.removeChild(document.getElementById('trophyimlog'));}
-else
-{var logging_div=null;}
-while(TrophyIM.client_div.childNodes.length>0)
-{TrophyIM.client_div.removeChild(TrophyIM.client_div.firstChild);}
-return logging_div;},onVersion:function(msg)
-{Strophe.debug("Version handler");if(msg.getAttribute('type')=='get')
-{var from=msg.getAttribute('from');var to=msg.getAttribute('to');var id=msg.getAttribute('id');var reply=$iq({type:'result',to:from,from:to,id:id}).c('query',{name:"TrophyIM",version:TROPHYIM_VERSION,os:"Javascript-capable browser"});TrophyIM.connection.send(reply.tree());}
-return true;},onRoster:function(msg)
-{var roster_items=msg.firstChild.getElementsByTagName('item');for(var i=0;i<roster_items.length;i++)
-{with(roster_items[i])
-{var groups=getElementsByTagName('group');var group_array=[];for(var g=0;g<groups.length;g++)
-{if(groups[g].hasChildNodes())
-group_array[group_array.length]=groups[g].firstChild.nodeValue;}
-if(getAttribute('ask')&&getAttribute('ask').toString()==="subscribe")
-{if(getAttribute('subscription').toString()==="none")
-{TrophyIM.rosterObj.addContact(getAttribute('jid'),getAttribute('ask'),getAttribute('name'),group_array);}
-if(getAttribute('subscription').toString()==="remove")
-{TrophyIM.rosterObj.removeContact(getAttribute('jid').toString());}}
-else
-{if((getAttribute('ask')==null&&getAttribute('subscription').toString()==="remove")||getAttribute('subscription').toString()==="remove")
-{TrophyIM.rosterObj.removeContact(getAttribute('jid').toString());}
-else
-{TrophyIM.rosterObj.addContact(getAttribute('jid'),getAttribute('subscription'),getAttribute('name'),group_array);}}}}
-if(msg.getAttribute('type')=='set')
-{var _iq=$iq({type:'reply',id:msg.getAttribute('id'),to:msg.getAttribute('from')});TrophyIM.connection.send(_iq.tree());}
-return true;},onPresence:function(msg)
-{TrophyIM.onPresenceChatRoom(msg);var type=msg.getAttribute('type')?msg.getAttribute('type'):'available';var show=msg.getElementsByTagName('show').length?Strophe.getText(msg.getElementsByTagName('show')[0]):type;var status=msg.getElementsByTagName('status').length?Strophe.getText(msg.getElementsByTagName('status')[0]):'';var priority=msg.getElementsByTagName('priority').length?parseInt(Strophe.getText(msg.getElementsByTagName('priority')[0])):0;if(msg.getAttribute('from').toString().indexOf(TROPHYIM_CHATROOM)<0)
-{var _from=Strophe.getBareJidFromJid(msg.getAttribute('from'));var _flag=true;if(TrophyIM.removeResult.idResult.length>0)
-{for(var i=0;i<TrophyIM.removeResult.idResult.length;i++)
-{if(TrophyIM.removeResult.idResult[i]==_from)
-{_flag=false;TrophyIM.removeResult.idResult.splice(i,1);i--;if(show.toLowerCase()==='subscribe')
-_flag=true;}}}
-if(_flag)
-TrophyIM.rosterObj.setPresence(msg.getAttribute('from'),priority,show,status);}
-return true;},onPresenceChatRoom:function(msg)
-{var xquery=msg.getElementsByTagName("x");var _error=msg.getElementsByTagName("error");if(_error.length>0)
-{for(var i=0;i<_error.length;i++)
-{if(_error[i].getElementsByTagName("text"))
-{var _errorMsg=Strophe.getText(_error[i].getElementsByTagName("text")[0]);if(_errorMsg=="Room creation is denied by service policy")
-{alert(i18n.ROOM_CREATION_IS_DENIED_BY_SERVICE_POLICY);}
-else
-{alert(" Informe ao seu Administrador ERRO : \n"+_errorMsg);}}}}
-else
-{if(xquery.length>0)
-{for(var i=0;i<xquery.length;i++)
-{var xmlns=xquery[i].getAttribute("xmlns");if(xmlns.indexOf("http://jabber.org/protocol/muc#user")==0)
-{var _from=xquery[i].parentNode.getAttribute('from');var _to=xquery[i].parentNode.getAttribute('to');var nameChatRoom=Strophe.getBareJidFromJid(_from);var nickName=Strophe.getResourceFromJid(_from);var type=(xquery[i].parentNode.getAttribute('type')!=null)?xquery[i].parentNode.getAttribute('type'):'available';var show=(xquery[i].parentNode.firstChild.nodeName=="show")?xquery[i].parentNode.firstChild.firstChild.nodeValue:type;var _idElement=nameChatRoom+"_UserChatRoom__"+nickName;var _UserChatRoom=document.createElement("div");_UserChatRoom.id=_idElement;_UserChatRoom.style.paddingLeft='18px';_UserChatRoom.style.margin='3px 0px 0px 2px';_UserChatRoom.style.background='url("'+path_jabberit+'templates/default/images/'+show+'.gif") no-repeat center left';_UserChatRoom.appendChild(document.createTextNode(nickName));var nodeUser=document.getElementById(_idElement);if(nodeUser==null)
-{if(document.getElementById(nameChatRoom+'__roomChat__participants')!=null)
-{nameChatRoom=document.getElementById(nameChatRoom+'__roomChat__participants');nameChatRoom.appendChild(_UserChatRoom);}
-else
-{if(type!='unavailable')
-{TrophyIM.makeChatRoom(nameChatRoom,nameChatRoom.substring(0,nameChatRoom.indexOf('@')));nameChatRoom=document.getElementById(nameChatRoom+'__roomChat__participants');nameChatRoom.appendChild(_UserChatRoom);}}}
-else
-{if(type=='unavailable')
-{nodeUser.parentNode.removeChild(nodeUser);}
-else if(show)
-{nodeUser.style.backgroundImage='url("'+path_jabberit+'templates/default/images/'+show+'.gif")';}}}}}}},onMessage:function(msg)
-{var checkTime=function(i)
-{if(i<10)i="0"+i;return i;};var messageDate=function(_date)
-{var _dt=_date.substr(0,_date.indexOf('T')).split('-');var _hr=_date.substr(_date.indexOf('T')+1,_date.length-_date.indexOf('T')-2).split(':');(_date=new Date).setTime(Date.UTC(_dt[0],_dt[1]-1,_dt[2],_hr[0],_hr[1],_hr[2]));return(_date.toLocaleDateString().replace(/-/g,'/')+' '+_date.toLocaleTimeString());};var data=new Date();var dtNow=checkTime(data.getHours())+":"+checkTime(data.getMinutes())+":"+checkTime(data.getSeconds());var from=msg.getAttribute('from');var type=msg.getAttribute('type');var elems=msg.getElementsByTagName('body');var delay=(msg.getElementsByTagName('delay'))?msg.getElementsByTagName('delay'):null;var stamp=(delay[0]!=null)?"<font style='color:red;'>"+messageDate(delay[0].getAttribute('stamp'))+"</font>":dtNow;var barejid=Strophe.getBareJidFromJid(from);var jidChatRoom=Strophe.getResourceFromJid(from);var jid_lower=barejid.toLowerCase();var contact="";var state="";var chatBox=document.getElementById(jid_lower+"__chatState");var chatStateOnOff=null;var active=msg.getElementsByTagName('active');contact=barejid.toLowerCase();contact=contact.substring(0,contact.indexOf('@'));if(TrophyIM.rosterObj.roster[barejid])
-{if(TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'])
-{contact=TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'];}}
-if(elems.length>0)
-{state="";chatStateOnOff=document.getElementById(jid_lower+"__chatStateOnOff");if(active.length>0&chatStateOnOff!=null)
-{chatStateOnOff.value='on';}
-var _message=document.createElement("div");var _text=Strophe.getText(elems[0]);_text=_text.replace(/onblur/gi,"EVENT_DENY");_text=_text.replace(/onchange/gi,"EVENT_DENY");_text=_text.replace(/onclick/gi,"EVENT_DENY");_text=_text.replace(/ondblclick/gi,"EVENT_DENY");_text=_text.replace(/onerror/gi,"EVENT_DENY");_text=_text.replace(/onfocus/gi,"EVENT_DENY");_text=_text.replace(/onkeydown/gi,"EVENT_DENY");_text=_text.replace(/onkeypress/gi,"EVENT_DENY");_text=_text.replace(/onkeyup/gi,"EVENT_DENY");_text=_text.replace(/onmousedown/gi,"EVENT_DENY");_text=_text.replace(/onmousemove/gi,"EVENT_DENY");_text=_text.replace(/onmouseout/gi,"EVENT_DENY");_text=_text.replace(/onmouseover/gi,"EVENT_DENY");_text=_text.replace(/onmouseup/gi,"EVENT_DENY");_text=_text.replace(/onresize/gi,"EVENT_DENY");_text=_text.replace(/onselect/gi,"EVENT_DENY");_text=_text.replace(/onunload/gi,"EVENT_DENY");_text=_text.replace(/style/gi,"EVENT_DENY");_text=_text.replace(/img /gi,"IMG_DENY ");_text=_text.replace(/script /gi,"SCRIPT_DENY ");_text=_text.replace(/div /gi,"DIV_DENY ");_text=_text.replace(/span /gi,"SPAN_DENY ");_text=_text.replace(/iframe /gi,"IFRAME_DENY ");_message.innerHTML=_text;var scripts=_message.getElementsByTagName('script_deny');for(var i=0;i<scripts.length;i++){_message.removeChild(scripts[i--]);}
-var _imgSrc=_message.getElementsByTagName('img_deny');for(var i=0;i<_imgSrc.length;i++){_imgSrc[i].parentNode.removeChild(_imgSrc[i--]);}
-var _Div=_message.getElementsByTagName('div_deny');for(var i=0;i<_Div.length;i++){_Div[i].parentNode.removeChild(_Div[i--]);}
-var _Span=_message.getElementsByTagName('span_deny');for(var i=0;i<_Span.length;i++){_Span[i].parentNode.removeChild(_Span[i--]);}
-var _Iframe=_message.getElementsByTagName('iframe_deny');for(var i=0;i<_Iframe.length;i++){_Iframe[i].parentNode.removeChild(_Iframe[i--]);}
-var _aHref=_message.getElementsByTagName('a');for(var i=0;i<_aHref.length;i++){_aHref[i].parentNode.removeChild(_aHref[i--]);}
-_message.innerHTML=_message.innerHTML.replace(/^\s+|\s+$|^\n|\n$/g,"");_message.innerHTML=loadscript.getSmiles(_message.innerHTML);if(type=='chat'||type=='normal')
-{if(_message.hasChildNodes())
-{var message={contact:"["+stamp+"] <font style='font-weight:bold; color:black;'>"+contact+"</font>",msg:"</br>"+_message.innerHTML};TrophyIM.addMessage(TrophyIM.makeChat(from),jid_lower,message);}}
-else if(type=='groupchat')
-{if(_message.hasChildNodes())
-{var message={contact:"["+stamp+"] <font style='font-weight:bold; color:black;'>"+jidChatRoom+"</font>",msg:"</br>"+_message.innerHTML};TrophyIM.addMessage(TrophyIM.makeChatRoom(barejid),jid_lower,message);}}}
-else
-{if(chatBox!=null)
-state=TrophyIM.getChatState(msg);}
-var clearChatState=function()
-{chatBox.innerHTML='';}
-if(chatBox!=null)
-{var clearChatStateTimer;chatBox.innerHTML="<font style='font-weight:bold; color:grey; float:right;'>"+state+"</font>";var _composing=msg.getElementsByTagName('composing');if(_composing.length==0)
-clearChatStateTimer=setTimeout(clearChatState,2000);else
-clearTimeout(clearChatStateTimer);}
-return true;},getChatState:function(msg)
-{var state=msg.getElementsByTagName('inactive');if(state.length>0)
-{return i18n.INACTIVE;}
-else
-{state=msg.getElementsByTagName('gone');if(state.length>0)
-{return i18n.GONE;}
-else
-{state=msg.getElementsByTagName('composing');if(state.length>0)
-{return i18n.COMPOSING;}
-else
-{state=msg.getElementsByTagName('paused');if(state.length>0)
-{return i18n.PAUSED;}}}}
-return'';},makeChat:function(fulljid)
-{var barejid=Strophe.getBareJidFromJid(fulljid);var titleWindow="";var paramsChatBox={'enabledPopUp':((loadscript.getBrowserCompatible())?"block":"none"),'idChatBox':barejid+"__chatBox",'jidTo':barejid,'path_jabberit':path_jabberit};titleWindow=barejid.toLowerCase();titleWindow=titleWindow.substring(0,titleWindow.indexOf('@'));if(TrophyIM.rosterObj.roster[barejid])
-{if(TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'])
-{titleWindow=TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'];}}
-TrophyIM.posWindow.top=TrophyIM.posWindow.top+10;if(TrophyIM.posWindow.top>200)
-TrophyIM.posWindow.top=100;TrophyIM.posWindow.left=TrophyIM.posWindow.left+5;if(TrophyIM.posWindow.left>455)
-TrophyIM.posWindow.left=400;var _content=document.createElement('div');_content.innerHTML=loadscript.parse("chat_box","chatBox.xsl",paramsChatBox);_content=_content.firstChild;var _messages=_content.firstChild.firstChild;var _textarea=_content.getElementsByTagName('textarea').item(0);var _send=_content.getElementsByTagName('input').item(0);var _chatStateOnOff=_content.getElementsByTagName('input').item(1);var _send_message=function()
-{if(!TrophyIM.sendMessage(barejid,_textarea.value))
-return false;TrophyIM.addMessage(_messages,barejid,{contact:"<font style='font-weight:bold; color:red;'>"+i18n.ME+"</font>",msg:"<br/>"+_textarea.value});_textarea.value='';_textarea.focus();};var composingTimer_=0;var isComposing_=0;var timeCounter;var setComposing=function()
-{var checkComposing=function()
-{if(!isComposing_){composingTimer_=0;clearInterval(timeCounter);TrophyIM.sendContentMessage(barejid,'paused');}else{TrophyIM.sendContentMessage(barejid,'composing');}
-isComposing_=0;}
-if(!composingTimer_){composingTimer_=1;timeCounter=setInterval(checkComposing,4000);}
-isComposing_=1;};loadscript.configEvents(_send,'onclick',_send_message);loadscript.configEvents(_textarea,'onkeyup',function(e)
-{if(e.keyCode==13){_send_message();composingTimer_=0;clearInterval(timeCounter);}else{if(_chatStateOnOff.value=='on')
-setComposing();}});var winChatBox={id_window:"window_chat_area_"+barejid,barejid:barejid,width:387,height:375,top:TrophyIM.posWindow.top,left:TrophyIM.posWindow.left,draggable:true,visible:"display",resizable:true,zindex:loadscript.getZIndex(),title:titleWindow,closeAction:"hidden",content:_content}
-_win=_winBuild(winChatBox);loadscript.notification(barejid);loadscript.getPhotoUser(barejid);_textarea.focus();_messages=_win.content().firstChild;while(_messages&&_messages.nodeType!==1)
-{_messages=_messages.nextSibling;}
-return(_messages);},makeChatRoom:function()
-{var jidChatRoom=arguments[0];var titleWindow="ChatRoom - "+unescape(arguments[1]);var paramsChatRoom={'idChatRoom':jidChatRoom+"__roomChat",'jidTo':jidChatRoom,'lang_Send':i18n.SEND,'lang_Leave_ChatRoom':i18n.LEAVE_CHATROOM,'path_jabberit':path_jabberit};TrophyIM.posWindow.top=TrophyIM.posWindow.top+10;if(TrophyIM.posWindow.top>200)
-TrophyIM.posWindow.top=100;TrophyIM.posWindow.left=TrophyIM.posWindow.left+5;if(TrophyIM.posWindow.left>455)
-TrophyIM.posWindow.left=400;var _content=document.createElement('div');_content.innerHTML=loadscript.parse("chat_room","chatRoom.xsl",paramsChatRoom);_content=_content.firstChild;var _messages=_content.firstChild.firstChild;var _textarea=_content.getElementsByTagName('textarea').item(0);var _send=_content.getElementsByTagName('input').item(0);var _leaveChatRoom=_content.getElementsByTagName('input').item(1);var _send_message=function()
-{if(!TrophyIM.sendMessageChatRoom(jidChatRoom,_textarea.value))
-return false;_textarea.value='';_textarea.focus();};loadscript.configEvents(_send,'onclick',_send_message);loadscript.configEvents(_leaveChatRoom,'onclick',function()
-{TrophyIM.leaveChatRoom(jidChatRoom);if(TrophyIM.activeChatRoom.name.length>0)
-{for(var i=0;i<TrophyIM.activeChatRoom.name.length;i++)
-{if(TrophyIM.activeChatRoom.name[i].indexOf(jidChatRoom)>=0)
-{TrophyIM.activeChatRoom.name[i]="";}}}
-setTimeout(function()
-{_winBuild("window_chat_room_"+jidChatRoom,"remove");},650);});loadscript.configEvents(_textarea,'onkeyup',function(e)
-{if(e.keyCode==13)
-{_send_message();}});var winChatRoom={id_window:"window_chat_room_"+arguments[0],barejid:jidChatRoom,width:500,height:450,top:TrophyIM.posWindow.top,left:TrophyIM.posWindow.left,draggable:true,visible:"display",resizable:true,zindex:loadscript.getZIndex(),title:titleWindow,closeAction:"hidden",content:_content}
-_win=_winBuild(winChatRoom);_messages=_win.content().firstChild;while(_messages&&_messages.nodeType!==1)
-{_messages=_messages.nextSibling;}
-return(_messages);},addContact:function(jidTo,name,group)
-{var _flag=true;if(TrophyIM.removeResult.idResult.length>0)
-{for(var i=0;i<TrophyIM.removeResult.idResult.length;i++)
-{if(TrophyIM.removeResult.idResult[i]==jidTo)
-{_flag=false;TrophyIM.removeResult.idResult.splice(i,1);i--;}}}
-if(_flag)
-{var _id=TrophyIM.connection.getUniqueId('add');var newContact=$iq({type:'set',id:_id});newContact=newContact.c('query').attrs({xmlns:'jabber:iq:roster'});newContact=newContact.c('item').attrs({jid:jidTo,name:name});newContact=newContact.c('group').t(group).tree();TrophyIM.connection.send(newContact);}},addMessage:function(chatBox,jid,msg)
-{msg.msg=loadscript.getSmiles(msg.msg);var messageDiv=document.createElement("div");messageDiv.style.margin="3px 0px 1em 3px";messageDiv.innerHTML=msg.contact+" : "+msg.msg;chatBox.appendChild(messageDiv);chatBox.scrollTop=chatBox.scrollHeight;},renameContact:function(jid)
-{var name=TrophyIM.rosterObj.roster[jid].contact.name;if((name=prompt(i18n.ASK_NEW_NAME_QUESTION+name+"!",name)))
-if((name=name.replace(/^\s+|\s+$|^\n|\n$/g,""))=="")
-name="";if(name==null||name=="")
-name="";var jidTo=jid
-var name=(name)?name:TrophyIM.rosterObj.roster[jid].contact.name;var group=TrophyIM.rosterObj.roster[jid].contact.groups[0];TrophyIM.addContact(jidTo,name,group);document.getElementById('itenContact_'+jid).innerHTML=name;},renameGroup:function(jid)
-{var group=TrophyIM.rosterObj.roster[jid].contact.groups[0];var presence=TrophyIM.rosterObj.roster[jid].presence;if((group=prompt(i18n.ASK_NEW_GROUP_QUESTION,group)))
-if((group=group.replace(/^\s+|\s+$|^\n|\n$/g,""))=="")
-group="";if(group==null||group=="")
-group="";var jidTo=TrophyIM.rosterObj.roster[jid].contact.jid;var name=TrophyIM.rosterObj.roster[jid].contact.name;var group=(group)?group:TrophyIM.rosterObj.roster[jid].contact.groups[0];TrophyIM.rosterObj.removeContact(jid);TrophyIM.addContact(jidTo,name,group);document.getElementById("JabberIMRoster").innerHTML="";TrophyIM.renderRoster();setTimeout(function()
-{for(var i in presence)
-{if(presence[i].constructor==Function)
-continue;TrophyIM.rosterObj.setPresence(jid,presence[i].priority,presence[i].show,presence[i].status);}},500);},createChatRooms:function()
-{var nickName=document.getElementById('nickName_chatRoom_jabberit').value;var nameChatRoom=document.getElementById('name_ChatRoom_jabberit').value;var _from=Base64.decode(loadscript.getUserCurrent().jid)+TROPHYIM_RESOURCE;var _to=escape(nameChatRoom)+"@"+TROPHYIM_CHATROOM+"/"+nickName;var new_room=$pres({from:_from,to:_to}).c("x",{xmlns:Strophe.NS.MUC});TrophyIM.activeChatRoom.name[TrophyIM.activeChatRoom.name.length]=_to;TrophyIM.connection.send(new_room.tree());},joinChatRoom:function(roomName)
-{var presence=$pres({from:TrophyIM.connection.jid,to:roomName}).c("x",{xmlns:Strophe.NS.MUC});TrophyIM.connection.send(presence);},leaveChatRoom:function(roomName)
-{var room_nick=roomName;var presenceid=TrophyIM.connection.getUniqueId();var presence=$pres({type:"unavailable",id:presenceid,from:TrophyIM.connection.jid,to:room_nick}).c("x",{xmlns:Strophe.NS.MUC});TrophyIM.connection.send(presence);},getListRooms:function()
-{if(TrophyIM.statusConn.connected)
-{var _error_return=function(element)
-{alert("ERRO : Tente novamente !");};var iq=$iq({to:TROPHYIM_CHATROOM,type:"get"}).c("query",{xmlns:Strophe.NS.DISCO_ITEMS});TrophyIM.connection.sendIQ(iq,loadscript.listRooms,_error_return,500);}
-else
-{alert("ERRO : Sem conexão com o servidor "+TROPHYIM_CHATROOM);}},removeContact:function(jidTo)
-{var divItenContact=null;if((divItenContact=document.getElementById('itenContact_'+jidTo)))
-{var _id=TrophyIM.connection.getUniqueId();TrophyIM.removeResult.idResult[TrophyIM.removeResult.idResult.length]=jidTo;var delContact=$iq({type:'set',id:_id})
-delContact=delContact.c('query').attrs({xmlns:'jabber:iq:roster'});delContact=delContact.c('item').attrs({jid:jidTo,subscription:'remove'}).tree();TrophyIM.connection.send(delContact);loadscript.removeElement(document.getElementById('itenContactNotification_'+jidTo));var spanShow=document.getElementById('span_show_itenContact_'+jidTo)
-spanShow.parentNode.removeChild(spanShow);loadscript.removeGroup(divItenContact.parentNode);divItenContact.parentNode.removeChild(divItenContact);}},renderRoster:function()
-{var roster_div=document.getElementById('JabberIMRoster');if(roster_div)
-{var users=new Array();var loading_gif=document.getElementById("JabberIMRosterLoadingGif");if(loading_gif.style.display=="block")
-loading_gif.style.display="none";for(var user in TrophyIM.rosterObj.roster)
-{if(TrophyIM.rosterObj.roster[user].constructor==Function)
-continue;users[users.length]=TrophyIM.rosterObj.roster[user].contact.jid;}
-users.sort();var groups=new Array();var flagGeral=false;for(var group in TrophyIM.rosterObj.groups)
-{if(TrophyIM.rosterObj.groups[group].constructor==Function)
-continue;if(group)
-groups[groups.length]=group;if(group=="Geral")
-flagGeral=true;}
-if(!flagGeral&&users.length>0)
-groups[groups.length]="Geral";groups.sort();for(var i=0;i<groups.length;i++)
-{TrophyIM.renderGroups(groups[i],roster_div);}
-TrophyIM.renderItensGroup(users,roster_div);}
-TrophyIM._timeOut.renderRoster=setTimeout("TrophyIM.renderRoster()",1000);},renderGroups:function(nameGroup,element)
-{var _addGroup=function()
-{var _nameGroup=nameGroup;var _element=element;var paramsGroup={'nameGroup':_nameGroup,'path_jabberit':path_jabberit}
-_element.innerHTML+=loadscript.parse("group","groups.xsl",paramsGroup);}
-if(!element.hasChildNodes())
-{_addGroup();}
-else
-{var _NodeChild=element.firstChild;var flagAdd=false;while(_NodeChild)
-{if(_NodeChild.childNodes[0].nodeName.toLowerCase()==="span")
-{if(_NodeChild.childNodes[0].childNodes[0].nodeValue===nameGroup)
-{flagAdd=true;}}
-_NodeChild=_NodeChild.nextSibling;}
-if(!flagAdd)
-{_addGroup();}}},renderItensGroup:function(users,element)
-{var addItem=function()
-{if(arguments.length>0)
-{var objContact=arguments[0];var group=arguments[1];var element=arguments[2];var showOffline=loadscript.getShowContactsOffline();var presence="unavailable";var status="";var statusColor="black";var statusDisplay="none";var _resource="";var _presence=function(objContact)
-{if(objContact.presence)
-{for(var resource in objContact.presence)
-{if(objContact.presence[resource].constructor==Function)
-continue;if(objContact.presence[resource].show!='invisible')
-presence=objContact.presence[resource].show;if(objContact.contact.subscription!="both")
-presence='subscription';if(objContact.presence[resource].status)
-{status=" ( "+objContact.presence[resource].status+" ) ";statusDisplay="block";}}}};var _subscription=function(objContact)
-{if(objContact.contact.subscription!="both")
-{switch(objContact.contact.subscription)
-{case"none":status=" (( "+i18n.ASK_FOR_AUTH+" )) ";statusColor="red";break;case"to":status=" (( "+i18n.CONTACT_ASK_FOR_AUTH+" )) ";statusColor="orange";break;case"from":status=" (( "+i18n.AUTHORIZED+" )) ";statusColor="green";break;case"subscribe":status=" (( "+i18n.AUTH_SENT+" )) ";statusColor="red";break;case"not-in-roster":status=" (( "+i18n.ASK_FOR_AUTH_QUESTION+" )) ";statusColor="orange";break;default:break;}
-statusDisplay="block";}};if(objContact.contact.subscription!="remove")
-{var itensJid=document.getElementById("itenContact_"+objContact.contact.jid);if(itensJid==null)
-{var nameContact="";if(objContact.contact.name)
-nameContact=objContact.contact.name;else
-{nameContact=objContact.contact.jid;nameContact=nameContact.substring(0,nameContact.indexOf('@'));}
-_presence(objContact);var paramsContact={divDisplay:"block",id:'itenContact_'+objContact.contact.jid,jid:objContact.contact.jid,nameContact:nameContact,path_jabberit:path_jabberit,presence:presence,spanDisplay:statusDisplay,status:status,statusColor:"black",subscription:objContact.contact.subscription,resource:_resource}
-_subscription(objContact);if(group!="")
-{var _NodeChild=element.firstChild;while(_NodeChild)
-{if(_NodeChild.childNodes[0].nodeName.toLowerCase()==="span")
-{if(_NodeChild.childNodes[0].childNodes[0].nodeValue===group)
-{_NodeChild.innerHTML+=loadscript.parse("itens_group","itensGroup.xsl",paramsContact);}}
-_NodeChild=_NodeChild.nextSibling;}}}
-else
-{_presence(objContact);var is_open=itensJid.parentNode.childNodes[0].style.backgroundImage;is_open=is_open.indexOf("arrow_down.gif");_subscription(objContact);itensJid.setAttribute('subscription',objContact.contact.subscription);with(document.getElementById('span_show_'+'itenContact_'+objContact.contact.jid))
-{if(presence=="unavailable"&&!showOffline)
-{style.display="none";}
-else
-{if(is_open>0)
-{style.display=statusDisplay;style.color=statusColor;innerHTML=status;}}}
-if(presence=="unavailable"&&!showOffline)
-{itensJid.style.display="none";}
-else
-{if(is_open>0)
-{itensJid.style.display="block";}}
-itensJid.style.background="url('"+path_jabberit+"templates/default/images/"+presence+".gif') no-repeat center left";}
-if(!objContact.presence&&!showOffline)
-{if(objContact.contact.subscription!="remove")
-{with(document.getElementById('span_show_'+'itenContact_'+objContact.contact.jid))
-{style.display="none";}
-with(document.getElementById('itenContact_'+objContact.contact.jid))
-{style.display="none";}}}}}};var flag=false;for(var i=0;i<users.length;i++)
-{if(TrophyIM.rosterObj.roster[users[i]].contact.jid!=Base64.decode(loadscript.getUserCurrent().jid))
-{var _subscription=TrophyIM.rosterObj.roster[users[i]].contact.subscription;if(_subscription==="to")
-{flag=true;}
-if(_subscription==="not-in-roster")
-{flag=true;}
-if(TrophyIM.rosterObj.roster[users[i]].contact.groups)
-{var groups=TrophyIM.rosterObj.roster[users[i]].contact.groups;if(groups.length>0)
-{for(var j=0;j<groups.length;j++)
-{addItem(TrophyIM.rosterObj.roster[users[i]],groups[j],element);}}
-else
-{addItem(TrophyIM.rosterObj.roster[users[i]],"Geral",element);}}
-else
-{addItem(TrophyIM.rosterObj.roster[users[i]],"Geral",element);}}}
-if(flag)
-{if(TrophyIM.controll.notificationNewUsers==0)
-{loadscript.enabledNotificationNewUsers();TrophyIM.controll.notificationNewUsers++;}}
-else
-{loadscript.disabledNotificationNewUsers();TrophyIM.controll.notificationNewUsers=0;}},rosterClick:function(fulljid)
-{TrophyIM.makeChat(fulljid);},setAutorization:function(jidTo,jidFrom,_typeSubscription)
-{var _id=TrophyIM.connection.getUniqueId();TrophyIM.connection.send($pres().attrs({from:jidFrom,to:jidTo,type:_typeSubscription,id:_id}).tree());},setPresence:function(_type)
-{var presence_chatRoom="";if(_type!='status')
-{if(_type=="unavailable"&&TrophyIM.statusConn.connected)
-{var loading_gif=document.getElementById("JabberIMRosterLoadingGif");if(TrophyIM._timeOut.renderRoster!=null)
-clearTimeout(TrophyIM._timeOut.renderRoster);if(TrophyIM.statusConn.connected)
-TrophyIM.connection.send($pres({type:_type}).tree());for(var i=0;i<TrophyIM.connection._requests.length;i++)
-{if(TrophyIM.connection._requests[i])
-TrophyIM.connection._removeRequest(TrophyIM.connection._requests[i]);}
-TrophyIM.logout();loadscript.clrAllContacts();delete TrophyIM.rosterObj.roster;delete TrophyIM.rosterObj.groups;setTimeout(function()
-{if(loading_gif.style.display=="block")
-loading_gif.style.display="none";},1000);}
-else
-{if(!TrophyIM.autoConnection.connect)
-{TrophyIM.autoConnection.connect=true;TrophyIM.load();}
-else
-{if(TrophyIM.statusConn.connected)
-{if(loadscript.getStatusMessage()!="")
-{var _presence=$pres();_presence.node.appendChild(Strophe.xmlElement('show')).appendChild(Strophe.xmlTextNode(_type));_presence.node.appendChild(Strophe.xmlElement('status')).appendChild(Strophe.xmlTextNode(loadscript.getStatusMessage()));TrophyIM.connection.send(_presence.tree());presence_chatRoom=_type;}
-else
-{TrophyIM.connection.send($pres().c('show').t(_type).tree());presence_chatRoom=_type;}}}}}
-else
-{var _show="available";var _status="";if(arguments.length<2)
-{if(loadscript.getStatusMessage()!="")
-_status=prompt(i18n.TYPE_YOUR_MSG,loadscript.getStatusMessage());else
-_status=prompt(i18n.TYPE_YOUR_MSG);var _divStatus=document.getElementById("JabberIMStatusMessage");if((_status=_status.replace(/^\s+|\s+$|^\n|\n$/g,""))!="")
-_divStatus.firstChild.innerHTML="( "+_status+" )";}
-else
-{_status=arguments[1];}
-for(var resource in TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence)
-{if(TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[resource].constructor==Function)
-continue;if(TROPHYIM_RESOURCE===("/"+resource))
-_show=TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[resource].show;}
-if(TrophyIM.statusConn.connected)
-{var _presence=$pres();_presence.node.appendChild(Strophe.xmlElement('show')).appendChild(Strophe.xmlTextNode(_show));_presence.node.appendChild(Strophe.xmlElement('status')).appendChild(Strophe.xmlTextNode(_status));TrophyIM.connection.send(_presence.tree());presence_chatRoom=_show;}}
-if(TrophyIM.activeChatRoom.name.length>0)
-{for(i=0;i<TrophyIM.activeChatRoom.name.length;i++)
-{if(TrophyIM.activeChatRoom.name[i]!="")
-TrophyIM.connection.send($pres({to:TrophyIM.activeChatRoom.name[i]}).c('show').t(presence_chatRoom));}}},sendMessage:function()
-{if(arguments.length>0)
-{var jidTo=arguments[0];var message_input=arguments[1];message_input=message_input.replace(/^\s+|\s+$|^\n|\n$/g,"");if(message_input!=""){var newMessage=$msg({to:jidTo,from:TrophyIM.connection.jid,type:'chat'});newMessage=newMessage.c('body').t(message_input);newMessage.up();newMessage=newMessage.c('active').attrs({xmlns:'http://jabber.org/protocol/chatstates'});TrophyIM.connection.send(newMessage.tree());return true;}}
-return false;},sendMessageChatRoom:function()
-{if(arguments.length>0)
-{var room_nick=arguments[0];var message=arguments[1];var msgid=TrophyIM.connection.getUniqueId();var msg=$msg({to:room_nick,type:"groupchat",id:msgid}).c("body",{xmlns:Strophe.NS.CLIENT}).t(message);msg.up();TrophyIM.connection.send(msg);return true;}},sendContentMessage:function()
-{if(arguments.length>0)
-{var jidTo=arguments[0];var state=arguments[1];var newMessage=$msg({to:jidTo,from:TrophyIM.connection.jid,type:'chat'});newMessage=newMessage.c(state).attrs({xmlns:'http://jabber.org/protocol/chatstates'});TrophyIM.connection.send(newMessage.tree());}}};function TrophyIMRoster()
-{if(TrophyIM.JSONStore.store_working)
-{var data=TrophyIM.JSONStore.getData(['roster','groups']);this.roster=(data['roster']!=null)?data['roster']:{};this.groups=(data['groups']!=null)?data['groups']:{};}
-else
-{this.roster={};this.groups={};}
-this.changes=new Array();if(TrophyIM.constants.stale_roster)
-{for(var jid in this.roster)
-{this.changes[this.changes.length]=jid;}}
-this.addChange=function(jid)
-{for(var c=0;c<this.changes.length;c++)
-{if(this.changes[c]==jid)
-{return;}}
-this.changes[this.changes.length]=jid;this.changes.sort();}
-this.addContact=function(jid,subscription,name,groups)
-{if(subscription==="remove")
-{this.removeContact(jid);}
-else
-{var contact={jid:jid,subscription:subscription,name:name,groups:groups}
-var jid_lower=jid.toLowerCase();if(this.roster[jid_lower])
-{this.roster[jid_lower]['contact']=contact;}
-else
-{this.roster[jid_lower]={contact:contact};}
-groups=groups?groups:[''];for(var g=0;g<groups.length;g++)
-{if(!this.groups[groups[g]])
-{this.groups[groups[g]]={};}
-this.groups[groups[g]][jid_lower]=jid_lower;}}}
-this.getContact=function(jid)
-{if(this.roster[jid.toLowerCase()])
-{return this.roster[jid.toLowerCase()]['contact'];}}
-this.getPresence=function(fulljid)
-{var jid=Strophe.getBareJidFromJid(fulljid);var current=null;if(this.roster[jid.toLowerCase()]&&this.roster[jid.toLowerCase()]['presence'])
-{for(var resource in this.roster[jid.toLowerCase()]['presence'])
-{if(this.roster[jid.toLowerCase()]['presence'][resource].constructor==Function)
-continue;var presence=this.roster[jid.toLowerCase()]['presence'][resource];if(current==null)
-{current=presence}
-else
-{if(presence['priority']>current['priority']&&((presence['show']=="chat"
-||presence['show']=="available")||(current['show']!="chat"||current['show']!="available")))
-{current=presence}}}}
-return current;}
-this.groupHasChanges=function(group)
-{for(var c=0;c<this.changes.length;c++)
-{if(this.groups[group][this.changes[c]])
-{return true;}}
-return false;}
-this.removeContact=function(jid)
-{if(this.roster[jid])
-{var groups=this.roster[jid].contact.groups;if(groups)
-{for(var i=0;i<groups.length;i++)
-{delete this.groups[groups[i]][jid];}
-for(var i=0;i<groups.length;i++)
-{var contacts=0;for(var contact in this.groups[groups[i]])
-{if(this.groups[groups[i]][contact].constructor==Function)
-continue;contacts++;}
-if(!contacts)
-delete this.groups[groups[i]];}}
-if(this.roster[jid])
-delete this.roster[jid];}}
-this.setPresence=function(fulljid,priority,show,status)
-{var barejid=Strophe.getBareJidFromJid(fulljid);var resource=Strophe.getResourceFromJid(fulljid);var jid_lower=barejid.toLowerCase();if(show!=='unavailable'||show!=='error')
-{if(!this.roster[jid_lower])
-{this.addContact(barejid,'not-in-roster');}
-var presence={resource:resource,priority:priority,show:show,status:status}
-if(!this.roster[jid_lower]['presence'])
-{this.roster[jid_lower]['presence']={};}
-this.roster[jid_lower]['presence'][resource]=presence;}}
-this.save=function()
-{if(TrophyIM.JSONStore.store_working)
-{TrophyIM.JSONStore.setData({roster:this.roster,groups:this.groups,active_chat:TrophyIM.activeChats['current'],chat_history:TrophyIM.chatHistory});}}}
-function TrophyIMJSONStore(){this.store_working=false;this._newXHR=function(handler){var xhr=null;if(window.XMLHttpRequest){xhr=new XMLHttpRequest();if(xhr.overrideMimeType){xhr.overrideMimeType("text/xml");}}else if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP");}
-return xhr;}
-this.getData=function(vars){if(typeof(TROPHYIM_JSON_STORE)!=undefined){Strophe.debug("Retrieving JSONStore data");var xhr=this._newXHR();var getdata="get="+vars.join(",");try{xhr.open("POST",TROPHYIM_JSON_STORE,false);}catch(e){Strophe.error("JSONStore open failed.");return false;}
-xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr.setRequestHeader('Content-length',getdata.length);xhr.send(getdata);if(xhr.readyState==4&&xhr.status==200){try{var dataObj=JSON.parse(xhr.responseText);return this.emptyFix(dataObj);}catch(e){Strophe.error("Could not parse JSONStore response"+
-xhr.responseText);return false;}}else{Strophe.error("JSONStore open failed. Status: "+xhr.status);return false;}}}
-this.emptyFix=function(obj){if(typeof(obj)=="object"){for(var i in obj){if(obj[i].constructor==Function)
-continue;if(i=='_empty_'){obj[""]=this.emptyFix(obj['_empty_']);delete obj['_empty_'];}else{obj[i]=this.emptyFix(obj[i]);}}}
-return obj}
-this.delData=function(vars){if(typeof(TROPHYIM_JSON_STORE)!=undefined){Strophe.debug("Retrieving JSONStore data");var xhr=this._newXHR();var deldata="del="+vars.join(",");try{xhr.open("POST",TROPHYIM_JSON_STORE,false);}catch(e){Strophe.error("JSONStore open failed.");return false;}
-xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr.setRequestHeader('Content-length',deldata.length);xhr.send(deldata);if(xhr.readyState==4&&xhr.status==200){try{var dataObj=JSON.parse(xhr.responseText);return dataObj;}catch(e){Strophe.error("Could not parse JSONStore response");return false;}}else{Strophe.error("JSONStore open failed. Status: "+xhr.status);return false;}}}
-this.setData=function(vars)
-{if(typeof(TROPHYIM_JSON_STORE)!=undefined)
-{var senddata="set="+JSON.stringify(vars);var xhr=this._newXHR();try
-{xhr.open("POST",TROPHYIM_JSON_STORE,false);}
-catch(e)
-{Strophe.error("JSONStore open failed.");return false;}
-xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');xhr.setRequestHeader('Content-length',senddata.length);xhr.send(senddata);if(xhr.readyState==4&&xhr.status==200&&xhr.responseText=="OK"){return true;}else{Strophe.error("JSONStore open failed. Status: "+xhr.status);return false;}}}
-var testData=true;if(this.setData({testData:testData})){var testResult=this.getData(['testData']);if(testResult&&testResult['testData']==true){this.store_working=true;}}}
-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;}
-if(!document.importNode){document.importNode=function(node,allChildren){switch(node.nodeType){case document.ELEMENT_NODE:var newNode=document.createElement(node.nodeName);if(node.attributes&&node.attributes.length>0){for(var i=0;i<node.attributes.length;i++){newNode.setAttribute(node.attributes[i].nodeName,node.getAttribute(node.attributes[i].nodeName));}}
-if(allChildren&&node.childNodes&&node.childNodes.length>0){for(var i=0;i<node.childNodes.length;i++){newNode.appendChild(document.importNode(node.childNodes[i],allChildren));}}
-return newNode;break;case document.TEXT_NODE:case document.CDATA_SECTION_NODE:case document.COMMENT_NODE:return document.createTextNode(node.nodeValue);break;}};}
-var oldonunload=window.onunload;window.onunload=function()
-{if(oldonunload)
-{oldonunload();}
-TrophyIM.setPresence('unavailable');}
+
+var Base64=(function(){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var obj={encode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;do{chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
+output=output+keyStr.charAt(enc1)+keyStr.charAt(enc2)+
+keyStr.charAt(enc3)+keyStr.charAt(enc4);}while(i<input.length);return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
+if(enc4!=64){output=output+String.fromCharCode(chr3);}}while(i<input.length);return output;}};return obj;})();var MD5=(function(){var hexcase=0;var b64pad="";var chrsz=8;var safe_add=function(x,y){var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);};var bit_rol=function(num,cnt){return(num<<cnt)|(num>>>(32-cnt));};var str2binl=function(str){var bin=[];var mask=(1<<chrsz)-1;for(var i=0;i<str.length*chrsz;i+=chrsz)
+{bin[i>>5]|=(str.charCodeAt(i/chrsz)&mask)<<(i%32);}
+return bin;};var binl2str=function(bin){var str="";var mask=(1<<chrsz)-1;for(var i=0;i<bin.length*32;i+=chrsz)
+{str+=String.fromCharCode((bin[i>>5]>>>(i%32))&mask);}
+return str;};var binl2hex=function(binarray){var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i<binarray.length*4;i++)
+{str+=hex_tab.charAt((binarray[i>>2]>>((i%4)*8+4))&0xF)+
+hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&0xF);}
+return str;};var binl2b64=function(binarray){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";var triplet,j;for(var i=0;i<binarray.length*4;i+=3)
+{triplet=(((binarray[i>>2]>>8*(i%4))&0xFF)<<16)|(((binarray[i+1>>2]>>8*((i+1)%4))&0xFF)<<8)|((binarray[i+2>>2]>>8*((i+2)%4))&0xFF);for(j=0;j<4;j++)
+{if(i*8+j*6>binarray.length*32){str+=b64pad;}
+else{str+=tab.charAt((triplet>>6*(3-j))&0x3F);}}}
+return str;};var md5_cmn=function(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b);};var md5_ff=function(a,b,c,d,x,s,t){return md5_cmn((b&c)|((~b)&d),a,b,x,s,t);};var md5_gg=function(a,b,c,d,x,s,t){return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t);};var md5_hh=function(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t);};var md5_ii=function(a,b,c,d,x,s,t){return md5_cmn(c^(b|(~d)),a,b,x,s,t);};var core_md5=function(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;var olda,oldb,oldc,oldd;for(var i=0;i<x.length;i+=16)
+{olda=a;oldb=b;oldc=c;oldd=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,olda);b=safe_add(b,oldb);c=safe_add(c,oldc);d=safe_add(d,oldd);}
+return[a,b,c,d];};var core_hmac_md5=function(key,data){var bkey=str2binl(key);if(bkey.length>16){bkey=core_md5(bkey,key.length*chrsz);}
+var ipad=new Array(16),opad=new Array(16);for(var i=0;i<16;i++)
+{ipad[i]=bkey[i]^0x36363636;opad[i]=bkey[i]^0x5C5C5C5C;}
+var hash=core_md5(ipad.concat(str2binl(data)),512+data.length*chrsz);return core_md5(opad.concat(hash),512+128);};var obj={hexdigest:function(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz));},b64digest:function(s){return binl2b64(core_md5(str2binl(s),s.length*chrsz));},hash:function(s){return binl2str(core_md5(str2binl(s),s.length*chrsz));},hmac_hexdigest:function(key,data){return binl2hex(core_hmac_md5(key,data));},hmac_b64digest:function(key,data){return binl2b64(core_hmac_md5(key,data));},hmac_hash:function(key,data){return binl2str(core_hmac_md5(key,data));},test:function(){return MD5.hexdigest("abc")==="900150983cd24fb0d6963f7d28e17f72";}};return obj;})();if(!Function.prototype.bind){Function.prototype.bind=function(obj)
+{var func=this;return function(){return func.apply(obj,arguments);};};}
+if(!Function.prototype.prependArg){Function.prototype.prependArg=function(arg)
+{var func=this;return function(){var newargs=[arg];for(var i=0;i<arguments.length;i++){newargs.push(arguments[i]);}
+return func.apply(this,newargs);};};}
+(function(callback){var Strophe;function $build(name,attrs){return new Strophe.Builder(name,attrs);}
+function $msg(attrs){return new Strophe.Builder("message",attrs);}
+function $iq(attrs){return new Strophe.Builder("iq",attrs);}
+function $pres(attrs){return new Strophe.Builder("presence",attrs);}
+Strophe={VERSION:"1.0.1",NS:{HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",MUC_USER:"http://jabber.org/protocol/muc#user",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas"},addNamespace:function(name,value)
+{Strophe.NS[name]=value;},Status:{ERROR:0,CONNECTING:1,CONNFAIL:2,AUTHENTICATING:3,AUTHFAIL:4,CONNECTED:5,DISCONNECTED:6,DISCONNECTING:7,ATTACHED:8},LogLevel:{DEBUG:0,INFO:1,WARN:2,ERROR:3,FATAL:4},ElementType:{NORMAL:1,TEXT:3},TIMEOUT:1.1,SECONDARY_TIMEOUT:0.1,forEachChild:function(elem,elemName,func)
+{var i,childNode;for(i=0;i<elem.childNodes.length;i++){childNode=elem.childNodes[i];if(childNode.nodeType==Strophe.ElementType.NORMAL&&(!elemName||this.isTagEqual(childNode,elemName))){func(childNode);}}},isTagEqual:function(el,name)
+{return el.tagName.toLowerCase()==name.toLowerCase();},_xmlGenerator:null,_makeGenerator:function(){var doc;if(window.ActiveXObject){doc=new ActiveXObject("Microsoft.XMLDOM");doc.appendChild(doc.createElement('strophe'));}else{doc=document.implementation.createDocument('jabber:client','strophe',null);}
+return doc;},xmlElement:function(name)
+{if(!name){return null;}
+var node=null;if(!Strophe._xmlGenerator){Strophe._xmlGenerator=Strophe._makeGenerator();}
+node=Strophe._xmlGenerator.createElement(name);var a,i,k;for(a=1;a<arguments.length;a++){if(!arguments[a]){continue;}
+if(typeof(arguments[a])=="string"||typeof(arguments[a])=="number"){node.appendChild(Strophe.xmlTextNode(arguments[a]));}else if(typeof(arguments[a])=="object"&&typeof(arguments[a].sort)=="function"){for(i=0;i<arguments[a].length;i++){if(typeof(arguments[a][i])=="object"&&typeof(arguments[a][i].sort)=="function"){node.setAttribute(arguments[a][i][0],arguments[a][i][1]);}}}else if(typeof(arguments[a])=="object"){for(k in arguments[a]){if(arguments[a].hasOwnProperty(k)){node.setAttribute(k,arguments[a][k]);}}}}
+return node;},xmlescape:function(text)
+{text=text.replace(/\&/g,"&amp;");text=text.replace(/</g,"&lt;");text=text.replace(/>/g,"&gt;");return text;},xmlTextNode:function(text)
+{text=Strophe.xmlescape(text);if(!Strophe._xmlGenerator){Strophe._xmlGenerator=Strophe._makeGenerator();}
+return Strophe._xmlGenerator.createTextNode(text);},getText:function(elem)
+{if(!elem){return null;}
+var str="";if(elem.childNodes.length===0&&elem.nodeType==Strophe.ElementType.TEXT){str+=elem.nodeValue;}
+for(var i=0;i<elem.childNodes.length;i++){if(elem.childNodes[i].nodeType==Strophe.ElementType.TEXT){str+=elem.childNodes[i].nodeValue;}}
+return str;},copyElement:function(elem)
+{var i,el;if(elem.nodeType==Strophe.ElementType.NORMAL){el=Strophe.xmlElement(elem.tagName);for(i=0;i<elem.attributes.length;i++){el.setAttribute(elem.attributes[i].nodeName.toLowerCase(),elem.attributes[i].value);}
+for(i=0;i<elem.childNodes.length;i++){el.appendChild(Strophe.copyElement(elem.childNodes[i]));}}else if(elem.nodeType==Strophe.ElementType.TEXT){el=Strophe.xmlTextNode(elem.nodeValue);}
+return el;},escapeNode:function(node)
+{return node.replace(/^\s+|\s+$/g,'').replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/\"/g,"\\22").replace(/\&/g,"\\26").replace(/\'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40");},unescapeNode:function(node)
+{return node.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\");},getNodeFromJid:function(jid)
+{if(jid.indexOf("@")<0){return null;}
+return jid.split("@")[0];},getDomainFromJid:function(jid)
+{var bare=Strophe.getBareJidFromJid(jid);if(bare.indexOf("@")<0){return bare;}else{var parts=bare.split("@");parts.splice(0,1);return parts.join('@');}},getResourceFromJid:function(jid)
+{var s=jid.split("/");if(s.length<2){return null;}
+s.splice(0,1);return s.join('/');},getBareJidFromJid:function(jid)
+{return jid.split("/")[0];},log:function(level,msg)
+{return;},debug:function(msg)
+{this.log(this.LogLevel.DEBUG,msg);},info:function(msg)
+{this.log(this.LogLevel.INFO,msg);},warn:function(msg)
+{this.log(this.LogLevel.WARN,msg);},error:function(msg)
+{this.log(this.LogLevel.ERROR,msg);},fatal:function(msg)
+{this.log(this.LogLevel.FATAL,msg);},serialize:function(elem)
+{var result;if(!elem){return null;}
+if(typeof(elem.tree)==="function"){elem=elem.tree();}
+var nodeName=elem.nodeName;var i,child;if(elem.getAttribute("_realname")){nodeName=elem.getAttribute("_realname");}
+result="<"+nodeName;for(i=0;i<elem.attributes.length;i++){if(elem.attributes[i].nodeName!="_realname"){result+=" "+elem.attributes[i].nodeName.toLowerCase()+"='"+elem.attributes[i].value.replace("&","&amp;").replace("'","&apos;").replace("<","&lt;")+"'";}}
+if(elem.childNodes.length>0){result+=">";for(i=0;i<elem.childNodes.length;i++){child=elem.childNodes[i];if(child.nodeType==Strophe.ElementType.NORMAL){result+=Strophe.serialize(child);}else if(child.nodeType==Strophe.ElementType.TEXT){result+=child.nodeValue;}}
+result+="</"+nodeName+">";}else{result+="/>";}
+return result;},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(name,ptype)
+{Strophe._connectionPlugins[name]=ptype;}};Strophe.Builder=function(name,attrs)
+{if(name=="presence"||name=="message"||name=="iq"){if(attrs&&!attrs.xmlns){attrs.xmlns=Strophe.NS.CLIENT;}else if(!attrs){attrs={xmlns:Strophe.NS.CLIENT};}}
+this.nodeTree=Strophe.xmlElement(name,attrs);this.node=this.nodeTree;};Strophe.Builder.prototype={tree:function()
+{return this.nodeTree;},toString:function()
+{return Strophe.serialize(this.nodeTree);},up:function()
+{this.node=this.node.parentNode;return this;},attrs:function(moreattrs)
+{for(var k in moreattrs){if(moreattrs.hasOwnProperty(k)){this.node.setAttribute(k,moreattrs[k]);}}
+return this;},c:function(name,attrs)
+{var child=Strophe.xmlElement(name,attrs);this.node.appendChild(child);this.node=child;return this;},cnode:function(elem)
+{this.node.appendChild(elem);this.node=elem;return this;},t:function(text)
+{var child=Strophe.xmlTextNode(text);this.node.appendChild(child);return this;}};Strophe.Handler=function(handler,ns,name,type,id,from,options)
+{this.handler=handler;this.ns=ns;this.name=name;this.type=type;this.id=id;this.options=options||{matchbare:false};if(!this.options.matchBare){this.options.matchBare=false;}
+if(this.options.matchBare){this.from=Strophe.getBareJidFromJid(from);}else{this.from=from;}
+this.user=true;};Strophe.Handler.prototype={isMatch:function(elem)
+{var nsMatch;var from=null;if(this.options.matchBare){from=Strophe.getBareJidFromJid(elem.getAttribute('from'));}else{from=elem.getAttribute('from');}
+nsMatch=false;if(!this.ns){nsMatch=true;}else{var self=this;Strophe.forEachChild(elem,null,function(elem){if(elem.getAttribute("xmlns")==self.ns){nsMatch=true;}});nsMatch=nsMatch||elem.getAttribute("xmlns")==this.ns;}
+if(nsMatch&&(!this.name||Strophe.isTagEqual(elem,this.name))&&(!this.type||elem.getAttribute("type")===this.type)&&(!this.id||elem.getAttribute("id")===this.id)&&(!this.from||from===this.from)){return true;}
+return false;},run:function(elem)
+{var result=null;try{result=this.handler(elem);}catch(e){if(e.sourceURL){Strophe.fatal("error: "+this.handler+" "+e.sourceURL+":"+
+e.line+" - "+e.name+": "+e.message);}else if(e.fileName){if(typeof(console)!="undefined"){console.trace();console.error(this.handler," - error - ",e,e.message);}
+Strophe.fatal("error: "+this.handler+" "+
+e.fileName+":"+e.lineNumber+" - "+
+e.name+": "+e.message);}else{Strophe.fatal("error: "+this.handler);}
+throw e;}
+return result;},toString:function()
+{return"{Handler: "+this.handler+"("+this.name+","+
+this.id+","+this.ns+")}";}};Strophe.TimedHandler=function(period,handler)
+{this.period=period;this.handler=handler;this.lastCalled=new Date().getTime();this.user=true;};Strophe.TimedHandler.prototype={run:function()
+{this.lastCalled=new Date().getTime();return this.handler();},reset:function()
+{this.lastCalled=new Date().getTime();},toString:function()
+{return"{TimedHandler: "+this.handler+"("+this.period+")}";}};Strophe.Request=function(elem,func,rid,sends)
+{this.id=++Strophe._requestId;this.xmlData=elem;this.data=Strophe.serialize(elem);this.origFunc=func;this.func=func;this.rid=rid;this.date=NaN;this.sends=sends||0;this.abort=false;this.dead=null;this.age=function(){if(!this.date){return 0;}
+var now=new Date();return(now-this.date)/1000;};this.timeDead=function(){if(!this.dead){return 0;}
+var now=new Date();return(now-this.dead)/1000;};this.xhr=this._newXHR();};Strophe.Request.prototype={getResponse:function()
+{var node=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){node=this.xhr.responseXML.documentElement;if(node.tagName=="parsererror"){Strophe.error("invalid response received");Strophe.error("responseText: "+this.xhr.responseText);Strophe.error("responseXML: "+
+Strophe.serialize(this.xhr.responseXML));throw"parsererror";}}else if(this.xhr.responseText){Strophe.error("invalid response received");Strophe.error("responseText: "+this.xhr.responseText);Strophe.error("responseXML: "+
+Strophe.serialize(this.xhr.responseXML));}
+return node;},_newXHR:function()
+{var xhr=null;if(window.XMLHttpRequest){xhr=new XMLHttpRequest();if(xhr.overrideMimeType){xhr.overrideMimeType("text/xml");}}else if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP");}
+xhr.onreadystatechange=this.func.prependArg(this);return xhr;}};Strophe.Connection=function(service)
+{this.service=service;this.jid="";this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this._idleTimeout=null;this._disconnectTimeout=null;this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this.paused=false;this.hold=1;this.wait=60;this.window=5;this._data=[];this._requests=[];this._uniqueId=Math.round(Math.random()*10000);this._sasl_success_handler=null;this._sasl_failure_handler=null;this._sasl_challenge_handler=null;this._idleTimeout=setTimeout(this._onIdle.bind(this),100);for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var ptype=Strophe._connectionPlugins[k];var F=function(){};F.prototype=ptype;this[k]=new F();this[k].init(this);}}};Strophe.Connection.prototype={reset:function()
+{this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this._requests=[];this._uniqueId=Math.round(Math.random()*10000);},pause:function()
+{this.paused=true;},resume:function()
+{this.paused=false;},getUniqueId:function(suffix)
+{if(typeof(suffix)=="string"||typeof(suffix)=="number"){return++this._uniqueId+":"+suffix;}else{return++this._uniqueId+"";}},connect:function(jid,pass,callback,wait,hold)
+{this.jid=jid;this.pass=pass;this.connect_callback=callback;this.disconnecting=false;this.connected=false;this.authenticated=false;this.errors=0;this.wait=wait||this.wait;this.hold=hold||this.hold;this.domain=Strophe.getDomainFromJid(this.jid);var body=this._buildBody().attrs({to:this.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":Strophe.NS.BOSH});this._changeConnectStatus(Strophe.Status.CONNECTING,null);this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)),body.tree().getAttribute("rid")));this._throttledRequestHandler();},attach:function(jid,sid,rid,callback,wait,hold,wind)
+{this.jid=jid;this.sid=sid;this.rid=rid;this.connect_callback=callback;this.domain=Strophe.getDomainFromJid(this.jid);this.authenticated=true;this.connected=true;this.wait=wait||this.wait;this.hold=hold||this.hold;this.window=wind||this.window;this._changeConnectStatus(Strophe.Status.ATTACHED,null);},xmlInput:function(elem)
+{return;},xmlOutput:function(elem)
+{return;},rawInput:function(data)
+{return;},rawOutput:function(data)
+{return;},send:function(elem)
+{if(elem===null){return;}
+if(typeof(elem.sort)==="function"){for(var i=0;i<elem.length;i++){this._queueData(elem[i]);}}else if(typeof(elem.tree)==="function"){this._queueData(elem.tree());}else{this._queueData(elem);}
+this._throttledRequestHandler();clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);},flush:function()
+{clearTimeout(this._idleTimeout);this._onIdle();},sendIQ:function(elem,callback,errback,timeout){var timeoutHandler=null;var that=this;if(typeof(elem.tree)==="function"){elem=elem.tree();}
+var id=elem.getAttribute('id');if(!id){id=this.getUniqueId("sendIQ");elem.setAttribute("id",id);}
+var handler=this.addHandler(function(stanza){if(timeoutHandler){that.deleteTimedHandler(timeoutHandler);}
+var iqtype=stanza.getAttribute('type');if(iqtype==='result'){if(callback){callback(stanza);}}else if(iqtype==='error'){if(errback){errback(stanza);}}else{throw{name:"StropheError",message:"Got bad IQ type of "+iqtype};}},null,'iq',null,id);if(timeout){timeoutHandler=this.addTimedHandler(timeout,function(){that.deleteHandler(handler);if(errback){errback(null);}
+return false;});}
+this.send(elem);return id;},_queueData:function(element){if(element===null||!element.tagName||!element.childNodes){throw{name:"StropheError",message:"Cannot queue non-DOMElement."};}
+this._data.push(element);},_sendRestart:function()
+{this._data.push("restart");this._throttledRequestHandler();clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);},addTimedHandler:function(period,handler)
+{var thand=new Strophe.TimedHandler(period,handler);this.addTimeds.push(thand);return thand;},deleteTimedHandler:function(handRef)
+{this.removeTimeds.push(handRef);},addHandler:function(handler,ns,name,type,id,from,options)
+{var hand=new Strophe.Handler(handler,ns,name,type,id,from,options);this.addHandlers.push(hand);return hand;},deleteHandler:function(handRef)
+{this.removeHandlers.push(handRef);},disconnect:function(reason)
+{this._changeConnectStatus(Strophe.Status.DISCONNECTING,reason);Strophe.info("Disconnect was called because: "+reason);if(this.connected){this._disconnectTimeout=this._addSysTimedHandler(3000,this._onDisconnectTimeout.bind(this));this._sendTerminate();}},_changeConnectStatus:function(status,condition)
+{for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var plugin=this[k];if(plugin.statusChanged){try{plugin.statusChanged(status,condition);}catch(err){Strophe.error(""+k+" plugin caused an exception "+"changing status: "+err);}}}}
+if(this.connect_callback){try{this.connect_callback(status,condition);}catch(e){Strophe.error("User connection callback caused an "+"exception: "+e);}}},_buildBody:function()
+{var bodyWrap=$build('body',{rid:this.rid++,xmlns:Strophe.NS.HTTPBIND});if(this.sid!==null){bodyWrap.attrs({sid:this.sid});}
+return bodyWrap;},_removeRequest:function(req)
+{Strophe.debug("removing request");var i;for(i=this._requests.length-1;i>=0;i--){if(req==this._requests[i]){this._requests.splice(i,1);}}
+req.xhr.onreadystatechange=function(){};this._throttledRequestHandler();},_restartRequest:function(i)
+{var req=this._requests[i];if(req.dead===null){req.dead=new Date();}
+this._processRequest(i);},_processRequest:function(i)
+{var req=this._requests[i];var reqStatus=-1;try{if(req.xhr.readyState==4){reqStatus=req.xhr.status;}}catch(e){Strophe.error("caught an error in _requests["+i+"], reqStatus: "+reqStatus);}
+if(typeof(reqStatus)=="undefined"){reqStatus=-1;}
+var time_elapsed=req.age();var primaryTimeout=(!isNaN(time_elapsed)&&time_elapsed>Math.floor(Strophe.TIMEOUT*this.wait));var secondaryTimeout=(req.dead!==null&&req.timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait));var requestCompletedWithServerError=(req.xhr.readyState==4&&(reqStatus<1||reqStatus>=500));if(primaryTimeout||secondaryTimeout||requestCompletedWithServerError){if(secondaryTimeout){Strophe.error("Request "+
+this._requests[i].id+" timed out (secondary), restarting");}
+req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){};this._requests[i]=new Strophe.Request(req.xmlData,req.origFunc,req.rid,req.sends);req=this._requests[i];}
+if(req.xhr.readyState===0){Strophe.debug("request id "+req.id+"."+req.sends+" posting");req.date=new Date();try{req.xhr.open("POST",this.service,true);}catch(e2){Strophe.error("XHR open failed.");if(!this.connected){this._changeConnectStatus(Strophe.Status.CONNFAIL,"bad-service");}
+this.disconnect();return;}
+var sendFunc=function(){req.xhr.send(req.data);};if(req.sends>1){var backoff=Math.pow(req.sends,3)*1000;setTimeout(sendFunc,backoff);}else{sendFunc();}
+req.sends++;this.xmlOutput(req.xmlData);this.rawOutput(req.data);}else{Strophe.debug("_processRequest: "+
+(i===0?"first":"second")+" request has readyState of "+
+req.xhr.readyState);}},_throttledRequestHandler:function()
+{if(!this._requests){Strophe.debug("_throttledRequestHandler called with "+"undefined requests");}else{Strophe.debug("_throttledRequestHandler called with "+
+this._requests.length+" requests");}
+if(!this._requests||this._requests.length===0){return;}
+if(this._requests.length>0){this._processRequest(0);}
+if(this._requests.length>1&&Math.abs(this._requests[0].rid-
+this._requests[1].rid)<this.window-1){this._processRequest(1);}},_onRequestStateChange:function(func,req)
+{Strophe.debug("request id "+req.id+"."+req.sends+" state changed to "+
+req.xhr.readyState);if(req.abort){req.abort=false;return;}
+var reqStatus;if(req.xhr.readyState==4){reqStatus=0;try{reqStatus=req.xhr.status;}catch(e){}
+if(typeof(reqStatus)=="undefined"){reqStatus=0;}
+if(this.disconnecting){if(reqStatus>=400){this._hitError(reqStatus);return;}}
+var reqIs0=(this._requests[0]==req);var reqIs1=(this._requests[1]==req);if((reqStatus>0&&reqStatus<500)||req.sends>5){this._removeRequest(req);Strophe.debug("request id "+
+req.id+" should now be removed");}
+if(reqStatus==200){if(reqIs1||(reqIs0&&this._requests.length>0&&this._requests[0].age()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait))){this._restartRequest(0);}
+Strophe.debug("request id "+
+req.id+"."+
+req.sends+" got 200");func(req);this.errors=0;}else{Strophe.error("request id "+
+req.id+"."+
+req.sends+" error "+reqStatus+" happened");if(reqStatus===0||(reqStatus>=400&&reqStatus<600)||reqStatus>=12000){this._hitError(reqStatus);if(reqStatus>=400&&reqStatus<500){this._changeConnectStatus(Strophe.Status.DISCONNECTING,null);this._doDisconnect();}}}
+if(!((reqStatus>0&&reqStatus<10000)||req.sends>5)){this._throttledRequestHandler();}}},_hitError:function(reqStatus)
+{this.errors++;Strophe.warn("request errored, status: "+reqStatus+", number of errors: "+this.errors);if(this.errors>4){this._onDisconnectTimeout();}},_doDisconnect:function()
+{Strophe.info("_doDisconnect was called");this.authenticated=false;this.disconnecting=false;this.sid=null;this.streamId=null;this.rid=Math.floor(Math.random()*4294967295);if(this.connected){this._changeConnectStatus(Strophe.Status.DISCONNECTED,null);this.connected=false;}
+this.handlers=[];this.timedHandlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];},_dataRecv:function(req)
+{var arrayIndexOf=function(pArray,pInd)
+{var len=pArray.length;for(var i=0;i<len;i++)
+{if(pArray[i]==pInd)
+return i;}
+return-1;};try{var elem=req.getResponse();}catch(e){if(e!="parsererror"){throw e;}
+this.disconnect("strophe-parsererror");}
+if(elem===null){return;}
+this.xmlInput(elem);this.rawInput(Strophe.serialize(elem));var i,hand;while(this.removeHandlers.length>0)
+{hand=this.removeHandlers.pop();i=arrayIndexOf(this.handlers,hand);if(i>=0)
+{this.handlers.splice(i,1);}}
+while(this.addHandlers.length>0){this.handlers.push(this.addHandlers.pop());}
+if(this.disconnecting&&this._requests.length===0){this.deleteTimedHandler(this._disconnectTimeout);this._disconnectTimeout=null;this._doDisconnect();return;}
+var typ=elem.getAttribute("type");var cond,conflict;if(typ!==null&&typ=="terminate"){cond=elem.getAttribute("condition");conflict=elem.getElementsByTagName("conflict");if(cond!==null){if(cond=="remote-stream-error"&&conflict.length>0){cond="conflict";}
+this._changeConnectStatus(Strophe.Status.CONNFAIL,cond);}else{this._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown");}
+this.disconnect();return;}
+var self=this;Strophe.forEachChild(elem,null,function(child){var i,newList;newList=self.handlers;self.handlers=[];for(i=0;i<newList.length;i++){var hand=newList[i];if(hand.isMatch(child)&&(self.authenticated||!hand.user)){if(hand.run(child)){self.handlers.push(hand);}}else{self.handlers.push(hand);}}});},_sendTerminate:function()
+{Strophe.info("_sendTerminate was called");var body=this._buildBody().attrs({type:"terminate"});if(this.authenticated){body.c('presence',{xmlns:Strophe.NS.CLIENT,type:'unavailable'});}
+this.disconnecting=true;var req=new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._dataRecv.bind(this)),body.tree().getAttribute("rid"));this._requests.push(req);this._throttledRequestHandler();},_connect_cb:function(req)
+{Strophe.info("_connect_cb was called");this.connected=true;var bodyWrap=req.getResponse();if(!bodyWrap){return;}
+this.xmlInput(bodyWrap);this.rawInput(Strophe.serialize(bodyWrap));var typ=bodyWrap.getAttribute("type");var cond,conflict;if(typ!==null&&typ=="terminate"){cond=bodyWrap.getAttribute("condition");conflict=bodyWrap.getElementsByTagName("conflict");if(cond!==null){if(cond=="remote-stream-error"&&conflict.length>0){cond="conflict";}
+this._changeConnectStatus(Strophe.Status.CONNFAIL,cond);}else{this._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown");}
+return;}
+if(!this.sid){this.sid=bodyWrap.getAttribute("sid");}
+if(!this.stream_id){this.stream_id=bodyWrap.getAttribute("authid");}
+var wind=bodyWrap.getAttribute('requests');if(wind){this.window=parseInt(wind,10);}
+var hold=bodyWrap.getAttribute('hold');if(hold){this.hold=parseInt(hold,10);}
+var wait=bodyWrap.getAttribute('wait');if(wait){this.wait=parseInt(wait,10);}
+var do_sasl_plain=false;var do_sasl_digest_md5=false;var do_sasl_anonymous=false;var mechanisms=bodyWrap.getElementsByTagName("mechanism");var i,mech,auth_str,hashed_auth_str;if(mechanisms.length>0){for(i=0;i<mechanisms.length;i++){mech=Strophe.getText(mechanisms[i]);if(mech=='DIGEST-MD5'){do_sasl_digest_md5=true;}else if(mech=='PLAIN'){do_sasl_plain=true;}else if(mech=='ANONYMOUS'){do_sasl_anonymous=true;}}}else{var body=this._buildBody();this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)),body.tree().getAttribute("rid")));this._throttledRequestHandler();return;}
+if(Strophe.getNodeFromJid(this.jid)===null&&do_sasl_anonymous){this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"ANONYMOUS"}).tree());}else if(Strophe.getNodeFromJid(this.jid)===null){this._changeConnectStatus(Strophe.Status.CONNFAIL,'x-strophe-bad-non-anon-jid');this.disconnect();}else if(do_sasl_digest_md5){this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge1_cb.bind(this),null,"challenge",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"DIGEST-MD5"}).tree());}else if(do_sasl_plain){auth_str=Strophe.getBareJidFromJid(this.jid);auth_str=auth_str+"\u0000";auth_str=auth_str+Strophe.getNodeFromJid(this.jid);auth_str=auth_str+"\u0000";auth_str=auth_str+this.pass;this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);hashed_auth_str=Base64.encode(auth_str);this.send($build("auth",{xmlns:Strophe.NS.SASL,mechanism:"PLAIN"}).t(hashed_auth_str).tree());}else{this._changeConnectStatus(Strophe.Status.AUTHENTICATING,null);this._addSysHandler(this._auth1_cb.bind(this),null,null,null,"_auth_1");this.send($iq({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:Strophe.NS.AUTH}).c("username",{}).t(Strophe.getNodeFromJid(this.jid)).tree());}},_sasl_challenge1_cb:function(elem)
+{var attribMatch=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/;var challenge=Base64.decode(Strophe.getText(elem));var cnonce=MD5.hexdigest(Math.random()*1234567890);var realm="";var host=null;var nonce="";var qop="";var matches;this.deleteHandler(this._sasl_failure_handler);while(challenge.match(attribMatch)){matches=challenge.match(attribMatch);challenge=challenge.replace(matches[0],"");matches[2]=matches[2].replace(/^"(.+)"$/,"$1");switch(matches[1]){case"realm":realm=matches[2];break;case"nonce":nonce=matches[2];break;case"qop":qop=matches[2];break;case"host":host=matches[2];break;}}
+var digest_uri="xmpp/"+this.domain;if(host!==null){digest_uri=digest_uri+"/"+host;}
+var A1=MD5.hash(Strophe.getNodeFromJid(this.jid)+":"+realm+":"+this.pass)+":"+nonce+":"+cnonce;var A2='AUTHENTICATE:'+digest_uri;var responseText="";responseText+='username='+
+this._quote(Strophe.getNodeFromJid(this.jid))+',';responseText+='realm='+this._quote(realm)+',';responseText+='nonce='+this._quote(nonce)+',';responseText+='cnonce='+this._quote(cnonce)+',';responseText+='nc="00000001",';responseText+='qop="auth",';responseText+='digest-uri='+this._quote(digest_uri)+',';responseText+='response='+this._quote(MD5.hexdigest(MD5.hexdigest(A1)+":"+
+nonce+":00000001:"+
+cnonce+":auth:"+
+MD5.hexdigest(A2)))+',';responseText+='charset="utf-8"';this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge2_cb.bind(this),null,"challenge",null,null);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build('response',{xmlns:Strophe.NS.SASL}).t(Base64.encode(responseText)).tree());return false;},_quote:function(str)
+{return'"'+str.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"';},_sasl_challenge2_cb:function(elem)
+{this.deleteHandler(this._sasl_success_handler);this.deleteHandler(this._sasl_failure_handler);this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null);this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null);this.send($build('response',{xmlns:Strophe.NS.SASL}).tree());return false;},_auth1_cb:function(elem)
+{var iq=$iq({type:"set",id:"_auth_2"}).c('query',{xmlns:Strophe.NS.AUTH}).c('username',{}).t(Strophe.getNodeFromJid(this.jid)).up().c('password').t(this.pass);if(!Strophe.getResourceFromJid(this.jid)){this.jid=Strophe.getBareJidFromJid(this.jid)+'/strophe';}
+iq.up().c('resource',{}).t(Strophe.getResourceFromJid(this.jid));this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2");this.send(iq.tree());return false;},_sasl_success_cb:function(elem)
+{Strophe.info("SASL authentication succeeded.");this.deleteHandler(this._sasl_failure_handler);this._sasl_failure_handler=null;if(this._sasl_challenge_handler){this.deleteHandler(this._sasl_challenge_handler);this._sasl_challenge_handler=null;}
+this._addSysHandler(this._sasl_auth1_cb.bind(this),null,"stream:features",null,null);this._sendRestart();return false;},_sasl_auth1_cb:function(elem)
+{var i,child;for(i=0;i<elem.childNodes.length;i++){child=elem.childNodes[i];if(child.nodeName=='bind'){this.do_bind=true;}
+if(child.nodeName=='session'){this.do_session=true;}}
+if(!this.do_bind){this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}else{this._addSysHandler(this._sasl_bind_cb.bind(this),null,null,null,"_bind_auth_2");var resource=Strophe.getResourceFromJid(this.jid);if(resource){this.send($iq({type:"set",id:"_bind_auth_2"}).c('bind',{xmlns:Strophe.NS.BIND}).c('resource',{}).t(resource).tree());}else{this.send($iq({type:"set",id:"_bind_auth_2"}).c('bind',{xmlns:Strophe.NS.BIND}).tree());}}
+return false;},_sasl_bind_cb:function(elem)
+{if(elem.getAttribute("type")=="error"){Strophe.info("SASL binding failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}
+var bind=elem.getElementsByTagName("bind");var jidNode;if(bind.length>0){jidNode=bind[0].getElementsByTagName("jid");if(jidNode.length>0){this.jid=Strophe.getText(jidNode[0]);if(this.do_session){this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2");this.send($iq({type:"set",id:"_session_auth_2"}).c('session',{xmlns:Strophe.NS.SESSION}).tree());}else{this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}}}else{Strophe.info("SASL binding failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}},_sasl_session_cb:function(elem)
+{if(elem.getAttribute("type")=="result"){this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}else if(elem.getAttribute("type")=="error"){Strophe.info("Session creation failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;}
+return false;},_sasl_failure_cb:function(elem)
+{if(this._sasl_success_handler){this.deleteHandler(this._sasl_success_handler);this._sasl_success_handler=null;}
+if(this._sasl_challenge_handler){this.deleteHandler(this._sasl_challenge_handler);this._sasl_challenge_handler=null;}
+this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false;},_auth2_cb:function(elem)
+{if(elem.getAttribute("type")=="result"){this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null);}else if(elem.getAttribute("type")=="error"){this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);this.disconnect();}
+return false;},_addSysTimedHandler:function(period,handler)
+{var thand=new Strophe.TimedHandler(period,handler);thand.user=false;this.addTimeds.push(thand);return thand;},_addSysHandler:function(handler,ns,name,type,id)
+{var hand=new Strophe.Handler(handler,ns,name,type,id);hand.user=false;this.addHandlers.push(hand);return hand;},_onDisconnectTimeout:function()
+{Strophe.info("_onDisconnectTimeout was called");var req;while(this._requests.length>0){req=this._requests.pop();req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){};}
+this._doDisconnect();return false;},_onIdle:function()
+{var arrayIndexOf=function(pArray,pInd)
+{var len=pArray.length;for(var i=0;i<len;i++)
+{if(pArray[i]==pInd)
+return i;}
+return-1;};var i,thand,since,newList;while(this.removeTimeds.length>0)
+{thand=this.removeTimeds.pop();i=arrayIndexOf(this.timedHandlers,thand);if(i>=0)
+{this.timedHandlers.splice(i,1);}}
+while(this.addTimeds.length>0){this.timedHandlers.push(this.addTimeds.pop());}
+var now=new Date().getTime();newList=[];for(i=0;i<this.timedHandlers.length;i++){thand=this.timedHandlers[i];if(this.authenticated||!thand.user){since=thand.lastCalled+thand.period;if(since-now<=0){if(thand.run()){newList.push(thand);}}else{newList.push(thand);}}}
+this.timedHandlers=newList;var body,time_elapsed;if(this.authenticated&&this._requests.length===0&&this._data.length===0&&!this.disconnecting){Strophe.info("no requests during idle cycle, sending "+"blank request");this._data.push(null);}
+if(this._requests.length<2&&this._data.length>0&&!this.paused){body=this._buildBody();for(i=0;i<this._data.length;i++){if(this._data[i]!==null){if(this._data[i]==="restart"){body.attrs({to:this.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":Strophe.NS.BOSH});}else{body.cnode(this._data[i]).up();}}}
+delete this._data;this._data=[];this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._dataRecv.bind(this)),body.tree().getAttribute("rid")));this._processRequest(this._requests.length-1);}
+if(this._requests.length>0){time_elapsed=this._requests[0].age();if(this._requests[0].dead!==null){if(this._requests[0].timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait)){this._throttledRequestHandler();}}
+if(time_elapsed>Math.floor(Strophe.TIMEOUT*this.wait)){Strophe.warn("Request "+
+this._requests[0].id+" timed out, over "+Math.floor(Strophe.TIMEOUT*this.wait)+" seconds since last activity");this._throttledRequestHandler();}}
+clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100);}};if(callback){callback(Strophe,$build,$msg,$iq,$pres);}})(function(){window.Strophe=arguments[0];window.$build=arguments[1];window.$msg=arguments[2];window.$iq=arguments[3];window.$pres=arguments[4];});
