-- ----------------------------------------------------------------------------
layoutPorchRock.mExits =
{
}
layoutPorchRock.mPOIs = 
{
}
layoutPorchRock.mHOs = 
{
	[objectPorchKey] = 
	{
		siblings = {objectPorchKeyDark, objectPorchKeyPocket}
	},
}
layoutPorchRock.mIOs =
{
	[objectPorchRockHitarea] =
	{
		cursors = kCursorOperate
	},
}
layoutPorchRock.mInsects =
{
	objectPorchRockPoiInsect1,
	objectPorchRockPoiInsect2,
	objectPorchRockPoiInsect3,
	objectPorchRockPoiInsect4,
}
-- ----------------------------------------------------------------------------
function layoutPorchRock:onInitialize()
    
    Layout.onInitialize(self)

	objectPorchRockTurned:ss(kInactive)
	-- end highlight
	objectPorchRockInsect:ss(kDone)
	
	
	
end
-- ----------------------------------------------------------------------------
function layoutPorchRock:onClickIO(object, x, y)

	if (object == objectPorchRockHitarea) then
		objectPorchKey:ss(kActive)
		
--		objectPorchRockTurned:setAlpha(0)
--		objectPorchRockTurned:ss(kLocked)		
--		objectPorchRockTurned:animate("TurnPorchRock_blocking",
--			{ alpha=0									},
--			{ alpha=1,		duration=kTimeFadeSwitch	}
--		)
--		
--		objectPorchRockHitarea:ss(kIdle)		
--		objectPorchRockHitarea:animate(
--			{ alpha=0,		duration=kTimeFadeSwitch	}
--		)

		objectPorchRockTurned:ss(kLocked)
		objectPorchRockBackground:ss(kDone)
		objectPorchRockHitarea:ss(kDone)
		
		local delay = 100
		
		for i=1, #self.mInsects do
			local insect = self.mInsects[i]
			insect:ss(kIdle)
			insect:animate("animRockInsect" .. i,
				{ delay = delay },
				{ startframe=0, frametime=50 },
				{ call = function() insect:ss(kDone) end }
			) 
			delay = delay + 250		
		end		

		playAudioTrack("PORCH_ROCK_MOVING")
		
		return true		
	end
	
	return Layout.onClickIO(self, object, x, y)

end
-- ----------------------------------------------------------------------------
function layoutPorchRock:onAnimationFinish(animationName)
	
	Layout.onAnimationFinish(self, animationName)
	
--	if (animationName == "TurnPorchRock_blocking") then
--		objectPorchRockBackground:ss(kDone)
--		objectPorchRockHitarea:ss(kDone)
--	end
	
end
