-- animations -----------------------------------------------------------------
dofile('data/Scripts/scenes/09_doctor/anim/09_doctor_anim_bg.lua')
dofile('data/Scripts/scenes/09_doctor/anim/09_doctor_anim_doors.lua')
dofile('data/Scripts/scenes/09_doctor/anim/09_doctor_anim_z_table.lua')
dofile('data/Scripts/scenes/09_doctor/anim/09_doctor_anim_z_dummy.lua')
dofile('data/Scripts/scenes/09_doctor/anim/09_doctor_anim_z_stand_turtle.lua')
dofile('data/Scripts/scenes/09_doctor/anim/09_doctor_anim_z_stand_clock.lua')

-- animations -----------------------------------------------------------------
dofile('data/Scripts/scenes/09_doctor/comics/09_doctor_comics_dupin_on_enter.lua')
dofile('data/Scripts/scenes/09_doctor/comics/09_doctor_comics_dupin_after_note.lua')

-- scene ----------------------------------------------------------------------
class 'l_09_doctor' (LevelEventHandler)

function l_09_doctor:__init(name)
	LevelEventHandler.__init(self, name)
	
	MakeSoundEntity('09_doctor_idle'):PlaySound(true)
	
	-- animations ----------------------------------
	self.anim_bg = AnimationBundle(Loader_09_BG_Animations(Object('bg')))
	self.anim_bg:PlayAnimation('front')
	self.anim_bg:PlayAnimation('back')
	
	Object('doors_anchor'):GetAnimation():SetColor('0x00FFFFFF')
	self.anim_doors = AnimationBundle(Loader_09_Doors_Animations(Object('doors_anchor')))
	self.anim_doors:GetAnimation('doors'):SetVisible(true)
	self.anim_doors:GetAnimation('doors'):GetElementByName('Layer_1'):SetOpacity(0)
	self.anim_doors:GetAnimation('doors'):GetElementByName('Layer_2'):SetOpacity(0)
	
	self.sound_doors = MakeSoundEntity('09_doors')
	
    local function playDoors()
        if not HasActionCompletedState('standDoorOpened') then
            if self.zoom_stand and not self.zoom_stand:IsVisible() then
                self.anim_doors:PlayAnimation('doors')
                
                self.sound_doors:StopSound()
                self.sound_doors:PlaySound(false)
            end
            
            local minTime = 1
            local maxTime = 10
            local delay = minTime + math.random() * (maxTime - minTime)
            
            self.timer:Add( function()
                                playDoors()
                            end,
                            self.anim_doors:GetAnimation('doors'):GetDuration() + delay)
        end
    end
    
    playDoors()
	
	-- link scenes ---------------------------------
	LinkScene('area_link_08', 'CursorDoorDown',   'l_08_street')
	
	-- main logic ----------------------------------
	ObjectOpacity('layer_right_door_open', 0)
	ObjectOpacity('layer_left_door_open',  0)
	-------------------------
	
	ObjectVisible('area_zoom_cabinet_top',    false)
    ObjectVisible('area_zoom_cabinet_bottom', false)
    ObjectVisible('area_link_ho',             false)
	-------------------------
	
	local function registerLinkHo()
	    LinkScene('area_link_ho', 'CursorGlass', 'l_09_doctor_ho', nil, nil, true)
	    
	    if IsToolFound('09_elefant') and
            not IsToolFound('09_belt') and
            IsSceneVisited('l_13_junk_shop')
        then
            ReopenScene('l_09_doctor_ho')
	    end
	end
	-------------------------
	
	local function on_click_right_door(e)
	    ObjectVisible(e.target, false)
	    
	    if e.save then
	        ObjectOpacity('layer_right_door_open',  1)
	        ObjectOpacity('layer_right_door_close', 0)
	        
	        ObjectVisible('area_zoom_cabinet_top',    true)
	        ObjectVisible('area_zoom_cabinet_bottom', true)
	    else
	        local time = 0.5
	        ObjectOpacity('layer_right_door_open',  1, time)
	        ObjectOpacity('layer_right_door_close', 0, time)
	        
	        MakeSoundEntity('09_click_right_door'):PlaySound(false)
	        
	        self.timer:Add( function()
	                            ObjectVisible('area_zoom_cabinet_top',    true)
	                            ObjectVisible('area_zoom_cabinet_bottom', true)
	                        end,
	                        time)
	    end
	end
	-------------------------
	
	local function on_click_left_door(e)
	    ObjectVisible(e.target, false)
	    
	    if e.save then
	        ObjectOpacity('layer_left_door_open',  1)
	        ObjectOpacity('layer_left_door_close', 0)
	        
	        ObjectVisible('area_link_ho', true)
	        registerLinkHo()
	    else
	        local time = 0.5
	        ObjectOpacity('layer_left_door_open',  1, time)
	        ObjectOpacity('layer_left_door_close', 0, time)
	        
	        MakeSoundEntity('09_click_left_door'):PlaySound(false)
	        
	        self.timer:Add( function()
	                            ObjectVisible('area_link_ho', true)
	                            
	                            registerLinkHo()
	                        end,
	                        time)
	    end
	end
	-------------------------
	
	self:create_comics_on_enter()
	RegisterActiveObject('area_click_right_door', on_click_right_door)
	RegisterActiveObject('area_click_left_door',  on_click_left_door)
	
	-- zoom zones ----------------------------------
	
	-- ZOOM CABINET BOTTOM
	do
	    CreateSmartZoomZone('cabinet_bottom')
	    ---------------------
	    
	    ObjectVisible('area_find_zcb_hamster', false)
	    ---------------------
	    
	    if not IsToolFound('09_hamster') then
            self.video_hamster_idle = CreateVideoEntity('data/Video/Scenes/09_doctor/09_hamster_idle.ogg', '', false)
            self.video_hamster_idle:AttachTo(Object('z_cabinet_bottom_bg'))
            self.video_hamster_idle:SetZ(40)
            self.video_hamster_idle:SetXY(-256, 37)
            self.video_hamster_idle:SetLoop(true)
            self.video_hamster_idle:PlayVideo()
            
            self.sound_hamster_idle = MakeSoundEntity('09_hamster_idle')
            self.sound_hamster_idle:SetVolume(0)
            self.sound_hamster_idle:PlaySound(true)
        end
	    ---------------------
	    
	    self.zoom_cabinet_bottom.on_open = function()
	        if self.sound_hamster_idle then
	            self.sound_hamster_idle:SetVolume(1)
	        end
	    end
	    ---------------------
	    
	    self.zoom_cabinet_bottom.on_close = function()
	        if self.sound_hamster_idle then
	            self.sound_hamster_idle:SetVolume(0)
	        end
	    end
	    ---------------------
	    
	    local function on_click_cover(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_cabinet_bottom_cover', 0)
	            ObjectVisible('area_find_zcb_hamster', true)
	        else
	            local time = 0.5
	            ObjectOpacity('z_cabinet_bottom_cover', 0, time)
	            
	            MakeSoundEntity('09_click_cover'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_find_zcb_hamster', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_find_hamster(e)
	        ObjectVisible(e.target, false)
	        
	        if not e.save then
	            self.video_hamster_idle:StopVideo()
	            self.sound_hamster_idle:StopSound()
	        end
	    end
	    ---------------------
	    
	    RegisterActiveObject('area_click_zcb_cover', on_click_cover)
	    RegisterToolFindInfo('09_hamster', 'area_find_zcb_hamster', on_find_hamster)
	end
	
	-- ZOOM CABINET TOP
	do
	    CreateSmartZoomZone('cabinet_top')
	    ---------------------
	    
	    ObjectOpacity('z_cabinet_top_cover_up', 0)
	    ---------------------
	    
	    ObjectVisible('area_find_zct_lenses', false)
	    ---------------------
	    
	    local function on_click_cover(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_cabinet_top_cover_up',   1)
	            ObjectOpacity('z_cabinet_top_cover_down', 0)
	            
	            ObjectVisible('area_find_zct_lenses', true)
	        else
	            local time = 0.5
	            ObjectOpacity('z_cabinet_top_cover_up',   1, time)
	            ObjectOpacity('z_cabinet_top_cover_down', 0, time)
	            
	            MakeSoundEntity('09_click_lenses_cover'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_find_zct_lenses', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_find_lenses(e)
	        ObjectVisible(e.target, false)
	    end
	    ---------------------
	    
	    RegisterActiveObject('area_click_zct_cover', on_click_cover)
	    RegisterToolFindInfo('09_lenses', 'area_find_zct_lenses', on_find_lenses)
	end
	
	-- ZOOM TABLE
	do
	    CreateSmartZoomZone('table')
	    ---------------------
	    
	    ObjectOpacity('z_table_garden_pruner',         0)
        ObjectOpacity('z_table_garden_pruner_water',   0)
        ObjectOpacity('z_table_nail_with_blood',       0)
        ObjectOpacity('z_table_nail_with_blood_water', 0)
        
        ObjectOpacity('z_table_pipette_1_blood', 0)
        ObjectOpacity('z_table_pipette_2_blood', 0)
	    ---------------------
	    
        ObjectVisible('area_drop_zt_bottle', false)
        ObjectVisible('area_get_zt_bottle',  false)
        ObjectVisible('area_get_zt_pipette_1', false)
	    ObjectVisible('area_get_zt_pipette_2', false)
	    ObjectVisible('area_drop_zt_pipette_garden_pruner',   false)
	    ObjectVisible('area_drop_zt_pipette_nail_with_blood', false)
	    ---------------------
	    
	    Helpers.AttachInPlace(Object('z_table_pipette_1_blood'), Object('z_table_pipette_1'))
	    Helpers.AttachInPlace(Object('z_table_pipette_2_blood'), Object('z_table_pipette_2'))
	    Helpers.AttachInPlace(Object('z_table_bottle_water'),    Object('z_table_bottle'))
	    
	    play_field:IgnoreOnTestPoint('z_table_bottle_water')
	    play_field:IgnoreOnTestPoint('z_table_pipette_1_blood')
	    play_field:IgnoreOnTestPoint('z_table_pipette_2_blood')
	    ---------------------
	    
	    local function on_click_cork(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_table_cork', 0)
	            ObjectVisible('area_get_zt_bottle', true)
	        else
	            local time = 0.5
	            ObjectOpacity('z_table_cork', 0, time)
	            MakeSoundEntity('09_click_cork'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_get_zt_bottle', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_apply_nail_with_blood(e)
	        if IsToolApplied('07_garden_pruner') then
	            ObjectVisible(e.target, false)
	        else
	            self.custom_cursors[e.target] = 'CursorGlass'
	        end
	        
	        if e.save then
	            ObjectOpacity('z_table_nail_with_blood', 1)
	        else
	            local time = 0.5
	            ObjectOpacity('z_table_nail_with_blood', 1, time)
	            MakeSoundEntity('09_apply_nail_with_blood'):PlaySound(false)
	            
	            if IsToolApplied('07_garden_pruner') then
	                self.timer:Add( function()
	                                    ObjectVisible('area_drop_zt_bottle', true)
	                                end,
	                                time)
                end
	        end
	    end
	    ---------------------
	    
	    local function on_apply_garden_pruner(e)
	        if IsToolApplied('05_nail_with_blood') then
	            ObjectVisible(e.target, false)
	        else
	            self.custom_cursors[e.target] = 'CursorGlass'
	        end
	        
	        if e.save then
	            ObjectOpacity('z_table_garden_pruner', 1)
	            
	            if IsToolApplied('05_nail_with_blood') then
                    ObjectVisible('area_drop_zt_bottle', true)
	            end
	        else
	            local time = 0.5
	            ObjectOpacity('z_table_garden_pruner', 1, time)
	            MakeSoundEntity('09_apply_garden_pruner'):PlaySound(false)
	            
	            if IsToolApplied('05_nail_with_blood') then
	                self.timer:Add( function()
	                                    ObjectVisible('area_drop_zt_bottle', true)
	                                end,
	                                time)
	            end
	        end
	    end
	    ---------------------
	    
	    local function on_click_tool_apply_area(e)
	        if not IsToolApplied('05_nail_with_blood') and not IsToolApplied('07_garden_pruner') then
	            return 'BBT_09_NEED_APPLY_BLOOD_TOOLS'
	        elseif not IsToolApplied('07_garden_pruner') then
	            return 'BBT_09_NEED_APPLY_GARDEN_PRUNER'
	        else
	            return 'BBT_09_NEED_APPLY_NAIL_WITH_BLOOD'
	        end
	    end
	    ---------------------
	    
	    local function on_get_bottle(e)
	        local time = 0.1
	        ObjectOpacity('z_table_bottle_shadow', 0, time)
	    end
	    ---------------------
	    
	    local function on_drop_bottle(e)
	        local time = 0.1
	        
	        self.timer:Add( function()
	                            ObjectOpacity('z_table_bottle_shadow', 1, time)
	                        end,
	                        e.time - time)
	    end
	    ---------------------
	    
	    local function on_bottle_full_dropped(save)
	        ObjectVisible('area_get_zt_pipette_1', true)
	        ObjectVisible('area_get_zt_pipette_2', true)
	        ObjectVisible('area_drop_zt_pipette_garden_pruner',   true)
	        ObjectVisible('area_drop_zt_pipette_nail_with_blood', true)
	    end
	    ---------------------
	    
	    local function on_drop_target_bottle(e)
	        ObjectVisible('area_drop_zt_bottle', false)
	        ObjectVisible('area_get_zt_bottle',  false)
	        
	        if e.save then
	            ObjectOpacity('z_table_garden_pruner_water',   1)
	            ObjectOpacity('z_table_nail_with_blood_water', 1)
	            ObjectOpacity('z_table_nail_with_blood',       0)
	            
	            ObjectOpacity('z_table_bottle_water', 0)
	            on_bottle_full_dropped(true)
	        else
	            self.anim_bottle = AnimationBundle(Loader_09_Zoom_Table_Animations(Object('z_table_bg')))
	            self.anim_bottle:GetAnimation('action'):SetClippingRect(self.zoom_table:GetClippingInfo())
	            self.anim_bottle:PlayAnimation('action')
	            
	            MakeSoundEntity('09_drop_target_bottle'):PlaySound(false)
	            
	            ObjectOpacity('z_table_bottle', 0)
	            ObjectOpacity('z_table_bottle_water', 0)
	            Object('z_table_bottle'):SetXY(e.baseX, e.baseY)
	            
	            self.mouseBlocker:Push()
	            self.timer:Add( function()
	                                self.mouseBlocker:Pop()
	                                
	                                ObjectOpacity('z_table_garden_pruner_water',   1)
                                    ObjectOpacity('z_table_nail_with_blood_water', 1)
                                    ObjectOpacity('z_table_nail_with_blood',       0)
                                    
                                    local battelFadeTime = 0.2
                                    ObjectOpacity('z_table_bottle',        1, battelFadeTime)
                                    ObjectOpacity('z_table_bottle_shadow', 1, battelFadeTime)
                                    
                                    on_bottle_full_dropped(false)
	                            end,
	                            self.anim_bottle:GetAnimation('action'):GetDuration())
	        end
	    end
	    ---------------------
	    
	    local function on_get_pipette(e)
	        if not self.sound_get_pipette then
	            self.sound_get_pipette = MakeSoundEntity('09_get_pipette')
	        end
	        
	        self.sound_get_pipette:StopSound()
	        self.sound_get_pipette:PlaySound(false)
	    end
	    ---------------------
	    
	    local function on_drop_pipette(e)
	    end
	    ---------------------
	    
	    self.pipettes_founded = 0
	    
	    local function on_drop_target_pipette(e)
	        self.pipettes_founded = self.pipettes_founded + 1
	        local id = string.sub(e.objName, -1)
	        
	        ObjectVisible(e.get_area, false)
	        ObjectVisible(e.target,   false)
	        
	        if self.pipettes_founded == 2 then
	            self.zoom_table:Disable()
            end
	        
	        if e.save then
	            ObjectOpacity(e.objName..'_blood', 1)
	            ObjectOpacity(e.objName, 0)
	            
	            FindTool('09_pipette_with_blood_'..id)
	        else
	            local time = 0.5
	            ObjectOpacity(e.objName..'_blood', 1, time)
	            
	            if not self.sound_drop_target_pipette then
	                self.sound_drop_target_pipette = MakeSoundEntity('09_drop_target_pipette')
	            end
	            
	            self.sound_drop_target_pipette:StopSound()
	            self.sound_drop_target_pipette:PlaySound(false)
	            
	            self.mouseBlocker:Push()
	            self.timer:Add( function()
	                                self.mouseBlocker:Pop()
	                                ObjectOpacity(e.objName, 0)
	                                FindTool('09_pipette_with_blood_'..id)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    RegisterActiveObject('area_click_zt_cork', on_click_cork)
	    RegisterToolApplyInfo('05_nail_with_blood', 'area_apply_zt_tools', on_apply_nail_with_blood, on_click_tool_apply_area)
	    RegisterToolApplyInfo('07_garden_pruner',   'area_apply_zt_tools', on_apply_garden_pruner,   on_click_tool_apply_area)
	    
	    do
	        local x,y,w,h = self.zoom_table:GetClippingInfo()
	        local rect = {x=x,y=y,w=w,h=h}
	        
	        Object('z_table_pipette_1'):SetClippingRect(x,y,w,h)
	        Object('z_table_pipette_2'):SetClippingRect(x,y,w,h)
	        
            RegisterDragObject('z_table_bottle', 'area_get_zt_bottle', 'area_drop_zt_bottle', on_get_bottle, on_drop_bottle, on_drop_target_bottle, rect, true)
            
            RegisterDragObject('z_table_pipette_1',
                               'area_get_zt_pipette_1',
                               {'area_drop_zt_pipette_garden_pruner', 'area_drop_zt_pipette_nail_with_blood'},
                               on_get_pipette, on_drop_pipette, on_drop_target_pipette, rect, true)
                               
            RegisterDragObject('z_table_pipette_2',
                               'area_get_zt_pipette_2',
                               {'area_drop_zt_pipette_garden_pruner', 'area_drop_zt_pipette_nail_with_blood'},
                               on_get_pipette, on_drop_pipette, on_drop_target_pipette, rect, true)
            
            RegisterMonologObject('area_drop_zt_bottle',                  'BBT_09_NEED_DROP_BOTTLE')
            RegisterMonologObject('area_drop_zt_pipette_garden_pruner',   'BBT_09_NEED_DROP_PIPETTE_ON_GARDEN_PRUNER')
            RegisterMonologObject('area_drop_zt_pipette_nail_with_blood', 'BBT_09_NEED_DROP_PIPETTE_ON_NAIL_WITH_BLOOD')
        end
	end
	
	-- ZOOM DUMMY
	do
	    CreateSmartZoomZone('dummy')
	    ---------------------
	    
	    self.anim_dummy = AnimationBundle(Loader_09_Zoom_Dummy_Animations(Object('z_dummy_bg')))
	    self.anim_dummy:GetAnimation('action'):SetVisible(true)
	    self.anim_dummy:GetAnimation('action'):GetElementByName('Layer_2'):SetOpacity(0)
	    ---------------------
	    
	    ObjectOpacity('layer_open_mouth', 0)
	    ---------------------
	    
	    ObjectVisible('area_find_zd_rusty_heart', false)
	    ---------------------
	    
	    local function on_apply_hamster(e)
	        ObjectVisible(e.target, false)
	        
	        local compos = self.anim_dummy:GetAnimation('action')
	        
	        if e.save then
	            compos:Rewind(true)
	            ObjectOpacity('layer_open_mouth', 1)
	            ObjectVisible('area_find_zd_rusty_heart', true)
	        else
	            self.anim_dummy:GetAnimation('action'):GetElementByName('Layer_2'):SetOpacity(1)
	            compos:Play()
	            MakeSoundEntity('09_apply_hamster'):PlaySound(false)
	            
	            ObjectOpacity('layer_open_mouth', 1, compos:GetDuration())
	            
	            self.mouseBlocker:Push()
	            self.timer:Add( function()
	                                self.mouseBlocker:Pop()
	                                ObjectVisible('area_find_zd_rusty_heart', true)
	                            end,
	                            compos:GetDuration())
	        end
	    end
	    ---------------------
	    
	    local function on_find_rusty_heart(e)
	        ObjectVisible(e.target, false)
	    end
	    ---------------------
	    
	    RegisterToolApplyInfo('09_hamster', 'area_apply_zd_hamster', on_apply_hamster, 'BBT_09_NEED_APPLY_HAMSTER')
	    RegisterToolFindInfo('09_rusty_heart', 'area_find_zd_rusty_heart', on_find_rusty_heart)
	end
	
	-- ZOOM MICROSCOPE
	do
	    CreateSmartZoomZone('microscope')
	    ---------------------
	    
	    self.zoom_microscope.on_open = function()
	        AddActionCompletedState('zoom_microscope_open')
	    end
	    ---------------------
	    
	    self.zoom_microscope.on_close = function()
	        RemoveActionCompletedState('zoom_microscope_open')
	    end
	    ---------------------
	    
	    LinkScene('area_link_mg', 'CursorGlass', 'l_09_Blood')
	    ---------------------
	    
	    Helpers.AttachInPlace(Object('z_microscope_lenses'), Object('z_microscope_lens_holder'))
	    ---------------------
	    
	    ObjectOpacity('z_microscope_lenses',      0)
	    ObjectOpacity('z_microscope_dish_in',     0)
	    ObjectOpacity('z_microscope_platform_in', 0)
	    ObjectOpacity('z_microscope_blood_1',     0)
	    ObjectOpacity('z_microscope_blood_2',     0)
	    
	    Helpers.AttachInPlace(Object('z_microscope_blood_1'), Object('z_microscope_dish_out'))
	    Helpers.AttachInPlace(Object('z_microscope_blood_2'), Object('z_microscope_dish_out'))
	    
	    play_field:IgnoreOnTestPoint('z_microscope_blood_1')
	    play_field:IgnoreOnTestPoint('z_microscope_blood_2')
	    ---------------------
	    
	    ObjectVisible('area_click_zm_lens_holder', false)
	    ObjectVisible('area_get_zm_dish',          false)
	    ObjectVisible('area_click_zm_platform',    false)
	    ObjectVisible('area_link_mg',              false)
	    ---------------------
	    
	    local function on_apply_lenses(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_microscope_lenses', 1)
	            ObjectVisible('area_click_zm_lens_holder', true)
	        else
	            local time = 0.5
	            ObjectOpacity('z_microscope_lenses', 1, time)
	            MakeSoundEntity('09_apply_lenses'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_click_zm_lens_holder', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_click_lens_holder(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_microscope_lens_holder', 0)
	        else
	            local time = 0.5
	            ObjectOpacity('z_microscope_lens_holder', 0, time)
	            MakeSoundEntity('09_click_lens_holder'):PlaySound(false)
	            
	            AddActionCompletedState('microscopeHolderIn')
	            
	            if HasActionCompletedState('microscopePlatformIn') then
	                self.timer:Add( function()
	                                    ObjectVisible('area_link_mg', true)
	                                end,
	                                time)
	            end
	        end
	    end
	    ---------------------
	    
	    self.pipettes_applied = 0
	    
	    local function on_apply_pipette(e)
	        self.pipettes_applied = self.pipettes_applied + 1
	        
	        if self.pipettes_applied == 2 then
	            ObjectVisible(e.target, false)
	        else
	            self.custom_cursors[e.target] = 'CursorActive'
	        end
	        
	        if e.save then
	            ObjectOpacity('z_microscope_blood_'..tostring(self.pipettes_applied), 1)
	            
	            if self.pipettes_applied == 2 then
	                ObjectVisible('area_get_zm_dish', true)
	            end
	        else
	            local time = 0.5
	            ObjectOpacity('z_microscope_blood_'..tostring(self.pipettes_applied), 1, time)
	            
	            if not self.sound_apply_pipette_with_blood then
	                self.sound_apply_pipette_with_blood = MakeSoundEntity('09_apply_pipette_with_blood')
	            end
	            
	            self.sound_apply_pipette_with_blood:StopSound()
	            self.sound_apply_pipette_with_blood:PlaySound(false)
	            
	            if self.pipettes_applied == 2 then
	                self.timer:Add( function()
	                                    ObjectVisible('area_get_zm_dish', true)
	                                end,
	                                time)
	            end
	        end
	    end
	    ---------------------
	    
	    local function on_click_appply_pipettes_area(e)
	        return 'BBT_09_NEED_APPLY_PIPETTES'
	    end
	    ---------------------
	    
	    local function on_get_dish(e)
	    end
	    ---------------------
	    
	    local function on_drop_dish(e)
	    end
	    ---------------------
	    
	    local function on_drop_target_dish(e)
	        ObjectVisible('area_get_zm_dish',  false)
	        ObjectVisible('area_drop_zm_dish', false)
	        
	        local pos = Vector(-82, 31)
	        
	        if e.save then
	            Object(e.objName):SetXY(pos.x, pos.y)
	            ObjectVisible('area_click_zm_platform', true)
	        else
	            local time = 0.5
	            Object(e.objName):MoveTo(pos.x, pos.y, time)
	            
	            MakeSoundEntity('09_drop_target_dish'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_click_zm_platform', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_click_platform(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_microscope_dish_out',     0)
	            ObjectOpacity('z_microscope_platform_out', 0)
	            
	            ObjectOpacity('z_microscope_dish_in',     1)
	            ObjectOpacity('z_microscope_platform_in', 1)
	            
	            if HasActionCompletedState('microscopeHolderIn') then
	                ObjectVisible('area_link_mg', true)
	            end
	        else
	            local time = 0.5
	            ObjectOpacity('z_microscope_dish_out',     0, time)
	            ObjectOpacity('z_microscope_platform_out', 0, time)
	            
	            ObjectOpacity('z_microscope_dish_in',     1, time)
	            ObjectOpacity('z_microscope_platform_in', 1, time)
	            
	            MakeSoundEntity('09_click_platform'):PlaySound(false)
	            
	            AddActionCompletedState('microscopePlatformIn')
	            
	            if HasActionCompletedState('microscopeHolderIn') then
	                self.timer:Add( function()
	                                    ObjectVisible('area_link_mg', true)
	                                end,
	                                time)
	            end
	        end
	    end
	    ---------------------
	    
	    RegisterToolApplyInfo('09_lenses', 'area_apply_zm_lenses', on_apply_lenses, 'BBT_09_NEED_APPLY_LENSES')
	    RegisterActiveObject('area_click_zm_lens_holder', on_click_lens_holder)
	    RegisterToolApplyInfo('09_pipette_with_blood_1', 'area_apply_zm_pipettes', on_apply_pipette, on_click_appply_pipettes_area)
	    RegisterToolApplyInfo('09_pipette_with_blood_2', 'area_apply_zm_pipettes', on_apply_pipette, on_click_appply_pipettes_area)
	    RegisterMonologObject('area_drop_zm_dish', 'BBT_09_NEED_DROP_DISH')
	    RegisterDragObject('z_microscope_dish_out', 'area_get_zm_dish', 'area_drop_zm_dish', on_get_dish, on_drop_dish, on_drop_target_dish)
	    RegisterActiveObject('area_click_zm_platform', on_click_platform)
	    RegisterMonologObject('area_hint_zs_need_sheme', 'BBT_09_NEED_SHEME')
	    
	    if IsMiniGameCompleted('l_09_Blood') then
	        self.zoom_microscope:Disable()
	        
	        if HasActionCompletedState('zoom_microscope_open') then
	            RemoveActionCompletedState('zoom_microscope_open')
	        end
	        
	        NotebookPushNote('note_09_blood')
	        NotebookPushNote('note_09_sheme')
	    else
	        if HasActionCompletedState('zoom_microscope_open') then
	            self.zoom_microscope:Open()
	        end
	    end
	end
	
	-- ZOOM STAND
	do
	    CreateSmartZoomZone('stand')
	    ---------------------
	    
	    self.CLOCK_IDLE_TIME = 3
	    ---------------------
	    
	    ObjectVisible('area_get_zs_elefant_1',     false)
	    ObjectVisible('area_get_zs_elefant_2',     false)
	    ObjectVisible('area_get_zs_elefant_3',     false)
	    ObjectVisible('area_click_zs_stop_clock',  false)
	    ObjectVisible('area_note_zs_paper',        false)
	    ObjectVisible('area_click_zs_break_clock', false)
	    ObjectVisible('area_find_zs_bell',         false)
	    ObjectVisible('area_hint_zs_need_sheme',   false)
	    --ObjectVisible('area_apply_scheme',   	   false)
	    ---------------------
	    
	    ObjectOpacity('z_stand_door_left_open',  0)
	    ObjectOpacity('z_stand_door_right_open', 0)
	    ObjectOpacity('z_stand_scheme', 	     0)
	    ObjectOpacity('layer_stand_open',        0)
	    
	    ObjectOpacity('layer_bell_broken',  0)
	    ObjectOpacity('layer_clock_broken', 0)

	    ---------------------
	    
	    play_field:IgnoreOnTestPoint('area_doors_anchor')
	    ---------------------
	    
	    self.anim_turtle = AnimationBundle(Loader_09_Zoom_Stand_Turtle_Animations(Object('area_doors_anchor')))
	    self.anim_turtle:GetAnimation('doors'):SetVisible(true)
	    self.anim_turtle:GetAnimation('doors'):GetElementByName('Layer_3'):SetOpacity(0)
	    self.anim_turtle:GetAnimation('doors'):GetElementByName('Layer_4'):SetOpacity(0)
	    
	    self.sound_turtle = MakeSoundEntity('09_doors_stand')
	    
	    self.anim_clock = AnimationBundle(Loader_09_Zoom_Stand_Clock_Animations(Object('z_stand_bg')))
	    self.anim_clock:GetAnimation('idle'):SetVisible(true)
	    ---------------------
	    
	    self.zoom_stand.on_open = function()
	        if not HasActionCompletedState('standDoorOpened') then
                self.timer:Add( function()
                                    self.anim_turtle:GetAnimation('doors'):Play()
                                    
                                    self.sound_turtle:StopSound()
                                    self.sound_turtle:PlaySound(false)
                                    
                                    self.mouseBlocker:Push()
                                    self.timer:Add( function()
                                                        self.mouseBlocker:Pop()
                                                    end,
                                                    self.anim_turtle:GetAnimation('doors'):GetDuration())
                                end,
                                ZOOM_ZONE_APPEARING_TIME)
                                
            elseif not HasActionCompletedState('clockBroken') then
               self.timer:Add( function()
                                    self:playIdleClock()
                                end,
                                ZOOM_ZONE_APPEARING_TIME) 
            end
	    end
	    ---------------------

	    local function on_apply_scheme(e)
	    	ObjectVisible(e.target, false)

    		if IsToolApplied('09_elefant') then
                ObjectVisible('area_get_zs_elefant_1', true)
                ObjectVisible('area_get_zs_elefant_2', true)
                ObjectVisible('area_get_zs_elefant_3', true)
            end

	    	if e.save then
	    	    ObjectOpacity('z_stand_scheme', 1)
	    	    self.anim_doors:GetAnimation('doors'):GetElementByName('Layer_2'):SetOpacity(1)
	    	else
	    		local time = 0.5
	    		ObjectOpacity('z_stand_scheme', 1, time)
	    		self.anim_doors:GetAnimation('doors'):GetElementByName('Layer_2'):ChangeOpacity(0, 1, time)
	    		
	    		self.mouseBlocker:Push()
	    		self.timer:Add(function()
	    								self.mouseBlocker:Pop()
	    							end,
	    							time)
	    	end
	    end
	    
	    ------------------------------------------------------------
	    
	    local function on_apply_elefant(e)
	        ObjectVisible(e.target, false)
	        
	        if IsToolApplied('09_scheme') then
                ObjectVisible('area_get_zs_elefant_1', true)
                ObjectVisible('area_get_zs_elefant_2', true)
                ObjectVisible('area_get_zs_elefant_3', true)
            end
	        
	        if e.save then
                self.anim_turtle:GetAnimation('doors'):GetElementByName('Layer_3'):SetOpacity(1)
                self.anim_turtle:GetAnimation('doors'):GetElementByName('Layer_4'):SetOpacity(1)
                self.anim_doors:GetAnimation('doors'):GetElementByName('Layer_1'):SetOpacity(1)
	        else
	            local time = 0.5
	            self.anim_turtle:GetAnimation('doors'):GetElementByName('Layer_3'):ChangeOpacity(0, 1, time)
	            self.anim_turtle:GetAnimation('doors'):GetElementByName('Layer_4'):ChangeOpacity(0, 1, time)
	            
	            self.anim_turtle:GetAnimation('doors'):GetElementByName('Layer_3'):Go()
	            self.anim_turtle:GetAnimation('doors'):GetElementByName('Layer_4'):Go()
	            
	            MakeSoundEntity('09_apply_elefant'):PlaySound(false)
	            
	            self.anim_doors:GetAnimation('doors'):GetElementByName('Layer_1'):ChangeOpacity(0, 1, time)
	        end
	    end
	    ---------------------
	    
	    self.elefant_heads = {}
	    self.elefant_heads['1'] = 'Layer_2'
	    self.elefant_heads['2'] = 'Layer_1'
	    self.elefant_heads['3'] = 'Layer_3'
	    
	    self.angleRange = 20 * M_PI/180
	    ---------------------
	    
	    local function on_get_elefant(e)
	        local id = string.sub(e.objName, -1)
	        
	        self.rotateElefant       = {}
	        self.rotateElefant.id    = id
	        self.rotateElefant.baseX = e.baseX
	        self.rotateElefant.baseY = e.baseY
	        
	        local mPos = GetMousePos()
	        Object(e.objName):SetScrXY(mPos.x, mPos.y)
	        
	        local dx = Object(e.objName):GetX() - self.rotateElefant.baseX
	        local dy = Object(e.objName):GetY() - self.rotateElefant.baseY
	        
	        local elementName = self.elefant_heads[self.rotateElefant.id]
            local element     = self.anim_turtle:GetAnimation('doors'):GetElementByName(elementName)
	        
	        self.rotateElefant.deltaAndle = math.atan2(dy, dx)
	        self.rotateElefant.startAngle = element:GetAngle()
	        
	        if not self.sound_drag_elefants_head then
	            self.sound_drag_elefants_head = MakeSoundEntity('09_drag_elefants_head')
	        end
	        
	        self.sound_drag_elefants_head:StopSound()
	        self.sound_drag_elefants_head:PlaySound(true)
	    end
	    ---------------------
	    
	    local function on_drop_elefant(e)
	        local id          = self.rotateElefant.id
	        local elementName = self.elefant_heads[id]
            local element     = self.anim_turtle:GetAnimation('doors'):GetElementByName(elementName)
	        
	        self.sound_drag_elefants_head:StopSound()
	        
	        if math.abs(element:GetAngle()) < self.angleRange then
	            AddActionCompletedState('ElefantHeadPlaced_'..id)
	            self.elefant_fix_count = self.elefant_fix_count + 1
	            
	            element:SetAngle(0)
	            
	            ObjectVisible('area_get_zs_elefant_'..id, false)
	            
	            if self.elefant_fix_count == 3 then
	                ObjectVisible('area_click_zs_stand_door_open', true)
	            end
	        else
	            local state = 'ElefantHeadAngle_'..id
	            if HasGameState(state) then
	                RemoveGameState(state)
	            end
	            
	            SetGameState(state, tostring(element:GetAngle()))
	        end
	        
	        self.rotateElefant = nil
	        e.time = 0
	    end
	    ---------------------
	    
	    local function on_click_stand_door_open(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('area_doors_anchor',       0)
	            ObjectOpacity('z_stand_door_left_open',  1)
	            ObjectOpacity('z_stand_door_right_open', 1)
	            
	            ObjectOpacity('doors_anchor',     0)
	            ObjectOpacity('layer_stand_open', 1)

	            ObjectOpacity('z_stand_scheme', 0)
	            
	            ObjectVisible('area_note_zs_paper', true)
	        else
	            local time = 0.5
	            ObjectOpacity('area_doors_anchor',       0, time)
	            ObjectOpacity('z_stand_door_left_open',  1, time)
	            ObjectOpacity('z_stand_door_right_open', 1, time)
	            
	            ObjectOpacity('doors_anchor',     0, time)
	            ObjectOpacity('layer_stand_open', 1, time)

	            ObjectOpacity('z_stand_scheme', 0, time)
	            
	            MakeSoundEntity('09_click_stand_door_open'):PlaySound(false)
	            AddActionCompletedState('standDoorOpened')
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_note_zs_paper', true)
	                                self:playIdleClock()
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_click_clock(e)
	        if e.save then
	            return
	        end
	        
	        self:stopIdleClock()
	    end
	    ---------------------
	    
	    local function on_click_paper(e)
	        ObjectVisible(e.target, false)
	        
	        if e.save then
	            ObjectOpacity('z_stand_paper', 0)
	            
	            NotebookPushNote('note_09_paper')
	            ObjectVisible('area_click_zs_break_clock', true)
	            
	            if IsToolFound('09_note') then
	                self:create_comics_after_note()
	            else
	                FindTool('09_note')
	            end
	        else
	            ObjectOpacity('z_stand_paper', 0, 0.2)
	            self:stopIdleClock()
	            self.zoom_stand:Close()
	            
	            NotebookPushFlyNote('note_09_paper',
                                    e.save,
                                    'data/Texture/Notes/note_09_paper_fly.png',
                                    Vector(Object(e.target):GetScrX(), Object(e.target):GetScrY()),
                                    Vector(0.2, 0.2),
                                    nil,
                                    function(e)
                                        self.mouseBlocker:Push()
                                        self.timer:Add(	function()
                                                            self.mouseBlocker:Pop()
                                                            FindTool('09_note')
                                                            ObjectVisible('area_click_zs_break_clock', true)
                                                        end,
                                                        e.flyingTime)
                                    end)
                
                local anim = CreateAnimationByTextureName('data/Texture/Notes/note_09_paper_fly_txt.png')
                local obj  = play_field:CreateObject('note_09_paper_fly_txt',anim,0,0,1,0,1,1)
                obj:AttachTo(Object('note_09_paper_fly'))
                play_field:IgnoreOnTestPoint('note_09_paper_fly_txt')
	        end
	    end
	    ---------------------
	    
	    local function on_click_break_clock(e)
	        ObjectVisible(e.target, false)
	        
	        self:stopIdleClock()
	        self.anim_clock:GetAnimation('idle'):SetVisible(false)
	        
	        --self.anim_clock:StopAnimation('idle')
	        
	        if e.save then
	            self.anim_clock:GetAnimation('break'):SetVisible(true)
	            self.anim_clock:GetAnimation('break'):Rewind(true)
	            
	            ObjectOpacity('layer_bell',         0)
	            ObjectOpacity('layer_clock',        0)
	            ObjectOpacity('layer_bell_broken',  1)
	            ObjectOpacity('layer_clock_broken', 1)
	            
	            ObjectVisible('area_find_zs_bell', true)
	        else
	            local time = self.anim_clock:GetAnimation('break'):GetDuration()
	            
	            self.anim_clock:PlayAnimation('break')
	            AddActionCompletedState('clockBroken')
	            
	            ObjectOpacity('layer_bell',         0, time)
	            ObjectOpacity('layer_clock',        0, time)
	            ObjectOpacity('layer_bell_broken',  1, time)
	            ObjectOpacity('layer_clock_broken', 1, time)
	            
	            MakeSoundEntity('09_alarm_break'):PlaySound(false)
	            
	            self.timer:Add( function()
	                                ObjectVisible('area_find_zs_bell', true)
	                            end,
	                            time)
	        end
	    end
	    ---------------------
	    
	    local function on_find_bell(e)
	        ObjectVisible(e.target, false)
	        ObjectOpacity('layer_bell_broken', 0)
	    end
	    ---------------------
	    
	    RegisterToolApplyInfo('09_elefant', 'area_apply_zs_elefant', on_apply_elefant, 'BBT_09_NEED_APPLY_ELEFANT')
	    RegisterToolApplyInfo('09_scheme', 'area_apply_scheme', on_apply_scheme, 'BBT_09_NEED_SHEME')

	    do
            self.elefant_fix_count = 0
            local x,y,w,h = self.zoom_stand:GetClippingInfo()
            local rect = {x=x,y=y,w=w,h=h}
            
            for i=1, 3 do
                local id = tostring(i)
                local objectName = 'area_get_zs_elefant_'..tostring(id)
                
                RegisterDragObject(objectName, nil, nil, on_get_elefant, on_drop_elefant, nil, rect, true, nil, nil, true)
                
                if HasActionCompletedState('ElefantHeadPlaced_'..id) then
                    ObjectVisible('area_get_zs_elefant_'..id, false)
                    self.elefant_fix_count = self.elefant_fix_count + 1
                else
                    local state = 'ElefantHeadAngle_'..id
                    local angle = 0
                    
                    if HasGameState(state) then
                        angle = tonumber(GetGameState(state):Get(0))
                    else
                        repeat
                            angle = math.random() * M_TWO_PI - M_PI
                        until math.abs(angle) > self.angleRange
                        
                        SetGameState(state, tostring(angle))
                    end
                    
                    local elementName = self.elefant_heads[id]
                    local element     = self.anim_turtle:GetAnimation('doors'):GetElementByName(elementName)
                    element:SetAngle(angle)
                end
            end
            
            ObjectVisible('area_click_zs_stand_door_open', self.elefant_fix_count == 3)
	    end
	    
	    RegisterActiveObject('area_click_zs_stand_door_open', on_click_stand_door_open)
	    RegisterActiveObject('area_click_zs_stop_clock',      on_click_clock, true)
	    RegisterActiveObject('area_note_zs_paper',            on_click_paper)
	    RegisterActiveObject('area_click_zs_break_clock',     on_click_break_clock)
	    RegisterToolFindInfo('09_bell', 'area_find_zs_bell',  on_find_bell)
	end
end
---------------------

function l_09_doctor:stopIdleClock(bDontKillAction)
    if self.stopClockIdleAction then
        
        if not bDontKillAction then
            self.stopClockIdleAction:Kill()
        end
        
        self.stopClockIdleAction = nil
        
        local compos = self.anim_clock:GetAnimation('idle')
        compos:Stop()
        compos:Rewind(false)
        
        self.sound_alarm_loop:StopSound()
        
        ObjectVisible('area_click_zs_stop_clock', false)
    end
end
---------------------

function l_09_doctor:playIdleClock()
    local compos = self.anim_clock:GetAnimation('idle')
    compos:Play()
    
    if not self.sound_alarm_loop then
        self.sound_alarm_loop = MakeSoundEntity('09_alarm_loop')
    end
    
    self.sound_alarm_loop:StopSound()
    self.sound_alarm_loop:PlaySound(true)
    
    if not Object('area_click_zs_break_clock'):IsVisible() then
        ObjectVisible('area_click_zs_stop_clock', true)
    end
    
    self.stopClockIdleAction = self.timer:Add(  function()
                                                    self:stopIdleClock(true)
                                                end,
                                                self.CLOCK_IDLE_TIME)
end
---------------------

function l_09_doctor:OnUpdate(dt)
    if self.rotateElefant then
        local elementName = self.elefant_heads[self.rotateElefant.id]
        local element     = self.anim_turtle:GetAnimation('doors'):GetElementByName(elementName)
        local object      = Object('area_get_zs_elefant_'..self.rotateElefant.id)
        
        local dx = object:GetX() - self.rotateElefant.baseX
        local dy = object:GetY() - self.rotateElefant.baseY
        
        local dAngle = math.atan2(dy, dx) - self.rotateElefant.deltaAndle
        local angle = FixAngle(self.rotateElefant.startAngle + dAngle)
        
        if angle > M_PI then
            angle = angle - M_TWO_PI
        end
        
        element:SetAngle(angle)
    end
end
---------------------

function l_09_doctor:create_comics_on_enter()
    local comics_name = '09_comics_on_enter'
    
    local comics_finish = function(save)
        if save then
            --ShowDemoDialog()
        else
            --[[
            self.mouseBlocker:Push()
            self.timer:Add( function()
                                self.mouseBlocker:Pop()
                                ShowDemoDialog()
                            end,
                            0.5)
            --]]
        end
    end
    
    if IsComicsShown(comics_name) then
        comics_finish(true)
    else
        local comics = l_09_doctor_comics_dupin_on_enter()
		comics:LoadData(play_field)
		
        local c = Comics(comics_name,
                            CreateComicsVideoFrame('Dupin',  'C_09_DUPIN_ON_ENTER_01', nil, {path='data/Video/Scenes/09_doctor/C_09_DUPIN_ON_ENTER_01.ogg', isAlpha=true, x=350}, 'comics_on_enter_bg')
                            )
        
        Object('comics_on_enter_bg'):GetAnimation():SetColor('0x01FFFFFF')
        
        c.on_finish = function()
            comics_finish(false)
        end
        
        self.mouseBlocker:Push()
        self.timer:Add( function()
                            self.mouseBlocker:Pop()
                            c:Start()
                        end,
                        1)
    end
end
---------------------

function l_09_doctor:create_comics_after_note()
    local comics_name = '09_comics_after_note'
    
    local comics_finish = function(save)
        if save then
        else
            self.mouseBlocker:Push()
            self.timer:Add( function()
                                self.mouseBlocker:Pop()
                                self.zoom_stand:Open()
                            end,
                            ZOOM_ZONE_APPEARING_TIME)
        end
    end
    
    if IsComicsShown(comics_name) then
        comics_finish(true)
    else
        local comics = l_09_doctor_comics_dupin_after_note()
		comics:LoadData(play_field)
		
        local c = Comics(comics_name,
                            CreateComicsVideoFrame('Dupin',  'C_09_DUPIN_AFTER_NOTE_01', nil, {path='data/Video/Scenes/09_doctor/C_09_DUPIN_AFTER_NOTE_01.ogg', isAlpha=true, x=760}, 'comics_after_note_bg')
                            )
        
        Object('comics_after_note_bg'):GetAnimation():SetColor('0x01FFFFFF')
        
        c.on_finish = function()
            comics_finish(false)
        end
        
        c:Start()
    end
end
---------------------

function l_09_doctor:OnAllItemsFound()
end

function l_09_doctor:OnObjectMouseEnter(object)
end

function l_09_doctor:OnObjectMouseLeave(object)
end

function l_09_doctor:OnScreenObjectMouseDown(object, key)
end

function l_09_doctor:OnObjectMouseDownProcessed(is_wrong_click)
end

function l_09_doctor:OnMouseMove(previous_pos, current_pos)
end

function l_09_doctor:OnObjectMouseUp(object)
end

function l_09_doctor:OnObjectFound(object)
end

function l_09_doctor:OnToolFound(tool)
end

function l_09_doctor:OnToolApply(tool, object)
end

function l_09_doctor:OnToolWindowClose(tool)
    if tool == '09_note' then
        self.mouseBlocker:Push()
    end
end

function l_09_doctor:OnToolAddToInventory(tool)
    if tool == '09_note' then
        self.mouseBlocker:Pop()
        self:create_comics_after_note()
    end
end

function l_09_doctor:OnObjectReachPanel(object)
end

function l_09_doctor:OnButtonPress(title)
end

function l_09_doctor:OnSetTool(tool)
end

function l_09_doctor:OnLoaded()
end

function l_09_doctor:OnDestroy()
end

--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function l_09_doctor:LoadData(screen)
	local anim
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/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,50,0,1,1)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_link_08',anim,512,700,100,0,128,17)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_cabinet_bottom',anim,446,361,100,0,15,10)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_cabinet_top',anim,445,190,100,0,15,30)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_dummy',anim,311,212,100,0,1,2)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_microscope',anim,816,440,100,0,1.5,1)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_stand',anim,596,538,100,0,15,15)
	
	anim = CreateAnimation('data/Texture/Common/area_round.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_zoom_table',anim,178,481,100,0,2,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_left_door_close.png',0,0,188,400,1,0)
	anim:SetHotSpot(94,200)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_left_door_close',anim,141,210,61,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_right_door_close.png',0,0,136,334,1,0)
	anim:SetHotSpot(68,167)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_right_door_close',anim,448,223,61,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_left_door_open.png',0,0,306,462,1,0)
	anim:SetHotSpot(153,231)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_left_door_open',anim,153,231,60,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_right_door_open.png',0,0,200,392,1,0)
	anim:SetHotSpot(100,196)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_right_door_open',anim,445,228,60,0,1,1)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_click_right_door',anim,449,232,100,0,15,40)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_click_left_door',anim,144,210,100,0,20,40)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_link_ho',anim,144,210,100,0,20,40)
	
	anim = CreateAnimation('data/Texture/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('doors_anchor',anim,512,384,60,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_stand_open.png',0,0,178,116,1,0)
	anim:SetHotSpot(89,58)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_stand_open',anim,614,543,61,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_bell.png',0,0,22,10,1,0)
	anim:SetHotSpot(11,5)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_bell',anim,595,536,53,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_bell_broken.png',0,0,16,16,1,0)
	anim:SetHotSpot(8,8)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_bell_broken',anim,630,568,54,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_clock.png',0,0,42,30,1,0)
	anim:SetHotSpot(21,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_clock',anim,603,549,52,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_clock_broken.png',0,0,26,28,1,0)
	anim:SetHotSpot(13,14)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_clock_broken',anim,606,555,54,0,1,1)
	
	anim = CreateAnimation('data/Texture/Scenes/09_doctor/main/layers/layer_open_mouth.png',0,0,17,18,1,0)
	anim:SetHotSpot(8,9)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('layer_open_mouth',anim,323,139,60,0,1,1)
	
end
-- CLEAR_ON_SAVE_END
