function OnLogoPress(widget)
	if not widget then return end
	
	local count = table.getn(g_LogosUrls)
	while count>=1 do
		if widget:GetId()=="logo"..count then
			if g_LogosUrls[count]~="" then
				ShellExecute(g_LogosUrls[count], "")
			end
			break
		end

		count = count - 1
	end
end

function AddLogos(_window, _logos)
	print("add logos")
	g_LogosUrls = {}

	local logos = g_Loader:GetTemplate(_logos)
	if not logos then 
		print("no logos found \"".._logos.."\"")
		return 
	end

	local child_iter = logos:GetFirstChild()
	while child_iter:Get() do
		local child = child_iter:Get()
		if child:Name()=="button_widget" then
			table.insert(g_LogosUrls, child:GetAttribute("url"))
			local logo = CButtonWidget(child)
			logo:SetId("logo"..table.getn(g_LogosUrls))
			_window:AddWidget(logo)
			print("added logo")
		elseif child:Name()=="logos_group" then
			local first_logo = true

			local x = 0
			if child:IsAttribute("x") then x = tonumber(child:GetAttribute("x")) end
			local y = 0
			if child:IsAttribute("y") then y = tonumber(child:GetAttribute("y")) end
			local dx = 0
			if child:IsAttribute("dx") then dx = tonumber(child:GetAttribute("dx")) end
			local align = child:GetAttribute("align")
			if align~="bottom" and align~="center" then align = "up" end
			local direction = child:GetAttribute("direction")
			if direction=="left" then direction = -1 else direction=1 end
			
			local group_iter = child:GetFirstChild()
			while group_iter:Get() do
				local logo_t = group_iter:Get()
				
				table.insert(g_LogosUrls, logo_t:GetAttribute("url"))
				local logo = CButtonWidget(logo_t)
				logo:SetId("logo"..table.getn(g_LogosUrls))

				
				if not first_logo then 
					local to_y = y
					if align=="center" then
						to_y = y - logo:GetRect().mHeight/2
					elseif align=="bottom" then
						to_y = y - logo:GetRect().mHeight
					end
					local to_x = x
					if direction==-1 then to_x = to_x - logo:GetRect().mWidth end
					logo:MoveTo(to_x, to_y)
					x = x + direction*logo:GetRect().mWidth + direction*dx
				else
					logo:MoveTo(x, y)
					if align=="center" then
						y = y + logo:GetRect().mHeight/2
					elseif align=="bottom" then
						y = y + logo:GetRect().mHeight
					end
					if direction~=-1 then x = x + logo:GetRect().mWidth end
					x = x + direction*dx
					first_logo = false
				end
				_window:AddWidget(logo)
				

				group_iter:Next()
			end
		end

		child_iter:Next()
	end
end


local infile, err = io.open("branch/branch.xml", "rb")
if infile == nil then
	return
end
infile:close()

g_Loader:LoadFile("branch/branch.xml")

g_App.mResourceManager:ParseResourcesFile("branch/branch.xml")
g_App.mResourceManager:LoadResources("Branch")

local hs = g_Loader:GetTemplate("highscore")
if hs then
	records_manager():SetUrl(hs:GetAttribute("url"))
end