var Wick = Wick || {};
Wick.PDPTile = (function () {

    let wastageInput = '#wastage',
        notificationAccordion = '.tile-total-area__detail-name_accordion',
        wastageArea = '.tile-total-area__wastage-area',
        removalInputYes = '#_removal-yes_',
        removalInputNo = '#_removal-no_',
        removalArea = '.cost__removal-area',
        removalAreaShow = 'cost__removal-area-show',
        btnStep1 = '#btn-step1';

    $(wastageInput).change(function () {
        if ($(wastageInput).attr('checked') === 'checked') {
            $(wastageInput).removeAttr('checked');
            if ($(notificationAccordion).hasClass('collapsed')) {
                $(notificationAccordion).click();
            }
        } else {
            $(wastageInput).attr('checked', 'checked');
        }
        $(wastageArea).toggleClass('tile-total-area__wastage-area-hide');
    });

    $(removalInputYes).change(function () {
        $(removalInputYes).attr('checked', 'checked');

        if ($(removalInputYes).attr('checked') === 'checked') {
            $(removalArea).toggleClass(removalAreaShow);
            $(removalInputNo).removeAttr('checked');
        }
    });

    $(removalInputNo).change(function () {
        $(removalInputNo).attr('checked', 'checked');

        if ($(removalInputNo).attr('checked') === 'checked') {
            $(removalArea).toggleClass(removalAreaShow);
            $(removalInputYes).removeAttr('checked');
        }
    });


    function setAnchoring() {
        if ($(window).width() < 768) {
            $(btnStep1).attr('data-link', '#tile-step2-header');
        } else {
            $(btnStep1).attr('data-link', '#tile-step1-header');
        }
    }

    $(window).resize(setAnchoring);

})();

