var controller=null;function start(){var C=IMXML.decrypt("ZVxS1PTT8f8q+7Gngk9B/YtaHm7r+PxMC8vfmWXMcEY=",formatKey("1013207830791219"));Logger.debug(C);var B=new AppModel();var A=new AppView(B);controller=new AppController(B,A);controller.run();Logger.debug(IMXML.generateChatId(1,2));Logger.debug("session initialized")}addLoadEvent(start);var IMXML={encrypt:function(C,B){Logger.debug("[decrypted] "+C);C=formatPlaintext(Utf8.encode(C));var A=rijndaelEncrypt(C,B,"ECB");A=Base64.encodeBytes(A);Logger.debug("[encrypted] "+A);return A},decrypt:function(B,A){Logger.debug("[encrypted] "+B);B=Base64.decodeBytes(B,false);var C=rijndaelDecrypt(B,A,"ECB");C=Utf8.decode(byteArrayToString(C));Logger.debug("[decrypted] "+C);return C},generateChatId:function(D,C){var E=Math.min(D,C);var A=Math.max(D,C);var B=E<<16|A;return B},guestIdFromChatId:function(C,B){var D=(B>>16)&65535;var A=B&65535;if(D==C){return A}else{return D}}};function BaseIMXMLNode(){this._elements=[];this._records=[];this._userlists=[]}BaseIMXMLNode.prototype.addElement=function(A,C,B){if(B){C=IMXML.encrypt(C,B)}this._elements.push({"tag":A,"value":C})};BaseIMXMLNode.prototype.addRecord=function(A){this._records.push(A)};BaseIMXMLNode.prototype.addUserlist=function(A){this._userlists.push(A)};BaseIMXMLNode.prototype.toString=function(){var B="";for(var E=0;E<this._elements.length;E++){var D=this._elements[E];B+="<"+D.tag+">"+D.value+"</"+D.tag+">"}for(E=0;E<this._records.length;E++){var A=this._records[E];B+=A.toString()}for(E=0;E<this._userlists.length;E++){var C=this._userlists[E];B+=C.toString()}return B};function IMXMLMessage(A){this._id=A;BaseIMXMLNode.apply(this)}IMXMLMessage.prototype=new BaseIMXMLNode();IMXMLMessage.prototype.toString=function(){var A="<0><IM>";A+="<ID>"+this._id+"</ID>";A+=BaseIMXMLNode.prototype.toString.apply(this);A+="</IM>";A="<"+(Utf8.encode(A).length+1)+">"+A;Logger.debug("[Sending]: "+A);return A};function IMXMLRecord(){BaseIMXMLNode.apply(this)}IMXMLRecord.prototype=new BaseIMXMLNode();IMXMLRecord.prototype.toString=function(){var A="<RE>";A+=BaseIMXMLNode.prototype.toString.apply(this);A+="</RE>";return A};function IMXMLUserlist(){this._userIDs=[]}IMXMLUserlist.prototype.addUserID=function(A){this._userIDs.push(A)};IMXMLUserlist.prototype.toString=function(){var A="<UL>";for(var C=0;C<this._userIDs.length;C++){var B=this._userIDs[C];A+="<ID>"+B+"</ID>"}A+="</UL>";return A};function IMXMLParser(A){var B=new RegExp("<IM>((.|\n|\r|s|\f|\v|\t)*)</IM>","i");this._message=B.exec(A);if(this._message){this._message=this._message[0]}else{this._message=A}this._doc=XMLParser.parseXML(this._message)}IMXMLParser.prototype.getDoc=function(){return this._doc};IMXMLParser.prototype.getElement=function(A,D){var B=null;var C=this._doc.getElementsByTagName(A);if(C&&C.length>0&&C[0].childNodes.length>0){B=C[0].childNodes[0].nodeValue}if(D&&B){B=IMXML.decrypt(B,D)}return B};IMXMLParser.prototype.getRecords=function(){var A=this._doc.getElementsByTagName("RE");if(!A||A.length==0){A=this._doc.getElementsByTagName("TRE")}return A};IMXMLParser.prototype.getId=function(){var A=this._doc.getElementsByTagName("ID")[0].childNodes[0].nodeValue;return A};IMXMLParser.prototype.getUserlistUsers=function(){var A=[];var D=this._doc.getElementsByTagName("UL");if(D&&D.length>0){var C=D[0].getElementsByTagName("ID");if(C&&C.length>0){for(var E=0;E<C.length;E++){var B=C[E].childNodes[0].nodeValue;A.push(B)}}}return A};IMXMLParser.getRecordElement=function(A,B){if(A.getElementsByTagName(B).length){var C=A.getElementsByTagName(B)[0];if(C.childNodes&&C.childNodes[0]){return C.childNodes[0].nodeValue}else{return""}}return null};function AppController(B,A){this.__base=Gilean.mvc.Controller;this.__base(B,A)}AppController.prototype=new Gilean.mvc.Controller;AppController.prototype.run=function(){this._model.initialize();this._view.showLogin()};AppController.prototype.onLogin=function(B){var C=B["display"];var A=B["email"];this._model.signin(C,A)};AppController.prototype.onSend=function(A){var C=A["msg"];var B=A["type"];var D=A["id"];this._model.sendMessage(C,B,D)};AppController.prototype.onTyping=function(B){var A=B["status"];var C=B["type"];var D=B["id"];this._model.setTypingStatus(C,D,A?1:2)};AppController.prototype.onOpenPrivate=function(A){var B=A["id"];this._model.openPrivate(B)};AppController.prototype.onOpenChat=function(A){var B=A["id"];this._model.openChatroom(B)};AppController.prototype.onClose=function(A){var B=A["type"];var C=A["id"];this._model.closeChat(B,C)};AppController.prototype.onCreateRoom=function(A){this._model.createOrUpdateChatroom(A["chat"])};AppController.prototype.onDeleteRoom=function(A){this._model.deleteChatroom(A["id"])};AppController.prototype.onCreateUser=function(A){this._model.createOrUpdateUser(A["user"])};AppController.prototype.onDeleteUser=function(A){this._model.deleteUser(A["id"])};AppController.prototype.onSetUserPassword=function(A){this._model.setUserPassword(A["id"],A["password"])};AppController.prototype.onSetRole=function(A){this._model.setRole(A["id"],A["imarights"])};AppController.prototype.onChangePhoto=function(A){this._model.changePhoto(A["id"])};AppController.prototype.onSignout=function(A){this._model.signout()};var staff_ready=true;function LoginView(A){this.__base=Gilean.mvc.View;this.__base(A);this.addEvent("login",new Gilean.observer.Event("onLogin"))}LoginView.prototype=new Gilean.mvc.View;LoginView.prototype.showLogin=function(B){var A=this;var F="/images/guest/chat-bubble.jpg";B=B||AppModel.loginStatus.OK;var D=document.createElement("form");D.name="login";D.id="login-form";D.method="post";D.onsubmit=function(){A.showStatus(AppModel.loginStatus.IN_PROGRESS);A.notifyListeners("login",{"display":D.display.value,"email":""});return false};if(staff_ready){var E=new com.deconcept.PlayerVersion([8,0,0]);var C=com.deconcept.FlashObjectUtil.getPlayerVersion();if(C.versionIsValid(E)==false){D.innerHTML='				<div id="login-container">					<div id="login-logo">						<img src="/images/common/logo-small.jpg" width="90" height="69" />					</div>					<div id="login-fields">						<p class="flash-error">24im requires Flash 8.0+ for live chat access.<br /> <a href="http://get.adobe.com/flashplayer/">Get Flash Now</a>.</p>					</div>				</div>';$("login-form-container").innerHTML="";$("login-form-container").appendChild(D);$("login-form-container").style.display=""}else{D.innerHTML='				<div id="login-container">					<div id="login-logo">						<a href="/" target="_blank"><img src="'+F+'" border="0" /></a>					</div>					<div id="login-fields">						<div class="field">							<label id="display-label" for="display">'+translate("b","Welcome. Please enter your name")+'</label>							<small class="label-description">'+translate("c","Our staff will see you displayed by this name.")+'</small>							<input size="25" class="input-text" id="display" name="display" value=""></input>						</div>						<div class="field" id="submit-field">							<label></label><input type="submit" value="'+translate("d","Enter Chat")+'"></input>						</div>						<div class="field hidden" id="loading-field">							<label></label><img src="/images/imc/ajax-loader.gif" alt="loading" />						</div>						<div class="field hidden" id="login-status-field">							<label></label><span id="login-status"></span>						</div>						<div class="field" id="tos-note">							By signing in I agree to be bound by the <a href="/tos/" target="_blank">terms of service</a>.						</div>					</div>				</div>';$("login-form-container").innerHTML="";$("login-form-container").appendChild(D);$("login-form-container").style.display="";this.showStatus(B);$("display").focus()}}else{D.innerHTML='			<div id="login-container">				<div id="login-logo">					<a href="/" target="_blank"><img src="'+F+'" border="0" /></a>				</div>				<div id="login-fields">					<div class="field">						<label id="display-label" for="display">'+translate("e","There is currently no staff available.")+'</label>						<small class="label-description">'+translate("f","Our staff is offline for now. Please come back later.")+"</small>					</div>				</div>			</div>";$("login-form-container").innerHTML="";$("login-form-container").appendChild(D);$("login-form-container").style.display=""}};LoginView.prototype.hideLogin=function(){$("login-form-container").style.display="none"};LoginView.prototype.showStatus=function(A){if(A==AppModel.loginStatus.OK){addClass($("login-status-field"),"hidden");addClass($("loading-field"),"hidden");removeClass($("submit-field"),"hidden")}else{if(A==AppModel.loginStatus.IN_PROGRESS){addClass($("login-status-field"),"hidden");removeClass($("loading-field"),"hidden");addClass($("submit-field"),"hidden")}else{removeClass($("login-status-field"),"hidden");addClass($("loading-field"),"hidden");removeClass($("submit-field"),"hidden");var B=this.getMessageFromStatus(A);$("login-status").innerHTML=B}}};LoginView.prototype.onSigninStatus=function(A){if(A["online"]==true){this.hideLogin()}else{loginStatus=A["status"]||AppModel.loginStatus.OK;this.showLogin(A["status"])}};LoginView.prototype.getMessageFromStatus=function(A){if(A==AppModel.loginStatus.INVALID_PASSWORD){return"Invalid Sign-in name or Password"}else{if(A==AppModel.loginStatus.SERVICE_NOT_AVAILABLE||A==AppModel.loginStatus.CLIENT_NO_LONGER_SUPPORTED){return"Connection to Service Failed"}else{if(A==AppModel.loginStatus.INVALID_GROUP){return"Group does not exist"}else{if(A==AppModel.loginStatus.GROUP_ACCOUNT_MAINTENANCE){return"Group account under maintenance"}else{if(A==AppModel.loginStatus.GROUP_ACCOUNT_BLOCKED){return"Your group account has been suspended"}else{if(A==AppModel.loginStatus.ACCOUNT_BLOCKED){return"Your account has been suspended by your administrator"}else{if(A==AppModel.loginStatus.OVER_LICENSE_LIMIT){return"You've exceeded your licensed user limit"}else{if(A==AppModel.loginStatus.INVALID_ACCESSCODE){return"This URL is no longer accepting Livechat requests"}else{if(A==AppModel.loginStatus.NEED_DISPLAYNAME){return"You must enter a display name"}else{if(A==AppModel.loginStatus.USER_NOT_AVAILABLE){return"Our staff members are currently unavailable"}}}}}}}}}}return""};function MainView(A){this.__base=Gilean.mvc.View;this.__base(A);this.chatView=new ChatView(A);this.chatView.addRelay(this);this.soundManagerView=new SoundManagerView(A);this.soundManagerView.addRelay(this);this.adView=new AdView(A,this.chatView);this.adView.addRelay(this);this.addEvent("signout",new Gilean.observer.Event("onSignout"))}MainView.prototype=new Gilean.mvc.View;MainView.prototype.onSigninStatus=function(B){if(B["online"]==true){var A=this;var C=null;var D=$("leave-link");D.href="javascript:void(0);";D.onclick=function(){A.notifyListeners("signout",{});return false};window.onbeforeunload=function(){return"If you leave you will be disconnected!"};window.onunload=window.document.body.onunload=function(){A.notifyListeners("signout",{})};document.getElementById("application-container").style.display="block"}else{document.getElementById("application-container").style.display="none";window.onbeforeunload=window.onunload=window.document.body.onunload=function(){}}};function AppView(A){this.__base=Gilean.mvc.View;this.__base(A);this.loginView=new LoginView(A);this.loginView.addRelay(this);this.mainView=new MainView(A);this.mainView.addRelay(this)}AppView.prototype=new Gilean.mvc.View;AppView.prototype.showLogin=function(){this.loginView.showLogin()};function ChatView(A){this.__base=Gilean.mvc.View;this.__base(A);this.focused=true;this.blinkTimer=null;this.chatdisplay=null;this.addEvent("send",new Gilean.observer.Event("onSend"));this.addEvent("typing",new Gilean.observer.Event("onTyping"));this.addEvent("close",new Gilean.observer.Event("onClose"))}ChatView.prototype=new Gilean.mvc.View;ChatView.prototype.adjustDimensions=function(){var F=getWindowDims();var E=getElementDims(document.body);var B=$("chat-box");var A=getElementDims(B);B.style.height=Math.max(0,A[1]-(E[1]-F[1])-20)+"px";var D=$("contacts");var C=getElementDims(D);D.style.height=Math.max(0,C[1]-(E[1]-F[1])-20)+"px"};ChatView.prototype.appendData=function(E,F,H,D,B,C,G){var A=$("chat-box");this.chatdisplay.addMessage(E,F,H,D,B);A.scrollTop=A.scrollHeight-A.clientHeight};ChatView.prototype.typingStatus=function(G,D,E,F,C){var B=$("chat-box");var A=(B.scrollTop==B.scrollHeight-B.clientHeight);this.chatdisplay.setTypingStatus(G,D,C);if(A){B.scrollTop=B.scrollHeight-B.clientHeight}};ChatView.prototype.addUserToRoom=function(E,A,D){var I=m_chatdb.rooms[A];var K=$("contacts");if(!K.users){K.users=[]}var J=K.users[D];if(J==null){J=document.createElement("li");K.users[D]=J;K.appendChild(J)}var G=false;if(E==2&&I.ownerType!=1){var H=I.specialUsers;for(var C=0;C<H.length;C++){if(D==H[C]){G=true}}}var B=D==0?null:m_userdb.user(D);var F=B?B.displayName:"Group Administrator";J.innerHTML=(G?"<strong>":"")+'<a href="javascript:void(0);" onclick="return false">'+F+"</a>"+(G?"</strong>":"")};ChatView.prototype.removeUserFromRoom=function(C,E,A){var B=$("contacts");if(B){var D=B.users[A];if(D){B.removeChild(D)}B.users[A]=null}};ChatView.prototype.onMessage=function(G){var B=G["msg"];var E=G["uid"];var H=G["type"];var A=G["id"];if(!B){return }B=ChatUtils.preProcessMsg(B);var D=m_userdb.user(E);if(!D&&E!==null&&E!==0){return }var I=(E==null)?"System":(E==0)?"Group Administrator":D.displayName;var C=(E==null)?("chat-bubble"):((E==m_uid)?"chat-bubble-self":"chat-bubble");var D=m_userdb.user(E);var F=new Date;this.appendData(C,B,I,F,ViewUtils.userToImageSrc(D,this._model.m_groupInfo?this._model.m_groupInfo.accountid:null,this._model.m_hostname?this._model.m_hostname:null),H,A);this.typingStatus(I,E,H,A,false);this.addUserToRoom(H,A,m_uid);if(E!=null){this.addUserToRoom(H,A,E)}if(E!=m_uid){this.flashTitle([I+"!",'"'+B+'"'],window)}};ChatView.prototype.onTypingStatus=function(D){var B=D["status"];var E=D["uid"];var F=D["type"];var G=D["id"];var C=m_userdb.user(E);if(!C&&E!==null&&E!=0){return }var A=(E==null)?"System":(E==0)?"Group Administrator":C.displayName;this.typingStatus(A,E,F,G,B==1);this.addUserToRoom(F,G,m_uid);if(E!=null){this.addUserToRoom(F,G,E)}};ChatView.prototype.onAddUserToRoom=function(A){var B=A["uid"];var C=A["type"];var D=A["id"];this.addUserToRoom(C,D,B)};ChatView.prototype.onUserEnterRoom=function(G){var H=G["type"];var B=G["id"];var E=G["uid"];var J=this;var F=new Date;if(E==m_uid){var A=m_chatdb.rooms[B];this.appendData("system-message",translate("j","You may now enter your message. Press ENTER to send."),"System",F,null,H,B);if(H=="2"){if(A.announcement){this.appendData("announcement-message",m_chatdb.rooms[B].announcement,"Announcement",F,null,H,B)}}textFieldLayout=document.createElement("form");textFieldLayout.style.margin=0;textFieldLayout.style.padding=0;textFieldLayout.style.paddingRight="100px";textFieldLeft=document.createElement("div");textFieldLeft.style.cssFloat="left";textFieldLeft.style.styleFloat="left";textFieldLeft.style.width="100%";textFieldRight=document.createElement("div");textFieldRight.style.cssFloat="left";textFieldRight.style.styleFloat="left";textFieldRight.style.width="100px";textFieldRight.style.marginRight="-100px";textFieldWrapper=document.createElement("div");textFieldWrapper.style.padding="13px";textField=document.createElement("input");textField.style.width="100%";textField.style.margin=0;textField.style.padding="3px";textField.style.border="1px solid silver";textField.style.fontSize="15px";var I=true;var D=true;textField.onkeypress=textField.onkeyup=function(L){setTimeout(function(){if(textField.value==""&&D){J.notifyListeners("typing",{"status":false,"type":H,"id":B});D=false;I=true;setTimeout(function(){D=true},10000)}else{if(textField.value!=""&&I){J.notifyListeners("typing",{"status":true,"type":H,"id":B});D=true;I=false;setTimeout(function(){I=true},10000)}}},1)};textButton=document.createElement("input");textButton.style.width="75px";textButton.style.height="25px";textButton.style.marginTop="13px";textButton.type="submit";textButton.value=translate("k","Send");textFieldLayout.onsubmit=function(L){J.notifyListeners("send",{"msg":textField.value,"type":H,"id":B});J.onfocus();textField.value="";textField.focus();return false};$("input-container").appendChild(textFieldLayout);textFieldLayout.appendChild(textFieldLeft);textFieldLayout.appendChild(textFieldRight);textFieldLeft.appendChild(textFieldWrapper);textFieldRight.appendChild(textButton);textFieldWrapper.appendChild(textField);textField.focus()}else{var C=m_userdb.user(E);if(!C&&E!=0){return }var K=(E==0)?"Group Administrator":C.displayName;this.appendData("system-message",K+" has entered the room.","System",F,null,H,B)}this.addUserToRoom(H,B,E)};ChatView.prototype.onUserExitRoom=function(C){var D=C["uid"];var E=C["type"];var G=C["id"];var F=new Date;var B=m_userdb.user(D);if(!B&&D!=0){return }var A=(D==0)?"Group Administrator":B.displayName;this.appendData("system-message",A+" has left the room.","System",F,null,E,G);this.typingStatus(A,D,E,G,false);this.removeUserFromRoom(E,G,D)};ChatView.prototype.onRemoveUserFromRoom=function(A){var B=A["uid"];var C=A["type"];var D=A["id"];this.removeUserFromRoom(C,D,B)};ChatView.prototype.onUpdateChatId=function(C){var B=C["prevtype"];var E=C["previd"];var D=C["newtype"];var A=C["newid"];this.updateChatId(B,E,D,A)};ChatView.prototype.onSigninStatus=function(C){var A=this;if(C["online"]==true){window.onblur=window.document.body.onblur=function(D){A.onblur(D)};window.onfocus=window.document.body.onfocus=function(D){A.onfocus(D)};this.chatdisplay=new ChatDisplayView();var B=this.chatdisplay.create();B.className="chatbox";B.style.width="auto";B.style.height="auto";$("chat-box").appendChild(B);this.adjustDimensions();window.onresize=window.document.body.onresize=function(D){A.adjustDimensions()}}else{if(C["online"]==false){this.onfocus();window.onblur=window.onfocus=function(){};window.onsize=window.document.body.onsize=function(D){};this.chatdisplay=null;$("chat-box").innerHTML="";$("contacts").innerHTML="";$("contacts").users=[];$("input-container").innerHTML=""}}};ChatView.prototype.onblur=function(A){A=A||window.event;Logger.debug("blurred");this.focused=false};ChatView.prototype.onfocus=function(){Logger.debug("focused");this.focused=true;if(this.blinkTimer){this.backupTitleWindow.document.title=this.backupTitle;clearInterval(this.blinkTimer);this.blinkTimer=null;this.backupTitle=null}};ChatView.prototype.flashTitle=function(C,A){A=A||window;if(this.focused==false){if(this.blinkTimer){this.backupTitleWindow.document.title=this.backupTitle;clearInterval(this.blinkTimer);this.blinkTimer=null;this.backupTitle=null}this.backupTitleWindow=A;this.backupTitle=A.document.title;C.push(this.backupTitle);var D=C.length;var E=0;var B=this;this.blinkTimer=setInterval(function(){A.document.title=C[E];E=(E+1)%D},1000);var F=A.onfocus;A.onfocus=function(G){F(G);if(B.backupTitle){B.backupTitleWindow.document.title=B.backupTitle;clearInterval(B.blinkTimer);B.blinkTimer=null;B.backupTitle=null;B.backupTitleWindow=null;A.onfocus=F}}}};function AdView(A,B){this.__base=Gilean.mvc.View;this.__base(A);this.rotationInterval=null;this.neighborView=B}AdView.prototype=new Gilean.mvc.View;AdView.prototype.onUpdateAds=function(C){var C=C["ads"];if(this.rotationInterval){clearInterval(this.rotationInterval)}if(C&&C.length>=1){$("chat-ad-display").style.display="block";this.neighborView.adjustDimensions();var B=0;var A=function(){var D=C[B];$("ad-contents").innerHTML='<a href="'+D.url+'" target="_blank">'+D.message+"</a>";B=(B+1)%C.length};A();this.rotationInterval=setInterval(A,60000)}else{$("chat-ad-display").style.display="none";this.neighborView.adjustDimensions()}};function SoundManagerView(A){Gilean.mvc.View.call(this,A);this._soundOn=true;this.recvSound=new SoundFile(sock_Aflax,"/sounds/recv.mp3");this.sendSound=new SoundFile(sock_Aflax,"/sounds/send.mp3")}SoundManagerView.prototype=new Gilean.mvc.View;SoundManagerView.prototype.render=function(){var B=document.createElement("div");B.className="clearfix";var A=this;var C=document.createElement("a");C.className="sound-icon";C.href="javascript:void(0)";C.onclick=function(){A.toggle();if(A.isSoundOn()){addClass(C,"sound-on");removeClass(C,"sound-off");C.innerHTML="Sound On"}else{addClass(C,"sound-off");removeClass(C,"sound-on");C.innerHTML="Sound Off"}return false};if(this.isSoundOn()){C.innerHTML="Sound On";addClass(C,"sound-on")}else{C.innerHTML="Sound Off";addClass(C,"sound-off")}return C};SoundManagerView.prototype.isSoundOn=function(){return this._soundOn};SoundManagerView.prototype.toggle=function(){this._soundOn=!this._soundOn};SoundManagerView.prototype.onMessage=function(A){var B=A["uid"];if(this.isSoundOn()){if(B!=m_uid){this.recvSound.play()}else{this.sendSound.play()}}};function ChatMap(){var A=[];A[0]=[];A[1]=[];A[2]=[];A[3]=[];this.set=function(C,D,B){A[C][D]=B};this.get=function(B,C){if(A[B]){return A[B][C]}return null}}function ChatTabsManager(D,C){var G=[];var B=window;var F=new JSTabControl;tabWnd=F.create();tabWnd.style.height="100%";tabWnd.style.width="100%";tabWnd.style.overflow="hidden";var A=new Object;A.onEmpty=function(){C.DestroyWindow()};F.addListener(A);var E=new Object;E.onClose=function(){F.close()};E.onSize=function(H,I){F.setDimensions(H,I);F.setSelectedIndex(F.getSelectedIndex())};E.onExtract=function(J,L){B=J||window;tabWnd=F.move(null,B);tabWnd.style.overflow="hidden";L.appendChild(tabWnd);for(var K in G){if(G[K]){var H=G[K];var I=F.getContent(K);if(I){I.appendChild(H.create(B))}}}};C.addListener(E);this.addChat=function(M,I,O,J){var K=F.addTab(O);var L=F.getContent(K);var P=new Object;P.type=M;P.id=I;P.index=K;F.addListener(P);G[K]=new ChatFrameView(D,M,I,m_userdb,M=="2"?m_chatdb.rooms[I]:null);var H=G[K].create(B);L.appendChild(H);P.onClose=function(Q){if((typeof (Q)=="undefined"||Q==K)&&G[K]){G[K].close();G[K]=null}};P.onActivate=function(Q){if((typeof (Q)=="undefined"||Q==K)&&G[K]){G[K].activate()}};P.onSize=function(Q,R){if(G[K]){var S=F.getContentDims();G[K].setDimensions(S[0],S[1])}};var N=C.getDims();F.setDimensions(N[0],N[1]);this.focus(K,J);return K};this.getChat=function(H){return G[H]};this.focus=function(H,I){if(I){F.setSelectedIndex(H);C.bringToFront()}else{F.flashIndex(H)}}}function ChatFrameView(L,E,R,K,B){var E=E;var L=L;var K=K;var B=B;var R=R;var V=new ChatDisplayView();var J=null;var Q=null;var H=null;var C=null;var U=null;var N=null;var I=null;var O=null;var D=null;var T=null;var F=null;var M=[];var A=(B&&B.accessCode)?B.accessCode:"";var S=null;var P=null;var G=null;this.create=function(Y){G=Y||window;if(D&&D.parentNode){D.parentNode.removeChild(D)}D=G.document.createElement("div");U=G.document.createElement("div");D.appendChild(U);N=G.document.createElement("div");D.appendChild(N);I=G.document.createElement("div");I.className="bottom";I.style.margin=0;I.style.height="50px";D.appendChild(I);J=G.document.createElement("div");J.className="chatbox-bg";J.style.overflow="auto";J.style.position="relative";J.style.margin=0;J.style.padding=0;Q=V.create(G);Q.className="chatbox";Q.style.width="auto";Q.style.height="auto";J.appendChild(Q);J.textbox=Q;H=G.document.createElement("div");H.className="userlist-box";H.style.cssFloat="right";H.style.styleFloat="right";H.style.display="none";if(E==2){var X=Chat.isRoomAdmin(m_uid,B);if(X||L._model.getPrivileges().isAdmin(m_uid)){T=G.document.createElement("div");T.className="guest-toggle";F=G.document.createElement("a");F.href="javascript:void(0)";T.appendChild(F);H.appendChild(T)}}C=G.document.createElement("ul");C.className="userlist-list";C.users=[];H.appendChild(C);N.appendChild(H);N.appendChild(J);textFieldLayout=G.document.createElement("form");textFieldLayout.style.margin=0;textFieldLayout.style.padding=0;textFieldLayout.style.paddingRight="100px";textFieldLeft=G.document.createElement("div");textFieldLeft.style.position="relative";textFieldLeft.style.cssFloat="left";textFieldLeft.style.styleFloat="left";textFieldLeft.style.width="100%";textFieldRight=G.document.createElement("div");textFieldRight.style.position="relative";textFieldRight.style.cssFloat="left";textFieldRight.style.styleFloat="left";textFieldRight.style.width="100px";textFieldRight.style.marginRight="-100px";textFieldWrapper=G.document.createElement("div");textFieldWrapper.style.padding="13px";O=G.document.createElement("input");O.style.width="100%";O.style.margin=0;O.style.padding="3px";O.style.border="1px solid silver";O.style.fontSize="15px";var Z=true;var a=true;O.onkeypress=O.onkeyup=function(b){setTimeout(function(){if(O.value==""&&a){L.notifyListeners("typing",{"status":false,"type":E,"id":R});a=false;Z=true;setTimeout(function(){a=true},10000)}else{if(O.value!=""&&Z){L.notifyListeners("typing",{"status":true,"type":E,"id":R});a=true;Z=false;setTimeout(function(){Z=true},10000)}}},1)};textButton=G.document.createElement("input");textButton.style.width="75px";textButton.style.height="25px";textButton.style.marginTop="13px";textButton.type="submit";textButton.value="Send";textFieldLayout.onsubmit=function(b){L.notifyListeners("send",{"msg":O.value,"type":E,"id":R});L.onfocus();O.value="";O.focus();return false};I.appendChild(textFieldLayout);textFieldLayout.appendChild(textFieldLeft);textFieldLayout.appendChild(textFieldRight);textFieldLeft.appendChild(textFieldWrapper);textFieldRight.appendChild(textButton);textFieldWrapper.appendChild(O);for(var W in M){if(M[W]){this.addUser(W)}}this.activate();this.setInfoText(A);return D};this.addUser=function(Z){var W=UserDB.isGuestID(Z);var c=C.users[Z];if(c==null){c=G.document.createElement("li");M[Z]=c;C.users[Z]=c;C.appendChild(c);if(!W){c.onclick=function(){L.notifyListeners("openprivate",{"id":Z})}}}var b=(B&&Chat.isRoomAdmin(Z,B));var Y=Z==0?null:K.user(Z);var X=Y?Y.displayName:"System Administrator";var d=Y?Y.image:null;var a="";if(d!=null){a=""}c.innerHTML=a+(b?"<strong>":"")+(W?X:('<a href="javascript:void(0);" onclick="return false">'+X+"</a>"))+(b?"</strong>":"")};this.removeUser=function(W){var X=M[W];if(X==null){return }C.removeChild(X);M[W]=null;C.users[W]=null};this.addMessage=function(X,Z,a,Y,W){V.addMessage(X,Z,a,Y,W);J.scrollTop=J.scrollHeight-J.clientHeight};this.setTypingStatus=function(Z,Y,X){var W=(J.scrollTop==J.scrollHeight-J.clientHeight);V.setTypingStatus(Z,Y,X);if(W){J.scrollTop=J.scrollHeight-J.clientHeight}};this.setInfoText=function(W){A=W;if(!A||A==""){U.className="chat-info-hidden"}else{U.className="chat-info"}var X=ViewUtils.accessCodeToURL(A);U.innerHTML='This room is accessible to guests at: <a target="_blank" href="'+X+'">'+X+"</a>";if(T){if(A){F.innerHTML="Turn off guest access";F.onclick=function(){if(confirm("Guests with a link to this room will no longer be able to access it. Are you sure?")){L.notifyListeners("changeaccesscode",{"type":0,"id":R,"op":0,"accesscode":null})}return false}}else{F.innerHTML="Turn on guest access";F.onclick=function(){L.notifyListeners("changeaccesscode",{"type":0,"id":R,"op":1,"accesscode":null});return false}}}if(S&&P){this.setDimensions(S,P)}};this.setType=function(W){E=W};this.setID=function(W){R=W;if(E!=0&&S){H.style.width="150px";H.style.display="";J.style.width=S-154+"px"}else{H.style.width="0px";H.style.display="none";J.style.width=S+"px"}};this.close=function(){L.notifyListeners("close",{"type":E,"id":R});if(D.parentNode){D.parentNode.removeChild(D)}};this.activate=function(){J.scrollTop=Math.max(0,J.scrollHeight);O.focus()};this.setDimensions=function(W,X){if(W==0||X==0){return }S=W;P=X;if(U.className=="chat-info"){X=X-21}N.style.height=Math.max(0,X-50)+"px";J.style.height=Math.max(0,X-50)+"px";H.style.height=Math.max(0,X-50)+"px";if(E!=0){H.style.width="150px";H.style.display="";J.style.width=Math.max(0,W-154)+"px"}else{H.style.width="0px";H.style.display="none";J.style.width=W+"px"}}}function ChatDisplayView(){var D=null;var J=null;var K=null;var C=null;var G=null;var B=null;var L=[];var H=[];var M=[];var A=[];var F=[];var E=[];var I=function(V){var R=V.type;var W=V.username;var U=V.timestamp;var S=V.message;if(V.msgDiv&&V.msgDiv.parentNode){V.msgDiv.parentNode.removeChild(V.msgDiv)}var Q=J.document.createElement("div");V.msgDiv=Q;var P=U.formatDate("h:i A");var T='<div class="'+R+'"><span class="username">'+W+'</span> <span class="timestamp">'+P+'</span><span class="message">'+S+"</span></div>";Q.innerHTML=T;K.appendChild(Q);G.style.display=""};var O=function(Q){var V=Q.type;var S=Q.username;var T=Q.timestamp;var X=Q.message;if(Q.msgDiv&&Q.msgDiv.parentNode){Q.msgDiv.parentNode.removeChild(Q.msgDiv)}var W=J.document.createElement("div");Q.msgDiv=W;var R=T.formatDate("h:i A");if(Q.img){var P='<div class="'+V+'-thumbnail"><img width="42" height="42" src="'+Q.img+'" /></div>';W.innerHTML+=P}var U='<div class="'+V+'">			<div class="top-row">				<div class="top-left"></div>				<div class="top-middle"></div>				<div class="top-right"></div>			</div>			<table cellpadding="0" cellspacing="0">				<tr width="100%">					<td class="left"><div class="left"></div></td>					<td class="middle"><div class="contents"><div><span class="username">'+S+'</span> <span class="timestamp">'+R+'</span></div> <div><span class="message">'+X+'</span></div></div></td>					<td class="right"><div class="right"></div></td>				</tr>			</table>			<div class="bottom-row">				<div class="bottom-left"></div>				<div class="bottom-middle"></div>				<div class="bottom-right"></div>			</div>		</div>';W.innerHTML+=U;C.appendChild(W)};var N=function(){if(A.length==0){B.innerHTML="";B.style.display="none"}else{B.style.display="";var Q=[];for(var P=0;P<A.length;P++){uid=A[P];username=F[uid];Q.push(username)}B.innerHTML=Q.join(", ");if(Q.length>1){B.innerHTML+=" are typing..."}else{B.innerHTML+=" is typing..."}}};this.create=function(Q){J=Q||window;if(D&&D.parentNode){D.parentNode.removeChild(D)}K=J.document.createElement("div");K.className="older-messages";C=J.document.createElement("div");C.className="recent-messages";G=J.document.createElement("div");G.className="messages-divider";G.innerHTML=" - Older Messages Above - ";G.style.display="none";B=J.document.createElement("div");B.style.display="none";B.className="typing-status";for(var P=0;P<H.length;P++){var R=H[P];I(R)}for(var P=0;P<M.length;P++){var R=M[P];O(R)}N();D=J.document.createElement("div");D.appendChild(K);D.appendChild(G);D.appendChild(C);D.appendChild(B);return D};this.addMessage=function(Q,R,V,S,P){if(M.length>=10){var U=M.splice(0,1);if(U&&U.length==1){U=U[0];H[H.length]=U;I(U)}}var T={"type":Q,"message":R,"username":V,"timestamp":S,"img":P};M[M.length]=T;O(T)};this.setTypingStatus=function(U,R,P){var T=false;var Q=0;for(Q=0;Q<A.length;Q++){if(R==A[Q]){T=true;break}}if(P&&!T){A.push(R);F[R]=U}else{if(!P&&T){A.splice(Q,1);F[R]=null;delete F[R]}}N();if(E[R]){clearTimeout(E[R]);E[R]=null;delete E[R]}if(P){var S=this;E[R]=setTimeout(function(){S.setTypingStatus(U,R,false)},15000)}}}var ChatUtils={preProcessMsg:function(A){A=A.replace(/\&/g,"&amp;");A=A.replace(/\</g,"&lt;");A=A.replace(/\>/g,"&gt;");A=A.replace(/\n/g,"<br />");var B=new RegExp(/((^|\s)((ht|f)tp(s?)\:\/\/|~\/|\/)([\w]+:\w+@)?(([a-zA-Z]{1}([\w\-\.]+\.?)*(\.[\w]{2,5})?)(:[\d]{1,5})?)?((\/?[\w\-]+\/)+|\/?)([\w\-]+\.[\w]{3,4})?([,]\w+)*[\?&\-\w=%,;\+\:\/\.#!\^$@\*\(\)]*[\?&\w=#])/g);A=A.replace(B,function(D){var C=D;if(D.length>35){C=D.substr(0,35)+"..."}return'<a href="'+D+'" title="'+D+'" target="_blank">'+C+"</a>"});return A}};var ViewUtils={userToImageSrc:function(B,C,A){if(B){return"/php/photo/user-images.php?userid="+B.userid+(C?"&groupid="+C:"")+(B.image?"&timestamp="+B.image:"")+(A?"&store="+A:"")}else{return"/php/photo/user-images.php"}},imageUploadURL:function(B,C,A){return"/php/photo/upload.php?userid="+B.userid+(C?"&groupid="+C:"")+(A?"&store="+A:"")},fileToURL:function(E,A,D,C,B){return"/php/file/download.php?type="+E+"&id="+(A?A:"")+(D?"&groupid="+D:"")+"&filename="+C+(B?"&store="+B:"")},fileToUploadURL:function(F,A,E,D,C,B){return"/php/file/upload.php?type="+F+"&id="+(A?A:"")+(E?"&groupid="+E:"")+(D?"&userid="+D:"")+"&filename="+C+(B?"&store="+B:"")},accessCodeToURL:function(A){return"http://"+window.location.hostname+"/room/"+A+"/"},newEl:function(D,A,E,C){if(D&&A){var B=D.createElement(A);if(E){B.id=E}if(C){B.className=C}return B}return null}};var m_uid=null;var m_key=null;var m_heartbeat=null;var m_heartbeatInterval=null;var model=null;var m_userdb=null;var m_chatdb=null;var group_id="INBIT2";var access_code="0";function AppModel(){Gilean.mvc.Model.apply(this);m_userdb=new UserDB();m_chatdb=new ChatDB();m_addb=new AdDB();this.m_privil=null;this.m_groupinfo=null;this.m_hostname=null;m_userdb.addRelay(this);m_addb.addRelay(this);this._displayName=null;this._email=null;this._receivedPrivileges=false;this._receivedUserDB=true;this._receivedChatDB=true;this._receivedAdDB=true;this._receivedGroupInfo=false;this.addEvent("message",new Gilean.observer.Event("onMessage"));this.addEvent("enterroom",new Gilean.observer.Event("onUserEnterRoom"));this.addEvent("exitroom",new Gilean.observer.Event("onUserExitRoom"));this.addEvent("adduserroom",new Gilean.observer.Event("onAddUserToRoom"));this.addEvent("removeroomuser",new Gilean.observer.Event("onRemoveUserFromRoom"));this.addEvent("typingstatus",new Gilean.observer.Event("onTypingStatus"));this.addEvent("signin",new Gilean.observer.Event("onSigninStatus"));this.addEvent("updategroupinfo",new Gilean.observer.Event("onUpdateGroupInfo"));this.addEvent("updateads",new Gilean.observer.Event("onUpdateAds"))}AppModel.prototype=new Gilean.mvc.Model();AppModel.loginStatus={OK:1,IN_PROGRESS:2,INVALID_PASSWORD:3,CLIENT_NO_LONGER_SUPPORTED:4,GROUP_ACCOUNT_MAINTENANCE:5,INVALID_GROUP:6,ACCOUNT_BLOCKED:7,GROUP_ACCOUNT_BLOCKED:8,OVER_LICENSE_LIMIT:9,SERVICE_NOT_AVAILABLE:10,NEED_DISPLAYNAME:11,INVALID_ACCESSCODE:12,USER_NOT_AVAILABLE:13};AppModel.connectionType={DIRECT:10882,DIRECT_SERVER:10883,TUNNEL:443};AppModel.connectionTarget={SERVER:0,PROXY:1};AppModel.prototype.initialize=function(){initSock();this._socket=new Sock()};AppModel.prototype.getPrivileges=function(){return this.m_privil};AppModel.prototype.connect=function(B,A){B=B||"proxy.24im.net";A=A||this.connectionType;Logger.debug("connecting to "+B+":"+A);this._socket.Connect(B,A,"OnConnect","OnRecv","OnCloseConnection")};AppModel.prototype.disconnect=function(){this._socket.Disconnect()};AppModel.prototype.signin=function(A,B){this._displayName=A;this._email=B;if(A==""){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.NEED_DISPLAYNAME});return false}model=this;this.connectionType=AppModel.connectionType.DIRECT;this.connectionTarget=AppModel.connectionTarget.PROXY;this.connect();return true};AppModel.prototype.signout=function(){var A=new IMXMLMessage(4);this._socket.Send(A.toString())};AppModel.prototype.sendMessage=function(C,A,D){var B=new IMXMLMessage(101);B.addElement("a",A);B.addElement("b",D);B.addElement("c",m_uid);B.addElement("d",0);B.addElement("e",0);B.addElement("f",C,m_key);this.notifyListeners("message",{"msg":C,"uid":m_uid,"type":A,"id":D});this._socket.Send(B.toString())};AppModel.prototype.setTypingStatus=function(B,D,A){var C=new IMXMLMessage(128);C.addElement("a",B);C.addElement("b",D);C.addElement("c",m_uid);C.addElement("d",A);this._socket.Send(C.toString())};AppModel.prototype.onConnect=function(B){if(B){var A=new IMXMLMessage(7);A.addElement("a",4);A.addElement("d",group_id);A.addElement("e",this.connectionTarget);this._socket.Send(A.toString())}else{if(this.connectionType==AppModel.connectionType.DIRECT){this.connectionType=AppModel.connectionType.TUNNEL;this.connect()}else{this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.SERVICE_NOT_AVAILABLE})}}};AppModel.prototype.onRecv=function(M){Logger.debug("[Received]: "+M);var H=new IMXMLParser(M);var T=H.getId();if(!this.isReadyForMsg(T)){return }if(T==6){this._socket.Send("<1>")}if(T==8){var B=H.getElement("a");if(B==1){var L=this._displayName;var U=this._email;var K=new IMXMLMessage(12);K.addElement("a",L);K.addElement("b",access_code);K.addElement("c",1);K.addElement("d",U);K.addElement("e",group_id);this._socket.Send(K.toString())}else{if(B===0){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.CLIENT_NO_LONGER_SUPPORTED});this.disconnect()}else{if(B==2){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.GROUP_ACCOUNT_MAINTENANCE});this.disconnect()}else{if(B==3){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.GROUP_ACCOUNT_BLOCKED});this.disconnect()}else{if(B==4){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.INVALID_GROUP});this.disconnect()}else{if(B==5){var N=H.getElement("l");var P=H.getElement("k");this.disconnect();Logger.debug("redirecting to: "+N+" : "+P);if(this.connectionType==AppModel.connectionType.DIRECT){this.connectionType=P?P:AppModel.connectionType.DIRECT_SERVER}this.connectionTarget=AppModel.connectionTarget.SERVER;this.connect(N)}else{this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.INVALID_ACCESSCODE});this.disconnect()}}}}}}}else{if(T==13){var B=H.getElement("a");if(B==6){m_uid=H.getElement("c");m_key=H.getElement("e");m_heartbeatInterval=H.getElement("m");var Q=this._socket;m_heartbeat=setInterval(function(){Q.Send("<1>")},m_heartbeatInterval*3000/4);if(m_key){Logger.debug("Encrypted Key is "+m_key);var E=formatKey(this._password);m_key=IMXML.decrypt(m_key,E);Logger.debug("Decrypted Key is "+m_key);m_key=formatKey(m_key)}this.notifyListeners("signin",{"online":true});K=new IMXMLMessage(706);K.addElement("b",3);var A=new IMXMLRecord();A.addElement("f",group_id);K.addRecord(A);this._socket.Send(K.toString());K=new IMXMLMessage(374);this._socket.Send(K.toString())}else{if(B==2){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.GROUP_ACCOUNT_MAINTENANCE});this.disconnect()}else{if(B==3){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.ACCOUNT_BLOCKED});this.disconnect()}else{if(B==8){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.OVER_LICENSE_LIMIT});this.disconnect()}else{if(B==9||B==10){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.INVALID_ACCESSCODE});this.disconnect()}else{if(B==11){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.USER_NOT_AVAILABLE});this.disconnect()}else{this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.INVALID_ACCESSCODE});this.disconnect()}}}}}}}else{if(T==74){var R=H.getElement("b");var X=H.getRecords();if(R==1){m_chatdb.addRooms(X)}else{m_chatdb.removeRooms(X)}}else{if(T==101){var O=this;var I=function(){if(O.m_hostname==null){setTimeout(I,100);return }var a=H.getElement("a");var Y=H.getElement("b");var Z=H.getElement("c");var b=H.getElement("f",m_key);O.notifyListeners("message",{"msg":b,"uid":Z,"type":a,"id":Y})};I()}else{if(T==106){var J=H.getElement("a");if(J!="0"){var S=H.getElement("b");var F=H.getElement("c");this.notifyListeners("exitroom",{"type":J,"id":S,"uid":F})}}else{if(T==115){var J=H.getElement("a");var S=H.getElement("b");var F=H.getElement("c");m_userdb.addGuest(F,H.getElement("e"),H.getElement("f"));this.notifyListeners("enterroom",{"uid":F,"type":J,"id":S})}else{if(T==118){var J=H.getElement("a");var S=H.getElement("b");this.notifyListeners("enterroom",{"id":S,"uid":m_uid,"type":J});if(J!="0"){var D=H.getRecords();for(var W=0;W<D.length;W++){var G=D[W];var C=IMXMLParser.getRecordElement(G,"a");var L=IMXMLParser.getRecordElement(G,"c");var U=IMXMLParser.getRecordElement(G,"d");m_userdb.addGuest(C,L,U);this.notifyListeners("adduserroom",{"type":J,"id":S,"uid":C})}}}else{if(T==128){var J=H.getElement("a");var S=H.getElement("b");var F=H.getElement("c");var V=H.getElement("d");this.notifyListeners("typingstatus",{"type":J,"id":S,"uid":F,"status":V})}else{if(T==374){m_addb.initialize();var X=H.getRecords();m_addb.addAds(X);this._receivedAdDB=true}else{if(T==706){var X=H.getRecords();if(X.length>=1){this.m_hostname=IMXMLParser.getRecordElement(X[0],"a");this.m_groupInfo=new GroupInfo(X[0]);this.notifyListeners("updategroupinfo",{});this._receivedGroupInfo=true}}}}}}}}}}}};AppModel.prototype.isReadyForMsg=function(B){var A=function(E,D){for(var C in D){if(E==D[C]){return true}}return false};if((this._receivedUserDB==false||this._receivedOnlineList==false)&&A(B,[14,15,26,27,53,521])){return false}if(this._receivedChatDB==false&&A(B,[74,521])){return false}return true};AppModel.prototype.onCloseConnection=function(){this._receivedPrivileges=false;this._receivedUserDB=false;this._receivedGroupInfo=false;this._receivedAdDB=false;this.m_privil=null;this.m_groupinfo=null;clearInterval(m_heartbeat);this.notifyListeners("signin",{"online":false})};var OnConnect=function(A){model.onConnect(A)};var OnRecv=function(A){model.onRecv(A)};var OnCloseConnection=function(){model.onCloseConnection()};function UserDB(){this.__base=Gilean.observer.Subject;this.__base();this.users=[];this.addEvent("update",new Gilean.observer.Event("onUpdateUser"));this.addEvent("user",new Gilean.observer.Event("onAddUser"))}UserDB.prototype=new Gilean.observer.Subject;UserDB.prototype.initialize=function(){this.users=[]};UserDB.prototype.user=function(A){return this.users[A]};UserDB.prototype.signon=function(A){if(this.user(A)&&!UserDB.isGuestID(A)){this.user(A).signon();this.notifyListeners("update",{"id":A,"action":"status"})}};UserDB.prototype.signoff=function(A){if(this.user(A)&&!UserDB.isGuestID(A)){this.user(A).signoff();this.notifyListeners("update",{"id":A,"action":"status"})}};UserDB.prototype.addUsers=function(B){for(var C=0;C<B.length;C++){var A=new User(B[C]);if(olduser=this.users[A.userid]){A.online=olduser.online;A.image=olduser.image}this.users[A.userid]=A;this.notifyListeners("user",{"id":A.userid})}};UserDB.prototype.removeUsers=function(B){for(var C=0;C<B.length;C++){var A=new User(B[C]);this.users[A.userid]=null;this.notifyListeners("user",{"id":A.userid})}};UserDB.prototype.setUserImage=function(B,A){this.user(B).setImage(A);this.notifyListeners("update",{"id":B})};UserDB.isGuestID=function(A){if(A<0){return true}else{return false}};UserDB.prototype.addGuest=function(D,A,C){var B=new User();if(!UserDB.isGuestID(D)&&this.users[D]!=null){return }B.userid=D;B.displayName=UserDB.isGuestID(D)?A+" (Guest)":A;B.email=C;this.users[B.userid]=B};UserDB.prototype.removeGuest=function(A){if(!UserDB.isGuestID(A)&&this.users[A]!=null){return }this.users[A]=null};function User(A){if(A){this.userid=IMXMLParser.getRecordElement(A,"b");this.firstName=IMXMLParser.getRecordElement(A,"c");this.middleName=IMXMLParser.getRecordElement(A,"d");this.lastName=IMXMLParser.getRecordElement(A,"e");this.phoneNumber=IMXMLParser.getRecordElement(A,"f");this.email=IMXMLParser.getRecordElement(A,"g");this.signin=IMXMLParser.getRecordElement(A,"h");this.screenName=IMXMLParser.getRecordElement(A,"i");this.image=IMXMLParser.getRecordElement(A,"j");this.roleid=IMXMLParser.getRecordElement(A,"k");this.privileges=IMXMLParser.getRecordElement(A,"l");this.displayName=IMXMLParser.getRecordElement(A,"o")}this.online=false}User.prototype.signon=function(){this.online=true};User.prototype.signoff=function(){this.online=false};User.prototype.isSignedOn=function(){return this.online};User.prototype.image=function(){return this.image};User.prototype.setImage=function(A){this.image=A};function ChatDB(){this.__base=Gilean.observer.Subject;this.__base();this.rooms=[];this.addEvent("update",new Gilean.observer.Event("onUpdateRoom"));this.addEvent("remove",new Gilean.observer.Event("onRemoveRoom"))}ChatDB.prototype=new Gilean.observer.Subject;ChatDB.prototype.initialize=function(){this.rooms=[]};ChatDB.prototype.addRooms=function(A){for(var C=0;C<A.length;C++){var B=new Chat(A[C]);this.rooms[B.chatid]=B;this.notifyListeners("update",{"id":B.chatid})}};ChatDB.prototype.removeRooms=function(A){for(var C=0;C<A.length;C++){var B=new Chat(A[C]);this.notifyListeners("remove",{"id":B.chatid});this.rooms[B.chatid]=null}};ChatDB.prototype.updateRoomUserCount=function(B,A){if(this.rooms[B]){this.rooms[B].userCount=A;this.notifyListeners("update",{"id":B})}};ChatDB.prototype.updateRoomAccessCode=function(B,A){if(this.rooms[B]){this.rooms[B].accessCode=A;this.notifyListeners("update",{"id":B})}};function Chat(A){this.specialUsers=[];if(A){this.chatid=IMXMLParser.getRecordElement(A,"b");this.sponsor=IMXMLParser.getRecordElement(A,"c");this.name=IMXMLParser.getRecordElement(A,"d");this.owner=IMXMLParser.getRecordElement(A,"e")||0;this.ownerType=IMXMLParser.getRecordElement(A,"f")||0;this.status=IMXMLParser.getRecordElement(A,"g")||0;this.announcement=IMXMLParser.getRecordElement(A,"h");this.description=IMXMLParser.getRecordElement(A,"i");this.accessCode=IMXMLParser.getRecordElement(A,"j");var D=A.getElementsByTagName("UL");if(D&&D.length>0){var C=D[0].getElementsByTagName("ID");for(var E=0;E<C.length;E++){var B=C[E].childNodes[0].nodeValue;this.specialUsers.push(B)}}this.userCount=0}}Chat.isRoomAdmin=function(A,D){if(D.ownerType!=1){var C=D.specialUsers;for(var B=0;B<C.length;B++){if(A==C[B]){return true}}}else{return(A==D.owner)}return false};function GroupInfo(A){if(A){this.accountid=IMXMLParser.getRecordElement(A,"b");this.groupid=IMXMLParser.getRecordElement(A,"c");this.groupname=IMXMLParser.getRecordElement(A,"g");this.servicePlan=IMXMLParser.getRecordElement(A,"q");this.maxUsers=IMXMLParser.getRecordElement(A,"t");this.renewDate=IMXMLParser.getRecordElement(A,"n")}}function AdDB(A){this.__base=Gilean.observer.Subject;this.__base();this.ads=new Array();this.addEvent("update",new Gilean.observer.Event("onUpdateAds"))}AdDB.prototype=new Gilean.observer.Subject;AdDB.prototype.initialize=function(){this.ads=new Array()};AdDB.prototype.addAds=function(C){for(var A=0;A<C.length;A++){var B=new Ad(C[A]);this.ads.push(B)}this.notifyListeners("update",{"ads":this.ads})};function Ad(A){if(A){this.tickerid=IMXMLParser.getRecordElement(A,"b");this.senderid=IMXMLParser.getRecordElement(A,"c");this.runstatus=IMXMLParser.getRecordElement(A,"d");this.messagetype=IMXMLParser.getRecordElement(A,"e");this.username=IMXMLParser.getRecordElement(A,"f");this.message=IMXMLParser.getRecordElement(A,"g");this.url=IMXMLParser.getRecordElement(A,"h");this.stopdate=IMXMLParser.getRecordElement(A,"i")}}
