function MoveShopPanels(where, reportArrivalTo, arrivalMessage)
	SendMessage("Shop mover", "report arrival to "..reportArrivalTo)
	SendMessage("Shop mover", "set arrival message "..arrivalMessage)
	SendMessage("Shop mover", "move to "..where)
	SendMessage("Shop eye button mover", "report arrival to null")
	SendMessage("Shop eye button mover", "set arrival message null")
	SendMessage("Shop eye button mover", "move to "..where)
	SendMessage("Shop left top panel mover", "report arrival to null")
	SendMessage("Shop left top panel mover", "set arrival message null")
	SendMessage("Shop left top panel mover", "move to "..where)
	SendMessage("Shop right top panel mover", "report arrival to null")
	SendMessage("Shop right top panel mover", "set arrival message null")
	SendMessage("Shop right top panel mover", "move to "..where)
end

function ShopFunc(message)
	if message == "Won a cup" then
		SendMessage("Screen", "template ZGlassTemplate")
		SendMessage("Screen", "create top instance")
		local tankId = PermanentStorage.GetLocalString("Current Tank")
		PermanentStorage.SetLocalBool(tankId.." ShowCupEffect", true)
		SendMessage("Won cup reminder", "set delay 2.0")
		SendMessage("Won cup reminder", "set message Won a cup after block")
		SendMessage("Won cup reminder", "report to lua:ShopFunc")

		SendMessage("Fish indicator", "freeze 1.0")
		SendMessage("Beauty indicator", "freeze 1.0")
		SendMessage("Comfort indicator", "freeze 1.0")
	elseif message == "Won a cup after block" then
		SendMessage("Screen", "template BeforeWonCupTemplate")
		SendMessage("Screen", "create top instance")
		SendMessage("Screen", "template ZGlassTemplate")
		SendMessage("Screen", "create top instance")
		SendMessage("before won cup", "show")
		MoveShopPanels("out", "null", "null")
		SendMessage("Shop cup alpha changer", "change alpha to 0.0")
		SendMessage("Won cup reminder", "set delay 5.0")
		SendMessage("Won cup reminder", "set message Won a cup after pause")
		SendMessage("Won cup reminder", "report to lua:ShopFunc")
	elseif message == "Won a cup after pause" then
		SendMessage("Screen", "erase top child")
			-- ZGlass
		SendMessage("Screen", "erase top child")
			-- BeforeWonCup
		SendMessage("Screen", "erase top child")
			-- ZGlass
		local tankId = PermanentStorage.GetLocalString("Current Tank")
		local cup = PermanentStorage.GetLocalString(tankId.." Cup")
		local templateName = nil
		if cup == "Bronze" and (tankId == "1" or tankId == "2") then
			templateName = "WonNotLastBronzeCupTemplate"
		elseif cup == "Bronze" and (tankId == "3") then
			templateName = "WonLastBronzeCupTemplate"
		elseif cup == "Silver" then
			templateName = "WonASilverCupTemplate"
		elseif cup == "Gold" then
			local cup1 = PermanentStorage.GetLocalString("1 Cup")
			local cup2 = PermanentStorage.GetLocalString("2 Cup")
			local cup3 = PermanentStorage.GetLocalString("3 Cup")
			if cup1 == "Gold" and cup2 == "Gold" and cup3 == "Gold" then
				templateName = "WonLastGoldCupTemplate"
			else
				templateName = "WonNotLastGoldCupTemplate"
			end
		else
			assert(false, "tankId="..tankId.." cup="..cup)
		end
		assert(templateName ~= nil)
		SendMessage("Shop modal dialog", "instantiate "..templateName)
		SendMessage("Cup panel mover", "report arrival to null")
		SendMessage("Cup panel mover", "set arrival message null")
		SendMessage("Cup panel mover", "move to in")
		if PermanentStorage.GetGlobalBoolOrDef("betaLog", false) then
			local player = PermanentStorage.GetActivePlayerName()
			WriteToLogColor("Player '"..player.."' won "..cup.." cup in tank "..tankId, "Red")
			SendMessage("post:lua:BetaFunc", "Duplicate player won cup")
			SendMessage("post:lua:BetaFunc", "Clear cup time")
		end
		Sound:SetLowVolumeTime(6.0, 0.4)
	elseif message == "Won cup panel stay in shop button pressed" then
		SendMessage("Fish indicator", "unfreeze")
		SendMessage("Beauty indicator", "unfreeze")
		SendMessage("Comfort indicator", "unfreeze")
		SendMessage("Cup panel mover", "report arrival to null")
		SendMessage("Cup panel mover", "set arrival message null")
		SendMessage("Cup panel mover", "move to out")
		SendMessage("Shop modal dialog", "hide")
		MoveShopPanels("in", "null", "null")
		SendMessage("Shop cup alpha changer", "change alpha to 1.0")
		SendMessage("CupRenderElement", "EffectShow")
		PermanentStorage.SetLocalBool(PermanentStorage.GetLocalString("Current Tank").." ShowCupEffect", false)
	elseif message == "Won cup panel choose tank button pressed" then
		SendMessage("Screen", "template ZGlassTemplate")
		SendMessage("Screen", "create top instance")
			-- Блокировка экрана
		SendMessage("Cup panel mover", "report arrival to null")
		SendMessage("Cup panel mover", "set arrival message null")
		SendMessage("Cup panel mover", "move to out")
		SendMessage("Shop modal dialog", "hide")
		MoveShopPanels("out", "post:lua:ShopFunc", "Shop panel out for choose tank")
	elseif message == "Shop panel out for choose tank" then
		SendMessage("Screen", "clear children list")
		SendMessage("lua:ChooseTankFunc", "Enter choose tank")
	elseif message == "Shop done button pressed" then
		if TutorialFunc("Shop done button pressed") then
			return
		end
		SendMessage("Screen", "template ZGlassTemplate")
		SendMessage("Screen", "create top instance")
			-- Блокировка экрана
		MoveShopPanels("out", "post:lua:ShopFunc", "Shop panel out for main screen")
		SendMessage("Move items message mover", "report arrival to null")
		SendMessage("Move items message mover", "set arrival message null")
		SendMessage("Move items message mover", "move to out")
		SendMessage("Move in button mover", "report arrival to null")
		SendMessage("Move in button mover", "set arrival message null")
		SendMessage("Move in button mover", "move to out")
			-- на всякий случай, если были в режиме перетаскивания
		SendMessage("Shop cup alpha changer", "change alpha to 0.0")
	elseif message == "Shop move button pressed" then
		SendMessage("Screen", "template ZGlassTemplate")
		SendMessage("Screen", "create top instance")
			-- Блокировка экрана
		SendMessage("Shop eye button mover", "report arrival to null")
		SendMessage("Shop eye button mover", "set arrival message null")
		SendMessage("Shop eye button mover", "move to out")
		SendMessage("Shop left top panel mover", "report arrival to null")
		SendMessage("Shop left top panel mover", "set arrival message null")
		SendMessage("Shop left top panel mover", "move to out")
		SendMessage("External shop mover", "report arrival to post:lua:ShopFunc")
		SendMessage("External shop mover", "set arrival message Shop panels out for move mode")
		SendMessage("External shop mover", "move to out")
	elseif message == "Shop panels out for move mode" then
		SendMessage("Screen", "erase top child")
			-- ZGlass
		SendMessage("Move items message mover", "report arrival to null")
		SendMessage("Move items message mover", "set arrival message null")
		SendMessage("Move items message mover", "move to in")
		SendMessage("Move in button mover", "report arrival to null")
		SendMessage("Move in button mover", "set arrival message null")
		SendMessage("Move in button mover", "move to in")
	elseif message == "Shop move mode done button pressed" then
		SendMessage("Move items message mover", "report arrival to null")
		SendMessage("Move items message mover", "set arrival message null")
		SendMessage("Move items message mover", "move to out")
		SendMessage("Move in button mover", "report arrival to lua:ShopFunc")
		SendMessage("Move in button mover", "set arrival message Move mode panels out for shop")
		SendMessage("Move in button mover", "move to out")
	elseif message == "Move mode panels out for shop" then
		SendMessage("Shop eye button mover", "report arrival to null")
		SendMessage("Shop eye button mover", "set arrival message null")
		SendMessage("Shop eye button mover", "move to in")
		SendMessage("Shop left top panel mover", "report arrival to null")
		SendMessage("Shop left top panel mover", "set arrival message null")
		SendMessage("Shop left top panel mover", "move to in")
		SendMessage("External shop mover", "report arrival to null")
		SendMessage("External shop mover", "set arrival message null")
		SendMessage("External shop mover", "move to in")
	elseif message == "Shop panel out for main screen" then
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		SendMessage("Screen", "clear children list")
		PermanentStorage.SetLocalString("temp:Tutorial main screen panels in after", "shop")
		SendMessage("lua:MainScreenFunc", "Enter main screen")
		SendMessage(currentTank.." Aquarium bottom", "leaved shop")
		SendMessage("lua:BetaFunc", "Shop to main screen")
	elseif message == "Shop eye button pressed" then
		SendMessage("Screen", "template ZGlassTemplate")
		SendMessage("Screen", "create top instance")
			-- Блокировка экрана
		MoveShopPanels("out", "post:lua:ShopFunc", "Shop panel out for eye")
		SendMessage("Shop cup alpha changer", "change alpha to 0.0")
	elseif message == "Shop panel out for eye" then
		SendMessage("Screen", "clear children list")
		SendMessage("Screen", "template TankOnlyTemplate")
		SendMessage("Screen", "defineText [variable] Current Tank")
		SendMessage("Screen", "defineText [exitMessageReceiver] post:lua:ShopFunc")
		SendMessage("Screen", "defineText [exitMessage] Tank only to shop")
		SendMessage("Screen", "create top instance")
	elseif message == "Tank only to 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")
	elseif message == "Shop help button pressed" then
		SendMessage("Shop modal dialog", "instantiate ShopHelpTemplate")
		SendMessage("Help mover", "report arrival to null")
		SendMessage("Help mover", "set arrival message null")
		SendMessage("Help mover", "move to in")
	elseif message == "Shop help ok button pressed" then
		SendMessage("Shop modal dialog", "hide")
		SendMessage("Help mover", "report arrival to null")
		SendMessage("Help mover", "set arrival message null")
		SendMessage("Help mover", "move to out")
	elseif string.sub(message, 1, 15) == "First got 100% " then
		local prefix = string.sub(message, 16)
		SendMessage("100 percents holder", "template "..prefix.."100PercentsTemplate");
		SendMessage("100 percents holder", "create top instance");
		SendMessage("100 percents alpha changer", "change alpha to 1.0");
		SendMessage("100 percents reminder", "set delay 8.0");
		SendMessage("100 percents reminder", "set message change alpha to 0.0");
		SendMessage("100 percents reminder", "report to 100 percents alpha changer");
	else
		assert(false, "Unknown message "..message)
	end
end