// Start of Tawk.to Script
var whitelabelcolor = "#70A8A8";

var talkChatElem;
var $_Tawk_API = {}, $_Tawk_LoadStart = new Date();
(function () {
    var s1 = document.createElement("script"), s0 = document.getElementsByTagName("script")[0];
    s1.async = true;
    s1.src = 'https://embed.tawk.to/555a31ace193f46370701cde/default';
    s1.charset = 'UTF-8';
    s1.setAttribute('crossorigin', '*');
    s0.parentNode.insertBefore(s1, s0);
})();

$(document).ready(function () {
    $('#talkto-show-button').click(function (e) {
        e.preventDefault();
        $('iframe').each(function(i,o) {
            if ($(o).contents().find('#tawkchat-minified-container').length != 0) {
                talkChatElem = $(o).contents().find('#tawkchat-minified-container');
                talkChatElem.click();
                return false;
            }

            if ($(o).contents().find('#tawkchat-maximized-container-element').length != 0) {
                talkChatElem = $(o).contents().find('#tawkchat-maximized-container-element');
                talkChatElem.click();
                return false;
            }
        });
    });

    setTimeout(function () {
        $('iframe').each(function(i,o) {
            if ($(o).contents().find('#tawkchat-minified-container').length != 0) {
                talkChatElem = $(o).contents().find('#tawkchat-minified-container');
                return false;
            }

            if ($(o).contents().find('#tawkchat-maximized-container-element').length != 0) {
                talkChatElem = $(o).contents().find('#tawkchat-maximized-container-element');
                return false;
            }
        });

        $('#chat-indicator-iframe').contents().find('head').append('<style type="text/css">#tawkchat-chat-indicator { left: 90px !important; background: ' + whitelabelcolor + ' !important; } #tawkchat-chat-indicator::after { right: 16.5px !important; border-top: 8px solid ' + whitelabelcolor + ' !important; }</style>');
        $('#chat-indicator-iframe').contents().find('#tawkchat-chat-indicator').wrap('<a id="tawkchat-indicator-button" href="#"></a>');
        $('#chat-indicator-iframe').contents().find('#tawkchat-indicator-button').click(function (e) {
            e.preventDefault();
            $(talkChatElem).click();
        });
    }, 1000);
});

// End of Tawk.to Script