disableSerialization;
uiNamespace setVariable ["displayVendor", findDisplay 100];
uiNamespace setVariable ["ctrlTitle", (uiNamespace getVariable "displayVendor") displayCtrl 101];
uiNamespace setVariable ["ctrlListBox", (uiNamespace getVariable "displayVendor") displayCtrl 2000];
uiNamespace setVariable ["ctrlPrice", (uiNamespace getVariable "displayVendor") displayCtrl 2001];
uiNamespace setVariable ["ctrlAtit", (uiNamespace getVariable "displayVendor") displayCtrl 2201];
uiNamespace setVariable ["ctrlMtit", (uiNamespace getVariable "displayVendor") displayCtrl 2202];
uiNamespace setVariable ["ctrlCount", (uiNamespace getVariable "displayVendor") displayCtrl 2002];
uiNamespace setVariable ["ctrlMoney", (uiNamespace getVariable "displayVendor" )displayCtrl 2003];
uiNamespace setVariable ["ctrlPreview", (uiNamespace getVariable "displayVendor") displayCtrl 2004];
uiNamespace setVariable ["ctrlPreviewMag", (uiNamespace getVariable "displayVendor") displayCtrl 2005];
uiNamespace setVariable ["ctrlDescTtl", (uiNamespace getVariable "displayVendor") displayCtrl 2010];
uiNamespace setVariable ["ctrlDesc", (uiNamespace getVariable "displayVendor") displayCtrl 2011];
uiNamespace setVariable ["ctrlWEaponsBck", (uiNamespace getVariable "displayVendor") displayCtrl 150];
uiNamespace setVariable ["ctrlMagazinesBck", (uiNamespace getVariable "displayVendor") displayCtrl 151];
uiNamespace setVariable ["ctrlWeapons", (uiNamespace getVariable "displayVendor") displayCtrl 155];
uiNamespace setVariable ["ctrlMagazines", (uiNamespace getVariable "displayVendor") displayCtrl 156];
uiNamespace setVariable ["ctrlBut1", (uiNamespace getVariable "displayVendor") displayCtrl 6056];
uiNamespace setVariable ["ctrlVis", (uiNamespace getVariable "displayVendor") displayCtrl 6057];
uiNamespace setVariable ["ctrlAirvis", (uiNamespace getVariable "displayVendor") displayCtrl 6058];
uiNamespace setVariable ["ctrlTervis", (uiNamespace getVariable "displayVendor") displayCtrl 6059];
uiNamespace setVariable ["ctrlVTitle", (uiNamespace getVariable "displayVendor") displayCtrl 2203];
uiNamespace setVariable ["ctrlVactive", (uiNamespace getVariable "displayVendor") displayCtrl 2205];
uiNamespace setVariable ["ctrlAVTitle", (uiNamespace getVariable "displayVendor") displayCtrl 2204];
uiNamespace setVariable ["ctrlAVactive", (uiNamespace getVariable "displayVendor") displayCtrl 2206];
uiNamespace setVariable ["ctrlTTitle", (uiNamespace getVariable "displayVendor") displayCtrl 2207];
uiNamespace setVariable ["ctrlTactive", (uiNamespace getVariable "displayVendor") displayCtrl 2208];
uiNamespace setVariable ["ctrlName", (uiNamespace getVariable "displayVendor") displayCtrl 500];
uiNamespace setVariable ["ctrlPicture", (uiNamespace getVariable "displayVendor") displayCtrl 501];

sliderSetRange [6057, 100, 10000];
sliderSetPosition [6057, EGG_EVO_vdist];
sliderSetRange [6058, 100, 10000];
sliderSetPosition [6058, EGG_EVO_avdist];
//
sliderSetRange [6059, 1, 5];
sliderSetPosition [6059, EGG_EVO_grid];

ctrlShow [6057,false];
ctrlShow [6058,false];
ctrlShow [6067,false];
ctrlShow [6068,false];
//
ctrlShow [6059,false];

ctrlShow [2203,false];
ctrlShow [2204,false];
ctrlShow [2205,false];
ctrlShow [2206,false];
ctrlShow [2207,false];
ctrlShow [2208,false];

ctrlSetText [2203,""];
ctrlSetText [2204,""];
ctrlSetText [2205,""];
ctrlSetText [2206,""];
//
ctrlSetText [2207,""];
ctrlSetText [2208,""];

bplace = false;

bmark = createMarkerLocal ["btarg", [0,0,0]];
bmark setMarkerShapeLocal "ELLIPSE";
bmark setMarkerTypeLocal "Destroy";
bmark setMarkerColorLocal "ColorGreen";
bmark setMarkerSizeLocal [0.5, 0.5];

//(FindDisplay 46) DisplaySetEventHandler ["keydown","if ((_this select 1) In actionKeys ""TeamSwitch"") then {closeDialog 0}"];

onMapSingleClick {"btarg" setMarkerPos _pos;bplace=true};
mrole = "";
mrank = 0;
mcost = 0;
msize = 0;
mtime = 0;
mord = 0;

// Lists
EGG_EVO_ListUpdate = 
{
	SupList = [];
	RecList = [];
	AssList = [];
	GrpList = [];

	_rank = 0;
	_newstring = "";
	if (score player >= EGG_EVO_rank1) then {_rank = 1};
	if (score player >= EGG_EVO_rank2) then {_rank = 2};
	if (score player >= EGG_EVO_rank3) then {_rank = 3};
	if (score player >= EGG_EVO_rank4) then {_rank = 4};
	if (score player >= EGG_EVO_rank5) then {_rank = 5};
	if (score player >= EGG_EVO_rank6) then {_rank = 6};

	_assemblelist =  
	{
		_list = _this select 0;
		_newstring = "";
		_count = _rank;
		_i = 0;
		while {_i <= _count} do 
		{	
			_units = (_list select _i);
			_arraycount = count _units;
			if(_arraycount > 0) then
			{
				while {_arraycount > 0} do 
				{
					_unit = _units select _arraycount-1;
					_uname = getText (configFile >> "CfgVehicles" >> _unit >> "DisplayName");
					_picture = getText (configFile >> "CfgVehicles" >> _unit >> "portrait");
					_guns = format["%1 %2",(getArray (configFile >> "CfgVehicles" >> _unit >> "weapons")) select 0,(getArray (configFile >> "CfgVehicles" >> _unit >> "weapons")) select 1];
					_guns = [_unit] call _GetGuns;
					_picture = "\uns_Army\icon\port_soldier1.paa";
					RecList = RecList +[[_uname, _unit, _picture, _guns]];
					_arraycount = _arraycount-1;
				};
			};
			_i = _i+1;
		};
	};

	_txtmessage = "";
	_GetGuns =
	{
		_type = _this select 0;;
		_name = "";
		_array = getArray (configFile >> "CfgVehicles" >> _type >> "weapons");
		_count = count _array;
		_txtmessage = format ["%1:",localize "STR_M04t100"];
		_i=0;
		while {_i < _count} do 
		{
			_name = getText (configFile >> "CfgWeapons" >> (_array select _i) >> "displayName");
			if(_name != "throw" and _name != "put") then 
			{
				if(_i == _count-3) then 
				{
					_txtmessage = format["%1 and %2.",_txtmessage,_name];
				};
				if(_i == 0) then 
				{
					_txtmessage = format["%1 %2",_txtmessage,_name];
				};
				if(_i != _count-3 and _i != 0) then
				{
					_txtmessage = format["%1 %2",_txtmessage,_name];
				};
			};
			_i = _i+1;
		};
		_txtmessage
	};

	//RECRUIT SETUP
	_recpage = Mpage select 0;
	_suppage = Mpage select 1;
	_asspage = Mpage select 2;
	_grppage = Mpage select 3;
	_optpage = Mpage select 4;


	ctrlShow [6057,false];
	ctrlShow [6058,false];
	ctrlShow [6059,false];
//	TerList = [[localize "STR_M04t129",50],[localize "STR_M04t130",25],[localize "STR_M04t131",12.5]];
	TerList = [[localize "str_terrain_50",50,0],[localize "str_terrain_25",25,1],[localize "str_terrain_12_5",12.5,2],[localize "str_terrain_6_25",6.25,3],[localize "str_terrain_3_125",3.125,4]];
	_sco = score player;

//RECRUIT

	if (helpersparam == 1) then 
	{
		RecList = [[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 0) >> "DisplayName"), (EGG_EVO_west1 select 0),"img\team\i_tripod_ca.paa", [(EGG_EVO_west1 select 0)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 1) >> "DisplayName"), (EGG_EVO_west1 select 1), "img\team\icon_med_ca.paa",[(EGG_EVO_west1 select 1)] call _GetGuns]];
	};

/* developing parameter for artillery cost based on:
EGG_EVO_Artycost = paramsArray select 14;
values[] = {1,2,3,4,5,6,7,8,9,10,1000};
use as:
SupList = SupList +[[localize "STR_M04t106",localize "STR_M04t107",20,(EGG_EVO_Artycost*1),10,"img\support\sup01.paa",2]];
*/

//support
//ammo
	SupList = SupList +[["Ammo crate","Cost: 5 All the ammo you need",10,5,10,"img\support\para.paa",1]];
//smoke
	SupList = SupList +[["Marker smoke (Green)","Cost: 0 Mark a location with green smoke",10,0,3,"img\support\mark.paa",9]];
//bike
	SupList = SupList +[["Offroad","Cost: 0 Emergency transport for four",20,0,10,"img\support\car.paa",19]];
//boat
	SupList = SupList +[["Boat","Cost: 0 Ideal for crossing water",20,0,10,"img\support\ship.paa",10]];
//lumes
	SupList = SupList +[["Illumination Barrage","Cost: 3 Ideal for night defence",20,3,20,"img\support\mark.paa",20]];
//precision strike
	SupList = SupList +[["Air strike",format ["Cost: %1 Call in a precision air strike",(EGG_EVO_Artycost*2)],20,(EGG_EVO_Artycost*2),10,"img\support\strk.paa",2]];
//mortar barrage
	SupList = SupList +[["Mortar barrage",format ["Cost: %1 Just perfect for Charlie in the Treeline!",(EGG_EVO_Artycost*2)],20,(EGG_EVO_Artycost*2),10,"img\support\strk.paa",23]];
//fortification
		SupList = SupList +[["Fortification","Cost: 10 Ideal for securing an area and providing cover",20,10,10,"img\support\sup01.paa",14]];

//missions
	AssList = [];
	AssList = AssList +[["Water Patrol","The enemy have been spotted in RHIBs. Follow the patrol route. You must eliminate any enemy units you find.","img\support\ship.paa",10,3]];//wpat
	AssList = AssList +[["Ambush","Ambush","img\support\vecs.paa",10,1]];//ambush
	AssList = AssList +[["Destroy armour","Destroy armour","img\support\sup01.paa",10,4]];//mdst armr
	AssList = AssList +[["Search and Rescue","basic rank search and rescue (doctor) mission","img\support\jail.paa",10,6]];//csarb
	AssList = AssList +[["Rendition","A few moments ago we received satellite intel that a key member of the enemy high command is visiting a remote station on the island. Your mission is to go to the location search for the officer and eliminate any resistance in the area.","img\support\jail.paa",20,10]];
	AssList = AssList +[["Extermination","We have received reports from an undercover agent on the location of a gathering of the People's Temple cult. They have a fertiliser bomb and may plan to use it. Go to the location and exterminate any civilians you find there.","img\support\nuke.paa",10,11]];
	AssList = AssList +[["Ambush troop convoy","Crossroad reports satellite recon has identified a heavily defended enemy infantry column moving cross-country.  Neutralise it.","img\support\vecs.paa",10,12]];
	AssList = AssList +[["Assassination","Crossroad reports a senior enemy general is approaching his HQ.  Position your sniper team on the roof of the nearby building and take him out.","img\support\mark.paa",10,13]];
	AssList = AssList +[["Liberate Agent","Crossroad reports a major blow to security.  One of the CDF's top agents has been captured.  Locate him, eliminate ALL hostiles, extract him to HMS GITS.","img\support\jail.paa",20,14]];

	if(_sco >= EGG_EVO_rank1) then 
	{
		mrank = EGG_EVO_rank1;

//recruit
	if (helpersparam == 1) then 
	{
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 2) >> "DisplayName"), (EGG_EVO_west1 select 2), "img\team\i_eng_ca.paa", [(EGG_EVO_west1 select 2)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 3) >> "DisplayName"), (EGG_EVO_west1 select 3), "img\team\i_rto_ca.paa",[(EGG_EVO_west1 select 3)] call _GetGuns]];
	};//pilot
//support
	SupList = SupList +[["Artillery barrage","Cost: 3 Ideal for masking your movement",20,3,5,"img\support\mark.paa",11]];
	SupList = SupList +[["Quadbike","Cost: 5 Emergency transport for two",20,5,10,"img\support\car.paa",8]];
//place mines
	SupList = SupList +[["Mines","Ideal for protecting a road",50,(EGG_EVO_Artycost*2),5,"img\support\mines.paa",22]];

//place traps
//		if (gitsnades == 2) then {SupList = SupList +[["Set traps","Ideal for protecting an area against infantry",50,(EGG_EVO_Artycost*2),5,"img\support\mines.paa",24]]};
		SupList = SupList +[["AP minefield","Ideal for protecting an area against infantry",50,(EGG_EVO_Artycost*2),5,"img\support\mines.paa",24]];
//missions
		AssList = AssList +[["Land patrol",localize "STR_M04t10_1","img\support\car.paa",20,2]];//land patrol
	};
	if(_sco >= EGG_EVO_rank2) then 
	{
		mrank = EGG_EVO_rank2;
//recruit
		if (helpersparam == 1) then 
		{
			RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 4) >> "DisplayName"), (EGG_EVO_west1 select 4), "img\team\i_hmg_ca.paa",[(EGG_EVO_west1 select 4)] call _GetGuns]];
			RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 5) >> "DisplayName"), (EGG_EVO_west1 select 5), "img\team\i_AT_ca.paa", [(EGG_EVO_west1 select 5)] call _GetGuns]];
		};

//support
		SupList = SupList +[["Static MG","Cost: 5 Ideal for defending an area against enemy troops",20,5,10,"img\support\sup01.paa",12]];
//small arty
		SupList = SupList +[["Small artillery",format [localize "STR_M04t109", (EGG_EVO_Artycost*4)],50,(EGG_EVO_Artycost*4),20,"img\support\strk.paa",3]];

//missions
		AssList = [];
		AssList = AssList +[["Water patrol",localize "STR_M04t7_1","img\support\ship.paa",10,3]];//wpat
		AssList = AssList +[["Land patrol",localize "STR_M04t10_1","img\support\car.paa",20,2]];//land patrol
		AssList = AssList +[["Ambush",localize "STR_M04t17_1","img\support\vecs.paa",20,1]];//ambush
		AssList = AssList +[["Destroy Armour","Destry Armour","img\support\sup01.paa",20,4]];//armour
		AssList = AssList +[["Search and Rescue","Search and Rescue","img\support\jail.paa",20,5]];//csar
		AssList = AssList +[["Defend","Defend","img\support\defend.paa",20,7]];
		AssList = AssList +[["Rendition","A few moments ago we received satellite intel that a key member of the enemy high command is visiting a remote station on the island. Your mission is to go to the location search for the officer and eliminate any resistance in the area.","img\support\jail.paa",30,10]];
		AssList = AssList +[["Extermination","We have received reports from an undercover agent on the location of a Red Brigade security arm of the People's Temple cult. They have a chemical weapon and may plan to use it. Go to the location and exterminate any civilians you find there.","img\support\nuke.paa",20,11]];
		AssList = AssList +[["Ambush troop convoy","Crossroad reports satellite recon has identified a heavily defended enemy infantry column moving cross-country.  Neutralise it.","img\support\vecs.paa",20,12]];
		AssList = AssList +[["Assassination","Crossroad reports a senior enemy general is approaching his HQ.  Position your sniper team on the roof of the nearby building and take him out.","img\support\mark.paa",20,13]];
		AssList = AssList +[["Liberate Agent","Crossroad reports a major blow to security.  One of the CDF's top agents has been captured.  Locate him, eliminate ALL hostiles, extract him to HMS GITS.","img\support\jail.paa",20,14]];
	};
	if(_sco >= EGG_EVO_rank3) then 
	{
		mrank = EGG_EVO_rank3;
//recruit
		if (helpersparam == 1) then 
		{
			RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 6) >> "DisplayName"), (EGG_EVO_west1 select 6), "img\team\i_pilot_ca.paa",[(EGG_EVO_west1 select 6)] call _GetGuns]];//AA
			RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 7) >> "DisplayName"), (EGG_EVO_west1 select 7), "img\team\i_hmg_ca.paa",[(EGG_EVO_west1 select 7)] call _GetGuns]];//sniper
		};
//support
		SupList = SupList +[["Static GMG","Cost: 15 Ideal for bombarding enemy troops",20,15,10,"img\support\sup01.paa",13]];
//cluster bomb
		SupList = SupList +[["Cluster Bomb",format ["Cost: %1 Cluster bomb the area",(EGG_EVO_Artycost*6)],50,(EGG_EVO_Artycost*6),20,"img\support\strk.paa",4]];
	};
	if(_sco >= EGG_EVO_rank4) then 
	{
		mrank = EGG_EVO_rank4;
//recruit
		if (helpersparam == 1) then 
		{
			RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 8) >> "DisplayName"), (EGG_EVO_west1 select 8), "img\team\i_mrk_ca.paa", [(EGG_EVO_west1 select 8)] call _GetGuns]];//expl
			RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 9) >> "DisplayName"), (EGG_EVO_west1 select 9), "img\team\i_gren_ca.paa",[(EGG_EVO_west1 select 9)] call _GetGuns]];//gl
		};
//support	
//		SupList = SupList +[[localize "str_dn_rhib2","Cost: 5 Ideal for assaulting positions from the sea",20,5,10,"img\support\ship.paa",15]];
		SupList = SupList +[["Assault Boat","Cost: 5 Ideal for assaulting positions from the sea",20,5,10,"img\support\ship.paa",15]];
		SupList = SupList +[["Static AA","Cost: 20 Ideal for Air Defences",20,20,10,"img\support\sup01.paa",16]];
//large area fire
//		SupList = SupList +[["Large Area Fire","Cost: ? Ideal for suppressing a city",200,(EGG_EVO_Artycost*5),30,"img\support\strk.paa",21]];
		SupList = SupList +[["Large Area Fire",format ["Cost: %1 Ideal for suppressing a city",(EGG_EVO_Artycost*5)],200,(EGG_EVO_Artycost*5),30,"img\support\strk.paa",21]];
//large arty
		SupList = SupList +[["Large Artillery",format ["Cost: %1 Large artillery strike",(EGG_EVO_Artycost*8)],100,(EGG_EVO_Artycost*8),30,"img\support\strk.paa",5]];
	};
	if(_sco >= EGG_EVO_rank5) then 
	{
		mrank = EGG_EVO_rank5;
//recruit
		if (helpersparam == 1) then 
		{
			RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 10) >> "DisplayName"), (EGG_EVO_west1 select 10), "img\team\i_mort_ca.paa",[(EGG_EVO_west1 select 10)] call _GetGuns]];//sgt
		};
//support
		SupList = SupList +[["Static AT","Cost: 25 Ideal for suppressing enemy armour and troops",20,25,10,"img\support\sup01.paa",17]];
//chem strike
		SupList = SupList +[["MOAB",format ["Cost: %1 Chemical strike",(EGG_EVO_Artycost*20)],150,(EGG_EVO_Artycost*20),40,"img\support\strk.paa",6]];

//missions
		AssList = [];
		AssList = AssList +[["Water Patrol","STR_M04t7_1","img\support\ship.paa",10,3]];
		AssList = AssList +[["Land Patrol","STR_M04t10_1","img\support\car.paa",20,2]];
		AssList = AssList +[["STR_M04t16_0","STR_M04t17_1","img\support\vecs.paa",20,1]];
		AssList = AssList +[["STR_M04t20","STR_M04t21_0","img\support\sup01.paa",20,4]];
		AssList = AssList +[["Search and Rescue","Jail","img\support\jail.paa",20,5]];
		AssList = AssList +[["Air patrol","STR_M04t13_1","img\support\air.paa",20,9]];//apat
		AssList = AssList +[["Defend","STR_M04t38_0","img\support\defend.paa",40,7]];
		AssList = AssList +[["Rendition","A few moments ago we received satellite intel that a key member of the enemy high command is visiting a remote station on the island. Your mission is to go to the location search for the officer and eliminate any resistance in the area.","img\support\jail.paa",40,10]];
		AssList = AssList +[["Extermination","We have received reports from an undercover agent on the location of a major Peoples Temple Agricultural Project. They have a nuclear weapon and plan to use it. Go to the location and exterminate all civilians you find there.","img\support\nuke.paa",40,11]];
		AssList = AssList +[["Ambush troop convoy","Crossroad reports satellite recon has identified a heavily defended enemy infantry column moving cross-country.  Neutralise it.","img\support\vecs.paa",30,12]];
		AssList = AssList +[["Assassination","Crossroad reports a senior enemy general is approaching his HQ.  Position your sniper team on the roof of the nearby building and take him out.","img\support\mark.paa",30,13]];
		AssList = AssList +[["Liberate Agent","Crossroad reports a major blow to security.  One of the CDF's top agents has been captured.  Locate him, eliminate ALL hostiles, extract him to HMS GITS.","img\support\jail.paa",20,14]];
		AssList = AssList +[["Air Assault","Crossroad reports a major enemy air assault is imminent - secure the air space and eliminate ALL hostiles.  Good hunting!","img\support\air.paa",40,15]];
	};
	if(_sco >= EGG_EVO_rank6) then 
	{
		mrank = EGG_EVO_rank6;
//recruit
		if (helpersparam == 1) then 
		{
			RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 11) >> "DisplayName"), (EGG_EVO_west1 select 11), "img\team\i_slight_ca.paa",[(EGG_EVO_west1 select 11)] call _GetGuns]];//officer - could be diver
		};
//support
//rank 6
		SupList = SupList +[["Halo Evac","Cost: 5 Get me out of this hell-hole",20,5,5,"img\support\para.paa",18]];
//nuke
		SupList = SupList +[["Nuke !",format ["Cost: %1 Nuke ...",(EGG_EVO_Artycost*40)],200,(EGG_EVO_Artycost*40),60,"img\support\nuke.paa",7]];
	};

	if (helpersparam == 0) then 
	{
		RecList = [];
	};

	if (helpersparam == 2) then 
	{
		RecList = [];
		RecList = [[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 0) >> "DisplayName"), (EGG_EVO_west1 select 0), "img\team\i_tripod_ca.paa", [(EGG_EVO_west1 select 0)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 1) >> "DisplayName"), (EGG_EVO_west1 select 1), "img\team\icon_med_ca.paa",[(EGG_EVO_west1 select 1)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 2) >> "DisplayName"), (EGG_EVO_west1 select 2), "img\team\i_eng_ca.paa", [(EGG_EVO_west1 select 2)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 3) >> "DisplayName"), (EGG_EVO_west1 select 3), "img\team\i_rto_ca.paa",[(EGG_EVO_west1 select 3)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 4) >> "DisplayName"), (EGG_EVO_west1 select 4), "img\team\i_hmg_ca.paa",[(EGG_EVO_west1 select 4)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 5) >> "DisplayName"), (EGG_EVO_west1 select 5), "img\team\i_AT_ca.paa", [(EGG_EVO_west1 select 5)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 6) >> "DisplayName"), (EGG_EVO_west1 select 6), "img\team\i_pilot_ca.paa",[(EGG_EVO_west1 select 6)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 7) >> "DisplayName"), (EGG_EVO_west1 select 7), "img\team\i_hmg_ca.paa",[(EGG_EVO_west1 select 7)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 8) >> "DisplayName"), (EGG_EVO_west1 select 8), "img\team\i_mrk_ca.paa", [(EGG_EVO_west1 select 8)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 9) >> "DisplayName"), (EGG_EVO_west1 select 9), "img\team\i_gren_ca.paa",[(EGG_EVO_west1 select 9)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 10) >> "DisplayName"), (EGG_EVO_west1 select 10), "img\team\i_mort_ca.paa",[(EGG_EVO_west1 select 10)] call _GetGuns]];
		RecList = RecList +[[getText (configFile >> "CfgVehicles" >> (EGG_EVO_west1 select 11) >> "DisplayName"), (EGG_EVO_west1 select 11), "img\team\i_slight_ca.paa",[(EGG_EVO_west1 select 11)] call _GetGuns]];
	};

	if (_recpage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

		_i = 0;
		lbClear 2000;
		while {_i < count RecList} do 
		{
			_name = (RecList select _i) select 0;
			_pic = (RecList select _i) select 2;
			_index = lbAdd[2000, _name];
			_index = lbSetPicture [2000, _i, _pic];
			lbSetPictureColor [2000, _i, [1,1,1,1]];
			lbSetPictureColorselected [2000, _i, [1,1,1,1]];
			_i = _i + 1;
		};
	};

	if (_suppage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

		_i = 0;
		lbClear 2000;
		while {_i < count SupList} do 
		{
			_name = (SupList select _i) select 0;
			_pic = (SupList select _i) select 5;

			_index = lbAdd [2000, _name];
			_index = lbSetPicture[2000, _i, _pic];
			lbSetPictureColor [2000, _i, [1,1,1,1]];
			lbSetPictureColorselected [2000, _i, [1,1,1,1]];
			_i = _i + 1;
		};
	};

	if (_asspage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

		_i = 0;
			lbClear 2000;
		while {_i < count AssList} do 
		{
			_name = (AssList select _i) select 0;
			_pic = (AssList select _i) select 2;

		_index = lbAdd [2000, _name];
			_index = lbSetPicture[2000, _i, _pic];
			lbSetPictureColor [2000, _i, [1,1,1,1]];
			lbSetPictureColorselected [2000, _i, [1,1,1,1]];
			_i = _i + 1;
		};
	};

//build list of players to join

	if (_grppage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

		_i = 0;
		_Plist = [objNull];
		{_Plist = _Plist + [_x]} forEach playableUnits;
		lbClear 2000;
		
		while {_i < count _Plist} do 
		{
			_unit = (_Plist select _i);
			
			_name = name _unit;
			_grpunit = group _unit;
			_rank = rank _unit;
			_pic = "";
			if(isNull _unit) then {_name = "<New>";_rank = ""};
			if(isNull _grpunit) then {_grpunit = ""};
			switch (_rank) do
			{
				case "PRIVATE":
				{
					_pic = "img\ranks\pvt.paa";
				};
				case "CORPORAL":
				{
					_pic = "img\ranks\corp.paa";
				};
				case "SERGEANT":
				{
					_pic = "img\ranks\sgt.paa";
				};
				case "LIEUTENANT":
				{
					_pic = "img\ranks\ltn.paa";
				};
				case "CAPTAIN":
				{
					_pic = "img\ranks\cpt.paa";
				};
				case "MAJOR":
				{
					_pic = "img\ranks\mjr.paa";
				};
				case "COLONEL":
				{
					_pic = "img\ranks\col.paa";
				};
			};
			GrpList = GrpList+[_unit];
			_index = lbAdd [2000, format["%1 %2",_name, _grpunit]];
			_index = lbSetPicture[2000, _i, _pic];
			lbSetPictureColor [2000, _i, [1,1,1,1]];
			lbSetPictureColorselected [2000, _i, [1,1,1,1]];
			_i = _i + 1;
		};
	};

	if (_optpage) then 
	{
		_i = 0;
		lbClear 2000;
		while {_i < count TerList} do 
		{
			_name = (TerList select _i) select 0;
			_index = lbAdd [2000, _name];
			_i = _i + 1;
		};
	};
	_index = lbSetCurSel [2000, 0];
};	
//Endlsts

EGG_EVO_ActButton = 
{
	   _index = lbCurSel 2000;
	  _recpage = Mpage select 0;
	  _suppage = Mpage select 1;
	  _asspage = Mpage select 2;
	  _grppage = Mpage select 3;
	  _optpage = Mpage select 4;

	if (_recpage) then 
	{
		if (helpersparam == 0) exitwith {ctrlSetText [2011,"AI Recruitment disabled"]};

		_item = ((RecList select _index) select 1);
		_grp = group player;
		_count = (count units _grp);
		_ainum = 0;
		_ap = player;
		_i = 0;

		while {_i < _count} do 
		{
			_ap = (units _grp select _i);
			if (not (isPlayer _ap)) then 
			{
				_ainum = _ainum +1;
			};
			_i = _i + 1;
		};

		if (score player < EGG_EVO_rank1 and helpersparam != 2 and _ainum >= 1) exitwith {ctrlSetText [2011,localize "STR_M04t99"]};
		if (score player < EGG_EVO_rank2 and helpersparam != 2 and _ainum >= 2) exitwith {ctrlSetText [2011,localize "STR_M04t99"]};
		if (score player < EGG_EVO_rank3 and helpersparam != 2 and _ainum >= 3) exitwith {ctrlSetText [2011,localize "STR_M04t99"]};
		if (score player < EGG_EVO_rank4 and helpersparam != 2 and _ainum >= 4) exitwith {ctrlSetText [2011,localize "STR_M04t99"]};
		if (score player < EGG_EVO_rank5 and helpersparam != 2 and _ainum >= 5) exitwith {ctrlSetText [2011,localize "STR_M04t99"]};
		if (score player < EGG_EVO_rank6 and helpersparam != 2 and _ainum >= 6) exitwith {ctrlSetText [2011,localize "STR_M04t99"]};
		if (score player >= EGG_EVO_rank6 and helpersparam != 2 and _ainum >= 7) exitwith {ctrlSetText [2011,localize "STR_M04t99"]};
		if (helpersparam == 2 and _ainum >= 8) exitwith {ctrlSetText [2011,localize "STR_M04t99"]};
		_rec = [_item] execVM "scripts\support\recruit.sqf";
	};   
	
	if (_suppage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

	      mrole = (SupList select _index) select 0;
	      msize = (SupList select _index) select 2;
	      mcost = (SupList select _index) select 3;
	      mtime = (SupList select _index) select 4;
	      mord = (SupList select _index) select 6;

	if ("ItemRadio" in assignedItems player) then
	{
		if (not EGG_EVO_fmission) then
		{
			 if (bplace) then 
			 {

				if (((score player)-mrank) >= mcost) then 
				{	
					if(airportin distance (getmarkerpos "btarg") < 400) then 
					{
						ctrlSetText [2011,"You can not call support in the base"];//you cannot call support in the base
					}
					else
					{
						_rec = [mrole,msize,mtime,mord] execVM "scripts\support\csupport.sqf";
						ctrlSetText [2003,str (score player)];
						EGG_EVO_lunit = player;
						EGG_EVO_lrew  = -mcost;
						publicVariable "EGG_EVO_lrew";
						publicVariable "EGG_EVO_lunit";
					};
				}
				else
				{
					ctrlSetText [2011,format["You do not have the required spare points \nRequired: %1 \nCurrent: %2",mcost, ((score player)-mrank)]];//You do not have the required spare points \nRequired: %1 \nCurrent: %2.
				};
			 }
			 else {ctrlSetText [2011,"Click a point on the map first."]};//Click a point on the map first.
		}else{
			ctrlSetText [2011,"Only one payload can be delivered at a time."]};//Only one payload can be delivered at a time.
//EGG editing
	}else{
		ctrlSetText [2011,"Equipped radio required"]};
	};
	
	if (_asspage) then 
	{	
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

	      _boun = (AssList select _index) select 3;
	      _type = (AssList select _index) select 4;	
	      if (EGG_EVO_Onmission) then {EGG_EVO_Onmission=false}else{_launch = [player,_type,_boun] execVM "scripts\missions\selectmis.sqf";EGG_EVO_Onmission = true};	
	      [] execVM "scripts\fcnListboxClk.sqf";
	};

//Join group button
	if(_grppage) then
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

		if (EGG_EVO_Onmission) then 
		{
			EGG_EVO_Onmission=false;
			with uiNamespace do
			{
				ctrlBut1 ctrlSetText "Join";//Join		

			};
			//ctrlSetText [6056,"Join"];//Join
		}
		else
		{
			_unit = (GrpList select _index);
			if(isNull _unit) then {_grp = creategroup (west)}else{_grp = group unit};
			[player] join group _unit;
		};	
	};
};

EGG_EVO_ListSelect =
{
	_x = lbCurSel 2000;
	//STR_M04t135,"Distance";
	//ctrlSetText [2003,str (score player)];
	ctrlSetText [2003,Format ["%1: %2","Score",(score player)]];//Score
	ctrlSetText [2203,""];
	ctrlSetText [2204,""];
	ctrlSetText [2205,""];
	ctrlSetText [2206,""]; 
	ctrlSetText [2207,""];
	ctrlSetText [2208,""];

	 _recpage = Mpage select 0;
	 _suppage = Mpage select 1;
	 _asspage = Mpage select 2;
	 _grppage = Mpage select 3;
	 _optpage = Mpage select 4;
	 _pos = [];

	if (_recpage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];
		if (helpersparam == 0) exitwith 
		{
			ctrlSetText [2011,"AI Recruitment disabled"]
		};

		_y = ((RecList select _x) select 0);
		_z = ((RecList select _x) select 3);
		_a = ((RecList select _x) select 2);
		_b = ((RecList select _x) select 4);
		_kind = ((RecList select _x) select 1);
		ctrlSetText [2201,localize "STR_M04t97"];
		ctrlSetText [2202,localize "STR_M04t96"];
		ctrlShow [6056,true];
		//ctrlSetText [6056,localize "STR_M04t98"];
		with uiNamespace do 
		{
			ctrlBut1 ctrlSetText localize "STR_M04t98";
		};
		
		ctrlSetText [2001,""];
		ctrlSetText [2002,""];
		ctrlSetText [2010,_y];
		ctrlSetText [2011,_z];
		ctrlSetText [2004,""];
		ctrlSetText [2005,_a];
	};
	
	if (_suppage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

		_y = ((SupList select _x) select 0);
		msize = (SupList select _x) select 2;
		_z = ((SupList select _x) select 1);
		_a = ((SupList select _x) select 5);
		bmark setMarkerSizeLocal [msize, msize];
		ctrlSetText [2202,"Support"];//support
		ctrlSetText [2201,"Ordnance and Support"];//ordnance
		ctrlShow [6056,true];
		//ctrlSetText [6056,"Request Support"]; //request
		with uiNamespace do 
		{
			ctrlBut1 ctrlSetText "Request Support";//request
		};
		ctrlSetText [2001,Format ["%1: %2","Cost",((SupList select _x) select 3)]]; // Support Cost
		ctrlSetText [2002,""];
		ctrlSetText [2010,_y];
		ctrlSetText [2011,_z];
		ctrlSetText [2004,""];
		ctrlSetText [2005,_a];
	};

	if (_asspage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

		_y = ((AssList select _x) select 0);
		_z = ((AssList select _x) select 1);
		_a = ((AssList select _x) select 2);
		_kind = ((AssList select _x) select 1);
		ctrlSetText [2202, localize "STR_M04t120"];
		ctrlSetText [2201, localize "STR_M04t121"];
		ctrlShow [6056,true];
		//if (EGG_EVO_Onmission) then {ctrlSetText [6056,"Abandon Mission"]}; //abandon
		//if (not EGG_EVO_Onmission) then {ctrlSetText [6056,"Request Mission"]}; //request
		if (EGG_EVO_Onmission) then 
		{	
			with uiNamespace do 
			{
				ctrlBut1 ctrlSetText "Abandon Mission"; //abandon
			};
		};
		if (not EGG_EVO_Onmission) then 
		{		
			with uinamespace do 
			{
				 ctrlBut1 ctrlSetText "Request Mission"; //request
			};
		};
		ctrlSetText [2001,""];
		ctrlSetText [2002,Format ["%1: %2","Reward",((AssList select _x) select 3)]];//Reward
		ctrlSetText [2010,_y];
		ctrlSetText [2011,_z];
		ctrlSetText [2005,_a];
		ctrlSetText [2004,""];
	};

	if (_grppage) then 
	{
		ctrlShow [6057,false];
		ctrlShow [6058,false];
		ctrlShow [6059,false];
		ctrlShow [2203,false];
		ctrlShow [2204,false];
		ctrlShow [2205,false];
		ctrlShow [2206,false];
		ctrlShow [2207,false];
		ctrlShow [2208,false];

		_unit = (GrpList select _x);
		_y = "";
		_z = "";
		if(isnull _unit) then 
		{
			_y = "New squad";
			_z = "Form a new squad.";
		}
		else
		{
			_y = format["%1",group _unit];
			_z = format["%1 : %2  x (%3)",group _unit,name _unit,count units _unit];
		};
		_a = "img\support\lock_off_ca.paa";
		_kind = ((AssList select _x) select 1);
		ctrlSetText [2202,"Transfer"]; //Transfer
		ctrlSetText [2201,"Squads"];//Squads
		ctrlShow [6056,true];
		//if (EGG_EVO_Onmission) then {ctrlSetText [6056,"Abandon Mission"]};//Abandon
		//if (not EGG_EVO_Onmission) then {ctrlSetText [6056,"Join Squad"]};//Join
		if (EGG_EVO_Onmission) then
		{
			with uiNamespace do
			{
				ctrlBut1 ctrlSetText "Abandon Mission";//Abandon
			};
		};
		if (not EGG_EVO_Onmission) then 
		{
			with uiNamespace do
			{
				ctrlBut1 ctrlSetText "Join Squad";//Join
			};
		};
		ctrlSetText [2001,""];
		ctrlSetText [2002,""];
		ctrlSetText [2010,_y];
		ctrlSetText [2011,_z];
		ctrlSetText [2005,""];
		ctrlSetText [2004,_a];
	};
	if (_optpage) then 
	{
//		_y = ((TerList select _x) select 0);
//		_z = ((TerList select _x) select 1);
		ctrlSetText [2202,"STR_M04t124"];
		ctrlSetText [2201,"STR_M04t125"];
		ctrlShow [6056,false];
		ctrlShow [6057,true];
		ctrlShow [6058,true];
		ctrlShow [6059,true];
		ctrlShow [2203,true];
		ctrlShow [2204,true];
		ctrlShow [2205,true];
		ctrlShow [2206,true];
		ctrlShow [2207,true];
		ctrlShow [2208,true];

	(uiNamespace getVariable "ctrlListBox") ctrlSetPosition [0.0506555,0.22,0.31, 0.05];
		ctrlSetText [2203,"STR_M04t126"];
		ctrlSetText [2204,"STR_M04t127"];
//		ctrlTTitle ctrlSetText "Terrain";
		ctrlSetText [2207,""];

		ctrlSetText [2003,""];
		ctrlSetText [2001,""];
		ctrlSetText [2002,""];
		ctrlSetText [2010,"STR_M04t124"];
		ctrlSetText [2011,"STR_M04t128"];
		ctrlSetText [2005,""];
		ctrlSetText [2004,""];
//		setterraingrid _z;
	};
};

[] call EGG_EVO_ListUpdate;

usedList = [];
GetoutClick = false;
ResetClick = false;
SupportClick = false;

while {dialog} do 
{
      if (GetoutClick) then 
	{
		closeDialog 1;
      };
      if(Mpage select 4) then 
	{
		_vpos = (sliderPosition 6057);
		_avpos = (sliderPosition 6058);
		setviewdistance _vpos;
		EGG_EVO_vdist = _vpos;
		EGG_EVO_avdist = _avpos;
		ctrlSetText [2205,format["Ground: %1",(round _vpos)]];
		ctrlSetText [2206,format["Air: %1",(round _avpos)]];

//TerList = [["No Grass",50,0] etc 	_z = ((TerList select _x) select 1);

		_gridval = (sliderPosition 6059);
		_gridrnd = (round _gridval) -1;
		_gridpos = ((TerList select _gridrnd) select 1);
		EGG_EVO_grid = _gridrnd;
		setterraingrid _gridpos;
		ctrlSetText [2208,format["Terrain: %1",((_gridrnd)+1)]];
		//
//		_z = ((TerList select _x) select 1);
//		setterraingrid _z;
//		EGG_EVO_grid = _z;
	};
	sleep 0.01;
};
//(FindDisplay 46) DisplaySetEventHandler ["keydown","if ((_this select 1) In actionKeys ""TeamSwitch"") then {a = createDialog 'evoUI'}"];
deleteMarkerLocal "btarg";
[] call EGG_EVO_ResetClick;
