<!--[if IE]>
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/excanvas.min.js?ver={$MAILBEEZ_VERSION}"></script><![endif]-->
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/gauge.js?ver={$MAILBEEZ_VERSION}"></script>
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/jquery.gauge.js?ver={$MAILBEEZ_VERSION}"></script>
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/flot/jquery.flot.js?ver={$MAILBEEZ_VERSION}"></script>
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/flot/jquery.flot.resize.js?ver={$MAILBEEZ_VERSION}"></script>
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/flot/jquery.flot.stack.js?ver={$MAILBEEZ_VERSION}"></script>
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/flot/jquery.flot.time.js?ver={$MAILBEEZ_VERSION}"></script>
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/flot/jquery.flot.canvas.js?ver={$MAILBEEZ_VERSION}"></script>
<script language="javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/timeago/jquery.timeago.js?ver={$MAILBEEZ_VERSION}"></script>
{if $smarty.session.language == 'german'}
    <script language="javascript"
            src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/timeago/locales/jquery.timeago.de.js?ver={$MAILBEEZ_VERSION}"></script>
{/if}
{*<script src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/vendor/t4t5/sweetalert/lib/sweetalert.js"></script>*}
{*<link rel="stylesheet" type="text/css" href="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/vendor/t4t5/sweetalert/sweetalert.css">*}


{*http://iamceege.github.io/tooltipster/#demos*}
{*
<script type="text/javascript"
        src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/js/jquery.tooltipster.min.js"></script>
*}
<script src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/vendor/victor-valencia/mailbeez_es6-promise.min.js?ver={$MAILBEEZ_VERSION}"></script> <!-- IE11 support -->
{capture name='MH_PLATFORM_GAMBIO'}{mh_cfg key='MH_PLATFORM_GAMBIO'}{/capture}
{if $smarty.capture.MH_PLATFORM_GAMBIO >= 2.6 }
    {*<script type="text/javascript">*}
    {*require('{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/vendor/limonte/sweetalert2/sweetalert2.js');*}
    {*</script>*}
    {*
    <script src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/vendor/limonte/sweetalert2/mailbeez_sweetalert2.js"></script>
    *}
{else}
{/if}

<script src="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/vendor/limonte/sweetalert2/mailbeez_sweetalert2.js?ver={$MAILBEEZ_VERSION}"></script>
<link rel="stylesheet" type="text/css"
      href="{$MH_CATALOG_URL}{$MH_ROOT_PATH}common/vendor/limonte/sweetalert2/sweetalert2.css?ver={$MAILBEEZ_VERSION}">

<style>
    {literal}

    .swal-button {
    {/literal}
        background-color: #efefef;
        color: #555;
    {literal}
    }
    .swal-button:not([disabled]):hover {
    {/literal}
        background-color: #e8e8e8;
        color: #555;
    {literal}
    }


    .swal-text, .swal-footer {
        text-align: center;
    }
    .swal-button--danger {
    {/literal} background-color: {mh_cfg key='MH_COLOR_RED'};
    {literal}
        color: #ffffff;
    }

    {/literal}
</style>
<script type="text/javascript">
    {literal}


    var initMailBeezApp;

    jQuery(document).ready(function () {

        initMailBeezApp = function () {

            jQuery(".ceebox").ceebox({
                overlayOpacity: 0.2,
                animSpeed: 1,
                fadeIn: 10,
                fadeOut: 1,
                easing: 'linear',
                titles: false,
                borderColor: '#666'
            });

            jQuery.timeago.settings.allowFuture = true;
            jQuery("abbr.timeago").timeago();

            jQuery('a[href*="action=remove"]').click(function (e) {
                e.preventDefault(); // Prevent the href from redirecting directly
                var linkURL = $(this).attr("href");
                warnUninstall(linkURL);
            });

            // jQuery('*[href*="app_action=delete"]').off('click').css({ 'border': "1px solid red" });
            jQuery('*[href*="app_action=delete"]').click(function (e) {
                e.preventDefault(); // Prevent the href from redirecting directly
                var linkURL = $(this).attr("href");
                warnDelete(linkURL);
            });

            jQuery('a#emailRepair').click(function (e) {
                e.preventDefault(); // Prevent the href from redirecting directly
                emailRepair();
            });

        }


        function warnUninstall(linkURL) {
            swal({
                // {/literal}
                {capture name='MAILBEEZ_CONFIRMATION_UNINSTALL_TITLE'}{mh_cfg key='MAILBEEZ_CONFIRMATION_UNINSTALL_TITLE'}{/capture}
                {capture name='MAILBEEZ_CONFIRMATION_UNINSTALL_TEXT'}{mh_cfg key='MAILBEEZ_CONFIRMATION_UNINSTALL_TITLE'}{/capture}
                {capture name='MAILBEEZ_CONFIRMATION_CANCEL_BUTTON'}{mh_cfg key='MAILBEEZ_CONFIRMATION_CANCEL_BUTTON'}{/capture}
                {capture name='MAILBEEZ_CONFIRMATION_OK_BUTTON'}{mh_cfg key='MAILBEEZ_CONFIRMATION_OK_BUTTON'}{/capture}

                title: "{$smarty.capture.MAILBEEZ_CONFIRMATION_UNINSTALL_TITLE|html_entity_decode}",
                text: "{$smarty.capture.MAILBEEZ_CONFIRMATION_UNINSTALL_TEXT|html_entity_decode}",
                icon: "warning",

                // {literal}
                buttons: {
                    // {/literal}
                    cancel: "{$smarty.capture.MAILBEEZ_CONFIRMATION_CANCEL_BUTTON|html_entity_decode}",
                    // {literal}
                    confirm: {
                        // {/literal}
                        text: "{$smarty.capture.MAILBEEZ_CONFIRMATION_OK_BUTTON|html_entity_decode}",
                        // {literal}
                        value: "OK"
                    },
                },
                animation: false,
                dangerMode: true
            }).then(function (value) {
                switch (value) {
                    case "OK":
                        window.location.href = linkURL;
                        break;
                }
            });
        }


        function warnDelete(linkURL) {
            swal({
                // {/literal}
                {capture name='MAILBEEZ_CONFIRMATION_DELETE_TITLE'}{mh_cfg key='MAILBEEZ_CONFIRMATION_DELETE_TITLE'}{/capture}
                {capture name='MAILBEEZ_CONFIRMATION_DELETE_TEXT'}{mh_cfg key='MAILBEEZ_CONFIRMATION_DELETE_TEXT'}{/capture}
                {capture name='MAILBEEZ_DELETE_CANCEL_BUTTON'}{mh_cfg key='MAILBEEZ_DELETE_CANCEL_BUTTON'}{/capture}
                {capture name='MAILBEEZ_DELETE_OK_BUTTON'}{mh_cfg key='MAILBEEZ_DELETE_OK_BUTTON'}{/capture}

                title: "{$smarty.capture.MAILBEEZ_CONFIRMATION_DELETE_TITLE|html_entity_decode}",
                text: "{$smarty.capture.MAILBEEZ_CONFIRMATION_DELETE_TEXT|html_entity_decode}",
                icon: "warning",

                // {literal}
                buttons: {
                    // {/literal}
                    cancel: "{$smarty.capture.MAILBEEZ_DELETE_CANCEL_BUTTON|html_entity_decode}",
                    // {literal}
                    confirm: {
                        // {/literal}
                        text: "{$smarty.capture.MAILBEEZ_DELETE_OK_BUTTON|html_entity_decode}",
                        // {literal}
                        value: "OK"
                    },
                },
                animation: false,
                dangerMode: true
            }).then(function (value) {
                switch (value) {
                    case "OK":
                        window.location.href = linkURL;
                        break;
                }
            });
        }

        function emailRepair() {

            var link = document.createElement("a");
            link.onclick = function () {
                swal.close();

                // {/literal}
                return openDocsPopup('{mh_cfg key='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_DOCS_URL'}')
                // {literal}
            };
            // {/literal}
            link.innerHTML = "{mh_cfg key='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_DOCS_BUTTON'}";
            // {literal}
            link.style.display = 'display: inline-block';
            link.style.color = 'rgb(170, 170, 170)';
            link.style.fontSize = "medium";

            swal({
                // {/literal}
                {capture name='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_TITLE'}{mh_cfg key='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_TITLE'}{/capture}
                {capture name='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_TEXT'}{mh_cfg key='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_TEXT'}{/capture}
                {capture name='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_DELETE_BUTTON'}{mh_cfg key='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_DELETE_BUTTON'}{/capture}
                {capture name='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_IGNORE_BUTTON'}{mh_cfg key='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_IGNORE_BUTTON'}{/capture}
                {capture name='MAILBEEZ_CONFIRMATION_CANCEL_BUTTON'}{mh_cfg key='MAILBEEZ_CONFIRMATION_CANCEL_BUTTON'}{/capture}

                title: '{$smarty.capture.MAILBEEZ_CONFIRMATION_SMTP_REPAIR_TITLE|html_entity_decode}',
                text: '{$smarty.capture.MAILBEEZ_CONFIRMATION_SMTP_REPAIR_TEXT|html_entity_decode} ',
                content: link,
                icon: 'info',
                // {literal}
                buttons: {
                    btn_repair: {
                        // {/literal}
                        text: "{$smarty.capture.MAILBEEZ_CONFIRMATION_SMTP_REPAIR_DELETE_BUTTON}",
                        // {literal}
                        value: "repair"
                    },
                    btn_ignore: {
                        // {/literal}
                        text: '{$smarty.capture.MAILBEEZ_CONFIRMATION_SMTP_REPAIR_IGNORE_BUTTON}',
                        // {literal}
                        value: "ignore"
                    },
                    // {/literal}
                    cancel: "{$smarty.capture.MAILBEEZ_CONFIRMATION_CANCEL_BUTTON}"
                    // {literal}
                },


            }).then(function (value) {

                switch (value) {
                    case "repair":
                        // remove email errors
                        window.location.href = 'mailbeez.php?app=load_app&app_path=config_email_engine/admin_application_plugins/smtp_repair.php'
                        break;
                    case "ignore":
                        // set ignore email errors
                        window.location.href = 'mailbeez.php?app=load_app&app_path=config_email_engine/admin_application_plugins/smtp_ignore.php'
                        break;
                    case "docs":
                        // {/literal}
                        return openDocsPopup("{mh_cfg key='MAILBEEZ_CONFIRMATION_SMTP_REPAIR_DOCS_URL'}")
                        // {literal}
                        break;

                }

            });
        }

        initMailBeezApp();

    });

    function openModal(link, cwidth, cheight, isTransparent) {
        let opacity = isTransparent ? 0.0 : 0.2; // Adjust the opacity as needed

        jQuery.fn.ceebox.popup('<a href="' + link + '" rel="iframe width:'  + cwidth +' height:'  + cheight +' ">link</a>', {
            overlayOpacity: opacity,
            animSpeed: 1,
            fadeIn: 1,
            fadeOut: 1,
            easing: 'linear',
            titles: false,
            width: cwidth,
            height: cheight
        });

        return false;
    }


    function openDocsPopup(popup_link) {
        {/literal}
        {if ($MAILBEEZ_MAILHIVE_POPUP_MODE == 'CeeBox')}
        {literal}
        jQuery.fn.ceebox.popup('<a href="' + popup_link + '" rel="iframe width:750">link</a>', {
            overlayOpacity: 0.2,
            animSpeed: 1,
            fadeIn: 1,
            fadeOut: 1,
            easing: 'linear',
            titles: false,
            borderColor: '#666',

        });
        {/literal}
        {/if}
        {literal}

        return false;
    }

    function openReportPopup(popup_link, isTransparent) {
        {/literal}
        {if ($MAILBEEZ_MAILHIVE_POPUP_MODE == 'CeeBox')}
        {literal}


        let opacity = isTransparent ? 0.0 : 0.2; // Adjust the opacity as needed


        jQuery.fn.ceebox.popup('<a href="' + popup_link + '" rel="iframe">link</a>', {
            overlayOpacity: opacity,
            animSpeed: 1,
            fadeIn: 1,
            fadeOut: 1,
            easing: 'linear',
            titles: false,
            borderColor: '#666'
        });
        {/literal}
        {/if}
        {literal}

        return false;
    }

    function openCISPopup(cid, viewmodule, isTransparent) {
        {/literal}
        {capture name='MAILBEEZ_INSIGHT_VIEW_STATUS'}{mh_cfg key='MAILBEEZ_INSIGHT_VIEW_STATUS'}{/capture}
        {if $smarty.capture.MAILBEEZ_INSIGHT_VIEW_STATUS == 'True'}
        return openReportPopup('{$MAILBEEZ_CIS_URL}&cID=' + cid + '&view_module=' + viewmodule, isTransparent);
        {else}
        return false;
        {/if}
        {literal}
    }

    function openCBTip(content, cwidth, cheight) {
        jQuery.fn.ceebox.popup(content, {
            overlayOpacity: 0.0,
            animSpeed: 1,
            fadeIn: 1,
            fadeOut: 1,
            easing: 'linear',
            titles: false,
            borderColor: '#666',
            width: cwidth,
            height: cheight
        });
    }

    {/literal}
</script>
