
function SetupPassed()
	GetMapManager:UnloadMapByName("Intro");
	GetMapManager:UnloadMapByName("Game");
	GetMapManager:SetActiveMapByName("Passed");
	g_SmartSound:SetMusic("audio/passed.ogg", false, true);

 	GetInputManager:AddBinding("control", "OnPassedSelect", C_ENTITY_NONE);	
  GetInputManager:AddBinding("return", "OnPassedSelect", C_ENTITY_NONE);	
	
	//some cool bg visuals
	
	entWall = CreateEntity(GetMapManager:GetActiveMap(), Vector2(0,0), "entity/doomwall_attract.lua"); 	

	//give message they should see
	
	if (g_level < g_totalLevels) then
		//unlock the next level
		local entText = GetEntityByName("passed_template"):Clone(nil, Vector2(80, 285));
		entText:SetPersistent(false);	
		entText:GetBrainManager():Add("FadeIn", "fade_speed_ms=1000");		
	
		entText = GetEntityByName("unlocked_template"):Clone(nil, Vector2(287, 399));
		entText:SetPersistent(false);	
		entText:GetBrainManager():Add("FadeIn", "fade_speed_ms=1000");		
	
		UnlockLevel(g_level+1);
		g_currentMenuSelection = g_level; //default to the new unlocked level, this works because of the 1-off deal..
		
	end
	
	if (g_level == g_totalLevels) then
		//special ending message?
	
	local x;
	local y;
	local entText;
	
	for i=0,10, 1 do
	
	
	x = random(500);
	y = random(500);
	
	  entText = GetEntityByName("won1_template"):Clone(nil, Vector2(x, y));
		entText:SetPersistent(false);	
		entText:SetBaseColor(Color(255,255,255,0)); //start as invisible
	
	  Schedule(600+ (600*i), entText:GetID(), 'this:SetBaseColor(Color(255,255,255,255)); this:GetBrainManager():Add("FadeIn", "fade_speed_ms=1000");');
    Schedule(1600+ (600*i), entText:GetID(), 'this:GetBrainManager():Add("FadeOutAndDelete", "fade_speed_ms=1000");');

	end
	  
	  entText = GetEntityByName("won2_template"):Clone(nil, Vector2(100, 300));
		entText:SetPersistent(false);	
		entText:SetBaseColor(Color(255,255,255,0)); //start as invisible
	
	  Schedule(3500+ (600*10), entText:GetID(), 'this:SetBaseColor(Color(255,255,255,255)); this:GetBrainManager():Add("FadeIn", "fade_speed_ms=1000");');
    
	
	end

end

function OnPassedSelect(bKeyDown)
	if (bKeyDown) then
			GetSoundManager:Play("audio/wall_break.ogg");
				KillPassed();
				SetupMainMenu();
	
		end

	return false;  //continue to process key callbacks for this key stroke?
end


function KillPassed()

  GetInputManager:RemoveBinding("control", "OnPassedSelect", C_ENTITY_NONE);	
  GetInputManager:RemoveBinding("return", "OnPassedSelect", C_ENTITY_NONE);	
end

