jQuery(document).ready(function($) {
    function manageRemoteRows() {
        if ($('#aieo_activate_utm_stats').is(':checked')) {
            $('.google-settings-row').show();
        } else {
            $('.google-settings-row').hide();
        }

        if ($('#aieo_activate_account').is(':checked')) {
            $('.account-settings-row').show();
        } else {
            $('.account-settings-row').hide();
        }

        if ($('#aieo_activate_remote_connection').is(':checked')) {
            $('.remote-settings-row').show();
            $('.erp-data-settings-row').show();
        } else {
            $('.remote-settings-row').hide();
            $('.erp-data-settings-row').hide();
        }

        if ($('#aieo_include_seasonality').is(':checked')) {
            $('.seasonality-settings-row').show();
        } else {
            $('.seasonality-settings-row').hide();
        }

        if ($('#aieo_erp_consolidation').is(':checked')) {
            $('.erp-data-settings-row').show();
        } else {
            $('.erp-data-settings-row').hide();
        }

        if ($('#aieo_erp_anonymous_consolidation').is(':checked')) {
            $('.erp-anonymous-data-settings-row').show();
        } else {
            $('.erp-anonymous-data-settings-row').hide();
        }
    }

    function manageAccountRows() {
        if ($('#aieo_activate_account').is(':checked')) {
            $('.account-settings-row').show();
        } else {
            $('.account-settings-row').hide();
        }
    }

    // Call on page load
    manageRemoteRows();


    // Call on checkbox change
    $('#aieo_activate_utm_stats, #aieo_include_seasonality, #aieo_activate_account, #aieo_activate_remote_connection, #aieo_erp_consolidation, #aieo_erp_anonymous_consolidation').on('change', function() {
        manageRemoteRows();
    });

});

