scripted_gui = {
	
	
	Resource_exploitation_c = {
		context_type = selected_state_context
		window_name = "Building_demolition"
		parent_window_token = selected_state_view
		
		visible = {
			THIS = {
				owner = {
					TAG = ROOT
					is_ai = no
				}
			}
		}
		triggers = {
			header_bg_visible = {
				check_variable = {
					ROOT.open_close = 1
				}
				ROOT = {
					NOT = {
						has_country_flag = no_ecy_flag
					}
				}
			}
		}
		properties = {
			open_close = {
				image = "GFX_op_cl" 
				frame = ROOT.open_close
			}
		}
		
		effects = { 
			open_close_click = {
				if = {
					limit = {
						ROOT = {
							NOT = { has_variable = root.open_close }
						}
					}
					set_variable = {
						root.open_close = 2
					}
				}
				else_if = {
					limit = {
						check_variable = {
							root.open_close = 2
						}
					}
					set_variable = {
						root.open_close = 1
					}
				}
				else_if = {
					limit = {
						check_variable = {
							root.open_close = 1
						}
					}
					set_variable = {
						root.open_close = 2
					}
				}
			}
			open_close_alt_right_click = {
				ROOT = {
					if = {
						limit = {
							ROOT = {
								NOT = { has_country_flag = no_ecy_flag }
							}
						}
						set_country_flag = no_ecy_flag
					}
					else = {
						clr_country_flag = no_ecy_flag
					}
				}
			}
	    }
    }
	bui_del_win = {
		context_type = selected_state_context
		window_name = "Building_delet"
		parent_window_token = selected_state_view
		visible = {
			THIS = {
				owner = {
					owner = {
						TAG = ROOT
						is_ai = no
					}
				}
				check_variable = {
					root.open_close = 2
				}
			}
		}
		properties = {
			open_close = {
				image = "GFX_op_cl" 
				frame = ROOT.open_close
			}
		}
		triggers = {
			header_bg_visible = {
				ROOT = {
					NOT = {
						has_country_flag = no_ecy_flag
					}
				}
			}
			Dismantling_1_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@infrastructure > 0
					}
				}
			}
			Dismantling_2_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@arms_factory > 0
					}
				}
			}
			Dismantling_3_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@industrial_complex > 0
					}
				}
			}
			Dismantling_4_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@dockyard > 0
					}
				}
			}
			Dismantling_5_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@office_park > 0
					}
				}
			}
			Dismantling_6_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@air_base > 0
					}
				}
			}
			Dismantling_7_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@anti_air_building > 0
					}
				}
			}
			Dismantling_8_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@synthetic_refinery > 0
					}
				}
			}
			Dismantling_9_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@fuel_silo > 0
					}
				}
			}
			Dismantling_10_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@radar_station > 0
					}
				}
			}
			Dismantling_11_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@rocket_site > 0
					}
				}
			}
			Dismantling_12_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@nuclear_reactor > 0
					}
				}
			}
			Dismantling_13_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@power_plant > 0
					}
				}
			}
			Dismantling_14_click_enabled = {
				THIS = {
					check_variable = {
						var:building_level@energy_farm > 0
					}
				}
			}
			Dismantling_15_click_enabled = {
				THIS = {
					#always = no
				}
			}
		}
		effects = {
			open_close_click = {
				if = {
					limit = {
						ROOT = {
							NOT = { has_variable = root.open_close }
						}
					}
					set_variable = {
						root.open_close = 2
					}
				}
				else_if = {
					limit = {
						check_variable = {
							root.open_close = 2
						}
					}
					set_variable = {
						root.open_close = 1
					}
				}
				else_if = {
					limit = {
						check_variable = {
							root.open_close = 1
						}
					}
					set_variable = {
						root.open_close = 2
					}
				}
			}
			open_close_alt_right_click = {
				ROOT = {
					if = {
						limit = {
							ROOT = {
								NOT = { has_country_flag = no_ecy_flag }
							}
						}
						set_country_flag = no_ecy_flag
					}
					else = {
						clr_country_flag = no_ecy_flag
					}
				}
			}
			Dismantling_1_alt_right_click = { 
				THIS = {
					set_building_level = {
						type = infrastructure
						level = 0
					}
				}
			}
			Dismantling_2_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = arms_factory
						level = 0
					}
				}
			}
			Dismantling_3_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = industrial_complex
						level = 0
					}
				}
			}
			Dismantling_4_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = dockyard
						level = 0
					}
				}
			}
			Dismantling_5_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = office_park
						level = 0
					}
				}
			}
			Dismantling_6_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = air_base
						level = 0
					}
				}
			}
			Dismantling_7_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = anti_air_building
						level = 0
					}
				}
			}
			Dismantling_8_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = synthetic_refinery
						level = 0
					}
				}
			}
			Dismantling_9_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = fuel_silo
						level = 0
					}
				}
			}
			Dismantling_10_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = radar_station
						level = 0
					}
				}
			}
			Dismantling_11_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = rocket_site
						level = 0
					}
				}
			}
			Dismantling_12_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = nuclear_reactor
						level = 0
					}
				}
			}
			Dismantling_13_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = power_plant
						level = 0
					}
				}
			}
			Dismantling_14_alt_right_click = { 
				THIS = {
					set_building_level= {
						type = energy_farm
						level = 0
					}
				}
			}
			Dismantling_1_click = {
				THIS = {
					remove_building= {
						type = infrastructure
						level = 1
					}
				}
			}
			Dismantling_2_click = {
				THIS = {
					remove_building = {
						type = arms_factory
						level = 1
					}
				}
			}
			Dismantling_3_click = {
				THIS = {
					remove_building = {
						type = industrial_complex
						level = 1
					}
				}
			}
			Dismantling_4_click = {
				THIS = {
					remove_building = {
						type = dockyard
						level = 1
					}
				}
			}
			Dismantling_5_click = {
				THIS = {
					remove_building = {
						type = office_park
						level = 1
					}
				}
			}
			Dismantling_6_click = {
				THIS = {
					remove_building = {
						type = air_base
						level = 1
					}
				}
			}
			Dismantling_7_click = {
				THIS = {
					remove_building = {
						type = anti_air_building
						level = 1
					}
				}
			}
			Dismantling_8_click = {
				THIS = {
					remove_building = {
						type = synthetic_refinery
						level = 1
					}
				}
			}
			Dismantling_9_click = {
				THIS = {
					remove_building = {
						type = fuel_silo
						level = 1
					}
				}
			}
			Dismantling_10_click = {
				THIS = {
					remove_building = {
						type = radar_station
						level = 1
					}
				}
			}
			Dismantling_11_click = {
				THIS = {
					remove_building = {
						type = rocket_site
						level = 1
					}
				}
			}
			Dismantling_12_click = {
				THIS = {
					remove_building = {
						type = nuclear_reactor
						level = 1
					}
				}
			}
			Dismantling_13_click = {
				THIS = {
					remove_building = {
						type = power_plant
						level = 1
					}
				}
			}
			Dismantling_14_click = {
				THIS = {
					remove_building = {
						type = energy_farm
						level = 1
					}
				}
			}
			Dismantling_15_click = {
				THIS = {
					set_building_level = {
						type = rail_way
						level = 0
						province = {
							all_provinces = yes
						}
					}
				}
			}
		}
	}
	
}

