#####################

###  ##  #  # # #  ## 
 #  #  # ## # # # #   
 #  #### # ## ##   #  
 #  #  # #  # # #   # 
 #  #  # #  # # # ## 

 #################### 


GER_porsche_organization = {
	include = generic_heavy_tank_organization
	icon = GFX_idea_porsche
	
 	allowed = {	
 		always = no
 	}

	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}

		IF = {
			limit = {
				FROM = { tag = MEX }
			}
			FROM = { is_in_faction_with = GER }
		}
		ELSE_IF = {
			limit = {
				FROM = { tag = NOR }
			}
			FROM = { has_completed_focus = NOR_invite_german_engineers }
		}
	}
}

GER_henschel_organization = {
	include = generic_mobile_tank_organization
	icon = GFX_idea_henschel
	
 	allowed = {	
 		always = no
 	}
	
	visible = {
		IF = {
			limit = { FROM = { original_tag = ETH } }
			FROM = { has_completed_focus = ETH_invite_foreign_industrialists }
		}
	}

	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}

		IF = {
			limit = { 
				OR = { 
					FROM = { original_tag = BUL }
					FROM = { original_tag = ETH } 
				} 
			}
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_henschel_mio_flag
				}
			}
			
		}
		IF = {
			limit = { FROM = { original_tag = BUL } } 
			FROM = { 
				OR = {
					is_subject = no
					is_subject_of = GER
				}
				#is_in_faction_with = GER
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
	}
}

GER_man_organization = {
	include = generic_medium_tank_organization
	icon = GFX_idea_GER_MAN
	
 	allowed = {	
 		always = no
 	}
	
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}
	}
}

#Benz 
GER_daimler_benz_organization = {
	include = generic_tank_organization
	icon = GFX_idea_generic_tank_manufacturer_2 # TODO change
	
 	allowed = {	
 		always = no
 	}

	available = {
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}
		IF = {
			limit = {
				FROM = {
					original_tag = BRA
				}
			}
			FROM = {
				has_completed_focus = BRA_german_tanks
			}
		}
	}

	tree_header_text = {
		text = mio_header_tank_construction
		x = 3
	}

	tree_header_text = {
		text = mio_header_equipment_and_specialization
		x = 7
	}

	tree_header_text = {
		text = mio_header_armor
		x = 9
	}
	initial_trait = {
		organization_modifier = {
			military_industrial_organization_research_bonus = 0.05
		}
	}

	add_trait = {  
		token = GER_mio_trait_hotrolled_armor
		name = GER_mio_trait_hotrolled_armor
		icon = GFX_generic_mio_department_icon_tank_general_technology
		special_trait_background = yes

		limit_to_equipment_type = { light_tank_chassis medium_tank_chassis }
		production_bonus = {
			production_efficiency_cap_factor = 0.05
			production_efficiency_gain_factor = 0.05
		}

		position = { x=9 y=0 }  
		ai_will_do = {
			base = 2
			modifier = {
				factor = 1.5
				date > 1937.1.1
			}
		}
	}

	add_trait = {
		token = GER_mio_trait_multilayer_armour
		name = GER_mio_trait_multilayer_armour
		icon = GFX_generic_mio_trait_icon_armor_value
		special_trait_background = yes

		any_parent = { GER_mio_trait_hotrolled_armor }
		limit_to_equipment_type = { light_tank_chassis medium_tank_chassis }
		equipment_bonus = {
			armor_value = 0.1
		} 

		position = { x=9 y=2 }  
		ai_will_do = {
			base = 2
			modifier = {
				factor = 1.5
				date > 1937.1.1
			}
		}
	}
}

#####################

 ## #  # ### ###   ## 
#   #  #  #  #  # #   
 #  ####  #  ###   #  
  # #  #  #  #      # 
##  #  # ### #    ##  
 
#####################

GER_germaniawerft_organization = {
	include = generic_battle_line_ship_organization
	icon = GFX_idea_germaniawerft
	
 	allowed = {	
 		always = no
 	}
}

GER_blohm_und_voss_organization = {
	include = generic_raider_ship_organization
	icon = GFX_idea_blohm_und_voss
	
 	allowed = {	
 		always = no
 	}
}

###########################

###  #    ##  #  # ###  ## 
#  # #   #  # ## # #   #   
###  #   #### # ## ##   #  
#    #   #  # #  # #     # 
#    ### #  # #  # ### ##  

###########################

GER_messerschmitt_organization = {
	include = generic_light_aircraft_organization
	icon = GFX_idea_messerschmitt
	
 	allowed = {	
 		always = no
 	}

	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}
		
		if = {
			limit = {
				FROM = { original_tag = NOR }
			}
			FROM = { has_completed_focus = NOR_invite_german_engineers }
		}
	}

	add_trait = {
		token = GER_mio_trait_maintenance_first_design
		name = GER_mio_trait_maintenance_first_design

		icon = GFX_generic_mio_department_icon_plane_fighter_line_efficiency
		special_trait_background = yes
		
		position = { x=-2 y=1 }
		relative_position_id = generic_mio_trait_expanded_production_facilities

		all_parents = { generic_mio_trait_expanded_production_facilities }

		equipment_bonus = {
			reliability = 0.05
		}

		production_bonus = {
			production_efficiency_gain_factor = 0.05
		}
	}

	add_trait = {
		token = GER_mio_trait_fuselage_based_weapons
		name = GER_mio_trait_fuselage_based_weapons

		icon = GFX_generic_mio_trait_icon_anti_air_attack
		special_trait_background = yes
		
		position = { x=1 y=1 }
		relative_position_id = generic_mio_trait_gun_pods

		any_parent = { generic_mio_trait_heavier_airframe generic_mio_trait_maximum_wing_loads generic_mio_trait_gun_pods }

		equipment_bonus = {
			air_attack = 0.05
			air_agility = 0.05
		} 
	}
}

GER_junkers_organization = {
	include = generic_cas_aircraft_organization
	icon = GFX_idea_junkers
	
 	allowed = {	
 		always = no
 	}
	
	visible = {
		IF = {
			limit = { FROM = { original_tag = ETH } }
			FROM = { has_completed_focus = ETH_invite_foreign_industrialists }
		}
	}

	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}

		IF = {
			limit = {
				FROM = { NOT  = { original_tag = GER } }
			}
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_GER_junkers_organization_flag
				}
			}
		}
	}

	add_trait = {
		token = GER_mio_trait_psychological_warfare
		name = GER_mio_trait_psychological_warfare

		icon = GFX_generic_mio_trait_icon_fuel_consumption
		special_trait_background = yes
		
		position = { x=2 y=0 }
		relative_position_id = generic_mio_trait_reinforced_wings

		equipment_bonus = {
			fuel_consumption = -0.05
		} 
	}
}

GER_focke_wulf_organization = {
	include = generic_multi_role_aircraft_organization
	icon = GFX_idea_focke_wulf
	
 	allowed = {	
 		always = no
 	}
}

GER_heinkel_organization = {
	include = generic_medium_aircraft_organization
	icon = GFX_idea_heinkel
	
 	allowed = {	
 		always = no
 	}
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}

		IF = {
			limit = {
				FROM = { original_tag = BUL }
			}
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_heinkel_mio_flag
				}
			}
			FROM = { 
				OR = {
					is_subject = no
					is_subject_of = GER
				}
				#is_in_faction_with = GER
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
		ELSE_IF = {
			limit = {
				FROM = { original_tag = NOR }
			}
			FROM = { has_completed_focus = NOR_invite_german_engineers }
		}
	}
}

GER_dornier_organization = {
	include = generic_naval_aircraft_organization
	icon = GFX_idea_dornier
	
 	allowed = {	
 		always = no
 	}
}


################################### 

#   #  ##  ### ### ###  ### ### #   
## ## #  #  #  #   #  #  #  #   #   
# # # ####  #  ##  ###   #  ##  #   
#   # #  #  #  #   #  #  #  #   #   
#   # #  #  #  ### #  # ### ### ### 


###################################

GER_rheinmetall_organization = {
	include = generic_artillery_organization
	icon = GFX_idea_rheinmetall
 	allowed = {	
 		always = no
 	}
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}
	}
}

GER_mauser_organization = {
	include = generic_infantry_equipment_organization
	icon = GFX_idea_mauser
	
 	allowed = {	
 		always = no
 	}
	
	visible = {
		IF = {
			limit = { FROM = { original_tag = ETH } }
			FROM = { has_completed_focus = ETH_invite_foreign_industrialists }
		}
	}
	
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}

		IF = {
			limit = {
				FROM = { NOT  = { original_tag = GER } }
			}
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_GER_mauser_organization_flag
				}
			}
		}
	}
}

GER_opel_organization = {
	include = generic_motorized_mechanized_organization
	icon = GFX_idea_opel
 	allowed = {	
 		always = no
 	}
	
	available = {
		# When in a Foreign MIO, countries need to be at peace with original country
		IF = {
			limit = {
				FROM = { NOT = { original_tag = GER } }
			}
			FROM = { NOT = { has_war_with = GER } }
		}

		IF = {
			limit = { FROM = { original_tag = BUL } }
			custom_trigger_tooltip = {
				tooltip = has_invited_mio_tt
				FROM = {
					has_country_flag = has_invited_opel_mio_flag
				}
			}
			FROM = { 
				OR = {
					is_subject = no
					is_subject_of = GER
				}
				#is_in_faction_with = GER
				NOT = { has_completed_focus = BUL_nationalization }
			}
		}
		IF = {
			limit = { FROM = { original_tag = ROM } }
			FROM = { has_country_flag = GER_mot_chosen }
		}	
	}
}