function MoveMainScreenPanels(where, reportArrivalTo, arrivalMessage)
	SendMessage("Main screen eye button mover", "report arrival to null")
	SendMessage("Main screen eye button mover", "set arrival message null")
	SendMessage("Main screen eye button mover", "move to "..where)
	SendMessage("Main screen right top panel mover", "report arrival to null")
	SendMessage("Main screen right top panel mover", "set arrival message null")
	SendMessage("Main screen right top panel mover", "move to "..where)
	SendMessage("Main screen left top panel mover", "report arrival to null")
	SendMessage("Main screen left top panel mover", "set arrival message null")
	SendMessage("Main screen left top panel mover", "move to "..where)
	SendMessage("Main screen blue panel mover", "report arrival to null")
	SendMessage("Main screen blue panel mover", "set arrival message null")
	SendMessage("Main screen blue panel mover", "move to "..where)
	SendMessage("Main screen bottom panel mover", "report arrival to "..reportArrivalTo)
	SendMessage("Main screen bottom panel mover", "set arrival message "..arrivalMessage)
	SendMessage("Main screen bottom panel mover", "move to "..where)
end

--
-- Помимо вывода панелей - ещё установка ZGlass и уход в альфу кое-каких элементов.
--
function MoveMainScreenPanelsOut(reportArrivalTo, arrivalMessage)
	SendMessage("Screen", "template ZGlassTemplate")
	SendMessage("Screen", "create top instance")
		-- Блокировка экрана
	MoveMainScreenPanels("out", reportArrivalTo, arrivalMessage)
	SendMessage("New tank holder", "change alpha to 0.0")
	SendMessage("Main screen cup alpha changer", "change alpha to 0.0")
end

function MainScreenFunc(message)
	if message == "Enter main screen" then
		SendMessage("Screen", "template MainScreenTemplate")
		SendMessage("Screen", "create top instance")
		SendMessage("CupRenderElement", "EffectShow")
		PermanentStorage.SetLocalBool(PermanentStorage.GetLocalString("Current Tank").." ShowCupEffect", false)
		MoveMainScreenPanels("in", "lua:TutorialFunc", "Main screen panels in")
		SendMessage("Main screen cup alpha changer", "change alpha to 1.0")
		do
			local lastOpen = PermanentStorage.GetLocalStringOrDef("Last main screen cup", "None") ~= "None"
			local newOpen = PermanentStorage.GetLocalStringOrDef("1 Cup", "None") ~= "None"
			if newOpen and not lastOpen then
				SendMessage("New tank holder", "change alpha to 1.0")
			else
				assert(newOpen == lastOpen)
			end
			PermanentStorage.SetLocalString("Last main screen cup", PermanentStorage.GetLocalString("1 Cup"))
		end
	elseif message == "Main screen eye button pressed" then
		MoveMainScreenPanelsOut("post:lua:MainScreenFunc", "Main screen panel out for eye")
	elseif message == "Main screen panel out for eye" then
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		SendMessage("Screen", "clear children list")
		SendMessage("Screen", "template TankOnlyTemplate")
		SendMessage("Screen", "defineText [variable] Current Tank")
		SendMessage("Screen", "defineText [exitMessageReceiver] post:lua:MainScreenFunc")
		SendMessage("Screen", "defineText [exitMessage] Tank only to main screen")
		SendMessage("Screen", "create top instance")
		SendMessage(currentTank.." Aquarium bottom", "leaved shop")
	elseif message == "Tank only to main screen" then
		SendMessage("Screen", "clear children list")
		SendMessage("lua:MainScreenFunc", "Enter main screen")
	elseif message == "Main screen tank name pressed" then
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		local oldTankName = PermanentStorage.GetLocalString("Tank "..currentTank.." name")
		SendMessage("Main screen modal dialog", "instantiate TankNameEditTemplate")
		SendMessage("Tank name mover", "report arrival to null")
		SendMessage("Tank name mover", "set arrival message null")
		SendMessage("Tank name mover", "move to in")
		SendMessage("Tank name edit", "set value "..oldTankName)
		SendMessage("ShopTipsManager", "Pause")
	elseif message == "Enter tank name dialog ok pressed" then
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		local newTankName = SendMessageReply("Tank name edit", "get value")
		PermanentStorage.SetLocalString("Tank "..currentTank.." name", newTankName)
		SendMessage("Tank name edit", "disable cursor")
		SendMessage("Tank name mover", "report arrival to null")
		SendMessage("Tank name mover", "set arrival message null")
		SendMessage("Tank name mover", "move to out")
		SendMessage("Main screen modal dialog", "hide")
		SendMessage("ShopTipsManager", "Continue")
	elseif message == "Enter tank name dialog cancel pressed" then
		SendMessage("Tank name edit", "disable cursor")
		SendMessage("Tank name mover", "report arrival to null")
		SendMessage("Tank name mover", "set arrival message null")
		SendMessage("Tank name mover", "move to out")
		SendMessage("Main screen modal dialog", "hide")
		SendMessage("ShopTipsManager", "Continue")
	elseif message == "Main screen help button pressed" then
		SendMessage("Main screen modal dialog", "instantiate MainScreenHelpTemplate")
		SendMessage("Help mover", "report arrival to null")
		SendMessage("Help mover", "set arrival message null")
		SendMessage("Help mover", "move to in")
	elseif message == "Main screen help ok button pressed" then
		SendMessage("Main screen modal dialog", "hide")
		SendMessage("Help mover", "report arrival to null")
		SendMessage("Help mover", "set arrival message null")
		SendMessage("Help mover", "move to out")
	elseif message == "Main screen main menu button pressed" then
		MoveMainScreenPanelsOut("post:lua:MainScreenFunc", "Main screen panel out for main menu")
		if IsReceiver("ShopTips") then
			SendMessage("ShopTips", "hide")
		end
	elseif message == "Main screen panel out for main menu" then
		SendMessage("Screen", "clear children list")
		SendMessage("lua:MainMenuFunc", "Enter main menu")
	elseif message == "Main screen shop button pressed" then
		if TutorialFunc("Main screen shop button pressed") then
			return
		end
		MoveMainScreenPanelsOut("post:lua:MainScreenFunc", "Main screen panel out for shop")
	elseif message == "Main screen panel out for shop" then
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		SendMessage("Screen", "clear children list")
		SendMessage("Screen", "template Aquarium"..currentTank.."Template")
		SendMessage("Screen", "create top instance")

		MoveShopPanels("in", "null", "null")
		SendMessage("Shop cup alpha changer", "change alpha to 1.0")
		SendMessage(currentTank.." Aquarium bottom", "entered shop")

		SendMessage("lua:TutorialFunc", "Main screen panel out for shop")

		SendMessage("lua:BetaFunc", "Main screen to shop")
	elseif message == "Main screen choose tank button pressed" then
		MoveMainScreenPanelsOut("post:lua:MainScreenFunc", "Main screen panel out for choose tank")
	elseif message == "Main screen panel out for choose tank" then
		SendMessage("Screen", "clear children list")
		SendMessage("lua:ChooseTankFunc", "Enter choose tank")
	elseif message == "Main screen play button pressed" then
		if PermanentStorage.GetLocalBoolOrDef("Need restart/continue level dialog", false) then
			SendMessage("Screen", "template RestartOrContinueDialogTemplate")
			SendMessage("Screen", "create top instance")
			SendMessage("RestartOrContinueDialog mover", "report arrival to null")
			SendMessage("RestartOrContinueDialog mover", "set arrival message null")
			SendMessage("RestartOrContinueDialog mover", "move to in")
		else
			SendMessage("lua:MainScreenFunc", "Main screen to game field")
		end
	elseif message == "Main screen restart button pressed" then
		PermanentStorage.SetLocalBool("Restart level", true)
		SendMessage("lua:MainScreenFunc", "Main screen to game field")
	elseif message == "Main screen continue button pressed" then
		PermanentStorage.SetLocalBool("Restart level", false)
		SendMessage("lua:MainScreenFunc", "Main screen to game field")
	elseif message == "Main screen to game field" then
		if TutorialFunc("Main screen to game field") then
			return
		end
		MoveMainScreenPanelsOut("null", "null")
		SendMessage("Screen", "template DarkeningTemplate")
		SendMessage("Screen", "defineText [receiver] post:lua:MainScreenFunc")
		SendMessage("Screen", "defineText [message] Main screen darkened for game field")
		SendMessage("Screen", "create top instance")
	elseif message == "Main screen darkened for game field" then
		Sound:FadeOutTrack("Menu"..PermanentStorage.GetLocalString("Current Tank"), 1.0)
		Sound:FadeInTrack(PermanentStorage.GetLocalStringOrDef("Track in game", "Game1"), 3.0, true)
		SendMessage("Screen", "clear children list")
		SendMessage("Screen", "template GameFieldTemplate")
		SendMessage("Screen", "defineText [fonTextureId] fon"..PermanentStorage.GetLocalStringOrDef("Gamefield background number", "1"))
		SendMessage("Screen", "create top instance")
		SendMessage("Screen", "template BrighteningTemplate")
		SendMessage("Screen", "create top instance")
		SendMessage("Game field panel mover", "report arrival to null")
		SendMessage("Game field panel mover", "set arrival message null")
		SendMessage("Game field panel mover", "move to in")
		SendMessage("lua:BetaFunc", "Main screen to game field")
	else
		assert(false, "Unknown message "..message)
	end
end