const TermsAgreement = function () {
    const init = function () {
        
        const pageTitle = $("#PageTitle").text();
        
        setPageTitle(pageTitle, true);
        
        handleAgreementCheckboxClick();
        
        handleAgreementButtonClick();
    };
    
    const handleAgreementCheckboxClick = function () {
        const $TermConditionAgreeChkBox = $("#TermConditionAgreeChkBox");
        const $btnAgree = $("#TermConditionAcceptBtn");
        
        $TermConditionAgreeChkBox.on("click", function () {
            if ($TermConditionAgreeChkBox.is(":checked")) {
                $btnAgree.prop("disabled", false);
            } else {
                $btnAgree.prop("disabled", true);
            }
        });
    };
    
    const handleAgreementButtonClick = function () {
        const $btnAgree = $("#TermConditionAcceptBtn");
        
        $btnAgree.on("click", function () {
            parent.openModalSpinner();
        });
    }

    return {
        init,
    };
}

jQuery(document).ready(function () {
    parent.closeModalSpinner();

    const termsAgreement = new TermsAgreement();

    termsAgreement.init();
});         
