-- Main game loop
function Main()

	local iCounter = 1;
	
	-- Display the publisher splash('s)
	while true do
		if not FileExists("publisher/publisher_"..tostring(iCounter)..".swf") then
			break;
		end

		DisplaySplash(
			"publisher/publisher_"..tostring(iCounter)..".swf",
			"publisher/publisher_"..tostring(iCounter), 4000
			);

		iCounter = iCounter + 1;
	end
	FileExists = nil;
	
	-- display the BlueLizardGamesSplash stuff
	DisplaySplash(
		"splash/blg.swf",
		"splash/blg",4000
		);


	-- Push the game selection screen
	while true do
		DoMainWindow("scripts/windows/wndmainmenu.lua");
		-- DoMainWindow will exit only if there are NO windows pushed on the stack, so
		-- a PopModal()/PushModal() combination will not cause this to loop.
	end
	
	PostMessage(CreateNamedMessage(kQuitNow, "Quit"));

end

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