-- << LOCAL FUNCTIONS >>

local function displayHomeArrowIcons(status)
	for a,b in pairs(mainFrame.Pages.Home:GetChildren()) do
		if b:FindFirstChild("Arrow") then
			b.Arrow.Visible = status
		end
	end
end

local function updateDragBar()
	if currentPage.Name == "Home" then
		local forceUpperFrom = main.hdAdminCoreName:find(" ")
		mainFrame.DragBar.Title.Text = main.hdAdminCoreName:sub(1, forceUpperFrom-1).. (main.hdAdminCoreName:sub(forceUpperFrom)):upper()
		mainFrame.DragBar.Back.Visible = false
		mainFrame.DragBar.Title.Position = UDim2.new(0.04, 0, 0.15, 0)
		displayHomeArrowIcons(true)
	else
		mainFrame.DragBar.Title.Text = string.upper(currentPage.Name)
		mainFrame.DragBar.Back.Visible = true
		mainFrame.DragBar.Title.Position = UDim2.new(0.15, 0, 0.15, 0)
		displayHomeArrowIcons(false)
	end
end

local function tweenPages(tweenOutPosition, tweenInPage, instantTween)
	local tweenTime
	if instantTween then
		tweenTime = 0
	else
		tweenTime = 0.3
	end
	local tweenInfoSlide = TweenInfo.new(tweenTime, Enum.EasingStyle.Quad)
	local oldPage = currentPage
	local tweenOut =  main.tweenService:Create(currentPage, tweenInfoSlide, {Position = tweenOutPosition})
	local tweenIn = main.tweenService:Create(tweenInPage, tweenInfoSlide, {Position = UDim2.new(0, 0, 0, 0)})
	if tweenInPage.Name == "Home" then
		tweenInPage.Position = UDim2.new(-1,0,0,0)
	else
		tweenInPage.Position = UDim2.new(1,0,0,0)
		if tweenInPage.Name == "Admin" then
			spawn(function() main:GetModule("PageAdmin"):UpdatePages() end)
		end
	end
	tweenInPage.Visible = true
	tweenOut:Play()
	tweenIn:Play()
	currentPage = tweenInPage
	updateDragBar()
	tweenIn.Completed:Wait()
	oldPage.Visible = false
end

