jQuery(document).ready(function($) {
    var departmentCounter = $('#departments-container .team-mxt-field').length;

    $('body').on('click', '.add-more-department', function() {
        var newField = $('<div class="team-mxt-field"><label for="team_mxt_member_department_' +
            departmentCounter +
            '">Department:</label><input type="text" id="team_mxt_member_department_' +
            departmentCounter +
            '" name="team_mxt_member_department[]" class="info-value" /><button type="button" class="button delete-department">Delete</button></div>'
        );
        $('#departments-container').append(newField);
        departmentCounter++;
    });

    $('body').on('click', '.delete-department', function() {
        $(this).closest('.team-mxt-field').remove();
    });
});

function toggleDropdown() {
    var dropdown = document.getElementById("socialMediaDropdown");
    dropdown.style.display = dropdown.style.display === "none" ? "block" : "none";
}