layoutCemeteryFence.mExits =
{
	[objectExitWoods2Cemetery] = 
	{
		target = layoutCemetery,
		arrowX = 357,
		arrowY = 395,
		arrowAngle = 0 * math.pi,
		labelX = 357,
		labelY = 234,
		labelAnchorpoint = ANCHOR_CENTER,
	},	
}

layoutCemeteryFence.mPOIs = 
{
	[objectPoiFencePaper] = 
	{
		target = layoutCemeteryFencePaper,
	},
}

layoutCemeteryFence.mHOs = 
{
}

layoutCemeteryFence.mIOs =
{
	[objectIoRoses1] = 
	{
		cursors = kCursorOperate,
	},
	[objectIoRoses2] = 
	{
		cursors = kCursorOperate,
	}
}
-- ----------------------------------------------------------------------------
function layoutCemeteryFence:onConstruct()
	
	Layout.onConstruct(self)
	
	objectPoiFencePaper:ss(kInactive)
	objectCemeteryFencePaper:ss(kInactive)	
	
end
-- ----------------------------------------------------------------------------
function layoutCemeteryFence:onInitialize()

	Layout.onInitialize(self)
	
	objectIoRoses1:ss(kActive)
	objectIoRoses2:ss(kInactive)
	objectIoRoses3:ss(kInactive)
	objectExitWoods2Cemetery:ss(kIdle)	

end
-- ----------------------------------------------------------------------------
function layoutCemeteryFence:onClickIO(object, x, y)

	if (object == objectIoRoses1) then
		objectIoRoses1:ss(kIdle)
		objectIoRoses1:animate(
			{ alpha = 0, duration = kTimeFadeSwitch }
		)
		
		objectIoRoses2:ss(kActive)
		objectIoRoses2:setAlpha(0)
		objectIoRoses2:animate("SwapToRoses2_blocking",
			{ command="playTrack track=PULL_ROSE_BRANCHES", target=self },		
			{ alpha = 1, duration = kTimeFadeSwitch }
		)
		
		return true
	
	elseif (object == objectIoRoses2) then
		objectIoRoses2:ss(kIdle)
		objectIoRoses2:animate(
			{ alpha = 0, duration = kTimeFadeSwitch }
		)
		
		objectIoRoses3:ss(kActive)
		objectIoRoses3:setAlpha(0)
		objectIoRoses3:animate("SwapToRoses3_blocking",
			{ command="playTrack track=PULL_ROSE_BRANCHES", target=self },		
			{ alpha = 1, duration = kTimeFadeSwitch }
		)
		
		return true

	end
	
	return Layout.onClickIO(self, object, x, y)

end
-- ----------------------------------------------------------------------------
function layoutCemeteryFence:onAnimationFinish(animationName)

	Layout.onAnimationFinish(self, animationName)
	
	if (animationName == "SwapToRoses2_blocking") then
		objectIoRoses1:ss(kDone)
		objectIoRoses2:ss(kActive)
		objectPoiFenceHole01:ss(kDone)
		objectPoiFenceHole02:ss(kActive)
		
	elseif (animationName == "SwapToRoses3_blocking") then
		objectIoRoses2:ss(kDone)
		objectIoRoses3:ss(kIdle)
		objectPoiFenceHole02:ss(kDone)
		objectPoiFenceHole03:ss(kActive)
		think("MESSAGE_LIGHT_BACK_THERE")
		
		objectExitWoods2Cemetery:ss(kActive)		
		
	elseif (animationName == "flapPaperCemeteryFence") then
		self:animPaper()
		
	end

end	
-- ----------------------------------------------------------------------------
function layoutCemeteryFence:onStartAudio()

	-- Play some outside noises
	playAmbientAudio(kSpookyAmbientGroup)

end
-- ----------------------------------------------------------------------------
function layoutCemeteryFence:animPaper()

	if (objectCemeteryFencePaper:isIdle()) then
		objectCemeteryFencePaper:animate("flapPaperCemeteryFence",
			{ delay = math.random(4500, 8000) },
			{ startframe=0, endframe=11, frametime=75 }
		)		
	end

end