
function GalleryRelease()
	ReleaseResource("ANIMATION_PANEL")
	ReleaseResource("ANIMATION_FADE")
	local animWidget = GUI:getLayer("Gallery"):getWidget("Mult")
	animWidget:AcceptMessage(Message("BlackScreen", 1))
	animWidget:AcceptMessage(Message("Active", 0))
	animWidget:AcceptMessage(Message("ReleaseResources"))
end

function PlayGalleryMult(multId)
	local animWidget = GUI:getLayer("Gallery"):getWidget("Mult")
	
	SetArtefactScene(multId)

	animWidget:AcceptMessage(Message("ReleaseResources"))
	animWidget:AcceptMessage(Message("BlackScreen", 0))
	animWidget:AcceptMessage(Message("Play", MultName[multId]))
	animWidget:AcceptMessage(Message("UploadResources"))
	animWidget:AcceptMessage(Message("Reset"))
	animWidget:AcceptMessage(Message("Active", 1))
	
	--GUI:getLayer("Gallery"):getWidget("zCaption"):AcceptMessage(Message("SetString", fieldNames[multId]))

end

-- Галерея мультиков
function GalleryFunc(message)

	local animWidget = GUI:getLayer("Gallery"):getWidget("Mult")
	local needPlay = message:getIntegerParam()

	if needPlay == 1 then

		animWidget:AcceptMessage(Message("Visible", 1))

	        if message:is("Phoenicia", "press") then
			PlayGalleryMult(1)

		elseif message:is("Babylon", "press") then
			PlayGalleryMult(2)

		elseif message:is("Egypt", "press") then
			PlayGalleryMult(3)

		elseif message:is("Carthage", "press") then
			PlayGalleryMult(4)

		elseif message:is("Rome", "press") then
			PlayGalleryMult(5)

		elseif message:is("Greece", "press") then
			PlayGalleryMult(6)

		elseif message:is("Troy", "press") then
			PlayGalleryMult(7)
		end

	elseif needPlay == 0 then

	        if message:is("Phoenicia", "press") then
	        	Sound:FadeOutTagTracks("Animation", 0.5)
			--GUI:getLayer("Gallery"):getWidget("zCaption"):AcceptMessage(Message("SetString", fieldNames[1]))
			animWidget:AcceptMessage(Message("Visible", 0))

		elseif message:is("Babylon", "press") then
			Sound:FadeOutTagTracks("Animation", 0.5)
			--GUI:getLayer("Gallery"):getWidget("zCaption"):AcceptMessage(Message("SetString", fieldNames[2]))
			animWidget:AcceptMessage(Message("Visible", 0))

		elseif message:is("Egypt", "press") then
			Sound:FadeOutTagTracks("Animation", 0.5)
			--GUI:getLayer("Gallery"):getWidget("zCaption"):AcceptMessage(Message("SetString", fieldNames[3]))
			animWidget:AcceptMessage(Message("Visible", 0))

		elseif message:is("Carthage", "press") then
			Sound:FadeOutTagTracks("Animation", 0.5)
			--GUI:getLayer("Gallery"):getWidget("zCaption"):AcceptMessage(Message("SetString", fieldNames[4]))
			animWidget:AcceptMessage(Message("Visible", 0))

		elseif message:is("Rome", "press") then
			Sound:FadeOutTagTracks("Animation", 0.5)
			--GUI:getLayer("Gallery"):getWidget("zCaption"):AcceptMessage(Message("SetString", fieldNames[5]))
			animWidget:AcceptMessage(Message("Visible", 0))

		elseif message:is("Greece", "press") then
			Sound:FadeOutTagTracks("Animation", 0.5)
			--GUI:getLayer("Gallery"):getWidget("zCaption"):AcceptMessage(Message("SetString", fieldNames[6]))
			animWidget:AcceptMessage(Message("Visible", 0))

		elseif message:is("Troy", "press") then
			Sound:FadeOutTagTracks("Animation", 0.5)
			--GUI:getLayer("Gallery"):getWidget("zCaption"):AcceptMessage(Message("SetString", fieldNames[7]))
			animWidget:AcceptMessage(Message("Visible", 0))
		end
	end


	if message:is("Return", "press") then
		param = VariableSet()
		--animWidget:AcceptMessage(Message("ReleaseResources"))
		param:setString("Layer1", "Menu")
		param:setString("CrossHandler", "GalleryRelease")
		kernel:addController(controlFactory:Create("CrossFade", param))
		Sound:FadeOutTagTracks("Animation", 0.5)
		SetHiscoreActive(1)
	end

end

