-- ----------------------------------------------------------------------------
layoutBedroom.mExits =
{
	[objectBedroomDoor] = 
	{
		target = layoutLivingroom,
		targetPageH = kRight,
		arrowX = 185,
		arrowY = 666,
		arrowAngle = 1.4 * math.pi,
		labelX = 6,
		labelY = 547,
		labelAnchorpoint = ANCHOR_CENTER_LEFT,
	},
}
layoutBedroom.mPOIs = 
{
	[objectBedroomUsefulphonenumbers] = 
	{	
		target = layoutBedroomPhoneNumbers,
	},
	[objectBedroomRadio] = 
	{	
		target = layoutBedroomRadio,
	},
}
layoutBedroom.mHOs = 
{
	[objectBedroomHandsetcord] = 
	{
		siblings = {objectBedroomHandsetcordDark},
	},
	[objectPhonenumberPiece2] = 
	{
		siblings = {objectPhonenumberPiece2Lit},
	},
	[objectPhonenumberPiece3] = 
	{
		siblings = {objectPhonenumberPiece3Lit, objectPhonenumberPiece3Pocket},
	},
	[objectPhonenumberPiece4] = 
	{
		siblings = {objectPhonenumberPiece4Lit, objectPhonenumberPiece4Pocket},
	},	
	[objectPhonenumberPiece5] = 
	{
		siblings = {objectPhonenumberPiece5Dark},
	},
	[objectPhonenumberPiece6] = 
	{
		siblings = {objectPhonenumberPiece6Dark},
	},
	[objectPhonenumberPiece8] = 
	{
		siblings = {objectPhonenumberPiece8Dark},
	},
	[objectPhonenumberPiece0] = 
	{
		siblings = {objectPhonenumberPiece0Dark, objectPhonenumberPiece0Pocket},
	},
	[objectPhonenumberPiece1] = 
	{
		siblings = {objectPhonenumberPiece1Dark},
	},
	[objectPhonenumberPiece7] = 
	{
		siblings = {objectPhonenumberPiece7Dark, objectPhonenumberPiece7Pocket},
	},	
	[objectBedroomHandsetcord] = 
	{
		siblings = {objectBedroomHandsetcordDark},
	},
}
layoutBedroom.mIOs =
{
}
-- ----------------------------------------------------------------------------
function layoutBedroom:onConstruct()
	
	Layout.onConstruct(self)
	
	objectBedroomDoor:ss(kActive)
	objectBedroomRadioAntennafixed:ss(kInactive)
	
end
-- ----------------------------------------------------------------------------
function layoutBedroom:flickerRadioLight()
	
	local fadeOut = math.random(40, 100)
	local outDelay = math.random(10, 800)
	local fadeIn = math.random(75, 150)
	local inDelay = math.random(400, 1000)

	objectBedroomRadioGlow:animate("flickerRadioLightBedroom",
		{ alpha=0,						duration=fadeOut			},
		--{ command="playTrack track=HUT_RADIO_GLOW",		target=self	},
		{ delay=outDelay											},
		{ alpha=1,						duration=fadeIn				},
		--{ command="playTrack track=HUT_RADIO_GLOW",		target=self	},
		{ delay=inDelay												}
	)
	
end
-- ----------------------------------------------------------------------------
function layoutBedroom:onAnimationFinish(animationName)
	
	if ((animationName == "flickerRadioLightBedroom") and (not goalFixRadio:isFinished())) then
		self:flickerRadioLight()
	else
		objectBedroomRadioGlow:setAlpha(1)
	end
	
	Layout.onAnimationFinish(self, animationName)

end
-- ----------------------------------------------------------------------------
function layoutBedroom:playRadioSound(type)

	local trackProperties = {}
	trackProperties.volume = 0.9
	
	if (type == "medium") then
		trackProperties.volume = 0.6
	elseif (type == "soft") then
		trackProperties.volume = 0.4
	elseif (type == "verySoft") then
		trackProperties.volume = 0.1
	elseif (type == "mute") then
		trackProperties.volume = 0.0
	end
	
	trackProperties.tag = "BEDROOM_RADIO_STATIC"
	trackProperties.definition = "BEDROOM_RADIO_STATIC"
	getAudioManager():playTrack(trackProperties)
	
end
-- ----------------------------------------------------------------------------
function layoutBedroom:stopRadioSound()

	local trackProperties = {}
	trackProperties.tag = "BEDROOM_RADIO_STATIC"
	getAudioManager():stopTrack(trackProperties)
	
end
-- ----------------------------------------------------------------------------
function layoutBedroom:checkRadioSound()
	
	if (objectBedroomRadioPliers:isActive()) then
		self:playRadioSound("mute")
	else
		self:checkRadioStatic("loud")
	end

end
-- ----------------------------------------------------------------------------
function layoutBedroom:checkRadioStatic(volumeType)
	
	local goal12 = getGoal("GOAL_12")
	local goal13 = getGoal("GOAL_13")
	local goal14 = getGoal("GOAL_14")
	
	local playStatic = false
	if (goal12 ~= nil and goal12:isActive()) then
		playStatic = true
	elseif (goal13 ~= nil and goal13:isActive()) then
		playStatic = true
	elseif (goal14 ~= nil and goal14:isActive()) then
		playStatic = true
	end
	if (playStatic) then
		self:playRadioSound(volumeType)
	else
		self:stopRadioSound()
	end
	
end
-- ----------------------------------------------------------------------------
function layoutBedroom:onStartAudio()
	self:checkRadioSound()
end