/*
 * @package AJAX_Chat
 * @author Sebastian Tschan
 * @copyright (c) Sebastian Tschan
 * @license GNU Affero General Public License
 * @link https://blueimp.net/ajax/
 * 
 * The SELFHTML documentation has been used throughout this project:
 * http://selfhtml.org
 * 
 * Stylesheet and cookie methods have been inspired by Paul Sowden (A List Apart):
 * http://www.alistapart.com/stories/alternate/
 */
var ajaxChat={settingsInitiated:null,styleInitiated:null,initializeFunction:null,finalizeFunction:null,loginChannelID:null,loginChannelName:null,timerRate:null,timer:null,ajaxURL:null,baseURL:null,regExpMediaUrl:null,dirs:null,startChatOnLoad:null,chatStarted:null,domIDs:null,dom:null,settings:null,nonPersistentSettings:null,unusedSettings:null,bbCodeTags:null,colorCodes:null,emoticonCodes:null,emoticonFiles:null,soundFiles:null,sounds:null,soundTransform:null,sessionName:null,cookieExpiration:null,cookiePath:null,cookieDomain:null,cookieSecure:null,chatBotName:null,chatBotID:null,allowUserMessageDelete:null,inactiveTimeout:null,privateChannelDiff:null,privateMessageDiff:null,showChannelMessages:null,messageTextMaxLength:null,socketServerEnabled:null,socketServerHost:null,socketServerPort:null,socketServerChatID:null,socket:null,socketIsConnected:null,socketTimerRate:null,socketReconnectTimer:null,socketRegistrationID:null,userID:null,userName:null,userRole:null,channelID:null,channelName:null,channelSwitch:null,usersList:null,userNamesList:null,userMenuCounter:null,encodedUserName:null,userNodeString:null,ignoredUserNames:null,lastID:null,localID:null,lang:null,langCode:null,baseDirection:null,originalDocumentTitle:null,blinkInterval:null,httpRequest:null,init:function(C,G,E,B,A,F,D){this.httpRequest=new Object();this.usersList=new Array();this.userNamesList=new Array();this.userMenuCounter=0;this.lastID=0;this.localID=0;this.lang=G;this.initConfig(C);this.initDirectories();if(E){this.initSettings()}if(B){this.initStyle()}this.initializeFunction=F;this.finalizeFunction=D;if(A){this.setLoadHandler()}},initConfig:function(A){this.loginChannelID=A.loginChannelID;this.loginChannelName=A.loginChannelName;this.timerRate=A.timerRate;this.ajaxURL=A.ajaxURL;this.baseURL=A.baseURL;this.regExpMediaUrl=A.regExpMediaUrl;this.startChatOnLoad=A.startChatOnLoad;this.domIDs=A.domIDs;this.settings=A.settings;this.nonPersistentSettings=A.nonPersistentSettings;this.bbCodeTags=A.bbCodeTags;this.colorCodes=A.colorCodes;this.emoticonCodes=A.emoticonCodes;this.emoticonFiles=A.emoticonFiles;this.soundFiles=A.soundFiles;this.sessionName=A.sessionName;this.cookieExpiration=A.cookieExpiration;this.cookiePath=A.cookiePath;this.cookieDomain=A.cookieDomain;this.cookieSecure=A.cookieSecure;this.chatBotName=A.chatBotName;this.chatBotID=A.chatBotID;this.allowUserMessageDelete=A.allowUserMessageDelete;this.inactiveTimeout=A.inactiveTimeout;this.privateChannelDiff=A.privateChannelDiff;this.privateMessageDiff=A.privateMessageDiff;this.showChannelMessages=A.showChannelMessages;this.messageTextMaxLength=A.messageTextMaxLength;this.socketServerEnabled=A.socketServerEnabled;this.socketServerHost=A.socketServerHost;this.socketServerPort=A.socketServerPort;this.socketServerChatID=A.socketServerChatID},initDirectories:function(){this.dirs=new Object();this.dirs.emoticons=this.baseURL+"img/emoticons/";this.dirs.sounds=this.baseURL+"sounds/";this.dirs.flash=this.baseURL+"flash/"},initSettings:function(){this.settingsInitiated=true;this.unusedSettings=new Object();var D=this.readCookie(this.sessionName+"_settings");if(D){var A=D.split("&");var E,C,G,F;for(var B=0;B<A.length;B++){E=A[B].split("=");if(E.length==2){C=E[0];G=this.decodeText(E[1]);switch(G){case"true":G=true;break;case"false":G=false;break;case"null":G=null;break;default:F=parseFloat(G);if(!isNaN(F)){if(parseInt(F)==F){G=parseInt(F)}else{G=F}}}if(this.inArray(this.nonPersistentSettings,C)){this.unusedSettings[C]=G}else{this.settings[C]=G}}}}},persistSettings:function(){if(this.settingsInitiated){var A=new Array();for(var B in this.settings){if(this.inArray(this.nonPersistentSettings,B)){if(this.unusedSettings&&this.unusedSettings[B]){this.settings[B]=this.unusedSettings[B]}else{continue}}A.push(B+"="+this.encodeText(this.settings[B]))}this.createCookie(this.sessionName+"_settings",A.join("&"),this.cookieExpiration)}},getSettings:function(){return this.settings},getSetting:function(A){for(var B in this.settings){if(B==A){return this.settings[A]}}return null},setSetting:function(A,B){this.settings[A]=B},initializeSettings:function(){if(this.settings.persistFontColor&&this.settings.fontColor){if(this.dom.inputField){this.dom.inputField.style.color=this.settings.fontColor}}},initialize:function(){this.setUnloadHandler();this.initializeDocumentNodes();this.loadPageAttributes();this.initEmoticons();this.initColorCodes();this.initializeSettings();this.setSelectedStyle();this.customInitialize();if(typeof this.initializeFunction=="function"){this.initializeFunction()}if(!this.isCookieEnabled()){this.addChatBotMessageToChatList("/error CookiesRequired")}else{if(this.startChatOnLoad){this.startChat()}else{this.setStartChatHandler();this.requestTeaserContent()}}},requestTeaserContent:function(){var A="&view=teaser";A+="&getInfos="+this.encodeText("userID,userName,userRole");if(!isNaN(parseInt(this.loginChannelID))){A+="&channelID="+this.loginChannelID}else{if(this.loginChannelName!==null){A+="&channelName="+this.encodeText(this.loginChannelName)}}this.updateChat(A)},setStartChatHandler:function(){if(this.dom.inputField){this.dom.inputField.onfocus=function(){ajaxChat.startChat();ajaxChat.dom.inputField.onfocus=""}}},startChat:function(){this.chatStarted=true;if(this.dom.inputField&&this.settings.autoFocus){this.dom.inputField.focus()}this.loadFlashInterface();this.startChatUpdate()},loadPageAttributes:function(){var A=document.getElementsByTagName("html")[0];this.langCode=A.getAttribute("lang")?A.getAttribute("lang"):"en";this.baseDirection=A.getAttribute("dir")?A.getAttribute("dir"):"ltr"},setLoadHandler:function(){var A=window.onload;if(typeof A!="function"){window.onload=function(){ajaxChat.initialize()}}else{window.onload=function(){A();ajaxChat.initialize()}}},setUnloadHandler:function(){var A=window.onunload;if(typeof A!="function"){window.onunload=function(){ajaxChat.finalize()}}else{window.onunload=function(){ajaxChat.finalize();A()}}},updateDOM:function(F,E,A,B){var C=this.dom[F]?this.dom[F]:document.getElementById(F);if(!C){return }try{C.cloneNode(false).innerHTML=E;if(B){C.innerHTML=E}else{if(A){C.innerHTML=E+C.innerHTML}else{C.innerHTML+=E}}}catch(D){this.addChatBotMessageToChatList("/error DOMSyntax "+F);this.updateChatlistView()}},initializeDocumentNodes:function(){this.dom=new Object();for(var A in this.domIDs){this.dom[A]=document.getElementById(this.domIDs[A])}},initEmoticons:function(){for(var A=0;A<this.emoticonCodes.length;A++){this.emoticonCodes[A]=this.encodeSpecialChars(this.emoticonCodes[A]);if(this.dom.emoticonsContainer){this.updateDOM("emoticonsContainer","<a href=\"javascript:ajaxChat.insertText('"+this.scriptLinkEncode(this.emoticonCodes[A])+'\');"><img src="'+this.dirs.emoticons+this.emoticonFiles[A]+'" alt="'+this.emoticonCodes[A]+'" title="'+this.emoticonCodes[A]+'"/></a>')}}},initColorCodes:function(){if(this.dom.colorCodesContainer){for(var A=0;A<this.colorCodes.length;A++){this.updateDOM("colorCodesContainer","<a href=\"javascript:ajaxChat.setFontColor('"+this.colorCodes[A]+'\');" style="background-color:'+this.colorCodes[A]+';" title="'+this.colorCodes[A]+'"></a>\n')}}},startChatUpdate:function(){var B="userID,userName,userRole,channelID,channelName";if(this.socketServerEnabled){B+=",socketRegistrationID"}var A="&getInfos="+this.encodeText(B);if(!isNaN(parseInt(this.loginChannelID))){A+="&channelID="+this.loginChannelID}else{if(this.loginChannelName!==null){A+="&channelName="+this.encodeText(this.loginChannelName)}}this.updateChat(A)},updateChat:function(B){var A=this.ajaxURL+"&lastID="+this.lastID;if(B){A+=B}this.makeRequest(A,"GET",null)},loadFlashInterface:function(){if(this.dom.flashInterfaceContainer){this.updateDOM("flashInterfaceContainer",'<object id="ajaxChatFlashInterface" style="position:absolute; left:-100px;" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+window.location.protocol+'//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" height="1" width="1"><param name="flashvars" value="bridgeName=ajaxChat"/><param name="src" value="'+this.dirs.flash+'FABridge.swf"/><embed name="ajaxChatFlashInterface" pluginspage="'+window.location.protocol+'//www.macromedia.com/go/getflashplayer" src="'+this.dirs.flash+'FABridge.swf" height="1" width="1" flashvars="bridgeName=ajaxChat"/></object>');FABridge.addInitializationCallback("ajaxChat",this.flashInterfaceLoadCompleteHandler)}},flashInterfaceLoadCompleteHandler:function(){ajaxChat.initializeFlashInterface()},initializeFlashInterface:function(){if(this.socketServerEnabled){this.socketTimerRate=(this.inactiveTimeout-1)*60*1000;this.socketConnect()}this.loadSounds();this.initializeCustomFlashInterface()},socketConnect:function(){if(!this.socketIsConnected){try{if(!this.socket&&FABridge.ajaxChat){this.socket=FABridge.ajaxChat.create("flash.net.XMLSocket");this.socket.addEventListener("connect",this.socketConnectHandler);this.socket.addEventListener("close",this.socketCloseHandler);this.socket.addEventListener("data",this.socketDataHandler);this.socket.addEventListener("ioError",this.socketIOErrorHandler);this.socket.addEventListener("securityError",this.socketSecurityErrorHandler)}this.socket.connect(this.socketServerHost,this.socketServerPort)}catch(A){}}clearTimeout(this.socketReconnectTimer);this.socketReconnectTimer=null},socketConnectHandler:function(A){ajaxChat.socketIsConnected=true;setTimeout("ajaxChat.socketRegister()",0)},socketCloseHandler:function(A){ajaxChat.socketIsConnected=false;if(ajaxChat.socket){clearTimeout(ajaxChat.timer);ajaxChat.updateChat(null)}},socketDataHandler:function(A){ajaxChat.socketUpdate(A.getData())},socketIOErrorHandler:function(A){setTimeout("ajaxChat.addChatBotMessageToChatList('/error SocketIO')",0);setTimeout("ajaxChat.updateChatlistView()",1)},socketSecurityErrorHandler:function(A){setTimeout("ajaxChat.addChatBotMessageToChatList('/error SocketSecurity')",0);setTimeout("ajaxChat.updateChatlistView()",1)},socketRegister:function(){if(this.socket&&this.socketIsConnected){try{this.socket.send('<register chatID="'+this.socketServerChatID+'" userID="'+this.userID+'" regID="'+this.socketRegistrationID+'"/>')}catch(A){}}},loadXML:function(C){if(!arguments.callee.parser){try{arguments.callee.parser=new DOMParser()}catch(B){var A=function(){};if(navigator.appName=="Microsoft Internet Explorer"){A.prototype.parseFromString=function(D,E){if(!arguments.callee.XMLDOM){arguments.callee.XMLDOM=new ActiveXObject("Microsoft.XMLDOM")}arguments.callee.XMLDOM.loadXML(D);return arguments.callee.XMLDOM}}else{A.prototype.parseFromString=function(D,E){if(!arguments.callee.httpRequest){arguments.callee.httpRequest=new XMLHttpRequest()}arguments.callee.httpRequest.open("GET","data:text/xml;charset=utf-8,"+encodeURIComponent(D),false);arguments.callee.httpRequest.send(null);return arguments.callee.httpRequest.responseXML}}arguments.callee.parser=new A()}}return arguments.callee.parser.parseFromString(C,"text/xml")},socketUpdate:function(C){var B=this.loadXML(C);if(B){this.handleOnlineUsers(B.getElementsByTagName("user"));if((this.showChannelMessages||B.firstChild.getAttribute("mode")!="1")&&!this.channelSwitch){var A=B.firstChild.getAttribute("channelID");if(A==this.channelID||parseInt(A)==parseInt(this.userID)+this.privateMessageDiff){this.handleChatMessages(B.getElementsByTagName("message"))}}}},setAudioVolume:function(A){A=parseFloat(A);if(!isNaN(A)){if(A<0){A=0}else{if(A>1){A=1}}this.settings.audioVolume=A;try{if(!this.soundTransform){this.soundTransform=FABridge.ajaxChat.create("flash.media.SoundTransform")}this.soundTransform.setVolume(A)}catch(B){}}},loadSounds:function(){try{this.setAudioVolume(this.settings.audioVolume);this.sounds=new Object();var D,A;for(var B in this.soundFiles){D=FABridge.ajaxChat.create("flash.media.Sound");D.addEventListener("complete",this.soundLoadCompleteHandler);D.addEventListener("ioError",this.soundIOErrorHandler);A=FABridge.ajaxChat.create("flash.net.URLRequest");A.setUrl(this.dirs.sounds+this.soundFiles[B]);D.load(A)}}catch(C){}},soundLoadCompleteHandler:function(B){var C=B.getTarget();for(var A in ajaxChat.soundFiles){if((new RegExp(ajaxChat.soundFiles[A])).test(C.getUrl())){ajaxChat.sounds[A]=C}}},soundIOErrorHandler:function(A){setTimeout("ajaxChat.addChatBotMessageToChatList('/error SoundIO')",0);setTimeout("ajaxChat.updateChatlistView()",1)},soundPlayCompleteHandler:function(A){},playSound:function(A){if(this.sounds&&this.sounds[A]){try{return this.sounds[A].play(0,0,this.soundTransform)}catch(B){}}return null},playSoundOnNewMessage:function(D,I,H,B,A,G,F,C){if(this.settings.audio&&this.sounds&&this.lastID&&!this.channelSwitch){switch(I){case this.chatBotID:var E=G.split(" ",1);switch(E[0]){case"/login":case"/channelEnter":this.playSound(this.settings.soundEnter);break;case"/logout":case"/channelLeave":case"/kick":this.playSound(this.settings.soundLeave);break;case"/error":this.playSound(this.settings.soundError);break;default:this.playSound(this.settings.soundChatBot)}break;case this.userID:this.playSound(this.settings.soundSend);break;default:this.playSound(this.settings.soundReceive);break}}},fillSoundSelection:function(A,E){var D=document.getElementById(A);var C=1;for(var B in this.soundFiles){D.options[C]=new Option(B,B);if(B==E){D.options[C].selected=true}C++}},getHttpRequest:function(A){if(!this.httpRequest[A]){if(window.XMLHttpRequest){this.httpRequest[A]=new XMLHttpRequest();if(this.httpRequest[A].overrideMimeType){this.httpRequest[A].overrideMimeType("text/xml")}}else{if(window.ActiveXObject){try{this.httpRequest[A]=new ActiveXObject("Msxml2.XMLHTTP")}catch(B){try{this.httpRequest[A]=new ActiveXObject("Microsoft.XMLHTTP")}catch(B){}}}}}return this.httpRequest[A]},makeRequest:function(B,E,C){try{var A;if(C){if(!arguments.callee.identifier||arguments.callee.identifier>50){arguments.callee.identifier=1}else{arguments.callee.identifier++}A=arguments.callee.identifier}else{A=0}this.getHttpRequest(A).open(E,B,true);this.getHttpRequest(A).onreadystatechange=function(){try{ajaxChat.handleResponse(A)}catch(F){try{clearTimeout(ajaxChat.timer)}catch(F){}try{if(C){ajaxChat.addChatBotMessageToChatList("/error ConnectionTimeout");ajaxChat.updateChatlistView()}}catch(F){}try{ajaxChat.timer=setTimeout("ajaxChat.updateChat(null);",ajaxChat.timerRate)}catch(F){}}};if(E=="POST"){this.getHttpRequest(A).setRequestHeader("Content-Type","application/x-www-form-urlencoded")}this.getHttpRequest(A).send(C)}catch(D){clearTimeout(this.timer);if(C){this.addChatBotMessageToChatList("/error ConnectionTimeout");this.updateChatlistView()}this.timer=setTimeout("ajaxChat.updateChat(null);",this.timerRate)}},handleResponse:function(A){if(this.getHttpRequest(A).readyState==4){if(this.getHttpRequest(A).status==200){var B=this.getHttpRequest(A).responseXML}else{this.addChatBotMessageToChatList("/error ConnectionStatus "+this.getHttpRequest(A).status);this.updateChatlistView();return false}}if(!B){return false}this.handleXML(B);return true},handleXML:function(A){this.handleInfoMessages(A.getElementsByTagName("info"));this.handleOnlineUsers(A.getElementsByTagName("user"));this.handleChatMessages(A.getElementsByTagName("message"));this.channelSwitch=null;this.setChatUpdateTimer()},setChatUpdateTimer:function(){clearTimeout(this.timer);if(this.chatStarted){var A;if(this.socketIsConnected){A=this.socketTimerRate}else{A=this.timerRate;if(this.socketServerEnabled&&!this.socketReconnectTimer){this.socketReconnectTimer=setTimeout("ajaxChat.socketConnect();",60000)}}this.timer=setTimeout("ajaxChat.updateChat(null);",A)}},handleInfoMessages:function(D){var B,C;for(var A=0;A<D.length;A++){B=D[A].getAttribute("type");C=D[A].firstChild?D[A].firstChild.nodeValue:"";this.handleInfoMessage(B,C)}},handleInfoMessage:function(A,B){switch(A){case"channelSwitch":this.clearChatList();this.clearOnlineUsersList();this.setSelectedChannel(B);this.channelName=B;this.channelSwitch=true;break;case"channelName":this.setSelectedChannel(B);this.channelName=B;break;case"channelID":this.channelID=B;break;case"userID":this.userID=B;break;case"userName":this.userName=B;this.encodedUserName=this.scriptLinkEncode(this.userName);this.userNodeString=null;break;case"userRole":this.userRole=B;break;case"logout":this.handleLogout(B);return ;case"socketRegistrationID":this.socketRegistrationID=B;this.socketRegister();default:this.handleCustomInfoMessage(A,B)}},handleOnlineUsers:function(F){if(F.length){var D,C,G,B;var A=new Array();for(var E=0;E<F.length;E++){C=F[E].getAttribute("userID");G=F[E].firstChild?F[E].firstChild.nodeValue:"";B=F[E].getAttribute("userRole");A.push(C);D=this.arraySearch(C,this.usersList);if(D===false){this.addUserToOnlineList(C,G,B)}else{if(this.userNamesList[D]!=G){this.removeUserFromOnlineList(C,D);this.addUserToOnlineList(C,G,B)}}}for(E=0;E<this.usersList.length;E++){if(!this.inArray(A,this.usersList[E])){this.removeUserFromOnlineList(this.usersList[E],E)}}this.setOnlineListRowClasses()}},handleChatMessages:function(C){if(C.length){var F,B,E,D;for(var A=0;A<C.length;A++){F=C[A].getElementsByTagName("username")[0];B=F.firstChild?F.firstChild.nodeValue:"";E=C[A].getElementsByTagName("text")[0];D=E.firstChild?E.firstChild.nodeValue:"";this.addMessageToChatList(new Date(C[A].getAttribute("dateTime")),C[A].getAttribute("userID"),B,C[A].getAttribute("userRole"),C[A].getAttribute("id"),D,C[A].getAttribute("channelID"),C[A].getAttribute("ip"))}this.updateChatlistView();this.lastID=C[C.length-1].getAttribute("id")}},setSelectedChannel:function(D){if(this.dom.channelSelection){D=this.decodeSpecialChars(D);var A=false;for(var B=0;B<this.dom.channelSelection.options.length;B++){if(this.dom.channelSelection.options[B].value==D){this.dom.channelSelection.options[B].selected=true;A=true;break}}if(!A){var C=document.createElement("option");var E=document.createTextNode(D);C.appendChild(E);C.setAttribute("value",D);C.setAttribute("selected","selected");this.dom.channelSelection.appendChild(C)}}},removeUserFromOnlineList:function(B,A){this.usersList.splice(A,1);this.userNamesList.splice(A,1);if(this.dom.onlineList){this.dom.onlineList.removeChild(this.getUserNode(B))}},addUserToOnlineList:function(B,C,A){this.usersList.push(B);this.userNamesList.push(C);if(this.dom.onlineList){this.updateDOM("onlineList",this.getUserNodeString(B,C,A),(this.userID==B))}},getUserNodeString:function(B,D,A){if(this.userNodeString&&B==this.userID){return this.userNodeString}else{var C=this.scriptLinkEncode(D);var E='<div id="'+this.getUserDocumentID(B)+'"><a href="javascript:ajaxChat.toggleUserMenu(\''+this.getUserMenuDocumentID(B)+"', '"+C+"', "+B+');" class="'+this.getRoleClass(A)+'" title="'+this.lang.toggleUserMenu.replace(/%s/,D)+'">'+D+'</a><ul class="userMenu" id="'+this.getUserMenuDocumentID(B)+'"'+((B==this.userID)?">"+this.getUserNodeStringItems(C,B):' style="display:none;">')+"</ul></div>";if(B==this.userID){this.userNodeString=E}return E}},toggleUserMenu:function(C,B,A){if(!document.getElementById(C).firstChild){this.updateDOM(C,this.getUserNodeStringItems(this.encodeText(this.addSlashes(this.getScriptLinkValue(B))),A),false,true)}this.showHide(C)},getUserNodeStringItems:function(B,A){var C;if(B!=this.encodedUserName){C="<li><a href=\"javascript:ajaxChat.insertMessageWrapper('/msg "+B+" ');\">"+this.lang.userMenuSendPrivateMessage+"</a></li><li><a href=\"javascript:ajaxChat.insertMessageWrapper('/describe "+B+" ');\">"+this.lang.userMenuDescribe+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/query "+B+"');\">"+this.lang.userMenuOpenPrivateChannel+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/query');\">"+this.lang.userMenuClosePrivateChannel+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/invite "+B+"');\">"+this.lang.userMenuInvite+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/uninvite "+B+"');\">"+this.lang.userMenuUninvite+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/ignore "+B+"');\">"+this.lang.userMenuIgnore+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/whereis "+B+"');\">"+this.lang.userMenuWhereis+"</a></li>";if(this.userRole==2||this.userRole==3){C+="<li><a href=\"javascript:ajaxChat.insertMessageWrapper('/kick "+B+" ');\">"+this.lang.userMenuKick+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/whois "+B+"');\">"+this.lang.userMenuWhois+"</a></li>"}}else{C="<li><a href=\"javascript:ajaxChat.sendMessageWrapper('/quit');\">"+this.lang.userMenuLogout+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/who');\">"+this.lang.userMenuWho+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/ignore');\">"+this.lang.userMenuIgnoreList+"</a></li><li><a href=\"javascript:ajaxChat.sendMessageWrapper('/list');\">"+this.lang.userMenuList+"</a></li><li><a href=\"javascript:ajaxChat.insertMessageWrapper('/action ');\">"+this.lang.userMenuAction+"</a></li><li><a href=\"javascript:ajaxChat.insertMessageWrapper('/roll ');\">"+this.lang.userMenuRoll+"</a></li><li><a href=\"javascript:ajaxChat.insertMessageWrapper('/nick ');\">"+this.lang.userMenuNick+"</a></li>";if(this.userRole==1||this.userRole==2||this.userRole==3){C+="<li><a href=\"javascript:ajaxChat.sendMessageWrapper('/join');\">"+this.lang.userMenuEnterPrivateRoom+"</a></li>";if(this.userRole==2||this.userRole==3){C+="<li><a href=\"javascript:ajaxChat.sendMessageWrapper('/bans');\">"+this.lang.userMenuBans+"</a></li>"}}}C+=this.getCustomUserMenuItems(B,A);return C},setOnlineListRowClasses:function(){if(this.dom.onlineList){var A=this.dom.onlineList.firstChild;var B=false;while(A){this.setClass(A,(B?"rowEven":"rowOdd"));A=A.nextSibling;B=!B}}},clearChatList:function(){while(this.dom.chatList.hasChildNodes()){this.dom.chatList.removeChild(this.dom.chatList.firstChild)}},clearOnlineUsersList:function(){this.usersList=new Array();this.userNamesList=new Array();if(this.dom.onlineList){while(this.dom.onlineList.hasChildNodes()){this.dom.onlineList.removeChild(this.dom.onlineList.firstChild)}}},getEncodedChatBotName:function(){if(typeof arguments.callee.encodedChatBotName=="undefined"){arguments.callee.encodedChatBotName=this.encodeSpecialChars(this.chatBotName)}return arguments.callee.encodedChatBotName},addChatBotMessageToChatList:function(A){this.addMessageToChatList(new Date(),this.chatBotID,this.getEncodedChatBotName(),4,null,A,null)},addMessageToChatList:function(E,C,F,B,A,G,D,H){if(this.getMessageNode(A)){return }if(!this.onNewMessage(E,C,F,B,A,G,D,H)){return }this.updateDOM("chatList",this.getChatListMessageString(E,C,F,B,A,G,D,H))},getChatListMessageString:function(F,K,I,B,A,H,G,E){var C=this.dom.chatList.lastChild&&this.getClass(this.dom.chatList.lastChild)=="rowOdd"?"rowEven":"rowOdd";var J=this.getRoleClass(B);var D;if(H.indexOf("/action")==0||H.indexOf("/privaction")==0){J+=" action";D=" "}else{D=": "}var L=this.settings.dateFormat?'<span class="dateTime">'+this.formatDate(this.settings.dateFormat,F)+"</span> ":"";return'<div id="'+this.getMessageDocumentID(A)+'" class="'+C+'">'+this.getDeletionLink(A,K,B,G)+L+'<span class="'+J+'"'+this.getChatListUserNameTitle(K,I,B,E)+' dir="'+this.baseDirection+'" onclick="ajaxChat.insertText(this.firstChild.nodeValue);">'+I+"</span>"+D+this.replaceText(H)+"</div>"},getChatListUserNameTitle:function(B,C,A,D){return(D!=null)?' title="IP: '+D+'"':""},getMessageDocumentID:function(A){return((A===null)?"ajaxChat_lm_"+(this.localID++):"ajaxChat_m_"+A)},getMessageNode:function(A){return((A===null)?null:document.getElementById(this.getMessageDocumentID(A)))},getUserDocumentID:function(A){return"ajaxChat_u_"+A},getUserNode:function(A){return document.getElementById(this.getUserDocumentID(A))},getUserMenuDocumentID:function(A){return"ajaxChat_um_"+A},getInlineUserMenuDocumentID:function(B,A){return"ajaxChat_ium_"+B+"_"+A},getDeletionLink:function(A,C,B,D){if(A!==null&&this.isAllowedToDeleteMessage(A,C,B,D)){if(!arguments.callee.deleteMessage){arguments.callee.deleteMessage=this.encodeSpecialChars(this.lang.deleteMessage)}return'<a class="delete" title="'+arguments.callee.deleteMessage+'" href="javascript:ajaxChat.deleteMessage('+A+');"> </a>'}return""},isAllowedToDeleteMessage:function(A,C,B,D){if((((this.userRole==1&&this.allowUserMessageDelete&&(C==this.userID||parseInt(D)==parseInt(this.userID)+this.privateMessageDiff||parseInt(D)==parseInt(this.userID)+this.privateChannelDiff))||this.userRole==2)&&B!=3&&B!=4)||this.userRole==3){return true}return false},onNewMessage:function(E,C,F,B,A,G,D,H){if(!this.customOnNewMessage(E,C,F,B,A,G,D,H)){return false}if(this.ignoreMessage(E,C,F,B,A,G,D,H)){return false}if(this.parseDeleteMessageCommand(G)){return false}this.blinkOnNewMessage(E,C,F,B,A,G,D,H);this.playSoundOnNewMessage(E,C,F,B,A,G,D,H);return true},parseDeleteMessageCommand:function(E){if(E.indexOf("/delete")==0){var A=E.substr(8);var B=this.getMessageNode(A);if(B){var C=B.nextSibling;try{this.dom.chatList.removeChild(B);if(C){this.updateChatListRowClasses(C)}}catch(D){}}return true}return false},blinkOnNewMessage:function(E,C,F,B,A,G,D,H){if(this.settings.blink&&this.lastID&&!this.channelSwitch&&C!=this.userID){clearInterval(this.blinkInterval);this.blinkInterval=setInterval("ajaxChat.blinkUpdate('"+this.addSlashes(this.decodeSpecialChars(F))+"')",this.settings.blinkInterval)}},blinkUpdate:function(A){if(!this.originalDocumentTitle){this.originalDocumentTitle=document.title}if(!arguments.callee.blink){document.title="[@ ] "+A+" - "+this.originalDocumentTitle;arguments.callee.blink=1}else{if(arguments.callee.blink>this.settings.blinkIntervalNumber){clearInterval(this.blinkInterval);document.title=this.originalDocumentTitle;arguments.callee.blink=0}else{if(arguments.callee.blink%2!=0){document.title="[@ ] "+A+" - "+this.originalDocumentTitle}else{document.title="[ @] "+A+" - "+this.originalDocumentTitle}arguments.callee.blink++}}},updateChatlistView:function(){if(this.dom.chatList.childNodes&&this.settings.maxMessages){while(this.dom.chatList.childNodes.length>this.settings.maxMessages){this.dom.chatList.removeChild(this.dom.chatList.firstChild)}}if(this.settings.autoScroll){this.dom.chatList.scrollTop=this.dom.chatList.scrollHeight}},encodeText:function(A){return encodeURIComponent(A)},decodeText:function(A){return decodeURIComponent(A)},utf8Encode:function(B){var C="";for(var A=0;A<B.length;A++){var D=B.charCodeAt(A);if(D<128){C+=String.fromCharCode(D)}else{if((D>127)&&(D<2048)){C+=String.fromCharCode((D>>6)|192);C+=String.fromCharCode((D&63)|128)}else{C+=String.fromCharCode((D>>12)|224);C+=String.fromCharCode(((D>>6)&63)|128);C+=String.fromCharCode((D&63)|128)}}}return C},utf8Decode:function(E){var D="";var F,C,A;var B=0;while(B<E.length){F=E.charCodeAt(B);if(F<128){D+=String.fromCharCode(F);B++}else{if((F>191)&&(F<224)){C=E.charCodeAt(B+1);D+=String.fromCharCode(((F&31)<<6)|(C&63));B+=2}else{C=E.charCodeAt(B+1);A=E.charCodeAt(B+2);D+=String.fromCharCode(((F&15)<<12)|((C&63)<<6)|(A&63));B+=3}}}return D},encodeSpecialChars:function(A){if(!arguments.callee.regExp){arguments.callee.regExp=new RegExp("[&<>'\"]","g")}return A.replace(arguments.callee.regExp,this.encodeSpecialCharsCallback)},encodeSpecialCharsCallback:function(A){switch(A){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case"'":return"&#39;";case'"':return"&quot;";default:return A}},decodeSpecialChars:function(A){if(!arguments.callee.regExp){arguments.callee.regExp=new RegExp("(&amp;)|(&lt;)|(&gt;)|(&#39;)|(&quot;)","g")}return A.replace(arguments.callee.regExp,this.decodeSpecialCharsCallback)},decodeSpecialCharsCallback:function(A){switch(A){case"&amp;":return"&";case"&lt;":return"<";case"&gt;":return">";case"&#39;":return"'";case"&quot;":return'"';default:return A}},inArray:function(B,C){var A=B.length;while(A--){if(B[A]===C){return true}}return false},arraySearch:function(C,B){var A=B.length;while(A--){if(B[A]===C){return A}}return false},stripTags:function(A){if(!arguments.callee.regExp){arguments.callee.regExp=new RegExp("<\\/?[^>]+?>","g")}return A.replace(arguments.callee.regExp,"")},stripBBCodeTags:function(A){if(!arguments.callee.regExp){arguments.callee.regExp=new RegExp("\\[\\/?[^\\]]+?\\]","g")}return A.replace(arguments.callee.regExp,"")},escapeRegExp:function(B){if(!arguments.callee.regExp){var A=new Array("^","$","*","+","?",".","|","/","(",")","[","]","{","}","\\");arguments.callee.regExp=new RegExp("(\\"+A.join("|\\")+")","g")}return B.replace(arguments.callee.regExp,"\\$1")},addSlashes:function(A){return A.replace(/\\/g,"\\\\").replace(/\'/g,"\\'")},removeSlashes:function(A){return A.replace(/\\\\/g,"\\").replace(/\\\'/g,"'")},formatDate:function(B,A){A=(A==null)?new A():A;return B.replace(/%Y/g,A.getFullYear()).replace(/%m/g,this.addLeadingZero(A.getMonth()+1)).replace(/%d/g,this.addLeadingZero(A.getDate())).replace(/%H/g,this.addLeadingZero(A.getHours())).replace(/%i/g,this.addLeadingZero(A.getMinutes())).replace(/%s/g,this.addLeadingZero(A.getSeconds()))},addLeadingZero:function(A){A=A.toString();if(A.length<2){A="0"+A}return A},getUserIDFromUserName:function(B){var A=this.arraySearch(B,this.userNamesList);if(A!==false){return this.usersList[A]}return null},getUserNameFromUserID:function(B){var A=this.arraySearch(B,this.usersList);if(A!==false){return this.userNamesList[A]}return null},getRoleClass:function(A){switch(parseInt(A)){case 0:return"guest";case 1:return"user";case 2:return"moderator";case 3:return"admin";case 4:return"chatBot";default:return"default"}},handleInputFieldKeyPress:function(A){if(A.keyCode==13&&!A.shiftKey){this.sendMessage();try{A.preventDefault()}catch(B){A.returnValue=false}return false}return true},handleInputFieldKeyUp:function(A){this.updateMessageLengthCounter()},updateMessageLengthCounter:function(){if(this.dom.messageLengthCounter){this.updateDOM("messageLengthCounter",this.dom.inputField.value.length+"/"+this.messageTextMaxLength,false,true)}},sendMessage:function(B){B=B?B:this.dom.inputField.value;if(!B){return }B=this.parseInputMessage(B);if(B){clearTimeout(this.timer);var A="lastID="+this.lastID+"&text="+this.encodeText(B);this.makeRequest(this.ajaxURL,"POST",A)}this.dom.inputField.value="";this.dom.inputField.focus();this.updateMessageLengthCounter()},parseInputMessage:function(B){if(B.charAt(0)=="/"){var A=B.split(" ");switch(A[0]){case"/ignore":B=this.parseIgnoreInputCommand(B,A);break;default:B=this.parseCustomInputCommand(B,A)}if(B&&this.settings.persistFontColor&&this.settings.fontColor){B=this.assignFontColorToCommandMessage(B,A)}}else{B=this.parseCustomInputMessage(B);if(B&&this.settings.persistFontColor&&this.settings.fontColor){B=this.assignFontColorToMessage(B)}}return B},assignFontColorToMessage:function(A){return"[color="+this.settings.fontColor+"]"+A+"[/color]"},assignFontColorToCommandMessage:function(B,A){switch(A[0]){case"/msg":case"/describe":if(A.length>2){return A[0]+" "+A[1]+" [color="+this.settings.fontColor+"]"+A.slice(2).join(" ")+"[/color]"}break;case"/action":if(A.length>1){return A[0]+" [color="+this.settings.fontColor+"]"+A.slice(1).join(" ")+"[/color]"}break}return B},parseIgnoreInputCommand:function(D,A){var E=this.getIgnoredUserNames();if(A.length>1){var C=this.encodeSpecialChars(A[1]);if(C==this.userName||C==this.getEncodedChatBotName()){return this.parseIgnoreInputCommand(null,new Array("/ignore"))}if(E.length>0){var B=E.length;while(B--){if(E[B]===C){E.splice(B,1);this.addChatBotMessageToChatList("/ignoreRemoved "+C);this.setIgnoredUserNames(E);this.updateChatlistView();return null}}}E.push(C);this.addChatBotMessageToChatList("/ignoreAdded "+C);this.setIgnoredUserNames(E)}else{if(E.length==0){this.addChatBotMessageToChatList("/ignoreListEmpty -")}else{this.addChatBotMessageToChatList("/ignoreList "+E.join(" "))}}this.updateChatlistView();return null},getIgnoredUserNames:function(){if(!this.ignoredUserNames){var A=this.getSetting("ignoredUserNames");if(A){this.ignoredUserNames=A.split(" ")}else{this.ignoredUserNames=new Array()}}return this.ignoredUserNames},setIgnoredUserNames:function(A){this.ignoredUserNames=A;this.setSetting("ignoredUserNames",A.join(" "))},ignoreMessage:function(D,I,G,B,A,F,E,C){if(I==this.chatBotID&&F.charAt(0)=="/"){var H=F.split(" ");if(H.length>1){switch(H[0]){case"/invite":case"/uninvite":case"/roll":G=H[1];break}}}if(this.inArray(this.getIgnoredUserNames(),G)){return true}return false},deleteMessage:function(B){var C=this.getMessageNode(B);if(C){var A=this.getClass(C);this.setClass(C,A+" deleteSelected");if(confirm(this.lang.deleteMessageConfirm)){var D=C.nextSibling;try{this.dom.chatList.removeChild(C);if(D){this.updateChatListRowClasses(D)}this.updateChat("&delete="+B)}catch(E){this.setClass(C,A)}}else{this.setClass(C,A)}}},updateChatListRowClasses:function(B){if(!B){B=this.dom.chatList.firstChild}if(B){var A=B.previousSibling;var C=(A&&this.getClass(A)=="rowOdd")?true:false;while(B){this.setClass(B,(C?"rowEven":"rowOdd"));B=B.nextSibling;C=!C}}},getClass:function(A){if(typeof A.className!="undefined"){return A.className}else{return A.getAttribute("class")}},setClass:function(B,A){if(typeof B.className!="undefined"){B.className=A}else{B.setAttribute("class",A)}},scriptLinkEncode:function(A){return this.encodeText(this.addSlashes(this.decodeSpecialChars(A)))},scriptLinkDecode:function(A){return this.encodeSpecialChars(this.removeSlashes(this.decodeText(A)))},getScriptLinkValue:function(A){if(typeof arguments.callee.utf8Decode=="undefined"){switch(navigator.appName){case"Microsoft Internet Explorer":case"Opera":arguments.callee.utf8Decode=true;return this.utf8Decode(A);default:arguments.callee.utf8Decode=false;return A}}else{if(arguments.callee.utf8Decode){return this.utf8Decode(A)}else{return A}}},sendMessageWrapper:function(A){this.sendMessage(this.getScriptLinkValue(A))},insertMessageWrapper:function(A){this.insertText(this.getScriptLinkValue(A),true)},switchChannel:function(B){if(!this.chatStarted){this.clearChatList();this.channelSwitch=true;this.loginChannelID=null;this.loginChannelName=B;this.requestTeaserContent();return }clearTimeout(this.timer);var A="lastID="+this.lastID+"&channelName="+this.encodeText(B);this.makeRequest(this.ajaxURL,"POST",A);if(this.dom.inputField&&this.settings.autoFocus){this.dom.inputField.focus()}},logout:function(){clearTimeout(this.timer);var A="logout=true";this.makeRequest(this.ajaxURL,"POST",A)},handleLogout:function(A){window.location.href=A},toggleSetting:function(B,A){this.setSetting(B,!this.getSetting(B));if(A){this.updateButton(B,A)}},updateButton:function(B,A){var C=document.getElementById(A);if(C){this.setClass(C,(this.getSetting(B)?"button":"button off"))}},showHide:function(D,C,A){var B=document.getElementById(D);if(B){if(C){B.style.display=C}else{if(B.style.display=="none"){B.style.display=(A?"inline":"block")}else{B.style.display="none"}}}},setPersistFontColor:function(A){this.settings.persistFontColor=A;if(!this.settings.persistFontColor){this.settings.fontColor=null;if(this.dom.inputField){this.dom.inputField.style.color=""}}},setFontColor:function(A){if(this.settings.persistFontColor){this.settings.fontColor=A;if(this.dom.inputField){this.dom.inputField.style.color=A}if(this.dom.colorCodesContainer){this.dom.colorCodesContainer.style.display="none";if(this.dom.inputField){this.dom.inputField.focus()}}}else{this.insert("[color="+A+"]","[/color]")}},insertText:function(B,A){if(A){this.dom.inputField.value=""}this.insert(B,"")},insertBBCode:function(A){switch(A){case"url":var B=prompt(this.lang.urlDialog,"http://");if(B){this.insert("[url="+B+"]","[/url]")}else{this.dom.inputField.focus()}break;default:this.insert("["+A+"]","[/"+A+"]")}},insert:function(E,D){this.dom.inputField.focus();var C,G;if(typeof document.selection!="undefined"){var B=document.selection.createRange();C=B.text;B.text=E+C+D;B=document.selection.createRange();if(C.length==0){B.move("character",-D.length)}else{B.moveStart("character",E.length+C.length+D.length)}B.select()}else{if(typeof this.dom.inputField.selectionStart!="undefined"){var F=this.dom.inputField.selectionStart;var A=this.dom.inputField.selectionEnd;C=this.dom.inputField.value.substring(F,A);this.dom.inputField.value=this.dom.inputField.value.substr(0,F)+E+C+D+this.dom.inputField.value.substr(A);if(C.length==0){G=F+E.length}else{G=F+E.length+C.length+D.length}this.dom.inputField.selectionStart=G;this.dom.inputField.selectionEnd=G}else{G=this.dom.inputField.value.length;this.dom.inputField.value=this.dom.inputField.value.substr(0,G)+E+D+this.dom.inputField.value.substr(G)}}},replaceText:function(B){try{B=this.replaceLineBreaks(B);if(B.charAt(0)=="/"){B=this.replaceCommands(B)}else{B=this.replaceBBCode(B);B=this.replaceHyperLinks(B);B=this.replaceEmoticons(B)}B=this.breakLongWords(B);B=this.replaceCustomText(B)}catch(A){}return B},replaceCommands:function(C){try{if(C.charAt(0)!="/"){return C}var A=C.split(" ");switch(A[0]){case"/login":return this.replaceCommandLogin(A);case"/logout":return this.replaceCommandLogout(A);case"/channelEnter":return this.replaceCommandChannelEnter(A);case"/channelLeave":return this.replaceCommandChannelLeave(A);case"/privmsg":return this.replaceCommandPrivMsg(A);case"/privmsgto":return this.replaceCommandPrivMsgTo(A);case"/privaction":return this.replaceCommandPrivAction(A);case"/privactionto":return this.replaceCommandPrivActionTo(A);case"/action":return this.replaceCommandAction(A);case"/invite":return this.replaceCommandInvite(A);case"/inviteto":return this.replaceCommandInviteTo(A);case"/uninvite":return this.replaceCommandUninvite(A);case"/uninviteto":return this.replaceCommandUninviteTo(A);case"/queryOpen":return this.replaceCommandQueryOpen(A);case"/queryClose":return this.replaceCommandQueryClose(A);case"/ignoreAdded":return this.replaceCommandIgnoreAdded(A);case"/ignoreRemoved":return this.replaceCommandIgnoreRemoved(A);case"/ignoreList":return this.replaceCommandIgnoreList(A);case"/ignoreListEmpty":return this.replaceCommandIgnoreListEmpty(A);case"/kick":return this.replaceCommandKick(A);case"/who":return this.replaceCommandWho(A);case"/whoChannel":return this.replaceCommandWhoChannel(A);case"/whoEmpty":return this.replaceCommandWhoEmpty(A);case"/list":return this.replaceCommandList(A);case"/bans":return this.replaceCommandBans(A);case"/bansEmpty":return this.replaceCommandBansEmpty(A);case"/unban":return this.replaceCommandUnban(A);case"/whois":return this.replaceCommandWhois(A);case"/whereis":return this.replaceCommandWhereis(A);case"/roll":return this.replaceCommandRoll(A);case"/nick":return this.replaceCommandNick(A);case"/error":return this.replaceCommandError(A);default:return this.replaceCustomCommands(C,A)}}catch(B){}return C},replaceCommandLogin:function(A){return'<span class="chatBotMessage">'+this.lang.login.replace(/%s/,A[1])+"</span>"},replaceCommandLogout:function(A){var B="";if(A.length==3){B=A[2]}return'<span class="chatBotMessage">'+this.lang["logout"+B].replace(/%s/,A[1])+"</span>"},replaceCommandChannelEnter:function(A){return'<span class="chatBotMessage">'+this.lang.channelEnter.replace(/%s/,A[1])+"</span>"},replaceCommandChannelLeave:function(A){return'<span class="chatBotMessage">'+this.lang.channelLeave.replace(/%s/,A[1])+"</span>"},replaceCommandPrivMsg:function(B){var A=B.slice(1).join(" ");A=this.replaceBBCode(A);A=this.replaceHyperLinks(A);A=this.replaceEmoticons(A);return'<span class="privmsg">'+this.lang.privmsg+"</span> "+A},replaceCommandPrivMsgTo:function(B){var A=B.slice(2).join(" ");A=this.replaceBBCode(A);A=this.replaceHyperLinks(A);A=this.replaceEmoticons(A);return'<span class="privmsg">'+this.lang.privmsgto.replace(/%s/,B[1])+"</span> "+A},replaceCommandPrivAction:function(A){var B=A.slice(1).join(" ");B=this.replaceBBCode(B);B=this.replaceHyperLinks(B);B=this.replaceEmoticons(B);return'<span class="action">'+B+'</span> <span class="privmsg">'+this.lang.privmsg+"</span> "},replaceCommandPrivActionTo:function(A){var B=A.slice(2).join(" ");B=this.replaceBBCode(B);B=this.replaceHyperLinks(B);B=this.replaceEmoticons(B);return'<span class="action">'+B+'</span> <span class="privmsg">'+this.lang.privmsgto.replace(/%s/,A[1])+"</span> "},replaceCommandAction:function(A){var B=A.slice(1).join(" ");B=this.replaceBBCode(B);B=this.replaceHyperLinks(B);B=this.replaceEmoticons(B);return'<span class="action">'+B+"</span>"},replaceCommandInvite:function(A){var B=this.lang.invite.replace(/%s/,A[1]).replace(/%s/,"<a href=\"javascript:ajaxChat.sendMessageWrapper('/join "+this.scriptLinkEncode(A[2])+'\');" title="'+this.lang.joinChannel.replace(/%s/,A[2])+'">'+A[2]+"</a>");return'<span class="chatBotMessage">'+B+"</span>"},replaceCommandInviteTo:function(A){var B=this.lang.inviteto.replace(/%s/,A[1]).replace(/%s/,A[2]);return'<span class="chatBotMessage">'+B+"</span>"},replaceCommandUninvite:function(A){var B=this.lang.uninvite.replace(/%s/,A[1]).replace(/%s/,A[2]);return'<span class="chatBotMessage">'+B+"</span>"},replaceCommandUninviteTo:function(A){var B=this.lang.uninviteto.replace(/%s/,A[1]).replace(/%s/,A[2]);return'<span class="chatBotMessage">'+B+"</span>"},replaceCommandQueryOpen:function(A){return'<span class="chatBotMessage">'+this.lang.queryOpen.replace(/%s/,A[1])+"</span>"},replaceCommandQueryClose:function(A){return'<span class="chatBotMessage">'+this.lang.queryClose.replace(/%s/,A[1])+"</span>"},replaceCommandIgnoreAdded:function(A){return'<span class="chatBotMessage">'+this.lang.ignoreAdded.replace(/%s/,A[1])+"</span>"},replaceCommandIgnoreRemoved:function(A){return'<span class="chatBotMessage">'+this.lang.ignoreRemoved.replace(/%s/,A[1])+"</span>"},replaceCommandIgnoreList:function(A){return'<span class="chatBotMessage">'+this.lang.ignoreList+" "+this.getInlineUserMenu(A.slice(1))+"</span>"},replaceCommandIgnoreListEmpty:function(A){return'<span class="chatBotMessage">'+this.lang.ignoreListEmpty+"</span>"},replaceCommandKick:function(A){return'<span class="chatBotMessage">'+this.lang.logoutKicked.replace(/%s/,A[1])+"</span>"},replaceCommandWho:function(A){return'<span class="chatBotMessage">'+this.lang.who+" "+this.getInlineUserMenu(A.slice(1))+"</span>"},replaceCommandWhoChannel:function(A){return'<span class="chatBotMessage">'+this.lang.whoChannel.replace(/%s/,A[1])+" "+this.getInlineUserMenu(A.slice(2))+"</span>"},replaceCommandWhoEmpty:function(A){return'<span class="chatBotMessage">'+this.lang.whoEmpty+"</span>"},replaceCommandList:function(C){var A=C.slice(1);var E=new Array();var B;for(var D=0;D<A.length;D++){B=(A[D]==this.channelName)?"<b>"+A[D]+"</b>":A[D];E.push("<a href=\"javascript:ajaxChat.sendMessageWrapper('/join "+this.scriptLinkEncode(A[D])+'\');" title="'+this.lang.joinChannel.replace(/%s/,A[D])+'">'+B+"</a>")}return'<span class="chatBotMessage">'+this.lang.list+" "+E.join(", ")+"</span>"},replaceCommandBans:function(A){var D=A.slice(1);var C=new Array();for(var B=0;B<D.length;B++){C.push("<a href=\"javascript:ajaxChat.sendMessageWrapper('/unban "+this.scriptLinkEncode(D[B])+'\');" title="'+this.lang.unbanUser.replace(/%s/,D[B])+'">'+D[B]+"</a>")}return'<span class="chatBotMessage">'+this.lang.bans+" "+C.join(", ")+"</span>"},replaceCommandBansEmpty:function(A){return'<span class="chatBotMessage">'+this.lang.bansEmpty+"</span>"},replaceCommandUnban:function(A){return'<span class="chatBotMessage">'+this.lang.unban.replace(/%s/,A[1])+"</span>"},replaceCommandWhois:function(A){return'<span class="chatBotMessage">'+this.lang.whois.replace(/%s/,A[1])+" "+A[2]+"</span>"},replaceCommandWhereis:function(A){return'<span class="chatBotMessage">'+this.lang.whereis.replace(/%s/,A[1]).replace(/%s/,"<a href=\"javascript:ajaxChat.sendMessageWrapper('/join "+this.scriptLinkEncode(A[2])+'\');" title="'+this.lang.joinChannel.replace(/%s/,A[2])+'">'+A[2]+"</a>")+"</span>"},replaceCommandRoll:function(A){var B=this.lang.roll.replace(/%s/,A[1]);B=B.replace(/%s/,A[2]);B=B.replace(/%s/,A[3]);return'<span class="chatBotMessage">'+B+"</span>"},replaceCommandNick:function(A){return'<span class="chatBotMessage">'+this.lang.nick.replace(/%s/,A[1]).replace(/%s/,A[2])+"</span>"},replaceCommandError:function(A){var B=this.lang["error"+A[1]];if(!B){B="Error: Unknown."}else{if(A.length>2){B=B.replace(/%s/,A.slice(2).join(" "))}}return'<span class="chatBotErrorMessage">'+B+"</span>"},getInlineUserMenu:function(C){var B="";for(var A=0;A<C.length;A++){if(A>0){B+=", "}B+="<a href=\"javascript:ajaxChat.toggleUserMenu('"+this.getInlineUserMenuDocumentID(this.userMenuCounter,A)+"', '"+this.scriptLinkEncode(C[A])+'\', null);" title="'+this.lang.toggleUserMenu.replace(/%s/,C[A])+'" dir="'+this.baseDirection+'">'+((C[A]==this.userName)?"<b>"+C[A]+"</b>":C[A])+'</a><ul class="inlineUserMenu" id="'+this.getInlineUserMenuDocumentID(this.userMenuCounter,A)+'" style="display:none;"></ul>'}this.userMenuCounter++;return B},containsUnclosedTags:function(B){if(!arguments.callee.regExpOpenTags||!arguments.callee.regExpCloseTags){arguments.callee.regExpOpenTags=new RegExp("<[^>\\/]+?>","gm");arguments.callee.regExpCloseTags=new RegExp("<\\/[^>]+?>","gm")}var C=B.match(arguments.callee.regExpOpenTags);var A=B.match(arguments.callee.regExpCloseTags);if((!C&&A)||(C&&!A)||(C&&A&&(C.length!=A.length))){return true}return false},breakLongWords:function(G){if(!this.settings.wordWrap){return G}var F="";var E=0;var B,D,A;for(var C=0;C<G.length;C++){B=G.charAt(C);if(B=="<"){D=true;if(C>5&&G.substr(C-5,4)=="<br/"){E=0}}else{if(D&&C>0&&G.charAt(C-1)==">"){D=false;if(C>4&&G.substr(C-5,4)=="<br/"){E=0}}else{if(B=="&"){A=true}else{if(A&&C>0&&G.charAt(C-1)==";"){A=false;E++}}}}if(!D&&!A){if(B==" "||B=="\n"||B=="\t"){E=0}else{E++}if(E>this.settings.maxWordLength){F+=this.getBreakString();E=0}}F+=B}return F},getBreakString:function(){if(typeof arguments.callee.breakString=="undefined"){arguments.callee.breakString="&#8203;"}return arguments.callee.breakString},replaceBBCode:function(A){if(!this.settings.bbCode){if(!arguments.callee.regExpStripBBCode){arguments.callee.regExpStripBBCode=new RegExp("\\[(?:\\/)?(\\w+)(?:=([^<>]*?))?\\]","gm")}return A.replace(arguments.callee.regExpStripBBCode,"")}if(!arguments.callee.regExp){arguments.callee.regExp=new RegExp("\\[(\\w+)(?:=([^<>]*?))?\\](.+?)\\[\\/\\1\\]","gm")}return A.replace(arguments.callee.regExp,this.replaceBBCodeCallback)},replaceBBCodeCallback:function(D,C,B,A){if(!ajaxChat.inArray(ajaxChat.bbCodeTags,C)){return D}if(ajaxChat.containsUnclosedTags(A)){return D}switch(C){case"color":return ajaxChat.replaceBBCodeColor(A,B);case"url":return ajaxChat.replaceBBCodeUrl(A,B);case"img":return ajaxChat.replaceBBCodeImage(A);case"quote":return ajaxChat.replaceBBCodeQuote(A,B);case"code":return ajaxChat.replaceBBCodeCode(A);case"u":return ajaxChat.replaceBBCodeUnderline(A);default:return ajaxChat.replaceCustomBBCode(C,B,A)}},replaceBBCodeColor:function(B,A){if(this.settings.bbCodeColors){if(!A||!this.inArray(ajaxChat.colorCodes,A)){return B}return'<span style="color:'+A+';">'+this.replaceBBCode(B)+"</span>"}return B},replaceBBCodeUrl:function(C,B){var A;if(B){A=B.replace(/\s/gm,this.encodeText(" "))}else{A=this.stripBBCodeTags(C.replace(/\s/gm,this.encodeText(" ")))}if(!arguments.callee.regExpUrl){arguments.callee.regExpUrl=new RegExp("^(?:(?:http)|(?:https)|(?:ftp)|(?:irc)):\\/\\/","")}if(!A||!A.match(arguments.callee.regExpUrl)){return C}return'<a href="'+A+'" onclick="window.open(this.href); return false;">'+this.replaceBBCode(C)+"</a>"},replaceBBCodeImage:function(A){if(this.settings.bbCodeImages){if(!arguments.callee.regExpUrl){arguments.callee.regExpUrl=new RegExp(this.regExpMediaUrl,"")}if(!A||!A.match(arguments.callee.regExpUrl)){return A}A=A.replace(/\s/gm,this.encodeText(" "));var C=this.dom.chatList.offsetWidth-50;var B=this.dom.chatList.offsetHeight-50;return'<a href="'+A+'" onclick="window.open(this.href); return false;"><img class="bbCodeImage" style="max-width:'+C+"px; max-height:"+B+'px;" src="'+A+'" alt=""/></a>'}return A},replaceBBCodeQuote:function(B,A){if(A){return'<span class="quote"><cite>'+this.lang.cite.replace(/%s/,A)+"</cite><q>"+this.replaceBBCode(B)+"</q></span>"}return'<span class="quote"><q>'+this.replaceBBCode(B)+"</q></span>"},replaceBBCodeCode:function(A){return"<code>"+this.replaceBBCode(A.replace(/\t|(?:  )/gm,"&#160;&#160;"))+"</code>"},replaceBBCodeUnderline:function(A){return'<span style="text-decoration:underline;">'+this.replaceBBCode(A)+"</span>"},replaceHyperLinks:function(A){if(!this.settings.hyperLinks){return A}if(!arguments.callee.regExp){arguments.callee.regExp=new RegExp("(^|\\s|>)((?:(?:http)|(?:https)|(?:ftp)|(?:irc)):\\/\\/[^\\s<>]+)(<\\/a>)?","gm")}return A.replace(arguments.callee.regExp,function(E,D,C,B){if(B){return E}return D+'<a href="'+C+'" onclick="window.open(this.href); return false;">'+C+"</a>"})},replaceLineBreaks:function(A){if(!arguments.callee.regExp){arguments.callee.regExp=new RegExp("\\n","g")}if(!this.settings.lineBreaks){return A.replace(arguments.callee.regExp," ")}else{return A.replace(arguments.callee.regExp,"<br/>")}},replaceEmoticons:function(C){if(!this.settings.emoticons){return C}if(!arguments.callee.regExp){var A="^(.*)(";for(var B=0;B<this.emoticonCodes.length;B++){if(B!=0){A+="|"}A+="(?:"+this.escapeRegExp(this.emoticonCodes[B])+")"}A+=")(.*)$";arguments.callee.regExp=new RegExp(A,"gm")}return C.replace(arguments.callee.regExp,this.replaceEmoticonsCallback)},replaceEmoticonsCallback:function(E,D,C,B){if(!arguments.callee.regExp){arguments.callee.regExp=new RegExp('(="[^"]*$)|(&[^;]*$)',"")}if(D.match(arguments.callee.regExp)){return E}if(C){var A=ajaxChat.arraySearch(C,ajaxChat.emoticonCodes);return ajaxChat.replaceEmoticons(D)+'<img src="'+ajaxChat.dirs.emoticons+ajaxChat.emoticonFiles[A]+'" alt="'+C+'" />'+ajaxChat.replaceEmoticons(B)}return E},getActiveStyle:function(){var A=this.readCookie(this.sessionName+"_style");var B=A?A:this.getPreferredStyleSheet();return B},initStyle:function(){this.styleInitiated=true;this.setActiveStyleSheet(this.getActiveStyle())},persistStyle:function(){if(this.styleInitiated){this.createCookie(this.sessionName+"_style",this.getActiveStyleSheet(),this.cookieExpiration)}},setSelectedStyle:function(){if(this.dom.styleSelection){var C=this.getActiveStyle();var A=this.dom.styleSelection.getElementsByTagName("option");for(var B=0;B<A.length;B++){if(A[B].value==C){A[B].selected=true;break}}}},getSelectedStyle:function(){var A=this.dom.styleSelection.getElementsByTagName("option");if(this.dom.styleSelection.selectedIndex==-1){return A[0].value}else{return A[this.dom.styleSelection.selectedIndex].value}},setActiveStyleSheet:function(D){var C,B;var A=false;for(C=0;(B=document.getElementsByTagName("link")[C]);C++){if(B.getAttribute("rel").indexOf("style")!=-1&&B.getAttribute("title")){B.disabled=true;if(B.getAttribute("title")==D){B.disabled=false;A=true}}}if(!A&&D!=null){this.setActiveStyleSheet(this.getPreferredStyleSheet())}},getActiveStyleSheet:function(){var B,A;for(B=0;(A=document.getElementsByTagName("link")[B]);B++){if(A.getAttribute("rel").indexOf("style")!=-1&&A.getAttribute("title")&&!A.disabled){return A.getAttribute("title")}}return null},getPreferredStyleSheet:function(){var B,A;for(B=0;(A=document.getElementsByTagName("link")[B]);B++){if(A.getAttribute("rel").indexOf("style")!=-1&&A.getAttribute("rel").indexOf("alt")==-1&&A.getAttribute("title")){return A.getAttribute("title")}}return null},switchLanguage:function(A){window.location.search="?lang="+A},createCookie:function(C,E,H){var A="";if(H){var B=new Date();B.setTime(B.getTime()+(H*24*60*60*1000));A="; expires="+B.toGMTString()}var G="; path="+this.cookiePath;var D=this.cookieDomain?"; domain="+this.cookieDomain:"";var F=this.cookieSecure?"; secure":"";document.cookie=C+"="+encodeURIComponent(E)+A+G+D+F},readCookie:function(B){if(!document.cookie){return null}var D=B+"=";var A=document.cookie.split(";");for(var C=0;C<A.length;C++){var E=A[C];while(E.charAt(0)==" "){E=E.substring(1,E.length)}if(E.indexOf(D)==0){return decodeURIComponent(E.substring(D.length,E.length))}}return null},isCookieEnabled:function(){this.createCookie(this.sessionName+"_cookie_test",true,1);var A=this.readCookie(this.sessionName+"_cookie_test");if(A){this.createCookie(this.sessionName+"_cookie_test",true,-1);return true}return false},finalize:function(){if(typeof this.finalizeFunction=="function"){this.finalizeFunction()}if(this.socket){try{this.socket.close();this.socket=null}catch(A){}}this.persistSettings();this.persistStyle();this.customFinalize()},initializeCustomFlashInterface:function(){},handleCustomInfoMessage:function(A,B){},customInitialize:function(){},customFinalize:function(){},getCustomUserMenuItems:function(B,A){return""},parseCustomInputMessage:function(A){return A},parseCustomInputCommand:function(B,A){return B},replaceCustomText:function(A){return A},replaceCustomCommands:function(B,A){return B},replaceCustomBBCode:function(A,C,B){return"<"+A+">"+this.replaceBBCode(B)+"</"+A+">"},customOnNewMessage:function(E,C,F,B,A,G,D,H){return true}};
