function GetMainScreenMenuTooltip()
	if IsReceiver("Shop mover") then
		return "ShopDoneButton"
	elseif IsReceiver("BuyTank backgroung mover") then
		return "BuyBack"
	elseif IsReceiver("Choose tank mover") then
		return "CloseChoose"
	elseif IsReceiver("Photo album mover") then
		return "ClosePhoto"
	else
		return "MainScreenMenuButton"
	end
end

function MoveMainScreenPanelsOnInactive(where)
	if IsReceiver("Choose tank mover") then
		return false
	elseif IsReceiver("Photo album mover") then
		return false
	elseif IsReceiver("HelpSmall") then
		return false
	elseif PermanentStorage.GetLocalBoolOrDef("temp:inItemBuy", false) then
		return false
	elseif PermanentStorage.GetLocalBoolOrDef("temp:Move mode", false) then
		return false
	else
		MoveMainScreenPanels(where)
		if (where == "out") then
			SendMessage("Cup alpha changer", "change alpha to 0.0")
		else
			SendMessage("Cup alpha changer", "change alpha to 1.0")
		end
		return true
	end
end

function MoveMainScreenPanels(where)
	SendMessage("Right top panel mover", "move to "..where)
	SendMessage("Left top panel mover", "move to "..where)
	SendMessage("Play panel mover", "move to "..where)
	
	if IsReceiver("Main screen shop_thoose panel mover") then
		SendMessage("Main screen shop_thoose panel mover", "move to "..where)
	elseif IsReceiver("Shop mover") then
		SendMessage("Shop mover", "move to "..where)
	end
end

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

function MoveMainScreenPanelsIn(reportArrivalTo, arrivalMessage)
	SendMessage("Screen", "template ZGlassTemplate")
	SendMessage("Screen", "create top instance")
		-- Блокировка экрана
	MoveMainScreenPanels("in")
	--SendMessage("New tank holder", "change alpha to 0.0")
	SendMessage("Cup alpha changer", "change alpha to 1.0")
end

function MainScreenFunc(message)
	if message == "Enter main screen" then
		SendMessage("Screen", "clear children list")
		SendMessage("Screen", "template MainScreenTemplate")
		SendMessage("Screen", "create top instance")
		PermanentStorage.SetLocalBool(PermanentStorage.GetLocalString("Current Tank").." ShowCupEffect", false)
		SendMessage("Cup alpha changer", "change alpha to 1.0")
		MoveMainScreenPanels("in")
		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
		TutorialFunc("Enter main screen")		
	
	elseif message == "Eye button pressed" then

		SendMessage("CSVSTATISTICS", "eye pressed")
		
		if IsReceiver("ShopTips")       then SendMessage("ShopTips", "hide") end
		if IsReceiver("SpecialMessage") then SendMessage("SpecialMessage", "hide") end
	
		SendMessage("Right top panel mover", "move to out")
		SendMessage("Left top panel mover", "move to out")		
		SendMessage("Play panel mover", "move to out")
		SendMessage("Cup alpha changer", "change alpha to 0.0")
		
		if IsReceiver("Main screen shop_thoose panel mover") then
			SendMessage("Main screen shop_thoose panel mover", "move to out")
		end
		
		if IsReceiver("Shop mover") then
			SendMessage("Shop mover", "move to out")
		end
		
		if IsReceiver("Choose tank mover") then
			SendMessage("Choose tank mover", "move to out")
			SendMessage("PlayPanel modal dialog", "hide")
			PermanentStorage.SetLocalString("temp:EyePressedFrom", "ChooseTank")
		end
		
		if IsReceiver("Photo album mover") then
			SendMessage("Photo album mover", "move to out")
			SendMessage("PlayPanel modal dialog", "hide")
			PermanentStorage.SetLocalString("temp:EyePressedFrom", "PhotoAlbum")
		end
		
		PermanentStorage.SetLocalString("Move in button mover", "in 0.4,0.4")
		PermanentStorage.SetLocalBool("temp:Move mode", true)
		LockScreen()
		SendMessage("TimedSMS", "lua:PostUnlockScreen, anyTextHere, 0.4")
        TutorialFunc("shown eye")

	elseif message == "Back button pressed" then

		PermanentStorage.SetLocalString("Move in button mover", "out")
		PermanentStorage.SetLocalBool("temp:Move mode", false)
		SendMessage("TimedSMS", "post:lua:MainScreenFunc, Back button pressed continue, 0.2")
		LockScreen()
		SendMessage("TimedSMS", "lua:PostUnlockScreen, anyTextHere, 0.5")
		
	elseif message == "Back button pressed continue" then
	
		local eyePressedFrom = PermanentStorage.GetLocalStringOrDef("temp:EyePressedFrom", "None")
		PermanentStorage.UndefLocalName("temp:EyePressedFrom")
		
		if (eyePressedFrom == "ChooseTank") then
			SendMessage("Right top panel mover", "move to in")
			SendMessage("Left top panel mover", "move to in")
			SendMessage("PlayPanel modal dialog", "instantiate ChooseTankTemplate")
			SendMessage("Choose tank mover", "move to in")
		elseif (eyePressedFrom == "PhotoAlbum") then
			SendMessage("Right top panel mover", "move to in")
			SendMessage("Left top panel mover", "move to in")
			SendMessage("PlayPanel modal dialog", "instantiate PhotoAlbumTemplate")		
			TutorialFunc("Show photoalbum")
			SendMessage("Photo album mover", "move to in")
		else
			SendMessage("Right top panel mover", "move to in")
			SendMessage("Left top panel mover", "move to in")		
			SendMessage("Play panel mover", "move to in")
			SendMessage("Cup alpha changer", "change alpha to 1.0")
			
			if IsReceiver("Main screen shop_thoose panel mover") then
				SendMessage("Main screen shop_thoose panel mover", "move to in")
			elseif IsReceiver("Shop mover") then
				SendMessage("Shop mover", "move to in")
			end
		end
				
	elseif message == "Photo button pressed" then
		LockScreen()
		SendMessage("Border alpha changer", "report arrival to lua:MainScreenFunc")
		SendMessage("Border alpha changer", "set arrival message Main screen panel invisible for screenshot")
		SendMessage("Border alpha changer", "move to out")

		SendMessage("Move alpha changer", "report arrival to lua:MainScreenFunc")
		SendMessage("Move alpha changer", "set arrival message Main screen panel invisible for screenshot")
		SendMessage("Move alpha changer", "move to out")
		
		--hideCursor() --костыль для скрытия customCursor-a при скриншоте
		
		PermanentStorage.SetLocalInt("temp:ready for screenshot", 0)
		if IsReceiver("HelpSmall alpha changer")                                      --есть туториал
			and SendMessageReply("HelpSmall", "get state") ~= "invisible"             --туториал не скрыт
			and SendMessageReply("HelpSmall alpha changer", "get state") ~= "out" then--туториал не скрыт фотоспышкой
			SendMessage("HelpSmall alpha changer", "report arrival to lua:MainScreenFunc")
			SendMessage("HelpSmall alpha changer", "set arrival message Main screen panel invisible for screenshot")
			SendMessage("HelpSmall alpha changer", "move to out")
			PermanentStorage.SetLocalInt("temp:all items for screenshot", 3)
		else
			PermanentStorage.SetLocalInt("temp:all items for screenshot", 2)
		end
		
		--сбор статистики
		SendMessage("CSVSTATISTICS", "make screenshot")

	elseif message == "Main screen panel invisible for screenshot" then
		local all   = PermanentStorage.GetLocalIntOrDef("temp:all items for screenshot", 100)
		local ready = PermanentStorage.GetLocalIntOrDef("temp:ready for screenshot", 0)+1
		if all == ready then
    		SendMessage("post:lua:MainScreenFunc", "screenshot")
		else
            PermanentStorage.SetLocalInt("temp:ready for screenshot", ready)
		end
	elseif message == "screenshot" then
	
    	Sound:PlaySample("screenshot")
		SendMessage("Screen", "template FlashTemplate")
		SendMessage("Screen", "defineText [receiver] post:lua:MainScreenFunc")
		SendMessage("Screen", "defineText [message] Main screen ready to return from screenshot")
		SendMessage("Screen", "defineText [name] Move in button mover")
		SendMessage("Screen", "create top instance")
		SendMessage("Move alpha changer", "move to in")
		SendMessage("Border alpha changer", "move to in")
		
	elseif message == "Main screen ready to return from screenshot" then
	
  		SendMessage("Screen", "erase top child"); -- удаляем верхний контрол, который должен быть FlashTemplate
  		PostUnlockScreen()
				
	elseif message == "Tank name pressed" then
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		local oldTankName = PermanentStorage.GetLocalString("Tank "..currentTank.." name")
		if IsReceiver("Shop modal dialog") then
			EditBoxDialog("Shop modal dialog", "Tank name edit"
					, "EnterTankName" 
					, 130
					, "lua:MainScreenFunc"
					, "Enter tank name dialog ok pressed" 
					, "Enter tank name dialog cancel pressed" )
		elseif IsReceiver("Main screen modal dialog") then
			EditBoxDialog("Main screen modal dialog", "Tank name edit"
					, "EnterTankName" 
					, 130
					, "lua:MainScreenFunc"
					, "Enter tank name dialog ok pressed" 
					, "Enter tank name dialog cancel pressed" )
		else
			return
		end
		SendMessage("EditBoxDialogMover", "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")
		-- Если в строке нет ни одного непустого символа, выйти
		if string.find(newTankName, "[%S]") == nil then
			return
		end
		
		PermanentStorage.SetLocalString("Tank "..currentTank.." name", newTankName)
		
		SendMessage("Tank name edit", "disable cursor")
		SendMessage("EditBoxDialogMover", "move to out")
		if IsReceiver("Shop modal dialog") then
			SendMessage("Shop modal dialog", "hide")
		elseif IsReceiver("Main screen modal dialog") then
			SendMessage("Main screen modal dialog", "hide")
		end
		SendMessage("ShopTipsManager", "Continue")
		
		if IsReceiver("ChooseTank scroll") then
			SendMessage("ChooseTank scroll", "Reset titles")
		end
		
	elseif message == "Enter tank name dialog cancel pressed" then
	
		SendMessage("Tank name edit", "disable cursor")
		SendMessage("EditBoxDialogMover", "move to out")
		if IsReceiver("Shop modal dialog") then
			SendMessage("Shop modal dialog", "hide")
		elseif IsReceiver("Main screen modal dialog") then
			SendMessage("Main screen modal dialog", "hide")
		end
		SendMessage("ShopTipsManager", "Continue")
	
	elseif message == "Main screen escape pressed" then
	
		if PermanentStorage.GetLocalBoolOrDef("temp:Move mode", false) then
			SendMessage("lua:MainScreenFunc", "Back button pressed")
		else
			SendMessage("lua:MainScreenFunc", "Main screen main menu button pressed")
		end

	elseif message == "Main screen main menu button pressed" then
	
		TutorialFunc("menu button pressed")
		
		if IsReceiver("ShopTips")       then SendMessage("ShopTips", "hide") end
		if IsReceiver("SpecialMessage") then SendMessage("SpecialMessage", "hide") end
		
		if IsReceiver("BuyTank backgroung mover") then
			SendMessage("lua:ChooseTankFunc", "BuyTank exit")
		elseif IsReceiver("Choose tank mover") then
			SendMessage("lua:ChooseTankFunc", "Choose tank cancel button pressed")
		elseif IsReceiver("Shop mover") then
			SendMessage("lua:ShopFunc", "Shop exit")
		elseif IsReceiver("Photo album mover") then
			SendMessage("lua:MainScreenFunc", "Main screen photoalbum exit button pressed")
		else
			SendMessage("Aquarium bottom", "exit from shop")
			MoveMainScreenPanels("out")
			
			SendMessage("Cup alpha changer", "change alpha to 0.0")
			SendMessage("TimedSMS", "post:lua:MainScreenFunc, Main screen panel out for main menu, 0.5")
			LockScreen()
		end
		
	elseif message == "Main screen panel out for main menu" then
			
		PostUnlockScreen() -- это так, для того, чтобы понятно было, что он всегда должен следовать после LockScreen()

		local signature = PermanentStorage.GetGlobalBool("temp:screenshotSignature")
		if signature then PermanentStorage.SetGlobalBool("temp:screenshotSignature", false) end
		Screenshot("textures\\choose_tank\\tanks\\"..
					PermanentStorage.GetLocalInt("_Id").."_tank_"..
					PermanentStorage.GetLocalString("Current Tank")..".jpg");
		if signature then PermanentStorage.SetGlobalBool("temp:screenshotSignature", signature) end

		SendMessage("post:Screen", "clear children list")
		SendMessage("post:lua:MainMenuFunc", "Enter main menu")
		
	elseif message == "Main screen shop button pressed" then
	
		SendMessage("CSVSTATISTICS", "shop pressed")
		
		PermanentStorage.SetLocalString("temp:Current mode", "shop")
		if IsReceiver("Main screen shop_thoose panel mover") then
			SendMessage("Main screen shop_thoose panel mover", "move to out")
		end
		SendMessage("TimedSMS", "post:lua:ShopFunc, Enter shop, 0.5")
		if PermanentStorage.GetLocalStringOrDef("current tutorial", "") ~= "" then
			SendMessage("TutorialControl", "hide")
		end
		LockScreen()
		
	elseif message == "Main screen choose tank button pressed" then

		SendMessage("Main screen shop_thoose panel mover", "move to out")
		SendMessage("Cup alpha changer", "change alpha to 0.0")
		SendMessage("Play panel mover", "move to out")
		
		SendMessage("TimedSMS", "post:lua:MainScreenFunc, Main screen panel out for choose tank, 0.4")
		LockScreen()
		
	elseif message == "Main screen panel out for choose tank" then
	
		PostUnlockScreen()
		SendMessage("PlayPanel modal dialog", "instantiate ChooseTankTemplate")
		SendMessage("Choose tank mover", "move to in")
		TutorialFunc("Choose tank pressed")
		
	elseif message == "Main screen play button pressed" then
		
		SendMessage("CSVSTATISTICS", "play pressed")
		
		if IsReceiver("Shop mover") then
			PermanentStorage.SetLocalString("temp:Current mode", "shop")
		else 
			PermanentStorage.SetLocalString("temp:Current mode", "menu")
		end

		MoveMainScreenPanelsOut("null", "null")
		--if PermanentStorage.GetLocalStringOrDef("current tutorial", "") == "let's play" then
			PermanentStorage.SetLocalBool("tutorial: play pressed", true)
			SendMessage("TutorialControl", "hide")
		--end
		
		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
			
		GetBackgroundHoliday() -- получили какой бэкграунд у нас будет
		SwitchTrack("Match3")
		
		SendMessage("Screen", "clear children list")
		
		SendMessage("Screen", "template GameFieldTemplate")
		-- SendMessage("Screen", "defineText [fonTextureId] fon"..PermanentStorage.GetLocalStringOrDef("Gamefield background number", "1"))
		local currentTank = PermanentStorage.GetLocalString("Current Tank")
		local tankType    = PermanentStorage.GetLocalString(currentTank.." Tank Type")
		if     tankType == "1" then 
			SendMessage("Screen", "defineText [Fish1] ".."Fish1")
			SendMessage("Screen", "defineText [Fish2] ".."Fish3")
			
		elseif tankType == "2" then
			
			SendMessage("Screen", "defineText [Fish1] ".."Fish2")
			SendMessage("Screen", "defineText [Fish2] ".."Fish3")
			
		elseif tankType == "3" then
			
			SendMessage("Screen", "defineText [Fish1] ".."Fish1")
			SendMessage("Screen", "defineText [Fish2] ".."Fish6")
		end
		SendMessage("Screen", "create top instance")
		SendMessage("Screen", "template BrighteningTemplate")
		SendMessage("Screen", "create top instance")
		SendMessage("Game field panel mover", "move to in")
		
		if not PermanentStorage.GetLocalBoolOrDef("Relax question shown", false) then
			SendMessage("GameField", "Pause")
			SendMessage("RestartContinueScreen", "instantiate ChoiseRelaxOrTimedTemplate")
			SendMessage("choise relax or timed mover", "move to in")			
			
		elseif PermanentStorage.GetLocalBoolOrDef("Need restart/continue level dialog", false) then
			SendMessage("GameField", "Pause")
			SendMessage("RestartContinueScreen", "instantiate RestartOrContinueDialogTemplate")
			SendMessage("RestartOrContinueDialog mover", "move to in")
		end
		
		SendMessage("lua:BetaFunc", "Main screen to game field")
		
	elseif message == "Main screen photoalbum button pressed" then	
	
		SendMessage("Play panel mover", "move to out")
		if IsReceiver("Main screen shop_thoose panel mover") then
			SendMessage("Main screen shop_thoose panel mover", "move to out")
		end
		SendMessage("Cup alpha changer", "change alpha to 0.0")
		SendMessage("TimedSMS", "lua:MainScreenFunc, Main screen panel out for photoalbum, 0.4")
		LockScreen()
		
		SendMessage("CSVSTATISTICS", "open photoalbum from mainscreen")
		
	elseif message == "Photoalbum button pressed" then
		
		PermanentStorage.SetLocalString("temp:PhotoAlbumPressedFrom", "Eye")
		--
		-- Если из режима глаза запустили фотоальбом, возвращаться потом в него же
		-- после выхода из режима глаза уже не нужно
		--
		if (PermanentStorage.GetLocalStringOrDef("temp:EyePressedFrom", "None") == "PhotoAlbum") then
			PermanentStorage.UndefLocalName("temp:EyePressedFrom")
		end
		--убираем панель фотоаппарата
		PermanentStorage.SetLocalString("Move in button mover", "out")
		SendMessage("PlayPanel modal dialog", "instantiate PhotoAlbumTemplate")
		TutorialFunc("Show photoalbum")
		SendMessage("Photo album mover", "move to in")
		
		SendMessage("CSVSTATISTICS", "open photoalbum from eye")

	elseif message == "Main screen panel out for photoalbum" then
		
		PostUnlockScreen()
		SendMessage("PlayPanel modal dialog", "instantiate PhotoAlbumTemplate")
		TutorialFunc("Show photoalbum")
		SendMessage("Photo album mover", "move to in")

	elseif message == "Main screen photoalbum exit button pressed" then
	
		if (PermanentStorage.GetLocalStringOrDef("temp:PhotoAlbumPressedFrom", "None") == "Eye") then
			PermanentStorage.UndefLocalName("temp:PhotoAlbumPressedFrom")
			SendMessage("Photo album mover", "move to out")
			SendMessage("PlayPanel modal dialog", "hide")
			PermanentStorage.SetLocalString("Move in button mover", "in 0.4,0.4")
			PermanentStorage.SetLocalBool("temp:Move mode", true)
		else
			SendMessage("Photo album mover", "move to out")
			SendMessage("PlayPanel modal dialog", "hide")
			SendMessage("TimedSMS", "lua:MainScreenFunc, Main screen photoalbum exit button pressed continue, 0.25")
			LockScreen()
		end

	elseif message == "Main screen photoalbum exit button pressed continue" then
	
		PostUnlockScreen()
		SendMessage("Cup alpha changer", "change alpha to 1.0")
		MoveMainScreenPanels("in")
	
	elseif message == "Main screen photoalbum delete button pressed" then
		local image = PermanentStorage.GetLocalStringOrDef("Photo album preview", "")
		if(image ~= "") then
			YesNoDialog(getModalDialog(), "ConfirmPhotoDelete"
			, "lua:MainScreenFunc"
			, "Photo delete confirmation dialog yes button pressed"
			, "Photo delete confirmation dialog no button pressed" )
		end
	
	elseif message == "Main screen photoalbum send button pressed" then
		local image = PermanentStorage.GetLocalStringOrDef("Photo album preview", "")
		if(image ~= "") then
			SendMessage("Photo album mover", "move to out")
			SendMessage("TimedSMS", "lua:MainScreenFunc, Main screen photoalbum send button pressed continue, 0.25")
		end
	
	elseif message == "Main screen photoalbum send button pressed continue" then
		SendMessage(getModalDialog(), "instantiate PhotoPreviewSendTemplate")
		SendMessage("Photo preview send sender", "set value "..PermanentStorage.GetLocalStringOrDef("Send sender", PermanentStorage.GetActivePlayerName()))
		SendMessage("Photo preview send name", "set value "..PermanentStorage.GetLocalStringOrDef("Send name", ""))
		SendMessage("Photo preview send email", "set value "..PermanentStorage.GetLocalStringOrDef("Send email", ""))
		SendMessage("Photo preview send text", "set value ".."")
		SendMessage("Photo preview send mover", "move to in")
	
	elseif message == "Photo send dialog ok button pressed" then
		Sound:PlaySample("send_letter")
		
		local image  = PermanentStorage.GetLocalStringOrDef("Photo album preview", "")
		local sender = SendMessageReply("Photo preview send sender", "get value")
		local name   = SendMessageReply("Photo preview send name", "get value")
		local email  = SendMessageReply("Photo preview send email", "get value")
		local text   = SendMessageReply("Photo preview send text", "get value")
		
		SendPostcard(image, sender, name, email, text)
		SendMessage("Photo preview send mover", "move to out")
		SendMessage(getModalDialog(), "hide")
		
		PermanentStorage.SetLocalString("Send sender", sender)
		PermanentStorage.SetLocalString("Send name", name)
		PermanentStorage.SetLocalString("Send email", email)
		
		SendMessage("lua:MainScreenFunc", "Main screen photoalbum exit button pressed")
		SendMessage("TimedSMS", "lua:MainScreenFunc, Postcard sent message, 0.25")
	
	elseif message == "Postcard sent message" then
	
		ShowHelpSmall(400, 300, "hack:Your e-mail has been sent", 1000, 1000, 0, 2.5)
	
	elseif message == "Photo send dialog cancel button pressed" then
	
		SendMessage("Photo preview send sender", "disable cursor")
		SendMessage("Photo preview send mover", "move to out")
		SendMessage(getModalDialog(), "hide")
		
		SendMessage("TimedSMS", "Photo album mover, move to in, 0.25")
		--SendMessage("lua:MainScreenFunc", "Main screen photoalbum exit button pressed")
	
	elseif message == "Ok dialog ok pressed" then
	
		SendMessage(getModalDialog(), "hide")
		
	elseif message == "Main screen photoalbum wallpaper button pressed" then
	
		local image = PermanentStorage.GetLocalStringOrDef("Photo album preview", "")
		if(image ~= "") then
			YesNoDialog(getModalDialog(), "ConfirmPhotoWallpaper"
					, "lua:MainScreenFunc"
					, "Photo wallpaper confirmation dialog yes button pressed"
					, "Photo wallpaper confirmation dialog no button pressed" )
		end
		
	elseif message == "Change photo preview dialog ok button pressed" then
	
		local image = PermanentStorage.GetLocalStringOrDef("Photo album preview", "")
		local title = SendMessageReply("Photo preview edit", "get value")
		if (title ~= "") and (image ~= "") then
			PermanentStorage.SetLocalString(image, title)
		elseif (image ~= "") then
			PermanentStorage.UndefLocalName(image);
		end
		SendMessage("Photo album scroll", "Reset titles");
		SendMessage("Photo preview edit", "disable cursor")
		SendMessage("Photo preview edit mover", "move to out")
		SendMessage("Main screen modal dialog", "hide")
		
	elseif message == "Change photo preview dialog cancel button pressed" then
	
		SendMessage("Photo preview edit", "disable cursor")
		SendMessage("Photo preview edit mover", "move to out")
		SendMessage("Main screen modal dialog", "hide")
		
	elseif message == "Photo delete confirmation dialog yes button pressed" then
	
		local image = PermanentStorage.GetLocalStringOrDef("Photo album preview", "")
		if (image ~= "") then
			SendMessage("Photo album scroll", "Delete "..image);
		end
		SendMessage(getModalDialog(), "hide")
		
	elseif message == "Photo delete confirmation dialog no button pressed" then
	
		SendMessage(getModalDialog(), "hide")
		
	elseif message == "Photo wallpaper confirmation dialog yes button pressed" then
	
		local image = PermanentStorage.GetLocalStringOrDef("Photo album preview", "")
		if(image ~= "") then
			InstallWallpaperAsBmp(image)
		end
		SendMessage(getModalDialog(), "hide")
		
	elseif message == "Photo wallpaper confirmation dialog no button pressed" then
	
		SendMessage(getModalDialog(), "hide")
		
	else
		assert(false, "Unknown message "..message)
	end
end

function getModalDialog()
	if IsReceiver("Main screen modal dialog") then
		return "Main screen modal dialog"
	end
	return "Shop modal dialog"
end

function ChoiseRelaxOrTimedFunc(message)
	if message == "Timed pressed" then
		PermanentStorage.SetLocalBool("Relaxed game mode", false)
	else
		PermanentStorage.SetLocalBool("Relaxed game mode", true)
	end
	SendMessage("choise relax or timed mover", "move to out")
	SendMessage("RestartContinueScreen", "hide")
	SendMessage("GameField", "Continue")
	PermanentStorage.SetLocalBool("Relax question shown", true)
end