size = { 400, 400 }

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

defineProperty("menu_pointer", loadImage("menu1.png", 246, 0, 16, 50))

defineProperty("cam_type", globalPropertyi("sim/custom/xap/cam_type"))
defineProperty("menu_type", globalPropertyi("sim/custom/xap/menu_type"))
defineProperty("customslider1", globalPropertyi("sim/custom/xap/customslider1"))
defineProperty("customslider1_r", globalPropertyf("sim/custom/xap/customslider1_r"))

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

defineProperty("slider9", globalPropertyf("sim/flightmodel2/misc/custom_slider_ratio[8]"))
defineProperty("slider9h", globalPropertyf("sim/cockpit2/switches/custom_slider_on[8]"))
defineProperty("slider13", globalPropertyf("sim/flightmodel2/misc/custom_slider_ratio[12]"))
defineProperty("slider13h", globalPropertyf("sim/cockpit2/switches/custom_slider_on[12]"))

defineProperty("background", loadImage("background.png", 21, 13, 220, 140))
defineProperty("menu1", loadImage("menu1.png", 0, 0, 262, 350))

defineProperty("totaltime", globalPropertyf("sim/time/total_running_time_sec"))
defineProperty("inst_p", globalPropertyi("sim/custom/xap/inst_p"))
defineProperty("opt_p", globalPropertyi("sim/custom/xap/opt_p"))

createCommand("sim/custom/xap/fast_start", "Fast Start button")

fast_start = findCommand("sim/custom/xap/fast_start")




--local sizecoeff1 = 1
local time_now = get(totaltime)
local font1 = loadFont('font_6.fnt')
local pos_1 = {0, 0, 272, 350}
local pos_2 = {0, 300, 272, 50}

local	color1 = {0.1,0.3,0.4}
local	color2 = {0.1,0.3,0.4}
local	color3 = {0.1,0.3,0.4}
local	color4 = {0.1,0.3,0.4}
local	color5 = {0.1,0.3,0.4}
local	color6 = {0.1,0.3,0.4}
local	color7 = {0.1,0.3,0.4}

--set(customslider1, 1)
--set(menu_type, 3)

function update()

--sizecoeff1 = get(customslider1_r)

pos_1 = {-256+256*get(customslider1_r), 0, 272, 350}
pos_2 = {-256+256*get(customslider1_r), 300, 272, 50}

--set(customslider1_r, customslide[1])



end

components = {

    -- menu1

	-- background
--    rectangle {
--        position = { -128 + 128*sizecoeff1, 119, 120, 256 },
 --       color = { 0.05, 0.05, 0.05, 0.4};
 --   },

--	rectangle {
--        position = { 0, 0, 400, 400 };
--        color = { 0.05, 0.05, 0.05, 0.1};

--    },
    textureLit {
        position = function() return pos_1 end,
        image = get(menu1)

    },

    textureLit {
        position = { 244, 150, 16, 50 },
        image = get(menu_pointer),
		visible = function() return get(cam_panel_s) == 1 and get(customslider1_r) == 1 end,

    },--

    textureLit {
        position = { 244, 200, 16, 50 },
        image = get(menu_pointer),
		visible = function() return get(ext_pr_panel_s) == 1 and get(customslider1_r) == 1 end,

    },

    textureLit {
        position = { 244, 100, 16, 50 },
        image = get(menu_pointer),
		visible = function() return get(anim_panel_s) == 1 and get(customslider1_r) == 1 end,

    },

    textureLit {
        position = { 244, 50, 16, 50 },
        image = get(menu_pointer),
		visible = function() return get(inst_p) == 1 and get(customslider1_r) == 1 end,

    },

    textureLit {
        position = { 244, 0, 16, 50 },
        image = get(menu_pointer),
		visible = function() return get(opt_p) == 1 and get(customslider1_r) == 1 end,

    },

	    clickable {
       position = function() return pos_2 end,

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

        },

		onMouseMove = function()
				color1 = {0.1,0.3,0.4}
				color2 = {0.1,0.3,0.4}
				color3 = {0.1,0.3,0.4}
				color4 = {0.1,0.3,0.4}
				color5 = {0.1,0.3,0.4}
				color6 = {0.1,0.3,0.4}
				--if get(menu_type) ~= 0 then
				--set(menu_type, 0)
				--end

        end,

        onMouseClick = function()
			if get(customslider1) > 0.9 then
			set(customslider1, 0)
--			set(cam_type, 0)
			else
			set(customslider1, 1)
			end
        end
    },

-- clickable for fast start

	    clickable {
       position = {  0, 250, 256, 50  },


		onMouseMove = function()
				color1 = {0.2,0.6,0.7}
				color2 = {0.1,0.3,0.4}
				color3 = {0.1,0.3,0.4}
				color4 = {0.1,0.3,0.4}
				color5 = {0.1,0.3,0.4}
				color6 = {0.1,0.3,0.4}
				--if get(menu_type) ~= 1 then
				--set(menu_type, 0)
				--end

        end,

        onMouseClick = function()
			if get(menu_type) ~= 1 then
			set(menu_type, 1)
			else
			set(menu_type, 0)
			set(cam_type, 0)
			end
			commandOnce(fast_start)
			set(customslider1, 0)
        end
    },


-- clickable for preflight menu

	    clickable {
       position = {  0, 200, 256, 50  },


		onMouseMove = function()
				color1 = {0.1,0.3,0.4}
				color2 = {0.2,0.6,0.7}
				color3 = {0.1,0.3,0.4}
				color4 = {0.1,0.3,0.4}
				color5 = {0.1,0.3,0.4}
				color6 = {0.1,0.3,0.4}
				--if get(menu_type) ~= 2 then
				--set(menu_type, 0)
				--end
        end,

        onMouseClick = function()
			if get(ext_pr_panel_s) ~= 1 then
			set(ext_pr_panel_s, 1)
			else
			set(ext_pr_panel_s, 0)
			set(cam_type, 0)
			end
			set(customslider1, 0)
        end
    },


--// Clicable for cameras menu


	    clickable {
       position = {  0, 150, 256, 50  },


		onMouseMove = function()
				color1 = {0.1,0.3,0.4}
				color2 = {0.1,0.3,0.4}
				color3 = {0.2,0.6,0.7}
				color4 = {0.1,0.3,0.4}
				color5 = {0.1,0.3,0.4}
				color6 = {0.1,0.3,0.4}
				--if get(menu_type) ~= 3 then
				--set(menu_type, 0)
				--end
        end,

        onMouseClick = function()
			if get(cam_panel_s) ~= 1 then
			set(cam_panel_s, 1)
			else
			set(cam_panel_s, 0)
--			set(cam_type, 0)
			end
			set(customslider1, 0)
        end
    },

-- clickable for animations menu

	    clickable {
       position = {  0, 100, 256, 50  },


		onMouseMove = function()
				color1 = {0.1,0.3,0.4}
				color2 = {0.1,0.3,0.4}
				color3 = {0.1,0.3,0.4}
				color4 = {0.2,0.6,0.7}
				color5 = {0.1,0.3,0.4}
				color6 = {0.1,0.3,0.4}
				--if get(menu_type) ~= 4 then
				--set(menu_type, 0)
				--end
        end,

        onMouseClick = function()
			if get(anim_panel_s) ~= 1 then
			set(anim_panel_s, 1)
			else
			set(anim_panel_s, 0)
--			set(cam_type, 0)
			end
			set(customslider1, 0)
        end
    },

-- clickable for instruments menu

	    clickable {
       position = {  0, 50, 256, 50  },


		onMouseMove = function()

				color1 = {0.1,0.3,0.4}
				color2 = {0.1,0.3,0.4}
				color3 = {0.1,0.3,0.4}
				color4 = {0.1,0.3,0.4}
				color5 = {0.2,0.6,0.7}
				color6 = {0.1,0.3,0.4}
				--if get(menu_type) ~= 5 then
				--set(menu_type, 0)
				--end
        end,

        onMouseClick = function()
			if get(inst_p) ~= 1 then
			set(inst_p, 1)
			else
			set(inst_p, 0)
--			set(cam_type, 0)
			end
			set(customslider1, 0)
        end
    },

	-- clickable for options

	    clickable {
       position = {  0, 0, 256, 50  },


		onMouseMove = function()
				color1 = {0.1,0.3,0.4}
				color2 = {0.1,0.3,0.4}
				color3 = {0.1,0.3,0.4}
				color4 = {0.1,0.3,0.4}
				color5 = {0.1,0.3,0.4}
				color6 = {0.2,0.6,0.7}
				--if get(menu_type) ~= 6 then
				--set(menu_type, 0)
				--end
        end,

        onMouseClick = function()
			if get(opt_p) ~= 1 then
			set(opt_p, 1)
			else
			set(opt_p, 0)
--			set(cam_type, 0)
			end
			set(customslider1, 0)
        end
    },


}
function draw()

drawAll(components)

drawText(font1, pos_1[1]+60, 270, "FAST START",  color1[1],color1[2],color1[3])
drawText(font1, pos_1[1]+50, 220, "EXTER PREFLT",  color2[1],color2[2],color2[3])
drawText(font1, pos_1[1]+70, 170, "CAMERAS",  color3[1],color3[2],color3[3])
drawText(font1, pos_1[1]+56, 120, "ANIMATIONS",  color4[1],color4[2],color4[3])
drawText(font1, pos_1[1]+50, 70, "INSTRUMENTS",  color5[1],color5[2],color5[3])
drawText(font1, pos_1[1]+76, 20, "OPTIONS",  color6[1],color6[2],color6[3])


	--set(disp, get(customslider1))


end

