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)
    
    notes_name = {}
    index_help = 0
    for i = 1, 50 do
        local name_obj = 'Notes_'..i
        if IsNotesFound(name_obj) then
            table.insert(notes_name, name_obj)
        end
    end
    index_max_help = table.maxn(notes_name)
    
    -- Установка последней страницы
    index_help = index_max_help - 1
    if #notes_name ~= 0 then
        local this_book = GetObjectNotes( notes_name[index_max_help] )
        this_book:SetOpacity(1)
    end
    
    if #notes_name >= 2 then
        OnButtonPress('')
    else
        button_previous_help:Hide()
        button_previous_help:Stop()
        button_next_help:Hide()
        button_next_help:Stop()
    end

    SetCursor(GetCursorArrow())
    PlaySound("opening_window")
    
    if HasGameState('ParticlesNotesFound', '') then
        RemoveGameState('ParticlesNotesFound', '')
    end
    play_field:GetLevelScreen():GetPanel():HideNotes()
end

function GetObjectNotes(name)
    if dialog:HasObject(name) then
        return dialog:GetObject(name)
    end
    
    local path = 'data/Texture/Screen/NotesScreen/'..name..'.png'
    local anim = CreateAnimation(path,0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	local obj = dialog:CreateObject(name,anim,512,384,112,0,1,1)
	
	return obj
end

function OnSceneFree()
    FreeData()
end

function OnScreenShown()
    SetCursor(GetCursorArrow())
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 OnToolFound(tool)
end

function OnToolApply(tool, object)
    DefaultOnToolApply(tool, object)
end

function OnPhotographing()
	DefaultOnPhotographing()
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
    
    if title == 'Close' then
        local screen = GetGameManager():GetCurrentScreen()
        screen:SetAllowInput(false)
        screen:ScreenDestroy()
        
        if play_field then
            panel:SetAllowInput(true)
            panel:GetObject('open_note'):GetAnimation():SetMode(HGEANIM_REV + HGEANIM_NOLOOP)
            panel:GetObject('open_note'):GetAnimation():Play()
            local length_anim = GetAnimationLength( panel:GetObject('open_note'):GetAnimation() )
            bttn_note:Stop()
            TimerDo(panel:GetTimer(), length_anim, function()
                                                    bttn_note:SetOpacity(1)
                                                    bttn_note:Go()
                                                   end )
            
            play_field:Go()
            play_field:GetLevelScreen():Go()
        else
            menu:SetAllowInput(true)
            menu:Go()
        end
    end
    
    if title == 'Previous' then
        local previous_book = GetObjectNotes( notes_name[index_help + 1] )
        index_help = index_help - 1
        local this_book = GetObjectNotes( notes_name[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 = GetObjectNotes( notes_name[index_help + 1] )
        index_help = index_help + 1
        local this_book = GetObjectNotes( notes_name[index_help + 1] )
        previous_book:ChangeOpacity(1, 0, 0.3)
        this_book:ChangeOpacity(0, 1, 0.2)
    end
    
    if #notes_name >= 2 then
        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
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/NotesScreen/Notes_bg.png',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Notes_bg',anim,512,384,90,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
