scripted_gui = {

	EAI_open_config = {

		context_type = player_context

		window_name = "EAI_open_config"
		
		visible = {
			is_ai = no

			OR = {
				NOT = { has_global_flag = EAI_restrict_to_host }
				has_country_flag = EAI_designated_host
				AND = {
					has_global_flag = EAI_restrict_to_host
					NOT = { any_other_country = { has_country_flag = EAI_designated_host } }
				}
			}
		}

		effects = {
			EAI_open_config_button_click = {
				set_country_flag = EAI_config_DIFFICULTY
				
				set_country_flag = EAI_show_country_config_decisions
				
				every_other_country = { limit = { is_ai = no } country_event = EAI.4 }

				EAI_refresh_gui = yes
			}
		}

		triggers = {
			EAI_open_config_button_click_enabled = {
				NOT = {  
					has_country_flag = EAI_config_STARTUP
					has_country_flag = EAI_config_DIFFICULTY
					has_country_flag = EAI_config_GENERAL
				}
			}
		}
	}

	EAI_open_country_config = {

		context_type = selected_country_context

		window_name = "EAI_open_country_config"

		visible = {
			ROOT = { OR = { has_country_flag = EAI_config_STARTUP has_country_flag = EAI_config_DIFFICULTY has_country_flag = EAI_config_GENERAL } }
		}

		effects = {
			EAI_open_country_config_button_click = {
				ROOT = {
					clr_country_flag = EAI_config_CUSTOM_BONUS
					
					set_country_flag = EAI_config_COUNTRY

					PREV = {
						set_country_flag = EAI_player_is_configuring_this_country

						set_country_flag = EAI_player_is_configuring_this_country_@ROOT

						set_variable = { ROOT.EAI_configuration_target = THIS.id }

						EAI_DIFFICULTY_get_custom_bonus_settings = yes
					}
					
					set_variable = { ROOT.EAI_dd_unit_count = PREV.EAI_dd_unit_count }
				}

				EAI_refresh_gui = yes
			}
		}

		triggers = {
			EAI_open_country_config_button_click_enabled = {
				NOT = { has_country_flag = EAI_player_is_configuring_this_country }

				NOT = { 
					ROOT = { has_country_flag = EAI_config_COUNTRY } 
					ROOT = { has_country_flag = EAI_config_ARMY } 
					ROOT = { has_country_flag = EAI_config_ARMY_DIPLOMATIC } 
				}
			}
		}
	}

	EAI_startup_message = {

		context_type = player_context

		window_name = "EAI_startup_message"
		
		visible = {
			NOT = { has_global_flag = EAI_startup_message }
		}

		effects = {

			EAI_startup_message_button_click = {
				
				set_global_flag = EAI_startup_message
			}
		}
	}
}