red = Color.new(255, 0, 0)
white = Color.new(255, 255, 255)

--
Select = 1
maxSelect = 9
menuBackground=Image.load("icons/mbg.png")
icon=Image.load("icons/icon.png")
icon0=Image.load("icons/icon0.png")
icon1=Image.load("icons/icon1.png")
icon11=Image.load("icons/icon11.png")
icon2=Image.load("icons/icon2.png")
icon22=Image.load("icons/icon22.png")
clock=Image.load("icons/clock.png")
clock1=Image.load("icons/clock1.png")
ownlua=Image.load("icons/ownlua.png")
ownlua1=Image.load("icons/ownlua1.png")
credits0=Image.load("icons/credits0.png")
credits1=Image.load("icons/credits1.png")
credit=Image.load("credit.png")
hud=Image.load("icons/hud.png")
sys=Image.load("icons/sysinfo1.png")
sys1=Image.load("icons/sysinfo.png")
sig=Image.load("signal.png")
sig1=Image.load("signal2.png")
full=Image.load("battery/full.png")
half=Image.load("battery/half.png")
third=Image.load("battery/last.png")
dead=Image.load("battery/dead.png")
keno=Image.load("icons/keno.png")
oldpad = Controls.read()
--
while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,menuBackground)
screen:blit(0,0,hud)
--
if pad:up() and oldpad:up() ~= pad:up() then
Select = Select - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
Select = Select + 1
end
if Select > maxSelect then
Select = 1
elseif Select <= 0 then
Select = maxSelect
end
if Select == 1 then
screen:blit(380,15,icon0)
screen:blit(380,100,icon1)
screen:blit(380,185,icon2)
screen:blit(300,15,clock)
screen:blit(300,100,ownlua)
screen:blit(300,185,ownlua)
screen:blit(220,15,credits0)
screen:blit(220,100,sys)
screen:blit(220,185,keno)
end
if Select == 2 then
screen:blit(380,15,icon)
screen:blit(380,100,icon11)
screen:blit(380,185,icon2)
screen:blit(300,15,clock)
screen:blit(300,100,ownlua)
screen:blit(300,185,ownlua)
screen:blit(220,15,credits0)
screen:blit(220,100,sys)
screen:blit(220,185,keno)
end
if Select == 3 then
screen:blit(380,15,icon)
screen:blit(380,100,icon1)
screen:blit(380,185,icon22)
screen:blit(300,15,clock)
screen:blit(300,100,ownlua)
screen:blit(300,185,ownlua)
screen:blit(220,15,credits0)
screen:blit(220,100,sys)
screen:blit(220,185,keno)
end
if Select == 4 then
screen:blit(380,15,icon)
screen:blit(380,100,icon1)
screen:blit(380,185,icon2)
screen:blit(300,15,clock1)
screen:blit(300,100,ownlua)
screen:blit(300,185,ownlua)
screen:blit(220,15,credits0)
screen:blit(220,100,sys)
screen:blit(220,185,keno)
end
if Select == 5 then
screen:blit(380,15,icon)
screen:blit(380,100,icon1)
screen:blit(380,185,icon2)
screen:blit(300,15,clock)
screen:blit(300,100,ownlua1)
screen:blit(300,185,ownlua)
screen:blit(220,15,credits0)
screen:blit(220,100,sys)
screen:blit(220,185,keno)
end
if Select == 6 then
screen:blit(380,15,icon)
screen:blit(380,100,icon1)
screen:blit(380,185,icon2)
screen:blit(300,15,clock)
screen:blit(300,100,ownlua)
screen:blit(300,185,ownlua1)
screen:blit(220,15,credits0)
screen:blit(220,100,sys)
screen:blit(220,185,keno)
end
if Select == 7 then
screen:blit(380,15,icon)
screen:blit(380,100,icon1)
screen:blit(380,185,icon2)
screen:blit(300,15,clock)
screen:blit(300,100,ownlua)
screen:blit(300,185,ownlua)
screen:blit(220,15,credits1)
screen:blit(220,100,sys)
screen:blit(220,185,keno)
end
if Select == 8 then
screen:blit(380,15,icon)
screen:blit(380,100,icon1)
screen:blit(380,185,icon2)
screen:blit(300,15,clock)
screen:blit(300,100,ownlua)
screen:blit(300,185,ownlua)
screen:blit(220,15,credits0)
screen:blit(220,100,sys1)
screen:blit(220,185,keno)
end
if Select == 9 then
screen:blit(380,15,icon)
screen:blit(380,100,icon1)
screen:blit(380,185,icon2)
screen:blit(300,15,clock)
screen:blit(300,100,ownlua)
screen:blit(300,185,ownlua)
screen:blit(220,15,credits0)
screen:blit(220,100,sys)
screen:blit(225,185,keno)
end
if pad:cross() and Select == 1 then
dofile("game.lua") 
end
if pad:cross() and Select == 2 then
dofile("pxlmenu.lua")
end
if pad:cross() and Select == 3 then
dofile("browser.lua")
end
if pad:cross() and Select == 4 then
dofile("clock.lua")
end
if pad:cross() and Select == 5 then
dofile("ownlua.lua")
end
if pad:cross() and Select == 6 then
dofile("ownlua.lua")
end
if pad:cross() and Select == 7 then
screen:blit(0,0,credit)
end
if pad:cross() and Select == 8 then
dofile("sysinfomenu.lua")
end
if pad:cross() and Select == 9 then
dofile("lotto/start.lua")
end

screen:blit(459,80,sig)
screen:blit(459,10,sig1)

batteryLife=System.powerGetBatteryLifePercent()

if batteryLife > 75 then
screen:blit(460,240,full)
end
if batteryLife < 75 and batteryLife > 50 then
screen:blit(460,240,half)
end
if batteryLife < 50 and batteryLife > 25 then
screen:blit(460,240,third)
end
if batteryLife < 25 and batteryLife > 0 then
screen:blit(460,240,dead)
end

screen.waitVblankStart()
screen.flip()
oldpad = pad
end