$(document).ready(function () {

    $("#hprint").hide();



    function loadParty() {
        var shopwk = $('.shopwk').val();
        var selectedparty = $('#selectedparty').val();

        $.ajax({
            url: 'get_party.php',
            type: 'POST',
            data: {
                shopwk: shopwk,
                selectedparty: selectedparty
            },

            success: function (response) {

                $('.party').html(response);

                $('.party').trigger('change');
            }
        });
    }

    // FIRST LOAD
    loadParty();

    // CHANGE SHOPWK
    $('.shopwk').change(function () {

        $('#selectedparty').val('');

        loadParty();
    });


    // ===== Group Change =====
    function togglePrname() {

        var group = $('.group').val();

        if (group == '1') { // BANK
            $('.prname').closest('.row').show();
        } else {
            $('.prname').closest('.row').hide();
            $('.prname').val('');
        }
    }

    // On change
    $('.group').change(function () {
        togglePrname();
    });

    // On page load
    togglePrname();



});