$(document).ready(function () {
    //////////////////////
    // HOPE UNITED 2022 //
    //////////////////////
    // Stock Check
    $(".hopeSelectorProducts  .product-container").each(function () {
        if ($(this).find("button:contains('Add to basket')").length != 0) {
            $('.secondBuyZone input[ql="' + $(this).attr('data-ql') + '"]').parent().removeClass('disabled');
        };
    });
    // Fit Check
    if (/*$('.mensProducts .product-container').length*/ $('#buyZone2mens label:not(.disabled)').length != 0) {
        $('input[name="shirtFit"][id="mens"]').parent().removeClass('disabled');
    };
    if (/*$('.womensProducts .product-container').length*/ $('#buyZone2womens label:not(.disabled)').length != 0) {
        $('input[name="shirtFit"][id="womens"]').parent().removeClass('disabled');
    };
    if (/*$('.youthProducts .product-container').length*/ $('#buyZone2youth label:not(.disabled)').length != 0) {
        $('input[name="shirtFit"][id="youth"]').parent().removeClass('disabled');
    };
    // Show Fit Selector
    $('.firstBuyZone').removeClass('d-none');
    // Fit Click Event
    $(".firstBuyZone input").click(function () {
        $('.secondBuyZone label').removeClass('active');
        var fitID = $(this).attr('id');
        $('.secondBuyZone').addClass('d-none');
        $('.thirdBuyZone').addClass('d-none');
        if (fitID === "mens") {
            $('#buyZone2mens').removeClass('d-none');
        } else if (fitID === "womens") {
            $('#buyZone2womens').removeClass('d-none');
        } else if (fitID === "youth") {
            $('#buyZone2youth').removeClass('d-none');
        };
    });
    // Size Click Event
    $(".secondBuyZone input").click(function () {
        $('.thirdBuyZone').addClass('d-none');
        var fitID = $(this).attr('name');
        var sizeID = $(this).attr('id');
        document.getElementById('buyZone3').innerHTML = '<p class="color-black btfont-bold h3 mt-3">£39.99</p><a href="https://store.ee.co.uk/basket/additem?quicklinx=' + $(this).attr('ql') + '&quantity=1" class="p-0 m-0"><button class="cta cta-main-alt cta-chevron basket-button btn button-ee-primary whitespace-nowrap" name="AddButton_' + $(this).attr('ql') + '" type="submit">Add to basket</button></a>';
        $('.thirdBuyZone').removeClass('d-none');
    });
    /////////////////
    // Size Guides //
    /////////////////
    $("#mensSizeGuideModal").click(function () {
        $('.modal').modal({ keyboard: false, show: true });
        $('.modal .modal-dialog').addClass('modal-dialog-centered modal-lg');
        $('.modal .modal-header').html('<p class="h5 bt-curve-headline modal-title w-100">2022 Size Guide - Mens</p><button type="button" class="close opaque" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="bticon-Close color-purple h3"></span></button>');
        $('.modal .modal-body').html('<table class="table bt-curve-regular"><thead><tr><th scope="col">Label Size</th><th scope="col">Chest (inches)</th><th scope="col">Length (inches)</th></tr></thead><tbody><tr><th scope="row">XS</th><td>39"</td><td>26"</td></tr><tr><th scope="row">S</th><td>42"</td><td>27"</td></tr><tr><th scope="row">M</th><td>44"</td><td>28"</td></tr><tr><th scope="row">L</th><td>46"</td><td>28.5"</td></tr><tr><th scope="row">XL</th><td>49"</td><td>29.5"</td></tr><tr><th scope="row">XXL</th><td>51"</td><td>30.5"</td></tr><tr><th scope="row">3XL</th><td>53"</td><td>31.5"</td></tr></tbody></table>');
    });
    $("#womensSizeGuideModal").click(function () {
        $('.modal').modal({ keyboard: false, show: true });
        $('.modal .modal-dialog').addClass('modal-dialog-centered modal-lg');
        $('.modal .modal-header').html('<p class="h5 bt-curve-headline modal-title w-100">2022 Size Guide - Womens</p><button type="button" class="close opaque" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="bticon-Close color-purple h3"></span></button>');
        $('.modal .modal-body').html('<table class="table bt-curve-regular"><thead><tr><th scope="col">Label Size</th><th scope="col">Chest (inches)</th><th scope="col">Length (inches)</th></tr></thead><tbody><tr><th scope="row">XS</th><td>30-32"</td><td>23.5"</td></tr><tr><th scope="row">S</th><td>34-36"</td><td>25"</td></tr><tr><th scope="row">M</th><td>38-40"</td><td>26.5"</td></tr><tr><th scope="row">L</th><td>40-42"</td><td>27.5"</td></tr><tr><th scope="row">XL</th><td>44-46"</td><td>29"</td></tr></tbody></table>');
    });
    $("#youthSizeGuideModal").click(function () {
        $('.modal').modal({ keyboard: false, show: true });
        $('.modal .modal-dialog').addClass('modal-dialog-centered modal-lg');
        $('.modal .modal-header').html('<p class="h5 bt-curve-headline modal-title w-100">2022 Size Guide - Youth</p><button type="button" class="close opaque" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="bticon-Close color-purple h3"></span></button>');
        $('.modal .modal-body').html('<table class="table bt-curve-regular"><thead><tr><th scope="col">Label Size</th><th scope="col">Chest (inches)</th><th scope="col">Length (inches)</th></tr></thead><tbody><tr><th scope="row">XS</th><td>30"</td><td>20"</td></tr><tr><th scope="row">S</th><td>32"</td><td>21.5"</td></tr><tr><th scope="row">M</th><td>34"</td><td>23"</td></tr><tr><th scope="row">L</th><td>37"</td><td>24"</td></tr><tr><th scope="row">XL</th><td>39"</td><td>25.5"</td></tr></tbody></table>');
    });
});