dofile('data/lua/screens/Strategy GuideMap.lua');

--------------------------------------------------------------------------------
function ShowStartegyGuideScreen()
	if (EXTRAS_DUILD or EXTRAS_BUILD) then
	    CreateStartegyGuideScreen();
	end
end

-- auxiliary functions ---------------------------------------------------------

local SCREEN_CENTER = {1024.0/2.0, 768.0/2.0};
local ZOOM_POSITION = {0, -45};
local ZOOM_SCALE	= 1.072;

local SCREEN_SCALE = 150.0/640.0;
local function auxGetScreenPos(row, column)
	local originPos = {269, -137};
	local colOffsets = {165, 165, 165};
	local rowOffsets = {127, 127, 125};

	return {originPos[1] - column * colOffsets[column + 1], 
			originPos[2] + row * rowOffsets[row + 1]};
end

local auxChangeOpacityWithDelay = function(object, startOpacity, endOpacity, duration, delay)
	local auxMakeSpriteInvisible = function(sprite)
		assert(sprite);
		sprite:SetVisible(false);
		sprite:Hide();
	end
	assert(object);	
	
    local eff = CreateAnimationEffector();
	eff:AttachTo(object);
	eff:SetKey(_TRACK_O, 0.0,       startOpacity);
	if (delay and delay > 0) then
		eff:SetKey(_TRACK_O, delay,     startOpacity);
	end
	eff:SetKey(_TRACK_O, duration,  endOpacity);
	eff:Play();

	if (endOpacity == 0.0) then
		TimerDo(GM:GetTimer(), duration, auxMakeSpriteInvisible, object);
	else
		object:SetVisible(true);
		object:Show();
	end
end

local zoomedObjectInfo = nil;

local function auxZoomObjectIn(object, duration)
	assert(object and zoomedObject == nil);
	duration = (duration ~= nil and duration or 0.35);

	local x,y,z = object:GetX(), object:GetY(), object:GetZ();
	local scale = object:GetScale();
	local targetX, targetY = unpack(ZOOM_POSITION);
	local targetScale = ZOOM_SCALE;

	zoomedObjectInfo = {};
	zoomedObjectInfo.x,
	zoomedObjectInfo.y,
	zoomedObjectInfo.z,
	zoomedObjectInfo.scale = x, y, z, scale;

	object:SetZ(z + 10.0);
	object:SetVisible(true);
	do
	    local eff = CreateAnimationEffector();
		eff:AttachTo(object);
		eff:SetKey(_TRACK_S, 0.0,       scale);
		eff:SetKey(_TRACK_S, duration,  targetScale);

		eff:SetKey(_TRACK_X, 0.0,       x);
		eff:SetKey(_TRACK_Y, 0.0,       y);
		eff:SetKey(_TRACK_X, duration,  targetX);
		eff:SetKey(_TRACK_Y, duration,  targetY);

		eff:SetKey(_TRACK_O, 0.0,       0.0);
		eff:SetKey(_TRACK_O, duration,  1.0);
		eff:Play();
	end
end

local function auxZoomObjectOut(object, duration)
	assert(object and zoomedObjectInfo);

	local x,y = object:GetX(), object:GetY();
	local scale = object:GetScale();
	local targetX,targetY = zoomedObjectInfo.x, zoomedObjectInfo.y;
	local targetScale =  zoomedObjectInfo.scale;
	duration = (duration ~= nil and duration or 0.35);

	do
	    local eff = CreateAnimationEffector();
		eff:AttachTo(object);
		eff:SetKey(_TRACK_S, 0.0,       scale);
		eff:SetKey(_TRACK_S, duration,  targetScale);

		eff:SetKey(_TRACK_X, 0.0,       x);
		eff:SetKey(_TRACK_Y, 0.0,       y);
		eff:SetKey(_TRACK_X, duration,  targetX);
		eff:SetKey(_TRACK_Y, duration,  targetY);

		eff:SetKey(_TRACK_O, 0.0,       1.0);
		eff:SetKey(_TRACK_O, duration,  0.0);
		eff:Play();		
	end
	TimerDo(GM:GetTimer(), duration, function (obj, z)
										assert(obj);
										obj:SetZ(z);
										obj:SetVisible(false);
									 end, object, zoomedObjectInfo.z);

	zoomedObjectInfo = nil;
end

local function auxDeactivateButton(button, fadeDuration)
    assert(button);
	fadeDuration = (fadeDuration == nil and 3.0 or fadeDuration);
    
	button:Stop();
    local auxEnableButton = function(button)
        button:Go();
	end
	TimerDo(GM:GetTimer(), fadeDuration, auxEnableButton, button);
end
--------------------------------------------------------------------------------
class 'CGuidePages'

function CGuidePages:__init(screen, parent)
	assert(screen and parent);
	self.screen = screen;
	self.parent = parent;
	self.map = {};
	self.activePageIndex = nil;
	self.zoomedScreen = nil;

	self:BuildContentMap();
	self:ShowPage(0);
end

function CGuidePages:ShowPage(pageIndex)
	assert(self.map and pageIndex and type(pageIndex) == 'number');
	local FADE_DURATION = 0.3;

	if (self.activePageIndex == pageIndex) then
		return;
	end
	--assert(self.activePageIndex ~= pageIndex);

	if (self.activePageIndex) then
		assert(self.map[self.activePageIndex].bgImage);
		auxChangeOpacityWithDelay(self.map[self.activePageIndex].bgImage, 1.0, 0.0, FADE_DURATION);
	end

	self.activePageIndex = pageIndex;

	if (self.map[self.activePageIndex].bgImage == nil) then
		assert(self.screen and self.parent);
		local page = self.map[self.activePageIndex];
--		local screen = self.screen;
		assert(page.bgImageFileName);

		local bgImage = self.screen:CreateAnimation(page.bgImageFileName);
		bgImage:AttachTo(self.parent);
--		bgImage:SetPosXY(SCREEN_CENTER[1], SCREEN_CENTER[2]);
		bgImage:SetHotSpot(800.0/2.0, 600.0/2.0);
		bgImage:SetPosZ(100.0);
		bgImage:SetOpacity(0.0);
		bgImage:SetVisible(false);

		page.bgImage = bgImage;
		if (pageIndex ==  0) then
			self:CreateContentButtons(page.bgImage);
		end

		if (page.screens) then
			for _,screen in pairs(page.screens) do
				assert(screen.screenRow and screen.screenCol and screen.screenImageFileName and not screen.screenImage);

				local imagePos = auxGetScreenPos(screen.screenRow, screen.screenCol);
				local image = self.screen:CreateAnimation(screen.screenImageFileName);
				image:AttachTo(bgImage);
				image:SetPosXY(imagePos[1], imagePos[2]);
				image:SetHotSpot(640.0/2.0, 480.0/2.0);
				image:SetPosZ(10.0);
				image:SetScale(SCREEN_SCALE);
				image:SetOpacity(0.0);
				image:SetVisible(false);

				screen.screenImage = image;
			end
		end
	end

	auxChangeOpacityWithDelay(self.map[self.activePageIndex].bgImage, 0.0, 1.0, FADE_DURATION);
end

function CGuidePages:CreateContentButtons(contentPageBackgroundImage)
	assert(contentPageBackgroundImage);

	local contentButtonsOrigPos = {-150, -140};
	local contentButtonsDistance = 320;
	local contentButtonCountInColumn = 5;
	local highlightColor = '0xFFF2A5A5';

	local buttonCount = 0;
	local auxCreateContentButton = function(parent, caption, onClickEventHandler)
		assert(parent);
		local rowNumber = (buttonCount / contentButtonCountInColumn >= 1.0 and 1 or 0);
		local columnNumber = buttonCount % contentButtonCountInColumn;
		local x, y = contentButtonsOrigPos[1] + rowNumber * contentButtonsDistance, contentButtonsOrigPos[2] + columnNumber * 52;
		local width, height = 200, 50;

	    button = MakeButton(x, y, width, height);
		button:DisableIfHidden(true);
		button:AttachTo(parent);
	    
--// (!) rect corrections beacause of ...
		local scrX, scrY = button:GetScrX(), button:GetScrY();
		button:SetRect(scrX - width / 2, scrY - height / 2, width, height);

	    button:GetCaption():SetFont(INGAME_MENU_FONT);
	    button:GetCaption():SetHighlightColor(highlightColor);
	    button:SetZ(60.0);	--// (!) above the screens buttons

	    button:SetActionSound('Menu_button_click');
	    button:SetTitle(caption);
	    button:SetAction(onClickEventHandler);
	auxDeactivateButton(button);

		buttonCount = buttonCount + 1;
	end

	local contentPage = contentPageBackgroundImage;
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_INTRO'),		'OnGoToIntroductionFirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_1'),	'OnGoToChapter1FirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_2'),	'OnGoToChapter2FirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_3'),	'OnGoToChapter3FirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_4'),	'OnGoToChapter4FirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_5'),	'OnGoToChapter5FirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_6'),	'OnGoToChapter6FirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_7'),	'OnGoToChapter7FirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_8'),	'OnGoToChapter8FirstPage');
	auxCreateContentButton(contentPage, GetString('GAMEGUIDE_CHAPTER_9'),	'OnGoToChapter9FirstPage');
end

function OnGoToIntroductionFirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(1); end
function OnGoToChapter1FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(5); end
function OnGoToChapter2FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(15); end
function OnGoToChapter3FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(17); end
function OnGoToChapter4FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(23); end
function OnGoToChapter5FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(30); end
function OnGoToChapter6FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(34); end
function OnGoToChapter7FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(40); end
function OnGoToChapter8FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(61); end
function OnGoToChapter9FirstPage() assert(strategyGuideScreen); strategyGuideScreen.pages:ShowPage(65); end

function CGuidePages:BuildContentMap()
	assert(self.map and table.getn(self.map) == 0);

	self.map = auxCreateStrategyGuideContentMap();
end

function CGuidePages:ZoomActivePageScreenIn(screenRow, screenCol)
	assert(self.map and self.activePageIndex and not self.zoomedScreen);

	local activePage = self.map[self.activePageIndex];
	assert(activePage);

	if (activePage.screens) then
		for _,screen in pairs(activePage.screens) do
			if (screen.screenCol == screenCol and screen.screenRow == screenRow) then
				assert(screen.screenImage);

				self.zoomedScreen = screen.screenImage;
				auxZoomObjectIn(self.zoomedScreen);
				return true;
			end
		end
	end
	return false;
end

function CGuidePages:ZoomActivePageScreenOut()
	assert(self.zoomedScreen);

	if (self.zoomedScreen) then
		auxZoomObjectOut(self.zoomedScreen);
		self.zoomedScreen = nil;
		return true;
	end
	return false;
end

--------------------------------------------------------------------------------

function CreateStartegyGuideScreen()
	strategyGuideScreen = nil;

    local GUI_CONTROLS_Z_OFFSET = 50.0;
	local screen = CreateScreen();
	screen:SetName('StrategyGuideScreen');
	screen:SetLayer(POPUP_WINDOWS_LAYER);

	local title = screen:CreateAnimation('data/Texture/GUI/Strategy Guide/title.png');
	title:SetHotSpot(400, 300);
	title:SetPosXY(SCREEN_CENTER[1], SCREEN_CENTER[2]);
	title:SetPosZ(GUI_CONTROLS_Z_OFFSET + 300.0);
	auxChangeOpacityWithDelay(title, 1.0, 0.0, 3.0, 1.5);

	local bgFog = screen:CreateAnimation('data/Texture/Scenes/Common/fade.png');
	bgFog:SetHotSpot(512.0/2.0, 384.0/2.0);
	bgFog:SetPosXY(512, 384);
	bgFog:SetPosZ(-1);
	bgFog:SetScale(2.0);
	bgFog:SetOpacity(0.75);

	local bg = screen:CreateAnimation('data/Texture/GUI/Strategy Guide/background.png');
	bg:SetHotSpot(400, 300);
	bg:SetPosXY(SCREEN_CENTER[1], SCREEN_CENTER[2]);
	bg:SetPosZ(0);
	auxChangeOpacityWithDelay(bg, 0.0, 1.0, 2.0, 1.0);

	do
		local bottomPanel = screen:CreateAnimation('data/Texture/GUI/Strategy Guide/UIBG.png');
		bottomPanel:SetHotSpot(400, 50);
		bottomPanel:SetPosXY(0, 250); --(SCREEN_CENTER[1], SCREEN_CENTER[2] + 250);
		bottomPanel:SetPosZ(200.0);
		bottomPanel:AttachTo(bg);

		local buttonsPosition = {180, 0};
    	do
    	    local button = MakeButton(buttonsPosition[1], buttonsPosition[2] - 20.0, 110, 60);
			button:DisableIfHidden(true);
    	    button:GetCaption():SetFont(BUTTONS_FONT);
    		button:GetCaption():SetScale(0.8);
    		button:SetZ(GUI_CONTROLS_Z_OFFSET);
    	
    		button:AttachTo(bottomPanel);
    		button:SetAction('OnHomeButtonPressed');
    		button:SetSpriteUp('GuideHomeButton');
    		button:SetSpriteOver('GuideHomeButtonOver');
    		button:SetSpriteDown('GuideHomeButtonDown');
    		button:SetActionSound('Menu_button_click');
    		auxDeactivateButton(button);
    	end
    	do
    	    local button = MakeButton(buttonsPosition[1] - 110, buttonsPosition[2], 110, 60);
			button:DisableIfHidden(true);
    	    button:GetCaption():SetFont(BUTTONS_FONT);
    		button:GetCaption():SetScale(0.8);
    		button:SetZ(GUI_CONTROLS_Z_OFFSET);
    	
    		button:AttachTo(bottomPanel);
    		button:SetAction('OnBackButtonPressed');
    		button:SetSpriteUp('GuideBackButton');
    		button:SetSpriteOver('GuideBackButtonOver');
    		button:SetSpriteDown('GuideBackButtonDown');
    		button:SetActionSound('Menu_button_click');
    		auxDeactivateButton(button);    		
    	end
    	do
    	    local button = MakeButton(buttonsPosition[1] + 110, buttonsPosition[2], 110, 60);
			button:DisableIfHidden(true);
    	    button:GetCaption():SetFont(BUTTONS_FONT);
    		button:GetCaption():SetScale(0.8);
    		button:SetZ(GUI_CONTROLS_Z_OFFSET);
    	
    		button:AttachTo(bottomPanel);
    		button:SetAction('OnNextButtonPressed');
    		button:SetSpriteUp('GuideNextButton');
    		button:SetSpriteOver('GuideNextButtonOver');
    		button:SetSpriteDown('GuideNextButtonDown');
    		button:SetActionSound('Menu_button_click');
    		auxDeactivateButton(button);    		
    	end
	end
	do
		local auxCreateScreenButton = function(parent, row, column, 
                                               onClickEventHandler,
                                               onEnterEventHandler,
                                               onLeaveEventHandler)
			assert(parent);

            local position = auxGetScreenPos(row, column);
	   	    local button = MakeButton(position[1], position[2], 150, 133);
			button:SetName(tostring(row)..tostring(column));
			button:DisableIfHidden(true);
	   	    button:GetCaption():SetFont(BUTTONS_FONT);
	   		button:GetCaption():SetScale(0.8);
	   		button:SetZ(GUI_CONTROLS_Z_OFFSET);
			button:SetOpacity(0.1); --// (!) to make buttons unnoticeable
    	
	   		button:AttachTo(parent);
	   		button:SetAction(onClickEventHandler);
	   		button:SetSpriteUp('ScreenButton');
	   		button:SetSpriteOver('ScreenButton');
	   		button:SetSpriteDown('ScreenButton');
	   		button:SetActionSound('Menu_button_click');
            button:SetEventHandlerOnEnter(onEnterEventHandler);
	   		button:SetEventHandlerOnLeave(onLeaveEventHandler);

			return button;
		end
		local auxCreateFullscreenButton = function(parent, onClickEventHandler)
			assert(parent);

	   	    local button = MakeButton(1024.0/2.0, 768.0/2.0, 1024, 768);
			button:DisableIfHidden(true);
	   	    button:GetCaption():SetFont(BUTTONS_FONT);
	   		button:GetCaption():SetScale(0.8);
	   		button:SetZ(GUI_CONTROLS_Z_OFFSET + 10);

	   		button:AttachTo(parent);
	   		button:SetAction(onClickEventHandler);
	   		button:SetActionSound('Menu_button_click');
	   		button:Stop();

			return button;
		end

	screen.screenButtons = {};
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 0,0, 'OnScreenClick00', 'OnScreenEnter00', 'OnScreenLeave'));
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 0,1, 'OnScreenClick01', 'OnScreenEnter01', 'OnScreenLeave'));
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 0,2, 'OnScreenClick02', 'OnScreenEnter02', 'OnScreenLeave'));
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 1,0, 'OnScreenClick10', 'OnScreenEnter10', 'OnScreenLeave'));
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 1,1, 'OnScreenClick11', 'OnScreenEnter11', 'OnScreenLeave'));
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 1,2, 'OnScreenClick12', 'OnScreenEnter12', 'OnScreenLeave'));
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 2,0, 'OnScreenClick20', 'OnScreenEnter20', 'OnScreenLeave'));
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 2,1, 'OnScreenClick21', 'OnScreenEnter21', 'OnScreenLeave'));
		table.insert(screen.screenButtons, auxCreateScreenButton(bg, 2,2, 'OnScreenClick22', 'OnScreenEnter22', 'OnScreenLeave'));
	screen.fullscreenButton = auxCreateFullscreenButton(bg, 'OnFullscreenClick');
	end
   	do
   	    local button = MakeButton(330, -220, 66, 66);
		button:DisableIfHidden(true);
   	    button:GetCaption():SetFont(BUTTONS_FONT);
   		button:GetCaption():SetScale(0.8);
   		button:SetZ(GUI_CONTROLS_Z_OFFSET);
		button:SetScale(0.6);
    	
   		button:AttachTo(bg);
   		button:SetAction('CloseStartegyGuideScreen');
   		button:SetSpriteUp('CloseGuideButton');
   		button:SetSpriteOver('CloseGuideButtonOver');
   		button:SetSpriteDown('CloseGuideButtonDown');
   		button:SetActionSound('Menu_button_click');
   		auxDeactivateButton(button);
   	end
	
	screen.pages = CGuidePages(screen, bg);
    PopUpScreensMgr:Push(screen);

strategyGuideScreen = screen;
end

function CloseStartegyGuideScreen()
	PopCurrentPopUpScreen();
end

function SetScreenButtonsActive(state)
	assert(type(state) == 'boolean');
	assert(strategyGuideScreen and strategyGuideScreen.screenButtons);

	for _,button in pairs(strategyGuideScreen.screenButtons) do
		if (state) then
			button:Go();
		else
			button:Stop();
		end
	end
end

function SetFullScreenButtonActive(state)
	assert(type(state) == 'boolean');
	assert(strategyGuideScreen and strategyGuideScreen.fullscreenButton);

	if (state) then
		strategyGuideScreen.fullscreenButton:Go();
	else
		strategyGuideScreen.fullscreenButton:Stop();
	end
end

-- Event handlers ------------------------------------------------------------
function auxCloseZoomedPage()
	if (zoomedObjectInfo) then
		OnFullscreenClick();
	end
end

function OnHomeButtonPressed()
	assert(strategyGuideScreen);

	if (strategyGuideScreen.pages.activePageIndex ~= 0) then
		auxCloseZoomedPage();
		strategyGuideScreen.pages:ShowPage(0);
	end
end

function auxGetPageNumber(currentPage, forward)
    local skipPageNumbers = {[54] = true};
    local nextPage = currentPage + (forward and 1 or -1);
    if (skipPageNumbers[nextPage]) then
        nextPage = nextPage + (nextPage - currentPage);
    end
    return nextPage;
end

function OnBackButtonPressed()
	assert(strategyGuideScreen and strategyGuideScreen.pages.activePageIndex);

	if (strategyGuideScreen.pages.activePageIndex > 0) then
		auxCloseZoomedPage();
		local newPageIndex = auxGetPageNumber(strategyGuideScreen.pages.activePageIndex, false);    --strategyGuideScreen.pages.activePageIndex - 1;
		strategyGuideScreen.pages:ShowPage(newPageIndex);
	end
end

function OnNextButtonPressed()
	assert(strategyGuideScreen and strategyGuideScreen.pages.activePageIndex);

	if (strategyGuideScreen.pages.activePageIndex < #strategyGuideScreen.pages.map) then
		auxCloseZoomedPage();
		local newPageIndex = auxGetPageNumber(strategyGuideScreen.pages.activePageIndex, true);     --strategyGuideScreen.pages.activePageIndex + 1;
		strategyGuideScreen.pages:ShowPage(newPageIndex);
	end
end


function OnScreenEnter00() OnScreenEnter(0,0); end
function OnScreenEnter01() OnScreenEnter(0,1); end
function OnScreenEnter02() OnScreenEnter(0,2); end
function OnScreenEnter10() OnScreenEnter(1,0); end
function OnScreenEnter11() OnScreenEnter(1,1); end
function OnScreenEnter12() OnScreenEnter(1,2); end
function OnScreenEnter20() OnScreenEnter(2,0); end
function OnScreenEnter21() OnScreenEnter(2,1); end
function OnScreenEnter22() OnScreenEnter(2,2); end

function OnScreenEnter(row, column)
	assert(strategyGuideScreen and strategyGuideScreen.pages.activePageIndex);

	local activePage = strategyGuideScreen.pages.map[strategyGuideScreen.pages.activePageIndex];
	assert(activePage);

	if (activePage.screens) then
		for _,screen in pairs(activePage.screens) do
			if (screen.screenCol == column and screen.screenRow == row) then
				SetCursor("CursorGlass");
				return;
			end
		end

		SetCursor("CursorDefault");
	end
end

function OnScreenLeave()
	SetCursor("CursorDefault");
end


function OnScreenClick00() OnScreenClick(0,0); end
function OnScreenClick01() OnScreenClick(0,1); end
function OnScreenClick02() OnScreenClick(0,2); end
function OnScreenClick10() OnScreenClick(1,0); end
function OnScreenClick11() OnScreenClick(1,1); end
function OnScreenClick12() OnScreenClick(1,2); end
function OnScreenClick20() OnScreenClick(2,0); end
function OnScreenClick21() OnScreenClick(2,1); end
function OnScreenClick22() OnScreenClick(2,2); end

function OnScreenClick(row, column)
	assert(strategyGuideScreen and strategyGuideScreen.pages.activePageIndex);

	if (strategyGuideScreen.pages:ZoomActivePageScreenIn(row, column)) then
		SetScreenButtonsActive(false);
		SetFullScreenButtonActive(true);
	end
end

function OnFullscreenClick()
	assert(strategyGuideScreen and strategyGuideScreen.fullscreenButton);

	if (strategyGuideScreen.pages:ZoomActivePageScreenOut()) then
		SetScreenButtonsActive(true);
		SetFullScreenButtonActive(false);
	end
end
