size = { 412, 462 }

defineProperty("gust_lock", globalPropertyf("sim/custom/xap/gust_lock"))

defineProperty("ext_pr_panel_s", globalPropertyi("sim/custom/xap/ext_pr_panel_s"))

defineProperty("rembf1", globalPropertyi("sim/custom/xap/rembf1"))
defineProperty("rembf2", globalPropertyi("sim/custom/xap/rembf2"))
defineProperty("rembf3", globalPropertyi("sim/custom/xap/rembf3"))
defineProperty("rembf4", globalPropertyi("sim/custom/xap/rembf4"))
defineProperty("rembf5", globalPropertyi("sim/custom/xap/rembf5"))
defineProperty("rembf6", globalPropertyi("sim/custom/xap/rembf6"))
defineProperty("rembf7", globalPropertyi("sim/custom/xap/rembf7"))
defineProperty("rembf8", globalPropertyi("sim/custom/xap/rembf8"))
defineProperty("rembf9", globalPropertyi("sim/custom/xap/rembf9"))
defineProperty("rembf10", globalPropertyi("sim/custom/xap/rembf10"))
defineProperty("rembf11", globalPropertyi("sim/custom/xap/rembf11"))
defineProperty("rembf12", globalPropertyi("sim/custom/xap/rembf12"))
defineProperty("rembf13", globalPropertyi("sim/custom/xap/rembf13"))
defineProperty("rembf14", globalPropertyi("sim/custom/xap/rembf14"))

defineProperty("disp", globalPropertyf("sim/custom/xap/disp"))

defineProperty("night_lights", globalPropertyf("sim/graphics/scenery/percent_lights_on"))


defineProperty("wing_insp_h", globalPropertyf("sim/custom/xap/wing_insp_h"))
defineProperty("nav_h", globalPropertyf("sim/custom/xap/nav_h"))
defineProperty("entrlight_h", globalPropertyi("sim/custom/xap/entrlight_h"))
defineProperty("emeright_h", globalPropertyi("sim/custom/xap/emeright_h"))
defineProperty("landlight1_h", globalPropertyi("sim/custom/xap/landlight1_h"))
defineProperty("landlight2_h", globalPropertyi("sim/custom/xap/landlight2_h"))
defineProperty("xap_taxilight_h", globalPropertyi("sim/custom/xap/xap_taxilight_h"))
defineProperty("strobe_h", globalPropertyi("sim/custom/xap/strobe_h"))
defineProperty("bat_on", globalPropertyi("sim/custom/xap/left_bat_h"))
defineProperty("bat_on2", globalPropertyi("sim/custom/xap/right_bat_h"))
defineProperty("gear_hand_dn", globalPropertyi("sim/cockpit2/controls/gear_handle_down"))
defineProperty("parkbrake", globalPropertyi("sim/flightmodel/controls/parkbrake"))
defineProperty("hydrpump", globalPropertyi("sim/cockpit2/switches/electric_hydraulic_pump_on"))

defineProperty("aux_hpump_h", globalPropertyi("sim/custom/xap/aux_hpump_h"))
defineProperty("l_hpump_h", globalPropertyi("sim/custom/xap/l_hpump_h"))
defineProperty("r_hpump_h", globalPropertyi("sim/custom/xap/r_hpump_h"))


defineProperty("headposx", globalPropertyf("sim/graphics/view/pilots_head_x"))
defineProperty("headposy", globalPropertyf("sim/graphics/view/pilots_head_y"))
defineProperty("headposz", globalPropertyf("sim/graphics/view/pilots_head_z"))
defineProperty("headpsi", globalPropertyf("sim/graphics/view/pilots_head_psi"))
defineProperty("headthe", globalPropertyf("sim/graphics/view/pilots_head_the"))


defineProperty("customslider3_r", globalPropertyf("sim/custom/xap/customslider3_r"))
defineProperty("customslider4_r", globalPropertyf("sim/custom/xap/customslider4_r"))


defineProperty("background", loadImage("menu1.png", 0, 561, 412, 462))
defineProperty("green_circle", loadImage("menu1.png", 266, 1, 20, 20))

captview = findCommand("sim/view/forward")
cockview = findCommand("sim/view/3d_cockpit")

captview2 = findCommand("sim/view/forward_with_panel")
cockview2 = findCommand("sim/view/3d_cockpit_cmnd_look")


local font1 = loadFont('font_5.fnt')

last_states = {get(bat_on),get(hydrpump),get(emeright_h),get(nav_h),get(landlight1_h),get(landlight2_h),get(xap_taxilight_h),get(strobe_h),get(wing_insp_h),get(gust_lock)}
preflight = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
light_pref = {0,0,0,0,0,0,0}

preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

function update ()

--// external preflights

-- preflt N1

if preflight[1] == 0 and get(gear_hand_dn) == 1 and get(bat_on) == 1 and get(bat_on2) == 1 and get(l_hpump_h) == 0 and get(r_hpump_h) == 0 and get(aux_hpump_h) == 0 then
		preflight[1] = 1
end

if preflight[1] == 1 and get(bat_on) == 1 and get(bat_on2) == 1 and get(l_hpump_h) == 2 and get(parkbrake) == 1 then
		preflight[1] = 2
end

if preflight[1] == 2 and get(bat_on) == 1 and get(bat_on2) == 1 and get(l_hpump_h) == 0  then
		preflight[1] = 3
end



if get(night_lights) > 0.2 and preflight[1] == 3 then

		if last_states[3] - get(emeright_h) ~= 0 then
			light_pref[1] = 1
		end

		if last_states[4] - get(nav_h) ~= 0 then
			light_pref[2] = 1
		end

		if last_states[5] - get(landlight1_h) ~= 0 then
			light_pref[3] = 1
		end

		if last_states[6] - get(landlight2_h) ~= 0 then
			light_pref[4] = 1
		end

		if last_states[7] - get(xap_taxilight_h) ~= 0 then
			light_pref[5] = 1
		end

		if last_states[8] - get(strobe_h) ~= 0 then
			light_pref[6] = 1
		end

		if last_states[9] - get(wing_insp_h) ~= 0 then
			light_pref[7] = 1
		end


		if light_pref[1] + light_pref[2] + light_pref[3] + light_pref[4] + light_pref[5] + light_pref[6] + light_pref[7] == 7 and get(emeright_h) == 0 and get(nav_h) == 0 and get(landlight1_h) == 0 and get(landlight2_h) == 0 and get(xap_taxilight_h) == 0 and get(strobe_h) == 0 and get(wing_insp_h) == 0 and get(bat_on) == 0 and get(bat_on2) == 0 and get(gust_lock) == 0 then
			preflight[1] = 4
		end

		elseif preflight[1] == 3 and get(night_lights) <= 0.2 and get(emeright_h) == 0 and get(nav_h) == 0 and get(landlight1_h) == 0 and get(landlight2_h) == 0 and get(xap_taxilight_h) == 0 and get(strobe_h) == 0 and get(bat_on) == 0  and get(bat_on2) == 0 and get(gust_lock) == 0 then preflight[1] = 4

end




-- TrackIR fix
if get(ext_pr_panel_s) == 1 then

	if preflight_positions[2] == 1 then
	set(headposx, -6.389056)
	set(headposy, -0.149156)
	set(headposz, -7.541492)
			set(headpsi, 86.729546)
			set(headthe, 12.584431)
	end

	if preflight_positions[3] == 1 then
			set(headposx, -0.602418)
			set(headposy, -0.745473)
			set(headposz, -12.931976)
			set(headpsi, 172.449005)
			set(headthe, 9.898267)
	end

	if preflight_positions[4] == 1 then
			set(headposx, 0.024869)
			set(headposy, 0.925803)
			set(headposz, -13.851510)
			set(headpsi, 177.866440)
			set(headthe, 4.870494)
	end

	if preflight_positions[5] == 1 then
			set(headposx, 5.954782)
			set(headposy, -0.183105)
			set(headposz, -8.712113)
			set(headpsi, 252.719376)
			set(headthe, 12.929071)
	end

	if preflight_positions[6] == 1 then
			set(headposx, 5.5005741119385)
			set(headposy, -0.70470744371414)
			set(headposz, -6.7671151161194-1.2192)
			set(headpsi, 239.03746032715)
			set(headthe, 21.444511413574)
	end

	if preflight_positions[7] == 1 then
			set(headposx, 2.8268129825592)
			set(headposy, -1.5780529975891)
			set(headposz, -3.589056968689-1.2192)
			set(headpsi, 214.55076599121)
			set(headthe, 29.718217849731)
	end

	if preflight_positions[8] == 1 then
			set(headposx, 2.4867901802063)
			set(headposy, 0.5495440363884)
			set(headposz, 2.1360440254211-1.2192)
			set(headpsi, 309.39141845703)
			set(headthe, 4.2717700004578)
	end

	if preflight_positions[9] == 1 then
			set(headposx, 8.2728357315063)
			set(headposy, -0.18656487762928)
			set(headposz, 3.1257970333099-1.2192)
			set(headpsi, 272.12274169922)
			set(headthe, 12.508261680603)
	end

	if preflight_positions[10] == 1 then
			set(headposx, 12.376005172729)
			set(headposy, 0.13815033435822)
			set(headposz, 3.5698390007019-1.2192)
			set(headpsi, 253.622818)
			set(headthe, 5.0102624893188)
	end

	if preflight_positions[11] == 1 then
			set(headposx, 10.119519233704)
			set(headposy, 0.85619628429413)
			set(headposz, 6.598979473114-1.2192)
			set(headpsi, 297.48208618164)
			set(headthe, -20.244525909424)
	end

	if preflight_positions[12] == 1 then
			set(headposx, 3.730618)
			set(headposy, -1.591129)
			set(headposz, -2.296650)
			set(headpsi, 211.093384)
			set(headthe, 9.854322)
	end

	if preflight_positions[13] == 1 then
			set(headposx, 5.06405210495)
			set(headposy, 0.31791409850121)
			set(headposz, 1.8548974990845-1.2192)
			set(headpsi, 216.37120056152)
			set(headthe, 12.05148887634)
	end

	if preflight_positions[14] == 1 then
			set(headposx, 3.4712388515472)
			set(headposy, -0.037349700927734)
			set(headposz, 11.332137107849-1.2192)
			set(headpsi, 325.51080322266)
			set(headthe, 18.729112625122)
	end

	if preflight_positions[15] == 1 then
			set(headposx, 1.1529536247253)
			set(headposy, -1.6946949958801)
			set(headposz, 11.890969276428-1.2192)
			set(headpsi, 340.324890)
			set(headthe, 38.639538)
	end

	if preflight_positions[16] == 1 then
			set(headposx, 6.603047)
			set(headposy, 0.869100)
			set(headposz, 13.991118)
			set(headpsi, 295.579224)
			set(headthe, 27.799990)
	end

	if preflight_positions[17] == 1 then
			set(headposx, -3.906355)
			set(headposy, -1.624961)
			set(headposz, 8.346842)
			set(headpsi, 39.960983)
			set(headthe, 16.427885)
	end

	if preflight_positions[18] == 1 then
			set(headposx, -3.9402742385864)
			set(headposy, -0.037349700927734)
			set(headposz, 10.278121)
			set(headpsi, 21.260725)
			set(headthe, 14.961067)
	end

	if preflight_positions[19] == 1 then
			set(headposx, -3.831425)
			set(headposy, -1.596274)
			set(headposz, -2.358464)
			set(headpsi, 144.938568)
			set(headthe, 10.654785)
	end

	if preflight_positions[20] == 1 then
			set(headposx, -9.933014)
			set(headposy, 0.797059)
			set(headposz, 5.192961)
			set(headpsi, 40.441746)
			set(headthe, -23.406305)
	end

	if preflight_positions[21] == 1 then
			set(headposx, -12.121741)
			set(headposy, -0.018101)
			set(headposz, 0.970637)
			set(headpsi, 123.337196)
			set(headthe, 9.109984)
	end

	if preflight_positions[22] == 1 then
			set(headposx, -8.0549201965332)
			set(headposy, -0.27915194630623)
			set(headposz, 3.0759136676788-1.2192)
			set(headpsi, 60.066551208496)
			set(headthe, 8.5916862487793)
	end

	if preflight_positions[23] == 1 then
			set(headposx, -4.0922675132751)
			set(headposy, -1.5789767503738)
			set(headposz, -3.6380000114441-1.2192)
			set(headpsi, 141.23330688477)
			set(headthe, 16.260517120361)
	end

	if preflight_positions[24] == 1 then
			set(headposx, -3.758221)
			set(headposy, 1.265534)
			set(headposz, -3.536954)
			set(headpsi, 147.782196)
			set(headthe, 3.163780)
	end

else
preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
end


last_states = {get(bat_on),get(hydrpump),get(emeright_h),get(nav_h),get(landlight1_h),get(landlight2_h),get(xap_taxilight_h),get(strobe_h),get(wing_insp_h),get(gust_lock)}

--set(disp, preflight[1])
end



components = {

    textureLit {
        position = {0,0,412,462},
        image = get(background)

    },





--// start again

		    clickable {
       position = {295,423,80,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()

			preflight = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
			light_pref = {0,0,0,0,0,0,0}

			last_states = {get(bat_on),get(hydrpump),get(emeright_h),get(nav_h),get(landlight1_h),get(landlight2_h),get(xap_taxilight_h),get(strobe_h),get(wing_insp_h),get(gust_lock)}

        end
    },

--// fast preflight

		    clickable {
       position = {275,23,110,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		set(rembf1,1)
		set(rembf2,1)
		set(rembf3,1)
		set(rembf4,1)
		set(rembf5,1)
		set(rembf6,1)
		set(rembf7,1)
		set(rembf8,1)
		set(rembf9,1)
		set(rembf10,1)
		set(rembf11,1)
		set(rembf12,1)
		set(rembf13,1)
		set(rembf14,1)
preflight = {4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
        end
    },


	--// prefl 1

    textureLit {
        position = {193,353,20,20},
        image = get(green_circle),
		visible = function () return preflight[1]  == 4 end,

    },


		    clickable {
       position = {193,353,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
		commandOnce(cockview2)
			set(headposx, -0.4724400639534)
			set(headposy, 0.90220862627029)
			set(headposz, -6.510527)
			set(headpsi, 21.699899673462)
			set(headthe, -19.589195251465)
        end
    },

--// prefl 2

    textureLit {
        position = {160,358,20,20},
        image = get(green_circle),
		visible = function () return preflight[2] == 1 and get(rembf1)==1 and  get(rembf2)==1 and get(rembf3)==1 and get(rembf4)==1 end,

    },


		    clickable {
       position = {160,358,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
		--print("Prefl 2", preflight_positions[2])
			preflight[2] = 1
			commandOnce(cockview2)
			set(headposx, -6.389056)
			set(headposy, -0.149156)
			set(headposz, -7.541492)
			set(headpsi, 86.729546)
			set(headthe, 12.584431)
        end
    },

		--// prefl 3

    textureLit {
        position = {151,376,20,20},
        image = get(green_circle),
		visible = function () return preflight[3] == 1 and get(rembf5)==1 and get(rembf10)==1 end,

    },


		    clickable {
       position = {151,376,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
		--print("Prefl 3", preflight_positions[3])
			preflight[3] = 1
			commandOnce(cockview2)
			set(headposx, -0.602418)
			set(headposy, -0.745473)
			set(headposz, -12.931976)
			set(headpsi, 172.449005)
			set(headthe, 9.898267)
        end
    },


	--// prefl 4

    textureLit {
        position = {193,419,20,20},
        image = get(green_circle),
		visible = function () return preflight[4] == 1 end,

    },


		    clickable {
       position = {193,419,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
		    preflight[4] = 1
			commandOnce(cockview2)
			set(headposx, 0.024869)
			set(headposy, 0.925803)
			set(headposz, -13.851510)
			set(headpsi, 177.866440)
			set(headthe, 4.870494)
        end
    },

	--// prefl 5

    textureLit {
        position = {233,378,20,20},
        image = get(green_circle),
		visible = function () return preflight[5] == 1 and get(rembf6)==1 and  get(rembf7)==1 end,

    },


		    clickable {
       position = {233,378,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[5] = 1
			commandOnce(cockview2)
			set(headposx, 5.954782)
			set(headposy, -0.183105)
			set(headposz, -8.712113)
			set(headpsi, 252.719376)
			set(headthe, 12.929071)
        end
    },


	--// prefl 6

    textureLit {
        position = {223,364,20,20},
        image = get(green_circle),
		visible = function () return preflight[6] == 1 and get(rembf8)==1 and  get(rembf9)==1 end,

    },


		    clickable {
       position = {223,364,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[6] = 1
			commandOnce(cockview2)
			set(headposx, 5.5005741119385)
			set(headposy, -0.70470744371414)
			set(headposz, -6.7671151161194-1.2192)
			set(headpsi, 239.03746032715)
			set(headthe, 21.444511413574)
        end
    },

	--// prefl 7

    textureLit {
        position = {227,276,20,20},
        image = get(green_circle),
		visible = function () return preflight[7] == 1 end,

    },


		    clickable {
       position = {227,276,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[7] = 1
			commandOnce(cockview2)
			set(headposx, 2.8268129825592)
			set(headposy, -1.5780529975891)
			set(headposz, -3.589056968689-1.2192)
			set(headpsi, 214.55076599121)
			set(headthe, 29.718217849731)
        end
    },

	--// prefl 8

    textureLit {
        position = {228,244,20,20},
        image = get(green_circle),
		visible = function () return preflight[8] == 1 and get(customslider4_r) == 0 end,

    },


		    clickable {
       position = {228,244,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[8] = 1
			commandOnce(cockview2)
			set(headposx, 2.4867901802063)
			set(headposy, 0.5495440363884)
			set(headposz, 2.1360440254211-1.2192)
			set(headpsi, 309.39141845703)
			set(headthe, 4.2717700004578)
        end
    },

	--// prefl 9

    textureLit {
        position = {300,230,20,20},
        image = get(green_circle),
		visible = function () return preflight[9] == 1 end,

    },


		    clickable {
       position = {300,230,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[9] = 1
			commandOnce(cockview2)
			set(headposx, 8.2728357315063)
			set(headposy, -0.18656487762928)
			set(headposz, 3.1257970333099-1.2192)
			set(headpsi, 272.12274169922)
			set(headthe, 12.508261680603)
        end
    },

	--// prefl 10

    textureLit {
        position = {368,191,20,20},
        image = get(green_circle),
		visible = function () return preflight[10] == 1 end,

    },


		    clickable {
       position = {368,191,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[10] = 1
			commandOnce(cockview2)
			set(headposx, 12.376005172729)
			set(headposy, 0.13815033435822)
			set(headposz, 3.5698390007019-1.2192)
			set(headpsi, 253.622818)
			set(headthe, 5.0102624893188)
        end
    },

	--// prefl 11

    textureLit {
        position = {346,153,20,20},
        image = get(green_circle),
		visible = function () return preflight[11] == 1 end,

    },


		    clickable {
       position = {346,153,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[11] = 1
			commandOnce(cockview2)
			set(headposx, 10.119519233704)
			set(headposy, 0.85619628429413)
			set(headposz, 6.598979473114-1.2192)
			set(headpsi, 297.48208618164)
			set(headthe, -20.244525909424)
        end
    },

	--// prefl 12

    textureLit {
        position = {261,177,20,20},
        image = get(green_circle),
		visible = function () return preflight[12] == 1 and get(rembf14)==1 end,

    },


		    clickable {
       position = {261,177,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[12] = 1
			commandOnce(cockview2)
			set(headposx, 3.730618)
			set(headposy, -1.591129)
			set(headposz, -2.296650)
			set(headpsi, 211.093384)
			set(headthe, 9.854322)
        end
    },

	--// prefl 13

    textureLit {
        position = {228,193,20,20},
        image = get(green_circle),
		visible = function () return preflight[13] == 1 and get(rembf11)==1 end,

    },


		    clickable {
       position = {228,193,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0}
			preflight[13] = 1
			commandOnce(cockview2)
			set(headposx, 5.06405210495)
			set(headposy, 0.31791409850121)
			set(headposz, 1.8548974990845-1.2192)
			set(headpsi, 216.37120056152)
			set(headthe, 12.05148887634)
        end
    },

	--// prefl 14

    textureLit {
        position = {225,108,20,20},
        image = get(green_circle),
		visible = function () return preflight[14] == 1 and get(rembf11)==1 end,

    },


		    clickable {
       position = {225,108,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0}
			preflight[14] = 1
			commandOnce(cockview2)
			set(headposx, 3.4712388515472)
			set(headposy, -0.037349700927734)
			set(headposz, 11.332137107849-1.2192)
			set(headpsi, 325.51080322266)
			set(headthe, 18.729112625122)
        end
    },

	--// prefl 15

    textureLit {
        position = {220,86,20,20},
        image = get(green_circle),
		visible = function () return preflight[15] == 1 end,

    },


		    clickable {
       position = {220,86,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0}
			preflight[15] = 1
			commandOnce(cockview2)
			set(headposx, 1.1529536247253)
			set(headposy, -1.6946949958801)
			set(headposz, 11.890969276428-1.2192)
			set(headpsi, 340.324890)
			set(headthe, 38.639538)
        end
    },

	--// prefl 16

    textureLit {
        position = {246,68,20,20},
        image = get(green_circle),
		visible = function () return preflight[16] == 1 end,

    },


		    clickable {
       position = {246,68,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}
			preflight[16] = 1
			commandOnce(cockview2)
			set(headposx, 6.603047)
			set(headposy, 0.869100)
			set(headposz, 13.991118)
			set(headpsi, 295.579224)
			set(headthe, 27.799990)
        end
    },

	--// prefl 17

    textureLit {
        position = {185,26,20,20},
        image = get(green_circle),
		visible = function () return preflight[17] == 1 end,

    },


		    clickable {
       position = {185,26,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}
			preflight[17] = 1
			commandOnce(cockview2)
			set(headposx, -3.906355)
			set(headposy, -1.624961)
			set(headposz, 8.346842)
			set(headpsi, 39.960983)
			set(headthe, 16.427885)
        end
    },

	--// prefl 18

    textureLit {
        position = {162,105,20,20},
        image = get(green_circle),
		visible = function () return preflight[18] == 1 and get(rembf12)==1 end,

    },


		    clickable {
       position = {162,105,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0}
			preflight[18] = 1
			commandOnce(cockview2)
			set(headposx, -3.9402742385864)
			set(headposy, -0.037349700927734)
			set(headposz, 10.278121)
			set(headpsi, 21.260725)
			set(headthe, 14.961067)
        end
    },

	--// prefl 19

    textureLit {
        position = {137,170,20,20},
        image = get(green_circle),
		visible = function () return preflight[19] == 1 and get(customslider3_r) == 0 and get(rembf13)==1 end,

    },


		    clickable {
       position = {137,170,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0}
			preflight[19] = 1
			commandOnce(cockview2)
			set(headposx, -3.831425)
			set(headposy, -1.596274)
			set(headposz, -2.358464)
			set(headpsi, 144.938568)
			set(headthe, 10.654785)
        end
    },

	--// prefl 20

    textureLit {
        position = {67,156,20,20},
        image = get(green_circle),
		visible = function () return preflight[20] == 1 end,

    },


		    clickable {
       position = {67,156,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0}
			preflight[20] = 1
			commandOnce(cockview2)
			set(headposx, -9.933014)
			set(headposy, 0.797059)
			set(headposz, 5.192961)
			set(headpsi, 40.441746)
			set(headthe, -23.406305)
        end
    },

	--// prefl 21

    textureLit {
        position = {21,198,20,20},
        image = get(green_circle),
		visible = function () return preflight[21] == 1 end,

    },


		    clickable {
       position = {21,198,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0}
			preflight[21] = 1
			commandOnce(cockview2)
			set(headposx, -12.121741)
			set(headposy, -0.018101)
			set(headposz, 0.970637)
			set(headpsi, 123.337196)
			set(headthe, 9.109984)
        end
    },

	--// prefl 22

    textureLit {
        position = {91,235,20,20},
        image = get(green_circle),
		visible = function () return preflight[22] == 1 end,

    },


		    clickable {
       position = {91,235,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}
			preflight[22] = 1
			commandOnce(cockview2)
			set(headposx, -8.0549201965332)
			set(headposy, -0.27915194630623)
			set(headposz, 3.0759136676788-1.2192)
			set(headpsi, 60.066551208496)
			set(headthe, 8.5916862487793)
        end
    },

	--// prefl 23

    textureLit {
        position = {159,278,20,20},
        image = get(green_circle),
		visible = function () return preflight[23] == 1 end,

    },


		    clickable {
       position = {159,278,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}
			preflight[23] = 1
			commandOnce(cockview2)
			set(headposx, -4.0922675132751)
			set(headposy, -1.5789767503738)
			set(headposz, -3.6380000114441-1.2192)
			set(headpsi, 141.23330688477)
			set(headthe, 16.260517120361)
        end
    },

	--// prefl 24

    textureLit {
        position = {159,237,20,20},
        image = get(green_circle),
		visible = function () return preflight[24] == 1 end,

    },


		    clickable {
       position = {159,237,20,20},

       cursor = {
            x = 10,
            y = 28,
            width = 32,
            height = 16,
            shape = loadImage("clickable.png"),

        },

        onMouseClick = function()
		--                     1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
		preflight_positions = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}
			preflight[24] = 1
			commandOnce(cockview2)
			set(headposx, -3.758221)
			set(headposy, 1.265534)
			set(headposz, -3.536954)
			set(headpsi, 147.782196)
			set(headthe, 3.163780)
        end
    },

 		-- close zone
		clickable {
		position = {size[1]-16, size[2]-16, 16, 16 },

		cursor = {
			x = -16,
			y = 0,
			width = 32,
			height = 16,
			shape = loadImage("clickclose.png")
		},
		 onMouseClick = function()
			set(ext_pr_panel_s, 0)
		 end
	},

}





function draw()

drawAll(components)

drawText(font1, 295, 423, "START AGAIN", 0.6, 0.6, 0.6)
drawText(font1, 275, 23, "FAST PREFLIGHT", 0.4, 0.4, 0.4)



drawText(font1, 199, 425, "4", 0.9, 0.9, 0.9)
drawText(font1, 158, 382, "3", 0.9, 0.9, 0.9)
drawText(font1, 167, 364, "2", 0.9, 0.9, 0.9)
drawText(font1, 199, 359, "1", 0.9, 0.9, 0.9)
drawText(font1, 240, 384, "5", 0.9, 0.9, 0.9)
drawText(font1, 230, 370, "6", 0.9, 0.9, 0.9)
drawText(font1, 162, 284, "23", 0.9, 0.9, 0.9)
drawText(font1, 234, 282, "7", 0.9, 0.9, 0.9)
drawText(font1, 94, 241, "22", 0.9, 0.9, 0.9)
drawText(font1, 162, 243, "24", 0.9, 0.9, 0.9)
drawText(font1, 235, 250, "8", 0.9, 0.9, 0.9)
drawText(font1, 307, 236, "9", 0.9, 0.9, 0.9)
drawText(font1, 371, 197, "10", 0.9, 0.9, 0.9)
drawText(font1, 24, 204, "21", 0.9, 0.9, 0.9)
drawText(font1, 70, 162, "20", 0.9, 0.9, 0.9)
drawText(font1, 139, 176, "19", 0.9, 0.9, 0.9)
drawText(font1, 164, 111, "18", 0.9, 0.9, 0.9)
drawText(font1, 188, 32, "17", 0.9, 0.9, 0.9)
drawText(font1, 249, 74, "16", 0.9, 0.9, 0.9)
drawText(font1, 222, 92, "15", 0.9, 0.9, 0.9)
drawText(font1, 227, 114, "14", 0.9, 0.9, 0.9)
drawText(font1, 230, 199, "13", 0.9, 0.9, 0.9)
drawText(font1, 264, 183, "12", 0.9, 0.9, 0.9)
drawText(font1, 349, 159, "11", 0.9, 0.9, 0.9)


end
