/* Minification failed. Returning unminified contents.
(2,17): run-time error CSS1031: Expected selector, found '='
(2,17): run-time error CSS1025: Expected comma or open brace, found '='
(4,10): run-time error CSS1031: Expected selector, found 'scrollFunction('
(4,10): run-time error CSS1025: Expected comma or open brace, found 'scrollFunction('
(11,10): run-time error CSS1031: Expected selector, found 'UpdateBasketTotal('
(11,10): run-time error CSS1025: Expected comma or open brace, found 'UpdateBasketTotal('
(35,1): run-time error CSS1019: Unexpected token, found '$'
(35,2): run-time error CSS1019: Unexpected token, found '('
(35,11): run-time error CSS1031: Expected selector, found ')'
(35,11): run-time error CSS1025: Expected comma or open brace, found ')'
(40,2): run-time error CSS1019: Unexpected token, found ')'
 */
// When the user scrolls down 100px from the top of the document, a class will be added to the logo imagr to make it smaller
window.onscroll = function () { scrollFunction() };

function scrollFunction() {
    if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
        document.getElementById("logoCT").classList.add("small-logo");
    } else {
        document.getElementById("logoCT").classList.remove("small-logo");
    }
}
function UpdateBasketTotal() {

    var basketItemCount = $("#basketItemCount");
    var basketValue = $("#basketValue");

    $.ajax({
        url: "/basket/baskettotal",
        cache: false
    }).done(function (data) {

        // Update Basket Item Count
        $(basketItemCount).text(data.ItemCount == 1 ? "1 Item" : `${data.ItemCount} Items`);

        // Update Basket Value
        const nf = new Intl.NumberFormat('en-GB', { minimumFractionDigits: 2 });
        const formattedTotal = nf.format(data.Value);
        $(basketValue).text(formattedTotal);

        $("#basketPreview").removeClass("invisible").hide().fadeIn("fast");

    });

}

$(document).ready(function () {

    // Fetch Basket Total
    UpdateBasketTotal();

});
