--------------------------------------------------------------------------------
--  File     : Bridge_Senry_box
--  Author(s): Prokopovich Larisa
--
--  Summary  : Скрипт управления локацией.
--
--  Copyright © 2012 Floodlight Games.  All rights reserved.
--------------------------------------------------------------------------------
function OnFirstEntry()
	room:GetItem("GLOVE_TORN"):Disable()
	room:GetItem("SENRY_BOX_GLOVE"):Disable()
	
	stars:Show("GLOVE_TORN", "4")
end
--------------------------------------------------------------------------------
function OnMouseClickOnBack()
	chapter:ExitCloseup()
	return true
end
--------------------------------------------------------------------------------
function OnMouseClickOnItem(item)
	local itemName = item:GetName()
	
	if (itemName == "GLOVE_TORN")  or					
	   (itemName == "SENRY_BOX_GLOVE") then 
		
		if item:IsEnabled() then						--целая рукавица
			room:GetItem("SENRY_BOX_GLOVE"):Hide()
			room:GetItem("GLOVE_TORN"):Hide()
			pick_panel:AddItems("GLOVE", true)
			cstore:SetKey("Close_Bridge_Senry", true)
			room:MarkCompleted()
			return true
			
		elseif itemName == "GLOVE_TORN" then			--рваная рукавица	
			comment:Add("CMT_Glove_Player")
			return true	
		end
	
	end
end
--------------------------------------------------------------------------------
function OnClickItemOnItem(item)					
	local itemName = item:GetName()

	if itemName == "GLOVE_TORN" then					--нитки с иголкой на рваную рукавицу  
		if cursor:IsItemNameEqual("THREAD_NEEDLE") then
			cursor:RemoveItem()
			
			local videoGlove = room:GetItem("SENRY_BOX_GLOVE")
			videoGlove:Show()
			videoGlove:PlayAnimation()
			room:AddCtrlAnimation("SENRY_BOX_GLOVE", -1)
			room.sfx:Play ("sew_glove")					--звук "зашивается рукавица нитками"
			return true
		end
	end
end
--------------------------------------------------------------------------------
-- Окончание анимации зашивания рукавицы
function OnAnimationComplete_SENRY_BOX_GLOVE(forced)
	local senry_box_glove = room:GetItem("SENRY_BOX_GLOVE")
	senry_box_glove:Enable()
	room:GetItem("GLOVE_TORN"):Enable()
	
	if forced == true then
		room:VideoSeekToEnd(senry_box_glove)
	end
end