function LogoExists(aName)
    local name = "splash/"..aName;    
    if( FileExists(name) )then
        return name;
    else
        return "";
    end
end

-- Main game loop
function Main()
    --[[
    logos=
    {
        "playfirst_logo",
        "merscom_splash",
        "absolutist_splash",
        "distributor_logo",
    };
    
    for i=1, table.getn(logos) do
        local name = LogoExists(logos[i]..".jpg");
        local aname = LogoExists(logos[i].."_animated.swf");
        if(name~="" or aname~="")then
            DisplaySplash(aname, name,2000);
        end
    end
	--]]
	DisplaySplash("splash/playfirst_logo_animated.swf", "splash/playfirst_logo", 2000);
	DisplaySplash("splash/merscom_splash_animated.swf", "splash/merscom_splash", 2000);
	DisplaySplash("splash/absolutist_splash_animated.swf", "splash/absolutist_splash", 2000);
	DisplaySplash("splash/distributor_logo_animated.swf", "splash/distributor_logo", 2000);
  
    
    StartUpLoading = true;
	DoModal("scripts/preload.lua");
	
	while (true) do
		-- Push the game selection screen
		DoModal("scripts/mainmenu.lua");
		-- The game select screen will spawn its own replacement modal window. When that modal window
		-- returns, it will be time to execute this one again--hence the while/do loop.
	end

end

-- Return a function to be executed in a thread
return Main