jQuery(document).ready(function($) {
    // Get the tab parameter from the URL
    var urlParams = new URLSearchParams(window.location.search);
    var currentPage = urlParams.get('page');
    if (currentPage === 'integrate-with-zoho-campaigns') {
        var activeTab = urlParams.get('tab') || 'accounts'; // Default to 'auth' tab if no tab parameter is set

        // If no 'tab' parameter exists in the URL, update the URL to include 'auth' as the default
        if (!urlParams.has('tab')) {
            // Append the 'auth' tab to the URL without reloading the page
            urlParams.set('tab', 'accounts');
            window.history.replaceState(null, null, '?' + urlParams.toString());
        }

        // Hide all tab content and remove active class from all tabs
        $('.iafwzcai-tab').removeClass('iafwzcai-tab-active');
        $('.iafwzcai-tab-content').hide();

        // Show the active tab content and add active class to the active tab
        $('#iafwzcai-tab-' + activeTab).addClass('iafwzcai-tab-active');
        $('#iafwzcai-content-' + activeTab).show();
    }
});
