restaurant3 = {}

function restaurant3:initialize()
	local background = scenes.SCENE_INTERSTITIAL:child("BACKGROUND")
	
	background:newChildSprite({x=290, y=120, image="CABLE_BACK3", section="interstitial"})	x="290"	y="120"
	local gondolla1 = background:newChildSprite({x=372, y=222, image="GONDOLLA3", section="interstitial", pivotPoint={x=47,y=12}})
	local gondolla2 = background:newChildSprite({x=372, y=222, image="GONDOLLA3", section="interstitial", pivotPoint={x=47,y=12}})
	background:newChildSprite({x=290, y=120, image="CABLE_FRONT3", section="interstitial"})	
	background:newChildSprite({x=0, y=0, image="FOREGROUND3", section="interstitial"})
	
	local path = {
		{186, 248},
		{286, 233},
		{321, 228},
		{356, 223},
		{386, 218},
		{416, 213},
		{456, 204},
		{506, 191},
		{546, 180},
		{586, 167},
		{616, 158},
		{656, 145},
		{696, 132},
		{756, 115}
	}
	
	local anims = {}
	local totalDur = 0

	local tX = path[1][1]
	local tY = path[1][2]
	for i = 2, #path do
		local x = path[i][1]
		local y = path[i][2]
		local dur = 20 * math.sqrt((x-tX)*(x-tX) + (y-tY)*(y-tY))
		anims[#anims+1] = {x=x, y=y, duration=dur}
		tX = x
		tY = y
		totalDur = totalDur + dur
	end
	
	gondolla1:doEvery(0, function()
		gondolla1:setX(path[1][1])
		gondolla1:setY(path[1][2])
		gondolla1:animate(unpack(anims))
		return totalDur
	end)

	local firstTime = true
	gondolla2:doEvery(0, function()
		gondolla2:setX(path[1][1])
		gondolla2:setY(path[1][2])
		if (firstTime) then
			firstTime = false
			gondolla2:animate({delay=totalDur/2}, unpack(anims))
			return totalDur + totalDur/2
		else
			gondolla2:animate(unpack(anims))
			return totalDur
		end
	end)
	
	gondolla1:doEvery(0, function()
		local dur = 900 + math.random(200)
		gondolla1:animate({rotation=4, style="easeInOut", duration=dur}, {rotation=0, style="easeInOut", duration=dur})
		return 2*dur
	end)

	gondolla2:doEvery(0, function()
		local dur = 900 + math.random(200)
		gondolla2:animate({rotation=4, style="easeInOut", duration=dur}, {rotation=0, style="easeInOut", duration=dur})
		return 2*dur
	end)
end

function restaurant3:simpleAnimation()
	local background = scene:child("BACKGROUND")
	local black = scene:newChildSprite({x=0, y=0, image="BACKGROUND1", section="interstitial"})
	black:setColor({alpha=0, red=0, green=0, blue=0})
	
	moveCalender(false)
	moveButtons(false)
	moveRestSelection(false)
	
	black:animate(		
		{alpha=1, duration=1000},
		{command="updateObjects", target=background},
		{command="updateBackground", target=background},	
		{alpha=0, duration=1000},
		{call=function() 
			moveCalender(true)
			moveButtons(true)
			moveRestSelection(true)
			black:setObsolete() end}
	)
end
