/* Minification failed. Returning unminified contents.
(337,40-41): run-time error JS1195: Expected expression: >
(341,40-41): run-time error JS1195: Expected expression: >
(345,40-41): run-time error JS1195: Expected expression: >
(349,40-41): run-time error JS1195: Expected expression: >
(368,61-62): run-time error JS1195: Expected expression: >
(377,6-7): run-time error JS1195: Expected expression: )
(383,1-2): run-time error JS1002: Syntax error: }
 */
function hideColumnRightCart() {
    $("#div-column-right").hide();
   /* $("#div-column-left").removeClass("col-9").addClass("col-12");*/
}

function openLogin() {
    $("#div-regular").hide();
    $("#div-guest").show();
    $("#regular-login").show();
    $("#guest-login").hide();
    $("#login-form").modal({
        escapeClose: false,
        clickClose: false
    });

    $("#btn-guest").click(function (event) {
        event.preventDefault();
        $("#regular-login").hide();
        $("#div-email-sent").hide();
        $("#div-email-already-registered").hide();
        $("#div-maxNumberExceeded").hide();
        $("#btn-prosegui").show();
        $("#guest-login").show();
    });
    fbAsyncInit();
}


function showColumnRightCart() {
    $("#div-column-right").show();
    /*$("#div-column-left").removeClass("col-12").addClass("col-9");*/
}

var originalWidth = 0;
$(window).scroll(function () {
    if (window.matchMedia('screen and (max-width: 768px)').matches) {
        scrollMobile();
    } else {
        scrollDesktop();
    }
});

$(window).resize(function () {
    if (!window.matchMedia('screen and (max-width: 768px)').matches) {
        $('.div-sticky-checkout').css({
            position: 'relative'
        });
    }
});

function scrollMobile() {
    if ($("#div-anchor").length > 0) {
        var offset = $("#div-anchor").position().top;
        var scrollTop = $(window).scrollTop() + $(window).height() - $("#div-anchor").height();
        if (scrollTop > offset) {
            $('.div-sticky-checkout').css({
                position: 'relative'
            });
        } else {
            $('.div-sticky-checkout').css({
                position: 'fixed',
                bottom: 0
            });
        }
    }
}
function scrollDesktop() {
    if (originalWidth === 0) {
        originalWidth = $('.div-sticky-checkout').width();
    }
    if ($("#div-anchor").length > 0) {
        var offset = $("#div-anchor").position().top;
        var scrollTop = $(window).scrollTop();
        if (scrollTop > offset) {
            $('.div-sticky-checkout').css({
                position: 'fixed',
                top: 0,
                width: originalWidth
            });
        } else {
            $('.div-sticky-checkout').css({
                position: 'relative'
            });
        }
        console.log("ST" + $(window).scrollTop() + "----DIV-TOP-" + originalWidth);
    }
}
;
function hideColumnRightShipping() {
    $("#div-column-right").hide();
    $("#div-column-left").removeClass("col-9").removeClass("borderRight").addClass("col-12");
}

function showColumnRightShipping() {
    $("#div-column-right").show();
    $("#div-column-left").removeClass("col-12").addClass("col-9").addClass("borderRight");
}

$(window).resize(function () {
    showSummaryOnTop();
});

function showSummaryOnTop() {
    if (window.matchMedia('screen and (max-width: 768px)').matches) {
        $("#div-summary").appendTo("#div-summary-top");
    } else {
        $("#div-summary").appendTo("#div-summary-bottom");
    }
}
;
$(document).ready(function () {
    $("[id$='toggle_pwd']").click(function () {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
        $("[id$='TxtPassword']").attr('type', type);
    });



    $("[id$='toggle_pwdConfirm']").click(function () {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
        $("[id$='TxtPasswordRepeat']").attr('type', type);
    });



    $("[id$='toggle_pwdGuest']").click(function () {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
        $("[id$='TxtPasswordGuest']").attr('type', type);
    });



    $("[id$='toggle_pwdConfirmGuest']").click(function () {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
        $("[id$='TxtPasswordRepeatGuest']").attr('type', type);
    });
});



function addToggle() {
    $("[id$='toggle_pwd']").click(function () {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
        $("[id$='TxtPassword']").attr('type', type);
    });



    $("[id$='toggle_pwdConfirm']").click(function () {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
        $("[id$='TxtPasswordRepeat']").attr('type', type);
    });



    $("[id$='toggle_pwdGuest']").click(function () {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
        $("[id$='TxtPasswordGuest']").attr('type', type);
    });



    $("[id$='toggle_pwdConfirmGuest']").click(function () {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var type = $(this).hasClass("fa-eye-slash") ? "text" : "password";
        $("[id$='TxtPasswordRepeatGuest']").attr('type', type);
    });
}



Sys.WebForms.PageRequestManager.getInstance().add_endRequest(addToggle);



function CheckBoxRequired_ClientValidate(sender, e) {
    e.IsValid = $(".AcceptedAgreement input:checkbox").is(':checked');
}
function selectAll() {
    if ($("#chkSelectAll").is(':checked')) {
        $(".jqChkSelect input:checkbox").prop("checked", true);



    } else {
        $(".jqChkSelect input:checkbox").prop("checked", false);
    }
}



function selectAllGuest() {
    if ($("#chkSelectAllGuest").is(':checked')) {
        $(".jqChkSelect input:checkbox").prop("checked", true);



    } else {
        $(".jqChkSelect input:checkbox").prop("checked", false);
    }
}





//function ValidatorUpdateDisplay(val) {
// if (typeof (val.display) == "string") {
// if (val.display == "None") {
// return;
// }
// if (val.display == "Dynamic") {
// val.style.display = val.isvalid ? "none" : "inline";
// return;
// }



// }
// val.style.visibility = val.isvalid ? "hidden" : "visible";
// if (val.isvalid) {
// document.getElementById(val.controltovalidate).style.border = '1px solid #333';
// }
// else {
// document.getElementById(val.controltovalidate).style.border = '1px solid red';
// }
//}




function checkEmailAlreadyExist() {
    var webMethod = '/ApiService.asmx/Forward';
    var parameters = {Email: $("#TxtEmail").val()};

    if ($("#TxtEmail").val() != "") {
        $.ajax({
            type: "POST",
            url: webMethod,
            data: JSON.stringify({
                path: window.AppConfig.checkEmailAlreadyExistPath,
                body: parameters,
                includeCookies: false
            }),
            contentType: "application/json",
            dataType: "json",
            success: function (res) {
                e.IsValid = res.d.IsRegistered === false;
            },
            error: function (e) {
                console.log(e);
            }
        });
    }
    else {
        console.log("errore");
        res.d = true;
    }


}
function showRegistrationGuest() {
    $("#div-registration-guest").show();
    $(".form-inputs").show();
    $("#div-checkboxes").show();
    $("#div-message-mail-activation-sent").hide();
}
function hideRegistrationGuest() {
    $("#div-registration-guest").hide();
}



function showEmailActivationSent() {
    $("#div-registration-guest").show();
    $("#div-checkboxes").hide();
    $("#div-message-mail-activation-sent").show();
    $("#spn-message-mail-activation-sent").text($("#TxtEmailGuest").val());
};
function countdownBannerLogic(bannerId, settings) {
    Sys.Application.add_load(function () {
        initBannerCountdown(bannerId, settings);
    });
    document.addEventListener("hcercaAftersearchInitialized", function (e) {
        initBannerCountdown(bannerId, settings);
    });

}

function initBannerCountdown(bannerId, settings) {

    if (new Date(settings.startDate) > new Date() || new Date(settings.endDate) < new Date())
        return;

    if (settings.imageUrl && settings.imageUrl.length > 0)
        $(bannerId + " .countdown-banner-image").css("background-image", "url(" + settings.imageUrl + ")")
    else
        $(bannerId + " .countdown-banner-image").hide()

    $(bannerId + " .countdown-banner-title p").text(settings.titleText.substring(0, 40))
    $(bannerId + " .countdown-banner-cta p").text(settings.ctaText.substring(0, 15))

    $(bannerId).click(function () {
        window.location.href = settings.bannerLink
    })

    $(bannerId + " .countdown-banner-text").css("background-color", settings.bgTextColor)
    $(bannerId + " .countdown-banner-image").css("background-color", settings.bgTextColor)

    $(bannerId + " .countdown-banner-text").css("color", settings.textColor)
    $(bannerId + " .countdown-banner-timer").css("background-color", settings.bgTimerColor)
    $(bannerId + " .countdown-banner-timer").css("color", settings.timerColor)

    initCountdown(bannerId + " .countdown-banner-timer .countdown-timer", new Date(settings.endDate))

    $(bannerId).show()
}

function initCountdown(elementQuery, endDate) {
    $(elementQuery).empty();
    simplyCountdown(elementQuery, {
        year: endDate.getFullYear(),
        month: endDate.getMonth() + 1,
        day: endDate.getDate(),
        hours: endDate.getHours(),
        minutes: endDate.getMinutes(),
        seconds: endDate.getSeconds(),
        words: {
            days: {
                lambda: (root, count) => root,
                root: "Giorni",
            },
            hours: {
                lambda: (root, count) => root,
                root: "Ore",
            },
            minutes: {
                lambda: (root, count) => root,
                root: "Minuti",
            },
            seconds: {
                lambda: (root, count) => root,
                root: "Secondi",
            },
        },
        plural: false,
        inline: false,
        enableUtc: false,
        zeroPad: true,
        countUp: false,
        removeZeroUnits: true,
        stopRemovingZeroUnitsAt: "hours",
        refresh: 1000,
        sectionClass: "simply-section",
        amountClass: "simply-amount",
        wordClass: "simply-word",
    })
}
;
(function () {
    const observer = new MutationObserver((mutations, obs) => {
        const container = document.querySelector("#eyeAble_container_ID");
        if (container && container.shadowRoot) {
            const icon = container.shadowRoot.querySelector("#mainIconID");
            if (icon) {
                icon.style.filter = 'none';
                obs.disconnect();
            }
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();;
