$(document).ready(function(){WEBCHAT.Init()});var WEBCHAT={AlohaChat:{},AlohaServerURL:"//chatapi.eu2.quandago.app/v2",TotalAvailableAgents:0,hasChatWindowOpen:!1,UI_ELEMENTS:{$chatStartButon:$(),$chatStartLink:$(),$chatStarters:$()},Init:function(){this.HELPERS.InitChatObject();this.HELPERS.InitChatUI()},HELPERS:{InitChatUI:function(){var n=this;n.InitUIConstants();n.RegulateVisibilityStartButton();WEBCHAT.UI_ELEMENTS.$chatStarters.on("click",function(){n.OpenChat();n.SendCurrentUrl();n.HideStartElements()});WEBCHAT.AlohaChat.addAlohaNotifyHandler("leaveSuccess",function(){WEBCHAT.hasChatWindowOpen=!1;WEBCHAT.TotalAvailableAgents>0&&n.ShowStartElements()});WEBCHAT.AlohaChat.addAlohaNotifyHandler("notauthorizedError",function(){LOG.WriteInfo("not authorized for aloha chat API");WEBCHAT.TotalAvailableAgents>0&&n.ShowStartElements()})},InitUIConstants:function(){WEBCHAT.UI_ELEMENTS.$chatStarters=$(".chat-starter");WEBCHAT.UI_ELEMENTS.$chatStartButon=$("#chat-startbutton");WEBCHAT.UI_ELEMENTS.$chatStartLink=$("#chat-link")},CustomizeChatWindow:function(){$("#alohatitle").addClass("icon misc conversation");$("#close_chat").addClass("icon actions delete")},RegulateVisibilityStartButton:function(){function t(){n.GetTotalAvailableAgents().then(function(){!isNaN(WEBCHAT.TotalAvailableAgents)&&WEBCHAT.TotalAvailableAgents>0&&!WEBCHAT.hasChatWindowOpen?n.ShowStartElements():n.HideStartElements()})}var n=this;WEBCHAT.UI_ELEMENTS.$chatStartButon.is(":visible")?n.ShowStartElements():n.HideStartElements();setInterval(t,1e4)},ShowStartElements:function(){WEBCHAT.UI_ELEMENTS.$chatStarters.show()},HideStartElements:function(){WEBCHAT.UI_ELEMENTS.$chatStarters.hide()},InitChatObject:function(){WEBCHAT.AlohaChat=new AlohaWebChat({server:"//chatapi.seniorweb.nl/v2",chatbox:"seniorweb_ledenservice",debug:!1,chat_obj:"aloha-chat-holder",tags:["tag1","tag2","currenturl: "+window.location.href],labels:{title:"Live chat",close_tooltip:"Sluiten",minimize_tooltip:"Inklappen",maximize_tooltip:"Uitklappen",send_button_label:"Verzenden",welcome:"U bent nu verbonden met ons kantoor.",queued:"Helaas zijn momenteel al onze chat-medewerkers bezet. U kunt dit venster sluiten.",agentjoin:"Welkom, u spreekt nu met {full}. Waarmee kan ik u helpen?",agentleave:"Tot ziens."}})},OpenChat:function(){WEBCHAT.AlohaChat.startAlohaWebChat("Acme user","acme@vanadgroup.com");WEBCHAT.hasChatWindowOpen=!0;this.CustomizeChatWindow()},SendCurrentUrl:function(){WEBCHAT.AlohaChat.settags(["currentUrl: "+window.location.href])},GetTotalAvailableAgents:function(){return $.ajax({url:"/webchat/getchatstats",type:"POST",dataType:"json",cache:!1,success:function(n){WEBCHAT.TotalAvailableAgents=n.available},error:function(){WEBCHAT.TotalAvailableAgents=0}})}}}