<HTML>
<HEAD>
    <meta http-equiv="Content-Language" content="ru">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>{$mlang.Livechat}</title>
    <link rel="stylesheet" href="{$config.site_root}/modules/livechat/templates/style.css?{$revision}" type="text/css">
    <link rel="stylesheet" href="../../cache/cur_scheme_{$config.css_id}_{$config.css_id_sheme}.css?{$revision}" type="text/css">

    <script src="../../themes/clientbase/libs/jquery/jquery-3.2.1.min.js?{$revision}"></script>
    <script src="../../themes/clientbase/libs/jquery/jquery-ui.min.js?{$revision}"></script>
    <script src="../../themes/clientbase/libs/jquery/jquery-migrate.min.js?{$revision}"></script>
    <script src="../../themes/clientbase/libs/jquery/jquery.cookie.js?{$revision}"></script>
    <script src="../../themes/clientbase/libs/jquery/widget.js?{$revision}"></script>
    <script type="text/javascript" src="../../themes/clientbase/libs/jquery/jquery.mousewheel.js?{$revision}"></script>
    {if $lang.short_name == 'ru'}
    <script type="text/javascript"
            src="../../themes/clientbase/libs/jquery/i18n/datepicker-ru.js?{$revision}"></script>
    {else}
    <script type="text/javascript"
            src="../../themes/clientbase/libs/jquery/i18n/jquery.ui.datepicker-us.js?{$revision}"></script>
    {/if}
    <script type="text/javascript" src="../../themes/clientbase/libs/jquery/autocomplete/jquery.autocomplete.js?{$revision}"></script>
    <script src="../../themes/clientbase/js/preloader.js?{$revision}"></script>
    <link href="https://fonts.googleapis.com/css?family=Encode+Sans+Expanded|Lato|Merriweather|Montserrat|Open+Sans|Oswald|PT+Sans|Poppins|Roboto|Roboto+Slab&display=swap" rel="stylesheet">
<body class="body" onLoad="pageloaded()" onunload="dounload()" style="overflow-x: hidden">
<style>
    .hidden {
        display: none !important;
    }

    #main_table_manager {
        font-size: 12px;
    }

    #lv_messages_td {
        overflow: unset;
        overflow-x: hidden;
        overflow-y: overlay;
        background-color: unset;
    }

    .livechat_manager_status {
        font-size: 11px;
        color: grey;
    }

    .livechat_c_one_old_message_block, .livechat_one_message_block, #greet_mess_span {
        padding: 10px 25px;
    }

    .custom-scroll::-webkit-scrollbar-thumb {
        background: #398EC6;
    }

    .livechat_textarea {
        width: 100%;
    }

    .livechat_one_message_block[data-author=client] {
        align-items: flex-start;
        display: flex !important;
    }

    .livechat_c_one_old_message_block[data-author=client] .message__time, .livechat_one_message_block[data-author=client] .message__time {
        align-self: flex-start;
        margin-left: 50px;
        margin-right: 0px;
    }

    .livechat_manager_text, .livechat_client_text {
        margin-left: 0;
        margin-right: 0;
    }

    .message__time {
        margin-left: 0;
    }

    .livechat_one_message_block[data-author=client] .message__time {
        margin-left: 0;
    }

    .bubbleUser0 {
        fill:#a5a5a6;
    }

    .bubbleUser1 {
        fill:#FFFFFF;
    }

    #lv_clients > div {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    /* Custom color settings */
    .manager_ok__users-block {
        background-color: {$config.modules.livechat.ok_color_block_left_manager} !important;
    }

    .manager_ok__message-block  {
        background-color: {$config.modules.livechat.ok_color_block_right_manager} !important;
    }

    .additional__buttons-item svg path, #ok_button__drop-user circle {
        fill: {$config.modules.livechat.ok_color_manager} !important;
    }

    #ok_button__drop-user svg rect {
        fill: {$config.modules.livechat.ok_color_block_right_manager} !important;
    }

    .unmute svg path, .mute svg path {
        fill: none !important;
        stroke: {$config.modules.livechat.ok_color_manager} !important;
    }

    .unmute svg polygon, .mute svg polygon {
        fill: {$config.modules.livechat.ok_color_manager} !important;
        stroke: {$config.modules.livechat.ok_color_manager} !important;
    }

    .livechat_contact_active_client, .livechat_contact_active_client_hover {
        background-color: {$config.modules.livechat.ok_color_my_clients_manager} !important;
    }

    .livechat_contact_my_client, .livechat_contact_my_client_hover {
        background-color: {$config.modules.livechat.ok_color_free_clients_manager} !important;
    }

    #paper-plane-label {
        fill: {$config.modules.livechat.ok_color_mes_buttons_manager} !important;
    }

    .answers__tooltip {
        background: white !important;
    }

    .fast__answers-block svg path {
        fill: {$config.modules.livechat.ok_color_mes_buttons_manager} !important;
    }

    .custom-scroll::-webkit-scrollbar-thumb {
        background: {$config.modules.livechat.ok_color_manager} !important;
    }

    .send_button__circle {
        background-color: {$config.modules.livechat.ok_color_mes_buttons_manager} !important;
    }

    .livechat_messages div[data-author=manager] .livechat_manager_text {
        background: {$config.modules.livechat.ok_color_manager_bg_color_manager} !important;
        color: {$config.modules.livechat.ok_color_manager_txt_color_manager} !important;
    }

    .livechat_messages div[data-author=client] .livechat_client_text {
        background: {$config.modules.livechat.ok_color_client_bg_color_manager} !important;
        color: {$config.modules.livechat.ok_color_client_txt_color_manager} !important;
    }

    #main_table_manager, #new_mess, li, td, a, form, p {
        font-family: '{$config.modules.livechat.ok_font_family_manager}', sans-serif !important;
    }

    .send_button {

    }

    .livechat_contact_active_client .livechat__client_status, .livechat_contact_active_client_hover .livechat__client_status {
        border-color: {$config.modules.livechat.ok_color_my_clients_manager} !important;
    }

    .livechat_contact_my_client .livechat__client_status, .livechat_contact_my_client_hover .livechat__client_status {
        border-color: {$config.modules.livechat.ok_color_free_clients_manager} !important;
    }

    div.livechat_contact_active_client.ok__now-client .livechat__client_status, .livechat_contact_active_client_hover .livechat__client_status {
        top: 10%;
        right: -9px;
        border: 4px solid #fffee9 !important;
        border-radius: 50%;
    }

    .livechat__client_status {
        background: transparent;
    }

    .message_ok-logout .shp0, .manager_ok__close-btn .shp0 {
        fill: #5c5c5c;
    }

    .livechat_contact__info {
        display: flex;
        flex-direction: column;
        flex-wrap: wrap;
    }

    .livechat_contact-wrapper {
        flex-wrap: wrap;
        display: flex;
    }
    /* End of custom color settings */
</style>
<script type="text/javascript" src="{$config.site_root}/modules/livechat/mybic.js?{$revision}"></script>


<script language="JavaScript" type="text/javascript">

    var AudioObj, AudioObj_Support, AudioObj_Format, AudioObj_NewMess, AudioObj_NewClient;
    try {
        // параметр 'src' обязателен для Opera 10, используем пустую строку"",
        // в противном случае получим исключение
        AudioObj = new Audio("");
        AudioObj_Support = !!(AudioObj.canPlayType);
        AudioObj_Format = "wav";
        if ((AudioObj.canPlayType("audio/ogg") != "no") && (AudioObj.canPlayType("audio/ogg") != "")) AudioObj_Format = "ogg";
        if ((AudioObj.canPlayType("audio/mpeg") != "no") && (AudioObj.canPlayType("audio/mpeg") != "")) AudioObj_Format = "mp3";
    } catch (e) {
        AudioObj_Support = false;
    }
    if (AudioObj_Support) {
        AudioObj_NewMess = new Audio("{$config.site_root}/modules/livechat/sounds/new_message." + AudioObj_Format);
        AudioObj_NewClient = new Audio("{$config.site_root}/modules/livechat/sounds/new_client." + AudioObj_Format);
    }
    ;

    var is_livechat_trial ={$is_livechat_trial};
    var post_mess_text = "";  // Cообщение которое нужно запостить
    var my_users = ""; // Пользователи которые принял менеджер
    var new_messages_flags = {}; // Массив, список пользователей у которых получили историю
    var muteSound = '';
    var iID = window.setInterval(get_new_messages, 5000); // Обновляем каждые 5 секунд
    var ajaxObj = new XMLHTTP("{$config.site_root}/modules/livechat/ajax_module.php");
    var ajax_result = 0;
    var iID_post = 0;
    var active_user = -1;
    var last_active_user = -1;
    var last_m = 0;
    var managerId = {$user.id};
    var alert_mode = -1; // Режим предупреждения, -1 - нет предупреждения, 1 - новое сообщение, 2 - новый пользователь
    var iID_alert_title = 0; // Таймер движения окна
    var csrf = '{$csrf}';
    var network_down_count = 0;  // Количество неуспешных загрузок
    var start_time = parseInt(new Date().getTime() / 1000); // Время запуска
    var isWindowOpen = false;
    var next_x = 1; // Антикеш, для изображения обновлений
    var last_activity_iID = 0; // Таймер для отложенного уведомления о активности, когда пользователь проводит мышкой по списку контактов
    var isFastAnswersOpen = false;
    var out_height = 0; // Высота истории сообщений
    var was_unload = 0; // Был выгружен
    var last_download_status = 1;

    var free_clients_play_iID = 0;
    var login_redirect = 0; // Флаг что выполняется редирект на окно логина

    function showtime() {
        var now = new Date();
        var yr = now.getFullYear();
        var mnth = now.getMonth() + 1;
        var dday = now.getDate();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var timeValue = "";
        timeValue += ((hours < 10) ? "0" : "") + hours
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        /*timeValue += " ";
        timeValue += dday + "/";
        timeValue += ((mnth < 10) ? "0" : "") + mnth + "/";
        timeValue += yr;*/
        return timeValue;
    }

    function htmlspecialchars(text) {
        var chars = Array("&", "<", ">", '"', "'");
        var replacements = Array("&amp;", "&lt;", "&gt;", "&quot;", "'");
        for (var i = 0; i < chars.length; i++) {
            var re = new RegExp(chars[i], "gi");
            if (re.test(text)) {
                text = text.replace(re, replacements[i]);
            }
        }
        return text;
    }


    function get_new_messages() {
        if (isWindowOpen) {
            if (ajax_result == 0) { // Предыдущая выполнена
                ajax_result = 1;
                ajaxObj.format = 0;
                ajaxObj.method = "POST";
                ajaxObj.abort_timeout = 60000;
                ajaxObj.failed_requests = 0;
                ajaxObj.failed_threshold = 1000;
                ajaxObj.net_down_func = NetworkDown;
                ajaxObj.call("csrf={$csrf}&active_user=" + active_user + post_mess_text, ComResp);
                clearInterval(iID);
                post_mess_text = "";
                last_m = 0;
                // Отправляем запрос на получение сообщений раз в минуту после того как получили сообщение
                //let getMessagesPerMinute = setInterval(get_new_messages_per_minute, 60000);
            }
        }
    }
    ;

    function get_new_messages_per_minute() {
        if (ajax_result == 0) { // Предыдущая выполнена
            ajax_result = 1;
            clearInterval(iID);
            ajaxObj.format = 0;
            ajaxObj.method = "POST";
            ajaxObj.abort_timeout = 60000;
            ajaxObj.failed_requests = 0;
            ajaxObj.net_down_func = NetworkDown;
            ajaxObj.call("csrf={$csrf}&active_user=" + active_user + post_mess_text, ComResp);
            post_mess_text = "";
            last_m = 0;
        }
    }
    ;

    function ComRespPost() { // Пост обработка используя обновленные объекты
        clearInterval(iID_post);
        iID = window.setInterval(get_new_messages, 4990); // Обновляем каждые 5 секунд
    }

    function ComResp(resp) {
        if (resp) {
            var login_pos = resp.indexOf('<form action="login.php" method="post">');
            if (login_pos != -1) {
                login_redirect = 1;
                location.href = "{$config.site_root}/login.php";
                return;
            }
            ;

            last_download_status = 1;
            document.getElementById("livechat_status").innerHTML = "{$lang.Online}";
            document.getElementById("livechat_status").className = "livechat_online_status";

            // Парсим на список пользователей, входящие сообщения
            var cl_pos = resp.indexOf(String.fromCharCode(26));
            if (cl_pos == -1) {
                document.getElementById("lv_clients").innerHTML = resp;
                ajax_result = 0;
                // Фиксируем активного пользователя
                if (document.getElementById("contact_list_client" + active_user)) {
                    if (document.getElementById("contact_list_client" + active_user).className == "livechat_contact_free_client") { // Отмечаем его что он наш
                        my_users += "&my_user" + active_user + "=1";
                    }

                    document.getElementById("contact_list_client" + active_user).className = "livechat_contact_active_client";
                    document.getElementById("contact_list_client" + active_user).classList.add('ok__now-client');
                    document.getElementById("contact_list_client_manager" + active_user).innerHTML = "";
                }
                ;
                if (resp.indexOf('<span id="var_new_clients_exists"></span>') != -1) { // Если индикатор о новых пользователях существует, то включаем звук
                    if (alert_mode == -1) alert_mode = 2;
                    if (free_clients_play_iID == 0) free_clients_play_iID = window.setInterval(playsound_new_client, 0); // Звук каждые 15 секунд
                    //if (iID_alert_title == 0) alert_title();

                }
                else {
                    if (alert_mode == 2) { // Если клиента перехватил другой менеджер, то снимаем уведомление
                        alert_mode = -1;
                        turn_alert = 0;
                        //alert_title();
                    }
                    clearInterval(free_clients_play_iID);
                    free_clients_play_iID = 0;
                }
                ;
                FixCLMouse();
                // Отображаем флажки о новых сообщениях
                fix_new_messages_flags();
                // Проверяем нет ли непрочитанных сообщений в чате
                if ( $('.new__message-img div svg').length == 0 ) {
                    {literal}parent.postMessage(JSON.stringify({okTitle: 'stop'}), '*');{/literal}
                }
                // Пост обработка используя обновленные объекты
                iID = window.setInterval(get_new_messages, 5000);
                return;
            }
            showPreloaderOK();
            var lv_clients = resp.substr(0, cl_pos);
            document.getElementById("lv_clients").innerHTML = lv_clients;

            // Парсим сообщения
            var cl_pos2, client_id_full, m_text, m_mode, t0;
            var new_text_messages = 0;
            cl_pos++;
//      alert("cl_pos:"+cl_pos);
            var history_is_clean = 0;
            while ((cl_pos2 = resp.indexOf(String.fromCharCode(26), cl_pos)) != -1) {
                m_mode = "";
                client_id_full = resp.substr(cl_pos, cl_pos2 - cl_pos);
                client_id = parseInt(client_id_full);
                if (client_id_full != client_id) {
                    m_mode = client_id_full.substr(client_id.toString().length, 1000);
//               alert("client_id_full:'"+client_id_full+"' client_id:'"+client_id+"' m_mode:'"+m_mode);
                }
                ;
                cl_pos2++;
                cl_pos3 = resp.indexOf(String.fromCharCode(26), cl_pos2);
                if (cl_pos3 == -1) cl_pos3 = resp.length;
                m_text = resp.substr(cl_pos2, cl_pos3 - cl_pos2);
//          alert("cl:"+client_id+"\n"+"resp:"+m_text);
                if (m_mode == "H") {
                    // Чтобы дважды не записать одно и тоже сообщение в историю, чистим предыдущую историю
                    if (history_is_clean == 0) {
                        history_is_clean = 1;
                        lv_messages_history_div(client_id).innerHTML = '';
                    }
                    // HISTORY
                    lv_messages_history_div(client_id).innerHTML = m_text + lv_messages_history_div(client_id).innerHTML;
                }
                else {
                    if (m_text.indexOf('<div class="livechat_client_text">') != -1) new_text_messages = 1;
                    // SIMPLE MESSAGES
                    lv_messages_div(client_id).innerHTML = lv_messages_div(client_id).innerHTML + m_text;
                    if (client_id != -1) {
                        new_messages_flags[client_id] = 1;
                    }
                }
                ;
                cl_pos = cl_pos3 + 1;
            }
            ;
            ajax_result = 0;
            if (document.getElementById("contact_list_client" + active_user)) {
                document.getElementById("contact_list_client" + active_user).className = "livechat_contact_active_client";
                document.getElementById("contact_list_client" + active_user).classList.add('ok__now-client');
                document.getElementById("contact_list_client_manager" + active_user).innerHTML = "";
            }
            // Отображаем флажки о новых сообщениях
            fix_new_messages_flags();

            // Проверяем нет ли непрочитанных сообщений в чате
            if ( $('.new__message-img div svg').length == 0 ) {
                {literal}parent.postMessage(JSON.stringify({okTitle: 'stop'}), '*');{/literal}
            }

            // Сдвигаем вниз
            scroll_down();
            // Проигрываем звук
            if (new_text_messages) {
                alert_mode = 1;
                if (muteSound == 'false') playsound_new_message();
                if (iID_alert_title == 0) alert_title();
            }
            hidePreloaderOK();
        }
        else {
            // handle error here
            // Проверяем нет ли непрочитанных сообщений в чате
            if ( $('.new__message-img div svg').length == 0 ) {
                {literal}parent.postMessage(JSON.stringify({okTitle: 'stop'}), '*');{/literal}
            }

            iID = window.setInterval(get_new_messages, 5000);
        }
        // Проверяем нет ли непрочитанных сообщений в чате
        if ( $('.new__message-img div svg').length == 0 ) {
            {literal}parent.postMessage(JSON.stringify({okTitle: 'stop'}), '*');{/literal}
        }

        iID = window.setInterval(get_new_messages, 5000);
    }

    // Фиксируем флажки о новых сообщениях
    function fix_new_messages_flags() {
        /*for (var i in new_messages_flags) {
            if ((new_messages_flags[i])) {
                if (document.getElementById("contact_list_new_messages_img" + i)) {
                    document.getElementById("contact_list_new_messages_img" + i).innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 19" width="20" height="19">
                                                                                                        <defs>
                                                                                                    <filter id="flt1"> <feColorMatrix in="SourceGraphic" type="matrix"
                                                                                                    values="0.36 0 0 0 0 0 0.36 0 0 0 0 0 0.36 0 0 0 0 0 1 0" /> </filter>
                                                                                                        <image width="20" height="19" id="img1-new-mess" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAMAAACnUt2HAAAAAXNSR0IB2cksfwAAAThQTFRF////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////4g1iRQAAAGh0Uk5TAAhYxNZGuP7/zj2r/a8xnvDs5JMnkO/RbxyE42DgVRV33bQ4xjYNZdKlFq0fCVzIiAaSzBFRv/lybqkDwV1M9owaVqLfQynmcSBmnTQmzfxNa/L1MAEdImcTgix+9MsCqA8/jqyJxQ7t3DDYAAAA4ElEQVR4nGNgQAOMTMws6GKsbOwcnKhCXNw8HBwcvMhCfPwCHIJC7BzCCCERUTEODnGgOIcETEhSShqokVlGloODRw4iJK+gCBTiUFJWAZJiqiAhNXUNkBCHppY2iFLUYWDQ1dMHC3EYGBqBaWMTBlMziJC5BYMlhGVlzWADYQnYMtjZQ5gODAyOTs5Ae11cGdzcIWIcHmC7Pb28fRh8/aBi/gEItwcGQQWDQ2BCoW5h4RE2YEOlI+EKtVmiohmUY5hjOeLi4YIJHBwg3yUmJQcijEzhSEUPWgYG7rR0BAcAtF8aLxEKeLMAAAAASUVORK5CYII="/>
                                                                                                        </defs>
                                                                                                        <style>
                                                                                                        tspan { white-space:pre }
                                                                                                </style>
                                                                                                    <use style="filter: url(#flt1)" href="#img1-new-mess" x="0" y="0" />
                                                                                                </svg>`;
                    document.getElementById("contact_list_new_messages_img" + i).style.width = "20px";
                }
                else {
                    delete new_messages_flags.i;
                }
            }
        }*/
    }


    // Ошибка сети
    var was_alert = 0;
    function NetworkDown(status) { // Ошибки игнорируем
        ajax_result = 0;
        if ((network_down_count > 2) && (was_alert == 0)) {
            was_alert = 1;
            var cur_time = parseInt(new Date().getTime() / 1000);
            if ((cur_time - start_time) < 60) { // Отвалилось в течении минуты
                alert("{$mlang.alert_bad_internet}");
            }
            ;
        }
        ;
        network_down_count++;
        last_download_status = 0;
        document.getElementById("livechat_status").innerHTML = "{$lang.Offline}";
        document.getElementById("livechat_status").className = "livechat_offline_status";
        iID = window.setInterval(get_new_messages, 5000); // Засыпаем на 5 секунд
        return;
    }
    ;


    // Получаем div сообщений клиента
    function lv_messages_div(id) {
        id = parseInt(id);
        if (document.getElementById("lv_messages" + id)) {
            return document.getElementById("lv_messages" + id);
        }
        else {  // Cоздаем данный div слой
            var newDiv = document.createElement('div');
            newDiv.className = 'livechat_messages custom-scroll';
            newDiv.id = 'lv_messages' + id;
            newDiv.style.overflow = "auto";
            newDiv.style.position = "relative";
            newDiv.style.display = "none"; // Скрываем его
            document.getElementById('lv_messages_td').appendChild(newDiv);
            // Создаем Div истории
            var newHistoryDiv = document.createElement('div');
            newHistoryDiv.id = 'lv_messages_history' + id;
            newHistoryDiv.className = 'livechat_history_messages';
            newDiv.appendChild(newHistoryDiv);
            return newDiv;
        }
        ;
    }
    ;

    // Получаем div ИСТОРИИ сообщений клиента
    function lv_messages_history_div(id) {
        id = parseInt(id);
        if (document.getElementById("lv_messages_history" + id)) {
            return document.getElementById("lv_messages_history" + id);
        }
        else {  // Cоздаем данный div слой
            lv_messages_div(id);
            return document.getElementById("lv_messages_history" + id);
        }
        ;
    }
    ;

    // Кликнули по пользователю
    function OnClientClick(id, thisWindow = true) { // Выбираем пользователя
        if ( thisWindow ) {
            if (event.which == 3) {
                return;
            }
        }
        active_user = id;
        if (last_active_user == active_user) return;
        if (last_active_user != -1) {
            if (document.getElementById("contact_list_client" + last_active_user))
                document.getElementById("contact_list_client" + last_active_user).className = "livechat_contact_my_client";
            lv_messages_div(last_active_user).style.display = "none";
        }
        else {
            document.getElementById("lv_messages-1").style.display = "none";
        }
        last_active_user = active_user;
        if ((active_user > 0) && (document.getElementById("contact_list_client" + active_user).className = "livechat_contact_free_client")) {
            my_users += "&my_user" + active_user + "=1";
        }
        ;
        if (active_user > 0) {
            document.getElementById("contact_list_client" + active_user).className = "livechat_contact_active_client";
            document.getElementById("contact_list_client_manager" + active_user).innerHTML = "";
            new_messages_flags[active_user] = 0;
        }

        {literal}$(`#lv_messages${active_user} > div.livechat_one_old_message_block`).remove();{/literal}
        {literal}$(`#lv_messages${active_user} > div.livechat_one_message_block`).remove();{/literal}

        // Проверяем нет ли непрочитанных сообщений в чате
        if ( $('.new__message-img div svg').length == 0 ) {
            {literal}parent.postMessage(JSON.stringify({okTitle: 'stop'}), '*');{/literal}
        }

        // Обновляем информацию о привязке клиента и менеджера + читаем сообщения
        if ( active_user != -1 )
            updateClientManagerLink(active_user, managerId, 1, 0);
        else
            updateClientManagerLink(active_user, managerId, 1, 1);

        // Меняем текст пользователя
        lv_messages_div(active_user).style.display = "flex";

        // Выставляем активность сайта
        set_activity();

        // Получаем новые сообщения
        if (my_users) {
            showPreloaderOK();
            get_new_messages();
        }
        scroll_down();

        {literal}
        // Меняем имя пользователя в шапке истории
        const activeClientName = $(`#contact_list_client${active_user} .livechat_contact_name`).text();
        $('.message__header-name').text(activeClientName);
        {/literal}
    }
    ;

    function OkContextMenu(id) { // Клик правой кнопкой на список клиентов
        // На Shift простое меню браузера
        if ( event.shiftKey ) {
            // Стандартный функционал правой кнопки мыши в браузере
        } else {
            event.preventDefault();
            let okContext = $('#okContextMenu');
            const offset = $('#lv_clients').offset();
            let okWindowX = (event.pageX - offset.left);
            let okWindowY = (event.pageY - offset.top);
            okContext.css({
                'top': okWindowY,
                'left': okWindowX
            });
            okContext.find('.okContextMenu__link').attr('href','{$config.site_root}/modules/livechat/subscribe_open.php?client_id='+id);
            okContext.toggleClass('hidden');
        }
    }

    function updateClientManagerLink(clientId, managerId, needRead = 0, preloader = 1) {
        $.ajax({
            url: 'updateUsersStatusInfo.php',
            type: 'post',
            data: {literal}`client_id=${clientId}&manager_id=${managerId}&read=${needRead}&csrf=${csrf}`,{/literal}
            beforeSend: function() {
                if (preloader)
                    showPreloaderOK();
            },
            success: function () {
                if (preloader)
                    hidePreloaderOK();
            }
        });
    }

    // Очистить историю пользователя
    function ClearHistory(id) {
        lv_messages_div(id).innerHTML = '<div id="lv_messages_history' + id + '" class="livechat_history_messages"></div>';
    }
    ;

    function post_message() {
        if (active_user == -1) {
            document.getElementById("new_mess").blur();
            alert("{$mlang.select_send_message_user}");
            return "false";
        }
        if (document.getElementById("new_mess").value.length < 1) { // Инорируем Enter, на пустом поле
            document.getElementById("new_mess").value = "";
            return false;
        }

        var cur_time = showtime();
        var disp_mess_text = htmlspecialchars(document.getElementById("new_mess").value);
        var new_mess_text = encodeURIComponent(document.getElementById("new_mess").value);
        disp_mess_text = disp_mess_text.replace(/\n/g, "<br>\n");
        if (is_livechat_trial) disp_mess_text += "<br> --- You use free program version. --- ";
        if ((new_mess_text) && (new_mess_text != undefined)) {
            var mess_div = '<div class="livechat_one_old_message_block" data-author="manager"><span class="livechat_manager_name">' + htmlspecialchars("{$user.fio}" + "test") + ' (' + cur_time + ')</span><div class="message__time">'+ htmlspecialchars("{$user.fio}, ") + cur_time +'</div><div class="livechat_manager_text">' + disp_mess_text + "</div></div>\n";
            document.getElementById("lv_messages" + active_user).innerHTML = document.getElementById("lv_messages" + active_user).innerHTML + mess_div;
            post_mess_text = post_mess_text + "&mess_" + active_user + "_" + last_m + "=" + new_mess_text;
            last_m = last_m + 1;
            scroll_down();
        }
        ;
        document.getElementById("new_mess").value = "";
        // Выставляем астивность сайта
        set_activity();
        // Отправляем сообщение
        get_new_messages();
        scroll_down();
        return false;
    }
    ;

    function scroll_down() {
        var i;
        for (i = 0; i < 1000; i++) {
            if (document.getElementById("lv_messages_td").doScroll) { //IE
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
                document.getElementById("lv_messages_td").doScroll("pageDown");
            }
            else {
                $('#lv_messages_td').scrollTop(10000)
            }
        }
    }
    ;


    function set_activity() {
        document.getElementById("set_activity_image").src = "{$config.site_root}/modules/livechat/ajax_module_activity.php?rand={$rand_int}&m=" + next_x;
        next_x++;
        last_activity_iID = 0;
    }

    function set_activity_id() {
        if (last_activity_iID == 0) last_activity_iID = window.setInterval(set_activity, 7000);
    }


    function playsound_new_message() {
        if (AudioObj_Support) {
            AudioObj_NewMess.play();
        }
        else { // Проигрываем с помощю тега
            document.getElementById("bgsound_id").src = "{$config.site_root}/modules/livechat/sounds/ok_open.wav"
        }
    }
    ;

    function playsound_new_client() {
        if (muteSound == 'false') {
            clearInterval(free_clients_play_iID);
            free_clients_play_iID = window.setInterval(playsound_new_client, 30000); // Каждые 30 секунд!!!
            if (AudioObj_Support) {
                AudioObj_NewClient.play();
            } else { // Проигрываем с помощю тега
                document.getElementById("bgsound_id").src = "{$config.site_root}/modules/livechat/sounds/new_client.wav"
            }
        }
    }
    ;

    function beforeunload() {
        //if (!login_redirect) return "{$mlang.alert_close}";
    }
    ;

    function dounload() {
        if (isWindowOpen) {
        var oReq = new XMLHttpRequest();
        oReq.open("get", "{$config.site_root}/modules/livechat/ajax_module.php?doClose=1", false);
        oReq.send();

        if ((subscribe_window) && (!subscribe_window.closed)) subscribe_window.close();
        if ((transmit_window) && (!transmit_window.closed)) transmit_window.close();
        if ((ban_window) && (!ban_window.closed)) ban_window.close();
        }
    }
    ;

    // Загружена страница
    function pageloaded() {
        window.onresize = on_window_resize;
        if (window.ActiveXObject) {
            document.getElementById("main_table_manager").style.minWidth = "";
            document.getElementById("main_table_manager").style.minHeight = "";
            // Cнимаем со стиля минимальную ширину для ie
            on_window_resize();
        }
        else if (window.navigator.userAgent.indexOf("Firefox") >= 0) { // Патч на firefox для изменения размера окна
            window.onresize = on_window_resize;
            if (out_height == 0) {
                var diff;
                out_height = document.getElementById("lv_messages_td").clientHeight;
                diff = out_height - document.getElementById("lv_messages_td").clientHeight;
                out_height += diff;
            }
            on_window_resize();
        }
        ;
        setTimeout(function(){
            $('#lv_messages_td.custom-scroll').css('height', '100%');
        }, 1000);
    }

    var last_ie_width = 0;
    var last_ie_height = 0;
    function on_window_resize() {
        /*var min_width = 745;
        var min_height = 495;
        var cwidth = document.body.clientWidth;
        var cheight = document.body.clientHeight;
        if (window.ActiveXObject) { // Патч на IE для изменения размера окна, меньше положенного
            var diff = 50;
            min_width -= diff;
            if (cwidth < min_width)
                document.getElementById("main_table_manager").style.width = last_ie_width + "px";
            else {
                document.getElementById("main_table_manager").style.width = "100%";
                last_ie_width = document.getElementById("main_table_manager").clientWidth;
                if (last_ie_width < (min_width - diff)) last_ie_height = min_width;
            }
            if (cheight < min_height)
                document.getElementById("main_table_manager").style.height = last_ie_height + "px";
            else {
                document.getElementById("main_table_manager").style.height = "100%";
                last_ie_height = document.getElementById("main_table_manager").clientHeight;
                if (last_ie_height < (min_height - diff)) last_ie_height = min_height;
            }

            var htm = document.getElementById("lv_messages_td").innerHTML;
            document.getElementById("lv_messages_td").innerHTML = htm;
        }
        else if (window.navigator.userAgent.indexOf("Chrome") >= 0) { // Патч на IE для изменения размера окна, меньше положенного
            if (cwidth < min_width) document.getElementById("main_table_manager").style.width = min_width + "px";
            else document.getElementById("main_table_manager").style.width = "100%";
            if (cheight < min_height) document.getElementById("main_table_manager").style.height = min_height + "px";
            else document.getElementById("main_table_manager").style.height = "100%"

            var htm = document.getElementById("lv_messages_td").innerHTML;
            document.getElementById("lv_messages_td").innerHTML = htm;
        }
        else if (window.navigator.userAgent.indexOf("Firefox") >= 0) { // Патч на firefox для изменения размера окна
            // Устанавливаем высоту блока в 10 пикселей
            var htm = document.getElementById("lv_messages_td").innerHTML;
            document.getElementById("lv_messages_td").innerHTML = '<div class="livechat_message_help" id="lv_messages_help">{$mlang.Messages_history}</div> <div class="livechat_messages custom-scroll" name="lv_messages" id="lv_messages" style="overflow: auto; height:100%; position:relative; display:block;"><div id="lv_messages_history-1" class="livechat_history_messages"></div><hr class="livechat_history_hr"></div>';
            // document.getElementById("messages_block").innerHTML="";
            document.getElementById("lv_messages_td").style.height = "";

            var diff;
            out_height = document.getElementById("lv_messages_td").clientHeight;
            document.getElementById("lv_messages_td").style.height = out_height + "px";
            diff = out_height - document.getElementById("lv_messages_td").clientHeight;
            out_height += diff;
            document.getElementById("lv_messages_td").style.height = out_height + "px";

            document.getElementById("lv_messages_td").innerHTML = htm;
        }*/
    }
    ;

    // Открыть окно истории
    var history_window = 0;
    function open_history() {
        var left = ( screen.width - 600 ) / 2;
        var top = ( screen.height - 500 ) / 2;
        if ((history_window) && (!history_window.closed)) history_window.close();
        history_window = window.open('{$config.site_root}/modules/livechat/history.php?client_id=' + active_user, 'ConsuntantHistory', 'top=' + top + ', left=' + left + ', menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0, width=600, height=500');
        return false;
    }
    ;

    // Открыть окно привязки клиента
    var subscribe_window = 0;
    function open_subscribe() {
        if (active_user == -1) {
            alert("{$mlang.select_subscribe_user}");
            return false;
        }
        var left = ( screen.width - 648 ) / 2;
        var top = ( screen.height - 500 ) / 2;
        if ((subscribe_window) && (!subscribe_window.closed)) subscribe_window.close();
        subscribe_window = window.open('{$config.site_root}/modules/livechat/subscribe.php?client_id=' + active_user, 'ConsuntantSubscribe', 'top=' + top + ', left=' + left + ', menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0, width=648, height=500');
        return false;
    }
    ;

    // Передать клиента другому менеджеру
    var transmit_window = 0;
    function open_transmit() {
        if (active_user == -1) {
            alert("{$mlang.select_tranfer_user}");
            return false;
        }
        var left = ( screen.width - 600 ) / 2;
        var top = ( screen.height - 500 ) / 2;
        if ((transmit_window) && (!transmit_window.closed)) transmit_window.close();
        transmit_window = window.open('{$config.site_root}/modules/livechat/transmit.php?client_id=' + active_user, 'ConsuntantTransmit', 'top=' + top + ', left=' + left + ', menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0, width=600, height=500');
        return false;
    }


    // Забанить клиента по ip
    var ban_window = 0;
    function open_ban() {
        if (active_user == -1) {
            alert("{$mlang.select_ban_user}");
            return false;
        }
        var left = ( screen.width - 600 ) / 2;
        var top = ( screen.height - 500 ) / 2;
        if ((ban_window) && (!ban_window.closed)) ban_window.close();
        ban_window = window.open('{$config.site_root}/modules/livechat/ban.php?client_id=' + active_user, 'ConsuntantBan', 'top=' + top + ', left=' + left + ', menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0, width=600, height=500');
        return false;
    }

    // Функционал HOVER
    var last_hover_id = -1;
    function OverCLMouse(id) {
        last_hover_id = id;
        var obj = document.getElementById("contact_list_client" + id);
        if (obj) {
            if (obj.className.indexOf('_hover') == -1) {
                obj.className = obj.className + "_hover";
            }
        }
        ;
    }
    ;

    function OutCLMouse(id) {
        last_hover_id = -1;
        var obj = document.getElementById("contact_list_client" + id);
        if (obj) {
            if (obj.className.indexOf('_hover') != -1) {
                obj.className = obj.className.substr(0, obj.className.indexOf('_hover'));
            }
        }
        ;
    }
    ;

    function FixCLMouse() {
        if (last_hover_id == -1) return false;
        var id = last_hover_id;
        var obj = document.getElementById("contact_list_client" + id);
        if (obj) {
            if (obj.className.indexOf('_hover') == -1) {
                obj.className = obj.className + "_hover";
            }
        }
        ;
    }

    // Изменяем Title
    window.onblur = OnMyBlur;
    window.onfocusout = OnMyBlur;
    window.onfocus = OnMyFocus;

    var turn_alert = 0;
    function OnMyBlur() {
//  alert("Blur");
        if (turn_alert == 1) return;
        turn_alert = 1;
    }
    ;

    function OnMyFocus() {
        if (turn_alert == 0) return;
        turn_alert = 0;
        alert_mode = -1;
        //alert_title();
    }
    ;


    var state_left = 0;
    var old_title = document.title;

    function alert_title() {
        // Передача сообщения в родительское окно кб
        {literal}parent.postMessage(JSON.stringify({okTitle: old_title}), '*');{/literal}

        if (iID_alert_title != 0) clearInterval(iID_alert_title);
        if ((turn_alert == 0) || (alert_mode == -1)) {
            document.title = old_title;
            state_left = 0;
            iID_alert_title = 0;
            turn_alert = 0;
            alert_mode = -1;
            return;
        }
        if (state_left) {
            document.title = old_title;
            state_left = 0;
        }
        else {
            document.title = " ~ " + old_title + " ~ ";
            state_left = 1;
        }
        iID_alert_title = window.setInterval(alert_title, 500); // Обновляем каждую секунду
    }
    ;

    $(document).ready(function () {
        $(document).click(function (event) {
            if (!$(".okContextMenu__link").is(event.target)) {
                $('#okContextMenu').addClass('hidden');
            }
        });

        $('.one__fast_answer').click(function () { // При клике на быстрый ответ вствлем его в поле ввода
            const $this = $(this);
            const fastAnswerText = $this.text();
            $('#new_mess').val(fastAnswerText);
            $('.answers__tooltip').css('display','none');
        });

        $('.fast__answers-block').mouseover(function (e) {
            isFastAnswersOpen = false;
            $('.answers__tooltip').css({
                'display':'flex',
                'opacity': '1'
            });
        });

        $('.fast__answers-block').mouseout(function (e) {
            isFastAnswersOpen = true;
            $('.answers__tooltip').css({
                'display':'none',
                'opacity': '0'
            });
        });

        $('.answers__tooltip').mouseover(function () {
            if ( isFastAnswersOpen ) {
                $(this).css({
                    'display':'flex',
                    'opacity': '1'
                });
            }
        });

        $('.answers__tooltip').mouseout(function () {
            $(this).css({
                'display':'none',
                'opacity': '0'
            });
        });

        let un_muteElem = $('#un-mute');
        // Задаем мут
        if ( localStorage.getItem('muteSound') ) {
            muteSound = localStorage.getItem('muteSound');
            if ( muteSound == 'true' ) {
                un_muteElem.attr('checked','checked');
            }
        } else {
            muteSound = 'false';
        }

        un_muteElem.click(function () {
           if ( $('.unmute svg').css('display') == 'none' ) { // Если при клике статус мут
               localStorage.setItem('muteSound','false');
               muteSound = 'false';
           } else {
               localStorage.setItem('muteSound','true');
               muteSound = 'true';
           }
        });

        // Бросить пользователя
        $('#ok_button__drop-user').click(function (e) {
            e.preventDefault();
            updateClientManagerLink(active_user, -1);
            {literal}$(`#lv_messages${active_user}`).hide();{/literal}
            $('.message__header-name').text('');
            active_user = -1;
            last_active_user = -1;
        });

        $('.manager_ok__close-btn').click(function () {
            isWindowOpen = false;
            {literal}$(`#lv_messages${active_user}`).hide();{/literal}
            $('.message__header-name').text('');
            $.ajax({
                url: 'ajax_module.php?doClose=1',
                success: function (resp) {
                    // Передача сообщения в родительское окно кб
                    {literal}parent.postMessage(JSON.stringify({okWindow: 'hidden'}), '*');{/literal}
                }
            });
            active_user = -1;
            last_active_user = -1;
        });

        // Выход менеджера
        $('.message_ok-logout').click(function () {
            isWindowOpen = false;
            {literal}$(`#lv_messages${active_user}`).hide();{/literal}
            $('.message__header-name').text('');
            $.ajax({
                url: 'ajax_module.php?doLogout=1',
                success: function (resp) {
                    // Передача сообщения в родительское окно кб
                    {literal}parent.postMessage(JSON.stringify({okWindow: 'hidden'}), '*');{/literal}
                }
            })
            active_user = -1;
            last_active_user = -1;
        });

        $('.manager_ok__message-block').on('mouseenter', function(e) {
            // Читаем сообщения
            if ( active_user != -1 ) {
                $.ajax({
                    url: 'readMessages.php',
                    type: 'post',
                    data: {literal}`client_id=${active_user}&csrf=${csrf}`,{/literal}
                    success: function () {

                    }
                });
            }
        });

        create_preloader_block();
    });

    // Для приема сообщения извне
    window.addEventListener('message',function(e) {
        isWindowOpen = e.data.isWindowOpen;
        {literal}$(`#lv_messages${active_user}`).hide();{/literal}
        $('.message__header-name').text('');
    });

    function showPreloaderOK() {
        $('.overlay-ok').css('display','flex');
    }

    function hidePreloaderOK() {
        $('.overlay-ok').hide();
    }
</script>

<section class="manager_ok__wrapper" id="main_table_manager" onMouseOver="OnMyFocus();">
    <section class="manager_ok__users-block manager_ok__wrapper-block">
        <div class="users__header">
            Онлайн консультант
            <span class="livechat_online_status" id="livechat_status">{$lang.Online}</span>
            <img id="set_activity_image" width="1" height="1">
            <BGSOUND src="" id="bgsound_id">
            <div class="input__additional-buttons">
                <a href="#" class="additional__buttons-item" id="ok_button__mute" title="">
                    <input type="checkbox" name="un-mute" id="un-mute"/>
                    <label for="un-mute" class="unmute" title="Аудио оповещения заблокированы">
                        <img src="images/sound_off.png" style="width: 23px; height: 21px;" title="Аудио оповещения заблокированы"/>
                    </label>
                    <label for="un-mute" class="mute" title="Аудио оповещения включены">
                        <img src="images/sound_on.png" style="width: 23px; height: 21px;" title="Аудио оповещения включены"/>
                    </label>
                </a>
                <a href="#" class="message_ok-logout" title="Закончить сессию в Онлайн консультате">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 19" width="21" height="19">
                        <style>
                            tspan { white-space:pre }
                            .shp0 { fill: #5c5c5c }
                        </style>
                        <path id="Shape 2" class="shp0" d="M1.65 10.15L14.26 10.15C14.62 10.15 14.91 9.86 14.91 9.5C14.91 9.14 14.62 8.85 14.26 8.85L1.65 8.85C1.29 8.85 1 9.14 1 9.5C1 9.86 1.29 10.15 1.65 10.15L1.65 10.15ZM1.65 10.15M10.78 13.6C10.95 13.6 11.12 13.54 11.24 13.41L14.72 9.96C14.98 9.7 14.98 9.29 14.72 9.04L11.24 5.59C10.99 5.33 10.58 5.33 10.32 5.59C10.07 5.84 10.07 6.25 10.32 6.5L13.34 9.5L10.32 12.5C10.07 12.75 10.07 13.16 10.32 13.41C10.45 13.54 10.62 13.6 10.78 13.6L10.78 13.6ZM10.78 13.6M11.43 19C16.71 19 21 14.74 21 9.5C21 4.26 16.71 0 11.43 0C7.48 0 3.98 2.36 2.53 6.02C2.4 6.36 2.57 6.73 2.9 6.87C3.23 6.99 3.61 6.83 3.75 6.5C5 3.34 8.02 1.3 11.43 1.3C15.99 1.3 19.7 4.98 19.7 9.5C19.7 14.02 15.99 17.7 11.43 17.7C8.02 17.7 5 15.66 3.75 12.5C3.61 12.17 3.24 12.01 2.9 12.14C2.57 12.27 2.4 12.64 2.53 12.98C3.98 16.64 7.48 19 11.43 19L11.43 19ZM11.43 19" />
                    </svg>
                </a>
            </div>
        </div>
        <div class="users__content">
            <div class="livechat_clients custom-scroll"
                 style="overflow: auto; width:100%; height:100%; display:block;">
                <div name="lv_clients" id="lv_clients">
                </div>
                <div id="okContextMenu" class="hidden">
                    <a class="okContextMenu__link" target="_blank" href="{$config.site_root}/modules/livechat/subscribe_open.php?client_id=">
                        Открыть в таблице
                    </a>
                </div>
            </div>
        </div>
    </section>
    <section class="manager_ok__message-block manager_ok__wrapper-block">
        <div class="message__header">
            <div class="message__header-name__wraper">
                <div class="message__header-name">
                </div>
                <div class="input__additional-buttons">
                    <a href="#" class="additional__buttons-item" id="ok_button__link" onclick="return open_subscribe();" title="{$lang.Bind}">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 19" width="27" height="18">
                            <style>
                                tspan { white-space:pre }
                                .shp0 { fill: #a7b9c5 }
                            </style>
                            <path class="shp0" d="M16.63 7.92L20.89 7.92L20.89 3.77L23.74 3.77L23.74 7.92L28 7.92L28 10.69L23.74 10.69L23.74 14.85L20.89 14.85L20.89 10.69L16.63 10.69L16.63 7.92ZM9.53 9.31C7.11 9.31 5.26 7.51 5.26 5.15C5.26 2.8 7.11 1 9.53 1C11.94 1 13.79 2.8 13.79 5.15C13.79 7.51 11.94 9.31 9.53 9.31ZM9.53 12.08C12.37 12.08 18.05 13.46 18.05 16.23L18.05 19L1 19L1 16.23C1 13.46 6.68 12.08 9.53 12.08Z" />
                        </svg>
                    </a>
                    <a href="#" class="additional__buttons-item" id="ok_button__transfer" onclick="return open_transmit();" title="{$lang.Transfer}">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 31 19" width="27" height="18">
                            <style>
                                tspan { white-space:pre }
                                .shp0 { fill: #a7b9c5 }
                            </style>
                            <path class="shp0" d="M9.47 9.31C11.89 9.31 13.74 7.51 13.74 5.15C13.74 2.8 11.89 1 9.47 1C7.06 1 5.21 2.8 5.21 5.15C5.21 7.51 7.06 9.31 9.47 9.31ZM9.47 12.08C6.63 12.08 0.95 13.46 0.95 16.23L0.95 19L18 19L18 16.23C18 13.46 12.32 12.08 9.47 12.08Z" />
                            <path class="shp0" d="M18,11.67h6.29v2.33l5.71,-4.5l-5.71,-4.5v2.33h-6.29z" />
                        </svg>
                    </a>
                    <a href="#" class="additional__buttons-item" id="ok_button__user_ban" onclick="return open_ban();" title="{$lang.Ban}">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 20" width="14" height="19">
                            <style>
                                tspan { white-space:pre }
                                .shp0 { fill: #a7b9c5 }
                            </style>
                            <path class="shp0" d="M14.61 8.12L13.44 8.12L13.44 6.54C13.44 3.49 11 1 8 1C5 1 2.56 3.49 2.56 6.54L2.56 8.12L1.39 8.12C1.17 8.12 1 8.3 1 8.52L1 18.42C1 19.29 1.7 20 2.56 20L13.44 20C14.3 20 15 19.29 15 18.42L15 8.52C15 8.3 14.83 8.12 14.61 8.12ZM9.16 16.39C9.18 16.51 9.14 16.62 9.07 16.7C8.99 16.79 8.89 16.83 8.78 16.83L7.22 16.83C7.11 16.83 7.01 16.79 6.93 16.7C6.86 16.62 6.82 16.51 6.84 16.39L7.08 14.15C6.68 13.85 6.44 13.39 6.44 12.87C6.44 12 7.14 11.29 8 11.29C8.86 11.29 9.56 12 9.56 12.87C9.56 13.39 9.32 13.85 8.92 14.15L9.16 16.39ZM11.11 8.12L4.89 8.12L4.89 6.54C4.89 4.8 6.28 3.37 8 3.37C9.72 3.37 11.11 4.8 11.11 6.54L11.11 8.12Z" />
                        </svg>
                    </a>
                    <a href="#" class="additional__buttons-item" id="ok_button__drop-user" title="Закончить диалог с клиентом">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="19" height="19">
                            <style>
                                tspan { white-space:pre }
                                .shp0 { fill: #a7b9c5 }
                            </style>
                            <path class="shp0" d="M10.5 1C5.27 1 1 5.27 1 10.5C1 15.72 5.27 20 10.5 20C15.72 20 20 15.72 20 10.5C20 5.27 15.72 1 10.5 1ZM15.25 13.92L13.92 15.25L10.5 11.83L7.08 15.25L5.75 13.92L9.17 10.5L5.75 7.08L7.08 5.75L10.5 9.17L13.92 5.75L15.25 7.08L11.83 10.5L15.25 13.92Z" />
                        </svg>
                    </a>
                    {*<a href="#" class="additional__buttons-item" id="ok_button__addFile">
                        <input type="file" name=""/>
                        <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
                             width="30px" height="30px" viewBox="0 0 612.675 612.675" style="enable-background:new 0 0 612.675 612.675;"
                             xml:space="preserve">
                            <g>
                                <g id="_x34__17_">
                                    <g>
                                        <path d="M581.209,223.007L269.839,530.92c-51.592,51.024-135.247,51.024-186.839,0c-51.592-51.023-51.592-133.737,0-184.761
                                            L363.248,69.04c34.402-34.009,90.15-34.009,124.553,0c34.402,34.008,34.402,89.166,0,123.174l-280.249,277.12
                                            c-17.19,17.016-45.075,17.016-62.287,0c-17.19-16.993-17.19-44.571,0-61.587L394.37,161.42l-31.144-30.793L114.144,376.975
                                            c-34.402,34.009-34.402,89.166,0,123.174c34.402,34.009,90.15,34.009,124.552,0l280.249-277.12
                                            c51.592-51.023,51.592-133.737,0-184.761c-51.593-51.023-135.247-51.023-186.839,0L36.285,330.784l1.072,1.071
                                            c-53.736,68.323-49.012,167.091,14.5,229.88c63.512,62.79,163.35,67.492,232.46,14.325l1.072,1.072l326.942-323.31
                                            L581.209,223.007z"/>
                                    </g>
                                </g>
                            </g>
                        </svg>
                    </a>*}
                </div>
            </div>
            <div class="message__header-close">
                <a href="#" class="manager_ok__close-btn" title="Закрыть окно">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 17" width="17" height="17">
                        <style>
                            tspan { white-space:pre }
                            .shp0 { fill: #5c5c5c }
                        </style>
                        <path class="shp0" d="M17,1.93l-0.93,-0.93l-7.07,7.07l-7.07,-7.07l-0.93,0.93l7.07,7.07l-7.07,7.07l0.93,0.93l7.07,-7.07l7.07,7.07l0.93,-0.93l-7.07,-7.07z" />
                    </svg>
                </a>
            </div>
        </div>
        <div class="message__history">
            <div id="lv_messages_td" class="custom-scroll">
                <div class="livechat_messages custom-scroll" name="lv_messages-1" id="lv_messages-1"
                     style="overflow: auto; position:relative;">
                </div>
            </div>
        </div>
        <div class="message__input">
            <div class="input__wrapper-one">
                <div class="input__textarea">
                    <textarea rows="2" class="livechat_textarea no-scroll"" name="new_mess" id="new_mess" onkeydown="javascript: if (((event.keyCode == 0xA)||(event.keyCode == 0xD))&&(!event.shiftKey)) return post_message();" placeholder="Введите сообщение"></textarea>
                </div>
                <div class="input__additional-buttons">
                    {*<a href="#" class="additional__buttons-item" id="ok_button__addFile">
                        <input type="file" name=""/>
                        <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
                             width="30px" height="30px" viewBox="0 0 612.675 612.675" style="enable-background:new 0 0 612.675 612.675;"
                             xml:space="preserve">
                            <g>
                                <g id="_x34__17_">
                                    <g>
                                        <path d="M581.209,223.007L269.839,530.92c-51.592,51.024-135.247,51.024-186.839,0c-51.592-51.023-51.592-133.737,0-184.761
                                            L363.248,69.04c34.402-34.009,90.15-34.009,124.553,0c34.402,34.008,34.402,89.166,0,123.174l-280.249,277.12
                                            c-17.19,17.016-45.075,17.016-62.287,0c-17.19-16.993-17.19-44.571,0-61.587L394.37,161.42l-31.144-30.793L114.144,376.975
                                            c-34.402,34.009-34.402,89.166,0,123.174c34.402,34.009,90.15,34.009,124.552,0l280.249-277.12
                                            c51.592-51.023,51.592-133.737,0-184.761c-51.593-51.023-135.247-51.023-186.839,0L36.285,330.784l1.072,1.071
                                            c-53.736,68.323-49.012,167.091,14.5,229.88c63.512,62.79,163.35,67.492,232.46,14.325l1.072,1.072l326.942-323.31
                                            L581.209,223.007z"/>
                                    </g>
                                </g>
                            </g>
                        </svg>
                    </a>*}
                </div>
            </div>
            <div class="input__wrapper-two">
                <div class="input__action-buttons">
                    <a href="#" class="send_button" onclick="return post_message();">
                        <span class="send_button_span" id="send_button_span">
                            {*<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 131 131" width="131" height="131">
                                <defs>
                                    <image width="131" height="131" id="img1-send" href="data:image/png;base64, "/>
                                </defs>
                                <style>
                                    tspan { white-space:pre }
                                </style>
                                <use href="#img1-send" x="0" y="0" />
                            </svg>*}
                            <div class="send_button__circle">
                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 25" width="24" height="25">
                                        <defs>
                                        <image width="24" height="25" id="img1-circle" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAMAAACnUt2HAAAAAXNSR0IB2cksfwAAAThQTFRF////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////4g1iRQAAAGh0Uk5TAAhYxNZGuP7/zj2r/a8xnvDs5JMnkO/RbxyE42DgVRV33bQ4xjYNZdKlFq0fCVzIiAaSzBFRv/lybqkDwV1M9owaVqLfQynmcSBmnTQmzfxNa/L1MAEdImcTgix+9MsCqA8/jqyJxQ7t3DDYAAAA4ElEQVR4nGNgQAOMTMws6GKsbOwcnKhCXNw8HBwcvMhCfPwCHIJC7BzCCCERUTEODnGgOIcETEhSShqokVlGloODRw4iJK+gCBTiUFJWAZJiqiAhNXUNkBCHppY2iFLUYWDQ1dMHC3EYGBqBaWMTBlMziJC5BYMlhGVlzWADYQnYMtjZQ5gODAyOTs5Ae11cGdzcIWIcHmC7Pb28fRh8/aBi/gEItwcGQQWDQ2BCoW5h4RE2YEOlI+EKtVmiohmUY5hjOeLi4YIJHBwg3yUmJQcijEzhSEUPWgYG7rR0BAcAtF8aLxEKeLMAAAAASUVORK5CYII="></image>
                                        </defs>
                                        <style>
                                        tspan { white-space:pre }
                                </style>
                                    <use href="#img1-circle" x="0" y="0"></use>
                                </svg>
                            </div>
                        </span>
                    </a>
                    <a href="#" class="fast__answers-block" title="Быстрые ответы">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27 22" width="27" height="22">
                            <style>
                                tspan { white-space:pre }
                                .shp0 { fill: #a7b9c5 }
                            </style>
                            <path id="Forma 1" class="shp0" d="M7.15 8.39L19.85 8.39C20.34 8.39 20.73 8.01 20.73 7.52C20.73 7.03 20.34 6.64 19.85 6.64L7.15 6.64C6.66 6.64 6.27 7.03 6.27 7.52C6.27 8.01 6.66 8.39 7.15 8.39ZM7.15 12.61L19.85 12.61C20.34 12.61 20.73 12.22 20.73 11.73C20.73 11.24 20.34 10.86 19.85 10.86L7.15 10.86C6.66 10.86 6.27 11.24 6.27 11.73C6.27 12.22 6.66 12.61 7.15 12.61ZM1.88 18.25L4.72 18.25L4.72 21.13C4.72 21.47 4.92 21.77 5.22 21.91C5.35 21.98 5.48 22 5.6 22C5.8 22 5.99 21.94 6.14 21.83L10.88 18.27L25.12 18.27C25.61 18.27 26 17.89 26 17.4L26 1.87C26 1.38 25.61 1 25.12 1L1.88 1C1.39 1 1 1.38 1 1.87L1 17.38C1 17.87 1.41 18.25 1.88 18.25ZM2.76 2.75L24.21 2.75L24.21 16.51L10.57 16.51C10.38 16.51 10.19 16.57 10.04 16.68L6.49 19.36L6.49 17.38C6.49 16.89 6.1 16.51 5.6 16.51L2.76 16.51L2.76 2.75Z" />
                        </svg>
                    </a>
                    <div class="answers__tooltip answers__top_tooltip custom-scroll">
                        <div class="one__fast_answer-header">Быстрые ответы</div>
                        {foreach from=$f_replies item=f_ans}
                            <div class="one__fast_answer">{$f_ans}</div>
                        {/foreach}
                    </div>
                </div>
            </div>
        </div>
    </section>
</section>

{*<section width="100%" height="100%" cellspacing="0" cellpadding="0" border=0
       style="table-layout: fixed;min-width:770px;min-height:480px;" id="main_table_manager" onMouseOver="OnMyFocus();">
    <div>
        <div valign=top id="lv_messages_td">
            <div class="livechat_messages" name="lv_messages-1" id="lv_messages-1"
                 style="overflow: auto; height:100%; position:relative;">
            </div>
        </div>
        <div valign="top" width="320px" style="padding: 0px 0px 0px 10px;">
            <span class="livechat_message_help">{$mlang.Clients_list}</span>
            <div class="livechat_clients"
                 style="overflow: auto; width:100%; height:100%; position:relative; display:block;">
                <div name="lv_clients" id="lv_clients">&nbsp;
                </div>
            </div>
        </div>
    </div>
    <div>
        <div height="130px" style="padding: 3px 0px 0px 0px;">
            <br>
            <section width="100%">
                <div>
                    <div nowrap>
                        <select id="fast_replies" name="fast_replies" style="width : 200;">
                            {$f_replies}
                        </select>  <span id="send_fast_reply">
<a href="#"
   onClick="x=getElementById('fast_replies'); getElementById('new_mess').value=x.options[x.selectedIndex].text; post_message();">
    {$mlang.send_fast_reply}</a> </span></div>
                    <div width="90%"></div>
                    <div nowrap>

                        <span class="livechat_online_status" id="livechat_status">{$lang.Online}</span>&nbsp; <span><a
                                    href="#" onclick="return open_history();">{$lang.History}</a> / <a href="#"
                                                                                                       onclick="return open_subscribe();">{$lang.Bind}</a> / <a
                                    href="#" onclick="return open_transmit();">{$lang.Transfer}</a> / <a href="#"
                                                                                                         onclick="return open_ban();">{$lang.Ban}</a></span>
                    </div>
                </div>
            </section>
<textarea rows="2" class="livechat_textarea" name="new_mess" id="new_mess" onkeydown="javascript:
{if $post_on_enter eq 1}
        if ((event.keyCode == 0xA)||(event.keyCode == 0xD))
        {
            if (!(event.ctrlKey))
                return post_message();
            else document.getElementById('new_mess').value += '\r\n';
        }
{/if}

{if $post_on_enter eq 0}
        if ((event.keyCode == 0xA)||(event.keyCode == 0xD))
        {
            if (event.ctrlKey)
                return post_message();
        }
{/if}"></textarea>
            <img id="set_activity_image" width="1" height="1">
            <BGSOUND src="" id="bgsound_id">
        </div>
        <div>
            <a href="#" class="send_button" onclick="return post_message();" style="margin: 30px 0 0 20px;">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <span class="send_button_span" id="send_button_span">{$lang.Send}</span>
            </a>
        </div>
    </div>
</section>*}
    <div class='overlay-ok' style="display: none;">
        <div class="ok__preloader-data">
            <div class="preloader__block" style="z-index: 10000000;">
                <div class="preloader">
                    <div class="lds-css ng-scope">
                        <div style="width:100%;height:100%" class="lds-ellipsis">
                            <div>
                                <div></div>
                            </div>
                            <div>
                                <div></div>
                            </div>
                            <div>
                                <div></div>
                            </div>
                            <div>
                                <div></div>
                            </div>
                            <div>
                                <div></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    <div>
</body>
