/* Minification failed. Returning unminified contents.
(79,5,102,6): run-time error JS1314: Implicit property name must be identifier: fnHideGooTrans() {
        $.ajax({
            url: window.location.origin + "/Master/SetCookieGooTrans",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken(),
                value: "2"
            },
            type: "POST",
            cache: false,
            success: function (result) {
                $(".select-gootrans-item").text("Start Google Translate");
                $(".skiptranslate:first-child").hide();
                $("#google_translate_element_position").hide();
                $("#naxosheader-sticky").removeClass("goog-te-banner-bar-show");
                $("#naxosheader-sticky").addClass("goog-te-banner-bar-hide");
                $("#gootran-placeholder").hide();
                window.MyReset = () => jQuery('#\\:1\\.container').contents().find('#\\:1\\.restore').click();
                document.cookie = "googtrans=";
                window.location.reload();
            },
            error: function (xhr, ajaxOptions, thrownError) {
            }
        });
    }
 */
/* ============================================================
 *
 * js/app/layout/gootrans.js
 *
 * ========================================================== */

var layout_gootrans = {

    fnShowGooTranslation: function () {
        $("#myModalGooTrans").modal("hide");
        $.ajax({
            url: window.location.origin + "/Master/SetCookieGooTrans",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken(),
                value: "1"
            },
            type: "POST",
            cache: false,
            success: function (result) {
                $(".select-gootrans-item").text("Stop Google Translate");
                $(".select-gootrans-item-mini").text("Stop Google Translate");
                layout_gootrans.fnShowGooTran();
            },
            error: function (xhr, ajaxOptions, thrownError) {
            }
        });
    },

    fnShowGooTranslationConfirmed: function () {
        $(".btn-close-modal-mygootrans").click();
        $.ajax({
            url: window.location.origin + "/Master/SetCookieGooTrans",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken(),
                value: "1"
            },
            type: "POST",
            cache: false,
            success: function (result) {
                $(".select-gootrans-item").text("Stop Google Translate");
                $(".select-gootrans-item-mini").text("Stop Google Translate");
                layout_gootrans.fnShowGooTran();
                alert("Click 'Select Language' in the top-left corner.");
            },
            error: function (xhr, ajaxOptions, thrownError) {
            }
        });
    },

    fnLoadGooTrans: function () {
        $.ajax({
            url: window.location.origin + "/Master/GetCookieGooTrans",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken()
            },
            type: "POST",
            cache: false,
            success: function (result) {
                if (result == "1") {
                    $(".select-gootrans-item").text("Stop Google Translate");
                    $(".select-gootrans-item-mini").text("Stop Google Translate");
                    layout_gootrans.fnShowGooTran();
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
            }
        });
    },

    fnShowGooTran: function () {
        $("#google_translate_element_position").show();
        new google.translate.TranslateElement({ includedLanguages: 'en,zh-CN,zh-TW,fr,de,ja,ko,pt,es', layout: google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element');
        $(".goog-te-gadget").show();
        $("#naxosheader-sticky").removeClass("goog-te-banner-bar-hide");
        $("#naxosheader-sticky").addClass("goog-te-banner-bar-show");
        $("#gootran-placeholder").show();
    },

    fnHideGooTrans() {
        $.ajax({
            url: window.location.origin + "/Master/SetCookieGooTrans",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken(),
                value: "2"
            },
            type: "POST",
            cache: false,
            success: function (result) {
                $(".select-gootrans-item").text("Start Google Translate");
                $(".skiptranslate:first-child").hide();
                $("#google_translate_element_position").hide();
                $("#naxosheader-sticky").removeClass("goog-te-banner-bar-show");
                $("#naxosheader-sticky").addClass("goog-te-banner-bar-hide");
                $("#gootran-placeholder").hide();
                window.MyReset = () => jQuery('#\\:1\\.container').contents().find('#\\:1\\.restore').click();
                document.cookie = "googtrans=";
                window.location.reload();
            },
            error: function (xhr, ajaxOptions, thrownError) {
            }
        });
    }

};

$(function () {

    layout_gootrans.fnLoadGooTrans();

    $(".select-gootrans-item").click(function () {
        $.ajax({
            url: window.location.origin + "/Master/GetCookieGooTrans",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken()
            },
            type: "POST",
            cache: false,
            success: function (result) {
                if (result == "0") {
                    $("#myModalGooTrans").modal("show");
                }
                else if (result == "2") {
                    layout_gootrans.fnShowGooTranslation();
                }
                else {
                    layout_gootrans.fnHideGooTrans();
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
            }
        });
    });

    $(".select-gootrans-item-mini").click(function () {
        $.ajax({
            url: window.location.origin + "/Master/GetCookieGooTrans",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken()
            },
            type: "POST",
            cache: false,
            success: function (result) {
                if (result == "0") {
                    $("#myModalGooTrans").modal("show");
                }
                else if (result == "2") {
                    layout_gootrans.fnShowGooTranslation();
                }
                else {
                    layout_gootrans.fnHideGooTrans();
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
            }
        });

    });

    $(".btn-yes").click(function () {
        layout_gootrans.fnShowGooTranslationConfirmed();
    });

});;
