
scripted_gui = {

	bottom_gui = {
		context_type = player_context
		parent_window_token = top_bar
		window_name = "bottom_gui"

		visible = {
			OR = {
				has_country_flag = country_has_gui
				has_country_flag = IBR_Terrorism_GUI
				tag = MEX
			}
			if = {
				limit = { tag = BRG }
				NOT = { has_country_flag = BRG_domestic_GUI_disabled }
			}
			if = {
				limit = {
					tag = GER
					has_global_flag = german_civil_war_bormannvic
				}
				OR = {
					has_country_flag = BOR_Kartenhaus_Active
					has_country_flag = BOR_DBG_Infl_Mech
				}
			}
			if = {
				limit = { tag = ENG }
				has_country_flag = BRI_WorkshopMechanic_Active
			}
			if = {
				limit = { tag = UKR }
				has_country_flag = UKR_bb_enabled
			}
		}

		triggers = {
            militarists_crt_icon_visible = {
				original_tag = GER
				NOT = { 
					has_global_flag = german_civil_war_speervic
					has_global_flag = german_civil_war_bormannvic
					has_global_flag = german_civil_war_heydrichvic
				}
			}		
			zollverein_crt_icon_visible = {
				original_tag = GER
				has_global_flag = german_civil_war_speervic
			}
			kartenhaus_crt_icon_visible = {
				original_tag = GER
				OR = {
					has_country_flag = BOR_Kartenhaus_Active
					has_country_flag = BOR_DBG_Infl_Mech
				}
			}
			breadbasket_crt_icon_visible = {
				AND = {
					original_tag = UKR
					has_country_flag = UKR_bb_enabled
				}
			}
			heydrich_nukes_crt_icon_visible = {
				original_tag = GER
				has_country_flag = HGR_Enable_Nuke_GUI
			}
			us_senate_crt_icon_visible = {
				original_tag = USA
			}
			brazil_federal_crt_icon_visible = {
				original_tag = BRA
			}
			england_parliament_crt_icon_visible = {
				OR = { original_tag = ENG original_tag = FEN }
				NOT = { has_country_flag = ENG_Parliament_Disabled }
			}
			england_parliament_crt_icon_click_enabled = {
				NOT = { has_country_flag = TNO_ParliamentMechanic_Disabled }
			}
			burgundy_crt_icon_visible = {
				original_tag = BRG
			}
			hunting_crt_icon_visible = {
				AND = {
					original_tag = COG
					has_country_leader = {
						character = COG_Siegfried_Muller
					}
				}
			}
			yokusankai_crt_icon_visible = {
				original_tag = JAP
			}
			novosib_gui_crt_icon_visible = {
				tag = NOV
				NOT = {
					has_global_flag = AFTER_MIDNIGHT_COMMENCED
				}
			}
			tomsk_duma_gui_crt_icon_visible = {
				tag = TOM
				NOT = {
					has_global_flag = AFTER_MIDNIGHT_COMMENCED
				}
			}
			iberia_terrorism_gui_crt_icon_visible = {
				tag = IBR
				has_country_flag = IBR_Terrorism_GUI
			}
			GNG_legco_crt_icon_visible = {
				tag = GNG
			}
			canada_GUIs_crt_icon_visible = {
				tag = CAN
			}
			project_ferus_crt_icon_visible = {
				original_tag = OMO
				has_country_flag = OMO_2022_project_ferus_active
			}
			BRI_workshop_crt_icon_visible = {
				original_tag = ENG
				has_country_flag = BRI_WorkshopMechanic_Active
			}
			MEX_PRI_mechanic_crt_icon_visible = {
				original_tag = MEX
			}
			antarctica_grid_gui_crt_icon_visible = {
				is_antarctic_nation = yes
			}
			greater_china_crt_icon_visible = {
				tag = YUN
				check_variable = { YUN_introduce_admin = 1 }
				NOT = { has_country_flag = YUN_NPA_despair_branch }
			}
		}

		effects = {
		    militarists_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = GER_Army_GUI_open_flag } }
					set_country_flag = GER_Army_GUI_open_flag
				}
				else_if = {
					limit = { has_country_flag = GER_Army_GUI_open_flag }
					clr_country_flag = GER_Army_GUI_open_flag
				}
				clr_country_flag = gui_alert_visible_2
			}
			zollverein_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = GER_Economy_GUI_open_flag } }
					set_country_flag = GER_Economy_GUI_open_flag
					calculate_Reich_GDP = yes
				}
				else_if = {
					limit = { has_country_flag = GER_Economy_GUI_open_flag }
					clr_country_flag = GER_Economy_GUI_open_flag
				}
				clr_country_flag = gui_alert_visible_2
			}
			us_senate_crt_icon_click = {
				USA_GUI_opening_effect = yes
			}
			brazil_federal_crt_icon_click = {
				if = {
					limit = { has_country_flag = BRA_map_window_open }
					clr_country_flag = BRA_map_window_open
				}
				else = {
					set_country_flag = BRA_map_window_open
					BRA_senate_select_state = yes
				}
				clear_array = BRA_senate_campaigning_party
				clr_country_flag = gui_alert_visible_2
			}
			brazil_federal_crt_icon_click = {
				if = {
					limit = { has_country_flag = BRA_map_window_open }
					clr_country_flag = BRA_map_window_open
				}
				else = {
					set_country_flag = BRA_map_window_open
					BRA_senate_select_state = yes
				}
				clear_array = BRA_senate_campaigning_party
				clr_country_flag = gui_alert_visible_2
			}
			kartenhaus_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = GER_Bormann_SIG_GUI_Open } }
					set_country_flag = GER_Bormann_SIG_GUI_Open
					BOR_Kartenhaus_Open = yes
				}
				else_if = {
					limit = { has_country_flag = GER_Bormann_SIG_GUI_Open }
					clr_country_flag = GER_Bormann_SIG_GUI_Open
					BOR_Kartenhaus_Close = yes
					GER_Bormann_Kartenhaus_Info_ClearBtnFlags = yes
				}
				clr_country_flag = gui_alert_visible_2
			}
			kartenhaus_crt_icon_right_click = {
				if = {
					limit = {
						NOT = { has_country_flag = GER_BOR_SIG_debug_screen_buttons }
						is_debug = yes
					}
					set_country_flag = GER_BOR_SIG_debug_screen_buttons
				}
				else_if = {
					limit = {
						has_country_flag = GER_BOR_SIG_debug_screen_buttons
						is_debug = yes
					}
					clr_country_flag = GER_BOR_SIG_debug_screen_buttons
				}
			}
			heydrich_nukes_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = HGR_GUI_open_flag } }
					set_country_flag = HGR_GUI_open_flag
				}
				else_if = {
					limit = { has_country_flag = HGR_GUI_open_flag }
					clr_country_flag = HGR_GUI_open_flag
				}
				clr_country_flag = HGR_gui_warning
				GER = { update_nuke_control = yes }
				clr_country_flag = gui_alert_visible_2
			}
			england_parliament_crt_icon_click = {
				TNO_Britain_ElectionMap_Setup = yes
				clr_country_flag = gui_alert_visible_2
				if = {
					limit = { NOT = { has_country_flag = ParliamentMechanic_screen_open } }
					ParliamentMechanic_GUIHelper_initialize = yes
					set_country_flag = ParliamentMechanic_screen_open
				}
				else = {
					ParliamentMechanic_GUIHelper_cleanup = yes
					clr_country_flag = ParliamentMechanic_screen_open
				}
			}
			england_parliament_crt_icon_right_click = {
				if = {
					limit = {
						is_debug = yes
						NOT = { has_country_flag = DBG_ENG_ParliamentMech }
					}
					set_country_flag = DBG_ENG_ParliamentMech
				}
				else = { clr_country_flag = DBG_ENG_ParliamentMech }
			}
			burgundy_crt_icon_click = {
				clr_country_flag = gui_alert_visible_2
				if = {
					limit = {
						has_country_flag = TNO_Burgundy_Domestic_GUI_visible
					}
					clr_country_flag = TNO_Burgundy_Domestic_GUI_visible
				}
				else = {
					set_country_flag = TNO_Burgundy_Domestic_GUI_visible
				}
				set_country_flag = TNO_Burgundy_Domestic_GUI_Opener_Clear
			}
			hunting_crt_icon_click = {
				if = {
					limit = {
						NOT = { has_country_flag = cog_muller_hunting_open }
					}
					set_country_flag = cog_muller_hunting_open
				}
				else_if = {
					limit = {
						has_country_flag = cog_muller_hunting_open
					}
					clr_country_flag = cog_muller_hunting_open
				}
				clr_country_flag = gui_alert_visible_2
			}
			yokusankai_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = JAP_Internal_GUI_open_flag } }
					set_country_flag = JAP_Internal_GUI_open_flag
				}
				else_if = {
					limit = { has_country_flag = JAP_Internal_GUI_open_flag }
					clr_country_flag = JAP_Internal_GUI_open_flag
				}
				clr_country_flag = gui_alert_visible_2
			}
			novosib_gui_crt_icon_click = {
				if = {
					limit = { has_country_flag = NOV_Silovik_State_GUI_visible_flag }
					clr_country_flag = NOV_Silovik_State_GUI_visible_flag
				}
				else = { set_country_flag = NOV_Silovik_State_GUI_visible_flag }
				clr_country_flag = gui_alert_visible_2
			}
			tomsk_duma_gui_crt_icon_click = {
				if = {
					limit = { has_country_flag = TOM_Duma_GUI_Open }
					clr_country_flag = TOM_Duma_GUI_Open
				}
				else = { set_country_flag = TOM_Duma_GUI_Open }
				clr_country_flag = gui_alert_visible_2
			}
			iberia_terrorism_gui_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = IBR_terrorism_window_open_flag } }
					set_country_flag = IBR_terrorism_window_open_flag
				}
				else_if = {
					limit = { has_country_flag = IBR_terrorism_window_open_flag }
					clr_country_flag = IBR_terrorism_window_open_flag
				}
				clr_country_flag = gui_alert_visible_2
			}
			GNG_legco_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = TNO_GNG_LegCo_GUI_Open } }
					set_country_flag = TNO_GNG_LegCo_GUI_Open
				}
				else_if = {
					limit = { has_country_flag = TNO_GNG_LegCo_GUI_Open }
					clr_country_flag = TNO_GNG_LegCo_GUI_Open
				}
				clr_country_flag = gui_alert_visible_2
			}
			canada_GUIs_crt_icon_click = {
				if = {
					limit = { has_country_flag = CAN_Election_GUI_Open_Flag }
					clr_country_flag = CAN_Election_GUI_Open_Flag
				}
				else = { set_country_flag = CAN_Election_GUI_Open_Flag }
				clr_country_flag = gui_alert_visible_2
			}
			breadbasket_crt_icon_click = {
				if = {
					limit = { has_country_flag = Ukraine_GUI_Visible_Flag }
					clr_country_flag = Ukraine_GUI_Visible_Flag
				}
				else = { set_country_flag = Ukraine_GUI_Visible_Flag }
				clr_country_flag = gui_alert_visible_2
			}
			project_ferus_crt_icon_click = {
				if = {
					limit = { has_country_flag = OMO_2022_project_ferus_displayed }
					clr_country_flag = OMO_2022_project_ferus_displayed
				}
				else = { set_country_flag = OMO_2022_project_ferus_displayed }
				clr_country_flag = gui_alert_visible_2
			}
			BRI_workshop_crt_icon_click = {
				clr_country_flag = gui_alert_visible_2
				if = {
					limit = { NOT = { has_country_flag = BRI_Workshop_Open } }
					set_country_flag = BRI_Workshop_Open
					BRI_Workshop_DisplayUpdate = yes
				}
				else = {
					clr_country_flag = BRI_Workshop_Open
				}
				add_to_variable = { BRI_Workshop_Dirty = 1 }
			}
			MEX_PRI_mechanic_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = TNO_MEX_PRI_GUI_Open } }
					set_country_flag = TNO_MEX_PRI_GUI_Open
				}
				else_if = {
					limit = { has_country_flag = TNO_MEX_PRI_GUI_Open }
					clr_country_flag = TNO_MEX_PRI_GUI_Open
				}
				clr_country_flag = gui_alert_visible_2
			}
			MEX_PRI_mechanic_crt_icon_right_click = {
				if = {
					limit = {
						NOT = { has_country_flag = TNO_MEX_PRI_GUI_Debug }
						is_debug = yes
					}
					set_country_flag = TNO_MEX_PRI_GUI_Debug
				}
				else_if = {
					limit = {
						has_country_flag = TNO_MEX_PRI_GUI_Debug
						is_debug = yes
					}
					clr_country_flag = TNO_MEX_PRI_GUI_Debug
				}
			}
			antarctica_grid_gui_crt_icon_click = {
				clr_country_flag = gui_alert_visible_2
				if = {
					limit = { NOT = { has_country_flag = Antarctica_GUI_Open_Flag } }
					set_country_flag = Antarctica_GUI_Open_Flag
				}
				else = {
					clr_country_flag = Antarctica_GUI_Open_Flag
				}
			}
			greater_china_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = WI_GUI_map_open } }
					set_country_flag = WI_GUI_map_open
					greater_china_states_concesus = yes
				}
				else_if = {
					limit = { has_country_flag = WI_GUI_map_open }
					clr_country_flag = WI_GUI_map_open
				}
				clr_country_flag = gui_alert_visible_2
			}
		}

		properties = {
			burgundy_crt_icon = { image = "[get_BRG_bottom_GUI_GFX]" }
		}
	}

	bottom_gui_2 = {
		context_type = player_context
		parent_window_token = top_bar
		window_name = "bottom_gui_2"

		visible = {
			has_country_flag = country_has_2nd_gui
		}

		triggers = {
			burgundy_investigation_crt_icon_visible = {
				original_tag = BRG
			}
			burgundy_investigation_crt_icon_click_enabled = {
				OR = { has_country_flag = BRG_Investigating_DeGrelle has_country_flag = BRG_Post_DeGrelle_Investigations_Unlocked }
			}
			tomsk_district_gui_crt_icon_visible = {
				tag = TOM
				NOT = {
					has_global_flag = AFTER_MIDNIGHT_COMMENCED
				}
			}
			GNG_market_crt_icon_visible = {
				tag = GNG
			}
			antarctica_pert_gui_crt_icon_visible = {
				tag = AAO
			}
		}
		effects = {
			burgundy_investigation_crt_icon_click = {
				if = {
					limit = { AND = { has_country_flag = BRG_Investigating_DeGrelle NOT = { has_global_flag = german_civil_war } } }
					if = {
						limit = { NOT = { has_country_flag = BRG_Walloon_Investigation_open_flag } }
						set_country_flag = BRG_Walloon_Investigation_open_flag
						BRG_Investigation_Setup = yes
					}
					else_if = {
						limit = { has_country_flag = BRG_Walloon_Investigation_open_flag }
						clr_country_flag = BRG_Walloon_Investigation_open_flag
					}
				}

				if = {
					limit = { has_country_flag = BRG_Post_DeGrelle_Investigations_Unlocked }
					if = {
						limit = { NOT = { has_country_flag = BRG_Investigation_main_open_flag } }
						set_country_flag = BRG_Investigation_main_open_flag
					}
					else_if = {
						limit = { has_country_flag = BRG_Investigation_main_open_flag }
						clr_country_flag = BRG_Investigation_main_open_flag
					}
				}
			}
			tomsk_district_gui_crt_icon_click = {
				if = {
					limit = { has_country_flag = TOM_Tomsk_Map_open }
					clr_country_flag = TOM_Tomsk_Map_open
				}
				else = { set_country_flag = TOM_Tomsk_Map_open }
			}
			GNG_market_crt_icon_click = {
				if = {
					limit = { has_country_flag = GNG_arms_market_visible }
					clr_country_flag = GNG_arms_market_visible
				}
				else = { set_country_flag = GNG_arms_market_visible }
			}
			antarctica_pert_gui_crt_icon_click = {
				if = {
					limit = { NOT = { has_country_flag = Antarctica_GUI_AAO_PERT_Mechanic_Visible } }
					set_country_flag = Antarctica_GUI_AAO_PERT_Mechanic_Visible
				}
				else_if = {
					limit = { has_country_flag = Antarctica_GUI_AAO_PERT_Mechanic_Visible }
					clr_country_flag = Antarctica_GUI_AAO_PERT_Mechanic_Visible
				}
			}
		}
	}

	arrows_alert = {
		context_type = player_context
		parent_window_token = top_bar
		window_name = "arrows_alert"

		visible = {
			has_country_flag = country_has_gui
		}

		triggers = {
			gui_alert_visible = {
				has_country_flag = gui_alert_visible_2
			}
		}
	}

}