scripted_gui = {
    sov_national_obligations_scripted_gui = {
        window_name = "sov_national_obligations_scripted_gui_window"
        context_type = player_context

        visible = {
            original_tag = SOV
            is_subject = no
            OR = {
                has_country_flag = sov_debug_national_obligations
                AND = {
                    has_global_flag = sov_national_obligations_allowed
                    has_country_flag = sov_unlocked_national_obligations
                    has_country_flag = sov_open_national_obligations
                }
            }
        }

        properties = {
            sov_national_obligations_main_icon_left = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsIcon]
            }

            sov_national_obligations_main_icon_right = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsIcon]
            }

            sov_national_obligations_scripted_gui_window_bg = {
                image = [THIS.GetCurrentSelectedIndexNationalObligations]
            }

            sov_national_obligations_nav_industrial_awakening = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavIndustrialAwakening]
            }

            sov_national_obligations_nav_tsar_bomba = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavTsarBomba]
            }

            sov_national_obligations_nav_unfailing_army = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavUnfailingArmy]
            }

            sov_national_obligations_nav_grand_fleet = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavGrandFleet]
            }

            sov_national_obligations_nav_proletarian_union = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavProletarianUnion]
            }

            sov_national_obligations_nav_neverending_story = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavNeverendingStory]
            }

            sov_national_obligations_nav_continental_system = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavContinentalSystem]
            }

            sov_national_obligations_nav_treaty_moscow = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavTreatyMoscow]
            }

            sov_national_obligations_nav_golden_age = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavGoldenAge]
            }

            sov_national_obligations_nav_imperial_obligations = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavImperialObligations]
            }

            sov_national_obligations_nav_carry_on_legacy = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavCarryOnLegacy]
            }

            sov_national_obligations_nav_russian_realm = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavRussianRealm]
            }

            sov_national_obligations_nav_rebirth = {
                image = [THIS.GetCurrentSelectedIndexNationalObligationsNavRebirth]
            }
        }

        effects = {
            sov_national_obligations_help_button_click = {
                if = {
                    limit = {
                        check_variable = {
                            var = national_obligations_help_open_count
                            value = 0
                            compare = equals
                        }
                        NOT = {
                            is_in_array = { global.click_me_achievement = THIS }
                        }
                    }
                    add_to_array = { global.click_me_achievement = THIS }
                    set_variable = { global.click_me_achievement_date@THIS = global.date }
                    set_country_flag = russia_reworked_new_achievement
                    if = {
                        limit = {
                            has_global_flag = russia_reworked_achievements_enabled
                        }
                        scoped_sound_effect = "russia_reworked_unlock_achievement"
                    }
                }
                if = {
                    limit = {
                        NOT = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                    }
                    set_country_flag = sov_open_national_obligations_help
                    add_to_variable = { national_obligations_help_open_count = 1 }
                }
            }

            sov_national_obligations_close_button_click = {
                if = {
                    limit = {
                        has_country_flag = sov_open_national_obligations_help
                    }
                    clr_country_flag = sov_open_national_obligations_help
                }
                if = {
                    limit = {
                        has_country_flag = sov_debug_national_obligations
                    }
                    clr_country_flag = sov_debug_national_obligations
                }
                if = {
                    limit = {
                        has_country_flag = sov_open_national_obligations
                    }
                    clr_country_flag = sov_open_national_obligations
                }
            }

            #NAV
            sov_national_obligation_nav_button_left_click = {
                set_temp_variable = { old_index = var:sov_national_obligations_selected_index }
                set_temp_variable = { new_index = var:sov_national_obligations_selected_index }
                while_loop_effect = {
                    break = break_loop
                    limit = {
                        OR = {
                            check_variable = {
                                var = old_index
                                value = var:sov_national_obligations_selected_index
                                compare = equals
                            }
                            check_variable = {
                                var = new_index
                                value = 0
                                compare = less_than_or_equals
                            }
                        }
                    }

                    subtract_from_temp_variable = { new_index = 1 }
                    if = {
                        limit = {
                            is_in_array = { sov_national_obligations_unlocked_indexes = new_index }
                        }
                        set_variable = { sov_national_obligations_selected_index = var:new_index }
                    }
                }
            }

            sov_national_obligation_nav_button_right_click = {
                set_temp_variable = { old_index = var:sov_national_obligations_selected_index }
                set_temp_variable = { new_index = var:sov_national_obligations_selected_index }
                while_loop_effect = {
                    break = break_loop
                    limit = {
                        OR = {
                            check_variable = {
                                var = old_index
                                value = var:sov_national_obligations_selected_index
                                compare = equals
                            }
                            check_variable = {
                                var = new_index
                                value = 100
                                compare = greater_than_or_equals
                            }
                        }
                    }

                    add_to_temp_variable = { new_index = 1 }
                    if = {
                        limit = {
                            is_in_array = { sov_national_obligations_unlocked_indexes = new_index }
                        }
                        set_variable = { sov_national_obligations_selected_index = var:new_index }
                    }
                }
            }

            sov_national_obligations_nav_industrial_awakening_click = {
                set_variable = { sov_national_obligations_selected_index = 1 }
            }

            sov_national_obligations_nav_tsar_bomba_click = {
                set_variable = { sov_national_obligations_selected_index = 2 }
            }

            sov_national_obligations_nav_unfailing_army_click = {
                set_variable = { sov_national_obligations_selected_index = 3 }
            }

            sov_national_obligations_nav_grand_fleet_click = {
                set_variable = { sov_national_obligations_selected_index = 4 }
            }

            sov_national_obligations_nav_proletarian_union_click = {
                set_variable = { sov_national_obligations_selected_index = 5 }
            }

            sov_national_obligations_nav_neverending_story_click = {
                set_variable = { sov_national_obligations_selected_index = 6 }
            }

            sov_national_obligations_nav_continental_system_click = {
                set_variable = { sov_national_obligations_selected_index = 7 }
            }

            sov_national_obligations_nav_treaty_moscow_click = {
                set_variable = { sov_national_obligations_selected_index = 8 }
            }

            sov_national_obligations_nav_golden_age_click = {
                set_variable = { sov_national_obligations_selected_index = 9 }
            }

            sov_national_obligations_nav_imperial_obligations_click = {
                set_variable = { sov_national_obligations_selected_index = 10 }
            }

            sov_national_obligations_nav_carry_on_legacy_click = {
                set_variable = { sov_national_obligations_selected_index = 11 }
            }

            sov_national_obligations_nav_russian_realm_click = {
                set_variable = { sov_national_obligations_selected_index = 12 }
            }

            sov_national_obligations_nav_rebirth_click = {
                set_variable = { sov_national_obligations_selected_index = 13 }
            }
        }

        #Triggers will always check for a precise number rather than "greater than" to avoid any possible bug (with a decimal variable for example)
        triggers = {
            sov_national_obligations_main_icon_left_glow_visible = {
                OR = {
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 1
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 2
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 3
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 4
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 5
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 6
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 7
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 8
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 9
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 10
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 11
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 12
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 13
                        compare = equals
                    }
                }
            }

            sov_national_obligations_main_icon_right_glow_visible = {
                OR = {
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 1
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 2
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 3
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 4
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 5
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 6
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 7
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 8
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 9
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 10
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 11
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 12
                        compare = equals
                    }
                    check_variable = {
                        var = sov_national_obligations_selected_index
                        value = 13
                        compare = equals
                    }
                }
            }

            #NAV
            sov_national_obligation_nav_button_left_click_enabled = {
                find_lowest_in_array = {
                    array = sov_national_obligations_unlocked_indexes
                    value = lowest_unlocked_index_v
                    index = lowest_unlocked_index_i
                }
                check_variable = {
                    var = lowest_unlocked_index_v
                    value = var:sov_national_obligations_selected_index
                    compare = less_than
                }
            }

            sov_national_obligation_nav_button_right_click_enabled = {
                find_highest_in_array = {
                    array = sov_national_obligations_unlocked_indexes
                    value = highest_unlocked_index_v
                    index = highest_unlocked_index_i
                }
                check_variable = {
                    var = highest_unlocked_index_v
                    value = var:sov_national_obligations_selected_index
                    compare = greater_than
                }
            }

            sov_national_obligations_nav_industrial_awakening_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 1 }
            }

            sov_national_obligations_nav_tsar_bomba_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 2 }
            }

            sov_national_obligations_nav_unfailing_army_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 3 }
            }

            sov_national_obligations_nav_grand_fleet_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 4 }
            }

            sov_national_obligations_nav_proletarian_union_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 5 }
            }

            sov_national_obligations_nav_neverending_story_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 6 }
            }

            sov_national_obligations_nav_continental_system_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 7 }
            }

            sov_national_obligations_nav_golden_age_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 8 }
            }

            sov_national_obligations_nav_treaty_moscow_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 9 }
            }

            sov_national_obligations_nav_imperial_obligations_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 10 }
            }

            sov_national_obligations_nav_carry_on_legacy_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 11 }
            }

            sov_national_obligations_nav_russian_realm_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 12 }
            }

            sov_national_obligations_nav_rebirth_click_enabled = {
                is_in_array = { sov_national_obligations_unlocked_indexes = 13 }
            }
        }
    }
    
    #Industrial Awakening
    sov_national_obligations_industrial_awakening_scripted_gui = {
        window_name = "sov_national_obligations_industrial_awakening_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 1
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_industrial_awakening_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionIndustrialAwakening]
            }

            sov_national_obligations_industrial_awakening_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionIndustrialAwakening]
            }

            sov_national_obligations_industrial_awakening_third_option_bg = {
                image = [THIS.GetCurrentStatusThirdOptionIndustrialAwakening]
            }
        }

        effects = {
            sov_national_obligations_industrial_awakening_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = industrial_awakening_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_industrial_awakening_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_industrial_awakening_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_industrial_awakening_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_industrial_awakening_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 2
                        }
                    }
                }
            }

            sov_national_obligations_industrial_awakening_third_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_industrial_awakening_selected_index = 3
                            }
                        }
                        set_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 3
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_industrial_awakening_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 2
                        }
                        check_variable = {
                            sov_national_obligations_industrial_awakening_selected_index = 3
                        }
                    }
                    NOT = {
                        has_country_flag = industrial_awakening_confirmed
                    }
                }
            }

            sov_national_obligations_industrial_awakening_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_industrial_awakening_selected_index = 1
                }
            }

            sov_national_obligations_industrial_awakening_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = industrial_awakening_confirmed
                    }
                }
            }

            sov_national_obligations_industrial_awakening_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_industrial_awakening_selected_index = 2
                }
            }

            sov_national_obligations_industrial_awakening_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = industrial_awakening_confirmed
                    }
                }
            }

            sov_national_obligations_industrial_awakening_third_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_industrial_awakening_selected_index = 3
                }
            }

            sov_national_obligations_industrial_awakening_third_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = industrial_awakening_confirmed
                    }
                }
            }
        }
    }

    #Tsar Bomba
    sov_national_obligations_tsar_bomba_scripted_gui = {
        window_name = "sov_national_obligations_tsar_bomba_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 2
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_tsar_bomba_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionTsarBomba]
            }

            sov_national_obligations_tsar_bomba_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionTsarBomba]
            }
        }

        effects = {
            sov_national_obligations_tsar_bomba_confirm_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_tsar_bomba_selected_index = 1
                            }
                        }
                        add_ideas = SOV_Major_nuclear_power
                    }
                    else_if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_tsar_bomba_selected_index = 2
                            }
                        }
                        add_nuclear_bombs = -3
                        goto_state = 262
                        launch_nuke = {
                            province = 11047
                            use_nuke = no
                        }
                        launch_nuke = {
                            province = 6192
                            use_nuke = no
                        }
                        launch_nuke = {
                            province = 12530
                            use_nuke = no
                        }
                        country_event = { id = russia2_russia.633 days = 2 }
                    }
                    set_country_flag = tsar_bomba_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_tsar_bomba_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_tsar_bomba_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_tsar_bomba_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_tsar_bomba_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_tsar_bomba_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_tsar_bomba_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_tsar_bomba_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_tsar_bomba_selected_index = 2
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_tsar_bomba_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_tsar_bomba_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_tsar_bomba_selected_index = 2
                        }
                    }
                    NOT = {
                        has_country_flag = tsar_bomba_confirmed
                    }
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_tsar_bomba_selected_index = 1
                            }
                        }
                        is_special_project_completed = sp:sp_nuclear_bomb
                    }
                    else_if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_tsar_bomba_selected_index = 2
                            }
                        }
                        has_full_control_of_state = 262
                        num_of_nukes > 2
                    }
                }
            }

            sov_national_obligations_tsar_bomba_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_tsar_bomba_selected_index = 1
                }
            }

            sov_national_obligations_tsar_bomba_first_option_button_click_enabled = {
                THIS = {
                    is_special_project_completed = sp:sp_nuclear_bomb
                    NOT = {
                        has_country_flag = tsar_bomba_confirmed
                    }
                }
            }

            sov_national_obligations_tsar_bomba_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_tsar_bomba_selected_index = 2
                }
            }

            sov_national_obligations_tsar_bomba_second_option_button_click_enabled = {
                THIS = {
                    has_full_control_of_state = 262
                    num_of_nukes > 2
                    NOT = {
                        has_country_flag = tsar_bomba_confirmed
                    }
                }
            }
        }
    }

    #Unfailing Army
    sov_national_obligations_unfailing_army_scripted_gui = {
        window_name = "sov_national_obligations_unfailing_army_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 3
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_unfailing_army_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionUnfailingArmy]
            }

            sov_national_obligations_unfailing_army_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionUnfailingArmy]
            }
        }

        effects = {
            sov_national_obligations_unfailing_army_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = unfailing_army_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_unfailing_army_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_unfailing_army_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_unfailing_army_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_unfailing_army_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_unfailing_army_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_unfailing_army_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_unfailing_army_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_unfailing_army_selected_index = 2
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_unfailing_army_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_unfailing_army_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_unfailing_army_selected_index = 2
                        }
                    }
                    NOT = {
                        has_country_flag = unfailing_army_confirmed
                    }
                }
            }

            sov_national_obligations_unfailing_army_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_unfailing_army_selected_index = 1
                }
            }

            sov_national_obligations_unfailing_army_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = unfailing_army_confirmed
                    }
                }
            }

            sov_national_obligations_unfailing_army_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_unfailing_army_selected_index = 2
                }
            }

            sov_national_obligations_unfailing_army_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = unfailing_army_confirmed
                    }
                }
            }
        }
    }

    #Grand Fleet
    sov_national_obligations_grand_fleet_scripted_gui = {
        window_name = "sov_national_obligations_grand_fleet_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 4
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_grand_fleet_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionGrandFleet]
            }

            sov_national_obligations_grand_fleet_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionGrandFleet]
            }
        }

        effects = {
            sov_national_obligations_grand_fleet_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = grand_fleet_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_grand_fleet_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_grand_fleet_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_grand_fleet_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_grand_fleet_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_grand_fleet_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_grand_fleet_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_grand_fleet_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_grand_fleet_selected_index = 2
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_grand_fleet_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_grand_fleet_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_grand_fleet_selected_index = 2
                        }
                    }
                    NOT = {
                        has_country_flag = grand_fleet_confirmed
                    }
                }
            }

            sov_national_obligations_grand_fleet_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_grand_fleet_selected_index = 1
                }
            }

            sov_national_obligations_grand_fleet_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = grand_fleet_confirmed
                    }
                }
            }

            sov_national_obligations_grand_fleet_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_grand_fleet_selected_index = 2
                }
            }

            sov_national_obligations_grand_fleet_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = grand_fleet_confirmed
                    }
                }
            }
        }
    }

    #Proletarian Union
    sov_national_obligations_proletarian_union_scripted_gui = {
        window_name = "sov_national_obligations_proletarian_union_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 5
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_proletarian_union_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionProletarianUnion]
            }

            sov_national_obligations_proletarian_union_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionProletarianUnion]
            }

            sov_national_obligations_proletarian_union_third_option_bg = {
                image = [THIS.GetCurrentStatusThirdOptionProletarianUnion]
            }
        }

        effects = {
            sov_national_obligations_proletarian_union_confirm_button_click = {
                THIS = {
                    set_country_flag = proletarian_union_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_proletarian_union_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_proletarian_union_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_proletarian_union_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_proletarian_union_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 2
                        }
                    }
                }
            }

            sov_national_obligations_proletarian_union_third_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_proletarian_union_selected_index = 3
                            }
                        }
                        set_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 3
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_proletarian_union_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 2
                        }
                        check_variable = {
                            sov_national_obligations_proletarian_union_selected_index = 3
                        }
                    }
                    NOT = {
                        has_country_flag = proletarian_union_confirmed
                    }
                }
            }

            sov_national_obligations_proletarian_union_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_proletarian_union_selected_index = 1
                }
            }

            sov_national_obligations_proletarian_union_first_option_button_click_enabled = {
                THIS = {
                    num_subjects > 19
                    NOT = {
                        has_country_flag = proletarian_union_confirmed
                    }
                }
            }

            sov_national_obligations_proletarian_union_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_proletarian_union_selected_index = 2
                }
            }

            sov_national_obligations_proletarian_union_second_option_button_click_enabled = {
                THIS = {
                    num_faction_members > 9
                    NOT = {
                        has_country_flag = proletarian_union_confirmed
                    }
                }
            }

            sov_national_obligations_proletarian_union_third_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_proletarian_union_selected_index = 3
                }
            }

            sov_national_obligations_proletarian_union_third_option_button_click_enabled = {
                THIS = {
                    has_country_leader = {
                        character = SOV_Joseph_stalin
                        ruling_only = yes
                    }
                    NOT = {
                        has_country_flag = proletarian_union_confirmed
                    }
                }
            }
        }
    }

    #Neverending Story
    sov_national_obligations_neverending_story_scripted_gui = {
        window_name = "sov_national_obligations_neverending_story_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 6
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_neverending_story_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionNeverendingStory]
            }

            sov_national_obligations_neverending_story_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionNeverendingStory]
            }

            sov_national_obligations_neverending_story_third_option_bg = {
                image = [THIS.GetCurrentStatusThirdOptionNeverendingStory]
            }
        }

        effects = {
            sov_national_obligations_neverending_story_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = neverending_story_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_neverending_story_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_neverending_story_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_neverending_story_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_neverending_story_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_neverending_story_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_neverending_story_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_neverending_story_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_neverending_story_selected_index = 2
                        }
                    }
                }
            }

            sov_national_obligations_neverending_story_third_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_neverending_story_selected_index = 3
                            }
                        }
                        set_variable = {
                            sov_national_obligations_neverending_story_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_neverending_story_selected_index = 3
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_neverending_story_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_neverending_story_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_neverending_story_selected_index = 2
                        }
                        check_variable = {
                            sov_national_obligations_neverending_story_selected_index = 3
                        }
                    }
                    NOT = {
                        has_country_flag = neverending_story_confirmed
                    }
                }
            }

            sov_national_obligations_neverending_story_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_neverending_story_selected_index = 1
                }
            }

            sov_national_obligations_neverending_story_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = neverending_story_confirmed
                    }
                }
            }

            sov_national_obligations_neverending_story_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_neverending_story_selected_index = 2
                }
            }

            sov_national_obligations_neverending_story_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = neverending_story_confirmed
                    }
                }
            }

            sov_national_obligations_neverending_story_third_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_neverending_story_selected_index = 3
                }
            }

            sov_national_obligations_neverending_story_third_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = neverending_story_confirmed
                    }
                }
            }
        }
    }

    #Continental System
    sov_national_obligations_continental_system_scripted_gui = {
        window_name = "sov_national_obligations_continental_system_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 7
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_continental_system_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionContinentalSystem]
            }

            sov_national_obligations_continental_system_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionContinentalSystem]
            }
        }

        effects = {
            sov_national_obligations_continental_system_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = continental_system_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_continental_system_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_continental_system_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_continental_system_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_continental_system_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_continental_system_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_continental_system_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_continental_system_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_continental_system_selected_index = 2
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_continental_system_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_continental_system_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_continental_system_selected_index = 2
                        }
                    }
                    NOT = {
                        has_country_flag = continental_system_confirmed
                    }
                }
            }

            sov_national_obligations_continental_system_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_continental_system_selected_index = 1
                }
            }

            sov_national_obligations_continental_system_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = continental_system_confirmed
                    }
                }
            }

            sov_national_obligations_continental_system_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_continental_system_selected_index = 2
                }
            }

            sov_national_obligations_continental_system_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = continental_system_confirmed
                    }
                }
            }
        }
    }

    #Treaty Moscow
    sov_national_obligations_treaty_moscow_scripted_gui = {
        window_name = "sov_national_obligations_treaty_moscow_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 8
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_treaty_moscow_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionTreatyMoscow]
            }

            sov_national_obligations_treaty_moscow_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionTreatyMoscow]
            }
        }

        effects = {
            sov_national_obligations_treaty_moscow_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = treaty_moscow_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_treaty_moscow_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_treaty_moscow_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_treaty_moscow_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_treaty_moscow_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_treaty_moscow_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_treaty_moscow_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_treaty_moscow_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_treaty_moscow_selected_index = 2
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_treaty_moscow_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_treaty_moscow_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_treaty_moscow_selected_index = 2
                        }
                    }
                    NOT = {
                        has_country_flag = treaty_moscow_confirmed
                    }
                }
            }

            sov_national_obligations_treaty_moscow_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_treaty_moscow_selected_index = 1
                }
            }

            sov_national_obligations_treaty_moscow_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = treaty_moscow_confirmed
                    }
                }
            }

            sov_national_obligations_treaty_moscow_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_treaty_moscow_selected_index = 2
                }
            }

            sov_national_obligations_treaty_moscow_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = treaty_moscow_confirmed
                    }
                }
            }
        }
    }

    #Golden Age
    sov_national_obligations_golden_age_scripted_gui = {
        window_name = "sov_national_obligations_golden_age_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 9
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_golden_age_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionGoldenAge]
            }

            sov_national_obligations_golden_age_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionGoldenAge]
            }
        }

        effects = {
            sov_national_obligations_golden_age_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = golden_age_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_golden_age_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_golden_age_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_golden_age_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_golden_age_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_golden_age_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_golden_age_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_golden_age_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_golden_age_selected_index = 2
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_golden_age_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_golden_age_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_golden_age_selected_index = 2
                        }
                    }
                    NOT = {
                        has_country_flag = golden_age_confirmed
                    }
                }
            }

            sov_national_obligations_golden_age_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_golden_age_selected_index = 1
                }
            }

            sov_national_obligations_golden_age_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = golden_age_confirmed
                    }
                }
            }

            sov_national_obligations_golden_age_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_golden_age_selected_index = 2
                }
            }

            sov_national_obligations_golden_age_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = golden_age_confirmed
                    }
                }
            }
        }
    }

    #Imperial Obligations
    sov_national_obligations_imperial_obligations_scripted_gui = {
        window_name = "sov_national_obligations_imperial_obligations_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 10
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_imperial_obligations_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionImperialObligations]
            }

            sov_national_obligations_imperial_obligations_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionImperialObligations]
            }

            sov_national_obligations_imperial_obligations_third_option_bg = {
                image = [THIS.GetCurrentStatusThirdOptionImperialObligations]
            }
        }

        effects = {
            sov_national_obligations_imperial_obligations_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = imperial_obligations_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_imperial_obligations_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_imperial_obligations_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_imperial_obligations_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_imperial_obligations_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 2
                        }
                    }
                }
            }

            sov_national_obligations_imperial_obligations_third_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_imperial_obligations_selected_index = 3
                            }
                        }
                        set_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 3
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_imperial_obligations_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 2
                        }
                        check_variable = {
                            sov_national_obligations_imperial_obligations_selected_index = 3
                        }
                    }
                    NOT = {
                        has_country_flag = imperial_obligations_confirmed
                    }
                }
            }

            sov_national_obligations_imperial_obligations_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_imperial_obligations_selected_index = 1
                }
            }

            sov_national_obligations_imperial_obligations_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = imperial_obligations_confirmed
                    }
                }
            }

            sov_national_obligations_imperial_obligations_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_imperial_obligations_selected_index = 2
                }
            }

            sov_national_obligations_imperial_obligations_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = imperial_obligations_confirmed
                    }
                }
            }

            sov_national_obligations_imperial_obligations_third_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_imperial_obligations_selected_index = 3
                }
            }

            sov_national_obligations_imperial_obligations_third_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = imperial_obligations_confirmed
                    }
                }
            }
        }
    }

    #Carry On Legacy
    sov_national_obligations_carry_on_legacy_scripted_gui = {
        window_name = "sov_national_obligations_carry_on_legacy_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 11
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_carry_on_legacy_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionCarryOnLegacy]
            }

            sov_national_obligations_carry_on_legacy_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionCarryOnLegacy]
            }
        }

        effects = {
            sov_national_obligations_carry_on_legacy_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = carry_on_legacy_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_carry_on_legacy_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_carry_on_legacy_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_carry_on_legacy_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_carry_on_legacy_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_carry_on_legacy_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_carry_on_legacy_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_carry_on_legacy_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_carry_on_legacy_selected_index = 2
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_carry_on_legacy_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_carry_on_legacy_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_carry_on_legacy_selected_index = 2
                        }
                    }
                    NOT = {
                        has_country_flag = carry_on_legacy_confirmed
                    }
                }
            }

            sov_national_obligations_carry_on_legacy_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_carry_on_legacy_selected_index = 1
                }
            }

            sov_national_obligations_carry_on_legacy_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = carry_on_legacy_confirmed
                    }
                }
            }

            sov_national_obligations_carry_on_legacy_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_carry_on_legacy_selected_index = 2
                }
            }

            sov_national_obligations_carry_on_legacy_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = carry_on_legacy_confirmed
                    }
                }
            }
        }
    }

    #Russian Realm
    sov_national_obligations_russian_realm_scripted_gui = {
        window_name = "sov_national_obligations_russian_realm_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 12
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_russian_realm_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionRussianRealm]
            }

            sov_national_obligations_russian_realm_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionRussianRealm]
            }

            sov_national_obligations_russian_realm_third_option_bg = {
                image = [THIS.GetCurrentStatusThirdOptionRussianRealm]
            }
        }

        effects = {
            sov_national_obligations_russian_realm_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = russian_realm_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_russian_realm_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_russian_realm_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_russian_realm_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_russian_realm_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_russian_realm_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_russian_realm_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_russian_realm_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_russian_realm_selected_index = 2
                        }
                    }
                }
            }

            sov_national_obligations_russian_realm_third_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_russian_realm_selected_index = 3
                            }
                        }
                        set_variable = {
                            sov_national_obligations_russian_realm_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_russian_realm_selected_index = 3
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_russian_realm_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_russian_realm_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_russian_realm_selected_index = 2
                        }
                        check_variable = {
                            sov_national_obligations_russian_realm_selected_index = 3
                        }
                    }
                    NOT = {
                        has_country_flag = russian_realm_confirmed
                    }
                }
            }

            sov_national_obligations_russian_realm_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_russian_realm_selected_index = 1
                }
            }

            sov_national_obligations_russian_realm_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = russian_realm_confirmed
                    }
                }
            }

            sov_national_obligations_russian_realm_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_russian_realm_selected_index = 2
                }
            }

            sov_national_obligations_russian_realm_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = russian_realm_confirmed
                    }
                }
            }

            sov_national_obligations_russian_realm_third_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_russian_realm_selected_index = 3
                }
            }

            sov_national_obligations_russian_realm_third_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = russian_realm_confirmed
                    }
                }
            }
        }
    }

    #Rebirth
    sov_national_obligations_rebirth_scripted_gui = {
        window_name = "sov_national_obligations_rebirth_view"
        context_type = player_context
        parent_window_name = "sov_national_obligations_scripted_gui_window"

        visible = {
            check_variable = {
                var = sov_national_obligations_selected_index
                value = 13
                compare = equals
            }
        }

        properties = {
            sov_national_obligations_rebirth_first_option_bg = {
                image = [THIS.GetCurrentStatusFirstOptionRebirth]
            }

            sov_national_obligations_rebirth_second_option_bg = {
                image = [THIS.GetCurrentStatusSecondOptionRebirth]
            }

            sov_national_obligations_rebirth_third_option_bg = {
                image = [THIS.GetCurrentStatusThirdOptionRebirth]
            }
        }

        effects = {
            sov_national_obligations_rebirth_confirm_button_click = {
                THIS = {
                    #TODO
                    set_country_flag = rebirth_confirmed
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations_help
                        }
                        clr_country_flag = sov_open_national_obligations_help
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_debug_national_obligations
                        }
                        clr_country_flag = sov_debug_national_obligations
                    }
                    if = {
                        limit = {
                            has_country_flag = sov_open_national_obligations
                        }
                        clr_country_flag = sov_open_national_obligations
                    }
                }
            }

            sov_national_obligations_rebirth_first_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_rebirth_selected_index = 1
                            }
                        }
                        set_variable = {
                            sov_national_obligations_rebirth_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_rebirth_selected_index = 1
                        }
                    }
                }
            }

            sov_national_obligations_rebirth_second_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_rebirth_selected_index = 2
                            }
                        }
                        set_variable = {
                            sov_national_obligations_rebirth_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_rebirth_selected_index = 2
                        }
                    }
                }
            }

            sov_national_obligations_rebirth_third_option_button_click = {
                THIS = {
                    if = {
                        limit = {
                            check_variable = {
                                sov_national_obligations_rebirth_selected_index = 3
                            }
                        }
                        set_variable = {
                            sov_national_obligations_rebirth_selected_index = 0
                        }
                    }
                    else = {
                        set_variable = {
                            sov_national_obligations_rebirth_selected_index = 3
                        }
                    }
                }
            }
        }

        triggers = {
            sov_national_obligations_rebirth_confirm_button_click_enabled = {
                THIS = {
                    OR = {
                        check_variable = {
                            sov_national_obligations_rebirth_selected_index = 1
                        }
                        check_variable = {
                            sov_national_obligations_rebirth_selected_index = 2
                        }
                        check_variable = {
                            sov_national_obligations_rebirth_selected_index = 3
                        }
                    }
                    NOT = {
                        has_country_flag = rebirth_confirmed
                    }
                }
            }

            sov_national_obligations_rebirth_first_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_rebirth_selected_index = 1
                }
            }

            sov_national_obligations_rebirth_first_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = rebirth_confirmed
                    }
                }
            }

            sov_national_obligations_rebirth_second_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_rebirth_selected_index = 2
                }
            }

            sov_national_obligations_rebirth_second_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = rebirth_confirmed
                    }
                }
            }

            sov_national_obligations_rebirth_third_option_glow_visible = {
                check_variable = {
                    sov_national_obligations_rebirth_selected_index = 3
                }
            }

            sov_national_obligations_rebirth_third_option_button_click_enabled = {
                THIS = {
                    #TODO
                    NOT = {
                        has_country_flag = rebirth_confirmed
                    }
                }
            }
        }
    }
}