setTimeout(function(){(function($){var templateOptions=null;$.fn.cmLivechat=function(options){var settings=$.extend({template:'C5Sy66S6P33942C',siteUrl:'https://cm.voipshop.lt',socketUrl:'wss://ws.voipshop.lt:443/ws',v4FontAwesome:true,v4OlderFontAwesome:true},options);$.getJSON(settings.siteUrl+'/livechat/template/'+settings.template,function(data){settingsOptions=settings;window.cmLivechat_appid=settings.template;window.cmLivechat_socketUrl=settings.socketUrl;window.cmLivechat_siteUrl=settings.siteUrl;window.cmLivechat_soundWorks=true;templateOptions=data;var span=document.createElement('span');span.className='fa';span.style.display='none';document.body.insertBefore(span,document.body.firstChild);if((css(span,'font-family'))!=='FontAwesome'){}
if(typeof jQuery=='undefined')
$('head').append("<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>");document.body.removeChild(span);setTimeout(function(){if(checkCookie('cmLivechat_chatID')){renderChatWindow();$('head').append('<style>.cmLivechat_required::after { content:" *";color: '+templateOptions.livechat.errorColor+';} #cmLivechat_icDropper>p{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_icDropper>span{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_icDropper>i{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_icDropper>input{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_icDropperNWH>p{font-size:.7em;line-height:1.5;font-family: "Archivo", sans-serif;}#cmLivechat_icDropperNWH>span{font-size:.7em;line-height:1.5;font-family: "Archivo", sans-serif;}#cmLivechat_icDropperNWH>i{font-size:.7em;line-height:1.5;font-family: "Archivo", sans-serif;}#cmLivechat_icDropperNWH>input{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_header>p{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_header>span{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_header>i{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_header>input{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_footer>p{font-size:.7em;    font-family: "Archivo", sans-serif;margin-bottom:1em}#cmLivechat_footer>span{font-size:.7em;    font-family: "Archivo", sans-serif;margin-bottom:1em}#cmLivechat_footer>i{font-size:.7em;    font-family: "Archivo", sans-serif;margin-bottom:1em}#cmLivechat_footer>input{font-size:.7em;    font-family: "Archivo", sans-serif;margin-bottom:1em}</style>');}else{$('head').append('<style>.cmLivechat_required::after { content:" *";color: '+templateOptions.livechat.errorColor+';} #cmLivechat_icDropper>p{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_icDropper>span{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_icDropper>i{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_icDropper>input{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_icDropperNWH>p{font-size:.7em;line-height:1.5;font-family: "Archivo", sans-serif;}#cmLivechat_icDropperNWH>span{font-size:.7em;line-height:1.5;font-family: "Archivo", sans-serif;}#cmLivechat_icDropperNWH>i{font-size:.7em;line-height:1.5;font-family: "Archivo", sans-serif;}#cmLivechat_icDropperNWH>input{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_header>p{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_header>span{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_header>i{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_header>input{font-size:.7em;line-height:1.5;    font-family: "Archivo", sans-serif}#cmLivechat_footer>p{font-size:.7em;    font-family: "Archivo", sans-serif;margin-bottom:1em}#cmLivechat_footer>span{font-size:.7em;    font-family: "Archivo", sans-serif;margin-bottom:1em}#cmLivechat_footer>i{font-size:.7em;    font-family: "Archivo", sans-serif;margin-bottom:1em}#cmLivechat_footer>input{font-size:.7em;    font-family: "Archivo", sans-serif;margin-bottom:1em}</style>');renderWindow();}
renderPopupButton();$(window).resize();},2000);});return this;};function setCookie(cname,cvalue){var d=new Date();d.setTime(d.getTime()+(12*60*60*1000));var expires="";document.cookie=cname+"="+cvalue+";"+expires+"path=/";}
function getCookie(cname){var name=cname+"=";var decodedCookie=decodeURIComponent(document.cookie);var ca=decodedCookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1);}
if(c.indexOf(name)==0){return c.substring(name.length,c.length);}}
return"";}
function checkCookie(name){var data=getCookie(name);if(data!=""){return true;}else{return false;}}
$(window).on('resize',function(){var win=$(this);if(win.width()<600){$('#cmLivechat_container').css('width','80%');$('#cmLivechat_container').css('height','auto');$('#cmLivechat_container').css('top','inherit');$('#cmLivechat_container').css('bottom','90px');$('#cmLivechat_container').css('right','15px');$('#cmLivechat_header').css('width','100%');$('#cmLivechat_icDropper').css('width','auto');$('#cmLivechat_icDropper').css('height','400px');$('#cmLivechat_icDropperNWH').css('width','auto');$('#cmLivechat_icDropperNWH').css('height','400px');$('#cmLivechat_chat').css('width','auto');$('#cmLivechat_chat').css('height','400px');$('#cmLivechat_chatMessage').css('width','97% !important');$('#cmLivechat_sendChatMessage').css('width','auto');$('#cmLivechat_sendChatMessage').css('height','34px');$('#cmLivechat_sendChatMessage').css('right','10px');$('#cmLivechat_container').css('z-index','10000');$('#cmLivechat_popupButton').css('z-index','9999');$('#cmLivechat_windowClose > i').addClass('fa-2x');$('#cmLivechat_windowMinimize > i').addClass('fa-2x');$('#cmLivechat_soundOn > i').addClass('fa-2x');$('#cmLivechat_soundOff > i').addClass('fa-2x');}
if(win.width()>650){$('#cmLivechat_container').css('width','300px');$('#cmLivechat_container').css('height','400px');$('#cmLivechat_container').css('top','auto');$('#cmLivechat_container').css('bottom','125px');$('#cmLivechat_container').css('right','23px');$('#cmLivechat_header').css('width','300px');$('#cmLivechat_icDropper').css('width','300px');$('#cmLivechat_icDropper').css('height','405px');$('#cmLivechat_icDropper').css('width','300px');$('#cmLivechat_icDropper').css('height','405px');$('#cmLivechat_chat').css('width','300px');$('#cmLivechat_chat').css('height','280px');$('#cmLivechat_chatMessage').css('width','97% !important');$('#cmLivechat_sendChatMessage').css('width','auto');$('#cmLivechat_sendChatMessage').css('height','auto');$('#cmLivechat_container').css('z-index','10000');$('#cmLivechat_popupButton').css('z-index','10000');$('#cmLivechat_windowClose > i').removeClass('fa-2x');$('#cmLivechat_windowMinimize > i').removeClass('fa-2x');$('#cmLivechat_soundOn > i').removeClass('fa-2x');$('#cmLivechat_soundOff > i').removeClass('fa-2x');}});function renderChatWindow(){var cssBtn='display: inline-block;margin-bottom: 0;margin-top:0;margin-left:0.3em;margin-right:0.3em;font-weight: 400;text-align: center;vertical-align: middle;touch-action: manipulation;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 0.7em;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;height:34px;text-transform:none;text-decoration:none;box-sizing: border-box;font-family: Arial, Helvetica, sans-serif;';var cssFormControl='display: block; width: 90%;height: 20px; padding: 6px 12px;font-size: 0.7em;line-height: 1.42857143;background-color: #fff;background-image: none;border: 1px solid #ccc; border-radius: 4px;-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); box-shadow: inset 0 1px 1px rgba(0,0,0,.075);-webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;  transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;min-height:34px;text-transform:none;text-decoration:none;box-sizing: border-box;font-family: Arial, Helvetica, sans-serif;';$('body').append("<div id='cmLivechat_container' style='width:300px;height:400px;position:fixed;bottom:125px;right:23px;display:none;box-sizing:initial;font-size:initial;border-radius:200px;z-index:10000;'></div>");$('#cmLivechat_container').append("<div id='cmLivechat_header' style='background-color: #2E4262;width:300px;height:28px;border-top-left-radius:0;border-top-right-radius:0;'></div>");if(templateOptions.logo!=null){$('#cmLivechat_header').append("<img alt='chat' style='max-width:229px;height:40px;margin:5px;float:left;' src='data: "+JSON.parse(templateOptions.livechat.logo).contentType+";base64,"+templateOptions.logo+"'>");}
$('#cmLivechat_header').append("<span  id='cmLivechat_windowClose'><svg style='float:right;' xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n"+"<path d=\"M2 14H14M8 2V11.3333M8 11.3333L12.6667 6.66667M8 11.3333L3.33333 6.66667\" stroke=\"white\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n"+"</svg></span>");$('#cmLivechat_header').append("<span id='cmLivechat_soundOn'><svg style='float: left;' xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n"+"<path d=\"M10 12.6667C10 13.7713 9.10457 14.6667 8 14.6667C6.89543 14.6667 6 13.7713 6 12.6667M9.19767 4.15908C9.488 3.85913 9.66667 3.45045 9.66667 3.00004C9.66667 2.07957 8.92048 1.33337 8 1.33337C7.07953 1.33337 6.33334 2.07957 6.33334 3.00004C6.33334 3.45045 6.512 3.85913 6.80233 4.15908M1.69788 5.54868C1.68832 4.58112 2.20997 3.67758 3.05269 3.20208M14.3021 5.54868C14.3117 4.58111 13.79 3.67758 12.9473 3.20208M12 7.46671C12 6.54729 11.5786 5.66553 10.8284 5.0154C10.0783 4.36528 9.06087 4.00004 8 4.00004C6.93914 4.00004 5.92172 4.36528 5.17158 5.0154C4.42143 5.66553 4 6.54729 4 7.46671C4 8.98791 3.62276 10.1004 3.15205 10.8965C2.61556 11.8038 2.34732 12.2574 2.35791 12.3658C2.37003 12.4898 2.39235 12.5289 2.4929 12.6024C2.58078 12.6667 3.02234 12.6667 3.90546 12.6667H12.0945C12.9777 12.6667 13.4192 12.6667 13.5071 12.6024C13.6077 12.5289 13.63 12.4898 13.6421 12.3658C13.6527 12.2574 13.3844 11.8038 12.848 10.8965C12.3772 10.1004 12 8.98791 12 7.46671Z\" stroke=\"white\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n"+"</svg></span>");$('#cmLivechat_header').append("<span id='cmLivechat_soundOff' style='display:none;'><svg style='float: left;' xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n"+"<path d=\"M10 12.6667C10 13.7713 9.10457 14.6667 8 14.6667C6.89543 14.6667 6 13.7713 6 12.6667M4.91832 5.25656C4.32725 5.87555 4 6.65651 4 7.46671C4 8.98791 3.62275 10.1004 3.15204 10.8965C2.61556 11.8038 2.34732 12.2574 2.35791 12.3658C2.37003 12.4898 2.39234 12.5289 2.49289 12.6024C2.58078 12.6667 3.02234 12.6667 3.90546 12.6667H13.2533M8 4.00004C7.80473 4.00004 7.61093 4.01242 7.42 4.03666C7.16565 4.06897 7.03847 4.08512 6.91083 4.05042C6.81893 4.02544 6.68038 3.94489 6.6132 3.8774C6.51988 3.78364 6.49948 3.73419 6.45867 3.63529C6.37789 3.43951 6.33333 3.22498 6.33333 3.00004C6.33333 2.07957 7.07953 1.33337 8 1.33337C8.92047 1.33337 9.66667 2.07957 9.66667 3.00004C9.66667 3.45045 9.488 3.85913 9.19767 4.15908C8.81355 4.0546 8.41002 4.00004 8 4.00004ZM8 4.00004C9.06087 4.00004 10.0783 4.36528 10.8284 5.0154C11.5786 5.66553 12 6.54729 12 7.46671C12 7.68989 12.0061 7.90427 12.0176 8.11015M14 13.3334L2 2.66671\" stroke=\"white\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n"+"</svg></span>");$('#cmLivechat_container').append("<div id='cmLivechat_icDropper' style='background-color: "+templateOptions.livechat.fgColor+";width:300px;height:405px;overflow:auto;overflow-x:hidden;padding-left:5px;padding-right:5px;position:relative;'></div>");window.cmLivechat_icData=[];var initialData=JSON.parse(templateOptions.livechat.icData);var groups=templateOptions.groups;window.cmLivechat_groups=groups;var htmlToAdd="";$('#cmLivechat_windowMinimize').click(function(){$('#cmLivechat_iconClosed').css('display','none');$('#cmLivechat_iconOpen').css('display','initial');$('#cmLivechat_container').css('display','none');window.cmLivechatIsOpen=false;});$('#cmLivechat_windowClose').click(function(){$('#cmLivechat_iconClosed').css('display','none');$('#cmLivechat_iconOpen').css('display','initial');$('#cmLivechat_container').css('display','none');window.cmLivechatIsOpen=false;});$('#cmLivechat_soundOn').click(function(){window.cmLivechat_soundWorks=false;$('#cmLivechat_soundOn').css('display','none');$('#cmLivechat_soundOff').css('display','initial');});$('#cmLivechat_soundOff').click(function(){window.cmLivechat_soundWorks=true;$('#cmLivechat_soundOn').css('display','initial');$('#cmLivechat_soundOff').css('display','none');});$('#cmLivechat_icDropper').empty();$('#cmLivechat_icDropper').append('<textarea rows="5" id="cmLivechat_chatMessage" type="text" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+';width:97% !important;position:absolute;bottom:22px;resize: none;margin-left:0px;height:90px;" ></textarea>');$('#cmLivechat_icDropper').append('<button id="cmLivechat_sendChatMessage" type="button" style="'+cssBtn+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+';width:auto;height:34px;position:absolute;background-color:transparent;padding:0;margin:0;bottom:0px;font-size:23px;right:0px;text-transform:none;">Siųsti</button>');$('#cmLivechat_icDropper').append("<div id='cmLivechat_chat' style='background-color: "+templateOptions.livechat.fgColor+";width:300px;height:280px;overflow:auto;padding-left:5px;padding-right:5px;position:relative;overflow-wrap:break-word'></div>");$.getJSON(window.cmLivechat_siteUrl+'/livechat/chathistory/'+getCookie('cmLivechat_chatID'),function(data){var messages=data.messages;for(var z=0;z<messages.length;z++){var formattedDate='<span style="font-size:0.6em;">'+messages[z].name+' '+(new Date(messages[z].date).getHours()<10?'0'+new Date(messages[z].date).getHours():new Date(messages[z].date).getHours())+":"+(new Date(messages[z].date).getMinutes()<10?'0'+new Date(messages[z].date).getMinutes():new Date(messages[z].date).getMinutes())+"</span><br>";if(messages[z].type=='INCOMING'&&messages[z].text!=undefined){var dlrStatus="<span style='margin-left:5px;font-size:0.9em;font-weight:bold;' id='"+messages[z].chatID+"'>";if(messages[z].dlrStatus==0)
dlrStatus+='🗸';if(messages[z].dlrStatus==1)
dlrStatus+='🗸<span style="font-size:0.8em;">🗸</span>';if(messages[z].dlrStatus==2)
dlrStatus+='<span style="color:'+templateOptions.livechat.readColor+'">🗸<span style="font-size:0.8em;">🗸</span></span>';dlrStatus+='</span>';formattedDate='<span style="font-size:0.6em;">'+messages[z].name+' '+(new Date(messages[z].date).getHours()<10?'0'+new Date(messages[z].date).getHours():new Date(messages[z].date).getHours())+":"+(new Date(messages[z].date).getMinutes()<10?'0'+new Date(messages[z].date).getMinutes():new Date(messages[z].date).getMinutes())+"</span>"+dlrStatus+"<br>";$('#cmLivechat_chat').append('<span class="atsakymas" style="color:'+templateOptions.livechat.csfcColor+';background-color: '+templateOptions.livechat.csbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:right;position:relative;margin-left:30px; word-break:break-word;">'+formattedDate+messages[z].text+'</span><br style="clear:both;">');}else{if(messages[z].text!=undefined){var formedDlr=1;if($('#cmLivechat_container').css('display')!='none')formedDlr=2;var formedData={chatID:messages[z].chatID,dlrStatus:formedDlr};$('#cmLivechat_chat').append('<span data-cid="'+messages[z].chatID+'" data-dlr="'+formedDlr+'" style="color:'+templateOptions.livechat.crfcColor+';background-color:'+templateOptions.livechat.crbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:left;position:relative;margin-right:30px; word-break: break-word;">'+formattedDate+messages[z].text+'</span><br style="clear:both;">');$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});}}}
window.cmLivechat_reconnect_interval_id=null;window.cmLivechat_connect=function(){window.cmLivechat_socket={};window.cmLivechat_socket.onListeners=[];window.cmLivechat_socket.deferred=[];window.cmLivechat_socket.on=function(msg,callbackFn){window.cmLivechat_socket.onListeners.push({msg:msg,callbackFn:callbackFn});}
window.cmLivechat_socket.emit=function(msg,data){var formedData={msg:msg,data:data,evt:'emit',chan:'uws_server'};if(window.cmLivechat_socket.ws!=null&&(window.cmLivechat_socket.ws.readyState==1))
window.cmLivechat_socket.ws.send(JSON.stringify(formedData));else
window.cmLivechat_socket.deferred.push(JSON.stringify(formedData));};var websocket=new WebSocket(window.cmLivechat_socketUrl);websocket.onopen=function(event){for(var i=0;i<window.cmLivechat_socket.deferred.length;i++){window.cmLivechat_socket.ws.send(window.cmLivechat_socket.deferred[i]);}
window.cmLivechat_socket.deferred=[];clearInterval(window.cmLivechat_reconnect_interval_id);window.cmLivechat_reconnect_interval_id=null;$.getJSON(window.cmLivechat_siteUrl+'/livechat/chathistory_reconnect/'+getCookie('cmLivechat_chatID'),function(data){$('#cmLivechat_chat').html("");var messages=data.messages;for(var z=0;z<messages.length;z++){var formattedDate='<span style="font-size:0.6em;">'+messages[z].name+' '+(new Date(messages[z].date).getHours()<10?'0'+new Date(messages[z].date).getHours():new Date(messages[z].date).getHours())+":"+(new Date(messages[z].date).getMinutes()<10?'0'+new Date(messages[z].date).getMinutes():new Date(messages[z].date).getMinutes())+"</span><br>";if(messages[z].type=='INCOMING'&&messages[z].text!=undefined){var dlrStatus="<span style='margin-left:5px;font-size:0.9em;font-weight:bold;' id='"+messages[z].chatID+"'>";if(messages[z].dlrStatus==0)
dlrStatus+='🗸';if(messages[z].dlrStatus==1)
dlrStatus+='🗸<span style="font-size:0.8em;">🗸</span>';if(messages[z].dlrStatus==2)
dlrStatus+='<span style="color:'+templateOptions.livechat.readColor+'">🗸<span style="font-size:0.8em;">🗸</span></span>';dlrStatus+='</span>';formattedDate='<span style="font-size:0.6em;">'+messages[z].name+' '+(new Date(messages[z].date).getHours()<10?'0'+new Date(messages[z].date).getHours():new Date(messages[z].date).getHours())+":"+(new Date(messages[z].date).getMinutes()<10?'0'+new Date(messages[z].date).getMinutes():new Date(messages[z].date).getMinutes())+"</span>"+dlrStatus+"<br>";$('#cmLivechat_chat').append('<span  class="atsakymas" style="color:'+templateOptions.livechat.csfcColor+';background-color: '+templateOptions.livechat.csbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:right;position:relative;margin-left:30px; word-break:break-word;">'+formattedDate+messages[z].text+'</span><br style="clear:both;">');}else{if(messages[z].text!=undefined){var formedDlr=1;if($('#cmLivechat_container').css('display')!='none')formedDlr=2;var formedData={chatID:messages[z].chatID,dlrStatus:formedDlr};$('#cmLivechat_chat').append('<span data-cid="'+messages[z].chatID+'" data-dlr="'+formedDlr+'" style="color:'+templateOptions.livechat.crfcColor+';background-color:'+templateOptions.livechat.crbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:left;position:relative;margin-right:30px; word-break: break-word;">'+formattedDate+messages[z].text+'</span><br style="clear:both;">');$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});}}}});};websocket.onmessage=function(event){var msg=JSON.parse(event.data);for(var i=0;i<window.cmLivechat_socket.onListeners.length;i++){if(window.cmLivechat_socket.onListeners[i].msg==msg.msg)
window.cmLivechat_socket.onListeners[i].callbackFn(msg.data);}};websocket.onclose=function(event){for(var i=0;i<window.cmLivechat_socket.onListeners.length;i++){if(window.cmLivechat_socket.onListeners[i].msg=='disconnect')
window.cmLivechat_socket.onListeners[i].callbackFn(null);}
if(window.cmLivechat_reconnect_interval_id==null)
window.cmLivechat_reconnect_interval_id=setInterval(function(){window.cmLivechat_connect();},15000);};websocket.onerror=function(event){};window.cmLivechat_socket.ws=websocket;window.cmLivechat_socket.emit('cmLivechat_Online',{chatID:getCookie('cmLivechat_chatID')});window.cmLivechat_socket.on('cmLivechat_message',function(data){setTimeout(function(){var formedDlr=1;if($('#cmLivechat_container').css('display')!='none')formedDlr=2;var formedData={chatID:data.chatID,dlrStatus:formedDlr};$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});},300);var formattedDate='<span style="font-size:0.6em;">'+data.name+' '+(new Date(data.date).getHours()<10?'0'+new Date(data.date).getHours():new Date(data.date).getHours())+":"+(new Date(data.date).getMinutes()<10?'0'+new Date(data.date).getMinutes():new Date(data.date).getMinutes())+"</span><br>";$('#cmLivechat_chat').append('<span style="color:'+templateOptions.livechat.crfcColor+';background-color:'+templateOptions.livechat.crbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:left;position:relative;margin-right:30px; word-break: break-word;">'+formattedDate+data.text+'</span><br style="clear:both;">');var elem=document.getElementById('cmLivechat_chat');elem.scrollTop=elem.scrollHeight;window.cmLivechatIsOpen=true;if(window.cmLivechatIsOpen){$('#cmLivechat_iconClosed').css('display','initial');$('#cmLivechat_iconOpen').css('display','none');$('#cmLivechat_container').css('display','initial');$('span[data-cid]').each(function(){var cid=$(this).data('cid');var formedData={chatID:cid,dlrStatus:2};$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});$(this).removeAttr("data-cid");$(this).removeAttr("data-dlr");});}
if(window.cmLivechat_soundWorks)
playAudio();});window.cmLivechat_socket.on('cmLivechat_statusUpdate',function(data){$('#'+data.chatID).html("");var formatedDlr="";if(data.dlrStatus==0)
formatedDlr='🗸';if(data.dlrStatus==1)
formatedDlr='🗸<span style="font-size:0.8em;">🗸</span>';if(data.dlrStatus==2)
formatedDlr='<span style="color:'+templateOptions.livechat.readColor+'">🗸<span style="font-size:0.8em;">🗸</span></span>';$('#'+data.chatID).html(formatedDlr);});};window.cmLivechat_connect();var input=document.getElementById("cmLivechat_chatMessage");input.addEventListener("keyup",function(event){if(event.key==="Enter"){if(event.shiftKey){}else{event.preventDefault();document.getElementById("cmLivechat_sendChatMessage").click();}}});$('#cmLivechat_sendChatMessage').click(function(){if($('#cmLivechat_chatMessage').val().trim()=="")return;var dataToSend={};var ts=Math.round((new Date()).getTime()/1000).toString()+
Math.floor(Math.random()*101).toString();dataToSend.appid=window.cmLivechat_appid;dataToSend.chatID=ts;dataToSend.type="INCOMING";dataToSend.status="UNREPLIED";dataToSend.isReplied=false;dataToSend.isAutoreply=false;dataToSend.inReplyTo=null;dataToSend.repliedAt=null;dataToSend.isFirst=false;dataToSend.body=$('#cmLivechat_chatMessage').val().replace(/(?:\r\n|\r|\n)/g,'<br>');dataToSend.initialData=[];dataToSend.from="";dataToSend.initialChatID=getCookie('cmLivechat_chatID');dataToSend.dlrStatus=0;var formattedDate='<span style="font-size:0.6em;">'+(new Date().getHours()<10?'0'+new Date().getHours():new Date().getHours())+":"+(new Date().getMinutes()<10?'0'+new Date().getMinutes():new Date().getMinutes())+"</span><span style='margin-left:5px;font-size:0.9em;font-weight:bold;' id='"+ts+"'>🗸</span>"+"<br>";$('#cmLivechat_chat').append('<span  class="atsakymas" style="color:'+templateOptions.livechat.csfcColor+';background-color: '+templateOptions.livechat.csbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:right;position:relative;margin-left:30px; word-break: break-word;">'+formattedDate+$('#cmLivechat_chatMessage').val().replace(/(?:\r\n|\r|\n)/g,'<br>')+'</span><br style="clear:both;">');$('#cmLivechat_chatMessage').val("");var elem=document.getElementById('cmLivechat_chat');elem.scrollTop=elem.scrollHeight;$.post(window.cmLivechat_siteUrl+'/livechat/api/create',dataToSend,function(data){});});});}
async function playAudio(){var audio=new Audio(window.cmLivechat_siteUrl+'/juntos.mp3');audio.type='audio/mp3';await audio.play();}
function renderPopupButton(){var windowDiv="<div class='old-chat-icon'><div class='text-center' id='cmLivechat_popupButton' style='width:60px;height:60px;border-radius:50%;position: fixed;bottom:15px;right:15px;z-index:2147483648;'></div></div>";$('body').append(windowDiv);if(settingsOptions.v4FontAwesome){templateOptions.livechat.iconActive='fa '+templateOptions.livechat.iconActive.split(' ')[1];templateOptions.livechat.iconInactive='fa '+templateOptions.livechat.iconInactive.split(' ')[1];}
if($('#cmLivechat_popupButton').closest('.old-chat-icon').length){$('#cmLivechat_popupButton').append("<span id='cmLivechat_iconClosed'  style='display:none;'><i><img alt='chat' src='/wp-content/themes/dextera-esensus/images/new/chat-svg.svg'></i></span>");$('#cmLivechat_popupButton').append("<span id='cmLivechat_iconOpen'><i><img alt='chat' src='/wp-content/themes/dextera-esensus/images/new/chat-svg.svg'></i></span>");}
setTimeout(function(){var foundWidthOpen=0;var foundHeightOpen=0;const iconOpen=$('#cmLivechat_iconOpen');const firstChild=iconOpen.children()[0];if(firstChild){if(firstChild.nodeName.toUpperCase()=='I'){foundWidthOpen=Math.ceil(parseInt(firstChild.getBoundingClientRect().width,10));foundHeightOpen=Math.ceil(parseInt(firstChild.getBoundingClientRect().height,10));}else{const nestedChild=$(firstChild).children()[0];if(nestedChild){foundWidthOpen=Math.ceil(parseInt(nestedChild.getBoundingClientRect().width,10));foundHeightOpen=Math.ceil(parseInt(nestedChild.getBoundingClientRect().height,10));}}}
var calculatedMarginOpenLeft=(60-foundWidthOpen)/2;var calculatedMarginOpenTop=(60-foundHeightOpen)/2;const firstChildOpen=$('#cmLivechat_iconOpen').children()[0];if(firstChildOpen){$(firstChildOpen).css('margin-left',calculatedMarginOpenLeft+'px');$(firstChildOpen).css('margin-top',calculatedMarginOpenTop+'px');}
$('#cmLivechat_iconClosed').css('display','initial');var foundWidthClosed=0;var foundHeightClosed=0;const firstChildClosed=$('#cmLivechat_iconClosed').children()[0];if(firstChildClosed){if(firstChildClosed.nodeName.toUpperCase()=='I'){foundWidthClosed=Math.ceil(parseInt(firstChildClosed.getBoundingClientRect().width,10));foundHeightClosed=Math.ceil(parseInt(firstChildClosed.getBoundingClientRect().height,10));}else{const nestedChildClosed=$(firstChildClosed).children()[0];if(nestedChildClosed){foundWidthClosed=Math.ceil(parseInt(nestedChildClosed.getBoundingClientRect().width,10));foundHeightClosed=Math.ceil(parseInt(nestedChildClosed.getBoundingClientRect().height,10));}}}
var calculatedMarginClosedLeft=(60-foundWidthClosed)/2;var calculatedMarginClosedTop=(60-foundHeightClosed)/2;$('#cmLivechat_iconClosed').css('display','none');$($('#cmLivechat_iconClosed').children()[0]).css('margin-left',calculatedMarginClosedLeft+'px');$($('#cmLivechat_iconClosed').children()[0]).css('margin-top',calculatedMarginClosedTop+'px');if(templateOptions.livechat.iconInactive.includes('fa-times')){$('#cmLivechat_iconClosed > svg').css('margin-left','21.5px');$('#cmLivechat_iconClosed > svg').css('margin-top','17.5px');$('#cmLivechat_iconClosed > i').css('margin-left','0px');$('#cmLivechat_iconClosed > i').css('margin-top','16px');}
if(templateOptions.livechat.iconActive.includes('fa-comment')){$('#cmLivechat_iconOpen > i').css('margin-left','0px');$('#cmLivechat_iconOpen > i').css('margin-top','16px');}
if(settingsOptions.v4OlderFontAwesome){$('#cmLivechat_iconClosed > i').css('font-size','26px');$('#cmLivechat_iconOpen > i').css('font-size','26px');$('#cmLivechat_iconOpen > i').css('z-index','2147483648');$('#cmLivechat_iconClosed > i').css('z-index','2147483648');}},100);window.cmLivechatIsOpen=false;$('#cmLivechat_popupButton').click(function(e){e.preventDefault();window.cmLivechatIsOpen=!window.cmLivechatIsOpen;if(window.cmLivechatIsOpen){$('#cmLivechat_iconClosed').css('display','initial');$('#cmLivechat_iconOpen').css('display','none');$('#cmLivechat_container').css('display','initial');$('span[data-cid]').each(function(){var cid=$(this).data('cid');var formedData={chatID:cid,dlrStatus:2};$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});$(this).removeAttr("data-cid");$(this).removeAttr("data-dlr");});var objDiv=document.getElementById("cmLivechat_chat");if(objDiv)
objDiv.scrollTop=objDiv.scrollHeight;}
if(window.cmLivechatIsOpen==false){$('#cmLivechat_iconClosed').css('display','none');$('#cmLivechat_iconOpen').css('display','initial');$('#cmLivechat_container').css('display','none');$('#cmLivechat_igDropper').css('display','none');if($('#cmLivechat_icNWHDropper').css('display')=='none'){$('#cmLivechat_icDropper').css('display','block');$('#cmLivechat_icNWHDropper').css('display','none');}
$('#cmLivechat_container').css('bottom','125px');$('#cmLivechat_container').css('height','405px');}});}
function doGreetings(){if(window.cmLivechatIsOpen==false&&checkCookie('cmLivechat_chatID')==false){$('#cmLivechat_iconClosed').css('display','initial');$('#cmLivechat_iconOpen').css('display','none');$('#cmLivechat_container').css('display','initial');$('span[data-cid]').each(function(){var cid=$(this).data('cid');var formedData={chatID:cid,dlrStatus:2};$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});$(this).removeAttr("data-cid");$(this).removeAttr("data-dlr");});var objDiv=document.getElementById("cmLivechat_chat");if(objDiv)
objDiv.scrollTop=objDiv.scrollHeight;$('#cmLivechat_container').css('bottom','125px');$('#cmLivechat_container').css('height','405px');$('#cmLivechat_igDropper').css('display','block');$('#cmLivechat_icDropper').css('display','none');$('#cmLivechat_icDropperNWH').css('display','none');window.cmLivechatIsOpen=true;}}
function renderWindow(){var cssBtn='display: inline-block;margin-bottom: 0;margin-top:0;margin-left:0.3em;margin-right:0.3em;font-weight: 400;text-align: center;vertical-align: middle;touch-action: manipulation;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 0.7em;line-height: 1.42857143;border-radius: 4px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;height:34px;text-transform:none;text-decoration:none;box-sizing: border-box;font-family: Arial, Helvetica, sans-serif;';var cssFormControl='display: inline-block; width: 85%;height: 20px; padding: 6px 12px;font-size: 0.7em;line-height: 1.42857143;background-color: #fff;background-image: none;border: 1px solid #ccc; border-radius: 4px;-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); box-shadow: inset 0 1px 1px rgba(0,0,0,.075);-webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;  transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;min-height:34px;text-transform:none;text-decoration:none;box-sizing: border-box;font-family: Arial, Helvetica, sans-serif;margin-left:10px;';$('body').append("<div id='cmLivechat_container' style='width:300px;height:400px;position:fixed;bottom:125px;right:23px;display:none;box-sizing:initial;font-size:initial;border-radius:200px;z-index:10000;'></div>");$('#cmLivechat_container').append("<div id='cmLivechat_header' style='background-color: #2E4262;width:300px;height:28px;border-top-left-radius:0;border-top-right-radius:0;'></div>");if(templateOptions.logo!=null){$('#cmLivechat_header').append("<img alt='chat' style='max-width:229px;height:40px;margin:5px;float:left;' src='data: "+JSON.parse(templateOptions.livechat.logo).contentType+";base64,"+templateOptions.logo+"'>");}
$('#cmLivechat_header').append("<span  id='cmLivechat_windowClose'><svg style='float:right;' xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n"+"<path d=\"M2 14H14M8 2V11.3333M8 11.3333L12.6667 6.66667M8 11.3333L3.33333 6.66667\" stroke=\"white\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n"+"</svg></span>");$('#cmLivechat_header').append("<span id='cmLivechat_soundOn'><svg style='float: left;' xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n"+"<path d=\"M10 12.6667C10 13.7713 9.10457 14.6667 8 14.6667C6.89543 14.6667 6 13.7713 6 12.6667M9.19767 4.15908C9.488 3.85913 9.66667 3.45045 9.66667 3.00004C9.66667 2.07957 8.92048 1.33337 8 1.33337C7.07953 1.33337 6.33334 2.07957 6.33334 3.00004C6.33334 3.45045 6.512 3.85913 6.80233 4.15908M1.69788 5.54868C1.68832 4.58112 2.20997 3.67758 3.05269 3.20208M14.3021 5.54868C14.3117 4.58111 13.79 3.67758 12.9473 3.20208M12 7.46671C12 6.54729 11.5786 5.66553 10.8284 5.0154C10.0783 4.36528 9.06087 4.00004 8 4.00004C6.93914 4.00004 5.92172 4.36528 5.17158 5.0154C4.42143 5.66553 4 6.54729 4 7.46671C4 8.98791 3.62276 10.1004 3.15205 10.8965C2.61556 11.8038 2.34732 12.2574 2.35791 12.3658C2.37003 12.4898 2.39235 12.5289 2.4929 12.6024C2.58078 12.6667 3.02234 12.6667 3.90546 12.6667H12.0945C12.9777 12.6667 13.4192 12.6667 13.5071 12.6024C13.6077 12.5289 13.63 12.4898 13.6421 12.3658C13.6527 12.2574 13.3844 11.8038 12.848 10.8965C12.3772 10.1004 12 8.98791 12 7.46671Z\" stroke=\"white\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n"+"</svg></span>");$('#cmLivechat_header').append("<span id='cmLivechat_soundOff' style='display:none;'><svg style='float: left;' xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n"+"<path d=\"M10 12.6667C10 13.7713 9.10457 14.6667 8 14.6667C6.89543 14.6667 6 13.7713 6 12.6667M4.91832 5.25656C4.32725 5.87555 4 6.65651 4 7.46671C4 8.98791 3.62275 10.1004 3.15204 10.8965C2.61556 11.8038 2.34732 12.2574 2.35791 12.3658C2.37003 12.4898 2.39234 12.5289 2.49289 12.6024C2.58078 12.6667 3.02234 12.6667 3.90546 12.6667H13.2533M8 4.00004C7.80473 4.00004 7.61093 4.01242 7.42 4.03666C7.16565 4.06897 7.03847 4.08512 6.91083 4.05042C6.81893 4.02544 6.68038 3.94489 6.6132 3.8774C6.51988 3.78364 6.49948 3.73419 6.45867 3.63529C6.37789 3.43951 6.33333 3.22498 6.33333 3.00004C6.33333 2.07957 7.07953 1.33337 8 1.33337C8.92047 1.33337 9.66667 2.07957 9.66667 3.00004C9.66667 3.45045 9.488 3.85913 9.19767 4.15908C8.81355 4.0546 8.41002 4.00004 8 4.00004ZM8 4.00004C9.06087 4.00004 10.0783 4.36528 10.8284 5.0154C11.5786 5.66553 12 6.54729 12 7.46671C12 7.68989 12.0061 7.90427 12.0176 8.11015M14 13.3334L2 2.66671\" stroke=\"white\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n"+"</svg></span>");$('#cmLivechat_container').append("<div id='cmLivechat_icDropper' style='background-color: "+templateOptions.livechat.fgColor+";width:300px;height:405px;overflow:auto;overflow-x:hidden;padding-left:5px;padding-right:5px;position:relative;'></div>");$('#cmLivechat_container').append("<div id='cmLivechat_icDropperNWH' style='background-color: #fff;width:300px;height:405px;overflow:auto;overflow-x:hidden;padding-left:5px;padding-right:5px;position:relative;display:none'></div>");$('#cmLivechat_container').append("<div id='cmLivechat_igDropper' style='background-color: "+templateOptions.livechat.fgColor+";width:300px;height:405px;overflow:auto;overflow-x:hidden;padding-left:5px;padding-right:5px;position:relative;display:none'></div>");var htmlGreeting='<p class="greetingas" style="border-radius:10px;margin:5px;margin-left:10px;padding:5px;background-color:'+templateOptions.livechat.tdbgColor+';color:'+templateOptions.livechat.tdfcColor+'">'+templateOptions.livechat.initialGreeting+'</p>';htmlGreeting+='<div style="display:flex;justify-content:center;margin:10px;"><button type="button" id="cmLivechat_greetingButton" style="'+cssBtn+' color:'+templateOptions.livechat.mfcColor+';background-color:'+templateOptions.livechat.bgColor+'"  >';var value=templateOptions.livechat.initialGreetingButtonText;htmlGreeting+=value;htmlGreeting+='</button></div>';$('#cmLivechat_igDropper').append(htmlGreeting);$('#cmLivechat_greetingButton').click(function(){$('#cmLivechat_iconClosed').css('display','initial');$('#cmLivechat_iconOpen').css('display','none');$('#cmLivechat_container').css('display','initial');var objDiv=document.getElementById("cmLivechat_chat");if(objDiv)
objDiv.scrollTop=objDiv.scrollHeight;$('#cmLivechat_igDropper').css('display','none');$('#cmLivechat_icDropper').css('display','block');$('#cmLivechat_icNWHDropper').css('display','none');$('#cmLivechat_container').css('bottom','125px');$('#cmLivechat_container').css('height','405px');window.cmLivechatIsOpen=true;});window.cmLivechat_icData=[];window.cmLivechat_icDataNWH=[];var initialData=JSON.parse(templateOptions.livechat.icData);var initialDataNWH=JSON.parse(templateOptions.livechat.icDataNWH);var groups=templateOptions.groups;window.cmLivechat_groups=groups;var htmlToAdd="";var localIdsNWH=[];for(var j=0;j<initialDataNWH.length;j++){var type=initialDataNWH[j].type;var id=initialDataNWH[j].id;var dataText=initialDataNWH[j].data;switch(type){case'text':var alignment=initialDataNWH[j].alignment?'text-align:'+initialDataNWH[j].alignment+';':'';htmlToAdd='<p class="nottherechat" style="'+alignment+'border-radius:10px;margin:5px;margin-left:10px;padding:5px;background-color:'+templateOptions.livechat.tdbgColor+';color:'+templateOptions.livechat.tdfcColor+'" id="'+id+'">'+dataText+'</p>';window.cmLivechat_icDataNWH.push({type:'text',id:id,data:dataText,alignment:initialDataNWH[j].alignment});$('#cmLivechat_icDropperNWH').append(htmlToAdd);break;case'label':var alignment=initialDataNWH[j].alignment?'text-align:'+initialDataNWH[j].alignment+';':'';htmlToAdd='<p style="'+alignment+'margin-top:5px;margin-bottom:5px;margin-left:10px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'">'+dataText+'</p>';window.cmLivechat_icDataNWH.push({type:'label',id:id,data:dataText,alignment:initialDataNWH[j].alignment});$('#cmLivechat_icDropperNWH').append(htmlToAdd);break;case'textinput':var extraRequired='<span '+(initialDataNWH[j].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<input type="text" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialDataNWH[j].value;var placeholder=initialDataNWH[j].placeholder;var name=initialDataNWH[j].name;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';htmlToAdd+='>'+extraRequired;window.cmLivechat_icDataNWH.push({type:'textinput',id:id,name:name,value:value,placeholder:placeholder,required:initialDataNWH[j].required});$('#cmLivechat_icDropperNWH').append(htmlToAdd);localIdsNWH.push(window.cmLivechat_icDataNWH[window.cmLivechat_icDataNWH.length-1].id);if(initialDataNWH[j].required){var scriptText='<script>';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'nickname':var extraRequired='<span '+(initialDataNWH[j].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<input type="text"  data-special="nickname" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialDataNWH[j].value;var placeholder=initialDataNWH[j].placeholder;var name=initialDataNWH[j].name;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';htmlToAdd+='>'+extraRequired;window.cmLivechat_icDataNWH.push({type:'nickname',id:id,name:name,value:value,placeholder:placeholder,required:initialDataNWH[j].required});$('#cmLivechat_icDropperNWH').append(htmlToAdd);localIdsNWH.push(window.cmLivechat_icDataNWH[window.cmLivechat_icDataNWH.length-1].id);if(initialDataNWH[j].required){var scriptText='<script>';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'email':var extraRequired='<span '+(initialDataNWH[j].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<input type="email" data-special="email" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialDataNWH[j].value;var placeholder=initialDataNWH[j].placeholder;var name=initialDataNWH[j].name;var pattern=initialDataNWH[j].pattern;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';if(pattern!='')
htmlToAdd+=' pattern="'+pattern+'"';htmlToAdd+='>'+extraRequired;window.cmLivechat_icDataNWH.push({type:'email',id:id,name:name,value:value,placeholder:placeholder,pattern:pattern,required:initialDataNWH[j].required});$('#cmLivechat_icDropperNWH').append(htmlToAdd);localIdsNWH.push(window.cmLivechat_icDataNWH[window.cmLivechat_icDataNWH.length-1].id);if(initialDataNWH[j].required){var scriptText='<script>';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'number':var label=initialDataNWH[j].label;var extraRequired='<span '+(initialDataNWH[j].required==true?"class='cmLivechat_required'":"")+'></span>';var labelInfo='<label style="color:'+templateOptions.livechat.fcColor+'">'+label;htmlToAdd=labelInfo+'<input type="tel" data-special="number" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;margin-left:10px;display:inline-block;width:70%;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialDataNWH[j].value;var placeholder=initialDataNWH[j].placeholder;var name=initialDataNWH[j].name;var pattern=initialDataNWH[j].pattern;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';if(pattern!='')
htmlToAdd+=' pattern="'+pattern+'"';htmlToAdd+='>';htmlToAdd+=extraRequired+'</label>';window.cmLivechat_icDataNWH.push({type:'number',id:id,name:name,value:value,placeholder:placeholder,pattern:pattern,label:label,required:initialDataNWH[j].required});$('#cmLivechat_icDropperNWH').append(htmlToAdd);localIdsNWH.push(window.cmLivechat_icDataNWH[window.cmLivechat_icDataNWH.length-1].id);if(initialDataNWH[j].required){var scriptText='<script>';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'textarea':var extraRequired='<span '+(initialDataNWH[j].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<textarea rows="5" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;resize: none;height:initial;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialDataNWH[j].value;var placeholder=initialDataNWH[j].placeholder;var name=initialDataNWH[j].name;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';htmlToAdd+='></textarea>'+extraRequired;window.cmLivechat_icDataNWH.push({type:'textarea',id:id,name:name,value:value,placeholder:placeholder,required:initialDataNWH[j].required});$('#cmLivechat_icDropperNWH').append(htmlToAdd);localIdsNWH.push(window.cmLivechat_icDataNWH[window.cmLivechat_icDataNWH.length-1].id);if(initialDataNWH[j].required){var scriptText='<script>';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIdsNWH[localIdsNWH.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'dropdown':var name=initialDataNWH[j].name;var extraRequired='<span '+(initialDataNWH[j].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<select name="'+name+'" style="'+cssFormControl+'color:'+templateOptions.livechat.fcColor+';margin-top:5px;margin-bottom:5px;height:34px;width:99%" >';var dataArray=initialDataNWH[j].options;for(var z=0;z<dataArray.length;z++)
htmlToAdd+='<option value="'+dataArray[z]+'">'+dataArray[z]+'</option>';htmlToAdd+='</select>'+extraRequired;window.cmLivechat_icDataNWH.push({type:'dropdown',id:id,name:name,options:dataArray});$('#cmLivechat_icDropperNWH').append(htmlToAdd);break;case'group_dropdown':var extraRequired='<span '+(initialDataNWH[j].required==true?"class='cmLivechat_required'":"")+'></span>';var name=initialDataNWH[j].name;htmlToAdd='<select id="'+id+'" data-type="group_dd" name="'+name+'" style="'+cssFormControl+' color:'+templateOptions.livechat.fcColor+';margin-top:5px;margin-bottom:5px;height:34px;width:85%;" >';for(var d=0;d<groups.length;d++)
htmlToAdd+='<option value="'+groups[d]._id+'">'+groups[d].name+'</option>';htmlToAdd+='</select>'+extraRequired;window.cmLivechat_icDataNWH.push({type:'group_dropdown',id:id,name:name});$('#cmLivechat_icDropperNWH').append(htmlToAdd);break;case'submit_btn':htmlToAdd='<div style="display:flex;justify-content:center;margin:10px;"><button  id="'+id+'" type="text"  style="'+cssBtn+' color:'+templateOptions.livechat.mfcColor+';background-color:'+templateOptions.livechat.bgColor+'"  >';var value=initialDataNWH[j].value;htmlToAdd+=value;htmlToAdd+='</button></div>';window.cmLivechat_icDataNWH.push({type:'submit_btn',id:id,value:value});$('#cmLivechat_icDropperNWH').append(htmlToAdd);$('#'+id.toString()).click(function(){var dataToSend={};var ts=Math.round((new Date()).getTime()/1000).toString()+
Math.floor(Math.random()*101).toString();dataToSend.appid=window.cmLivechat_appid;dataToSend.chatID=ts;dataToSend.type="INCOMING";dataToSend.status="UNREPLIED";dataToSend.isReplied=false;dataToSend.isAutoreply=false;dataToSend.inReplyTo=null;dataToSend.repliedAt=null;dataToSend.isFirst=true;dataToSend.initialData=[];dataToSend.from="";var allGoodNWH=true;for(var j=0;j<window.cmLivechat_icDataNWH.length;j++){var type=window.cmLivechat_icDataNWH[j].type;switch(type){case'nickname':if(window.cmLivechat_icDataNWH[j].required==true&&$('#'+window.cmLivechat_icDataNWH[j].id).val().trim()==''){allGoodNWH=false;$('#'+window.cmLivechat_icDataNWH[j].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'nickname',name:window.cmLivechat_icDataNWH[j].name,value:$('#'+window.cmLivechat_icDataNWH[j].id).val()});break;case'email':dataToSend.from=$('#'+window.cmLivechat_icDataNWH[j].id).val();if($('#'+window.cmLivechat_icDataNWH[j].id).attr('pattern')!=''&&$('#'+window.cmLivechat_icDataNWH[j].id).attr('pattern')!=undefined){var pattern=new RegExp($('#'+window.cmLivechat_icDataNWH[j].id).attr('pattern'),'gi');if(pattern.test($('#'+window.cmLivechat_icDataNWH[j].id).val())==false)
$('#'+window.cmLivechat_icDataNWH[j].id).css('background-color',templateOptions.livechat.errorColor);allGoodNWH=false;}
if(window.cmLivechat_icDataNWH[j].required==true&&$('#'+window.cmLivechat_icDataNWH[j].id).val().trim()==''){allGoodNWH=false;$('#'+window.cmLivechat_icDataNWH[j].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'email',name:window.cmLivechat_icDataNWH[j].name,value:$('#'+window.cmLivechat_icDataNWH[j].id).val()});break;case'number':if($('#'+window.cmLivechat_icDataNWH[j].id).attr('pattern')!=''&&$('#'+window.cmLivechat_icDataNWH[j].id).attr('pattern')!=undefined){var pattern=new RegExp($('#'+window.cmLivechat_icDataNWH[j].id).attr('pattern'),'gi');if(pattern.test($('#'+window.cmLivechat_icDataNWH[j].id).val())==false){$('#'+window.cmLivechat_icDataNWH[j].id).css('background-color',templateOptions.livechat.errorColor);allGoodNWH=false;}}
if(window.cmLivechat_icDataNWH[j].required==true&&$('#'+window.cmLivechat_icDataNWH[j].id).val().trim()==''){allGoodNWH=false;$('#'+window.cmLivechat_icDataNWH[j].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'number',name:window.cmLivechat_icDataNWH[j].name,value:$('#'+window.cmLivechat_icDataNWH[j].id).val(),label:$('#'+window.cmLivechat_icDataNWH[j].id)[0].parentElement.nodeName=="LABEL"?$($('#'+window.cmLivechat_icDataNWH[j].id)[0].parentElement).contents().first()[0].textContent:""});break;case'group_dropdown':dataToSend.to=$('#'+window.cmLivechat_icDataNWH[j].id).val();break;case'dropdown':dataToSend.initialData.push({type:'dropdown',name:window.cmLivechat_icDataNWH[j].name,value:$('#'+window.cmLivechat_icDataNWH[j].id).val()});break;case'textinput':if(window.cmLivechat_icDataNWH[j].required==true&&$('#'+window.cmLivechat_icDataNWH[j].id).val().trim()==''){allGoodNWH=false;$('#'+window.cmLivechat_icDataNWH[j].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'textinput',name:window.cmLivechat_icDataNWH[j].name,value:$('#'+window.cmLivechat_icDataNWH[j].id).val()});break;case'textarea':if(window.cmLivechat_icDataNWH[j].required==true&&$('#'+window.cmLivechat_icDataNWH[j].id).val().trim()==''){allGoodNWH=false;$('#'+window.cmLivechat_icDataNWH[j].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'textarea',name:window.cmLivechat_icDataNWH[j].name,value:$('#'+window.cmLivechat_icDataNWH[j].id).val()});break;}}
if(allGoodNWH==false){return;}
if(dataToSend.to==''||dataToSend.to==undefined||dataToSend.to==null)
dataToSend.to=window.cmLivechat_groups[0]._id;setCookie('cmLivechat_chatID',ts);dataToSend.initialData=JSON.stringify(dataToSend.initialData);window.cmLivechat_reconnect_interval_id=null;window.cmLivechat_connect=function(){window.cmLivechat_socket={};window.cmLivechat_socket.onListeners=[];window.cmLivechat_socket.deferred=[];window.cmLivechat_socket.on=function(msg,callbackFn){window.cmLivechat_socket.onListeners.push({msg:msg,callbackFn:callbackFn});}
window.cmLivechat_socket.emit=function(msg,data){var formedData={msg:msg,data:data,evt:'emit',chan:'uws_server'};if(window.cmLivechat_socket.ws!=null&&(window.cmLivechat_socket.ws.readyState==1))
window.cmLivechat_socket.ws.send(JSON.stringify(formedData));else
window.cmLivechat_socket.deferred.push(JSON.stringify(formedData));};var websocket=new WebSocket(window.cmLivechat_socketUrl);websocket.onopen=function(event){for(var i=0;i<window.cmLivechat_socket.deferred.length;i++){window.cmLivechat_socket.ws.send(window.cmLivechat_socket.deferred[i]);}
window.cmLivechat_socket.deferred=[];clearInterval(window.cmLivechat_reconnect_interval_id);window.cmLivechat_reconnect_interval_id=null;$.getJSON(window.cmLivechat_siteUrl+'/livechat/chathistory_reconnect/'+getCookie('cmLivechat_chatID'),function(data){$('#cmLivechat_chat').html("");var messages=data.messages;for(var z=0;z<messages.length;z++){var formattedDate='<span style="font-size:0.6em;">'+messages[z].name+' '+(new Date(messages[z].date).getHours()<10?'0'+new Date(messages[z].date).getHours():new Date(messages[z].date).getHours())+":"+(new Date(messages[z].date).getMinutes()<10?'0'+new Date(messages[z].date).getMinutes():new Date(messages[z].date).getMinutes())+"</span><br>";if(messages[z].type=='INCOMING'&&messages[z].text!=undefined){var dlrStatus="<span style='margin-left:5px;font-size:0.9em;font-weight:bold;' id='"+messages[z].chatID+"'>";if(messages[z].dlrStatus==0)
dlrStatus+='🗸';if(messages[z].dlrStatus==1)
dlrStatus+='🗸<span style="font-size:0.8em;">🗸</span>';if(messages[z].dlrStatus==2)
dlrStatus+='<span style="color:'+templateOptions.livechat.readColor+'">🗸<span style="font-size:0.8em;">🗸</span></span>';formattedDate='<span style="font-size:0.6em;">'+messages[z].name+' '+(new Date(messages[z].date).getHours()<10?'0'+new Date(messages[z].date).getHours():new Date(messages[z].date).getHours())+":"+(new Date(messages[z].date).getMinutes()<10?'0'+new Date(messages[z].date).getMinutes():new Date(messages[z].date).getMinutes())+"</span>"+dlrStatus+"<br>";$('#cmLivechat_chat').append('<span  class="atsakymas" style="color:'+templateOptions.livechat.csfcColor+';background-color: '+templateOptions.livechat.csbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:right;position:relative;margin-left:30px; word-break:break-word;">'+formattedDate+messages[z].text+'</span><br style="clear:both;">');}else{if(messages[z].text!=undefined){var formedDlr=1;if($('#cmLivechat_container').css('display')!='none')formedDlr=2;var formedData={chatID:messages[z].chatID,dlrStatus:formedDlr};$('#cmLivechat_chat').append('<span data-cid="'+messages[z].chatID+'" data-dlr="'+formedDlr+'" style="color:'+templateOptions.livechat.crfcColor+';background-color:'+templateOptions.livechat.crbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:left;position:relative;margin-right:30px; word-break: break-word;">'+formattedDate+messages[z].text+'</span><br style="clear:both;">');$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});}}}});};websocket.onmessage=function(event){var msg=JSON.parse(event.data);for(var i=0;i<window.cmLivechat_socket.onListeners.length;i++){if(window.cmLivechat_socket.onListeners[i].msg==msg.msg)
window.cmLivechat_socket.onListeners[i].callbackFn(msg.data);}};websocket.onclose=function(event){for(var i=0;i<window.cmLivechat_socket.onListeners.length;i++){if(window.cmLivechat_socket.onListeners[i].msg=='disconnect')
window.cmLivechat_socket.onListeners[i].callbackFn(null);}
if(window.cmLivechat_reconnect_interval_id==null)
window.cmLivechat_reconnect_interval_id=setInterval(function(){console.log("SOCKET RECONNECTING");window.cmLivechat_connect();},15000);};websocket.onerror=function(event){};window.cmLivechat_socket.ws=websocket;window.cmLivechat_socket.emit('cmLivechat_Online',{chatID:getCookie('cmLivechat_chatID')});window.cmLivechat_socket.on('cmLivechat_message',function(data){setTimeout(function(){var formedDlr=1;if($('#cmLivechat_container').css('display')!='none')formedDlr=2;var formedData={chatID:data.chatID,dlrStatus:formedDlr};$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});},300);var formattedDate='<span style="font-size:0.6em;">'+data.name+' '+(new Date(data.date).getHours()<10?'0'+new Date(data.date).getHours():new Date(data.date).getHours())+":"+(new Date(data.date).getMinutes()<10?'0'+new Date(data.date).getMinutes():new Date(data.date).getMinutes())+"</span><br>";$('#cmLivechat_chat').append('<span style="color:'+templateOptions.livechat.crfcColor+';background-color:'+templateOptions.livechat.crbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:left;position:relative;margin-right:30px; word-break: break-word;">'+formattedDate+data.text+'</span><br style="clear:both;">');var elem=document.getElementById('cmLivechat_chat');elem.scrollTop=elem.scrollHeight;window.cmLivechatIsOpen=true;if(window.cmLivechatIsOpen){$('#cmLivechat_iconClosed').css('display','initial');$('#cmLivechat_iconOpen').css('display','none');$('#cmLivechat_container').css('display','initial');}
if(window.cmLivechat_soundWorks)
playAudio();});window.cmLivechat_socket.on('cmLivechat_statusUpdate',function(data){$('#'+data.chatID).html("");var formatedDlr="";if(data.dlrStatus==0)
formatedDlr='🗸';if(data.dlrStatus==1)
formatedDlr='🗸<span style="font-size:0.8em;">🗸</span>';if(data.dlrStatus==2)
formatedDlr='<span style="color:'+templateOptions.livechat.readColor+'">🗸<span style="font-size:0.8em;">🗸</span></span>';$('#'+data.chatID).html(formatedDlr);});};window.cmLivechat_connect();$.post(window.cmLivechat_siteUrl+'/livechat/api/create',dataToSend,function(data){$('#cmLivechat_icDropperNWH').empty();$('#cmLivechat_icDropperNWH').css('display','none');$('#cmLivechat_icDropper').css('display','block');$('#cmLivechat_icDropper').empty();$('#cmLivechat_icDropper').append('<textarea rows="5" id="cmLivechat_chatMessage" type="text" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+';width:97% !important;position:absolute;bottom:22px;resize: none;margin-left:0px;height:90px;" ></textarea>');$('#cmLivechat_icDropper').append('<button id="cmLivechat_sendChatMessage" type="button" style="'+cssBtn+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+';width:auto;height:34px;padding:0;background-color:transparent;position:absolute;bottom:0px;margin:0;right:0px;font-size:23px;text-transform:none;">Siųsti</button>');$('#cmLivechat_icDropper').append("<div id='cmLivechat_chat' style='background-color: "+templateOptions.livechat.fgColor+";width:300px;height:280px;overflow:auto;padding-left:5px;padding-right:5px;position:relative;'></div>");var input=document.getElementById("cmLivechat_chatMessage");input.addEventListener("keyup",function(event){if(event.key==="Enter"){if(event.shiftKey){}else{event.preventDefault();document.getElementById("cmLivechat_sendChatMessage").click();}}});$('#cmLivechat_sendChatMessage').click(function(){if($('#cmLivechat_chatMessage').val().trim()=="")return;var dataToSend={};var ts=Math.round((new Date()).getTime()/1000).toString()+
Math.floor(Math.random()*101).toString();dataToSend.appid=window.cmLivechat_appid;dataToSend.chatID=ts;dataToSend.type="INCOMING";dataToSend.status="UNREPLIED";dataToSend.isReplied=false;dataToSend.isAutoreply=false;dataToSend.inReplyTo=null;dataToSend.repliedAt=null;dataToSend.isFirst=false;dataToSend.body=$('#cmLivechat_chatMessage').val().replace(/(?:\r\n|\r|\n)/g,'<br>');dataToSend.initialData=[];dataToSend.from="";dataToSend.initialChatID=getCookie('cmLivechat_chatID');dataToSend.dlrStatus=0;var formattedDate='<span style="font-size:0.6em;">'+(new Date().getHours()<10?'0'+new Date().getHours():new Date().getHours())+":"+(new Date().getMinutes()<10?'0'+new Date().getMinutes():new Date().getMinutes())+"</span><span style='margin-left:5px;font-size:0.9em;font-weight:bold;' id='"+ts+"'>🗸</span>"+"<br>";$('#cmLivechat_chat').append('<span  class="atsakymas" style="color:'+templateOptions.livechat.csfcColor+';background-color: '+templateOptions.livechat.csbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:right;position:relative;margin-left:30px; word-break: break-word;">'+formattedDate+$('#cmLivechat_chatMessage').val().replace(/(?:\r\n|\r|\n)/g,'<br>')+'</span><br style="clear:both;">');$('#cmLivechat_chatMessage').val("");var elem=document.getElementById('cmLivechat_chat');elem.scrollTop=elem.scrollHeight;$.post(window.cmLivechat_siteUrl+'/livechat/api/create',dataToSend,function(data){});});});});break;}}
htmlToAdd="";var localIds=[];for(var i=0;i<initialData.length;i++){var type=initialData[i].type;var id=initialData[i].id;var dataText=initialData[i].data;switch(type){case'text':var alignment=initialData[i].alignment?'text-align:'+initialData[i].alignment+';':'';htmlToAdd='<p style="'+alignment+'border-radius:10px;margin:5px;margin-left:10px;padding:5px;background-color:'+templateOptions.livechat.tdbgColor+';color:'+templateOptions.livechat.tdfcColor+'" id="'+id+'">'+dataText+'</p>';window.cmLivechat_icData.push({type:'text',id:id,data:dataText,alignment:initialData[i].alignment});$('#cmLivechat_icDropper').append(htmlToAdd);break;case'label':var alignment=initialData[i].alignment?'text-align:'+initialData[i].alignment+';':'';htmlToAdd='<p style="'+alignment+'margin-top:5px;margin-bottom:5px;margin-left:10px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'">'+dataText+'</p>';window.cmLivechat_icData.push({type:'label',id:id,data:dataText,alignment:initialData[i].alignment});$('#cmLivechat_icDropper').append(htmlToAdd);break;case'textinput':var extraRequired='<span '+(initialData[i].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<input type="text" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialData[i].value;var placeholder=initialData[i].placeholder;var name=initialData[i].name;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';htmlToAdd+='>'+extraRequired;window.cmLivechat_icData.push({type:'textinput',id:id,name:name,value:value,placeholder:placeholder,required:initialData[i].required});$('#cmLivechat_icDropper').append(htmlToAdd);localIds.push(window.cmLivechat_icData[window.cmLivechat_icData.length-1].id);if(initialData[i].required){var scriptText='<script>';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIds[localIds.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'nickname':var extraRequired='<span '+(initialData[i].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<input type="text"  data-special="nickname" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialData[i].value;var placeholder=initialData[i].placeholder;var name=initialData[i].name;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';htmlToAdd+='>'+extraRequired;window.cmLivechat_icData.push({type:'nickname',id:id,name:name,value:value,placeholder:placeholder,required:initialData[i].required});$('#cmLivechat_icDropper').append(htmlToAdd);localIds.push(window.cmLivechat_icData[window.cmLivechat_icData.length-1].id);if(initialData[i].required){var scriptText='<script>';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIds[localIds.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'email':var extraRequired='<span '+(initialData[i].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<input type="email" data-special="email" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialData[i].value;var placeholder=initialData[i].placeholder;var name=initialData[i].name;var pattern=initialData[i].pattern;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';if(pattern!='')
htmlToAdd+=' pattern="'+pattern+'"';htmlToAdd+='>'+extraRequired;window.cmLivechat_icData.push({type:'email',id:id,name:name,value:value,placeholder:placeholder,pattern:pattern,required:initialData[i].required});$('#cmLivechat_icDropper').append(htmlToAdd);localIds.push(window.cmLivechat_icData[window.cmLivechat_icData.length-1].id);if(initialData[i].required){var scriptText='<script>';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIds[localIds.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'number':var label=initialData[i].label;var extraRequired='<span '+(initialData[i].required==true?"class='cmLivechat_required'":"")+'></span>';var labelInfo='<label style="color:'+templateOptions.livechat.fcColor+'">'+label;htmlToAdd=labelInfo+'<input type="tel" data-special="number" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;margin-left:10px;display:inline-block;width:70%;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialData[i].value;var placeholder=initialData[i].placeholder;var name=initialData[i].name;var pattern=initialData[i].pattern;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';if(pattern!='')
htmlToAdd+=' pattern="'+pattern+'"';htmlToAdd+='>';htmlToAdd+=extraRequired+'</label>';window.cmLivechat_icData.push({type:'number',id:id,name:name,value:value,placeholder:placeholder,pattern:pattern,label:label,required:initialData[i].required});$('#cmLivechat_icDropper').append(htmlToAdd);localIds.push(window.cmLivechat_icData[window.cmLivechat_icData.length-1].id);if(initialData[i].required){var scriptText='<script>';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIds[localIds.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'textarea':var extraRequired='<span '+(initialData[i].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<textarea rows="5" style="'+cssFormControl+' margin-top:5px;resize: none;height:initial;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+'" id="'+id+'"';var value=initialData[i].value;var placeholder=initialData[i].placeholder;var name=initialData[i].name;if(value!='')
htmlToAdd+=' value="'+value+'"';if(placeholder!='')
htmlToAdd+=' placeholder="'+placeholder+'"';if(name!='')
htmlToAdd+=' name="'+name+'"';htmlToAdd+='></textarea>'+extraRequired;window.cmLivechat_icData.push({type:'textarea',id:id,name:name,value:value,placeholder:placeholder,required:initialData[i].required});$('#cmLivechat_icDropper').append(htmlToAdd);localIds.push(window.cmLivechat_icData[window.cmLivechat_icData.length-1].id);if(initialData[i].required){var scriptText='<script>';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").on("input propertychange change",function()';scriptText+='{';scriptText+='if($("#'+localIds[localIds.length-1].toString()+'").val()!="")';scriptText+='{';scriptText+='$("#'+localIds[localIds.length-1].toString()+'").css("background-color","#fff");';scriptText+='}';scriptText+='});';scriptText+='<\/script>';$('#cmLivechat_icDropper').append(scriptText);}
break;case'dropdown':var name=initialData[i].name;var extraRequired='<span '+(initialData[i].required==true?"class='cmLivechat_required'":"")+'></span>';htmlToAdd='<select name="'+name+'" style="'+cssFormControl+'color:'+templateOptions.livechat.fcColor+';margin-top:5px;margin-bottom:5px;height:34px;width:99%" >';var dataArray=initialData[i].options;for(var z=0;z<dataArray.length;z++)
htmlToAdd+='<option value="'+dataArray[z]+'">'+dataArray[z]+'</option>';htmlToAdd+='</select>'+extraRequired;window.cmLivechat_icData.push({type:'dropdown',id:id,name:name,options:dataArray});$('#cmLivechat_icDropper').append(htmlToAdd);break;case'group_dropdown':var extraRequired='<span '+(initialData[i].required==true?"class='cmLivechat_required'":"")+'></span>';var name=initialData[i].name;htmlToAdd='<select id="'+id+'" data-type="group_dd" name="'+name+'" style="'+cssFormControl+' color:'+templateOptions.livechat.fcColor+';margin-top:5px;margin-bottom:5px;height:34px;width:85%" >';for(var d=0;d<groups.length;d++)
htmlToAdd+='<option value="'+groups[d]._id+'">'+groups[d].name+'</option>';htmlToAdd+='</select>'+extraRequired;window.cmLivechat_icData.push({type:'group_dropdown',id:id,name:name});$('#cmLivechat_icDropper').append(htmlToAdd);break;case'submit_btn':htmlToAdd='<div style="display:flex;justify-content:center;margin:10px;"><button  id="'+id+'" type="text"  style="'+cssBtn+' color:'+templateOptions.livechat.mfcColor+';background-color:'+templateOptions.livechat.bgColor+'"  >';var value=initialData[i].value;htmlToAdd+=value;htmlToAdd+='</button></div>';window.cmLivechat_icData.push({type:'submit_btn',id:id,value:value});$('#cmLivechat_icDropper').append(htmlToAdd);$('#'+id.toString()).click(function(){var dataToSend={};var ts=Math.round((new Date()).getTime()/1000).toString()+
Math.floor(Math.random()*101).toString();dataToSend.appid=window.cmLivechat_appid;dataToSend.chatID=ts;dataToSend.type="INCOMING";dataToSend.status="UNREPLIED";dataToSend.isReplied=false;dataToSend.isAutoreply=false;dataToSend.inReplyTo=null;dataToSend.repliedAt=null;dataToSend.isFirst=true;dataToSend.initialData=[];dataToSend.from="";var allGood=true;for(var i=0;i<window.cmLivechat_icData.length;i++){var type=window.cmLivechat_icData[i].type;switch(type){case'nickname':if(window.cmLivechat_icData[i].required==true&&$('#'+window.cmLivechat_icData[i].id).val().trim()==''){allGood=false;$('#'+window.cmLivechat_icData[i].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'nickname',name:window.cmLivechat_icData[i].name,value:$('#'+window.cmLivechat_icData[i].id).val()});break;case'email':dataToSend.from=$('#'+window.cmLivechat_icData[i].id).val();if($('#'+window.cmLivechat_icData[i].id).attr('pattern')!=''&&$('#'+window.cmLivechat_icData[i].id).attr('pattern')!=undefined){var pattern=new RegExp($('#'+window.cmLivechat_icData[i].id).attr('pattern'),'gi');if(pattern.test($('#'+window.cmLivechat_icData[i].id).val())==false)
$('#'+window.cmLivechat_icData[i].id).css('background-color',templateOptions.livechat.errorColor);allGood=false;}
if(window.cmLivechat_icData[i].required==true&&$('#'+window.cmLivechat_icData[i].id).val().trim()==''){allGood=false;$('#'+window.cmLivechat_icData[i].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'email',name:window.cmLivechat_icData[i].name,value:$('#'+window.cmLivechat_icData[i].id).val()});break;case'number':if($('#'+window.cmLivechat_icData[i].id).attr('pattern')!=''&&$('#'+window.cmLivechat_icData[i].id).attr('pattern')!=undefined){var pattern=new RegExp($('#'+window.cmLivechat_icData[i].id).attr('pattern'),'gi');if(pattern.test($('#'+window.cmLivechat_icData[i].id).val())==false){$('#'+window.cmLivechat_icData[i].id).css('background-color',templateOptions.livechat.errorColor);allGood=false;}}
if(window.cmLivechat_icData[i].required==true&&$('#'+window.cmLivechat_icData[i].id).val().trim()==''){allGood=false;$('#'+window.cmLivechat_icData[i].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'number',name:window.cmLivechat_icData[i].name,value:$('#'+window.cmLivechat_icData[i].id).val(),label:$('#'+window.cmLivechat_icData[i].id)[0].parentElement.nodeName=="LABEL"?$($('#'+window.cmLivechat_icData[i].id)[0].parentElement).contents().first()[0].textContent:""});break;case'group_dropdown':dataToSend.to=$('#'+window.cmLivechat_icData[i].id).val();break;case'dropdown':dataToSend.initialData.push({type:'dropdown',name:window.cmLivechat_icData[i].name,value:$('#'+window.cmLivechat_icData[i].id).val()});break;case'textinput':if(window.cmLivechat_icData[i].required==true&&$('#'+window.cmLivechat_icData[i].id).val().trim()==''){allGood=false;$('#'+window.cmLivechat_icData[i].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'textinput',name:window.cmLivechat_icData[i].name,value:$('#'+window.cmLivechat_icData[i].id).val()});break;case'textarea':if(window.cmLivechat_icData[i].required==true&&$('#'+window.cmLivechat_icData[i].id).val().trim()==''){allGood=false;$('#'+window.cmLivechat_icData[i].id).css('background-color',templateOptions.livechat.errorColor);}
dataToSend.initialData.push({type:'textarea',name:window.cmLivechat_icData[i].name,value:$('#'+window.cmLivechat_icData[i].id).val()});break;}}
if(allGood==false){return;}
if(dataToSend.to==''||dataToSend.to==undefined||dataToSend.to==null)
dataToSend.to=window.cmLivechat_groups[0]._id;setCookie('cmLivechat_chatID',ts);dataToSend.initialData=JSON.stringify(dataToSend.initialData);window.cmLivechat_reconnect_interval_id=null;window.cmLivechat_connect=function(){window.cmLivechat_socket={};window.cmLivechat_socket.onListeners=[];window.cmLivechat_socket.deferred=[];window.cmLivechat_socket.on=function(msg,callbackFn){window.cmLivechat_socket.onListeners.push({msg:msg,callbackFn:callbackFn});}
window.cmLivechat_socket.emit=function(msg,data){var formedData={msg:msg,data:data,evt:'emit',chan:'uws_server'};if(window.cmLivechat_socket.ws!=null&&(window.cmLivechat_socket.ws.readyState==1))
window.cmLivechat_socket.ws.send(JSON.stringify(formedData));else
window.cmLivechat_socket.deferred.push(JSON.stringify(formedData));};var websocket=new WebSocket(window.cmLivechat_socketUrl);websocket.onopen=function(event){for(var i=0;i<window.cmLivechat_socket.deferred.length;i++){window.cmLivechat_socket.ws.send(window.cmLivechat_socket.deferred[i]);}
window.cmLivechat_socket.deferred=[];clearInterval(window.cmLivechat_reconnect_interval_id);window.cmLivechat_reconnect_interval_id=null;$.getJSON(window.cmLivechat_siteUrl+'/livechat/chathistory_reconnect/'+getCookie('cmLivechat_chatID'),function(data){$('#cmLivechat_chat').html("");var messages=data.messages;for(var z=0;z<messages.length;z++){var formattedDate='<span style="font-size:0.6em;">'+messages[z].name+' '+(new Date(messages[z].date).getHours()<10?'0'+new Date(messages[z].date).getHours():new Date(messages[z].date).getHours())+":"+(new Date(messages[z].date).getMinutes()<10?'0'+new Date(messages[z].date).getMinutes():new Date(messages[z].date).getMinutes())+"</span><br>";if(messages[z].type=='INCOMING'&&messages[z].text!=undefined){var dlrStatus="<span style='margin-left:5px;font-size:0.9em;font-weight:bold;' id='"+messages[z].chatID+"'>";if(messages[z].dlrStatus==0)
dlrStatus+='🗸';if(messages[z].dlrStatus==1)
dlrStatus+='🗸<span style="font-size:0.8em;">🗸</span>';if(messages[z].dlrStatus==2)
dlrStatus+='<span style="color:'+templateOptions.livechat.readColor+'">🗸<span style="font-size:0.8em;">🗸</span></span>';dlrStatus+='</span>';formattedDate='<span style="font-size:0.6em;">'+messages[z].name+' '+(new Date(messages[z].date).getHours()<10?'0'+new Date(messages[z].date).getHours():new Date(messages[z].date).getHours())+":"+(new Date(messages[z].date).getMinutes()<10?'0'+new Date(messages[z].date).getMinutes():new Date(messages[z].date).getMinutes())+"</span>"+dlrStatus+"<br>";$('#cmLivechat_chat').append('<span  class="atsakymas" style="color:'+templateOptions.livechat.csfcColor+';background-color: '+templateOptions.livechat.csbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:right;position:relative;margin-left:30px; word-break:break-word;">'+formattedDate+messages[z].text+'</span><br style="clear:both;">');}else{if(messages[z].text!=undefined){var formedDlr=1;if($('#cmLivechat_container').css('display')!='none')formedDlr=2;var formedData={chatID:messages[z].chatID,dlrStatus:formedDlr};$('#cmLivechat_chat').append('<span data-cid="'+messages[z].chatID+'" data-dlr="'+formedDlr+'" style="color:'+templateOptions.livechat.crfcColor+';background-color:'+templateOptions.livechat.crbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:left;position:relative;margin-right:30px; word-break: break-word;">'+formattedDate+messages[z].text+'</span><br style="clear:both;">');$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});}}}});};websocket.onmessage=function(event){var msg=JSON.parse(event.data);console.log(msg);for(var i=0;i<window.cmLivechat_socket.onListeners.length;i++){if(window.cmLivechat_socket.onListeners[i].msg==msg.msg)
window.cmLivechat_socket.onListeners[i].callbackFn(msg.data);}};websocket.onclose=function(event){for(var i=0;i<window.cmLivechat_socket.onListeners.length;i++){if(window.cmLivechat_socket.onListeners[i].msg=='disconnect')
window.cmLivechat_socket.onListeners[i].callbackFn(null);}
if(window.cmLivechat_reconnect_interval_id==null)
window.cmLivechat_reconnect_interval_id=setInterval(function(){window.cmLivechat_connect();},15000);};websocket.onerror=function(event){};window.cmLivechat_socket.ws=websocket;window.cmLivechat_socket.emit('cmLivechat_Online',{chatID:getCookie('cmLivechat_chatID')});window.cmLivechat_socket.on('cmLivechat_message',function(data){setTimeout(function(){var formedDlr=1;if($('#cmLivechat_container').css('display')!='none')formedDlr=2;var formedData={chatID:data.chatID,dlrStatus:formedDlr};$.post(window.cmLivechat_siteUrl+'/livechat/api/status/update',formedData,function(data){});},300);var formattedDate='<span style="font-size:0.6em;">'+data.name+' '+(new Date(data.date).getHours()<10?'0'+new Date(data.date).getHours():new Date(data.date).getHours())+":"+(new Date(data.date).getMinutes()<10?'0'+new Date(data.date).getMinutes():new Date(data.date).getMinutes())+"</span><br>";$('#cmLivechat_chat').append('<span style="color:'+templateOptions.livechat.crfcColor+';background-color:'+templateOptions.livechat.crbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:left;position:relative;margin-right:30px; word-break: break-word;">'+formattedDate+data.text+'</span><br style="clear:both;">');var elem=document.getElementById('cmLivechat_chat');elem.scrollTop=elem.scrollHeight;window.cmLivechatIsOpen=true;if(window.cmLivechatIsOpen){$('#cmLivechat_iconClosed').css('display','initial');$('#cmLivechat_iconOpen').css('display','none');$('#cmLivechat_container').css('display','initial');}
if(window.cmLivechat_soundWorks)
playAudio();});window.cmLivechat_socket.on('cmLivechat_statusUpdate',function(data){$('#'+data.chatID).html("");var formatedDlr="";if(data.dlrStatus==0)
formatedDlr='🗸';if(data.dlrStatus==1)
formatedDlr='🗸<span style="font-size:0.8em;">🗸</span>';if(data.dlrStatus==2)
formatedDlr='<span style="color:'+templateOptions.livechat.readColor+'">🗸<span style="font-size:0.8em;">🗸</span></span>';$('#'+data.chatID).html(formatedDlr);});};window.cmLivechat_connect();$.post(window.cmLivechat_siteUrl+'/livechat/api/create',dataToSend,function(data){$('#cmLivechat_icDropper').empty();$('#cmLivechat_icDropper').append('<textarea rows="5" id="cmLivechat_chatMessage" type="text" style="'+cssFormControl+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+';width:97% !important;position:absolute;bottom:22px;resize: none;margin-left:0px;height:90px;" ></textarea>');$('#cmLivechat_icDropper').append('<button id="cmLivechat_sendChatMessage" type="button" style="'+cssBtn+' margin-top:5px;margin-bottom:5px;color:'+templateOptions.livechat.fcColor+';width:auto;height:34px;padding:0;background-color:transparent;position:absolute;bottom:0px;margin:0;right:0px;font-size:23px;text-transform:none;">Siųsti</button>');$('#cmLivechat_icDropper').append("<div id='cmLivechat_chat' style='background-color: "+templateOptions.livechat.fgColor+";width:300px;height:280px;overflow:auto;padding-left:5px;padding-right:5px;position:relative;'></div>");var input=document.getElementById("cmLivechat_chatMessage");input.addEventListener("keyup",function(event){if(event.key==="Enter"){if(event.shiftKey){}else{event.preventDefault();document.getElementById("cmLivechat_sendChatMessage").click();}}});$('#cmLivechat_sendChatMessage').click(function(){if($('#cmLivechat_chatMessage').val().trim()=="")return;var dataToSend={};var ts=Math.round((new Date()).getTime()/1000).toString()+
Math.floor(Math.random()*101).toString();dataToSend.appid=window.cmLivechat_appid;dataToSend.chatID=ts;dataToSend.type="INCOMING";dataToSend.status="UNREPLIED";dataToSend.isReplied=false;dataToSend.isAutoreply=false;dataToSend.inReplyTo=null;dataToSend.repliedAt=null;dataToSend.isFirst=false;dataToSend.body=$('#cmLivechat_chatMessage').val().replace(/(?:\r\n|\r|\n)/g,'<br>');dataToSend.initialData=[];dataToSend.from="";dataToSend.initialChatID=getCookie('cmLivechat_chatID');dataToSend.dlrStatus=0;var formattedDate='<span style="font-size:0.6em;">'+(new Date().getHours()<10?'0'+new Date().getHours():new Date().getHours())+":"+(new Date().getMinutes()<10?'0'+new Date().getMinutes():new Date().getMinutes())+"</span><span style='margin-left:5px;font-size:0.9em;font-weight:bold;' id='"+ts+"'>🗸</span>"+"<br>";$('#cmLivechat_chat').append('<span  class="atsakymas" style="color:'+templateOptions.livechat.csfcColor+';background-color: '+templateOptions.livechat.csbgColor+';font-size: 0.7em;padding:5px;margin:5px;border-radius:5px;display:inline-block;float:right;position:relative;margin-left:30px; word-break: break-word;">'+formattedDate+$('#cmLivechat_chatMessage').val().replace(/(?:\r\n|\r|\n)/g,'<br>')+'</span><br style="clear:both;">');$('#cmLivechat_chatMessage').val("");var elem=document.getElementById('cmLivechat_chat');elem.scrollTop=elem.scrollHeight;$.post(window.cmLivechat_siteUrl+'/livechat/api/create',dataToSend,function(data){});});});});break;}}
var currentGroup=groups[0];var isDayOff=false;var isWorkTime=false;if(currentGroup.livechatGroupDayTimeSettings){var currentDate=new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate());var currentTime=currentDate.getHours()+':'+currentDate.getMinutes();var daysOff=[];for(var i=0;i<JSON.parse(currentGroup.conditionDayOff).length;i++){daysOff.push([new Date(JSON.parse(currentGroup.conditionDayOff)[i].startDate),new Date(JSON.parse(currentGroup.conditionDayOff)[i].endDate)]);}
for(var j=0;j<daysOff.length;j++){if(daysOff[j][0].getTime()<=currentDate.getTime()&&daysOff[j][1].getTime()>=currentDate.getTime())
isDayOff=true;}
currentDate=new Date();currentTime=currentDate.getHours()*60+currentDate.getMinutes();if(!isDayOff){var workHours=[];var wH=JSON.parse(currentGroup.conditionWorkhour);var currentDay=currentDate.getDay();for(var k=0;k<wH.length;k++){var startDay=-1;var endDay=-1;var startHour=-1;var endHour=-1;var currentHour=-1;switch(wH[k].startday){case'Su':startDay=0;break;case'Mo':startDay=1;break;case'Tu':startDay=2;break;case'We':startDay=3;break;case'Th':startDay=4;break;case'Fr':startDay=5;break;case'Sa':startDay=6;break;}
switch(wH[k].endday){case'Su':endDay=0;break;case'Mo':endDay=1;break;case'Tu':endDay=2;break;case'We':endDay=3;break;case'Th':endDay=4;break;case'Fr':endDay=5;break;case'Sa':endDay=6;break;}
startHour=Number(wH[k].starttime.split(':')[0])*60+Number(wH[k].starttime.split(':')[1]);endHour=Number(wH[k].endtime.split(':')[0]*60)+Number(wH[k].endtime.split(':')[1]);currentHour=currentTime;if((currentDay>=startDay&&currentDay<=endDay)&&(currentHour>=startHour&&currentHour<=endHour))
isWorkTime=true;}
if(isWorkTime)
isDayOff=false;else
isDayOff=true;if(isDayOff){$('#cmLivechat_icDropper').css('display','none');$('#cmLivechat_icDropperNWH').css('display','block');}else{$('#cmLivechat_icDropper').css('display','block');$('#cmLivechat_icDropperNWH').css('display','none');if(templateOptions.livechat.initialGreetingRepeating){setInterval(function(){},templateOptions.livechat.initialGreetingTimer*1000);}else{setTimeout(function(){},templateOptions.livechat.initialGreetingTimer*1000);}}}}else{for(var zx=0;zx<groups.length;zx++){if(groups[zx].isDefault==true)
currentGroup=groups[zx];}
var currentDate=new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate());var currentTime=currentDate.getHours()+':'+currentDate.getMinutes();var daysOff=[];for(var i=0;i<JSON.parse(currentGroup.conditionDayOff).length;i++){daysOff.push([new Date(JSON.parse(currentGroup.conditionDayOff)[i].startDate),new Date(JSON.parse(currentGroup.conditionDayOff)[i].endDate)]);}
for(var j=0;j<daysOff.length;j++){if(daysOff[j][0].getTime()<=currentDate.getTime()&&daysOff[j][1].getTime()>=currentDate.getTime())
isDayOff=true;}
currentDate=new Date();currentTime=currentDate.getHours()*60+currentDate.getMinutes();if(!isDayOff){var workHours=[];var wH=JSON.parse(currentGroup.conditionWorkhour);var currentDay=currentDate.getDay();for(var k=0;k<wH.length;k++){var startDay=-1;var endDay=-1;var startHour=-1;var endHour=-1;var currentHour=-1;switch(wH[k].startday){case'Su':startDay=0;break;case'Mo':startDay=1;break;case'Tu':startDay=2;break;case'We':startDay=3;break;case'Th':startDay=4;break;case'Fr':startDay=5;break;case'Sa':startDay=6;break;}
switch(wH[k].endday){case'Su':endDay=0;break;case'Mo':endDay=1;break;case'Tu':endDay=2;break;case'We':endDay=3;break;case'Th':endDay=4;break;case'Fr':endDay=5;break;case'Sa':endDay=6;break;}
startHour=Number(wH[k].starttime.split(':')[0])*60+Number(wH[k].starttime.split(':')[1]);endHour=Number(wH[k].endtime.split(':')[0]*60)+Number(wH[k].endtime.split(':')[1]);currentHour=currentTime;if((currentDay>=startDay&&currentDay<=endDay)&&(currentHour>=startHour&&currentHour<=endHour))
isWorkTime=true;}
if(isWorkTime)
isDayOff=false;else
isDayOff=true;if(isDayOff){$('#cmLivechat_icDropper').css('display','none');$('#cmLivechat_icDropperNWH').css('display','block');}else{$('#cmLivechat_icDropper').css('display','block');$('#cmLivechat_icDropperNWH').css('display','none');if(templateOptions.livechat.initialGreetingRepeating){setInterval(function(){},templateOptions.livechat.initialGreetingTimer*1000);}else{setTimeout(function(){},templateOptions.livechat.initialGreetingTimer*1000);}}}}
$('[data-type="group_dd"]').on('change',function(){var currentGroup=null;var selectedGroup=$(this).val();$('[data-type="group_dd"]').val(selectedGroup);for(var zy=0;zy<groups.length;zy++){if(groups[zy]._id.toString()==selectedGroup.toString())
currentGroup=groups[zy];}
var isDayOff=false;var isWorkTime=false;if(currentGroup.livechatGroupDayTimeSettings){var currentDate=new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate());var currentTime=currentDate.getHours()+':'+currentDate.getMinutes();var daysOff=[];for(var i=0;i<JSON.parse(currentGroup.conditionDayOff).length;i++){daysOff.push([new Date(JSON.parse(currentGroup.conditionDayOff)[i].startDate),new Date(JSON.parse(currentGroup.conditionDayOff)[i].endDate)]);}
for(var j=0;j<daysOff.length;j++){if(daysOff[j][0].getTime()<=currentDate.getTime()&&daysOff[j][1].getTime()>=currentDate.getTime())
isDayOff=true;}
currentDate=new Date();currentTime=currentDate.getHours()*60+currentDate.getMinutes();if(!isDayOff){var workHours=[];var wH=JSON.parse(currentGroup.conditionWorkhour);var currentDay=currentDate.getDay();for(var k=0;k<wH.length;k++){var startDay=-1;var endDay=-1;var startHour=-1;var endHour=-1;var currentHour=-1;switch(wH[k].startday){case'Su':startDay=0;break;case'Mo':startDay=1;break;case'Tu':startDay=2;break;case'We':startDay=3;break;case'Th':startDay=4;break;case'Fr':startDay=5;break;case'Sa':startDay=6;break;}
switch(wH[k].endday){case'Su':endDay=0;break;case'Mo':endDay=1;break;case'Tu':endDay=2;break;case'We':endDay=3;break;case'Th':endDay=4;break;case'Fr':endDay=5;break;case'Sa':endDay=6;break;}
startHour=Number(wH[k].starttime.split(':')[0])*60+Number(wH[k].starttime.split(':')[1]);endHour=Number(wH[k].endtime.split(':')[0]*60)+Number(wH[k].endtime.split(':')[1]);currentHour=currentTime;if((currentDay>=startDay&&currentDay<=endDay)&&(currentHour>=startHour&&currentHour<=endHour))
isWorkTime=true;}
if(isWorkTime)
isDayOff=false;else
isDayOff=true;if(isDayOff){$('#cmLivechat_icDropper').css('display','none');$('#cmLivechat_icDropperNWH').css('display','block');}else{$('#cmLivechat_icDropper').css('display','block');$('#cmLivechat_icDropperNWH').css('display','none');if(templateOptions.livechat.initialGreetingRepeating){setInterval(function(){},templateOptions.livechat.initialGreetingTimer*1000);}else{setTimeout(function(){},templateOptions.livechat.initialGreetingTimer*1000);}}}}else{for(var zx=0;zx<groups.length;zx++){if(groups[zx].isDefault==true)
currentGroup=groups[zx];}
var currentDate=new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate());var currentTime=currentDate.getHours()+':'+currentDate.getMinutes();var daysOff=[];for(var i=0;i<JSON.parse(currentGroup.conditionDayOff).length;i++){daysOff.push([new Date(JSON.parse(currentGroup.conditionDayOff)[i].startDate),new Date(JSON.parse(currentGroup.conditionDayOff)[i].endDate)]);}
for(var j=0;j<daysOff.length;j++){if(daysOff[j][0].getTime()<=currentDate.getTime()&&daysOff[j][1].getTime()>=currentDate.getTime())
isDayOff=true;}
currentDate=new Date();currentTime=currentDate.getHours()*60+currentDate.getMinutes();if(!isDayOff){var workHours=[];var wH=JSON.parse(currentGroup.conditionWorkhour);var currentDay=currentDate.getDay();for(var k=0;k<wH.length;k++){var startDay=-1;var endDay=-1;var startHour=-1;var endHour=-1;var currentHour=-1;switch(wH[k].startday){case'Su':startDay=0;break;case'Mo':startDay=1;break;case'Tu':startDay=2;break;case'We':startDay=3;break;case'Th':startDay=4;break;case'Fr':startDay=5;break;case'Sa':startDay=6;break;}
switch(wH[k].endday){case'Su':endDay=0;break;case'Mo':endDay=1;break;case'Tu':endDay=2;break;case'We':endDay=3;break;case'Th':endDay=4;break;case'Fr':endDay=5;break;case'Sa':endDay=6;break;}
startHour=Number(wH[k].starttime.split(':')[0])*60+Number(wH[k].starttime.split(':')[1]);endHour=Number(wH[k].endtime.split(':')[0]*60)+Number(wH[k].endtime.split(':')[1]);currentHour=currentTime;if((currentDay>=startDay&&currentDay<=endDay)&&(currentHour>=startHour&&currentHour<=endHour))
isWorkTime=true;}
if(isWorkTime)
isDayOff=false;else
isDayOff=true;if(isDayOff){$('#cmLivechat_icDropper').css('display','none');$('#cmLivechat_icDropperNWH').css('display','block');}else{$('#cmLivechat_icDropper').css('display','block');$('#cmLivechat_icDropperNWH').css('display','none');if(templateOptions.livechat.initialGreetingRepeating){setInterval(function(){},templateOptions.livechat.initialGreetingTimer*1000);}else{setTimeout(function(){},templateOptions.livechat.initialGreetingTimer*1000);}}}}});$('#cmLivechat_windowMinimize').click(function(){$('#cmLivechat_iconClosed').css('display','none');$('#cmLivechat_iconOpen').css('display','initial');$('#cmLivechat_container').css('display','none');window.cmLivechatIsOpen=false;});$('#cmLivechat_windowClose').click(function(){$('#cmLivechat_iconClosed').css('display','none');$('#cmLivechat_iconOpen').css('display','initial');$('#cmLivechat_container').css('display','none');window.cmLivechatIsOpen=false;$('#cmLivechat_igDropper').css('display','none');if($('#cmLivechat_icDropperNWH').css('display')=='none'){$('#cmLivechat_icDropper').css('display','block');$('#cmLivechat_icDropperNWH').css('display','none');}
$('#cmLivechat_container').css('bottom','125px');$('#cmLivechat_container').css('height','405px');});$('#cmLivechat_soundOn').click(function(){window.cmLivechat_soundWorks=false;$('#cmLivechat_soundOn').css('display','none');$('#cmLivechat_soundOff').css('display','initial');});$('#cmLivechat_soundOff').click(function(){window.cmLivechat_soundWorks=true;$('#cmLivechat_soundOn').css('display','initial');$('#cmLivechat_soundOff').css('display','none');});};function css(element,property){return window.getComputedStyle(element,null).getPropertyValue(property);}}(jQuery));jQuery(document).cmLivechat();},2000);