function loadClientMethods(n){n.client.Post=function(n,t,i,r,u,f){Post(n,t,i,r,u,f)};n.client.OnPing=function(t){Pong(n,t)};n.client.Pong=function(){};n.client.postToSelf=function(n,t,i,r,u,f){PostToSelf(t,i,r,u,f)};n.client.onConnected=function(t,i,r,u,f,e){ClearChat();HideLoader();$("#hCid").val(t);$("#hCUID").val(r);$("#formCUID").val(r);$("#hRoom").val(u);$("#hUclass").val(f);$("#hCRID").val(u);$("#hTimeJoin").val(GetTimeNow());setCookie(r,730,chatUserIDCookie);var o=CheckSetGetIP();if(BroadcastMyRooms(n,u,i,myCUID(),0,GetRes(),GetCity(),GetCountry(),o,GetPage(),GetCurrentStatus()),$("#divChat").show(),isMobile()||$("#txtMsg").trigger("focus"),$("#chatheader").addClass("connected"),$(".chatButton, .openchat").fadeIn("fast"),$(".chatContainer .closeBtn").fadeIn("fast"),e!=="False"){$(".chatButton").addClass("bounce");$(".chatButton").on("mouseover",function(){$(this).addClass("bounce")},function(){$(this).removeClass("bounce")})}};n.client.onAdminPost=function(n,t){SetLastPost(n,t,GetTimeNow())};n.client.onGetLastPost=function(){GetLastPostTime()!=""&&n.server.sendLastPost(GetLastPostCUID(),currRoom(),GetLastPostUname(),GetLastPostTime())};n.client.onSetLastPost=function(n,t,i){SetLastPost(t,n,i)};n.client.onAdminCheckWhoAttending=function(t,i,r){var u=GetAdminAttending(),f=GetAdminAttendingName();n.server.sendWhoAttending(u,f,$("#hACUID").val(),currRoom(),i,r)};n.client.onSendWhoAttendingToUser=function(n,t,i,r){n!=""&&t!=""&&SetAttend(n,t,i,r)};n.client.onAdminAttend=function(n,t,i,r){clearTimeout(longWaitTimer);SetAttend(t,i,n,r)};n.client.onUnattend=function(){SetUnAttend()};var t;n.client.adminIsTyping=function(n,i){clearTimeout(longWaitTimer);SetTyping(i+" is typing",n);clearTimeout(t);t=setTimeout(function(){$("#typing").hide()},6e4)};n.client.adminStopTyping=function(n){SetTyping(null,n)};n.client.onGetMessagesCount=function(n,t){var i,r;totalMsgCount=n;i=getChatRowCount();n>0&&i<n&&$("#loadMore").show();n==0&&$(".GreetMsg").length==0&&(config_isfairstarted?PostToSelf("Dr Chan Khai Leok","Hi, our education counsellors will be at the university fair today. You may drop us your questions on WhatsApp and we'll respond to them after the fair. <div class='viawa'><div class='wamsg'><div class='wabtn'><i class='fa fa-whatsapp' aria-hidden='true'><\/i> <span>Chat on Whatsapp<\/span><\/div><\/div><\/div>","AdminUser GreetMsg theRightU",GetTimeNow(),""):PostToSelf("Dr Chan Khai Leok",t,"AdminUser GreetMsg theRightU",GetTimeNow(),""));r=getAdminRowCount();r==0&&i>=1&&TriggerLongWait()};n.client.postToSelfEarlier=function(n,t,i,r,u,f){PostToSelfEarlier(n,t,i,r,u,f)};n.client.onDisconnect=function(n){Disconnect(n)};n.client.getRecents=function(t,i){var r=getCookieValue("truweb1_chat_ru"),u=getCookieValue("truweb1_chat_rs"),f=getCookieValue("truweb1_chat_rc"),e=detect.getUserData();n.server.returnRecents(t,r,u,f,i,myCUID(),e,GetPage())};n.client.onRehash=function(){location.reload(!0)};n.client.onRedirect=function(n){location.href=n};n.client.onAdminUnattend=function(){RemoveAttendingAdmin()};n.client.onBlock=function(){detect.crashandburn()};n.client.onCrash=function(){detect.crash()};n.client.onUnreadCount=function(n){n>0&&!$("chatButton").hasClass("newMsg")&&TriggerNotification()};n.client.onLogoff=function(){$.ajax({url:"/Account/UserLogOff",success:function(){location.href="/"}})}}function TriggerLongWait(){clearTimeout(longWaitTimer);longWaitTimer=setTimeout(PostWATemplate,1e4)}function PostWATemplate(){var n=$(".chatMsg .viawa").length;n==0&&PostToSelf(null,"<div class='viawa fwdwa'><div class='wa'><i class='fa fa-whatsapp' aria-hidden='true'><\/i><\/div><div class='wamsg'>To be notified when we respond, click here to forward your questions to us on Whatsapp!<\/div><\/div>","AdminUser GreetMsg longWait",GetTimeNow(),"")}function getChatRowCount(){return $("#divMessage #innerArea").find(".chatrow").not(".systemMsg").not(".GreetMsg").not("#typing").length}function getAdminRowCount(){return $("#divMessage #innerArea").find(".chatrow").not(".systemMsg").not(".GreetMsg").not("#typing").not(".User").length}function getCookieValue(n){for(var t,r=n+"=",f=decodeURIComponent(document.cookie),u=f.split(";"),i=0;i<u.length;i++){for(t=u[i];t.charAt(0)==" ";)t=t.substring(1);if(t.indexOf(r)==0)return t.substring(r.length,t.length)}return""}function loadEvents(n){loadChatRoomEvents(n)}function loadChatRoomEvents(n){if(n){$("#btnSendMsg").off("click").on("click",function(){var t,u;if($.connection.hub&&($.connection.hub.state===$.signalR.connectionState.disconnected||$.connection.hub.state===$.signalR.connectionState.connecting||$.connection.hub.state===$.signalR.connectionState.reconnecting)){PostToSelf(null,"You have been disconnected due to a network issue. Please wait while we reconnect you.","systemMsg",GetTimeNow(),"");Reconnect();return}if(t=$("#txtMsg").val(),t.trim().length>0){var f=$("#hCRID").val(),r=$("#hUclass").val(),e=new Date,i=e.getTime();lastMsgTime&&(i-lastMsgTime)/1e3<.5?PostToSelf(null,"Message not delivered. You are sending too many messages too quickly.","systemMsg",i,myCUID()):(lastMsgTime=i,Post("me",t,r,currRoom(),myCUID(),GetTimeNow()),PostAsUser(n,currRoom(),t,myCUID(),f,r),isMobile()&&$("#txtMsg").blur(),u=getAdminRowCount(),u==0&&TriggerLongWait())}});$("#txtMsg").on("keyup",function(t){var i;t.which==13?(t.preventDefault(),$("#btnSendMsg").trigger("click"),isSentTyping=!1,n.server.stopTyping(currRoom())):($(this).val()==""?(i=$(".chatArea"),i.hasClass("opened")&&CloseChatInput()):(i=$(".chatArea"),i.hasClass("opened")||isMobile()&&OpenChatInput()),checkTyping(n,$(this)))});if(isMobile()){$("#txtMsg").off("click").on("click",function(){OpenChatInput()});document.removeEventListener("touchmove",ScrollStart);document.addEventListener("touchmove",ScrollStart)}if(!config_isfairstarted)$(document).off("scroll").on("scroll",function(){sendscroll(n)});$(document).off("newFairSignUpNotification").on("newFairSignUpNotification",function(t,i,r,u,f){n.server.newFairSignUpNotification(i,r,u,f)});$(document).off("newAssessmentNotification").on("newAssessmentNotification",function(t,i,r,u){n.server.newAssessmentNotification(i,r,u)});$(document).off("newBookingNotification").on("newBookingNotification",function(t,i,r,u){n.server.newBookingNotification(i,r,u)})}}function BindConnectionEvents(){$.connection.hub.disconnected(function(){clearTimeout(disconnectTimer);disconnectTimer=setTimeout(function(){console.log("Disconnected from hub");Reconnect()},5e3)});$.connection.hub.reconnecting(function(){console.log("reconnecting")});$.connection.hub.reconnected(function(){console.log("Reconnected");clearTimeout(reconnectTimer);clearTimeout(disconnectTimer)})}function ClearChat(){$("#loadMore").hide();$(".chatrow").not("#typing").remove()}function Reconnect(){if(console.log("Reconnecting to hub"),typeof reConnectWebRTCSession=="function"){var n=$.connection.chatHub;console.log("webrtcName="+n.webrtcName);n.client.onUpdateAppointmentStatus=onUpdateAppointmentStatus;n.client.onSendMeetingMessage=onSendMeetingMessage;n.client.onSendStudentMeetingMessage=onSendStudentMeetingMessage}$.connection.hub.start({transport:["webSockets","longPolling"]}).done(function(){console.log("Connected to hub");$.connection.chatHub.server.connect(GetChatUserIDCookie(),isMinimised,getCookieValue("truweb1_IP"),chatRef,chatRole,"",GetPreferenceIDCookie(),GetUNameCookie(),GetEmailCookie());typeof reConnectWebRTCSession=="function"&&reConnectWebRTCSession();$(".chatrow #typing").hide()})}function Post(n,t,i,r,u,f){var o=$("#hCUID").val(),e=GetUserName(n,u,o);t==VideoStopFlag&&(isShowToMe=!1);!0&&(e=="me"?($("#txtMsg").val(""),f=null):(SetTyping(null,r),TriggerNotification()),DisplayPost(e,t,i,f,u))}function PostToSelf(n,t,i,r,u){DisplayPost(n,t,i,r,u)}function PostToSelfEarlier(n,t,i,r,u,f){var o=$("#divMessage .chatrow")[0],e=GetTimeStamp(u);$('<div class="chatrow '+r+'" title="Sent on '+e+'">'+GetChatInfo(t,e,f)+'<div class="chatMsg" data-timesent="'+e+'">'+linkifyHtml(i.trim(),{})+'<div class="clearBoth"><\/div><\/div><\/div><\/div>').insertBefore(o);getChatRowCount()>=totalMsgCount&&$("#loadMore").hide()}function addMiniConf(){$.ajax({url:"/Support/MiniConf",type:"GET"}).done(function(n){$("#miniconference").html(n);miniconf.ChatRoom(myCUID());miniconf.OnChatLoadedMini(function(){miniconf.coonectRTCSocket()})})}function approveUserRequest(){var n=noty({text:"<div><span>Your consultant is inviting you to join the virtual meeting. Your microphone will be used for this voice call. <\/span><\/div>",type:"information",dismissQueue:!0,layout:"bottomLeft",timeout:18e5,theme:"relax",killer:!1,maxVisible:3,animation:{open:"animated bounceInLeft",close:"animated bounceOutLeft",easing:"flipInX"},buttons:[{addClass:"btn",text:"Accept",onClick:function(n){addMiniConf();n.close()}},{addClass:"btn",text:"Decline",onClick:function(n){SendToHost(VideoStopFlag);n.close()}}]})}function DisplayPost(n,t,i,r,u){if(t===VideoStartFlag)getCookie(VideoApproved)=="VideoApproved"?addMiniConf():approveUserRequest();else if(t===VideoStopFlag)miniconf.closeUserMeetingSession(!0);else{var f=GetTimeStamp(r);$('<div class="chatrow '+i+'" title="Sent on '+f+'">'+GetChatInfo(n,f,u)+'<div class="chatMsg" data-timesent="'+f+'">'+linkifyHtml(t.trim(),{})+'<\/div><div class="clearBoth"><\/div><\/div>').insertBefore("#innerArea #typing");UserViewScrollBottom()}}function UserViewScrollBottom(){$(".messageArea").length>0&&$(".messageArea").scrollTop($(".messageArea")[0].scrollHeight)}function PostAsUser(n,t,i,r,u,f){SetLastPost("user",r,GetTimeNow());n.server.postAsUser(t,i,r,u,f,$("#hACID").val(),"",chatsiteid)}function SendToHost(n){var i=$("#hCRID").val(),r=$("#hUclass").val(),t=$.connection.chatHub;t?t.server.postAsUser(currRoom(),n,myCUID(),i,r,$("#hACID").val(),"",chatsiteid):console.log("ObjHub is undefined")}function SetLastPost(n,t,i){$("#hLastPostTime").val(i);$("#hLastPostUname").val(n);$("#hLastPostCUID").val(t)}function GetChatInfo(n,t,i){return i!=myCUID()?"<div class='chatinfo'><div class='float-left'>"+n+"<\/div><div class='clearBoth'><\/div><\/div>":""}function GetUserName(n,t,i){return t==i?"me":n}function checkTyping(n,t){var r,i;n!=null&&(r=currRoom(),isSentTyping=!1,r!=null&&r!=""&&(i=t.val().trim(),!isSentTyping&&i.length>0&&i.length%2==0&&(isSentTyping=!0,n.server.sendTyping(currRoom(),i))))}function SetAttend(n,t,i,r){SetAdminAttendCookie(n,t);$("#hACUID").val(n);$("#hACID").val(r);$("#hAUname").val(t);var u=String.format("{0} from theRightU is supporting you.",t);$(".consultant-img").attr("title",u);$(".consultant-img").attr("data-original-title",u)}function SetUnAttend(){RemoveAdminAttendCookie();$("#hACUID").val("");$("#hACID").val("");$("#hAUname").val("")}function SetTyping(n,t){t==currRoom()&&(n?($("#typing").fadeIn(),$("#typing .chatMsg").html(n)):$("#typing").hide())}function LoadEarlier(){var n=getChatRowCount();$.connection.chatHub.server.getEarlierPosts(currRoom(),n,6)}function GetAdminAttending(){var n=getCookie(chatAdminAttendCookie);return n!=!1?n:""}function GetAdminAttendingName(){var n=getCookie(chatAdminAttendNameCookie);return n!=!1?n:""}function Pong(n,t){if(n!=null){var i=$("#hTimeJoin").val(),r=CheckSetGetIP();n.server.pong(currRoom(),"",!1,myCUID(),i,t,GetRes(),GetCity(),GetCountry(),r,GetPage(),GetCurrentStatus().Status,GetCurrentStatus().Room)}}function BroadcastMyRooms(n,t,i,r,u,f,e,o,s,h,c){n!=null&&t!=null&&n.server.broadcastMyRooms(t,i,!1,r,u,f,"",e,o,s,h,c.Status,c.Room)}function Disconnect(n){n!=null&&$("#hACID").val()==n&&($("#hACUID").val(""),$("#hACID").val(""),$("#hAUname").val(""))}function RemoveAttendingAdmin(){$("#hACUID").val("");$("#hACID").val("");$("#hAUname").val("")}function ScrollStart(){CloseChatInput(!1)}function OpenChatInput(){var n=$("#divMessage"),t=$(".chatArea");t.addClass("opened");n.stop().animate({height:"70%"},{duration:400,easing:"easeInOutCubic"});UserViewScrollBottom()}function CloseChatInput(){var n=$(".chatArea"),t;n.hasClass("opened")&&(t=$("#divMessage"),n.removeClass("opened"),t.stop().animate({height:"80%"},{duration:200,easing:"easeInOutCubic"}),UserViewScrollBottom())}function closeChat(){ChatClosed();$(window).off("scroll.chat");SetChatOpenCookie(!1);c=$(".chatContainer");$(c).animate({right:"-550px"},600,"easeOutQuint",function(){$(c).hide();$(".chatButton").fadeIn()});notifyReset();SetChatMinimisedCookie(!0)}function ShowChatContainer(){var n,t,i;c=$(".chatContainer");n=$("#preview-uni_wrapper");n.length>0&&(t=$("#preview-uni_wrapper").css("z-index"),i=t+1,$(c).attr("style","z-index:"+i));c.show(function(){$(c).animate({right:"0"},450,"easeOutQuint",function(){$(".chatButton").hide()})});ChatOpened()}function ConnectMinimised(n){$(".chatContainer").hide();SetChatMinimisedCookie(!0);ConnectToChat(!0,n)}var isSentTyping=!1,longWaitTimer,lastMsgTime,disconnectTimer,reconnectTimer,chatsiteid=chatsiteid===null?getCookieValue("truweb1_SelectedSiteID"):chatsiteid