function OnSceneLoad(screen)
    LoadData(screen)

    dialog = screen
    dialog:SetAllowInput(true)
    button_previous_help =    create_button_ex(screen, 'data/Texture/GUI/Button/button_previous.png', 'Previous', 165, 674, 120)
    button_previous_help:SetRect(-66, -17, 132, 34)
    button_next_help     =    create_button_ex(screen, 'data/Texture/GUI/Button/button_next.png', 'Next', 915, 674, 120)
    button_next_help:SetRect(-52, -17, 104, 34)
	local button_close   =    create_button_ex(screen, 'data/Texture/GUI/Button/button_close.png', 'Close', 941, 90, 120)
	button_close:SetRect(-17, -17, 34, 34)
	
    screen:GetObject('help_1'):SetOpacity(1)
    screen:GetObject('help_2'):SetOpacity(0)
    index_help = 0
    index_max_help = 2
    
    OnButtonPress('')
    PlaySound("opening_window")
end

function OnSceneFree()
    FreeData()
end

function OnScreenShown()
end

function OnUpdate(dt)
    DefaultOnUpdate(dt)
end

function OnLose()
end

function OnExit()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

function OnButtonMouseEnter(title)
end

function OnButtonMouseLeave(title)
end

function OnObjectMouseDown(object)
end

function OnObjectMouseUp(object)
end

function OnObjectRightMouseDown(object)
end

function OnObjectRightMouseUp(object)
end

function OnObjectFound(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
    
    if title == 'Close' then
        dialog:SetAllowInput(false)
        dialog:ScreenDestroy()
        dialog = nil
        
        if play_field then
            panel:SetAllowInput(true)
            
            play_field:Go()
            play_field:GetLevelScreen():Go();
        else
            menu:SetAllowInput(true)
            menu:Go()
        end
    end
    
    if title == 'Previous' then
        local previous_book = dialog:GetObject('help_' .. index_help + 1);
        index_help = index_help - 1;
        local this_book = dialog:GetObject('help_' .. index_help + 1);
        previous_book:ChangeOpacity(1., 0., 0.3);
        this_book:ChangeOpacity(0, 1, 0.2)
    end
    
    if title == 'Next' then
        local previous_book = dialog:GetObject('help_' .. index_help + 1);
        index_help = index_help + 1;
        local this_book = dialog:GetObject('help_' .. index_help + 1);
        previous_book:ChangeOpacity(1., 0., 0.3);
        this_book:ChangeOpacity(0., 1., 0.2);
    end
    
    if index_help == 0 then
        button_next_help:Show();    
        button_next_help:Go();
        
        button_previous_help:Hide();    
        button_previous_help:Stop();
    elseif index_help == index_max_help - 1 then
        button_next_help:Hide();    
        button_next_help:Stop();
        
        button_previous_help:Show();    
        button_previous_help:Go();
    else
        button_next_help:Show();    
        button_next_help:Go();
        
        button_previous_help:Show();    
        button_previous_help:Go();
    end
end

function OnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
end

function OnMinigameCompleted()
end

function OnLostFocus()
end

function OnGainFocus()
end

-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('pixel',anim,512,385,70,0,128,96)
	local anim = CreateAnimation('data/Texture/Screen/HelpScreen/help_1.png',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('help_1',anim,512,384,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Screen/HelpScreen/help_2.png',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('help_2',anim,512,384,105,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
