function MoveChooseTankPanels(where, reportArrivalTo, arrivalMessage)
	SendMessage("Top panel mover", "report arrival to null")
	SendMessage("Top panel mover", "set arrival message null")
	SendMessage("Top panel mover", "move to "..where)
	SendMessage("Tank 1 icon mover", "report arrival to "..reportArrivalTo)
	SendMessage("Tank 1 icon mover", "set arrival message "..arrivalMessage)
	SendMessage("Tank 1 icon mover", "move to "..where)
	SendMessage("Tank 2 icon mover", "report arrival to null")
	SendMessage("Tank 2 icon mover", "set arrival message null")
	SendMessage("Tank 2 icon mover", "move to "..where)
	SendMessage("Tank 3 icon mover", "report arrival to null")
	SendMessage("Tank 3 icon mover", "set arrival message null")
	SendMessage("Tank 3 icon mover", "move to "..where)
	SendMessage("Cancel button mover", "report arrival to null")
	SendMessage("Cancel button mover", "set arrival message null")
	SendMessage("Cancel button mover", "move to "..where)
	SendMessage("Top left ball mover", "report arrival to null")
	SendMessage("Top left ball mover", "set arrival message null")
	SendMessage("Top left ball mover", "move to "..where)
	SendMessage("Top right ball mover", "report arrival to null")
	SendMessage("Top right ball mover", "set arrival message null")
	SendMessage("Top right ball mover", "move to "..where)
	SendMessage("Bottom right ball mover", "report arrival to null")
	SendMessage("Bottom right ball mover", "set arrival message null")
	SendMessage("Bottom right ball mover", "move to "..where)
end

function ChooseTankFunc(message)
	if
		message == "Choose tank tank 1 pressed" or
		message == "Choose tank tank 2 pressed" or
		message == "Choose tank tank 3 pressed"
	then
		local newTank = string.sub(message, 18, 18)
		assert(newTank == "1" or newTank == "2" or newTank == "3")
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		assert(currentTank == "1" or currentTank == "2" or currentTank == "3")
		if newTank == currentTank then
			SendMessage("lua:ChooseTankFunc", "Choose tank cancel button pressed")
				-- вызов через MessageServer для удобства отладки в VS
		else
			assert(newTank ~= currentTank)
			SendMessage("Screen", "template ZGlassTemplate")
			SendMessage("Screen", "create top instance")
				-- защита от повторного выбора
			SendMessage("Screen", "template DarkeningTemplate")
			SendMessage("Screen", "defineText [receiver] post:lua:ChooseTankFunc")
			SendMessage("Screen", "defineText [message] Choose tank darkened to change tank to "..newTank)
			SendMessage("Screen", "create top instance")
		end
	elseif
		message == "Choose tank darkened to change tank to 1" or
		message == "Choose tank darkened to change tank to 2" or
		message == "Choose tank darkened to change tank to 3"
	then
		local newTank = string.sub(message, 40, 40)
		assert(newTank == "1" or newTank == "2" or newTank == "3")
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		assert(currentTank == "1" or currentTank == "2" or currentTank == "3")
		assert(newTank ~= currentTank)
		Sound:FadeOutTrack("Menu"..currentTank, 1.0)
		Sound:FadeInTrack("Menu"..newTank, 1.0, true)
		PermanentStorage.SetLocalString("Current Tank", newTank)
		SendMessage("Screen", "clear children list")
		SendMessage("lua:MainScreenFunc", "Enter main screen")
		SendMessage("Screen", "template BrighteningTemplate")
		SendMessage("Screen", "create top instance")
	elseif message == "Choose tank cancel button pressed" then
		SendMessage("Screen", "template ZGlassTemplate")
		SendMessage("Screen", "create top instance")
			-- защита от повторного выбора
		MoveChooseTankPanels("out", "post:lua:ChooseTankFunc", "Choose tank panels out for main screen")
		SendMessage("Choose tank dialog", "hide")
	elseif message == "Choose tank panels out for main screen" then
		SendMessage("Screen", "clear children list")
		SendMessage("lua:MainScreenFunc", "Enter main screen")
	elseif message == "Choose tank help button pressed" then
		SendMessage("Choose tank modal dialog", "instantiate ChooseTankHelpTemplate")
		SendMessage("Help mover", "report arrival to null")
		SendMessage("Help mover", "set arrival message null")
		SendMessage("Help mover", "move to in")
	elseif message == "Choose tank help ok button pressed" then
		SendMessage("Choose tank 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 == "Enter choose tank" then
		-- Зануляем индикаторы, чтобы после приезда панелей показатели начали расти.
		-- Зануление нужно сделать ДО создания экземпляра ChooseTankTemplate.
		for tankId = 1, 3 do
			PermanentStorage.SetLocalFloat(tankId.." Choose tank fish indicator", 0)
			PermanentStorage.SetLocalFloat(tankId.." Choose tank beauty indicator", 0)
			PermanentStorage.SetLocalFloat(tankId.." Choose tank comfort indicator", 0)
		end
		SendMessage("Screen", "template ChooseTankTemplate")
		SendMessage("Screen", "create top instance")

		-- Эффект открытия панели - запуск перед эффектом получения кубка,
		-- потому что эффект получения кубка может изменить значение
		-- переменной  tankId.." Last choose tank cup".
		for tankId = 2, 3 do
			local lastOpen = PermanentStorage.GetLocalStringOrDef((tankId - 1).." Last choose tank cup", "None") ~= "None"
			local newOpen = PermanentStorage.GetLocalStringOrDef((tankId - 1).." Cup", "None") ~= "None"
			if newOpen and not lastOpen then
				SendMessage(tankId.." Unlocked effect", "start")
				Sound:SetLowVolumeTime(3.0, 0.4)
			else
				assert(newOpen == lastOpen)
			end
		end
		-- Эффект получения кубка.
		for tankId = 1, 3 do
			local lastCup = PermanentStorage.GetLocalStringOrDef(tankId.." Last choose tank cup", "None")
			local newCup = PermanentStorage.GetLocalStringOrDef(tankId.." Cup", "None")
			if newCup ~= lastCup then
				PermanentStorage.SetLocalString(tankId.." Last choose tank cup", newCup)
				if newCup == "Bronze" then
					SendMessage(tankId.." Bronze cup effect", "start")
				elseif newCup == "Silver" then
					SendMessage(tankId.." Silver cup effect", "start")
				elseif newCup == "Gold" then
					SendMessage(tankId.." Gold cup effect", "start")
				else
					assert(false) -- неожиданный вид кубка
				end
			end
		end
		SendMessage("Choose tank dialog", "instantiate EmptyTemplate")
			-- Просто затемнение с помощью вызова диалога
		MoveChooseTankPanels("in", "lua:ChooseTankFunc", "Choose tank panels in")
	elseif message == "Choose tank panels in" then
		-- Заполняем индикаторы значениями, до которых нужно расти.
		for tankId = 1, 3 do
			local fish = PermanentStorage.GetLocalFloatOrDef(tankId.." Fish indicator value", 0)
			PermanentStorage.SetLocalFloat(tankId.." Choose tank fish indicator", fish)
			local beauty = PermanentStorage.GetLocalFloatOrDef(tankId.." Beauty indicator value", 0)
			PermanentStorage.SetLocalFloat(tankId.." Choose tank beauty indicator", beauty)
			local comfort = PermanentStorage.GetLocalFloatOrDef(tankId.." Comfort indicator value", 0)
			PermanentStorage.SetLocalFloat(tankId.." Choose tank comfort indicator", comfort)
		end
	else
		assert(false, "Unknown message "..message)
	end
end