/*
 * Advance Tab
 */
jQuery( function ( $ ) {
    var AdvanceTabScript = {
        init : function () {
            this.show_or_hide_for_my_account_menu_page() ;
            this.show_or_hide_for_apply_previous_order_range() ;
            this.show_or_hide_for_menu_restriction_based_on_userrole() ;
            this.show_or_hide_for_pagination_for_total_earned_points() ;
            this.show_or_hide_for_pagination_for_total_available_points();
            this.show_or_hide_for_enable_msg_to_participate_in_reward_prgm();
            $( document ).on( 'change' , '#rs_reward_content_menu_page' , this.my_account_menu_page ) ;
            $( document ).on( 'change' , '#rs_sumo_select_order_range' , this.apply_previous_order_range ) ;
            $( document ).on( 'change' , '#rs_menu_restriction_based_on_user_role' , this.menu_restriction_based_on_userrole ) ;
            $( document ).on( 'change' , '#rs_select_pagination_for_total_earned_points' , this.pagination_for_total_earned_points ) ;
            $( document ).on( 'change' , '#rs_select_pagination_for_available_points' , this.pagination_for_total_available_points ) ;
            $( document ).on( 'change' , '#rs_enable_reward_program' , this.enable_msg_to_participate_in_reward_prgm ) ;
        } ,
        my_account_menu_page : function () {
            AdvanceTabScript.show_or_hide_for_my_account_menu_page() ;
        } ,
        show_or_hide_for_my_account_menu_page : function () {
            if ( jQuery( '#rs_reward_content_menu_page' ).is( ':checked' ) == true ) {
                jQuery( '#rs_my_reward_table_menu_page' ).parent().parent().show() ;
                jQuery( '#rs_show_hide_generate_referral_menu_page' ).parent().parent().show() ;
                jQuery( '#rs_show_hide_referal_table_menu_page' ).parent().parent().show() ;
                jQuery( '#rs_my_cashback_table_menu_page' ).parent().parent().show() ;
                jQuery( '#rs_show_hide_nominee_field_menu_page' ).parent().parent().show() ;
                jQuery( '#rs_show_hide_redeem_voucher_menu_page' ).parent().parent().show() ;
                jQuery( '#rs_show_hide_your_subscribe_link_menu_page' ).parent().parent().show() ;
                jQuery( '#rs_my_reward_content_title' ).parent().parent().show() ;
                jQuery( '#rs_my_reward_url_title' ).parent().parent().show() ;
            } else {
                jQuery( '#rs_my_reward_table_menu_page' ).parent().parent().hide() ;
                jQuery( '#rs_show_hide_generate_referral_menu_page' ).parent().parent().hide() ;
                jQuery( '#rs_show_hide_referal_table_menu_page' ).parent().parent().hide() ;
                jQuery( '#rs_my_cashback_table_menu_page' ).parent().parent().hide() ;
                jQuery( '#rs_show_hide_nominee_field_menu_page' ).parent().parent().hide() ;
                jQuery( '#rs_show_hide_redeem_voucher_menu_page' ).parent().parent().hide() ;
                jQuery( '#rs_show_hide_your_subscribe_link_menu_page' ).parent().parent().hide() ;
                jQuery( '#rs_my_reward_content_title' ).parent().parent().hide() ;
                jQuery( '#rs_my_reward_url_title' ).parent().parent().hide() ;
            }
        } ,
        apply_previous_order_range : function () {
            AdvanceTabScript.show_or_hide_for_apply_previous_order_range() ;
        } ,
        show_or_hide_for_apply_previous_order_range : function () {
            if ( jQuery( '#rs_sumo_select_order_range' ).val() === '1' ) {
                jQuery( '#rs_from_date' ).parent().parent().hide() ;
            } else {
                jQuery( '#rs_from_date' ).parent().parent().show() ;
            }
        } ,
        menu_restriction_based_on_userrole : function () {
            AdvanceTabScript.show_or_hide_for_menu_restriction_based_on_userrole() ;
        } ,
        show_or_hide_for_menu_restriction_based_on_userrole : function () {
            if ( jQuery( '#rs_menu_restriction_based_on_user_role' ).is( ':checked' ) == true ) {
                jQuery( '.rewardpoints_userrole_menu_restriction' ).parent().parent().show() ;
            } else {
                jQuery( '.rewardpoints_userrole_menu_restriction' ).parent().parent().hide() ;
            }
        } ,
        pagination_for_total_earned_points : function () {
            AdvanceTabScript.show_or_hide_for_pagination_for_total_earned_points() ;
        } ,
        show_or_hide_for_pagination_for_total_earned_points : function () {
            if ( jQuery( '#rs_select_pagination_for_total_earned_points' ).val() == '1' ) {
                jQuery( '#rs_value_without_pagination_for_total_earned_points' ).closest( 'tr' ).hide() ;
            } else {
                jQuery( '#rs_value_without_pagination_for_total_earned_points' ).closest( 'tr' ).show() ;
            }
        } ,
        pagination_for_total_available_points : function () {
            AdvanceTabScript.show_or_hide_for_pagination_for_total_available_points() ;
        } ,
        show_or_hide_for_pagination_for_total_available_points : function () {
            if ( jQuery( '#rs_select_pagination_for_available_points' ).val() == '1' ) {
                jQuery( '#rs_value_without_pagination_for_available_points' ).closest( 'tr' ).hide() ;
            } else {
                jQuery( '#rs_value_without_pagination_for_available_points' ).closest( 'tr' ).show() ;
            }
        } ,
        enable_msg_to_participate_in_reward_prgm: function(){
            AdvanceTabScript.show_or_hide_for_enable_msg_to_participate_in_reward_prgm() ;
        },
        show_or_hide_for_enable_msg_to_participate_in_reward_prgm: function(){
            if(jQuery('#rs_enable_reward_program').is(':checked') == true){
                jQuery('#rs_msg_in_reg_page').closest('tr').show();
                jQuery('#rs_msg_in_acc_page_when_checked').closest('tr').show();
                jQuery('#rs_msg_in_acc_page_when_unchecked').closest('tr').show();
            }else{
                jQuery('#rs_msg_in_reg_page').closest('tr').hide();
                jQuery('#rs_msg_in_acc_page_when_checked').closest('tr').hide();
                jQuery('#rs_msg_in_acc_page_when_unchecked').closest('tr').hide();
            }
        },
    } ;
    AdvanceTabScript.init() ;
} ) ;