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 D=B["username"];var A=B["password"];var C=B["remember"];this._model.signin(D,A,C)};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(2,B)};AppController.prototype.onClose=function(A){var B=A["type"];var C=A["id"];this._model.closeChat(B,C)};AppController.prototype.onJoinInvite=function(A){var B=A["type"];var C=A["id"];this._model.openChatroom(B,C)};AppController.prototype.onDeclineInvite=function(A){var B=A["type"];var C=A["id"];this._model.declineInvite(B,C)};AppController.prototype.onCreateRoom=function(A){this._model.createOrUpdateChatroom(A["chat"])};AppController.prototype.onDeleteRoom=function(A){this._model.deleteChatroom(A["id"])};AppController.prototype.onCreateWorkgroup=function(A){this._model.createOrUpdateDepartment(A["workgroup"],DepartmentDB.type.WORKGROUP)};AppController.prototype.onDeleteWorkgroup=function(A){this._model.deleteDepartment(A["id"],DepartmentDB.type.WORKGROUP)};AppController.prototype.onCreateDepartment=function(A){this._model.createOrUpdateDepartment(A["dept"],DepartmentDB.type.DEPARTMENT)};AppController.prototype.onDeleteDepartment=function(A){this._model.deleteDepartment(A["id"],DepartmentDB.type.DEPARTMENT)};AppController.prototype.onCreateUser=function(A){this._model.createOrUpdateUser(A["user"])};AppController.prototype.onDeleteUser=function(A){this._model.deleteUser(A["id"])};AppController.prototype.onCreateLink=function(A){this._model.createOrUpdateLink(A["link"])};AppController.prototype.onDeleteLink=function(A){this._model.deleteLink(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.onChangeAccessCode=function(A){this._model.changeAccessCode(A["type"],A["id"],A["op"],A["accesscode"])};AppController.prototype.onAddStreamMsg=function(A){this._model.addStreamMessage(A["msg"])};AppController.prototype.onRequestFiles=function(A){this._model.requestFiles(A["ownertype"],A["owner"])};AppController.prototype.onUploadFile=function(A){this._model.uploadFile(A["fileownertype"],A["fileowner"],A["compression"],A["filesize"],A["filename-stored"],A["filename-target"],A["description"])};AppController.prototype.onDeleteFile=function(A){this._model.deleteFile(A["ownertype"],A["owner"],A["filename"])};AppController.prototype.onSignout=function(A){this._model.signout()};function LoginView(A){this.__base=Gilean.mvc.View;this.__base(A);this.m_wndLogin=null;this.addEvent("login",new Gilean.observer.Event("onLogin"))}LoginView.prototype=new Gilean.mvc.View;LoginView.prototype.showLogin=function(B){if(this.m_wndLogin==null){var A=this;B=B||AppModel.loginStatus.OK;storedUserName=this._model.getStoredUsername()||"";storedPassword=this._model.getStoredPassword()||"";var D=document.createElement("form");D.name="login";D.id="login-form";D.method="post";D.setAttribute("autocomplete","off");D.onsubmit=function(){A.showStatus(AppModel.loginStatus.IN_PROGRESS);A.notifyListeners("login",{"username":D.username.value,"password":D.password.value,"remember":D.remember.checked});return false};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 web client access.<br /> <a href="http://get.adobe.com/flashplayer/">Get Flash Now</a>.</p>					</div>				</div>'}else{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">						<div class="field">							<label for="username">Sign-in:</label> <input size="25" class="input-text" id="username" name="username" value="'+storedUserName+'"></input>						</div>						<div class="field">							<label for="password">Password:</label> <input size="25" class="input-text" id="password" name="password" value="'+storedPassword+'" type="password"></input>						</div>						<div class="field">							<label></label><input type="checkbox" name="remember" checked="checked"></input> <span id="remember-me">Remember me</span>						</div>						<div class="field" id="submit-field">							<label></label><input type="submit" value="Sign In"></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="security-note">							24im uses a <a href="http://en.wikipedia.org/wiki/Cryptographic_nonce" target="_blank">cryptographic nonce</a> for authentication.						</div>					</div>				</div>'}this.m_wndLogin=new JSDialog();this.m_wndLogin.CreateWindow("Welcome - Login",false,D)}if($("username")){this.showStatus(B);$("username").focus()}};LoginView.prototype.hideLogin=function(){if(this.m_wndLogin){this.m_wndLogin.DestroyWindow();this.m_wndLogin=null}};LoginView.prototype.showStatus=function(A){if(A==AppModel.loginStatus.OK){addClass($("login-status-field"),"hidden");addClass($("loading-field"),"hidden");removeClass($("submit-field"),"hidden");removeClass($("security-note"),"hidden")}else{if(A==AppModel.loginStatus.IN_PROGRESS){addClass($("login-status-field"),"hidden");removeClass($("loading-field"),"hidden");addClass($("submit-field"),"hidden");removeClass($("security-note"),"hidden")}else{removeClass($("login-status-field"),"hidden");addClass($("loading-field"),"hidden");removeClass($("submit-field"),"hidden");addClass($("security-note"),"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"}}}}}}}return""};function MainView(A){this.__base=Gilean.mvc.View;this.__base(A);this.contactPanelView=new ContactPanelView(A);this.contactPanelView.addRelay(this);this.userPanelView=new UserPanelView(A);this.userPanelView.addRelay(this);this.chatRoomsView=new ChatRoomsView(A);this.chatRoomsView.addRelay(this);this.activeRoomsView=new ActiveRoomsView(A);this.activeRoomsView.addRelay(this);this.linkView=new LinkView(A);this.linkView.addRelay(this);this.filePostView=new FilePostView(A);this.filePostView.addRelay(this);this.fileView=new FileView(A);this.fileView.addRelay(this);this.departmentsView=new DepartmentsView(A);this.departmentsView.addRelay(this);this.accountInfoView=new AccountInfoView(A);this.accountInfoView.addRelay(this);this.adminUserView=new AdminUserView(A);this.adminUserView.addRelay(this);this.chatView=new ChatView(A);this.chatView.addRelay(this);this.streamView=new StreamView(A);this.streamView.addRelay(this);this.soundManagerView=new SoundManagerView(A);this.soundManagerView.addRelay(this);this.addEvent("signout",new Gilean.observer.Event("onSignout"))}MainView.prototype=new Gilean.mvc.View;MainView.prototype.onSigninStatus=function(C){if(C["online"]==true){var H=this;var M=null;var E=document.createElement("a");E.href="javascript:void(0);";E.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/changephotoview.js"],function(){var S=function(){if(window.ChangePhotoView&&window.FormView){if(!H.changePhotoView){H.changePhotoView=new ChangePhotoView(H._model);H.changePhotoView.addRelay(H)}H.changePhotoView.render()}else{setTimeout(S,200)}};S()},null,null,true);return false};E.innerHTML="Change Photo";M=document.createElement("li");M.appendChild(E);if(m_uid!=0){document.getElementById("header-menu").appendChild(M)}var I=document.createElement("a");I.href="javascript:void(0);";I.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/changepasswordview.js"],function(){var S=function(){if(window.ChangePasswordView&&window.FormView){if(!H.changePasswordView){H.changePasswordView=new ChangePasswordView(H._model);H.changePasswordView.addRelay(H)}H.changePasswordView.render()}else{setTimeout(S,200)}};S()},null,null,true);return false};I.innerHTML="Change Password";M=document.createElement("li");M.appendChild(I);if(this._model.getPrivileges().isPasswordChangeable()){document.getElementById("header-menu").appendChild(M)}var L=document.createElement("a");L.href="javascript:void(0);";L.onclick=function(){H.notifyListeners("signout",{});return false};L.innerHTML="Sign Out";M=document.createElement("li");M.appendChild(L);document.getElementById("header-menu").appendChild(M);var A=new JSTabControl;tabWnd=A.create();var F=A.addTab("Home");var B=A.getContent(F);var J=A.addTab("Chatrooms");var P=A.getContent(J);var G=A.addTab("Links");var O=A.getContent(G);var K=A.addTab("Files");var D=A.getContent(K);if(m_uid!=0){var R=A.addTab("People");var Q=A.getContent(R)}var N=document.createElement("div");N.className="clearfix";N.appendChild(this.soundManagerView.render());document.getElementById("left-column-contents").appendChild(this.userPanelView.render());document.getElementById("center-column-contents").appendChild(tabWnd);if(m_uid!=0){B.appendChild(this.streamView.render())}else{if(this._model.getPrivileges().isAdmin(m_uid)){B.appendChild(this.adminUserView.render())}}if(this._model.getPrivileges().isAdmin(m_uid)){B.appendChild(this.departmentsView.render())}if(this._model.getPrivileges().isAdmin(m_uid)){document.getElementById("left-column-contents").appendChild(this.accountInfoView.render())}P.appendChild(this.chatRoomsView.render());O.appendChild(this.linkView.render());D.appendChild(this.filePostView.render());D.appendChild(this.fileView.render());if(m_uid!=0){Q.appendChild(this.adminUserView.render())}document.getElementById("right-column-contents").appendChild(N);document.getElementById("right-column-contents").appendChild(this.contactPanelView.render());document.getElementById("right-column-contents").appendChild(this.activeRoomsView.render());window.onbeforeunload=function(){return"If you leave you will be disconnected!"};window.onunload=function(){H.notifyListeners("signout",{})}}else{document.getElementById("header-menu").innerHTML="";document.getElementById("main-tabs").innerHTML="";document.getElementById("left-column-contents").innerHTML="";document.getElementById("center-column-contents").innerHTML="";document.getElementById("right-column-contents").innerHTML="";document.getElementById("group-name").innerHTML="";window.onbeforeunload=window.onunload=function(){}}};MainView.prototype.onUpdateGroupInfo=function(A){document.getElementById("group-name").innerHTML=this._model.m_groupInfo.groupname};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 AccountInfoView(A){this.__base=Gilean.mvc.View;this.__base(A);this._mainDiv=document.createElement("div")}AccountInfoView.prototype=new Gilean.mvc.View;AccountInfoView.prototype.render=function(){return this._mainDiv};AccountInfoView.prototype.show=function(){this._mainDiv.style.display="block"};AccountInfoView.prototype.hide=function(){this._mainDiv.style.display="none"};AccountInfoView.prototype.getPlanNameFromID=function(A){if(A=="0"||A==null){return"Free"}else{if(A=="1"){return"Bronze"}else{if(A=="2"){return"Silver"}else{if(A=="3"){return"Gold"}else{if(A=="3"){return"Platinum"}else{return"Custom"}}}}}};AccountInfoView.prototype.CreatePanel=function(){var A=this;this._mainDiv.innerHTML="";var H=document.createElement("h3");H.className="contact-type-header";H.innerHTML="Account Info";this._mainDiv.appendChild(H);var D=this._model.m_groupInfo.servicePlan;var G=document.createElement("div");G.className="account-info-line";G.innerHTML="Subscription Plan: "+this.getPlanNameFromID(D);this._mainDiv.appendChild(G);var F=document.createElement("div");F.className="account-info-line";F.innerHTML="Max. Group Users: "+this._model.m_groupInfo.maxUsers;this._mainDiv.appendChild(F);if(D!="0"&&D!=null){var E=document.createElement("div");var B=new Date(parseInt(this._model.m_groupInfo.renewDate)*1000);E.className="account-info-line";E.innerHTML="Next Billing Date: "+B.formatDate("M")+" "+B.formatDate("d")+", "+B.formatDate("Y");this._mainDiv.appendChild(E);var C=document.createElement("div");C.style.fontSize="70%";C.className="account-info-line";C.innerHTML='<a href="http://www.24im.com/subscribe/billing/'+group_id+'/" target="_blank">Change billing information</a>';this._mainDiv.appendChild(C)}};AccountInfoView.prototype.onUpdateGroupInfo=function(A){this.CreatePanel()};function ActiveRoomsView(A){this.__base=Gilean.mvc.View;this.__base(A);this._mainDiv=document.createElement("div");this._activeList=new SortedList(ActiveRoomsView.sortActiveRooms);this.addEvent("openchat",new Gilean.observer.Event("onOpenChat"))}ActiveRoomsView.prototype=new Gilean.mvc.View;ActiveRoomsView.sortActiveRooms=function(B,A){if(A.count<B.count){return 1}else{if(B.count<A.count){return -1}else{return 0}}};ActiveRoomsView.prototype.render=function(){return this._mainDiv};ActiveRoomsView.prototype.show=function(){this._mainDiv.style.display="block"};ActiveRoomsView.prototype.hide=function(){this._mainDiv.style.display="none"};ActiveRoomsView.prototype.appendRoom=function(C){var A=m_chatdb.rooms[C];var H=A.name;var D=A.userCount;var E=this._activeList.getElement().rooms[C];var G;var I;var J;if(!E){var K=document.createElement("li");var F=this;G=document.createElement("a");G.href="javascript:void(0);";G.onclick=function(){F.notifyListeners("openchat",{"id":C});return false};K.appendChild(G);K.link=G;var B=document.createElement("span");B.innerHTML=" ";K.appendChild(B);I=document.createElement("span");I.style.color="silver";K.appendChild(I);K.span=I}else{K=E;G=K.link;I=K.span}K.count=D;G.innerHTML=H;I.innerHTML="("+D+")";if(!E){this._activeList.getElement().rooms[C]=K;this._activeList.insert(K)}else{this._activeList.remove(K);this._activeList.insert(K)}};ActiveRoomsView.prototype.removeRoom=function(B){var A=this._activeList.getElement().rooms[B];if(A){this._activeList.remove(A);this._activeList.getElement().rooms[B]=null}};ActiveRoomsView.prototype.checkToShowEmptyMessage=function(){if(this._activeList.size()==0){this.emptyListDescription.style.display="";this._activeList.getElement().style.display="none"}else{this.emptyListDescription.style.display="none";this._activeList.getElement().style.display=""}};ActiveRoomsView.prototype.CreatePanel=function(){var B=document.createElement("h3");B.className="contact-type-header";B.innerHTML="Active Chatrooms";this.emptyListDescription=document.createElement("p");this.emptyListDescription.className="information";this.emptyListDescription.innerHTML="No active chatrooms";var A=this._activeList.getElement();A.id="active-rooms";A.className="contact-list";A.rooms=[];A.style.display="none";this._mainDiv.appendChild(B);this._mainDiv.appendChild(this.emptyListDescription);this._mainDiv.appendChild(A)};ActiveRoomsView.prototype.onRemoveRoom=function(A){this.removeRoom(A["id"]);this.checkToShowEmptyMessage()};ActiveRoomsView.prototype.onUpdateRoom=function(A){var C=A["id"];var B=m_chatdb.rooms[C];if(B&&B.userCount>0&&B.status==1){this.appendRoom(A["id"])}else{this.removeRoom(A["id"])}this.checkToShowEmptyMessage()};ActiveRoomsView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._mainDiv.innerHTML="";this._activeList.empty()}};function AdminLogView(A){Gilean.mvc.View.call(this,A);this._mainDiv=document.createElement("div")}AdminLogView.prototype=new Gilean.mvc.View;AdminLogView.prototype.render=function(){return this._mainDiv};AdminLogView.prototype.show=function(){this._mainDiv.style.display="block"};AdminLogView.prototype.hide=function(){this._mainDiv.style.display="none"};AdminLogView.prototype.CreatePanel=function(){var A=document.createElement("h2");A.className="column-header";A.innerHTML="Admin Logs";this.log=document.createElement("div");this.log.className="log";this.log.style.overflow="auto";this._mainDiv.appendChild(A);this._mainDiv.appendChild(this.log)};AdminLogView.prototype.onLogMessage=function(B){var A=new Date(B["timestamp"]*1000);var C=A.formatDate("g:i a");this.log.innerHTML+=('<span class="timestamp">['+C+"]</span> "+(B["chatroom"]?('<span class="chatroom">['+B["chatroom"]+"]</span> "):"")+'<span class="username">'+B["username"]+":</span> "+B["message"]+"<br />")};AdminLogView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._mainDiv.innerHTML=""}};function AdminUserView(A){this.__base=Gilean.mvc.View;this.__base(A);this._mainDiv=document.createElement("div");this._userList=new SortedList(AdminUserView.sortOnlineItem);this.addEvent("deleteuser",new Gilean.observer.Event("onDeleteUser"))}AdminUserView.prototype=new Gilean.mvc.View;AdminUserView.sortOnlineItem=function(B,A){if(B.displayName.innerHTML<A.displayName.innerHTML){return 1}else{if(A.displayName.innerHTML<B.displayName.innerHTML){return -1}else{return 0}}};AdminUserView.prototype.render=function(){return this._mainDiv};AdminUserView.prototype.show=function(){this._mainDiv.style.display="block"};AdminUserView.prototype.hide=function(){this._mainDiv.style.display="none"};AdminUserView.prototype.appendUser=function(M){var Q=document.getElementById("admin-user-column");if(!Q){this.CreatePanel();Q=document.getElementById("admin-user-column");if(!Q){return }}var B=document.getElementById("userlist");if(!B){var B=this._userList.getElement();B.id="userlist";B.className="contact-list";B.users=[];Q.appendChild(B)}var P=B.users[M];if(P==null){P=document.createElement("li");B.users[M]=P;var C=document.createElement("div");var E=document.createElement("div");E.className="delete-stub";C.className="delete-stub-wrapper";C.appendChild(E);P.appendChild(C);var K=this;var A=document.createElement("a");A.href="javascript:void(0)";A.className="delete-link";A.onclick=function(){if(confirm("Are you sure you want to delete this user?")){K.notifyListeners("deleteuser",{"id":M})}return false};E.appendChild(A);var U=document.createElement("a");U.className="edit-link";U.href="javascript:void(0)";U.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createuserview.js"],function(){var V=function(){if(window.CreateUserView&&window.FormView){if(!K.createUserView){K.createUserView=new CreateUserView(K._model);K.createUserView.addRelay(K)}K.createUserView.render(m_userdb.user(M))}else{setTimeout(V,200)}};V()},null,null,true);return false};E.appendChild(U);var F=document.createElement("div");F.className="display-name";var T=document.createElement("div");T.className="user-image-container";T.onclick=function(){K.notifyListeners("openprivate",{"id":M});return false};var L=document.createElement("img");L.width="32";L.height="32";P.image=L;if(this._model.getPrivileges().isAdmin(m_uid)){P.appendChild(C);var I=new StubTarget(P,C);I.attachTrigger("mouseover")}var N=document.createElement("div");P.email=N;N.className="sub-desc";var G=document.createElement("div");P.phone=G;G.className="sub-desc";var J=document.createElement("div");P.signin=J;J.className="sub-desc";var O=document.createElement("div");P.department=O;O.className="user-department";var D=document.createElement("div");D.className="user-container";T.appendChild(L);P.appendChild(T);P.displayName=F;D.appendChild(F);D.appendChild(O);D.appendChild(N);D.appendChild(J);D.appendChild(G);P.appendChild(D);P.className="user-entry";P.style.clear="both";var S=m_userdb.user(M);var F=S.displayName;P.displayName.innerHTML=F;this._userList.insert(P)}var S=m_userdb.user(M);var F=S.displayName;P.displayName.innerHTML=F;var R=m_deptdb.getUserDepartment(S.userid);var H=m_deptdb.department(R);if(H){P.department.innerHTML=H.name;P.department.style.display=""}else{P.department.style.display="none"}if(S.email){P.email.innerHTML='<span class="sub-desc-label">email:</span> <a target="_blank" href="mailto:'+S.email+'">'+S.email+"</a>";P.email.style.display=""}else{P.email.style.display="none"}if(S.signin){P.signin.innerHTML='<span class="sub-desc-label">sign-in:</span> '+S.signin;P.signin.style.display=""}else{P.signin.style.display="none"}if(S.phoneNumber){P.phone.innerHTML='<span class="sub-desc-label">phone:</span> '+S.phoneNumber+"<span>";P.phone.style.display=""}else{P.phone.style.display="none"}P.image.src=ViewUtils.userToImageSrc(S,this._model.m_groupInfo?this._model.m_groupInfo.accountid:null,this._model.m_hostname?this._model.m_hostname:null)};AdminUserView.prototype.removeUser=function(F){var D=document.getElementById("admin-user-column");if(!D){this.CreatePanel();D=document.getElementById("admin-user-column");if(!D){return }}var B=document.getElementById("userlist");if(!B){var B=this._userList.getElement();B.id="userlist";B.className="contact-list";B.users=[];var E=document.createElement("h3");E.className="contact-type-header";E.innerHTML="Online Users";D.appendChild(E);D.appendChild(B)}var A=m_userdb.user(F);if(!A){var C=B.users[F];if(C){this._userList.remove(C);B.users[F]=null}}};AdminUserView.prototype.CreatePanel=function(){var A=this;var E=document.createElement("h2");E.className="column-header";E.innerHTML="Group Users";this._mainDiv.appendChild(E);if(m_uid==0){var B=document.createElement("div");B.className="information";B.innerHTML="This is the Group account. You can create group users for your account, including a user account for yourself.";this._mainDiv.appendChild(B)}var C=document.createElement("div");C.className="add-user";C.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createuserview.js"],function(){var F=function(){if(window.CreateUserView&&window.FormView){if(!A.createUserView){A.createUserView=new CreateUserView(A._model);A.createUserView.addRelay(A)}A.createUserView.render()}else{setTimeout(F,200)}};F()},null,null,true);return false};var D=document.createElement("div");D.id="admin-user-column";if(this._model.getPrivileges().isAdmin(m_uid)){D.appendChild(C)}this._mainDiv.appendChild(D)};AdminUserView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._mainDiv.innerHTML="";this._userList.empty()}};AdminUserView.prototype.onUpdateUser=function(A){this.appendUser(A["id"])};AdminUserView.prototype.onAddUser=function(A){if(m_userdb.user(A["id"])){this.appendUser(A["id"])}else{this.removeUser(A["id"])}};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)}}}function ChatRoomsView(A){this.__base=Gilean.mvc.View;this.__base(A);this._mainDiv=document.createElement("div");this.addEvent("openchat",new Gilean.observer.Event("onOpenChat"));this.addEvent("deleteroom",new Gilean.observer.Event("onDeleteRoom"))}ChatRoomsView.prototype=new Gilean.mvc.View;ChatRoomsView.ownerType={PUBLIC:0,PRIVATE:1,WORKGROUP:2,DEPARTMENT:3};ChatRoomsView.prototype.render=function(){return this._mainDiv};ChatRoomsView.prototype.show=function(){this._mainDiv.style.display="block"};ChatRoomsView.prototype.hide=function(){this._mainDiv.style.display="none"};ChatRoomsView.prototype.appendRoom=function(L){var Q=m_chatdb.rooms[L];var A=Q.owner;var G=Q.ownerType;var T=this.addOrGetSection(A,G);var F=Q.name;var E=Q.userCount;var M=Q.status;var I=T.rooms[L];if(M==1){var H;var O;var N;if(!I){var R=document.createElement("li");var C=document.createElement("div");var D=document.createElement("div");D.className="delete-stub";C.className="delete-stub-wrapper";C.appendChild(D);R.appendChild(C);var K=this;H=document.createElement("a");H.href="javascript:void(0);";H.onclick=function(){K.notifyListeners("openchat",{"id":L});return false};R.appendChild(H);R.link=H;var P=document.createElement("span");P.innerHTML=" ";R.appendChild(P);O=document.createElement("span");O.style.color="silver";R.appendChild(O);R.span=O;N=document.createElement("span");N.style.color="gray";N.style.fontSize="80%";R.appendChild(N);R.description=N;if(this._model.getPrivileges().isAllowedToCreateRoom()){var B=document.createElement("a");B.className="delete-link";B.href="javascript:void(0)";B.onclick=function(){if(confirm("Are you sure you want to delete this room?")){K.notifyListeners("deleteroom",{"id":L})}return false};D.appendChild(B);var S=document.createElement("a");S.className="edit-link";S.href="javascript:void(0)";S.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createchatroomview.js"],function(){var U=function(){if(window.CreateChatRoomView&&window.FormView){if(!K.createChatRoomView){K.createChatRoomView=new CreateChatRoomView(K._model);K.createChatRoomView.addRelay(K)}if(G==0){A=0}else{if(G==1){A=m_uid}}K.createChatRoomView.render(A,G,m_chatdb.rooms[L])}else{setTimeout(U,200)}};U()},null,null,true);return false};D.appendChild(S);var J=new StubTarget(H,C);J.attachTrigger("mouseover")}}else{R=I;H=R.link;O=R.span;N=R.description}H.innerHTML=F;if(E>0){O.innerHTML="("+E+")"}else{O.innerHTML=""}if(Q.description){N.innerHTML=" - "+Q.description}T.rooms[L]=R;if(!I){T.appendChild(R)}}else{if(I){this.removeRoom(L)}}};ChatRoomsView.prototype.removeRoom=function(F){var E=m_chatdb.rooms[F];var A=E.owner;var D=E.ownerType;var C=this.addOrGetSection(A,D);var B=C.rooms[F];if(B){C.removeChild(B);C.rooms[F]=null}};ChatRoomsView.prototype.CreatePanel=function(){var A=this;var C=document.createElement("h2");C.className="column-header";C.innerHTML="Chat Rooms";var B=document.createElement("div");B.id="chat-column";B.className="item-column";this._mainDiv.appendChild(B)};ChatRoomsView.prototype.addOrGetSection=function(A,G){var B="chatlist";var J="Public Chatrooms";if(G==3){B+="-3-"+A;J=m_deptdb.departments[A].name}else{if(G==2){B+="-2-"+A;J=m_wkgpdb.departments[A].name}else{if(G==1){B+="-1";J="Private Chatrooms"}}}var F=document.getElementById("chat-column");if(!F){this.CreatePanel();F=document.getElementById("chat-column")}var I=document.getElementById(B);if(!I){var I=document.createElement("ul");I.id=B;I.className="chatroom-list";I.rooms=[];var E=document.createElement("h3");E.className="chatroom-type-header";E.id=B+"-header";E.innerHTML=J;var H=this;var C=document.createElement("div");C.className="chatroom-type-action";C.id=B+"-action";var D=document.createElement("a");D.innerHTML="Add Chatroom";D.href="javascript:void(0)";D.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createchatroomview.js"],function(){var K=function(){if(window.CreateChatRoomView&&window.FormView){if(!H.createChatRoomView){H.createChatRoomView=new CreateChatRoomView(H._model);H.createChatRoomView.addRelay(H)}if(G==0){A=0}else{if(G==1){A=m_uid}}H.createChatRoomView.render(A,G)}else{setTimeout(K,200)}};K()},null,null,true);return false};C.appendChild(D);F.appendChild(E);F.appendChild(I);if(this._model.getPrivileges().isAllowedToCreateRoom()){F.appendChild(C)}}return I};ChatRoomsView.prototype.removeSection=function(B,F){var D="chatlist";var H="Public Chatrooms";if(F==3){D+="-3-"+B}else{if(F==2){D+="-2-"+B}else{if(F==1){D+="-1"}}}var G=$("chat-column");var C=$(D);var A=$(D+"-header");var E=$(D+"-action");if(G&&C){G.removeChild(C)}if(G&&A){G.removeChild(A)}if(G&&E){G.removeChild(E)}};ChatRoomsView.prototype.onRemoveRoom=function(A){this.removeRoom(A["id"])};ChatRoomsView.prototype.onUpdateRoom=function(A){this.appendRoom(A["id"])};ChatRoomsView.prototype.onUpdateDepartment=function(A){var B=A["id"];var C=m_deptdb.department(B);if(this._model.getPrivileges().isAdmin(m_uid)||m_deptdb.isUserOneOf(m_uid,B)){this.addOrGetSection(B,ChatRoomsView.ownerType.DEPARTMENT)}else{this.removeSection(B,ChatRoomsView.ownerType.DEPARTMENT)}};ChatRoomsView.prototype.onRemoveDepartment=function(A){var B=A["id"];var C=m_deptdb.department(B);this.removeSection(B,ChatRoomsView.ownerType.DEPARTMENT)};ChatRoomsView.prototype.onUpdateWorkgroup=function(B){var C=B["id"];var A=m_wkgpdb.department(C);if(this._model.getPrivileges().isAdmin(m_uid)||m_wkgpdb.isUserOneOf(m_uid,C)){this.addOrGetSection(C,ChatRoomsView.ownerType.WORKGROUP)}else{this.removeSection(C,ChatRoomsView.ownerType.WORKGROUP)}};ChatRoomsView.prototype.onRemoveWorkgroup=function(B){var C=B["id"];var A=m_wkgpdb.department(C);this.removeSection(C,ChatRoomsView.ownerType.WORKGROUP)};ChatRoomsView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel();this.addOrGetSection(0,ChatRoomsView.ownerType.PUBLIC);this.addOrGetSection(m_uid,ChatRoomsView.ownerType.PRIVATE)}else{this._mainDiv.innerHTML=""}};function ChatView(A){this.__base=Gilean.mvc.View;this.__base(A);this.m_wndChat=null;this.focused=false;this.blinkTimer=null;this.chatMap=new ChatMap();this.addEvent("send",new Gilean.observer.Event("onSend"));this.addEvent("typing",new Gilean.observer.Event("onTyping"));this.addEvent("joininvite",new Gilean.observer.Event("onJoinInvite"));this.addEvent("declineinvite",new Gilean.observer.Event("onDeclineInvite"));this.addEvent("openprivate",new Gilean.observer.Event("onOpenPrivate"));this.addEvent("close",new Gilean.observer.Event("onClose"));this.addEvent("changeaccesscode",new Gilean.observer.Event("onChangeAccessCode"))}ChatView.prototype=new Gilean.mvc.View;ChatView.prototype.getChat=function(C,D){var B=this.chatMap.get(C,D);if(B!=null&&this.chatTabsManager!=null){var A=this.chatTabsManager.getChat(B);return A}return null};ChatView.prototype.createWindow=function(A,B){this.CreateChatWindow(this,A,B,true)};ChatView.prototype.appendData=function(E,F,H,D,B,C,G){this.CreateChatWindow(this,C,G,false);if(F==""||F==null){return }var A=this.getChat(C,G);if(A){A.addMessage(E,F,H,D,B)}};ChatView.prototype.typingStatus=function(F,C,D,E,A){var B=this.getChat(D,E);if(B){B.setTypingStatus(F,C,A)}};ChatView.prototype.addUserToRoom=function(C,D,B){this.CreateChatWindow(this,C,D,false);var A=this.getChat(C,D);if(A){A.addUser(B)}};ChatView.prototype.removeUserFromRoom=function(C,D,B){var A=this.getChat(C,D);if(A){A.removeUser(B)}};ChatView.prototype.changeAccessCode=function(B,A){chatFrame=this.getChat(2,B);if(chatFrame){chatFrame.setInfoText(A)}};ChatView.prototype.updateChatId=function(C,E,D,A){var B=this.chatMap.get(C,E);if(B!=null){this.chatMap.set(C,E,null);this.chatMap.set(D,A,B);Logger.debug(E+" => "+A);chatFrame=this.chatTabsManager.getChat(B);if(chatFrame){chatFrame.setType(D);chatFrame.setID(A)}}};ChatView.prototype.CreateChatWindow=function(L,J,B,C){var O=this.m_wndChat;var G=this.chatTabsManager;if(!O||!G){var N=getWindowDims();var D=Math.max((N[0]-600)/2,0);var K=Math.max((N[1]-425)/2,0);O=new JSWnd();G=new ChatTabsManager(this,O);this.chatMap=new ChatMap();var I=this;var E=new Object;E.onClose=function(){I.m_wndChat=null;I.chatTabsManager=null};O.CreateWindow("Chat Window",D,K,450,350,true,true,true);O.SetContent(tabWnd);O.setExtractedPage('			<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">			<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">				<head>					<title>Chat Window</title>					<link rel="stylesheet" href="/css/1.0.9.0/common.css" type="text/css" />					<link rel="stylesheet" href="/css/1.0.9.0/jswnd.css" type="text/css" />					<link rel="stylesheet" href="/css/1.0.9.0/jstab.css" type="text/css" />					<link rel="stylesheet" href="/css/1.0.9.0/chat.css" type="text/css" />				</head>				<body class="JSWndBody"></body>			</html>');O.addListener(E);this.m_wndChat=O;this.chatTabsManager=G}var H=this.chatMap.get(J,B);if(H==null||!G.getChat(H)){var M="";if(J==3){M="Live Chat"}else{if(J==2){var A=m_chatdb.rooms[B];M=A.name}else{if(J==1){M="Conference"}else{var F=IMXML.guestIdFromChatId(m_uid,B);user=m_userdb.user(F);M=user?m_userdb.user(F).displayName:"Group Administrator"}}}var H=G.addChat(J,B,M,C);this.chatMap.set(J,B,H)}else{G.focus(H,C)}};ChatView.prototype.onMessage=function(H){var C=H["msg"];var F=H["uid"];var I=H["type"];var B=H["id"];if(!C){return }C=ChatUtils.preProcessMsg(C);var E=m_userdb.user(F);if(!E&&F!==null&&F!=0){return }var J=(F==null)?"System":(F==0)?"Group Administrator":E.displayName;var D=(F==null)?("system-message"):((F==m_uid)?"chat-bubble-self":"chat-bubble");var E=m_userdb.user(F);var G=new Date;var A=F==null?null:ViewUtils.userToImageSrc(E,this._model.m_groupInfo?this._model.m_groupInfo.accountid:null,this._model.m_hostname?this._model.m_hostname:null);this.appendData(D,C,J,G,A,I,B);this.typingStatus(J,F,I,B,false);this.addUserToRoom(I,B,m_uid);if(F!=null){this.addUserToRoom(I,B,F)}if(F!=m_uid){this.flashTitle([J+"!",'"'+C+'"'],window)}};ChatView.prototype.onBlocked=function(F){var C=F["reason"];var D=F["uid"];var G=F["type"];var A=F["id"];var B=m_userdb.user(D);if(!B&&D!==null&&D!=0){return }var H=(D==null)?"System":(D==0)?"Group Administrator":B.displayName;var E=new Date;var I="";if(C==0){I=H+" is currently offline."}else{if(C==4){I=H+" is currently not accepting incoming messages."}}if(I){this.appendData("system-message",I,"System",E,null,G,A)}};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)};ChatView.prototype.onPrivateChat=function(A){var C=A["chatid"];var B=A["uid"];var D=new Date;if(this.getChat(0,C)!=null){this.createWindow(0,C)}else{this.createWindow(0,C);this.appendData("system-message","You may now enter your message. Press ENTER to send.","System",D,null,0,C)}this.addUserToRoom(0,C,m_uid);this.addUserToRoom(0,C,B)};ChatView.prototype.onOthersInvited=function(H){var B=H["prevtype"];var K=H["previd"];var L=H["newtype"];var A=H["newid"];var G=H["invitor"];var E=H["invitees"];var F=new Date;this.updateChatId(B,K,L,A);var D=[];for(var C=0;C<E.length;C++){var I=E[C];var J=m_userdb.users[I].displayName;D.push(J)}if(D.length>0){var J=m_userdb.users[G].displayName;this.appendData("system-message",J+" invited "+D.join(", ")+" to chat.","System",F,null,L,A)}};ChatView.prototype.onInvited=function(H){var I=H["type"];var C=H["id"];var D=H["users"];var E=[];for(var F=0;F<D.length;F++){var G=D[F];var J=m_userdb.users[G].displayName;E.push(J)}var B="";if(I==3){B="a live chat";if(E.length>0){B+=" with "+E.join(", ")}}else{if(I==2){var A=m_chatdb.rooms[C];B='chat room "'+A.name+'"'}else{if(I==1){B="a conference";if(E.length>0){B+=" with "+E.join(", ")}}}}if(window.confirm("You have been invited to join "+B)){this.notifyListeners("joininvite",{"id":C,"type":I})}else{this.notifyListeners("declineinvite",{"id":C,"type":I})}};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(C){var E=C["type"];var G=C["id"];var D=C["uid"];var F=new Date;if(D==m_uid){if(this.getChat(E,G)!=null){this.createWindow(E,G)}else{this.createWindow(E,G);this.appendData("system-message","You may now enter your message. Press ENTER to send.","System",F,null,E,G);if(E=="2"){if(m_chatdb.rooms[G].announcement){this.appendData("announcement-message",m_chatdb.rooms[G].announcement,"Announcement",F,null,E,G)}}}}else{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 entered the room.","System",F,null,E,G)}this.addUserToRoom(E,G,D)};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.onUpdateRoom=function(A){var B=A["id"];var C=m_chatdb.rooms[B];this.changeAccessCode(B,C.accessCode)};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.onUpdateUser=function(D){var C=D["id"];var B=m_userdb.user(C);var E=new Date;if(D["action"]=="status"){var A=IMXML.generateChatId(m_uid,C);if(this.getChat(0,A)!=null){if(!B.isSignedOn()){this.appendData("system-message",B.displayName+" has signed off.","System",E,null,0,A);this.typingStatus(B.displayName,C,0,A,false)}else{this.appendData("system-message",B.displayName+" has signed in.","System",E,null,0,A)}}}};ChatView.prototype.onSigninStatus=function(B){var A=this;if(B["online"]==true){window.onblur=window.document.body.onblur=function(C){A.onblur(C)};window.onfocus=window.document.body.onfocus=function(C){A.onfocus(C)}}else{if(B["online"]==false){if(this.m_wndChat){this.m_wndChat.DestroyWindow();this.m_wndChat=null}this.onfocus();window.onblur=window.onfocus=function(){}}}};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.m_wndChat.isExtracted()){A=this.m_wndChat._subwin}if(this.focused==false||(this.m_wndChat.isExtracted()&&!this.m_wndChat.isFocused())){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(){if(A!=window&&B.m_wndChat._subwin==null){return }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 ContactPanelView(A){this.__base=Gilean.mvc.View;this.__base(A);this._mainDiv=document.createElement("div");this._onlineList=new SortedList(ContactPanelView.sortOnlineItem);this._offlineList=new SortedList(ContactPanelView.sortOfflineItem);this.addEvent("openprivate",new Gilean.observer.Event("onOpenPrivate"));this.addEvent("deleteuser",new Gilean.observer.Event("onDeleteUser"))}ContactPanelView.prototype=new Gilean.mvc.View;ContactPanelView.sortOnlineItem=function(B,A){if(B.link.innerHTML<A.link.innerHTML){return 1}else{if(A.link.innerHTML<B.link.innerHTML){return -1}else{return 0}}};ContactPanelView.sortOfflineItem=function(B,A){if(B.displayNameSpan.innerHTML<A.displayNameSpan.innerHTML){return 1}else{if(A.displayNameSpan.innerHTML<B.displayNameSpan.innerHTML){return -1}else{return 0}}};ContactPanelView.prototype.render=function(){return this._mainDiv};ContactPanelView.prototype.show=function(){this._mainDiv.style.display="block"};ContactPanelView.prototype.hide=function(){this._mainDiv.style.display="none"};ContactPanelView.prototype.appendUser=function(J){var Q=document.getElementById("contact-column");if(!Q){this.CreatePanel();Q=document.getElementById("contact-column")}var L=document.getElementById("contact");if(!L){var L=this._onlineList.getElement();L.id="contact";L.className="contact-list";L.users=[];var M=document.createElement("h3");M.className="contact-type-header";M.innerHTML="Online Users";var N=document.createElement("div");N.className="information";N.innerHTML="Click name to chat";Q.appendChild(M);Q.appendChild(N);Q.appendChild(L)}var K=document.getElementById("offline");if(!K){var K=this._offlineList.getElement();K.id="offline";K.className="contact-list";K.users=[];var M=document.createElement("h3");M.className="contact-type-header";M.innerHTML="Offline Users";Q.appendChild(M);Q.appendChild(K)}var O=L.users[J];if(O==null){O=document.createElement("li");L.users[J]=O;var B=document.createElement("div");var D=document.createElement("div");D.className="delete-stub";B.className="delete-stub-wrapper";B.appendChild(D);O.appendChild(B);var H=this;var A=document.createElement("a");A.href="javascript:void(0)";A.className="delete-link";A.onclick=function(){if(confirm("Are you sure you want to delete this user?")){H.notifyListeners("deleteuser",{"id":J})}return false};D.appendChild(A);var T=document.createElement("a");T.className="edit-link";T.href="javascript:void(0)";T.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createuserview.js"],function(){var U=function(){if(window.CreateUserView&&window.FormView){if(!H.createUserView){H.createUserView=new CreateUserView(H._model);H.createUserView.addRelay(H)}H.createUserView.render(m_userdb.user(J))}else{setTimeout(U,200)}};U()},null,null,true);return false};D.appendChild(T);var F=document.createElement("a");F.href="javascript:void(0);";F.className="username";F.onclick=function(){H.notifyListeners("openprivate",{"id":J});return false};var S=document.createElement("div");S.className="image-container";S.onclick=function(){H.notifyListeners("openprivate",{"id":J});return false};var I=document.createElement("img");I.width="32";I.height="32";O.image=I;if(this._model.getPrivileges().isAdmin(m_uid)){O.appendChild(B);var G=new StubTarget(O,B);G.attachTrigger("mouseover")}var C=document.createElement("div");O.subdesc=C;C.className="sub-desc";S.appendChild(I);O.appendChild(S);O.link=F;O.appendChild(F);O.appendChild(C);O.style.clear="both";var R=m_userdb.user(J);var E=R.displayName;O.link.innerHTML=E;this._onlineList.insert(O)}var P=K.users[J];if(P){this._offlineList.remove(P);K.users[J]=null}var R=m_userdb.user(J);var E=R.displayName;O.link.innerHTML=E;O.subdesc.innerHTML=R.email;O.image.src=ViewUtils.userToImageSrc(R,this._model.m_groupInfo?this._model.m_groupInfo.accountid:null,this._model.m_hostname?this._model.m_hostname:null)};ContactPanelView.prototype.removeUser=function(J){var Q=document.getElementById("contact-column");if(!Q){this.CreatePanel();Q=document.getElementById("contact-column")}var M=document.getElementById("contact");if(!M){var M=this._onlineList.getElement();M.id="contact";M.className="contact-list";M.users=[];var N=document.createElement("h3");N.className="contact-type-header";N.innerHTML="Online Users";var O=document.createElement("div");O.className="information";O.innerHTML="Click name to chat";Q.appendChild(N);Q.appendChild(O);Q.appendChild(M)}var L=document.getElementById("offline");if(!L){var L=this._offlineList.getElement();L.id="offline";L.className="contact-list";L.users=[];var N=document.createElement("h3");N.className="contact-type-header";N.innerHTML="Offline Users";Q.appendChild(N);Q.appendChild(L)}var R=m_userdb.user(J);if(R){var P=L.users[J];if(P==null){P=document.createElement("li");L.users[J]=P;var B=document.createElement("div");var D=document.createElement("div");D.className="delete-stub";B.className="delete-stub-wrapper";B.appendChild(D);var H=this;var A=document.createElement("a");A.className="delete-link";A.href="javascript:void(0)";A.onclick=function(){if(confirm("Are you sure you want to delete this user?")){H.notifyListeners("deleteuser",{"id":J})}return false};D.appendChild(A);var S=document.createElement("a");S.className="edit-link";S.href="javascript:void(0)";S.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createuserview.js"],function(){var T=function(){if(window.CreateUserView&&window.FormView){if(!H.createUserView){H.createUserView=new CreateUserView(H._model);H.createUserView.addRelay(H)}H.createUserView.render(m_userdb.user(J))}else{setTimeout(T,200)}};T()},null,null,true);return false};D.appendChild(S);var K=document.createElement("span");P.displayNameSpan=K;if(this._model.getPrivileges().isAdmin(m_uid)){P.appendChild(B);var G=new StubTarget(K,B);G.attachTrigger("mouseover")}P.appendChild(K);var C=M.users[J];if(C){this._onlineList.remove(C);M.users[J]=null}var E=R.displayName;var I=R.image;var F="";P.displayNameSpan.innerHTML=E;this._offlineList.insert(P)}var C=M.users[J];if(C){this._onlineList.remove(C);M.users[J]=null}var E=R.displayName;var I=R.image;var F="";P.displayNameSpan.innerHTML=E}else{var P=L.users[J];if(P){this._offlineList.remove(P);L.users[J]=null}}};ContactPanelView.prototype.CreatePanel=function(){var A=this;var B=document.createElement("div");B.id="add-user";B.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createuserview.js"],function(){var D=function(){if(window.CreateUserView&&window.FormView){if(!A.createUserView){A.createUserView=new CreateUserView(A._model);A.createUserView.addRelay(A)}A.createUserView.render()}else{setTimeout(D,200)}};D()},null,null,true);return false};var C=document.createElement("div");C.id="contact-column";if(this._model.getPrivileges().isAdmin(m_uid)){this._mainDiv.appendChild(B)}this._mainDiv.appendChild(C)};ContactPanelView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._mainDiv.innerHTML="";this._onlineList.empty();this._offlineList.empty()}};ContactPanelView.prototype.onUpdateUser=function(A){if(m_userdb.user(A["id"]).isSignedOn()){this.appendUser(A["id"])}else{this.removeUser(A["id"])}};ContactPanelView.prototype.onAddUser=function(A){if(m_userdb.user(A["id"])&&m_userdb.user(A["id"]).isSignedOn()){this.appendUser(A["id"])}else{this.removeUser(A["id"])}};function DepartmentsView(A){this.__base=Gilean.mvc.View;this.__base(A);this._mainDiv=document.createElement("div");this.addEvent("deletedepartment",new Gilean.observer.Event("onDeleteDepartment"));this.addEvent("changeaccesscode",new Gilean.observer.Event("onChangeAccessCode"))}DepartmentsView.prototype=new Gilean.mvc.View;DepartmentsView.prototype.render=function(){return this._mainDiv};DepartmentsView.prototype.show=function(){this._mainDiv.style.display="block"};DepartmentsView.prototype.hide=function(){this._mainDiv.style.display="none"};DepartmentsView.prototype.appendDepartment=function(B){var K=m_deptdb.departments[B];var Q=this.addOrGetList();if(!Q){return }var H=K.name;var D=Q.depts[B];var F;var A;var L;if(!D){var O=document.createElement("li");var N=document.createElement("div");var I=document.createElement("div");I.className="delete-stub";N.className="delete-stub-wrapper";N.appendChild(I);O.appendChild(N);var E=this;F=document.createElement("a");F.href="javascript:void(0);";A=document.createElement("a");A.href="javascript:void(0);";A.style.fontSize="70%";var G=document.createElement("div");var J=document.createElement("div");J.className="second-line";O.appendChild(G);O.appendChild(J);G.appendChild(F);O.link=F;L=document.createElement("span");L.style.color="gray";L.style.fontSize="70%";liveSpacer=document.createTextNode(" ");liveInfo=document.createElement("span");liveInfo.style.color="gray";liveInfo.style.fontSize="70%";liveInfo.innerHTML=' Livechat <a target="_blank" href="/features/livechat/#3-steps">[?]</a> ';O.liveDesc=L;O.liveToggle=A;J.appendChild(A);J.appendChild(liveSpacer);J.appendChild(liveInfo);J.appendChild(L);var P=document.createElement("a");P.className="delete-link";P.href="javascript:void(0)";P.onclick=function(){if(confirm("Are you sure you want to delete this department?")){E.notifyListeners("deletedepartment",{"id":B})}return false};I.appendChild(P);var C=document.createElement("a");C.className="edit-link";C.href="javascript:void(0)";C.onclick=F.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createdepartmentview.js"],function(){var R=function(){if(window.CreateDepartmentView&&window.FormView){if(!E.createDepartmentView){E.createDepartmentView=new CreateDepartmentView(E._model);E.createDepartmentView.addRelay(E)}E.createDepartmentView.render(m_deptdb.department(B))}else{setTimeout(R,200)}};R()},null,null,true);return false};I.appendChild(C);var M=new StubTarget(F,N);M.attachTrigger("mouseover");A.onclick=function(){var R=1;if(K.accessCode){R=0}E.notifyListeners("changeaccesscode",{"type":1,"id":B,"op":R,"accesscode":null});return false}}else{O=D;F=O.link;L=O.liveDesc;A=O.liveToggle}F.innerHTML=H;if(K.accessCode){A.innerHTML="Turn off";L.innerHTML=' - This department is live at: <a href="'+K.accessCode+'" target="_blank">'+K.accessCode+"</a>"}else{A.innerHTML="Turn on";L.innerHTML=""}Q.depts[B]=O;if(!D){Q.appendChild(O)}};DepartmentsView.prototype.removeDepartment=function(D){var C=m_deptdb.departments[D];var A=this.addOrGetList();var B=A.depts[D];if(B){A.removeChild(B);A.depts[D]=null}};DepartmentsView.prototype.CreatePanel=function(){var B=this;var H=document.createElement("h2");H.className="column-header";H.innerHTML="Departments";var E=document.createElement("div");E.className="information";E.innerHTML="You have admin privileges which allow you to create and edit group departments";var A=document.createElement("div");A.id="department-column";A.className="item-column";var F="departmentlist";var D=document.createElement("ul");D.id=F;D.className="department-list";D.depts=[];var C=document.createElement("div");C.className="chatroom-type-action";var G=document.createElement("a");G.innerHTML="Add Department";G.href="javascript:void(0)";G.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createdepartmentview.js"],function(){var I=function(){if(window.CreateDepartmentView&&window.FormView){if(!B.createDepartmentView){B.createDepartmentView=new CreateDepartmentView(B._model);B.createDepartmentView.addRelay(B)}B.createDepartmentView.render()}else{setTimeout(I,200)}};I()},null,null,true);return false};C.appendChild(G);A.appendChild(D);A.appendChild(C);this._mainDiv.appendChild(H);this._mainDiv.appendChild(E);this._mainDiv.appendChild(A);this._mainDiv.departmentcolumn=A};DepartmentsView.prototype.addOrGetList=function(){var C="departmentlist";var A=this._mainDiv.departmentcolumn;if(!A){this.CreatePanel();A=this._mainDiv.departmentcolumn}var B=document.getElementById(C);return B};DepartmentsView.prototype.onUpdateDepartment=function(A){this.appendDepartment(A["id"])};DepartmentsView.prototype.onRemoveDepartment=function(A){this.removeDepartment(A["id"])};DepartmentsView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._mainDiv.innerHTML=""}};function FilePostView(A){Gilean.mvc.View.call(this,A);this.aflax=sock_Aflax;this.swfupload=null;this._mainDiv=document.createElement("div");this._statusDiv=document.createElement("div");this._statusMsg=document.createElement("div");this._selectionDiv=null;this._filename="";this._postDiv=null;this.addEvent("uploadfile",new Gilean.observer.Event("onUploadFile"))}FilePostView.prototype=new Gilean.mvc.View;FilePostView.ownerType={PUBLIC:1,PRIVATE:7,WORKGROUP:3,DEPARTMENT:9,RECEIVED:5};FilePostView.prototype.render=function(){return this._mainDiv};FilePostView.prototype.show=function(){this._mainDiv.style.display="block"};FilePostView.prototype.hide=function(){this._mainDiv.style.display="none"};FilePostView.prototype.CreatePanel=function(){var B=document.createElement("div");B.className="create-post";B.style.position="relative";this.fileReady=false;var A=this;LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js"],function(){var E=function(){var J="add a description...";if(window.FormView){A._postForm=new FormView("create-post-form","create-post-form-file",function(){Logger.debug("ready?");if(A.fileReady){var N=A._postForm.getForm();A.fileDescription=getElementByName("description",N,"textarea").value;A.fileOwnerType=getElementByName("owner-type",N,"select").value;A.fileOwner=getElementByName("owner",N,"select").value;if(A.fileDescription==J){A.fileDescription=""}getElementByName("description",N,"textarea").value=J;var M=ViewUtils.fileToUploadURL(A.fileOwnerType,A.fileOwner,A._model.m_groupInfo?A._model.m_groupInfo.accountid:null,m_uid,"",A._model.m_hostname?A._model.m_hostname:null);Logger.debug(M);var O=getElementDims(A._mainDiv);A._statusDiv.style.width=O[0]+"px";A._statusDiv.style.height=O[1]+"px";A._statusDiv.style.display="";A.swfupload.setUploadURL(M);A.swfupload.startUpload();return false}else{alert("Select a file to upload first");return false}},function(){return false});var I=A._postForm.render();var L=ViewUtils.newEl(document,"h3","create-post-header-file","create-post-header");L.innerHTML="Upload a file to your group";I.appendChild(L);A._statusMsg=ViewUtils.newEl(document,"small",null,"no-msg");A._statusMsg.innerHTML="";I.appendChild(A._statusMsg);I.appendChild(A._postForm._generateNewFieldWithWrapper("filename","",null,false,""));var K=document.createElement("div");K.style.position="relative";var G=document.createElement("input");G.type="button";G.value="Choose File...";document.body.appendChild(G);buttonWidth=getElementWidth(G);buttonHeight=getElementHeight(G);var F=document.createElement("div");F.id="choose-file-button";K.appendChild(G);K.appendChild(F);I.appendChild(K);I.appendChild(A._postForm._generateNewTextAreaWithWrapper("description","",null,true,J,true));A._selectionDiv=document.createElement("div");var H=A.ownerSelection();H.appendChild(A._postForm._submitButton("Post"));A._selectionDiv.appendChild(H);I.appendChild(A._selectionDiv);B.appendChild(I);A.fileNameField=getElementByName("filename",I,"input");A.fileNameField.disabled=true;if(A.swfupload){A.swfupload.destroy()}setTimeout(function(){A.swfupload=new SWFUpload({flash_url:"/swfupload.swf",file_types:"*.*",file_types_description:"All files (*.*)",file_size_limit:"2 MB",file_queue_limit:1,button_placeholder_id:"choose-file-button",button_cursor:SWFUpload.CURSOR.HAND,button_width:buttonWidth,button_height:buttonHeight,button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,file_queued_handler:function(M){A.fileNameField.value=M.name;A.fileReady=true;A._statusMsg.className="no-msg";A._statusMsg.innerHTML=""},upload_progress_handler:function(N,M,O){A._statusDivInformation.innerHTML="Upload Progress: "+Math.round((M/O*100))+"% completed"},upload_error_handler:function(N,M,O){A._statusDiv.style.display="none";A._statusMsg.className="error-msg";if(M==SWFUpload.UPLOAD_ERROR.FILE_CANCELLED){A._statusMsg.innerHTML="Upload Cancelled"}else{A._statusMsg.innerHTML="Upload Error: "+O}},upload_success_handler:function(M){A._filename=M.name;A._statusDivInformation.innerHTML="Confirming upload... ";A.notifyListeners("uploadfile",{"fileowner":A.fileOwner,"fileownertype":A.fileOwnerType,"compression":false,"filesize":M.size,"filename-stored":"temp-"+m_uid+"-"+M.name,"filename-target":M.name,"description":A.fileDescription})}})},0)}else{setTimeout(E,200)}};E()},null,null,true);this._statusDiv=ViewUtils.newEl(document,"div",null,"create-post-cover");this._statusDiv.style.position="absolute";this._statusDiv.style.zIndex="1";this._statusDiv.style.background="white";this._statusDiv.style.height="100%";this._statusDiv.style.width="100%";this._statusDiv.style.left="0";this._statusDiv.style.top="0";this._statusDiv.style.display="none";var D=ViewUtils.newEl(document,"div",null,"create-post-cover-inner");this._statusDiv.appendChild(D);this._statusDivInformation=ViewUtils.newEl(document,"span",null,"create-post-cover-information");D.appendChild(this._statusDivInformation);var C=document.createElement("input");C.type="button";C.value="Cancel";C.onclick=function(){if(this.swfupload){this.swfupload.stopUpload()}};D.appendChild(C);B.appendChild(this._statusDiv);this._mainDiv.appendChild(B)};FilePostView.prototype.ownerSelection=function(){var F=document.createElement("div");var D=document.createElement("select");D.name="owner-type";D.size=1;F.appendChild(D);var A=document.createElement("select");A.name="owner";A.size=1;F.appendChild(A);var B=0;D.options[B++]=new Option("Public",FilePostView.ownerType.PUBLIC);D.options[B++]=new Option("My Files",FilePostView.ownerType.PRIVATE);var E=(this._model.getPrivileges().isAdmin(m_uid))?m_deptdb.getDepartments():m_deptdb.getUserDepartments(m_uid);if(E.length>0){D.options[B++]=new Option("Department",FilePostView.ownerType.DEPARTMENT)}var C=(this._model.getPrivileges().isAdmin(m_uid))?m_wkgpdb.getDepartments():m_wkgpdb.getUserDepartments(m_uid);if(C.length>0){D.options[B++]=new Option("Workgroup",FilePostView.ownerType.WORKGROUP)}D.onchange=function(){var H=0;var G=D.value;if(G==FilePostView.ownerType.PUBLIC){A.style.display="none";while(A.firstChild){A.removeChild(A.firstChild)}A.options[0]=new Option("",0)}else{if(G==FilePostView.ownerType.PRIVATE){A.style.display="none";while(A.firstChild){A.removeChild(A.firstChild)}A.options[0]=new Option("",m_uid)}else{if(G==FilePostView.ownerType.WORKGROUP){while(A.firstChild){A.removeChild(A.firstChild)}for(var I=0;I<C.length;I++){A.options[H++]=new Option(C[I].name,C[I].deptid)}A.style.display=""}else{if(G==FilePostView.ownerType.DEPARTMENT){while(A.firstChild){A.removeChild(A.firstChild)}for(var I=0;I<E.length;I++){A.options[H++]=new Option(E[I].name,E[I].deptid)}A.style.display=""}}}}};A.style.display="none";A.options[0]=new Option("",0);return F};FilePostView.prototype.onUpdateDepartment=function(A){if(this.selectionDiv){this.selectionDiv.innerHTML="";var B=this.ownerSelection();B.appendChild(this._postForm._submitButton("Post"));this._selectionDiv.appendChild(B)}};FilePostView.prototype.onRemoveDepartment=function(A){if(this.selectionDiv){this.selectionDiv.innerHTML="";var B=this.ownerSelection();B.appendChild(this._postForm._submitButton("Post"));this._selectionDiv.appendChild(B)}};FilePostView.prototype.onUpdateWorkgroup=function(A){if(this.selectionDiv){this.selectionDiv.innerHTML="";var B=this.ownerSelection();B.appendChild(this._postForm._submitButton("Post"));this._selectionDiv.appendChild(B)}};FilePostView.prototype.onRemoveWorkgroup=function(A){if(this.selectionDiv){this.selectionDiv.innerHTML="";var B=this.ownerSelection();B.appendChild(this._postForm._submitButton("Post"));this._selectionDiv.appendChild(B)}};FilePostView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._streamSegments=[];this._mainDiv.innerHTML=""}};FilePostView.prototype.onUploadVerify=function(B){var C=B["success"];var A=B["errorcode"];this._statusDiv.style.display="none";if(C==1){this._statusMsg.className="success-msg";this._statusMsg.innerHTML=this._filename+" uploaded successfully"}else{this._statusMsg.className="error-msg";if(A==1){this._statusMsg.innerHTML=this._filename+" is too large."}else{if(A==2){this._statusMsg.innerHTML="Your group has reached its disk-space quota"}else{this._statusMsg.innerHTML="Unknown error. Please try again later."}}}this._filename="";this.fileNameField.value=""};function FileView(A){this.__base=Gilean.mvc.View;this.__base(A);this._mainDiv=document.createElement("div");this._firstCreation=true;this.sections=[];this.addEvent("requestfiles",new Gilean.observer.Event("onRequestFiles"));this.addEvent("deletefile",new Gilean.observer.Event("onDeleteFile"))}FileView.prototype=new Gilean.mvc.View;FileView.sortOnlineItem=function(B,A){if(B.filename.innerHTML<A.filename.innerHTML){return 1}else{if(A.filename.innerHTML<B.filename.innerHTML){return -1}else{return 0}}};FileView.ownerType={PUBLIC:1,PRIVATE:7,WORKGROUP:3,DEPARTMENT:9,RECEIVED:5};FileView.prototype.render=function(){return this._mainDiv};FileView.prototype.show=function(){this._mainDiv.style.display="block"};FileView.prototype.hide=function(){this._mainDiv.style.display="none"};FileView.prototype.CreatePanel=function(){var B=this;var E=ViewUtils.newEl(document,"h3",null,"chatroom-type-header");E.innerHTML="Group Files";var C=ViewUtils.newEl(document,"div","file-column","item-column");this.tabControl=new JSTabControl;var A=this.tabControl.create();var D=document.createElement("div");D.appendChild(this.CreateSelectionPanel());this.selectionDiv=D;this._mainDiv.appendChild(C);C.appendChild(E);C.appendChild(D);C.appendChild(A)};FileView.prototype.CreateSelectionPanel=function(){var B=document.createElement("div");B.className="file-folder-selection";var A=this;LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js"],function(){var C=function(){var G="http://";var H="add a description...";if(window.FormView){var D=new FormView("create-post-form","create-post-form",function(){return false},function(){return false});var F=D.render();var E=A.selectionOwnerSelection();F.appendChild(E);B.appendChild(F)}else{setTimeout(C,200)}};C()},null,null,true);return B};FileView.prototype.selectionOwnerSelection=function(){var H=document.createElement("div");var D=document.createElement("label");D.innerHTML="Select file type: ";H.appendChild(D);var F=document.createElement("select");F.name="owner-type";F.size=1;H.appendChild(F);var B=document.createElement("select");B.name="owner";B.size=1;H.appendChild(B);var C=0;F.options[C++]=new Option("Public Files",FileView.ownerType.PUBLIC);F.options[C++]=new Option("My Files",FileView.ownerType.PRIVATE);F.options[C++]=new Option("My Received Files",FileView.ownerType.RECEIVED);var G=(this._model.getPrivileges().isAdmin(m_uid))?m_deptdb.getDepartments():m_deptdb.getUserDepartments(m_uid);if(G.length>0){F.options[C++]=new Option("Department",FileView.ownerType.DEPARTMENT)}var E=(this._model.getPrivileges().isAdmin(m_uid))?m_wkgpdb.getDepartments():m_wkgpdb.getUserDepartments(m_uid);if(E.length>0){F.options[C++]=new Option("Workgroup",FileView.ownerType.WORKGROUP)}var A=this;F.onchange=function(){var J=0;var I=F.value;if(I==FileView.ownerType.PUBLIC){B.style.display="none";while(B.firstChild){B.removeChild(B.firstChild)}B.options[0]=new Option("",0);A.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.PUBLIC,"owner":null});A.tabControl.setSelectedIndex(A.addOrGetSection(FileView.ownerType.PUBLIC))}else{if(I==FileView.ownerType.PRIVATE){B.style.display="none";while(B.firstChild){B.removeChild(B.firstChild)}B.options[0]=new Option("",m_uid);A.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.PRIVATE,"owner":m_uid});A.tabControl.setSelectedIndex(A.addOrGetSection(FileView.ownerType.PRIVATE))}else{if(I==FileView.ownerType.RECEIVED){B.style.display="none";while(B.firstChild){B.removeChild(B.firstChild)}B.options[0]=new Option("",m_uid);A.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.RECEIVED,"owner":m_uid});A.tabControl.setSelectedIndex(A.addOrGetSection(FileView.ownerType.RECEIVED))}else{if(I==FileView.ownerType.WORKGROUP){while(B.firstChild){B.removeChild(B.firstChild)}for(var K=0;K<E.length;K++){B.options[J++]=new Option(E[K].name,E[K].deptid)}B.style.display="";B.onchange=function(){A.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.WORKGROUP,"owner":B.value});A.tabControl.setSelectedIndex(A.addOrGetSection(FileView.ownerType.WORKGROUP,B.value))};A.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.WORKGROUP,"owner":B.value});A.tabControl.setSelectedIndex(A.addOrGetSection(FileView.ownerType.WORKGROUP,B.value))}else{if(I==FileView.ownerType.DEPARTMENT){while(B.firstChild){B.removeChild(B.firstChild)}for(var K=0;K<G.length;K++){B.options[J++]=new Option(G[K].name,G[K].deptid)}B.style.display="";B.onchange=function(){A.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.DEPARTMENT,"owner":B.value});A.tabControl.setSelectedIndex(A.addOrGetSection(FileView.ownerType.DEPARTMENT,B.value))};A.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.DEPARTMENT,"owner":B.value});A.tabControl.setSelectedIndex(A.addOrGetSection(FileView.ownerType.DEPARTMENT,B.value))}}}}}};B.style.display="none";B.options[0]=new Option("",0);if(this._firstCreation){Logger.debug("Send: ownerSelection");this.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.PUBLIC,"owner":null});this.tabControl.setSelectedIndex(this.addOrGetSection(FileView.ownerType.PUBLIC));this._firstCreation=false}return H};FileView.prototype.addOrGetSection=function(C,A){if(C==FileView.ownerType.PUBLIC||C==FileView.ownerType.PRIVATE||C==FileView.ownerType.RECEIVED){if(this.sections[C]==null){var B=this.tabControl.addTab("");this.sections[C]=B}return this.sections[C]}else{if(this.sections[C]==null){this.sections[C]=[]}if(!this.sections[C][A]){var B=this.tabControl.addTab("");this.sections[C][A]=B}return this.sections[C][A]}};FileView.prototype.removeSection=function(B,A){if(B==FileView.ownerType.PUBLIC||B==FileView.ownerType.PRIVATE||B==FileView.ownerType.RECEIVED){if(this.sections[B]){this.tabControl.removeTab(this.sections[B]);this.sections[B]=null;delete this.sections[B]}}else{if(this.sections[B]&&this.sections[B][A]){this.tabControl.removeTab(this.sections[B][A]);this.sections[B][A]=null;delete this.sections[B][A]}}};FileView.prototype.onAddFile=function(E){var J=E["ownerType"];var A=E["owner"];var R=E["filename"];var L=E["filelength"];var C=E["userid"];var G=E["username"];var N=E["uploadtime"];var S=E["description"];var M=this.addOrGetSection(J,A);var Q=this.tabControl.getContent(M);if(!Q.filelist){Q.filelist=new SortedList(FileView.sortOnlineItem);var D=Q.filelist.getElement();D.className="file-list";Q.appendChild(D)}if(!Q.file){Q.file=[]}var T=Q.file[R];if(T==null){T=ViewUtils.newEl(document,"li",null,"file");filenameDiv=ViewUtils.newEl(document,"div",null,"filename");var F=document.createElement("div");var I=document.createElement("div");I.className="delete-stub";F.className="delete-stub-wrapper";F.appendChild(I);T.appendChild(F);var O=new StubTarget(T,F);O.attachTrigger("mouseover");var P=this;var B=document.createElement("a");B.href="javascript:void(0)";B.className="delete-link";B.onclick=function(){if(confirm("Are you sure you want to delete this file?")){P.notifyListeners("deletefile",{"ownertype":J,"owner":A,"filename":R})}return false};I.appendChild(B);T.appendChild(filenameDiv);T.filename=R;T.filenameDiv=filenameDiv;Q.file[R]=T;Q.filelist.insert(T)}var K="";if(L>1048576){K=L/1046576;K=K.toFixed(2)+" MB"}else{if(L>1024){K=L/1024;K=K.toFixed(2)+" KB"}else{K=L+" bytes"}}var U=new Date(N*1000);N=U.formatDate("M j, Y");S=(S?(" - "+S):"");var H=ViewUtils.fileToURL(J,A,this._model.m_groupInfo?this._model.m_groupInfo.accountid:null,R,this._model.m_hostname?this._model.m_hostname:null);T.filenameDiv.innerHTML='<a href="'+H+'" target="_blank">'+R+'</a>  <span style="font-size: 80%; color: gray"> - '+K+" - "+G+" ("+N+")"+S+"</small>"};FileView.prototype.onRemoveFile=function(D){var H=D["ownerType"];var A=D["owner"];var B=D["filename"];var C=this.addOrGetSection(H,A);var G=this.tabControl.getContent(C);if(!G.filelist){G.filelist=new SortedList(FileView.sortOnlineItem);var E=G.filelist.getElement();E.className="file-list";G.appendChild(E)}if(!G.file){G.file=[]}var F=G.file[B];if(F){G.file[B]=null;delete G.file[B];G.filelist.remove(F)}};FileView.prototype.onUpdateDepartment=function(A){this.addOrGetSection(FileView.ownerType.DEPARTMENT,A["id"]);if(this.selectionDiv){this.selectionDiv.innerHTML="";this.selectionDiv.appendChild(this.CreateSelectionPanel())}};FileView.prototype.onRemoveDepartment=function(A){this.removeSection(FileView.ownerType.DEPARTMENT,A["id"]);if(this.selectionDiv){this.selectionDiv.innerHTML="";this.selectionDiv.appendChild(this.CreateSelectionPanel())}};FileView.prototype.onUpdateWorkgroup=function(A){this.addOrGetSection(FileView.ownerType.WORKGROUP,A["id"]);if(this.selectionDiv){this.selectionDiv.innerHTML="";this.selectionDiv.appendChild(this.CreateSelectionPanel())}};FileView.prototype.onRemoveWorkgroup=function(A){this.removeSection(FileView.ownerType.WORKGROUP,A["id"]);if(this.selectionDiv){this.selectionDiv.innerHTML="";this.selectionDiv.appendChild(this.CreateSelectionPanel())}};FileView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel();Logger.debug("Send: onSigninStatus");this.notifyListeners("requestfiles",{"ownertype":FileView.ownerType.PUBLIC,"owner":null});this.tabControl.setSelectedIndex(this.addOrGetSection(FileView.ownerType.PUBLIC))}else{this._firstCreation=true;this.tabControl=null;this._mainDiv.innerHTML="";this.sections=[]}};function LinkView(A){this.__base=Gilean.mvc.View;this.__base(A);this.addEvent("createlink",new Gilean.observer.Event("onCreateLink"));this.addEvent("deletelink",new Gilean.observer.Event("onDeleteLink"));this._mainDiv=document.createElement("div")}LinkView.prototype=new Gilean.mvc.View;LinkView.ownerType={PUBLIC:0,PRIVATE:1,WORKGROUP:2,DEPARTMENT:3};LinkView.prototype.render=function(){return this._mainDiv};LinkView.prototype.show=function(){this._mainDiv.style.display="block"};LinkView.prototype.hide=function(){this._mainDiv.style.display="none"};LinkView.prototype.appendLink=function(M){var R=m_linkdb.links[M];var B=R.owner;var H=R.ownerType;var F=R.url;var A=this.addOrGetSection(B,H);var G=R.title;var J=A.links[M];var I;var O;var N;if(!J){var Q=document.createElement("li");var D=document.createElement("div");var E=document.createElement("div");E.className="delete-stub";D.className="delete-stub-wrapper";D.appendChild(E);Q.appendChild(D);var L=this;I=document.createElement("a");I.href=F;I.target="_blank";Q.appendChild(I);Q.link=I;var P=document.createElement("span");P.innerHTML=" ";Q.appendChild(P);O=document.createElement("span");O.style.color="silver";Q.appendChild(O);Q.span=O;N=document.createElement("span");N.style.color="gray";N.style.fontSize="80%";Q.appendChild(N);Q.description=N;var C=document.createElement("a");C.className="delete-link";C.href="javascript:void(0)";C.onclick=function(){if(confirm("Are you sure you want to delete this shared link?")){L.notifyListeners("deletelink",{"id":M})}return false};E.appendChild(C);var K=new StubTarget(I,D);K.attachTrigger("mouseover")}else{Q=J;I=Q.link;O=Q.span;N=Q.description}I.innerHTML=G;if(R.description){N.innerHTML=" - "+R.description}A.links[M]=Q;if(!J){A.appendChild(Q)}};LinkView.prototype.removeLink=function(F){var D=m_linkdb.links[F];if(D){var A=D.owner;var E=D.ownerType;var B=this.addOrGetSection(A,E);var C=B.links[F];if(C){B.removeChild(C);B.links[F]=null}if(!B.firstChild){this.removeSection(A,E)}}};LinkView.prototype.CreatePanel=function(){var A=this;var D=document.createElement("h2");D.className="column-header";D.innerHTML="Shared Links";var B=document.createElement("div");B.appendChild(this.CreatePostPanel());this.postDiv=B;var C=document.createElement("div");C.id="link-column";C.className="item-column";this._mainDiv.appendChild(B);this._mainDiv.appendChild(C)};LinkView.prototype.CreatePostPanel=function(){var B=document.createElement("div");B.className="create-post";var A=this;LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js"],function(){var C=function(){var G="http://";var H="add a description...";if(window.FormView){var D=new FormView("create-post-form","create-post-form",function(){var N=D.getForm();var K=getElementByName("url",N,"input").value;var M=getElementByName("description",N,"textarea").value;var O=getElementByName("owner-type",N,"select").value;var J=getElementByName("owner",N,"select").value;if(M==H){M=""}var L=new Link();L.sponsor=m_uid;L.title=K;L.url=K;L.owner=J;L.ownerType=O;L.description=M;A.notifyListeners("createlink",{"link":L});getElementByName("url",N,"input").value=G;getElementByName("description",N,"textarea").value=H;return false},function(){return false});var F=D.render();var I=ViewUtils.newEl(document,"h3","create-post-header-link","create-post-header");I.innerHTML="Share a link with your group";F.appendChild(I);F.appendChild(D._generateNewFieldWithWrapper("url","",null,true,G));F.appendChild(D._generateNewTextAreaWithWrapper("description","",null,true,H,true));var E=A.ownerSelection();E.appendChild(D._submitButton("Post"));F.appendChild(E);B.appendChild(F)}else{setTimeout(C,200)}};C()},null,null,true);return B};LinkView.prototype.ownerSelection=function(){var F=document.createElement("div");var D=document.createElement("select");D.name="owner-type";D.size=1;F.appendChild(D);var A=document.createElement("select");A.name="owner";A.size=1;F.appendChild(A);var B=0;D.options[B++]=new Option("Public",LinkView.ownerType.PUBLIC);D.options[B++]=new Option("Private",LinkView.ownerType.PRIVATE);var E=(this._model.getPrivileges().isAdmin(m_uid))?m_deptdb.getDepartments():m_deptdb.getUserDepartments(m_uid);if(E.length>0){D.options[B++]=new Option("Department",LinkView.ownerType.DEPARTMENT)}var C=(this._model.getPrivileges().isAdmin(m_uid))?m_wkgpdb.getDepartments():m_wkgpdb.getUserDepartments(m_uid);if(C.length>0){D.options[B++]=new Option("Workgroup",LinkView.ownerType.WORKGROUP)}D.onchange=function(){var H=0;var G=D.value;if(G==LinkView.ownerType.PUBLIC){A.style.display="none";while(A.firstChild){A.removeChild(A.firstChild)}A.options[0]=new Option("",0)}else{if(G==LinkView.ownerType.PRIVATE){A.style.display="none";while(A.firstChild){A.removeChild(A.firstChild)}A.options[0]=new Option("",m_uid)}else{if(G==LinkView.ownerType.WORKGROUP){while(A.firstChild){A.removeChild(A.firstChild)}for(var I=0;I<C.length;I++){A.options[H++]=new Option(C[I].name,C[I].deptid)}A.style.display=""}else{if(G==LinkView.ownerType.DEPARTMENT){while(A.firstChild){A.removeChild(A.firstChild)}for(var I=0;I<E.length;I++){A.options[H++]=new Option(E[I].name,E[I].deptid)}A.style.display=""}}}}};A.style.display="none";A.options[0]=new Option("",0);return F};LinkView.prototype.addOrGetSection=function(A,F){var D="linklist";var H="Public Links";if(F==3){D+="-3-"+A;H=m_deptdb.departments[A].name}else{if(F==2){D+="-2-"+A;H=m_wkgpdb.departments[A].name}else{if(F==1){D+="-1";H="Private Links"}}}var E=document.getElementById("link-column");if(!E){this.CreatePanel();E=document.getElementById("link-column")}var C=document.getElementById(D);if(!C){var C=document.createElement("ul");C.id=D;C.className="chatroom-list";C.links=[];var G=document.createElement("h3");G.className="chatroom-type-header";G.id=D+"-header";G.innerHTML=H;var B=this;E.appendChild(G);E.appendChild(C)}return C};LinkView.prototype.removeSection=function(A,G){var E="linklist";if(G==3){E+="-3-"+A}else{if(G==2){E+="-2-"+A}else{if(G==1){E+="-1"}}}var F=$("link-column");var D=$(E);var C=$(E+"-header");var B=$(E+"-action");if(F&&D){F.removeChild(D)}if(F&&C){F.removeChild(C)}};LinkView.prototype.onRemoveLink=function(A){this.removeLink(A["id"])};LinkView.prototype.onUpdateLink=function(A){this.appendLink(A["id"])};LinkView.prototype.onUpdateDepartment=function(A){if(this.postDiv){this.postDiv.innerHTML="";this.postDiv.appendChild(this.CreatePostPanel())}};LinkView.prototype.onRemoveDepartment=function(A){if(this.postDiv){this.postDiv.innerHTML="";this.postDiv.appendChild(this.CreatePostPanel())}};LinkView.prototype.onUpdateWorkgroup=function(A){if(this.postDiv){this.postDiv.innerHTML="";this.postDiv.appendChild(this.CreatePostPanel())}};LinkView.prototype.onRemoveWorkgroup=function(A){if(this.postDiv){this.postDiv.innerHTML="";this.postDiv.appendChild(this.CreatePostPanel())}};LinkView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._mainDiv.innerHTML=""}};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 StreamView(A){Gilean.mvc.View.call(this,A);this._streamSegments=[];this.addEvent("addstreammsg",new Gilean.observer.Event("onAddStreamMsg"));this._mainDiv=document.createElement("div")}StreamView.prototype=new Gilean.mvc.View;StreamView.prototype.render=function(){return this._mainDiv};StreamView.prototype.show=function(){this._mainDiv.style.display="block"};StreamView.prototype.hide=function(){this._mainDiv.style.display="none"};StreamView.prototype.CreatePanel=function(){var C=ViewUtils.newEl(document,"h2",null,"column-header");C.innerHTML="Group Stream";var B=document.createElement("div");B.appendChild(this.CreatePostPanel());this.postDiv=B;this._mainDiv.appendChild(this.postDiv);if(m_uid==0){var A=document.createElement("div");A.className="information";A.innerHTML="<p><strong>As the Group Administrator, you can post to the group, but you will not receive anything.</strong></p><p>You should create a normal user account for yourself if you wish to use all the features of the group. A normal user with administrative privileges does not have these restrictions.</p>";this._mainDiv.appendChild(A)}this.log=new SortedList(function(E,D){return E.date-D.date});this.log.getElement().id="stream";this._mainDiv.appendChild(this.log.getElement())};StreamView.prototype.CreatePostPanel=function(){var B=document.createElement("div");B.className="create-post";var A=this;LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js"],function(){var C=function(){var J="post a note...";var I=240;if(window.FormView){var E=document.createElement("div");E.className="counter";E.innerHTML=I;var H=document.createElement("h3");var H=ViewUtils.newEl(document,"h3","create-post-header-msg","create-post-header");H.innerHTML="Tell Your Group Something";var D=new FormView("create-stream-msg-form","create-stream-msg-form",function(){var K=D.getForm();var L=getElementByName("msg",K,"textarea").value;if(L==J){L=""}if(L!=""){A.notifyListeners("addstreammsg",{"msg":L});getElementByName("msg",K,"textarea").value=J;E.innerHTML=I}return false},function(){return false});var F=D.render();F.appendChild(E);F.appendChild(H);F.appendChild(D._generateNewTextAreaWithWrapper("msg","",null,true,J,true));F.appendChild(D._submitButton("Post"));var G=getElementByName("msg",D.getForm(),"textarea");G.rows=3;G.onkeypress=G.onkeyup=function(){setTimeout(function(){if(G.value.length>=I){G.value=G.value.slice(0,I)}E.innerHTML=(I-G.value.length)},1)};B.appendChild(F)}else{setTimeout(C,200)}};C()},null,null,true);return B};StreamView.prototype.getOrAddSection=function(D){var B=new Date(D);if(!this._streamSegments[D]){this._streamSegments[D]=document.createElement("div");this._streamSegments[D].className="section";this._streamSegments[D].date=D;this.log.insert(this._streamSegments[D]);var F=document.createElement("div");F.className="calendar";var E=document.createElement("div");E.className="month";var A=document.createElement("div");A.className="date";E.innerHTML=B.formatDate("M");A.innerHTML=B.formatDate("d");F.appendChild(E);F.appendChild(A);var C=new SortedList((function(H,G){return H.time-G.time}));C.getElement().className="stream-contents";this._streamSegments[D].appendChild(F);this._streamSegments[D].appendChild(C.getElement());this._streamSegments[D].contents=C}return this._streamSegments[D]};StreamView.prototype.onAddStream=function(A){var C=A["type"];Logger.debug("stream type: "+C);if(C!=1&&C!=8&&C!=5&&C!=2){return }var Q=new Date(A["timestamp"]*1000);var S=Q.formatDate("h:i a");var L=new Date(Q.getYear(),Q.getMonth(),Q.getDate());var J=this.getOrAddSection(L.getTime());var O=J.contents;var T=m_userdb.user(A["userid"]);if(T||A["userid"]==0){var G=ViewUtils.newEl(document,"li",null,"stream-entry");G.time=A["timestamp"];var R=ViewUtils.newEl(document,"div",null,"stream-message");var D="";if(T){var M=ViewUtils.newEl(document,"img",null,"stream-user-image");M.src=ViewUtils.userToImageSrc(T,this._model.m_groupInfo?this._model.m_groupInfo.accountid:null,this._model.m_hostname?this._model.m_hostname:null);M.width="32";M.height="32";G.appendChild(M);D=T.displayName}else{D="Group Administrator"}G.appendChild(R);var B=ViewUtils.newEl(document,"div",null,"stream-timestamp");B.innerHTML=S;R.appendChild(B);if(C==1){var F=ViewUtils.newEl(document,"blockquote",null,"stream-quote");F.innerHTML=A["msg"];R.appendChild(F);var N=ViewUtils.newEl(document,"blockquote",null,"stream-target");N.innerHTML="Message sent by "+D;R.appendChild(N)}else{if(C==2){var F=ViewUtils.newEl(document,"blockquote",null,"stream-quote");F.innerHTML=A["msg"];R.appendChild(F);var K="";if(A["ownerType"]==LinkView.ownerType.PUBLIC){K="Public"}else{if(A["ownerType"]==LinkView.ownerType.PRIVATE){K="yourself"}else{if(A["ownerType"]==LinkView.ownerType.DEPARTMENT){var P=m_deptdb.department(A["owner"]);if(P){K="department - "+P.name}}else{if(A["ownerType"]==LinkView.ownerType.WORKGROUP){var P=m_wkgpdb.department(A["owner"]);if(P){K="workgroup - "+P.name}}}}}if(K){var N=ViewUtils.newEl(document,"blockquote",null,"stream-target");N.innerHTML="Broadcast sent to "+K+" by "+D;R.appendChild(N)}else{var N=ViewUtils.newEl(document,"blockquote",null,"stream-target");N.innerHTML="Broadcast sent by "+D;R.appendChild(N)}}else{if(C==5){var F=ViewUtils.newEl(document,"blockquote",null,"stream-file");var E=ViewUtils.fileToURL(A["ownerType"],A["owner"],this._model.m_groupInfo?this._model.m_groupInfo.accountid:null,A["msg"],this._model.m_hostname?this._model.m_hostname:null);F.innerHTML='<a href="'+E+'" target="_blank">'+A["msg"]+"</a>";R.appendChild(F);if(A["description"]){var F=ViewUtils.newEl(document,"blockquote",null,"stream-quote");F.innerHTML=A["description"];R.appendChild(F)}var K="";if(A["ownerType"]==FileView.ownerType.PUBLIC){K="Public"}else{if(A["ownerType"]==FileView.ownerType.PRIVATE){K="your files"}else{if(A["ownerType"]==FileView.ownerType.RECEIVED){K="your received files"}else{if(A["ownerType"]==FileView.ownerType.DEPARTMENT){var P=m_deptdb.department(A["owner"]);if(P){K="department - "+P.name}}else{if(A["ownerType"]==FileView.ownerType.WORKGROUP){var P=m_wkgpdb.department(A["owner"]);if(P){K="workgroup - "+P.name}}}}}}if(K){var N=ViewUtils.newEl(document,"blockquote",null,"stream-target");N.innerHTML="Uploaded to "+K+" by "+D;R.appendChild(N)}else{var N=ViewUtils.newEl(document,"blockquote",null,"stream-target");N.innerHTML="Uploaded by "+D;R.appendChild(N)}}else{if(C==8){var I=ViewUtils.newEl(document,"div",null,"stream-link");var H=ViewUtils.newEl(document,"a",null,null);H.innerHTML=A["msg"];H.href=A["msg"];H.target="_blank";I.appendChild(H);R.appendChild(I);if(A["description"]){var F=ViewUtils.newEl(document,"blockquote",null,"stream-quote");F.innerHTML=A["description"];R.appendChild(F)}var K="";if(A["ownerType"]==LinkView.ownerType.PUBLIC){K="Public"}else{if(A["ownerType"]==LinkView.ownerType.PRIVATE){K="yourself"}else{if(A["ownerType"]==LinkView.ownerType.DEPARTMENT){var P=m_deptdb.department(A["owner"]);if(P){K="department - "+P.name}}else{if(A["ownerType"]==LinkView.ownerType.WORKGROUP){var P=m_wkgpdb.department(A["owner"]);if(P){K="workgroup - "+P.name}}}}}if(K){var N=ViewUtils.newEl(document,"blockquote",null,"stream-target");N.innerHTML="Link posted to "+K+" by "+D;R.appendChild(N)}else{var N=ViewUtils.newEl(document,"blockquote",null,"stream-target");N.innerHTML="Link posted by "+D;R.appendChild(N)}}}}}O.insert(G)}};StreamView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._streamSegments=[];this._mainDiv.innerHTML=""}};function UserPanelView(A){this.__base=Gilean.mvc.View;this.__base(A);this.panelImage=null;this.image=null;this.userDisplayName=null;this.departmentDisplay=null;this.actionsSection=null;this.workgroupSection=null;this.workgroupJoiner=null;this.addEvent("createworkgroup",new Gilean.observer.Event("onCreateWorkgroup"));this._mainDiv=document.createElement("div")}UserPanelView.prototype=new Gilean.mvc.View;UserPanelView.prototype.render=function(){return this._mainDiv};UserPanelView.prototype.show=function(){this._mainDiv.style.display="block"};UserPanelView.prototype.hide=function(){this._mainDiv.style.display="none"};UserPanelView.prototype.CreatePanel=function(){this.panelImage=document.createElement("div");this.panelImage.id="user-panel-photo";this.image=document.createElement("img");this.panelImage.appendChild(this.image);this.image.src=ViewUtils.userToImageSrc(null,null);this.userDisplayName=document.createElement("div");this.userDisplayName.id="user-display-name";if(m_uid==0){this.userDisplayName.innerHTML="Group Administrator"}this.departmentDisplay=document.createElement("div");this.departmentDisplay.id="user-department-display";var A=document.createElement("div");A.className="information";if(m_uid==0){A.innerHTML="You are the group administrator. This account is considered the owner of the group. You can create other user accounts for your group."}else{if(this._model.getPrivileges().isAdmin(m_uid)){A.innerHTML="You have administrative privileges. You can create and edit users for your group as well as monitor all departments and workgroups."}}this.CreateActionsPanel();this.CreateWorkgroupPanel();this._mainDiv.appendChild(this.panelImage);this._mainDiv.appendChild(this.userDisplayName);this._mainDiv.appendChild(this.departmentDisplay);if(this._model.getPrivileges().isAdmin(m_uid)){this._mainDiv.appendChild(A)}this._mainDiv.appendChild(this.actionsSection)};UserPanelView.prototype.CreateActionsPanel=function(){this.actionsSection=document.createElement("div");this.actionsSection.className="panel-section";var A=this;if(this._model.getPrivileges().isAdmin(m_uid)){var G=document.createElement("h3");G.className="contact-type-header";G.innerHTML="My Group";var E=document.createElement("ul");var D=document.createElement("a");D.href="javascript:void(0);";D.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/createuserview.js"],function(){var H=function(){if(window.CreateUserView&&window.FormView){if(!A.createUserView){A.createUserView=new CreateUserView(A._model);A.createUserView.addRelay(A)}A.createUserView.render()}else{setTimeout(H,200)}};H()},null,null,true);return false};D.innerHTML="Add New User";var C=document.createElement("li");C.appendChild(D);E.appendChild(C);this.actionsSection.appendChild(G);this.actionsSection.appendChild(E)}var G=document.createElement("h3");G.className="contact-type-header";G.innerHTML="My Account";var E=document.createElement("ul");var F=document.createElement("a");F.href="javascript:void(0);";F.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/changephotoview.js"],function(){var H=function(){if(window.ChangePhotoView&&window.FormView){if(!A.changePhotoView){A.changePhotoView=new ChangePhotoView(A._model);A.changePhotoView.addRelay(A)}A.changePhotoView.render()}else{setTimeout(H,200)}};H()},null,null,true);return false};F.innerHTML="Change Photo";var C=document.createElement("li");C.appendChild(F);if(m_uid!=0){E.appendChild(C)}var B=document.createElement("a");B.href="javascript:void(0);";B.onclick=function(){LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js","/js/1.0.9.0/imc/view/forms/changepasswordview.js"],function(){var H=function(){if(window.ChangePasswordView&&window.FormView){if(!A.changePasswordView){A.changePasswordView=new ChangePasswordView(A._model);A.changePasswordView.addRelay(A)}A.changePasswordView.render()}else{setTimeout(H,200)}};H()},null,null,true);return false};B.innerHTML="Change Password";C=document.createElement("li");C.appendChild(B);if(this._model.getPrivileges().isPasswordChangeable()){E.appendChild(C)}this.actionsSection.appendChild(G);this.actionsSection.appendChild(E)};UserPanelView.prototype.CreateWorkgroupPanel=function(){this.workgroupSection=document.createElement("div");this.workgroupSection.className="panel-section";var B=document.createElement("h3");B.className="contact-type-header";B.innerHTML="My Workgroups";var A=document.createElement("ul");this.workgroupSection.list=A;this.workgroupSection.list.workgroups=[];this.workgroupJoiner=document.createElement("div");this.workgroupJoiner.appendChild(this.CreateWorkgroupJoiner());this.workgroupSection.appendChild(B);this.workgroupSection.appendChild(A);this.workgroupSection.appendChild(this.workgroupJoiner)};UserPanelView.prototype.CreateWorkgroupJoiner=function(){var B=document.createElement("div");var A=this;LazyLoad.loadOnce(["/js/1.0.9.0/imc/view/forms/formview.js"],function(){var C=function(){var D="http://";var J="add a description...";if(window.FormView){var E=new FormView("join-workgroup-form","join-workgroup-form",function(){var O=E.getForm();var P=getElementByName("workgroup",O,"select").value;var N=m_wkgpdb.department(P);if(N&&!m_wkgpdb.isUserOneOf(m_uid,P)){N.users.push(m_uid)}A.notifyListeners("createworkgroup",{"workgroup":N});return false},function(){return false});var K=E.render();var H=document.createElement("h3");H.className="create-post-header";H.innerHTML="Join a workgroup";K.appendChild(H);var I=m_wkgpdb.getDepartments();var M=[];for(var G=0,F=0;G<I.length;G++){if(!m_wkgpdb.isUserOneOf(m_uid,I[G].deptid)){M[F++]=new Option(I[G].name,I[G].deptid)}}var L=E._selectBox("workgroup","",M);L.appendChild(E._submitButton("Post"));K.appendChild(L);B.appendChild(K)}else{setTimeout(C,200)}};C()},null,null,true);return B};UserPanelView.prototype.displayUser=function(F){var A=m_userdb.user(F);if(A){this.image.src=ViewUtils.userToImageSrc(A,this._model.m_groupInfo?this._model.m_groupInfo.accountid:null,this._model.m_hostname?this._model.m_hostname:null);this.userDisplayName.innerHTML=A.displayName;this.departmentDisplay.innerHTML="";var E=m_deptdb.getUserDepartments(F);for(var C=0;C<E.length;C++){var D=E[C];var B=D.name;this.departmentDisplay.innerHTML+=B+"<br />"}if(E.length==0){this.departmentDisplay.innerHTML="No Department"}}};UserPanelView.prototype.appendWorkgroup=function(C){if(this.workgroupSection.list.workgroups[C]||m_wkgpdb.department(C)==null){return }var A=m_wkgpdb.department(C);var B=document.createElement("li");this.workgroupSection.list.workgroups[C]=B;B.innerHTML=A.name;this.workgroupSection.list.appendChild(B)};UserPanelView.prototype.removeWorkgroup=function(B){var A=this.workgroupSection.list.workgroups[B];if(A){this.workgroupSection.list.removeChild(A);this.workgroupSection.list.workgroups[B]=null}};UserPanelView.prototype.onSigninStatus=function(A){if(A["online"]){this.CreatePanel()}else{this._mainDiv.innerHTML=""}};UserPanelView.prototype.onUpdateUser=function(A){this.onAddUser(A)};UserPanelView.prototype.onAddUser=function(A){if(m_uid!=A["id"]){return }if(m_userdb.user(A["id"])&&m_userdb.user(A["id"]).isSignedOn()){this.displayUser(A["id"])}};UserPanelView.prototype.onUpdateDepartment=UserPanelView.prototype.onRemoveDepartment=function(A){var B=A["id"];this.displayUser(m_uid)};UserPanelView.prototype.onUpdateWorkgroup=function(A){this.workgroupJoiner.innerHTML="";this.workgroupJoiner.appendChild(this.CreateWorkgroupJoiner());var B=A["id"];if(m_wkgpdb.isUserOneOf(m_uid,B)){this.appendWorkgroup(B)}else{this.removeWorkgroup(B)}};UserPanelView.prototype.onRemoveWorkgroup=function(A){this.workgroupJoiner.innerHTML="";this.workgroupJoiner.appendChild(this.CreateWorkgroupJoiner());var B=A["id"];this.removeWorkgroup(B)};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}};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")}}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 DepartmentDB(A){this.__base=Gilean.observer.Subject;this.__base();this.departments=[];if(A==DepartmentDB.type.DEPARTMENT){this.addEvent("update",new Gilean.observer.Event("onUpdateDepartment"));this.addEvent("remove",new Gilean.observer.Event("onRemoveDepartment"))}else{this.addEvent("update",new Gilean.observer.Event("onUpdateWorkgroup"));this.addEvent("remove",new Gilean.observer.Event("onRemoveWorkgroup"))}}DepartmentDB.prototype=new Gilean.observer.Subject;DepartmentDB.type={WORKGROUP:1,DEPARTMENT:2};DepartmentDB.prototype.initialize=function(){this.departments=[]};DepartmentDB.prototype.addDepartments=function(C){for(var A=0;A<C.length;A++){var B=new Department(C[A]);this.departments[B.deptid]=B;this.notifyListeners("update",{"id":B.deptid})}};DepartmentDB.prototype.removeDepartments=function(C){for(var A=0;A<C.length;A++){var B=new Department(C[A]);this.notifyListeners("remove",{"id":B.deptid});this.departments[B.deptid]=null}};DepartmentDB.prototype.updateAccessCode=function(B,A){if(this.departments[B]){this.departments[B].accessCode=A;this.notifyListeners("update",{"id":B})}};DepartmentDB.prototype.getUserDepartment=function(A){for(var B in this.departments){if(this.isUserOneOf(A,B)){return B}}return null};DepartmentDB.prototype.getUserDepartments=function(B){var A=[];for(var C in this.departments){if(this.isUserOneOf(B,C)){A.push(this.departments[C])}}return A};DepartmentDB.prototype.isUserOneOf=function(A,C){var D=this.departments[C];if(!D||typeof (D.users)=="undefined"){return false}for(var B=0;B<D.users.length;B++){if(A==D.users[B]){return true}}return false};DepartmentDB.prototype.department=function(A){return this.departments[A]};DepartmentDB.prototype.getDepartments=function(){var A=[];for(var B in this.departments){var C=this.departments[B];if(!C||typeof (C.users)=="undefined"){continue}A.push(C)}return A};function Department(A){this.users=[];if(A){this.deptid=IMXMLParser.getRecordElement(A,"b");this.sponsor=IMXMLParser.getRecordElement(A,"c");this.name=IMXMLParser.getRecordElement(A,"d");this.accessCode=IMXMLParser.getRecordElement(A,"e");var D=A.getElementsByTagName("UL")[0];if(D){D=D.getElementsByTagName("ID");for(var B=0;B<D.length;B++){var C=D[B].childNodes[0].nodeValue;this.users.push(C)}}}}Department.prototype.addUser=function(A){for(var B=0;B<this.users.length;B++){if(this.users[B]==A){return }}this.users.push(A)};Department.prototype.removeUser=function(A){for(var B=0;B<this.users.length;B++){if(this.users[B]==A){this.users.splice(B,1)}}};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 LinkDB(){this.__base=Gilean.observer.Subject;this.__base();this.links=[];this.addEvent("update",new Gilean.observer.Event("onUpdateLink"));this.addEvent("remove",new Gilean.observer.Event("onRemoveLink"))}LinkDB.prototype=new Gilean.observer.Subject;LinkDB.prototype.initialize=function(){this.links=[]};LinkDB.prototype.addLinks=function(C){for(var A=0;A<C.length;A++){var B=new Link(C[A]);this.links[B.id]=B;this.notifyListeners("update",{"id":B.id})}};LinkDB.prototype.removeLinks=function(C){for(var A=0;A<C.length;A++){var B=new Link(C[A]);this.notifyListeners("remove",{"id":B.id});this.links[B.id]=null}};function Link(A){if(A){this.id=IMXMLParser.getRecordElement(A,"b");this.sponsor=IMXMLParser.getRecordElement(A,"c");this.title=IMXMLParser.getRecordElement(A,"d");this.owner=IMXMLParser.getRecordElement(A,"e");this.ownerType=IMXMLParser.getRecordElement(A,"f");this.url=IMXMLParser.getRecordElement(A,"g");this.description=IMXMLParser.getRecordElement(A,"h");if(this.url){if(this.url.indexOf("://")<0){this.url="http://"+this.url}}}}var m_uid=null;var m_key=null;var m_heartbeat=null;var m_heartbeatInterval=null;var model=null;var group_id="INBIT";var m_userdb=null;var m_chatdb=null;var m_deptdb=null;var m_wkgpdb=null;function AppModel(){Gilean.mvc.Model.apply(this);m_userdb=new UserDB();m_chatdb=new ChatDB();m_deptdb=new DepartmentDB(DepartmentDB.type.DEPARTMENT);m_wkgpdb=new DepartmentDB(DepartmentDB.type.WORKGROUP);m_linkdb=new LinkDB();this.m_privil=null;this.m_groupinfo=null;this.m_hostname=null;m_userdb.addRelay(this);m_chatdb.addRelay(this);m_deptdb.addRelay(this);m_wkgpdb.addRelay(this);m_linkdb.addRelay(this);this._username=null;this._password=null;this._remember=false;this._connected=false;this._reconnecting=false;this._connectedChats=[];this._receivedPrivileges=false;this._receivedUserDB=false;this._receivedChatDB=false;this._receivedDeptDB=false;this._receivedWkgpDB=false;this._receivedLinkDB=false;this._receivedGroupInfo=false;this._receivedOnlineList=false;this._receivedRoomCounts=false;this.addEvent("message",new Gilean.observer.Event("onMessage"));this.addEvent("blocked",new Gilean.observer.Event("onBlocked"));this.addEvent("private",new Gilean.observer.Event("onPrivateChat"));this.addEvent("invited",new Gilean.observer.Event("onInvited"));this.addEvent("othersinvited",new Gilean.observer.Event("onOthersInvited"));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("updatechatid",new Gilean.observer.Event("onUpdateChatId"));this.addEvent("signin",new Gilean.observer.Event("onSigninStatus"));this.addEvent("logmessage",new Gilean.observer.Event("onLogMessage"));this.addEvent("updategroupinfo",new Gilean.observer.Event("onUpdateGroupInfo"));this.addEvent("confirmcreateuser",new Gilean.observer.Event("onConfirmCreateUser"));this.addEvent("addstream",new Gilean.observer.Event("onAddStream"));this.addEvent("addfile",new Gilean.observer.Event("onAddFile"));this.addEvent("removefile",new Gilean.observer.Event("onRemoveFile"));this.addEvent("uploadfileverify",new Gilean.observer.Event("onUploadVerify"))}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};AppModel.createUserStatus={OK:1,SIGNIN_TAKEN:2,INVALID_EMAIL:3,INVALID_USERNAME:4,OVER_LIMIT:5};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.getStoredUsername=function(){return getCookie("username")};AppModel.prototype.getStoredPassword=function(){var A=getCookie("password");if(!A){return null}return IMXML.decrypt(decodeURIComponent(A),formatKey("24im"))};AppModel.prototype.setStoredUsername=function(A){setCookie("username",A,365)};AppModel.prototype.setStoredPassword=function(A){return setCookie("password",IMXML.encrypt(A,formatKey("24im")),365)};AppModel.prototype.signin=function(C,A,B){this._username=C;this._password=A;this._remember=B;if(B){this.setStoredUsername(C);this.setStoredPassword(A)}else{this.setStoredUsername("");this.setStoredPassword("")}if(C==""||A==""){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.INVALID_PASSWORD});return false}this._username=C;this._password=A;model=this;this.connectionType=AppModel.connectionType.DIRECT;this.connectionTarget=AppModel.connectionTarget.PROXY;this.connect();return true};AppModel.prototype.signout=function(){this._connected=false;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.openChatroom=function(A,C){var B=new IMXMLMessage(115);B.addElement("a",A);B.addElement("b",C);B.addElement("c",m_uid);this._socket.Send(B.toString());this.addConnectedRoom(A,C);this.notifyListeners("enterroom",{"id":C,"uid":m_uid,"type":A})};AppModel.prototype.closeChat=function(A,C){var B=new IMXMLMessage(106);B.addElement("a",A);B.addElement("b",C);B.addElement("c",m_uid);this._socket.Send(B.toString());this.removeConnectedRoom(A,C)};AppModel.prototype.declineInvite=function(A,C){var B=new IMXMLMessage(133);B.addElement("a",A);B.addElement("b",C);this._socket.Send(B.toString())};AppModel.prototype.createOrUpdateChatroom=function(B){var E=new IMXMLMessage(74);E.addElement("b",1);var D=new IMXMLRecord();var A=new IMXMLUserlist();if(B.chatid){D.addElement("b",B.chatid)}D.addElement("c",B.sponsor);D.addElement("d",B.name);D.addElement("e",B.owner);D.addElement("f",B.ownerType);D.addElement("g",B.status);D.addElement("h",B.announcement);D.addElement("i",B.description);for(var C=0;C<B.specialUsers.length;C++){A.addUserID(B.specialUsers[C])}D.addUserlist(A);E.addRecord(D);this._socket.Send(E.toString())};AppModel.prototype.deleteChatroom=function(A){var C=new IMXMLMessage(74);C.addElement("b",0);var B=new IMXMLRecord();B.addElement("b",A);C.addRecord(B);this._socket.Send(C.toString())};AppModel.prototype.createOrUpdateDepartment=function(B,E){var F=new IMXMLMessage(E==DepartmentDB.type.WORKGROUP?85:78);F.addElement("b",1);var D=new IMXMLRecord();var A=new IMXMLUserlist();if(B.deptid){D.addElement("b",B.deptid)}D.addElement("c",B.sponsor);D.addElement("d",B.name);for(var C=0;C<B.users.length;C++){A.addUserID(B.users[C])}D.addUserlist(A);F.addRecord(D);this._socket.Send(F.toString())};AppModel.prototype.deleteDepartment=function(D,B){var C=new IMXMLMessage(B==DepartmentDB.type.WORKGROUP?85:78);C.addElement("b",0);var A=new IMXMLRecord();A.addElement("b",D);C.addRecord(A);this._socket.Send(C.toString())};AppModel.prototype.createOrUpdateUser=function(A){var C=new IMXMLMessage(528);C.addElement("b",1);var B=new IMXMLRecord();if(A.userid){B.addElement("b",A.userid)}if(A.firstName!=null){B.addElement("c",A.firstName)}if(A.middleName!=null){B.addElement("d",A.middleName)}if(A.lastName!=null){B.addElement("e",A.lastName)}if(A.phoneNumber!=null){B.addElement("f",A.phoneNumber)}if(A.email!=null){B.addElement("g",A.email)}if(A.signin!=null){B.addElement("h",A.signin)}if(A.screenName!=null){B.addElement("i",A.screenName)}if(A.privileges!=null){B.addElement("l",A.privileges)}C.addRecord(B);this._socket.Send(C.toString())};AppModel.prototype.deleteUser=function(A){var C=new IMXMLMessage(528);C.addElement("b",0);var B=new IMXMLRecord();B.addElement("b",A);C.addRecord(B);this._socket.Send(C.toString())};AppModel.prototype.createOrUpdateLink=function(B){var C=new IMXMLMessage(94);C.addElement("b",1);var A=new IMXMLRecord();if(B.id){A.addElement("b",B.id)}if(B.sponsor!=null){A.addElement("c",B.sponsor)}if(B.title!=null){A.addElement("d",B.title)}if(B.owner!=null){A.addElement("e",B.owner)}if(B.ownerType!=null){A.addElement("f",B.ownerType)}if(B.url!=null){A.addElement("g",B.url)}if(B.description!=null){A.addElement("h",B.description)}C.addRecord(A);this._socket.Send(C.toString())};AppModel.prototype.deleteLink=function(B){var C=new IMXMLMessage(94);C.addElement("b",0);var A=new IMXMLRecord();A.addElement("b",B);C.addRecord(A);this._socket.Send(C.toString())};AppModel.prototype.setUserPassword=function(C,A){if(C==m_uid){if(this._remember){this.setStoredPassword(A)}}var B=new IMXMLMessage(525);B.addElement("a",C);B.addElement("b",A,m_key);this._socket.Send(B.toString())};AppModel.prototype.setRole=function(B,A){var D=new IMXMLMessage(61);D.addElement("b",1);D.addElement("c",1);var C=new IMXMLRecord();C.addElement("b",B);C.addElement("e",A);D.addRecord(C);this._socket.Send(D.toString())};AppModel.prototype.openPrivate=function(B){var A=IMXML.generateChatId(m_uid,B);this.notifyListeners("private",{"chatid":A,"uid":B})};AppModel.prototype.changePhoto=function(B){var A=new IMXMLMessage(26);A.addElement("a",B);A.addElement("b",1);this._socket.Send(A.toString())};AppModel.prototype.changeAccessCode=function(B,E,D,A){var C=new IMXMLMessage(72);C.addElement("a",E);C.addElement("b",D);if(B==0){C.addElement("c",A)}C.addElement("f",B);this._socket.Send(C.toString())};AppModel.prototype.addStreamMessage=function(B){var A=new IMXMLMessage(383);A.addElement("a",B,m_key);this._socket.Send(A.toString())};AppModel.prototype.requestFiles=function(B,A){var C=new IMXMLMessage(241);C.addElement("a",B);C.addElement("b",A);this._socket.Send(C.toString())};AppModel.prototype.uploadFile=function(D,H,A,B,C,F,E){var G=new IMXMLMessage(210);G.addElement("a",D);G.addElement("b",H);G.addElement("c",A?1:0);if(A){G.addElement("d",B)}G.addElement("e",C,m_key);G.addElement("f",F,m_key);G.addElement("g",E,m_key);this._socket.Send(G.toString())};AppModel.prototype.deleteFile=function(B,D,A){var C=new IMXMLMessage(243);C.addElement("a",B);C.addElement("b",D);C.addElement("c","800");C.addElement("d",m_uid);C.addElement("e",A,m_key);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._reconnecting=false;this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.SERVICE_NOT_AVAILABLE})}}};AppModel.prototype.onRecv=function(l){Logger.debug("[Received] "+l);var W=new IMXMLParser(l);var g=W.getId();if(!this.isReadyForMsg(g)){return }if(g==5){this._connected=false}else{if(g==6){this._socket.Send("<1>")}else{if(g==8){var E=W.getElement("a");if(E==1){var m=W.getElement("d");var a=this._password;var c=this._username;var J=m?hex_md5(a+m):a;var Q=new IMXMLMessage(11);Q.addElement("a",0);Q.addElement("b",c);Q.addElement("c",J);Q.addElement("d",group_id);this._socket.Send(Q.toString())}else{if(E===0){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.CLIENT_NO_LONGER_SUPPORTED});this.disconnect()}else{if(E==2){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.GROUP_ACCOUNT_MAINTENANCE});this.disconnect()}else{if(E==3){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.GROUP_ACCOUNT_BLOCKED});this.disconnect()}else{if(E==4){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.INVALID_GROUP});this.disconnect()}else{if(E==5){var U=W.getElement("l");var j=W.getElement("k");this.disconnect();Logger.debug("redirecting to: "+U+" : "+j);if(this.connectionType==AppModel.connectionType.DIRECT){this.connectionType=j?j:AppModel.connectionType.DIRECT_SERVER}this.connectionTarget=AppModel.connectionTarget.SERVER;this.connect(U)}else{this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.INVALID_PASSWORD});this.disconnect()}}}}}}}else{if(g==13){var E=W.getElement("a");if(E==1){m_uid=W.getElement("c");m_key=W.getElement("e");m_heartbeatInterval=W.getElement("m");var B=this._socket;m_heartbeat=setInterval(function(){B.Send("<1>")},m_heartbeatInterval*1000/2);if(m_key){Logger.debug("Encrypted Key is "+m_key);var d=formatKey(this._password);m_key=IMXML.decrypt(m_key,d);Logger.debug("Decrypted Key is "+m_key);m_key=formatKey(m_key)}var Q=null;this._connected=true;if(this._reconnecting==false){Q=new IMXMLMessage(48);this._socket.Send(Q.toString());Q=new IMXMLMessage(706);Q.addElement("b",3);var b=new IMXMLRecord();b.addElement("f",group_id);Q.addRecord(b);this._socket.Send(Q.toString());Q=new IMXMLMessage(76);this._socket.Send(Q.toString());Q=new IMXMLMessage(81);this._socket.Send(Q.toString());Q=new IMXMLMessage(51);this._socket.Send(Q.toString());Q=new IMXMLMessage(71);this._socket.Send(Q.toString());Q=new IMXMLMessage(23);this._socket.Send(Q.toString());Q=new IMXMLMessage(70);this._socket.Send(Q.toString());Q=new IMXMLMessage(91);this._socket.Send(Q.toString());Q=new IMXMLMessage(381);Q.addElement("a",0);Q.addElement("b",0);this._socket.Send(Q.toString())}else{this.reconnectToRooms()}this._reconnecting=false}else{if(E==2){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.GROUP_ACCOUNT_MAINTENANCE});this.disconnect()}else{if(E==3){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.ACCOUNT_BLOCKED});this.disconnect()}else{if(E==8){this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.OVER_LICENSE_LIMIT});this.disconnect()}else{this.notifyListeners("signin",{"online":false,"status":AppModel.loginStatus.INVALID_PASSWORD});this.disconnect()}}}}}else{if(g==14){var t=W.getElement("a");m_userdb.signon(t)}else{if(g==15){var t=W.getElement("a");m_userdb.signoff(t)}else{if(g==23){var s=W.getRecords();for(var v=0;v<s.length;v++){var t=IMXMLParser.getRecordElement(s[v],"a");m_userdb.signon(t)}this._receivedOnlineList=true}else{if(g==27){var t=W.getElement("a");var I=W.getElement("b");m_userdb.setUserImage(t,I)}else{if(g==49){this.m_privil=new Privileges(W.getElement("b"),W.getElement("c"),W.getElement("d"),W.getElement("e"),W.getElement("f"));this.notifyListeners("signin",{"online":true});this._receivedPrivileges=true}else{if(g==51){m_userdb.initialize();var s=W.getRecords();m_userdb.addUsers(s);this._receivedUserDB=true}else{if(g==53){var s=W.getRecords();var e=W.getElement("b");if(e==1){m_userdb.addUsers(s)}else{m_userdb.removeUsers(s)}}else{if(g==70){var s=W.getRecords();for(var v=0;v<s.length;v++){var h=IMXMLParser.getRecordElement(s[v],"a");var q=IMXMLParser.getRecordElement(s[v],"b");m_chatdb.updateRoomUserCount(h,q)}this._receivedRoomCounts=true}else{if(g==71){m_chatdb.initialize();var s=W.getRecords();m_chatdb.addRooms(s);this._receivedChatDB=true}else{if(g==72){var p=W.getElement("b");if(p){var x=W.getElement("f");var g=W.getElement("a");if(x=="0"){var H=W.getElement("c");m_chatdb.updateRoomAccessCode(g,H)}else{if(x=="1"){var H=W.getElement("d");m_deptdb.updateAccessCode(g,H)}}}}else{if(g==74){var e=W.getElement("b");var s=W.getRecords();if(e==1){m_chatdb.addRooms(s)}else{m_chatdb.removeRooms(s)}}else{if(g==76){m_deptdb.initialize();var s=W.getRecords();m_deptdb.addDepartments(s);this._receivedDeptDB=true}else{if(g==78){var e=W.getElement("b");var s=W.getRecords();if(e==1){m_deptdb.addDepartments(s)}else{m_deptdb.removeDepartments(s)}}else{if(g==81){m_wkgpdb.initialize();var s=W.getRecords();m_wkgpdb.addDepartments(s);this._receivedWkgpDB=true}else{if(g==85){var e=W.getElement("b");var s=W.getRecords();if(e==1){m_wkgpdb.addDepartments(s)}else{m_wkgpdb.removeDepartments(s)}}else{if(g==91){m_linkdb.initialize();var s=W.getRecords();m_linkdb.addLinks(s);this._receivedLinkDB=true}else{if(g==94){var e=W.getElement("b");var s=W.getRecords();if(e==1){m_linkdb.addLinks(s)}else{m_linkdb.removeLinks(s)}}else{if(g==101){var x=W.getElement("a");var h=W.getElement("b");var F=W.getElement("c");var K=W.getElement("f",m_key);this.notifyListeners("message",{"msg":K,"uid":F,"type":x,"id":h})}else{if(g==103){var x=W.getElement("a");var h=W.getElement("b");var F=W.getElement("c");var P=W.getElement("d");this.notifyListeners("blocked",{"reason":P,"uid":F,"type":x,"id":h})}else{if(g==106){var x=W.getElement("a");if(x!="0"){var h=W.getElement("b");var F=W.getElement("c");this.notifyListeners("exitroom",{"type":x,"id":h,"uid":F});if(UserDB.isGuestID(F)){m_userdb.removeGuest(F)}}}else{if(g==115){var x=W.getElement("a");var h=W.getElement("b");var F=W.getElement("c");if(UserDB.isGuestID(F)){m_userdb.addGuest(F,W.getElement("e"),W.getElement("f"))}this.notifyListeners("enterroom",{"uid":F,"type":x,"id":h})}else{if(g==116){var x=W.getElement("a");var h=W.getElement("b");if(x!="0"){var G=W.getDoc();var n=W.getUserlistUsers();for(var v=0;v<n.length;v++){var t=n[v];this.notifyListeners("adduserroom",{"type":x,"id":h,"uid":t})}}}else{if(g==117){var h=W.getElement("a");var q=W.getElement("b");m_chatdb.updateRoomUserCount(h,q)}else{if(g==118){var x=W.getElement("a");var h=W.getElement("b");if(x!="0"){var n=W.getRecords();for(var v=0;v<n.length;v++){var k=n[v];var t=IMXMLParser.getRecordElement(k,"a");var Y=IMXMLParser.getRecordElement(k,"c");var S=IMXMLParser.getRecordElement(k,"d");m_userdb.addGuest(t,Y,S);this.notifyListeners("adduserroom",{"type":x,"id":h,"uid":t})}}}else{if(g==128){var x=W.getElement("a");var h=W.getElement("b");var F=W.getElement("c");var X=W.getElement("d");this.notifyListeners("typingstatus",{"type":x,"id":h,"uid":F,"status":X})}else{if(g==129){var u=W.getElement("a");var D=W.getElement("b");var r=W.getElement("e");var M=W.getElement("f");this.notifyListeners("updatechatid",{"prevtype":u,"previd":D,"newtype":r,"newid":M})}else{if(g==131){var x=W.getElement("a");var h=W.getElement("b");var T=W.getUserlistUsers();this.notifyListeners("invited",{"type":x,"id":h,"users":T})}else{if(g==132){var u=W.getElement("a");var D=W.getElement("b");var r=W.getElement("e");var M=W.getElement("f");var w=W.getElement("d");var R=W.getUserlistUsers();if(r==0&&M==0){r=u;M=D}this.notifyListeners("othersinvited",{"prevtype":u,"previd":D,"newtype":r,"newid":M,"invitor":w,"invitees":R})}else{if(g==133){var x=W.getElement("a");var h=W.getElement("b");var F=W.getElement("c");var Y=(F==0)?"Group Administrator":m_userdb.users[F].displayName;this.notifyListeners("message",{"msg":Y+" has denied the invitation.","uid":null,"type":x,"id":h});this.notifyListeners("removeroomuser",{"type":x,"id":h,"uid":F})}else{if(g==211){var p=W.getElement("a");var N=W.getElement("b");this.notifyListeners("uploadfileverify",{"success":p,"errorcode":N})}else{if(g==242){var f=W.getElement("b");var V=W.getElement("c");var s=W.getRecords();for(var v=0;v<s.length;v++){var C=this;new function(){var i=s[v];setTimeout(function(){var AA=IMXMLParser.getRecordElement(i,"h");var AE=IMXMLParser.getRecordElement(i,"f");var z=IMXMLParser.getRecordElement(i,"c");var AD=IMXMLParser.getRecordElement(i,"i");var y=IMXMLParser.getRecordElement(i,"d");var AC=IMXMLParser.getRecordElement(i,"j");var AB={"ownerType":f,"owner":V,"filename":AA,"filelength":AE,"userid":z,"username":AD,"uploadtime":y,"description":AC};C.notifyListeners("addfile",AB)},0)}()}}else{if(g==243){var f=W.getElement("a");var V=W.getElement("b");var Z=W.getElement("e",m_key);var o={"ownerType":f,"owner":V,"filename":Z};this.notifyListeners("removefile",o)}else{if(g==247){var f=W.getElement("a");var V=W.getElement("b");var Z=W.getElement("k");var A=W.getElement("g");var t=W.getElement("d");var c=W.getElement("l");var L=W.getElement("e");var O=W.getElement("s");var o={"ownerType":f,"owner":V,"filename":Z,"filelength":A,"userid":t,"username":c,"uploadtime":L,"description":O};this.notifyListeners("addfile",o)}else{if(g==381||g==382){var s=W.getRecords();for(var v=0;v<s.length;v++){var C=this;new function(){var i=s[v];setTimeout(function(){var AB=IMXMLParser.getRecordElement(i,"e");AB=m_key?IMXML.decrypt(AB,m_key):AB;var z=IMXMLParser.getRecordElement(i,"f");z=m_key?IMXML.decrypt(z,m_key):z;var AA=IMXMLParser.getRecordElement(i,"i");AA=(m_key&&AA)?IMXML.decrypt(AA,m_key):AA;var y={"timestamp":IMXMLParser.getRecordElement(i,"a"),"type":IMXMLParser.getRecordElement(i,"c"),"userid":IMXMLParser.getRecordElement(i,"d"),"msg":AB,"sender":z,"owner":IMXMLParser.getRecordElement(i,"g"),"ownerType":IMXMLParser.getRecordElement(i,"h"),"description":AA,"title":IMXMLParser.getRecordElement(i,"j")};C.notifyListeners("addstream",y)},0)}()}}else{if(g==521){var o={"timestamp":W.getElement("a"),"userid":W.getElement("b"),"logtype":W.getElement("c"),"username":W.getElement("d",m_key),"message":W.getElement("e",m_key),"chatroom":W.getElement("f",m_key)};this.notifyListeners("logmessage",o)}else{if(g==529){var E=W.getElement("a");var t=W.getElement("b");this.notifyListeners("confirmcreateuser",{"status":E,"id":t})}else{if(g==706){var s=W.getRecords();if(s.length>=1){this.m_hostname=IMXMLParser.getRecordElement(s[0],"a");this.m_groupInfo=new GroupInfo(s[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}if(this._receivedDeptDB==false&&A(B,[78])){return false}if(this._receivedWkgpDB==false&&A(B,[85])){return false}return true};AppModel.prototype.addConnectedRoom=function(A,B){this.removeConnectedRoom(A,B);this._connectedChats.push({"type":A,"id":B})};AppModel.prototype.removeConnectedRoom=function(C,D){for(var B=0;B<this._connectedChats.length;B++){var A=this._connectedChats[B];if(A.type==C&&A.id==D){this._connectedChats.splice(B,1);break}}};AppModel.prototype.reconnectToRooms=function(){for(var B=0;B<this._connectedChats.length;B++){var A=this._connectedChats[B];if(A.type==2){this.openChatroom(A.id)}}};AppModel.prototype.onCloseConnection=function(){clearInterval(m_heartbeat);if(this._connected==true){this._reconnecting=true;this._connected=false;this.connectionType=AppModel.connectionType.DIRECT;this.connectionTarget=AppModel.connectionTarget.PROXY;this.connect()}else{this._receivedPrivileges=false;this._receivedUserDB=false;this._receivedChatDB=false;this._receivedDeptDB=false;this._receivedWkgpDB=false;this._receivedGroupInfo=false;this._receivedOnlineList=false;this._receivedRoomCounts=false;this._connectedChats=[];this._reconnecting=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 Privileges(D,E,C,B,A){this.profileRights=E||0;this.publicRights=D||0;this.imaRights1=C||0;this.imcRights1=B||0;this.imcRights2=A||0}Privileges.prototype.isEventLoggingAllowed=function(){if(m_uid==0){return true}return(this.imaRights1&1)};Privileges.prototype.isChatLoggingAllowed=function(){if(m_uid==0){return true}return(this.imaRights1&2)};Privileges.prototype.isPasswordChangeable=function(){if(m_uid==0){return true}return(this.profileRights&2)};Privileges.prototype.isAllowedToCreateRoom=function(){if(m_uid==0){return true}return(this.imcRights1&2)};Privileges.prototype.isAdmin=function(A){if(A==0){return true}return(this.publicRights&536870912)};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}