jQuery(document).ready(function($) {
    // Initially show the first gallery set and hide others
    $('#gallery_set_1').show();
    $('#gallery_set_2, #gallery_set_3, #gallery_set_4').hide();

    // Initially hide business plan pricing table
    $('.business-plan-pricing-table').hide();

    // Handle the toggle checkbox logic
    $("#togglechecked").click(function() {
        console.log("in");

        var isChecked = $(this).is(":checked"); // Check if the checkbox is currently checked

        if (isChecked) {
            $('.individual-plan-pricing-table').hide();
            $('.business-plan-pricing-table').show();
            $('.toggle-main-class-pricetable').find('.business-plan-label').addClass('active');
            $('.toggle-main-class-pricetable').find('.individual-plan-label').removeClass('active');
        } else {
            $('.toggle-main-class-pricetable').find('.individual-plan-label').addClass('active');
            $('.toggle-main-class-pricetable').find('.business-plan-label').removeClass('active');
            $('.business-plan-pricing-table').hide();
            $('.individual-plan-pricing-table').show();
        }
    });

    // Function to hide all gallery sets and show the specified one
    function showGallerySet(galleryId) {
        $('.gallery_set').hide(); // Hide all gallery sets
        $(galleryId).show();      // Show the specified gallery set
    }

    // Add click event handlers for all buttons
    $('#button_1').on('click', function(event) {
        event.preventDefault();
        showGallerySet('#gallery_set_1');
    });

    $('#button_2').on('click', function(event) {
        event.preventDefault();
        showGallerySet('#gallery_set_2');
    });

    $('#button_3').on('click', function(event) {
        event.preventDefault();
        showGallerySet('#gallery_set_3');
    });

    $('#button_4').on('click', function(event) {
        event.preventDefault();
        showGallerySet('#gallery_set_4');
    });

    // Optimizing the toggle functionality
    $("#togglechecked").change(function() {
        var isChecked = $(this).is(":checked");
        if (isChecked) {
            $('.individual-plan-pricing-table').hide();
            $('.business-plan-pricing-table').show();
            $('.toggle-main-class-pricetable').find('.business-plan-label').addClass('active');
            $('.toggle-main-class-pricetable').find('.individual-plan-label').removeClass('active');
        } else {
            $('.toggle-main-class-pricetable').find('.individual-plan-label').addClass('active');
            $('.toggle-main-class-pricetable').find('.business-plan-label').removeClass('active');
            $('.business-plan-pricing-table').hide();
            $('.individual-plan-pricing-table').show();
        }
    });
});
