server_menu = {}

function AddMenu(m,lvl)
	table.insert(server_menu, {m = m,lvl = lvl})
end

function PlayerMenus(id)
	local menus = {}
	for _, b in pairs(server_menu) do
		if SERVER_RANK[USER[id]["rank"]].lvl >= b.lvl then
			table.insert(menus, b.m)
		end
	end
	return menus
end

function GetMenu(id,b)
	return PlayerMenus(id)[b]
end

server_navigation = CreateMenu("Navigation")
function server_navigation:getcustombutton(b,id)
	local m = GetMenu(id, b)
	if m then return m.title end
end

function server_navigation:click(id,b,p)
	local m = GetMenu(id, b)
	if m then m:OpenPlayer(id, 1) end
end

addhook("serveraction","AM.Navigation")
function AM.Navigation(id,s)
	if s == 1 then
		server_navigation:OpenPlayer(id, 1)
	end
end