function OnSceneLoad(screen)
    game_state = {}    
    LoadData(screen)
    local pf = play_field
    local level = pf:GetLevelScreen()
    game_state.custom_cursors = {}
    game_state.locked_objects = {}
    --level:AddTaskSafe(CreateTask('', '', ''))
    --zone = CreateZoomZone('')
    game_state.locker = ReferenceCounter()
    game_state.active_zone = nil
    game_state.inventory_zones = {}
    game_state.active_objects = {}
	
	zoom_toolbox = CreateZoomZone('close_zone_toolbox',
                                 '',
                                 'zoom_bak',
                                 'sprait_dreli',
                                 'film',
                                 'Border')
	zoom_toolbox.SetOffsetZ(500);
	
	local object = play_field:GetObject('uniform');
	inventory_uniform = CreateInventory(object:GetX(),
                                        object:GetY(),
                                        object:GetZ() + 10,
                                        "uniform_active_zone",
                                        CreateItem('camera1', 'camera'),
                                        nil,
                                        CreateItem('film1', 'film_scaled'),
                                        play_field:GetTimer(),
										"INVENTORY_TASK_7_1");
    inventory_uniform.state_changer = "OnUniiformComplete"
    local t = CreateTool('film', 'film_scaled')
    t.OnSet = function()
	    play_field:GetObject('film_scaled'):SetOpacity(1)
	    zoom_toolbox.SetVisible(false)	    
	    game_state.locker:Release()    
	end
	
	t.OnFail = function()
	    play_field:GetObject('film_scaled'):SetOpacity(0)	    
	    play_field:ShowParticleLine(GetMouseX(),
                                    GetMouseY(),
                                    638,
                                    557,
                                    300)
	end
	
	t.OnSuccess = function()
		UnregisterZoomZone(zoom_toolbox)
	end
	
	CreateTool('camera', 'camera')		

	inventory_uniform.OnCompleteImmediate = function()
	    --game_state.locked_objects['tool_box_zone'] = true
	end
	
	inventory_uniform.OnShown = function()
		RegisterZoomZone(zoom_toolbox, 'tool_box_zone')
	end
	
	--ShowComics();
	inventory_uniform.OnComplete = function()
		if play_field:HasObject('uniform') then
			play_field:GetObject('uniform'):ChangeOpacity(1, 0, 0.3)
			play_field:GetObject('uniform_active_zone'):ChangeOpacity(1, 0, 0.3)
			play_field:GetObject('picture'):ChangeOpacity(0, 1, 0.3)
			game_state.locker:AddRef()
			local s = CreateSoundEntity("7_TakePhoto")
			s:AttachTo(play_field)
			s:Play(false)
		end
	end
	
    play_field:GetObject('picture'):SetOpacity(0)
	play_field:GetObject('picture'):SetZ(10000)
	
	level:AddTaskSafe(CreateTask('PHOTO', '', 'picture')); 
	
	AddRandomTasks(17,	
			   CreateTask('AXE', '', 'axe'),
			   CreateTask('BAT1', '', 'bat'),
			   CreateTask('BELL', '', 'bell'),
			   CreateTask('BELT', '', 'belt'),
			   CreateTask('CHAIN', '', 'chain'),
			   CreateTask('FLASK', '', 'flask'),
               CreateTask('HAMMER', '', 'hammer'),
			   CreateTask('HORSESHOE', '', 'horseshoe'),
			   CreateTask('IRON', '', 'iron'),
			   CreateTask('KNIFE', '', 'knife'),
			   CreateTask('MOUSETRAP', '', 'mousetrap'),
			   CreateTask('MUSHROOM', '', 'mushroom'),
			   CreateTask('RAKE', '', 'rake'),
			   CreateTask('RAPIER', '', 'rapier'),
			   CreateTask('ROPE', '', 'rope'),
			   CreateTask('SKATES', '', 'skates'),
			   CreateTask('SOCK', '', 'sock'),
			   CreateTask('TAPE_MEASURE', '', 'tape_measure'),
			   CreateTask('WHISTLE', '', 'whistle')
    )
	
	InitChain1(screen);
	game_state.chain1.state_changer = "OnStartingComicsComplete"
    InitChain2(screen);
    InitChain3(screen);
	game_state.chain3.final = true
    
    AddSheriffEyeLogic();
	AddSMEyeLogic();
    
    game_state.minigame_complete = false    
    
    play_field:GetObject('picture'):GetAnimation():SetColor('0xFFFFFFFF')
	
	game_state.meta_object = 'cigar7'
	game_state.OnUniiformComplete = function()
	    if play_field:HasObject('picture') then
            play_field:GetObject('uniform'):SetOpacity(0)
            play_field:GetObject('uniform_active_zone'):SetOpacity(0)
            play_field:GetObject('picture'):SetOpacity(1)
            game_state.locker:AddRef()
	    end
	end
	
	game_state.OnStartingComicsComplete = function()
		RegisterZoomZone(zoom_toolbox, 'tool_box_zone')
		inventory_uniform.Unlock()
	end
	
	game_state.OnMinigameConditionsComplete = function()
	    if game_state.do_not_load_mini_game then
	        return
	    end
	    load_screen('data/Scenes/Minigames/7_clothes.lua');
	end		
	
	game_state.CheckWinConditions = function()
	    if game_state.minigame_finished then
            if IsNotebookClosed() and ArePanelTasksComplete() then
                game_state.chain3.Start()
            end
        end
	end
	
	game_state.OnPhotoFound = function()
	    if GetProfileManager():GetCurrentProfile():CallsFunction('OnMinigameConditionsComplete') then
	        return
	    end
        game_state.chain2.Start()	    
	end
	
	game_state.minigame_finished = false
end

function OnSceneFree(screen)
    FreeData(screen)
end

function OnScreenShown()
	game_state.chain1.Start();
end

function OnLostFocus()
end

function OnGainFocus()
end

function OnMinigameCompleted()
    game_state.minigame_finished = true
    if IsNotebookClosed() and ArePanelTasksComplete() then
        game_state.chain3.Start()
    end    
end

------------------------------------------------------------------------------------------------------------------
--Comics
function InitChain1(screen)
     local comics3 = CreateComics(screen,                                 
                                 'Service_Manager',
								 'SMMask',
								 'eyes_sm')
								 
    comics3.OnHidden = function()
		comics3.DefaultOnHidden()
		inventory_uniform.Unlock()
    end
    
    game_state.chain1 = CreateChain('pixel1',
                                    screen,
                                    comics3, GetString("COMICS_7_1"))
end

function InitChain2(screen)
    local comics1 = CreateComics(screen,                                 
                                 'Sheriff',
								 'eyes')
                                 
     local comics2 = CreateComics(screen,                                  
                                 'Service_Manager',
								 'SMMask',
								 'eyes_sm')
                                 
    local comics3 = CreateComics(screen,                                 
                                 'Sheriff',
								 'eyes')

    AddSheriffEyeLogic()    
    
    game_state.chain2 = CreateChain('pixel2',
                                    screen,
                                    comics1, GetString("COMICS_7_2"),
                                    comics2, GetString("COMICS_7_3"),
                                    comics3, GetString("COMICS_7_4"))
                                    
	comics3.OnHidden = function()
		game_state.locker:Release();
		GetProfileManager():GetCurrentProfile():AddStateChanger('OnMinigameConditionsComplete')
		load_screen('data/Scenes/Minigames/7_clothes.lua');      
    end
end

function InitChain3(screen)
     local comics1 = CreateComics(screen,                                 
                                 'Sheriff',
								 'eyes')
                                 
    comics1.OnHidden = function()
        OnWin()
    end
    
    game_state.chain3 = CreateChain('pixel3',
                                    screen,
                                    comics1, GetString("COMICS_7_6"))
end

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

function OnUpdate(dt)
end

function OnNotebookClosed()    
    game_state.chain3.Start()    
end

function OnNotebookOpened()
end


function OnExit()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

function OnObjectMouseDown(object)
    obj_name = object:GetName()
    if obj_name == 'picture' and object:GetOpacity() == 1 then
        play_field:OnObjectFound(object)
    end
    local pf = play_field
    local is_wrong_click = true

    is_wrong_click = DefaultOnObjectMouseDown(object)

    if is_wrong_click then
        --pf:ShowWrongObjectEffect()
    end

    return is_wrong_click;    
end

function OnObjectMouseUp(object)
end

function OnObjectWasFound(object)
    if object:GetName() == 'picture' then
        if game_state.locker:GetNReferences() > 0 then
            game_state.locker:Release()
        end        
        game_state.chain2.Start();
    end
end

function OnObjectWillBeFound(object)
    if object:GetName() == 'picture' then
        GetProfileManager():GetCurrentProfile():AddStateChanger('OnPhotoFound')
    end
    if not play_field:GetLevelScreen():HasTaskObjects() then
		GetProfileManager():GetCurrentProfile():AddStateChanger('CheckWinConditions')
	end
end

function OnToolFound(tool)
end

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

function OnObjectReachPanel(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
end

function OnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
end

function CanBeHinted(obj)
    if locked_object[obj] ~= true then
        return true
    else
        return false
    end
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/7_ locker_room_repairers_3/Layers/bg.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bg',anim,512,384,9,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/picture.png',0,0,514,770,1,0)
	anim:SetHotSpot(257,385)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('picture',anim,512,384,400,0,0.8,0.8)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Zoom/zoom_bak.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('zoom_bak',anim,512,384,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Zoom/film.png',0,0,62,77,1,0)
	anim:SetHotSpot(31,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('film',anim,711,289,201,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Zoom/film.png',0,0,62,77,1,0)
	anim:SetHotSpot(31,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('film_scaled',anim,27,29,201,0,0.5,0.5)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Zoom/film.png',0,0,62,77,1,0)
	anim:SetHotSpot(31,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('film1',anim,27,29,201,0,0.5,0.5)
	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('tool_box_zone',anim,630,566,100,0,10,10)
	local anim = CreateAnimation('data/Texture/Comics/Sheriff.dds',0,0,532,636,1,0)
	anim:SetHotSpot(266,256)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Sheriff',anim,734,390,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('pixel1',anim,512,384,401,0,128,96)
	local anim = CreateAnimation('data/Texture/Comics/eyes.png',0,0,79,33,1,0)
	anim:SetHotSpot(39,16)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('eyes',anim,725,213,500,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('pixel2',anim,512,384,401,0,128,96)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('pixel3',anim,512,384,401,0,128,96)
	local anim = CreateAnimation('data/Texture/Comics/Service_Manager.dds',0,0,661,696,1,0)
	anim:SetHotSpot(330,348)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('Service_Manager',anim,521,422,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Comics/SMmask.png',0,0,203,61,1,0)
	anim:SetHotSpot(101,30)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('SMMask',anim,544,161,410,0,1,1)
	local anim = CreateAnimation('data/Texture/Comics/eyes_sm.png',0,0,142,22,1,0)
	anim:SetHotSpot(71,11)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('eyes_sm',anim,729,163,405,0,1,1)
	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('uniform_active_zone',anim,867,546,110,0,26,19)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/hammer.png',0,0,150,76,1,0)
	anim:SetHotSpot(75,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('hammer',anim,897,731,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/tape_measure.png',0,0,48,44,1,0)
	anim:SetHotSpot(24,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('tape_measure',anim,378,584,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/uniform.png',0,0,244,183,1,0)
	anim:SetHotSpot(122,91)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('uniform',anim,876,559,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/camera.png',0,0,86,99,1,0)
	anim:SetHotSpot(43,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('camera',anim,952,353,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/camera.png',0,0,86,99,1,0)
	anim:SetHotSpot(43,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('camera1',anim,296,79,100,0,0.8,0.8)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/axe.png',0,0,83,144,1,0)
	anim:SetHotSpot(41,72)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('axe',anim,968,126,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/bat.png',0,0,57,172,1,0)
	anim:SetHotSpot(28,86)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bat',anim,323,423,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Layers/sprait_skameyki.png',0,0,63,73,1,0)
	anim:SetHotSpot(31,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('sprait_skameyki',anim,327,467,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/belt.png',0,0,49,120,1,0)
	anim:SetHotSpot(24,60)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('belt',anim,230,362,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/butterfly.png',0,0,34,25,1,0)
	anim:SetHotSpot(17,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('butterfly',anim,708,528,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/chain.png',0,0,60,237,1,0)
	anim:SetHotSpot(30,118)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('chain',anim,1010,305,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/flask.png',0,0,67,34,1,0)
	anim:SetHotSpot(33,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('flask',anim,507,511,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/horseshoe.png',0,0,40,44,1,0)
	anim:SetHotSpot(20,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('horseshoe',anim,779,90,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/iron.png',0,0,79,93,1,0)
	anim:SetHotSpot(39,46)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('iron',anim,864,355,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/knife.png',0,0,65,16,1,0)
	anim:SetHotSpot(32,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('knife',anim,601,318,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/mousetrap.png',0,0,46,24,1,0)
	anim:SetHotSpot(23,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mousetrap',anim,896,456,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/bell.png',0,0,45,25,1,0)
	anim:SetHotSpot(22,12)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('bell',anim,644,415,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/mushroom.png',0,0,57,46,1,0)
	anim:SetHotSpot(28,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('mushroom',anim,373,755,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/rake.png',0,0,42,148,1,0)
	anim:SetHotSpot(21,74)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('rake',anim,319,209,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/rapier.png',0,0,46,169,1,0)
	anim:SetHotSpot(23,84)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('rapier',anim,718,490,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Layers/sprait_shelf.png',0,0,226,32,1,0)
	anim:SetHotSpot(113,16)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('sprait_shelf',anim,878,208,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Layers/rapier_over.png',0,0,46,39,1,0)
	anim:SetHotSpot(23,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('rapier_over',anim,742,549,106,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/rope.png',0,0,52,126,1,0)
	anim:SetHotSpot(26,63)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('rope',anim,857,118,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Items/skates.png',0,0,66,54,1,0)
	anim:SetHotSpot(33,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('skates',anim,792,423,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Layers/uniform_over.png',0,0,62,76,1,0)
	anim:SetHotSpot(31,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('uniform_over',anim,791,498,106,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Zoom/sprait_dreli.png',0,0,82,81,1,0)
	anim:SetHotSpot(41,40)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('sprait_dreli',anim,702,310,203,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/cigar7.png',0,0,94,108,1,0)
	anim:SetHotSpot(47,54)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('cigar7',anim,577,513,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/7_ locker_room_repairers_3/Animations/voda.png',0,0,282,220,25,10)
	anim:SetHotSpot(141,110)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('voda',anim,620,140,100,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
