-- Hologram announcements
-- JuzzbyXfalcon
-- 23 Nov. 2013


Interval = 5
Content = script.Parent.Base.Content
Footer = script.Parent.Base.Footer
Title = script.Parent.Base.Title

CurIndex = 0
MaxIndex = 1


function Update()
	local function AnimateOut()
		Title:TweenPosition(UDim2.new(0, 0, 0, -50), "Out", "Quart", 0.5, false)
		Footer:TweenPosition(UDim2.new(0,0,1,0), "Out", "Quart", 0.5, false)
		wait(0.3)
		Content:TweenPosition(UDim2.new(1, 0, 0, 60), "Out", "Quart", 0.5, false)
	end

	local function AnimateIn()
		Title:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.5, false)
		Footer:TweenPosition(UDim2.new(0,0,1,-25), "Out", "Quart", 0.5, false)
		Content.Position = UDim2.new(-1, 0, 0, 60)
		wait(0.3)
		Content:TweenPosition(UDim2.new(0, 0, 0, 60), "Out", "Quart", 0.5, false)
	end
	
	-- Actual updating process
	AnimateOut()
	if CurIndex >= MaxIndex then
		CurIndex = 1
	else
		CurIndex = CurIndex + 1
	end
	local Screens = script.Parent.Screens:GetChildren()
	wait(0.5)
	Title.Text = "  "..Screens[CurIndex].Title.Value
	Content.Content.Text = Screens[CurIndex].Content.Value
	wait(0.25)
	AnimateIn()
end

function Index()
	MaxIndex = #script.Parent.Screens:GetChildren()
end

Index()
script.Parent.Screens.DescendantAdded:connect(Index)

while true do
	wait(Interval)
	Update()
end
