layoutShedLawnmower.leftUp = false
layoutShedLawnmower.rightUp = false
layoutShedLawnmower.mFirstTime = true
-- ----------------------------------------------------------------------------
layoutShedLawnmower.mExits =
{
}
layoutShedLawnmower.mPOIs = 
{
}
layoutShedLawnmower.mHOs = 
{
	[objectShedLawnmowerAntirust] = 
	{
		siblings = {objectShedLawnmowerAntirustDark, objectShedLawnmowerAntirustPocket},
	},
}
layoutShedLawnmower.mIOs =
{
	[objectShedLawnmowerHitareaWheelleft] = 
	{
		cursor = kCursorPointer,
	},
	[objectShedLawnmowerHitareaWheelright] = 
	{
		cursor = kCursorPointer,
	},
}
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:onConstruct()
	
	Layout.onConstruct(self)
	
	objectShedLawnmowerScare:ss(kInactive)
	objectShedLawnmowerUpboth:ss(kInactive)
	objectShedLawnmowerUpleft:ss(kInactive)
	objectShedLawnmowerUpright:ss(kInactive)
	objectShedLawnmowerMoved:ss(kInactive)
	
	objectShedLawnmowerHitareaWheelleft:ss(kActive)
	objectShedLawnmowerHitareaWheelright:ss(kActive)

end
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:onInitialize()
	
	Layout.onInitialize(self)
	
	objectShedSmallwheel1:ss(kActive)
	objectShedSmallwheel2:ss(kActive)
	
	objectShedLawnmowerShine:ss(kDone)

end
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:onShow()

	Layout.onShow(self)
	
	if (self.mFirstTime) then
		think("MESSAGE_SHED_LAWNMOWER")		
		self.mFirstTime = false
	end

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

	local returnVal = false

	if (gSelection == objectShedSmallwheel1) then
		
		if (object == objectShedLawnmowerHitareaWheelleft) then
			
			objectShedLawnmowerHitareaWheelleft:ss(kIdle)
			objectShedSmallwheel1:ss(kUsed)
			animObjectUsedCorrectly(objectShedSmallwheel1, objectShedLawnmowerHitareaWheelleft, "onPlaceLeftCallback")
			returnVal = true
			playAudioTrack("PLACE_OBJECT")
			
		elseif (object == objectShedLawnmowerHitareaWheelright) then
		
			objectShedLawnmowerHitareaWheelright:ss(kIdle)
			objectShedSmallwheel1:ss(kUsed)
			animObjectUsedCorrectly(objectShedSmallwheel1, objectShedLawnmowerHitareaWheelright, "onPlaceRightCallback")
			returnVal = true
			playAudioTrack("PLACE_OBJECT")
			
		end
		
	elseif (gSelection == objectShedSmallwheel2) then
	
		if (object == objectShedLawnmowerHitareaWheelleft) then
			
			objectShedLawnmowerHitareaWheelleft:ss(kIdle)
			objectShedSmallwheel2:ss(kUsed)
			animObjectUsedCorrectly(objectShedSmallwheel2, objectShedLawnmowerHitareaWheelleft, "onPlaceLeftCallback")
			returnVal = true
			playAudioTrack("PLACE_OBJECT")
			
		elseif (object == objectShedLawnmowerHitareaWheelright) then
		
			objectShedLawnmowerHitareaWheelright:ss(kIdle)
			objectShedSmallwheel2:ss(kUsed)
			animObjectUsedCorrectly(objectShedSmallwheel2, objectShedLawnmowerHitareaWheelright, "onPlaceRightCallback")
			returnVal = true
			playAudioTrack("PLACE_OBJECT")
			
		end
		
	elseif (gSelection == nil) then
	
		if (object == objectShedLawnmowerHitareaWheelleft) or (object == objectShedLawnmowerHitareaWheelright) then
			think("MESSAGE_FIND_TWO_WHEELS")	
		end
	
	end

	return returnVal
	
end
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:onPlaceLeftCallback()
	self:addWheel("left")
end
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:onPlaceRightCallback()
	self:addWheel("right")
end
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:onClickHO(object, x, y)

	if (object == objectShedLawnmowerAntirust) then
		objectShedLawnmowerScare:ss(kIdle)

		objectShedLawnmowerScare:animate("scareLawnmower_blocking",
			{ delay=2500											},
			{ command="playTrack track=SHADOW_SCARE_1", target=self },
			{ startframe=0, 		frametime=100					}
		)
	end 
	
	return Layout.onClickHO(self, object, x, y)
	
end
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:onAnimationFinish(animationName)

	if (animationName == "scareLawnmower_blocking") then
		objectShedLawnmowerScare:ss(kDone)
		
	elseif (animationName == "moveMower_blocking") then
		objectShedLawnmowerNowheelDark:ss(kDone)
		objectShedLawnmowerNowheel1Dark:ss(kDone)
		objectShedLawnmowerWheelDark:ss(kDone)
		objectShedLawnmowerWheelDarkMoved:ss(kIdle)
	
	end
	
	Layout.onAnimationFinish(self, animationName)
	
end
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:addWheel(side)
	
	if (not objectShedLawnmowerNowheels:isDone()) then
		objectShedLawnmowerNowheels:ss(kDone)
	end
	
	if (side == "left") then
	
		if (self.leftUp == false) then
		
			self.leftUp = true
		
			if (self.rightUp == false) then
				objectShedLawnmowerDown:ss(kDone)
				objectShedLawnmowerUpleft:ss(kActive)	
				
				-- Update image in the main shed layout:
				objectShedLawnmowerNowheelDark:ss(kIdle)
				objectShedLawnmowerNowheel1Dark:ss(kDone)	-- We will now never use this one
				
			else
				self:finishMower()
			end
		
		end
		
	else
	
		if (self.rightUp == false) then
		
			self.rightUp = true
			
			if (self.leftUp == false) then
				objectShedLawnmowerDown:ss(kDone)
				objectShedLawnmowerUpright:ss(kActive)
				
				-- Update image in the main shed layout:
				objectShedLawnmowerNowheel1Dark:ss(kIdle)
				objectShedLawnmowerNowheelDark:ss(kDone)	-- We will now never use this one
				
			else
				self:finishMower()
			end
			
		end

	end
	
end
-- ----------------------------------------------------------------------------
function layoutShedLawnmower:finishMower()

	objectShedLawnmowerUpboth:ss(kActive)
	objectShedLawnmowerUpleft:ss(kDone)
	objectShedLawnmowerUpright:ss(kDone)
	
	objectShedLawnmowerAntirust:ss(kActive)
	
	objectShedLawnmowerMoved:setAlpha(0)
	objectShedLawnmowerMoved:ss(kIdle)
	objectShedLawnmowerMoved:animate("moveMower_blocking",
		{ alpha=0									},
		{ delay=500									},
		{ alpha=1,		duration=kTimeFadeSwitch	} 
		
	)
	objectShedLawnmowerUpboth:animate(
		{ delay=500									},
		{ alpha=0,		duration=kTimeFadeSwitch	} 
	)

end