function CreateButton ( x, y, z, font, t, color, hover )
	local h = font:get_height ( )
	local w = font:get_width ( t )
	local b = Clickable:Create ( x, y, z, w, h )
	b.sprite = Sprite ( x, y )
	b.sprite.depth = z
	b.sprite.color = color
	display:add_child ( b.sprite )
	b.sprite.canvas:set_font ( font )
	b.sprite.canvas:move_to ( 0, 0 )
	b.sprite.canvas:write ( t )
	AddGUIElement ( b )

	b.color = color
	b.hover = hover

	b.OnPress = function ( self, button, x, y )
		if button == MBUTTON_LEFT then
			if self.OnLeftButtonPress ~= nil then
				self:OnLeftButtonPress ( button, x, y )
			end
		end
	end
	b.EnterHover = function ( self, x, y )
		self.sprite.color = self.hover
	end
	b.ExitHover = function ( self, x, y )
		self.sprite.color = self.color
	end

	return b
end

function Destroy ( list )
	while #list > 0 do
		local last = list[#list]
		table.remove ( list )

		DestroyItem ( last )
	end
end

function DestroyItem ( last )
	display:remove_child ( last.sprite )
	last:Destroy ( )

	RemoveGUIElement ( last )
end


function CreateProfile ( slot, text )
	SaveProgress ( )

	profiles[slot] = text

	difficulty = 2
	showtips = true
	completed = false
	colorblind = false

	total_time = 0
	total_cleared = 0
	total_chains = 0
	total_longest_chain = 0

	for i, v in pairs ( levels ) do
		if i ~= 1 then
			v.locked = true
		end
	end

	profile_count = profile_count + 1
	current_profile = slot

	SaveProfiles ( )
	SaveProgress ( )
end





















createdialog_gui = {}
function ShowCreateProfileDialog ( slot )

	level_curtain3 = Sprite ( )
	level_curtain3.depth = -10001
	level_curtain3.canvas:rectangle ( resx, resy )
	level_curtain3.canvas:set_fill_style ( DARKRED, 1 )
	level_curtain3.canvas:fill ( )
	display:add_child ( level_curtain3 )

	level_curtain3.alpha = 0
	local effect = Fade:Create ( level_curtain3, 0.75 )
	effects:AddEffect ( effect, 250, 0 )

	-- grab mouse input
	clickable2 = Clickable:Create ( -resx_hw, -resy_hh, -10001, resx, resy )
	AddGUIElement ( clickable2 )

	local title = dialog_titles[#dialog_titles]
	local message = dialog_messages[#dialog_messages]

	local w = silkscreen14:get_width ( text.profile_name )
	local b = CreateButton ( -w / 2, 0, -10002, silkscreen14, text.profile_name, WHITE, WHITE )
	table.insert ( createdialog_gui, b )

	local w = silkscreen11:get_width ( text.enter_name )
	local b = CreateButton ( -w / 2, -20, -10002, silkscreen11, text.enter_name, WHITE, WHITE )
	table.insert ( createdialog_gui, b )


	newname = InputField:Create ( -100, -80, -10002, 200, 25, silkscreen14 )
	newname:SetValue ( text.newplayer .. slot )
	SetFocus ( newname )
	newname:SelectAll ( )
	AddGUIElement ( newname )


	local b = CreateButton ( -15, -110, -10002, silkscreen14, text.ok, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		CreateProfile ( slot, newname.text )
		HideCreateProfileDialog ( )
		ExitProfilesMenu ( )
	end
	table.insert ( createdialog_gui, b )
end

function HideCreateProfileDialog ( )

	display:remove_child ( level_curtain3 )
	level_curtain3 = nil

	RemoveGUIElement ( clickable2 )
	clickable2:Destroy ( )
	clickable2 = nil

	Destroy ( createdialog_gui )

	DestroyItem ( newname )
	newname = nil
end






deletedialog_gui = {}
function ShowDeleteProfileDialog ( )
	
	diag:play ( )

	level_curtain3 = Sprite ( )
	level_curtain3.depth = -10001
	level_curtain3.canvas:rectangle ( resx, resy )
	level_curtain3.canvas:set_fill_style ( DARKRED, 1 )
	level_curtain3.canvas:fill ( )
	display:add_child ( level_curtain3 )

	level_curtain3.alpha = 0
	local effect = Fade:Create ( level_curtain3, 0.75 )
	effects:AddEffect ( effect, 250, 0 )

	-- grab mouse input
	clickable2 = Clickable:Create ( -resx_hw, -resy_hh, -10001, resx, resy )
	AddGUIElement ( clickable2 )

	local title = dialog_titles[#dialog_titles]
	local message = dialog_messages[#dialog_messages]

	local w = silkscreen14:get_width ( text.delete )
	local b = CreateButton ( -w / 2, 0, -10002, silkscreen14, text.delete, WHITE, WHITE )
	table.insert ( deletedialog_gui, b )

	local sz = text.delete_sure .. " '" .. profiles[current_profile] .. "'?"
	local w = silkscreen11:get_width ( sz )
	local b = CreateButton ( -w / 2, -20, -10002, silkscreen11, sz, WHITE, WHITE )
	table.insert ( deletedialog_gui, b )

	local b = CreateButton ( -65, -60, -10002, silkscreen14, text.yes, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		HideDeleteProfileDialog ( )

		profiles[current_profile] = nil
		profile_count = profile_count - 1

		SaveProfiles ( )

		EnterProfilesMenu ( )
		ShowLoadProfileItems ( false )

		ShowDialog ( text.profiledeleted, text.selectanother )
	end
	table.insert ( deletedialog_gui, b )

	local b = CreateButton ( 30, -60, -10002, silkscreen14, text.no, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		HideDeleteProfileDialog ( )
	end
	table.insert ( deletedialog_gui, b )
end

function HideDeleteProfileDialog ( )
	display:remove_child ( level_curtain3 )
	level_curtain3 = nil

	RemoveGUIElement ( clickable2 )
	clickable2:Destroy ( )
	clickable2 = nil

	Destroy ( deletedialog_gui )
end



loadprofiles_gui = {}
function ShowLoadProfileItems ( allow_cancel )


	if swoosh ~= nil and sound_volume > 0 then
		swoosh:play ( )
	end


	local b = CreateButton ( -113, 200, -3000, silkscreen20, text.load_profile, WHITE, WHITE )
	table.insert ( loadprofiles_gui, b )

	local b = CreateButton ( -113, 180, -3000, silkscreen14, text.select_profile, WHITE, WHITE )
	table.insert ( loadprofiles_gui, b )


	local y = 150
	local x = -113
	for i = 1, 15 do
		local b
		if profiles[i] ~= nil then
			b = CreateButton ( x, y - ( i * 20 ), -3000, silkscreen11, i .. ". " .. profiles[i], WHITE, RED )
			b.sprite.canvas:rel_move_to ( 200, 0 )
			b.OnLeftButtonPress = function ( button, x, y )
				SaveProgress ( )
				current_profile = i
				if pcall ( LoadProgress ) == false then
					ShowDialog ( text.load_error, text.no_load )
					CreateProfile ( current_profile, profiles[current_profile] )

					ExitProfilesMenu ( )
					return
				end

				ExitProfilesMenu ( )
			end
		else
			b = CreateButton ( x, y - ( i * 20 ), -3000, silkscreen11, i .. ". " .. text.empty, GRAY, GRAY )
		end
		table.insert ( loadprofiles_gui, b )
	end

	if allow_cancel == true then
		local b = CreateButton ( -113, -190, -3000, silkscreen14, text.cancel, WHITE, RED )
		table.insert ( loadprofiles_gui, b )
		b.OnLeftButtonPress = function ( button, x, y )
			ExitProfilesMenu ( )
		end
	end
end

function HideLoadProfileItems ( )
	Destroy ( loadprofiles_gui, b )
end








createprofiles_gui = {}
function ShowCreateProfileItems ( )
	local b = CreateButton ( -113, 200, -3000, silkscreen17, text.create_profile, WHITE, WHITE )
	table.insert ( createprofiles_gui, b )

	local b = CreateButton ( -113, 180, -3000, silkscreen14, text.select_slot, WHITE, WHITE )
	table.insert ( createprofiles_gui, b )

	local y = 150
	local x = -113
	for i = 1, 15 do
		local b
		if profiles[i] ~= nil then
			b = CreateButton ( x, y - ( i * 20 ), -3000, silkscreen11, i .. ". " .. profiles[i], GRAY, GRAY )
		else
			b = CreateButton ( x, y - ( i * 20 ), -3000, silkscreen11, i .. ". " .. text.empty, WHITE, RED )
			b.sprite.canvas:rel_move_to ( 200, 0 )
			b.OnLeftButtonPress = function ( button, x, y )
				ShowCreateProfileDialog ( i )
			end
		end
		table.insert ( createprofiles_gui, b )
	end

	local b = CreateButton ( -113, -190, -3000, silkscreen14, text.cancel, WHITE, RED )
	table.insert ( createprofiles_gui, b )
	b.OnLeftButtonPress = function ( button, x, y )
		ExitProfilesMenu ( )
	end
end

function HideCreateProfileItems ( )
	Destroy ( createprofiles_gui, b )
end



function EnterProfilesMenu ( )

	if swoosh ~= nil and sound_volume > 0 then
		swoosh:play ( )
	end


	HideLevelselectMenu ( )
	HideOptionsMenu ( )
	HideProfileMenu ( )
	HideMenuItems ( )

	creditor.visible = false
	local effect = Move:Create ( title, -170, -5 )
	effects:AddEffect ( effect, 150, 0 )

	local effect = Resize:Create ( title, 0.9, 0.9 )
	effects:AddEffect ( effect, 150, 0 )

	local effect = Rotate:Create ( title, 90 )
	effects:AddEffect ( effect, 150, 0 )

	local sx = background.scalex + 0.6
	local sy = background.scaley - 0.6
	local effect = Resize:Create ( background, sx, sy )
	effects:AddEffect ( effect, 150, 0 )
	local effect = Move:Create ( background, -800, 800 )
	effects:AddEffect ( effect, 150, 0 )
	local effect = Rotate:Create ( background, -15 )
	effects:AddEffect ( effect, 150, 0 )
end

function ExitProfilesMenu ( )
	HideLoadProfileItems ( )
	HideCreateProfileItems ( )


	local effect = Move:Create ( title, 0, 150 )
	effects:AddEffect ( effect, 150, 0 )
	local effect = Resize:Create ( title, 1, 1 )
	effects:AddEffect ( effect, 150, 0 )
	local effect = Rotate:Create ( title, 0 )
	effects:AddEffect ( effect, 150, 0 )

	local sx = background.scalex - 0.6
	local sy = background.scaley + 0.6
	local effect = Resize:Create ( background, sx, sy )
	effects:AddEffect ( effect, 150, 0 )
	local effect = Move:Create ( background, -350 / camera_scaler, 340 / camera_scaler )
	effects:AddEffect ( effect, 150, 0 )
	local effect = Rotate:Create ( background, 0 )
	effects:AddEffect ( effect, 150, 0 )


	ShowMenuItems ( )
	ShowLevelselectMenu ( )
end















levelselect_gui = {}
function ShowLevelselectMenu ( )
	HideLevelselectMenu ( )
	HideOptionsMenu ( )
	HideProfileMenu ( )

	myprofile.color = WHITE
	myprofile.sprite.color = WHITE
	options.color = WHITE
	options.sprite.color = WHITE
	levelselect.color = RED
	levelselect.sprite.color = RED

	y = 23
	x = -163

	for i, v in pairs ( levels ) do
		local b
		if ( i == 1 ) or ( v.locked ~= nil and v.locked == false ) then
			b = CreateButton ( x, y - ( i * 20 ), -3000, silkscreen11, i .. ". " .. v.name, WHITE, RED )
			b.OnLeftButtonPress = function ( button, x, y )
				ExitMenu ( )
				state = 'playing'
				EnterLevel ( i )
			end
		else
			b = CreateButton ( x, y - ( i * 20 ), -3000, silkscreen11, i .. ". " .. v.name, GRAY, GRAY )
		end
		table.insert ( levelselect_gui, b )

		if i == 10 then
			y = 20 + ( i * 20 )
			x = x + 200
		end
	end
end

function HideLevelselectMenu ( )
	Destroy ( levelselect_gui )

	if visitus ~= nil then
		DestroyItem ( visitus )
		visitus = nil
	end
end



function ChangeDisplayMode ( x, y, w )
	dm = DisplayMode ( )
	dm.width = x
	dm.height = y
	dm.depth = 32
	dm.windowed = w
	dm.refresh = 0
	if display:set_mode ( dm ) == true then
		resx = x
		resy = y
		windowed = w
		resx_hw = resx / 2
		resy_hh = resy / 2
		camera_scaler = 600 / resy


--		viewport:resize ( resx, resy )
--  		viewport.camera:set_scale ( 1, 1 )

		if level_curtain ~= nil then
			level_curtain.canvas:clear ( )
			level_curtain.canvas:rectangle ( resx, resy )
			level_curtain.canvas:set_fill_style ( BLACK, 1 )
			level_curtain.canvas:fill ( )
		end

		if level_curtain2 ~= nil then
			level_curtain2.canvas:clear ( )
			level_curtain2.canvas:rectangle ( resx, resy )
			level_curtain2.canvas:set_fill_style ( BLACK, 1 )
			level_curtain2.canvas:fill ( )
		end

		local x = resx_hw - silkscreen11:get_width ( text.records ) - 20
		local y = resy_hh - 30
		records_button:SetPosition ( x, y )
		records_button.sprite:set_position ( x, y )

		background.scalex = 1.1 / camera_scaler
		background.scaley = -1.1 / camera_scaler
		background.x = -350 / camera_scaler
		background.y = 340 / camera_scaler
		
		HideMenuItems ( )
		ShowMenuItems ( )

		return true
	else
		ShowDialog ( "Video Error", "The selected display mode is not supported on your system" )
	end
	return false
end



options_gui = {}
function ShowOptionsMenu ( )
	HideLevelselectMenu ( )
	HideOptionsMenu ( )
	HideProfileMenu ( )


	myprofile.color = WHITE
	myprofile.sprite.color = WHITE
	options.color = RED
	options.sprite.color = RED
	levelselect.color = WHITE
	levelselect.sprite.color = WHITE
	

	local y = 5
	local b = CreateButton ( -160, y, -3000, silkscreen11, text.music_volume, WHITE, WHITE )
	table.insert ( options_gui, b )

	y = y - 30
	local slider = Slider:Create ( -160, y, -3000, 200, 25, 1 )
	slider:SetValue ( music_volume )
	slider.OnChange = function ( self, t )
		if music ~= nil and music_volume == 0 then
			music:load ( "Music/01-cellule.ogg" )
			music:play ( )
		end
		music_volume = t
		if music ~= nil then
			music.volume = music_volume
			if music_volume == 0 then
				music:unload ( )
			end
		end
		self:Paint ( )
	end
	AddGUIElement ( slider )
	table.insert ( options_gui, slider )



	y = y - 20
	local b = CreateButton ( -160, y, -3000, silkscreen11, text.sound_volume, WHITE, WHITE )
	table.insert ( options_gui, b )

	y = y - 30
	local slider = Slider:Create ( -160, y, -3000, 200, 25, 1 )
	slider:SetValue ( sound_volume )
	slider.OnChange = function ( self, t )
		sound_volume = t
		self:Paint ( )

		if audio ~= nil then
			advance.volume = sound_volume
			record.volume = sound_volume
			gameover.volume = sound_volume
			tip.volume = sound_volume
			swoosh.volume = sound_volume
			diag.volume = sound_volume
		end
	end
	AddGUIElement ( slider )
	table.insert ( options_gui, slider )





	local y = 5
	local b = CreateButton ( 60, y, -3000, silkscreen11, text.resolution, WHITE, WHITE )
	table.insert ( options_gui, b )


	y = y - 20
	if resx == 800 and resy == 600 then
		local b = CreateButton ( 60, y, -3000, silkscreen11, "800x600 (4:3)", RED, RED )
		table.insert ( options_gui, b )
	else
		local b = CreateButton ( 60, y, -3000, silkscreen11, "800x600 (4:3)", WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			if ChangeDisplayMode ( 800, 600, windowed ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, b )
	end

	y = y - 20
	if resx == 1024 and resy == 768 then
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1024x768 (4:3)", RED, RED )
		table.insert ( options_gui, b )
	else
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1024x768 (4:3)", WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			if ChangeDisplayMode ( 1024, 768, windowed ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, b )
	end



	y = y - 20
	if resx == 1152 and resy == 864 then
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1152x864 (4:3)", RED, RED )
		table.insert ( options_gui, b )
	else
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1152x864 (4:3)", WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			if ChangeDisplayMode ( 1152, 864, windowed ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, b )
	end



	y = y - 20
	if resx == 1280 and resy == 768 then
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1280x768 (15:9)", RED, RED )
		table.insert ( options_gui, b )
	else
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1280x768 (15:9)", WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			if ChangeDisplayMode ( 1280, 768, windowed ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, b )
	end



	y = y - 20
	if resx == 1280 and resy == 960 then
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1280x960 (4:3)", RED, RED )
		table.insert ( options_gui, b )
	else
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1280x960 (4:3)", WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			if ChangeDisplayMode ( 1280, 960, windowed ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, b )
	end


	y = y - 20
	if resx == 1280 and resy == 1024 then
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1280x1024 (5:4)", RED, RED )
		table.insert ( options_gui, b )
	else
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1280x1024 (5:4)", WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			if ChangeDisplayMode ( 1280, 1024, windowed ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, b )
	end


	y = y - 20
	if resx == 1600 and resy == 1200 then
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1600x1200 (4:3)", RED, RED )
		table.insert ( options_gui, b )
	else
		local b = CreateButton ( 60, y, -3000, silkscreen11, "1600x1200 (4:3)", WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			if ChangeDisplayMode ( 1600, 1200, windowed ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, b )
	end





	y = y - 30
	local b = CreateButton ( 60, y, -3000, silkscreen11, "Mode", WHITE, WHITE )
	table.insert ( options_gui, b )

	y = y - 20
	if windowed == false then
		local mode = CreateButton ( 60, y, -3000, silkscreen11, text.fullscreen, RED, RED )
		table.insert ( options_gui, mode )
	else
		local mode = CreateButton ( 60, y, -3000, silkscreen11, text.fullscreen, WHITE, RED )
		mode.OnLeftButtonPress = function ( button, x, y )
			dm = DisplayMode ( )
			display:get_mode ( dm )
			dm.windowed = not dm.windowed
			if ChangeDisplayMode ( resx, resy, false ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, mode )
	end


	y = y - 20
	if windowed == true then
		local mode = CreateButton ( 60, y, -3000, silkscreen11, text.windowed, RED, RED )
		table.insert ( options_gui, mode )
	else
		local mode = CreateButton ( 60, y, -3000, silkscreen11, text.windowed, WHITE, RED )
		mode.OnLeftButtonPress = function ( button, x, y )
			dm = DisplayMode ( )
			display:get_mode ( dm )
			dm.windowed = not dm.windowed
			if ChangeDisplayMode ( resx, resy, true ) == true then
				HideOptionsMenu ( )
				ShowOptionsMenu ( )
			end
		end
		table.insert ( options_gui, mode )
	end

end

function HideOptionsMenu ( )
	Destroy ( options_gui )
end






function FormatTime ( t )
	local hrs = math.floor ( t / 1000 / 60 / 60 )
	local mins = math.floor ( t / 1000 / 60 ) - ( hrs * 60 )
	local mins_sz
	if mins < 10 then
		mins_sz = "0" .. mins
	else
		mins_sz = mins
	end
	local secs = math.floor ( t / 1000 ) - ( hrs * 60 * 60 ) - ( mins * 60 )
	local secs_sz
	if secs < 10 then
		secs_sz = "0" .. secs
	else
		secs_sz = secs
	end

	return hrs .. ":" .. mins_sz .. ":" .. secs_sz
end



myprofile_gui = {}
function ShowProfileMenu ( )
	HideLevelselectMenu ( )
	HideOptionsMenu ( )
	HideProfileMenu ( )

	myprofile.color = RED
	myprofile.sprite.color = RED
	options.color = WHITE
	options.sprite.color = WHITE
	levelselect.color = WHITE
	levelselect.sprite.color = WHITE
	

	local y = 3
	local x = -160
	local b = CreateButton ( x, y, -3000, silkscreen11, text.profile, WHITE, WHITE )
	table.insert ( myprofile_gui, b )

	y = y - 30
	local inputfield = InputField:Create ( x, y, -3000, 200, 25, silkscreen14 )
	inputfield:SetValue ( profiles[current_profile] )
	inputfield.OnChange = function ( self, t )
		profiles[current_profile] = t
		DestroyItem ( name_label )
		name_label = CreateButton ( -resx_hw + 20, -resy_hh + 40, -3000, silkscreen14, t, RED, RED )
	end
	AddGUIElement ( inputfield )
	table.insert ( myprofile_gui, inputfield )








	x = 60
	y = 3
	local b = CreateButton ( x, y, -3000, silkscreen11, text.difficulty, WHITE, WHITE )
	table.insert ( myprofile_gui, b )


	y = y - 20
	if difficulty == 1 then
		local b = CreateButton ( x, y, -3000, silkscreen11, text.easy, RED, RED )
		table.insert ( myprofile_gui, b )
	else
		local b = CreateButton ( x, y, -3000, silkscreen11, text.easy, WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			difficulty = 1
			HideProfileMenu ( )
			ShowProfileMenu ( )
		end
		table.insert ( myprofile_gui, b )
	end

	x = 60
	x = x + silkscreen11:get_width ( text.easy ) + 10

--	y = y - 20
	if difficulty == 2 then
		local b = CreateButton ( x, y, -3000, silkscreen11, text.normal, RED, RED )
		table.insert ( myprofile_gui, b )
	else
		local b = CreateButton ( x, y, -3000, silkscreen11, text.normal, WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			difficulty = 2
			HideProfileMenu ( )
			ShowProfileMenu ( )
		end
		table.insert ( myprofile_gui, b )
	end
	x = x + silkscreen11:get_width ( text.normal ) + 10

--	y = y - 20
	if difficulty == 3 then
		local b = CreateButton ( x, y, -3000, silkscreen11, text.hard, RED, RED )
		table.insert ( myprofile_gui, b )
	else
		local b = CreateButton ( x, y, -3000, silkscreen11, text.hard, WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			difficulty = 3
			HideProfileMenu ( )
			ShowProfileMenu ( )
		end
		table.insert ( myprofile_gui, b )
	end



	x = 60
	y = y - 30
	local b = CreateButton ( x, y, -3000, silkscreen11, text.tips, WHITE, WHITE )
	table.insert ( myprofile_gui, b )


	y = y - 20
	if showtips == true then
		local b = CreateButton ( x, y, -3000, silkscreen11, text.on, RED, RED )
		table.insert ( myprofile_gui, b )
	else
		local b = CreateButton ( x, y, -3000, silkscreen11, text.on, WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			showtips = true
			HideProfileMenu ( )
			ShowProfileMenu ( )
		end
		table.insert ( myprofile_gui, b )
	end

	x = x + silkscreen11:get_width ( text.off ) + 10
--	y = y - 20
	if showtips == false then
		local b = CreateButton ( x, y, -3000, silkscreen11, text.off, RED, RED )
		table.insert ( myprofile_gui, b )
	else
		local b = CreateButton ( x, y, -3000, silkscreen11, text.off, WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			showtips = false
			HideProfileMenu ( )
			ShowProfileMenu ( )
		end
		table.insert ( myprofile_gui, b )
	end







	x = 60
	y = y - 30
	local b = CreateButton ( x, y, -3000, silkscreen11, "Colorblind fix", WHITE, WHITE )
	table.insert ( myprofile_gui, b )

	y = y - 20
	if colorblind == true then
		local b = CreateButton ( x, y, -3000, silkscreen11, text.on, RED, RED )
		table.insert ( myprofile_gui, b )
	else
		local b = CreateButton ( x, y, -3000, silkscreen11, text.on, WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			colorblind = true
			HideProfileMenu ( )
			ShowProfileMenu ( )
table.remove ( colors )
table.insert ( colors, CYAN )
		end
		table.insert ( myprofile_gui, b )
	end

	x = x + silkscreen11:get_width ( text.off ) + 10
--	y = y - 20
	if colorblind == false then
		local b = CreateButton ( x, y, -3000, silkscreen11, text.off, RED, RED )
		table.insert ( myprofile_gui, b )
	else
		local b = CreateButton ( x, y, -3000, silkscreen11, text.off, WHITE, RED )
		b.OnLeftButtonPress = function ( button, x, y )
			colorblind = false
			HideProfileMenu ( )
			ShowProfileMenu ( )
table.remove ( colors )
table.insert ( colors, LIME )
		end
		table.insert ( myprofile_gui, b )
	end










	x = 60
	y = y - 50
	local b = CreateButton ( x, y, -3000, silkscreen14, text.total_stats, WHITE, WHITE )
	table.insert ( myprofile_gui, b )

	y = y - 20
	local b = CreateButton ( x, y, -3000, silkscreen11, text.cleared .. ": " .. total_cleared, WHITE, WHITE )
	table.insert ( myprofile_gui, b )

	y = y - 20
	local b = CreateButton ( x, y, -3000, silkscreen11, text.chains .. ": " .. total_chains, WHITE, WHITE )
	table.insert ( myprofile_gui, b )

	y = y - 20
	local b = CreateButton ( x, y, -3000, silkscreen11, text.longest_chain .. ": " .. total_longest_chain, WHITE, WHITE )
	table.insert ( myprofile_gui, b )

	y = y - 20
	local b = CreateButton ( x, y, -3000, silkscreen11, text.playing_time .. ": " .. FormatTime ( total_time ), WHITE, WHITE )
	table.insert ( myprofile_gui, b )


end

function HideProfileMenu ( )
	Destroy ( myprofile_gui )
end













dialog_gui = {}
dialog_titles = {}
dialog_messages = {}

function ShowDialog ( title, message )

	if #dialog_titles == 0 then
		-- drop the second curtain
		level_curtain3 = Sprite ( )
		level_curtain3.depth = -10001
		level_curtain3.canvas:rectangle ( resx, resy )
		level_curtain3.canvas:set_fill_style ( DARKRED, 1 )
		level_curtain3.canvas:fill ( )
		display:add_child ( level_curtain3 )

		level_curtain3.alpha = 0
		local effect = Fade:Create ( level_curtain3, 0.75 )
		effects:AddEffect ( effect, 250, 0 )

		-- grab mouse input
		clickable2 = Clickable:Create ( -resx_hw, -resy_hh, -10001, resx, resy )
		AddGUIElement ( clickable2 )
	else
		Destroy ( dialog_gui )
	end

	table.insert ( dialog_titles, title )
	table.insert ( dialog_messages, message )
	ShowDialogContents ( )
end

function ShowDialogContents ( )
	local title = dialog_titles[#dialog_titles]
	local message = dialog_messages[#dialog_messages]

	local w = silkscreen14:get_width ( title )
	local b = CreateButton ( -w / 2, 0, -10002, silkscreen14, title, WHITE, WHITE )
	table.insert ( dialog_gui, b )

	local w = silkscreen11:get_width ( message )
	local b = CreateButton ( -w / 2, -20, -10002, silkscreen11, message, WHITE, WHITE )
	table.insert ( dialog_gui, b )

	local b = CreateButton ( -15, -60, -10002, silkscreen14, text.ok, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		HideDialog ( )
	end
	table.insert ( dialog_gui, b )
end

function HideDialog ( )
	table.remove ( dialog_titles )
	table.remove ( dialog_messages )

	Destroy ( dialog_gui )

	if #dialog_titles == 0 then
		display:remove_child ( level_curtain3 )
		level_curtain3 = nil

		RemoveGUIElement ( clickable2 )
		clickable2:Destroy ( )
		clickable2 = nil
	else
		ShowDialogContents ( )
	end
end






records_current = 'longest_chain'
records_current_leader = 'longest_chain_leader'

records_gui = {}
function ShowRecordItems ( )

	local y = 150
	local x = -113

	for i, v in pairs ( levels ) do
		local b
		if ( i == 1 ) or ( v.locked ~= nil and v.locked == false ) then
			b = CreateButton ( x, y - ( i * 20 ), -3000, silkscreen11, i .. ". " .. v.name, WHITE, RED )
			b.OnLeftButtonPress = function ( button, x, y )
				HideRecords ( )
				ExitMenu ( )
				state = 'playing'
				EnterLevel ( i )
			end
		else
			b = CreateButton ( x, y - ( i * 20 ), -3000, silkscreen11, i .. ". " .. v.name, GRAY, GRAY )
		end

			local l = records[i]
			if l[records_current][difficulty] ~= nil and l[records_current][difficulty] > 0 and l[records_current_leader][difficulty] ~= nil then
				b.sprite.canvas:move_to ( 250, 0 )
				if records_current == 'longest_time' or records_current == 'fastest' then
					local left = l[records_current][difficulty]
					if left < 0 then
						left = 0
					end
					local mins = math.floor ( left / 1000 / 60 )
					local secs = math.floor ( left / 1000 ) - ( mins * 60 )
					local left_sz
					if secs < 10 then
						left_sz = ( mins .. ":0" .. secs  )
					else
						left_sz = ( mins .. ":" .. secs  )
					end
					b.sprite.canvas:write ( left_sz .. " (" .. l[records_current_leader][difficulty] .. ")" )
				else
					b.sprite.canvas:write ( l[records_current][difficulty] .. " (" .. l[records_current_leader][difficulty] .. ")" )
				end
			end

		table.insert ( records_gui, b )
	end
end

function HideRecordItems ( )
	Destroy ( records_gui )
end

function ShowRecords ( )
	-- purge the effects queue
	while effects:IsDone ( ) == false do
		effects:Update ( 16 )
	end


	if swoosh ~= nil and sound_volume > 0 then
		swoosh:play ( )
	end

	creditor.visible = false
	local effect = Move:Create ( title, 30, 230 )
	effects:AddEffect ( effect, 150, 0 )

	local effect = Resize:Create ( title, 0.9, 0.9 )
	effects:AddEffect ( effect, 150, 0 )

	local sx = background.scalex + 0.6
	local sy = background.scaley - 0.6
	local effect = Resize:Create ( background, sx, sy )
	effects:AddEffect ( effect, 150, 0 )

	local dsz
	if difficulty == 1 then
		dsz = text.easy
	elseif difficulty == 2 then
		dsz = text.normal
	else
		dsz = text.hard
	end
	local sz = text.level_records .. " (" .. dsz .. ")"
	levelrecords = CreateButton ( -113, 180, -3000, silkscreen17, sz, WHITE, WHITE )


	local w = silkscreen11:get_width ( text.back )
	back = CreateButton ( resx_hw - w - 20, resy_hh - 30, -5000, silkscreen11, text.back, WHITE, RED )
	back.OnLeftButtonPress = function ( button, x, y )
		HideRecords ( )
		ShowMenuItems ( )
		ShowLevelselectMenu ( )
	end


	HideProfileMenu ( )
	HideOptionsMenu ( )
	HideLevelselectMenu ( )
	HideMenuItems ( )

	records_current = 'longest_chain'
	records_current_leader = 'longest_chain_leader'
	ShowRecordItems ( )

	local x = -113
	local y = 130

	local w = silkscreen14:get_width ( text.longest_chain )
	lpt = CreateButton ( x - w - 20, y, -5000, silkscreen14, text.longest_chain, RED, RED )
	lpt.OnLeftButtonPress = function ( button, x, y )
		records_current = 'longest_chain'
		records_current_leader = 'longest_chain_leader'
		HideRecordItems ( )
		ShowRecordItems ( )

		lpt.color = RED
		lpt.sprite.color = RED
		mc.color = WHITE
		mc.sprite.color = WHITE
		lt.color = WHITE
		lt.sprite.color = WHITE
		fc.color = WHITE
		fc.sprite.color = WHITE
		oc.color = WHITE
		oc.sprite.color = WHITE
	end

	y = y - 30
	local w = silkscreen14:get_width ( text.most_cleared )
	mc = CreateButton ( x - w - 20, y, -5000, silkscreen14, text.most_cleared, WHITE, RED )
	mc.OnLeftButtonPress = function ( button, x, y )
		records_current = 'cleared'
		records_current_leader = 'cleared_leader'
		HideRecordItems ( )
		ShowRecordItems ( )

		lpt.color = WHITE
		lpt.sprite.color = WHITE
		mc.color = RED
		mc.sprite.color = RED
		lt.color = WHITE
		lt.sprite.color = WHITE
		fc.color = WHITE
		fc.sprite.color = WHITE
		oc.color = WHITE
		oc.sprite.color = WHITE
	end

	y = y - 30
	local w = silkscreen14:get_width ( text.longest_playing_time )
	lt = CreateButton ( x - w - 20, y, -5000, silkscreen14, text.longest_playing_time, WHITE, RED )
	lt.OnLeftButtonPress = function ( button, x, y )
		records_current = 'longest_time'
		records_current_leader = 'longest_time_leader'
		HideRecordItems ( )
		ShowRecordItems ( )

		lpt.color = WHITE
		lpt.sprite.color = WHITE
		mc.color = WHITE
		mc.sprite.color = WHITE
		lt.color = RED
		lt.sprite.color = RED
		fc.color = WHITE
		fc.sprite.color = WHITE
		oc.color = WHITE
		oc.sprite.color = WHITE
	end

	y = y - 30
	local w = silkscreen14:get_width ( text.fastest_completion )
	fc = CreateButton ( x - w - 20, y, -5000, silkscreen14, text.fastest_completion, WHITE, RED )
	fc.OnLeftButtonPress = function ( button, x, y )
		records_current = 'fastest'
		records_current_leader = 'fastest_leader'
		HideRecordItems ( )
		ShowRecordItems ( )

		lpt.color = WHITE
		lpt.sprite.color = WHITE
		mc.color = WHITE
		mc.sprite.color = WHITE
		lt.color = WHITE
		lt.sprite.color = WHITE
		fc.color = RED
		fc.sprite.color = RED
		oc.color = WHITE
		oc.sprite.color = WHITE
	end

	y = y - 30
	local w = silkscreen14:get_width ( text.optimal_completion )
	oc = CreateButton ( x - w - 20, y, -5000, silkscreen14, text.optimal_completion, WHITE, RED )
	oc.OnLeftButtonPress = function ( button, x, y )
		records_current = 'optimal'
		records_current_leader = 'optimal_leader'
		HideRecordItems ( )
		ShowRecordItems ( )

		lpt.color = WHITE
		lpt.sprite.color = WHITE
		mc.color = WHITE
		mc.sprite.color = WHITE
		lt.color = WHITE
		lt.sprite.color = WHITE
		fc.color = WHITE
		fc.sprite.color = WHITE
		oc.color = RED
		oc.sprite.color = RED
	end


	y = y - 260
	local w = silkscreen11:get_width ( text.clear_records )
	cr = CreateButton ( x - w - 20, y, -5000, silkscreen11, text.clear_records, WHITE, RED )
	cr.OnLeftButtonPress = function ( button, x, y )
		ShowClearRecordsDialog ( )
	end
end

function HideRecords ( )

	-- purge the effects queue
	while effects:IsDone ( ) == false do
		effects:Update ( 16 )
	end

	local effect = Move:Create ( title, 0, 150 )
	effects:AddEffect ( effect, 150, 0 )
	local effect = Resize:Create ( title, 1, 1 )
	effects:AddEffect ( effect, 150, 0 )

	local sx = background.scalex - 0.6
	local sy = background.scaley + 0.6
	local effect = Resize:Create ( background, sx, sy )
	effects:AddEffect ( effect, 150, 0 )

	HideRecordItems ( )

	DestroyItem ( levelrecords )
	DestroyItem ( back )

	DestroyItem ( lpt )
	DestroyItem ( mc )
	DestroyItem ( lt )
	DestroyItem ( fc )
	DestroyItem ( oc )

	DestroyItem ( cr )

	creditor.visible = true
end














clearrecordsdialog_gui = {}
function ShowClearRecordsDialog ( )

	if diag ~= nil and sound_volume > 0 then
		diag:play ( )
	end

	level_curtain3 = Sprite ( )
	level_curtain3.depth = -10001
	level_curtain3.canvas:rectangle ( resx, resy )
	level_curtain3.canvas:set_fill_style ( DARKRED, 1 )
	level_curtain3.canvas:fill ( )
	display:add_child ( level_curtain3 )

	level_curtain3.alpha = 0
	local effect = Fade:Create ( level_curtain3, 0.75 )
	effects:AddEffect ( effect, 250, 0 )

	-- grab mouse input
	clickable2 = Clickable:Create ( -resx_hw, -resy_hh, -10001, resx, resy )
	AddGUIElement ( clickable2 )

	local title = dialog_titles[#dialog_titles]
	local message = dialog_messages[#dialog_messages]

	local w = silkscreen14:get_width ( text.clear_records )
	local b = CreateButton ( -w / 2, 0, -10002, silkscreen14, text.clear_records, WHITE, WHITE )
	table.insert ( clearrecordsdialog_gui, b )

	local w = silkscreen11:get_width ( text.clear_sure )
	local b = CreateButton ( -w / 2, -20, -10002, silkscreen11, text.clear_sure, WHITE, WHITE )
	table.insert ( clearrecordsdialog_gui, b )

	local b = CreateButton ( -65, -60, -10002, silkscreen14, text.yes, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		for i, v in pairs ( levels ) do
			records[i] = {}
			records[i].longest_chain = { 0, 0, 0 }
			records[i].longest_chain_leader = { "", "", "" }
			records[i].cleared = { 0, 0, 0 }
			records[i].cleared_leader = { "", "", "" }
			records[i].longest_time = { 0, 0, 0 }
			records[i].longest_time_leader = { "", "", "" }
			records[i].fastest = { 0, 0, 0 }
			records[i].fastest_leader = { "", "", "" }
			records[i].optimal = { 0, 0, 0 }
			records[i].optimal_leader = { "", "", "" }
		end
		pcall ( SaveRecords )
		HideClearProfileDialog ( )
		HideRecordItems ( )
		ShowRecordItems ( )
	end
	table.insert ( clearrecordsdialog_gui, b )

	local b = CreateButton ( 30, -60, -10002, silkscreen14, text.no, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		HideClearProfileDialog ( )
	end
	table.insert ( clearrecordsdialog_gui, b )
end

function HideClearProfileDialog ( )
	display:remove_child ( level_curtain3 )
	level_curtain3 = nil

	RemoveGUIElement ( clickable2 )
	clickable2:Destroy ( )
	clickable2 = nil

	Destroy ( clearrecordsdialog_gui )
end












menuitems_gui = {}
function ShowMenuItems ( )

	local y = 0
	local w = silkscreen17:get_width ( text.levelselect )
	levelselect = CreateButton ( -162 - w - 20, y, -5000, silkscreen17, text.levelselect, RED, RED )
	levelselect.OnLeftButtonPress = function ( button, x, y )
		ShowLevelselectMenu ( )
	end

	y = y - 30
	local w = silkscreen17:get_width ( text.myprofile )
	myprofile = CreateButton ( -162 - w - 20, y, -5000, silkscreen17, text.myprofile, WHITE, RED )
	myprofile.OnLeftButtonPress = function ( button, x, y )
		ShowProfileMenu ( )
	end

	y = y - 30
	local w = silkscreen17:get_width ( text.options )
	options = CreateButton ( -162 - w - 20, y, -5000, silkscreen17, text.options, WHITE, RED )
	options.OnLeftButtonPress = function ( button, x, y )
		ShowOptionsMenu ( )
	end

if demo == true then
	y = y - 25
	local w = silkscreen14:get_width ( "Buy it" )
	buynow = CreateButton ( -162 - w - 20, y, -5000, silkscreen14, "Buy it", WHITE, RED )
	buynow.OnLeftButtonPress = function ( button, x, y )
		open_url ( "http://2dengine.com/chains/" )
	end
end

	y = y - 25
	local w = silkscreen14:get_width ( text.quit )
	quit = CreateButton ( -162 - w - 20, y, -5000, silkscreen14, text.quit, WHITE, RED )
	quit.OnLeftButtonPress = function ( button, x, y )
		display:destroy ( )
	end

	local w = silkscreen11:get_width ( text.records )
	records_button = CreateButton ( resx_hw - w - 20, resy_hh - 30, -5000, silkscreen11, text.records, WHITE, RED )
	records_button.OnLeftButtonPress = function ( button, x, y )
		ShowRecords ( )
	end




	local x = -resx_hw + 20
	y = -resy_hh + 20
	local b = CreateButton ( x, y, -3000, silkscreen11, text.create, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		if profile_count >= 15 then
			ShowDialog ( text.slots_error, text.no_slots )
			return
		end
		EnterProfilesMenu ( )
		ShowCreateProfileItems ( )
	end
	table.insert ( menuitems_gui, b )

	x = x + silkscreen11:get_width ( text.create ) + 10
	local b = CreateButton ( x, y, -3000, silkscreen11, text.load, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		if profile_count == 0 then
			ShowDialog ( text.nload_error, text.no_nload )
			return
		end
		EnterProfilesMenu ( )
		ShowLoadProfileItems ( true )
	end
	table.insert ( menuitems_gui, b )


	x = x + silkscreen11:get_width ( text.load ) + 10
	local b = CreateButton ( x, y, -3000, silkscreen11, text.delete, WHITE, RED )
	b.OnLeftButtonPress = function ( button, x, y )
		if profile_count <= 1 then
			ShowDialog ( text.left_error, text.no_left )
			return
		end
		ShowDeleteProfileDialog ( )
	end
	table.insert ( menuitems_gui, b )

	name_label = CreateButton ( -resx_hw + 20, -resy_hh + 40, -3000, silkscreen14, profiles[current_profile], RED, RED )
end

function HideMenuItems ( )
	if levelselect then
		DestroyItem ( levelselect )
		levelselect = nil
	end
	if options then
		DestroyItem ( options )
		options = nil
	end
	if quit then
		DestroyItem ( quit )
		quit = nil
	end

	if buynow then
		DestroyItem ( buynow )
		buynow = nil
	end

	if records_button then
		DestroyItem ( records_button )
		records_button = nil
	end

	if myprofile then
		DestroyItem ( myprofile )
		myprofile = nil
	end

	if name_label then
		DestroyItem ( name_label )
		name_label = nil
	end

	Destroy ( menuitems_gui )
end




function EnterMainMenu ( )
	if music ~= nil and music_volume > 0 then
		music:load ( "Music/01-cellule.ogg" )
		music:play ( )
		music.volume = music_volume
	end

	-- purge the effects queue
	while effects:IsDone ( ) == false do
		effects:Update ( 16 )
	end


	-- drop the curtain
	level_curtain.alpha = 1
	level_curtain.visible = true

	-- drop the second curtain
	level_curtain2 = Sprite ( )
	level_curtain2.depth = -10000
	level_curtain2.canvas:rectangle ( resx, resy )
	level_curtain2.canvas:set_fill_style ( BLACK, 1 )
	level_curtain2.canvas:fill ( )
	display:add_child ( level_curtain2 )

	level_curtain2.visible = true
	local effect = Fade:Create ( level_curtain2, 0 )
	effects:AddEffect ( effect, 3000, 0 )
	local effect = ChangeVisibility:Create ( level_curtain2, false )
	effects:AddEffect ( effect, 0, 3001 )


	credits_current = 0
	credits_time = 0


	title = Sprite ( 0, 150 )
	title.canvas:set_source_image ( title_image )
	title.canvas:paint ( )
	title.depth = -3000 - 1
	display:add_child ( title )

	ShowMenuItems ( )
	ShowLevelselectMenu ( )

	background = Sprite ( -350 / camera_scaler, 340 / camera_scaler )

	background.canvas:move_to ( 614.03932 , 693.89125 )
	background.canvas:curve_to ( 581.0588 , 670.71933 , 602.48732 , 689.78053 , 594.82583 , 684.39761 )
	background.canvas:curve_to ( 527.17925 , 594.75402 , 561.97486 , 651.7584 , 547.3003 , 631.0686 )
	background.canvas:curve_to ( 477.64488 , 486.71933 , 507.55986 , 559.34482 , 486.06213 , 512.45818 )
	background.canvas:curve_to ( 472.57417 , 472.82528 , 475.30666 , 479.56933 , 473.02483 , 473.31701 )
	background.canvas:curve_to ( 472.27896 , 473.93571 , 472.1235 , 472.33355 , 471.99066 , 472.83324 )
	background.canvas:curve_to ( 450.80092 , 514.53394 , 473.117 , 477.14038 , 458.32666 , 505.09739 )
	background.canvas:curve_to ( 445.58109 , 522.84697 , 449.12772 , 516.63198 , 446.7788 , 520.37284 )
	background.canvas:curve_to ( 414.23771 , 529.39143 , 440.58644 , 533.16454 , 429.24209 , 535.53322 )
	background.canvas:curve_to ( 400.23771 , 521.5724 , 409.88987 , 527.61171 , 403.58987 , 524.09315 )
	background.canvas:curve_to ( 368.74861 , 504.84042 , 393.97357 , 516.8619 , 379.80267 , 509.33209 )
	background.canvas:curve_to ( 341.39372 , 511.45882 , 360.00186 , 501.2863 , 358.55237 , 501.637 )
	background.canvas:curve_to ( 299.08873 , 528.24561 , 331.75094 , 516.97847 , 328.35151 , 518.32738 )
	background.canvas:curve_to ( 234.64288 , 538.6635 , 273.08499 , 537.05924 , 263.6265 , 538.58823 )
	background.canvas:curve_to ( 202.69684 , 536.38111 , 215.62342 , 538.71289 , 211.93768 , 538.44956 )
	background.canvas:curve_to ( 154.64224 , 513.17373 , 183.85589 , 532.1638 , 170.4295 , 525.67969 )
	background.canvas:curve_to ( 85.594819 , 415.21933 , 131.66791 , 494.97449 , 109.92828 , 464.13348 )
	background.canvas:curve_to ( 65.138339 , 367.21933 , 72.485849 , 388.86819 , 65.915359 , 373.4509 )
	background.canvas:curve_to ( 63.047709 , 359.50451 , 64.761159 , 364.19433 , 63.820369 , 360.72266 )
	background.canvas:curve_to ( 61.642879 , 355.90598 , 62.275059 , 358.28636 , 61.642879 , 356.66702 )
	background.canvas:curve_to ( 52.892879 , 352.23583 , 61.642879 , 355.00731 , 58.575599 , 353.72076 )
	background.canvas:curve_to ( 15.870191 , 338.56011 , 40.586852 , 349.02018 , 26.925879 , 343.97399 )
	background.canvas:line_to ( 6.4109136 , 333.92799 )
	background.canvas:line_to ( 2.4707776 , 325.71652 )
	background.canvas:curve_to ( 0.24419857 , 278.38078 , -5.0232844 , 310.09848 , -5.6914854 , 295.89294 )
	background.canvas:curve_to ( 26.822611 , 232.71933 , 5.0366226 , 264.24159 , 16.991005 , 243.70409 )
	background.canvas:curve_to ( 36.654063 , 221.21933 , 29.776185 , 229.41933 , 34.200339 , 224.24433 )
	background.canvas:curve_to ( 41.696048 , 215.21933 , 39.107788 , 218.19433 , 41.376681 , 215.49433 )
	background.canvas:curve_to ( 114.75853 , 112.21933 , 44.386998 , 212.90221 , 75.318919 , 169.29587 )
	background.canvas:line_to ( 135.14288 , 82.719326 )
	background.canvas:line_to ( 142.64288 , 78.962526 )
	background.canvas:curve_to ( 171.74376 , 70.870656 , 152.65664 , 73.946556 , 158.186 , 72.409046 )
	background.canvas:curve_to ( 192.14288 , 71.870886 , 182.63891 , 69.634396 , 183.54078 , 69.678616 )
	background.canvas:curve_to ( 223.64288 , 83.943096 , 203.36521 , 74.730916 , 215.17483 , 79.256896 )
	background.canvas:curve_to ( 295.0528 , 159.09223 , 246.5138 , 96.599816 , 261.25182 , 112.10956 )
	background.canvas:curve_to ( 377.86 , 246.34129 , 324.54577 , 200.08686 , 345.2901 , 221.94394 )
	background.canvas:curve_to ( 407.64288 , 266.77062 , 390.62803 , 255.90553 , 407.64288 , 267.57672 )
	background.canvas:curve_to ( 400.53489 , 255.49482 , 407.64288 , 266.49545 , 404.44428 , 261.42134 )
	background.canvas:curve_to ( 379.00671 , 213.4804 , 391.94439 , 242.47189 , 388.89174 , 236.51434 )
	background.canvas:curve_to ( 357.2627 , 142.21933 , 367.13689 , 185.82155 , 362.2249 , 169.72362 )
	background.canvas:curve_to ( 352.93467 , 53.719326 , 352.31094 , 114.77296 , 351.06102 , 89.214446 )
	background.canvas:curve_to ( 372.9926 , 2.0444797 , 355.00743 , 14.452331 , 358.06349 , 6.5790557 )
	background.canvas:curve_to ( 393.05674 , 0.56358471 , 379.18321 , 0.16413971 , 381.44724 , -0.0029642857 )
	background.canvas:curve_to ( 430.64288 , 3.6956847 , 400.25412 , 0.91481971 , 417.16788 , 2.3242647 )
	background.canvas:curve_to ( 575.64288 , 9.1705887 , 491.32735 , 9.8718537 , 539.28358 , 11.682584 )
	background.canvas:curve_to ( 599.6196 , 8.0473057 , 586.36788 , 8.4296197 , 597.15741 , 7.9241417 )
	background.canvas:curve_to ( 612.09024 , 96.719326 , 620.72448 , 9.1030137 , 624.16894 , 33.594756 )
	background.canvas:curve_to ( 607.03995 , 122.56484 , 610.1959 , 106.61933 , 607.92327 , 118.24981 )
	background.canvas:curve_to ( 606.29396 , 131.27041 , 606.14348 , 126.94408 , 605.81389 , 130.79034 )
	background.canvas:curve_to ( 642.64844 , 132.82796 , 606.76698 , 131.74343 , 623.1265 , 132.44433 )
	background.canvas:line_to ( 678.14288 , 133.52547 )
	background.canvas:line_to ( 679.5102 , 130.6224 )
	background.canvas:curve_to ( 698.14288 , 115.95882 , 683.67485 , 121.78007 , 684.72896 , 120.9505 )
	background.canvas:curve_to ( 752.25548 , 118.77448 , 713.25245 , 110.33613 , 726.73023 , 111.03743 )
	background.canvas:curve_to ( 789.20986 , 143.75555 , 770.41007 , 124.27738 , 785.72483 , 134.63012 )
	background.canvas:curve_to ( 787.77083 , 163.66298 , 791.29583 , 149.21759 , 790.73622 , 156.95923 )
	background.canvas:curve_to ( 747.64288 , 204.1902 , 785.27738 , 169.29985 , 770.72518 , 183.99684 )
	background.canvas:curve_to ( 723.01805 , 226.67221 , 738.56788 , 212.12939 , 727.48671 , 222.24629 )
	background.canvas:curve_to ( 715.34069 , 233.55885 , 718.5494 , 231.09813 , 715.09458 , 234.19712 )
	background.canvas:curve_to ( 711.61907 , 234.46107 , 715.58679 , 232.92059 , 713.91206 , 233.32659 )
	background.canvas:curve_to ( 701.95857 , 234.79275 , 707.55794 , 236.47036 , 707.3078 , 236.47895 )
	background.canvas:curve_to ( 696.14357 , 233.39053 , 698.93828 , 233.84069 , 696.32154 , 233.20969 )
	background.canvas:curve_to ( 682.48972 , 268.62797 , 695.41675 , 234.1291 , 687.0865 , 255.62755 )
	background.canvas:curve_to ( 649.14271 , 336.78808 , 672.7041 , 296.30323 , 664.53915 , 312.9921 )
	background.canvas:curve_to ( 629.05233 , 355.41973 , 645.773 , 341.99614 , 636.29412 , 350.78678 )
	background.canvas:curve_to ( 616.6766 , 362.20238 , 626.80253 , 356.85905 , 621.23345 , 359.91124 )
	background.canvas:line_to ( 608.39142 , 366.36808 )
	background.canvas:line_to ( 609.04144 , 371.04371 )
	background.canvas:curve_to ( 610.67814 , 385.14697 , 609.39895 , 373.6153 , 610.13547 , 379.96177 )
	background.canvas:curve_to ( 611.90385 , 394.77372 , 611.22081 , 390.33217 , 611.77238 , 394.66421 )
	background.canvas:curve_to ( 665.45102 , 409.16769 , 612.40689 , 395.19276 , 639.26464 , 402.41237 )
	background.canvas:curve_to ( 768.14288 , 437.34902 , 694.19509 , 416.58282 , 721.81311 , 424.16192 )
	background.canvas:curve_to ( 820.93469 , 459.24014 , 798.87722 , 446.0971 , 812.36913 , 451.69177 )
	background.canvas:curve_to ( 828.58708 , 481.71933 , 828.89941 , 466.25903 , 831.00747 , 472.45153 )
	background.canvas:curve_to ( 813.34266 , 499.58824 , 827.73926 , 484.96568 , 824.86702 , 488.3324 )
	background.canvas:curve_to ( 785.64288 , 523.75636 , 805.53278 , 507.21614 , 793.06788 , 518.09179 )
	background.canvas:curve_to ( 697.91377 , 621.71933 , 753.00073 , 548.65917 , 733.40385 , 570.5421 )
	background.canvas:curve_to ( 659.2347 , 680.71933 , 687.85259 , 636.22772 , 663.54236 , 673.30987 )
	background.canvas:curve_to ( 639.39046 , 694.87476 , 656.54418 , 685.34719 , 645.35755 , 693.32692 )
	background.canvas:curve_to ( 614.03932 , 693.89125 , 631.73365 , 696.86091 , 621.24071 , 696.45383 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 615.27474 , 648.38034 )
	background.canvas:curve_to ( 665.64288 , 605.69949 , 627.44619 , 644.1736 , 632.32266 , 640.04139 )
	background.canvas:curve_to ( 762.30084 , 523.8893 , 692.54729 , 577.97012 , 720.47054 , 554.33621 )
	background.canvas:curve_to ( 790.95398 , 502.12979 , 775.01816 , 514.63278 , 787.91207 , 504.841 )
	background.canvas:curve_to ( 797.03424 , 478.69387 , 799.55504 , 494.46379 , 801.7709 , 485.92292 )
	background.canvas:curve_to ( 772.81005 , 461.36359 , 794.34643 , 474.59175 , 783.55912 , 466.87438 )
	background.canvas:curve_to ( 697.14288 , 430.82182 , 755.1541 , 452.3118 , 705.54598 , 432.28832 )
	background.canvas:curve_to ( 640.14288 , 412.34977 , 693.31758 , 430.15423 , 642.21759 , 413.5942 )
	background.canvas:curve_to ( 638.39288 , 411.60964 , 639.59288 , 412.01987 , 638.80538 , 411.68681 )
	background.canvas:curve_to ( 637.14288 , 411.21933 , 637.98038 , 411.53247 , 637.41788 , 411.35683 )
	background.canvas:curve_to ( 635.89288 , 410.75796 , 636.86788 , 411.08183 , 636.30538 , 410.87422 )
	background.canvas:curve_to ( 633.64288 , 409.88666 , 635.48038 , 410.64171 , 634.46788 , 410.24963 )
	background.canvas:curve_to ( 622.03121 , 405.83579 , 632.81788 , 409.5237 , 627.59263 , 407.70081 )
	background.canvas:line_to ( 611.91954 , 402.44484 )
	background.canvas:line_to ( 610.70505 , 417.58208 )
	background.canvas:curve_to ( 601.65936 , 460.18703 , 609.43484 , 433.41368 , 605.24104 , 453.16635 )
	background.canvas:curve_to ( 581.65673 , 478.21234 , 599.05072 , 465.30039 , 588.62683 , 474.69384 )
	background.canvas:curve_to ( 556.04292 , 481.28681 , 574.48435 , 481.83294 , 565.60184 , 482.89913 )
	background.canvas:curve_to ( 551.54643 , 475.28122 , 546.03426 , 479.59863 , 545.63966 , 479.07159 )
	background.canvas:curve_to ( 577.24494 , 434.71933 , 564.6545 , 466.8698 , 573.30505 , 453.21598 )
	background.canvas:curve_to ( 579.95429 , 393.30215 , 578.74068 , 427.69725 , 580.78329 , 396.47227 )
	background.canvas:curve_to ( 567.8275 , 387.79122 , 579.65249 , 392.14806 , 575.80275 , 390.39858 )
	background.canvas:curve_to ( 554.70092 , 382.84524 , 561.40096 , 385.69019 , 555.494 , 383.4645 )
	background.canvas:curve_to ( 553.94217 , 382.85968 , 553.62766 , 382.00722 , 553.43365 , 382.01091 )
	background.canvas:curve_to ( 551.2219 , 384.63853 , 554.37847 , 383.58791 , 553.39538 , 384.23078 )
	background.canvas:curve_to ( 546.73199 , 388.39355 , 548.57104 , 385.13583 , 547.57817 , 385.96619 )
	background.canvas:curve_to ( 542.05062 , 395.89722 , 546.13446 , 390.10763 , 544.02784 , 393.48429 )
	background.canvas:curve_to ( 524.20537 , 411.21933 , 538.57939 , 400.1334 , 525.6679 , 411.21933 )
	background.canvas:curve_to ( 520.57352 , 408.30382 , 523.81138 , 411.21933 , 522.17705 , 409.90735 )
	background.canvas:curve_to ( 503.75392 , 403.7671 , 517.22815 , 404.95845 , 509.40804 , 402.84914 )
	background.canvas:curve_to ( 478.61112 , 410.86171 , 500.05213 , 404.36809 , 491.90789 , 406.66617 )
	background.canvas:curve_to ( 467.22096 , 415.86006 , 474.46865 , 412.16879 , 469.34308 , 414.41805 )
	background.canvas:curve_to ( 464.16397 , 417.10062 , 465.09884 , 417.30208 , 463.72319 , 417.86033 )
	background.canvas:curve_to ( 462.48968 , 417.96933 , 464.60475 , 416.34091 , 463.85132 , 416.73183 )
	background.canvas:curve_to ( 459.50302 , 420.21933 , 461.12804 , 419.20683 , 459.78405 , 420.21933 )
	background.canvas:curve_to ( 448.06747 , 430.70506 , 459.222 , 420.21933 , 454.076 , 424.93791 )
	background.canvas:curve_to ( 436.27798 , 441.20506 , 442.05895 , 436.47222 , 436.75368 , 441.19722 )
	background.canvas:curve_to ( 408.10763 , 464.1623 , 434.78097 , 441.22976 , 407.61635 , 463.36739 )
	background.canvas:curve_to ( 378.29225 , 490.94674 , 408.77344 , 465.23959 , 384.46127 , 487.08026 )
	background.canvas:curve_to ( 375.14288 , 494.21206 , 374.73787 , 493.17448 , 373.76237 , 494.1859 )
	background.canvas:curve_to ( 375.86823 , 495.0589 , 376.55144 , 494.23875 , 376.76594 , 494.48918 )
	background.canvas:curve_to ( 398.34407 , 507.27366 , 375.04211 , 495.58318 , 382.95112 , 499.88142 )
	background.canvas:curve_to ( 428.67115 , 519.05109 , 419.93866 , 517.64414 , 422.69154 , 518.71321 )
	background.canvas:curve_to ( 438.40514 , 516.76592 , 434.61375 , 519.38687 , 435.55212 , 519.16658 )
	background.canvas:curve_to ( 457.06288 , 474.15018 , 444.19442 , 511.89457 , 455.43814 , 486.21302 )
	background.canvas:curve_to ( 459.58968 , 455.71933 , 457.39112 , 471.71321 , 458.52818 , 463.41933 )
	background.canvas:curve_to ( 462.19624 , 433.99637 , 460.65118 , 448.01933 , 461.82413 , 438.244 )
	background.canvas:curve_to ( 464.00783 , 425.4265 , 462.56834 , 429.74874 , 463.38356 , 425.8923 )
	background.canvas:curve_to ( 469.54369 , 423.18963 , 464.63211 , 424.9607 , 467.12324 , 423.9541 )
	background.canvas:curve_to ( 486.54023 , 425.00685 , 473.66589 , 421.88766 , 474.74192 , 422.00271 )
	background.canvas:curve_to ( 536.00598 , 481.2583 , 515.72675 , 432.43845 , 522.42769 , 440.05862 )
	background.canvas:curve_to ( 547.12693 , 524.2583 , 540.69414 , 495.48323 , 543.71871 , 507.17798 )
	background.canvas:curve_to ( 579.23336 , 635.36828 , 559.00471 , 583.78396 , 569.08152 , 618.65655 )
	background.canvas:curve_to ( 615.27474 , 648.38034 , 586.86199 , 647.92635 , 601.40108 , 653.17541 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 228.39946 , 527.75204 )
	background.canvas:curve_to ( 333.53149 , 495.46778 , 265.6812 , 522.13768 , 311.43554 , 508.08731 )
	background.canvas:line_to ( 338.66843 , 492.53396 )
	background.canvas:line_to ( 328.56077 , 487.87627 )
	background.canvas:curve_to ( 317.39349 , 483.87346 , 323.00156 , 485.31454 , 317.97628 , 483.51328 )
	background.canvas:curve_to ( 317.00289 , 483.44583 , 316.79599 , 484.24274 , 316.62564 , 484.05624 )
	background.canvas:curve_to ( 315.4074 , 481.67513 , 317.37931 , 482.83678 , 316.68149 , 482.06233 )
	background.canvas:curve_to ( 307.14288 , 475.92256 , 314.16191 , 481.29662 , 310.44288 , 478.70796 )
	background.canvas:curve_to ( 298.11769 , 469.21933 , 297.12671 , 467.46831 , 297.18622 , 467.51251 )
	background.canvas:curve_to ( 297.86068 , 469.71933 , 298.68938 , 470.2669 , 298.61186 , 470.41771 )
	background.canvas:curve_to ( 290.78215 , 453.44714 , 295.69771 , 467.70841 , 291.49582 , 458.04906 )
	background.canvas:curve_to ( 311.55031 , 428.75081 , 289.0036 , 441.97851 , 295.55121 , 434.19246 )
	background.canvas:curve_to ( 327.37942 , 420.45504 , 315.44799 , 427.42513 , 322.54517 , 423.70561 )
	background.canvas:curve_to ( 342.11918 , 411.14089 , 332.19932 , 417.21411 , 338.83221 , 413.02274 )
	background.canvas:curve_to ( 357.22554 , 398.71933 , 345.40614 , 409.25903 , 352.204 , 403.66933 )
	background.canvas:curve_to ( 370.85125 , 380.66331 , 364.83164 , 391.22158 , 367.106 , 388.20773 )
	background.canvas:curve_to ( 375.93685 , 370.16331 , 373.32385 , 375.6825 , 375.61237 , 370.9575 )
	background.canvas:curve_to ( 377.6545 , 370.50501 , 376.42144 , 368.97721 , 376.72819 , 369.03823 )
	background.canvas:curve_to ( 387.46254 , 379.53283 , 378.27473 , 371.48713 , 382.68835 , 375.54965 )
	background.canvas:curve_to ( 398.41891 , 388.74715 , 392.23673 , 383.51601 , 397.16709 , 387.66245 )
	background.canvas:curve_to ( 419.8549 , 401.58829 , 402.05265 , 391.89578 , 419.05639 , 402.0818 )
	background.canvas:curve_to ( 423.11199 , 393.12778 , 420.25431 , 401.34145 , 421.71999 , 397.53422 )
	background.canvas:curve_to ( 408.65854 , 347.71933 , 428.67208 , 375.52698 , 425.77675 , 366.43071 )
	background.canvas:curve_to ( 393.57038 , 320.93901 , 396.37876 , 334.2967 , 391.8278 , 326.21908 )
	background.canvas:curve_to ( 396.9219 , 315.48731 , 394.19218 , 319.05494 , 395.70036 , 316.60167 )
	background.canvas:curve_to ( 414.73457 , 306.21933 , 399.89971 , 312.77075 , 412.49127 , 306.21933 )
	background.canvas:curve_to ( 417.1358 , 305.23078 , 415.71922 , 306.21933 , 416.79978 , 305.77448 )
	background.canvas:curve_to ( 416.19482 , 304.83777 , 417.48614 , 304.66392 , 417.08474 , 304.49628 )
	background.canvas:curve_to ( 414.64288 , 303.79264 , 415.18086 , 305.22687 , 414.64288 , 304.86457 )
	background.canvas:curve_to ( 401.89288 , 293.82144 , 414.64288 , 302.79313 , 409.66036 , 298.89652 )
	background.canvas:curve_to ( 373.47568 , 278.35153 , 387.63259 , 284.5041 , 384.03849 , 282.54753 )
	background.canvas:curve_to ( 276.64288 , 267.18722 , 354.03379 , 270.62839 , 310.5976 , 265.62042 )
	background.canvas:curve_to ( 152.64288 , 254.13085 , 239.49036 , 268.90158 , 202.96165 , 265.05535 )
	background.canvas:curve_to ( 91.678739 , 250.83127 , 105.83814 , 243.96925 , 98.072689 , 243.54896 )
	background.canvas:curve_to ( 84.031589 , 274.10622 , 87.177349 , 255.95807 , 85.801279 , 260.14629 )
	background.canvas:curve_to ( 89.657699 , 359.9045 , 81.169409 , 296.68408 , 83.305219 , 329.25518 )
	background.canvas:curve_to ( 182.64288 , 519.67092 , 106.0255 , 438.87551 , 140.80381 , 498.63134 )
	background.canvas:curve_to ( 206.2757 , 527.66681 , 190.45255 , 523.59816 , 197.0731 , 525.83815 )
	background.canvas:curve_to ( 228.39946 , 527.75204 , 215.34619 , 529.46922 , 216.95549 , 529.47542 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 355.85563 , 482.58503 )
	background.canvas:curve_to ( 388.91204 , 455.94703 , 366.28273 , 476.00269 , 379.52284 , 465.33335 )
	background.canvas:curve_to ( 405.8061 , 431.50918 , 398.90305 , 445.95909 , 399.29908 , 445.38621 )
	background.canvas:curve_to ( 410.8061 , 416.81618 , 411.43257 , 419.51004 , 412.21054 , 417.22389 )
	background.canvas:curve_to ( 376.4873 , 417.16757 , 399.45208 , 413.52004 , 385.82454 , 413.65957 )
	background.canvas:curve_to ( 342.0588 , 438.90255 , 369.16044 , 419.92027 , 357.15602 , 427.49875 )
	background.canvas:curve_to ( 326.66484 , 455.54076 , 326.54306 , 450.62248 , 326.63845 , 450.51938 )
	background.canvas:curve_to ( 345.04792 , 481.38287 , 326.70963 , 464.06311 , 333.85917 , 474.11361 )
	background.canvas:curve_to ( 351.31779 , 485.21933 , 348.29569 , 483.49292 , 351.11713 , 485.21933 )
	background.canvas:curve_to ( 355.85563 , 482.58503 , 351.51845 , 485.21933 , 353.56048 , 484.03389 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 475.6417 , 404.8527 )
	background.canvas:curve_to ( 470.86421 , 383.71933 , 475.63883 , 402.08637 , 472.72217 , 389.18444 )
	background.canvas:curve_to ( 469.69279 , 356.76964 , 467.41283 , 373.5672 , 467.06713 , 365.61419 )
	background.canvas:curve_to ( 472.79983 , 348.62233 , 470.93798 , 352.57519 , 472.33615 , 348.9089 )
	background.canvas:curve_to ( 473.64288 , 344.67937 , 473.26351 , 348.33576 , 473.64288 , 346.56143 )
	background.canvas:curve_to ( 459.29451 , 340.46362 , 473.64288 , 340.32611 , 471.74681 , 339.76902 )
	background.canvas:curve_to ( 469.48165 , 336.12037 , 447.6583 , 341.11269 , 450.23384 , 340.01462 )
	background.canvas:curve_to ( 494.19699 , 340.64841 , 491.66102 , 331.63301 , 495.54566 , 332.3447 )
	background.canvas:curve_to ( 493.42267 , 345.96933 , 493.83334 , 342.88742 , 493.4849 , 345.28183 )
	background.canvas:curve_to ( 492.78165 , 346.69144 , 493.36045 , 346.65683 , 493.07199 , 346.98178 )
	background.canvas:curve_to ( 482.06002 , 364.46879 , 491.87706 , 345.78685 , 483.83765 , 359.11686 )
	background.canvas:curve_to ( 480.9703 , 378.0683 , 480.75531 , 368.39692 , 480.50672 , 371.49929 )
	background.canvas:curve_to ( 479.4753 , 394.93412 , 481.44939 , 384.8571 , 481.14695 , 388.26902 )
	background.canvas:curve_to ( 477.83711 , 403.74689 , 478.32273 , 399.52958 , 477.58554 , 403.49532 )
	background.canvas:curve_to ( 502.89288 , 394.26283 , 478.29654 , 404.20632 , 494.02196 , 398.25396 )
	background.canvas:curve_to ( 507.64288 , 390.67254 , 505.50538 , 393.08743 , 507.64288 , 391.4718 )
	background.canvas:curve_to ( 508.63034 , 389.21933 , 507.64288 , 389.87327 , 508.08723 , 389.21933 )
	background.canvas:curve_to ( 515.71225 , 376.21933 , 510.41773 , 389.21933 , 515.00004 , 380.80776 )
	background.canvas:curve_to ( 514.40688 , 363.71933 , 516.20341 , 373.05503 , 515.81595 , 369.34475 )
	background.canvas:curve_to ( 505.83423 , 346.21933 , 512.77437 , 357.20183 , 511.18575 , 353.95886 )
	background.canvas:curve_to ( 494.36372 , 331.71933 , 502.22139 , 340.99433 , 497.05966 , 334.46933 )
	background.canvas:curve_to ( 484.20622 , 311.90115 , 488.62074 , 325.8612 , 484.23149 , 317.29738 )
	background.canvas:curve_to ( 483.851 , 309.09497 , 484.19638 , 309.80115 , 484.03653 , 308.53837 )
	background.canvas:curve_to ( 482.25079 , 309.62237 , 483.66547 , 309.65157 , 482.94537 , 309.8889 )
	background.canvas:curve_to ( 471.5654 , 311.26939 , 481.55621 , 309.35583 , 476.74779 , 310.09699 )
	background.canvas:curve_to ( 434.64288 , 315.74389 , 463.11634 , 313.1808 , 456.03263 , 314.03925 )
	background.canvas:curve_to ( 416.14288 , 320.77058 , 427.15493 , 316.34063 , 419.03735 , 318.54628 )
	background.canvas:curve_to ( 414.21621 , 327.27686 , 414.59486 , 321.96018 , 414.15945 , 323.43052 )
	background.canvas:curve_to ( 424.22594 , 342.48277 , 414.28863 , 332.18474 , 414.41244 , 332.37283 )
	background.canvas:curve_to ( 438.80901 , 357.82642 , 429.69096 , 348.11288 , 436.25334 , 355.01752 )
	background.canvas:curve_to ( 445.04928 , 363.54504 , 441.36468 , 360.63533 , 444.1728 , 363.2087 )
	background.canvas:curve_to ( 446.64288 , 365.27443 , 445.92576 , 363.88138 , 446.64288 , 364.6596 )
	background.canvas:curve_to ( 453.93957 , 376.07873 , 446.64288 , 365.88926 , 449.92639 , 370.7512 )
	background.canvas:curve_to ( 468.65669 , 401.21933 , 462.67082 , 387.66957 , 467.04544 , 395.14254 )
	background.canvas:curve_to ( 470.85707 , 406.34676 , 469.31294 , 403.69433 , 470.3031 , 406.00167 )
	background.canvas:curve_to ( 475.6417 , 404.8527 , 472.29533 , 407.24272 , 475.6431 , 406.19733 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 579.64288 , 380.77323 )
	background.canvas:line_to ( 579.64288 , 376.32713 )
	background.canvas:line_to ( 574.39288 , 377.99824 )
	background.canvas:curve_to ( 565.32179 , 379.53991 , 571.50538 , 378.91735 , 567.42339 , 379.6111 )
	background.canvas:curve_to ( 561.82736 , 379.73715 , 563.22019 , 379.46873 , 561.6477 , 379.55748 )
	background.canvas:curve_to ( 578.39288 , 385.19376 , 562.41704 , 380.32683 , 577.11288 , 385.16758 )
	background.canvas:curve_to ( 579.64288 , 380.77323 , 579.20928 , 385.21046 , 579.64288 , 383.67708 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 560.74268 , 375.12785 )
	background.canvas:curve_to ( 575.89288 , 368.90861 , 567.56279 , 372.32754 , 574.38038 , 369.52888 )
	background.canvas:curve_to ( 577.11048 , 345.26234 , 579.22582 , 367.54179 , 579.25368 , 367.00069 )
	background.canvas:curve_to ( 570.24445 , 301.12385 , 574.58931 , 319.69018 , 572.88015 , 308.70279 )
	background.canvas:curve_to ( 550.92533 , 285.01126 , 566.30945 , 289.80876 , 560.95283 , 285.34121 )
	background.canvas:curve_to ( 534.64288 , 289.95405 , 545.79822 , 284.84256 , 543.95288 , 285.40274 )
	background.canvas:curve_to ( 505.64288 , 301.7177 , 525.30592 , 294.51854 , 509.74057 , 300.83252 )
	background.canvas:curve_to ( 498.64288 , 304.7536 , 502.91556 , 302.30686 , 498.64288 , 304.15992 )
	background.canvas:curve_to ( 499.89288 , 304.57876 , 498.64288 , 305.07467 , 499.20538 , 304.99599 )
	background.canvas:curve_to ( 498.39288 , 307.45302 , 500.58038 , 304.16153 , 499.90538 , 305.45495 )
	background.canvas:curve_to ( 496.62233 , 319.66529 , 495.50999 , 311.26144 , 494.93501 , 315.2273 )
	background.canvas:curve_to ( 519.49986 , 343.98039 , 497.16103 , 321.08217 , 507.45592 , 332.02397 )
	background.canvas:curve_to ( 544.7704 , 372.91305 , 539.30107 , 363.63771 , 541.72086 , 366.40817 )
	background.canvas:curve_to ( 548.24268 , 380.16305 , 546.62527 , 376.8696 , 548.18779 , 380.1321 )
	background.canvas:curve_to ( 560.74268 , 375.12785 , 548.29756 , 380.194 , 553.92256 , 377.92816 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 613.706 , 347.17253 )
	background.canvas:curve_to ( 642.71614 , 316.02058 , 622.99528 , 340.28611 , 635.82291 , 326.51142 )
	background.canvas:curve_to ( 675.06314 , 245.34606 , 653.74897 , 299.22968 , 665.11417 , 274.39801 )
	background.canvas:curve_to ( 679.64288 , 231.59606 , 677.582 , 237.99076 , 679.64288 , 231.80326 )
	background.canvas:curve_to ( 677.89288 , 231.21933 , 679.64288 , 231.38886 , 678.85538 , 231.21933 )
	background.canvas:curve_to ( 676.06354 , 227.46933 , 676.55143 , 231.21933 , 676.12436 , 230.34387 )
	background.canvas:curve_to ( 674.70936 , 194.71933 , 676.0199 , 225.40683 , 675.41052 , 210.66933 )
	background.canvas:curve_to ( 674.00743 , 160.12184 , 674.0082 , 178.76933 , 673.69233 , 163.20046 )
	background.canvas:line_to ( 674.58033 , 154.52435 )
	background.canvas:line_to ( 660.36161 , 153.84731 )
	background.canvas:curve_to ( 609.65926 , 148.77523 , 645.3873 , 153.13428 , 625.52441 , 151.14727 )
	background.canvas:curve_to ( 598.65819 , 151.99785 , 599.48331 , 147.2538 , 598.68851 , 147.48663 )
	background.canvas:curve_to ( 595.75882 , 159.99785 , 598.64977 , 153.25103 , 597.34505 , 156.85103 )
	background.canvas:curve_to ( 588.14109 , 177.21933 , 594.17258 , 163.14466 , 590.74461 , 170.89433 )
	background.canvas:curve_to ( 556.3154 , 234.65984 , 579.25456 , 198.80831 , 570.49547 , 214.61714 )
	background.canvas:curve_to ( 526.6841 , 269.64996 , 544.78021 , 250.96418 , 534.28871 , 263.35306 )
	background.canvas:curve_to ( 515.9179 , 281.82768 , 519.70089 , 275.43232 , 514.9248 , 280.83458 )
	background.canvas:curve_to ( 531.77699 , 275.69701 , 516.18916 , 282.09894 , 523.32575 , 279.34014 )
	background.canvas:curve_to ( 550.14288 , 268.75392 , 540.22823 , 272.05388 , 548.49288 , 268.92949 )
	background.canvas:curve_to ( 556.93281 , 267.70823 , 551.79288 , 268.57834 , 554.84835 , 268.10779 )
	background.canvas:curve_to ( 572.90545 , 272.69342 , 562.16284 , 266.70572 , 568.54322 , 268.69709 )
	background.canvas:curve_to ( 576.91174 , 275.61714 , 574.89462 , 274.51575 , 576.69746 , 275.83142 )
	background.canvas:curve_to ( 589.53016 , 302.21933 , 577.39896 , 275.12992 , 585.4943 , 292.19655 )
	background.canvas:curve_to ( 604.6013 , 347.96933 , 595.84718 , 317.90722 , 600.03316 , 330.61421 )
	background.canvas:curve_to ( 606.30911 , 352.21933 , 605.21657 , 350.30683 , 605.98508 , 352.21933 )
	background.canvas:curve_to ( 613.706 , 347.17253 , 606.63314 , 352.21933 , 609.96174 , 349.94827 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 59.098059 , 333.46933 )
	background.canvas:curve_to ( 52.642879 , 272.33501 , 57.763259 , 326.05099 , 52.642879 , 277.55802 )
	background.canvas:curve_to ( 68.029179 , 229.73826 , 52.642879 , 252.55491 , 58.167469 , 237.26015 )
	background.canvas:curve_to ( 95.375399 , 220.75107 , 73.731959 , 225.38853 , 85.501019 , 221.52069 )
	background.canvas:curve_to ( 122.64288 , 225.06297 , 103.79485 , 220.09484 , 104.87724 , 220.266 )
	background.canvas:curve_to ( 222.36649 , 248.83712 , 169.53978 , 237.72577 , 199.45866 , 244.85844 )
	background.canvas:curve_to ( 297.78589 , 253.16063 , 237.3707 , 251.44308 , 264.86038 , 253.01896 )
	background.canvas:curve_to ( 313.38632 , 240.55065 , 313.75243 , 253.22933 , 312.61424 , 254.14933 )
	background.canvas:curve_to ( 305.3482 , 202.71933 , 314.01318 , 229.50993 , 311.61905 , 218.242 )
	background.canvas:curve_to ( 244.89288 , 122.08621 , 295.07765 , 177.2959 , 271.82006 , 146.27577 )
	background.canvas:curve_to ( 233.64288 , 110.66853 , 238.70538 , 116.52778 , 233.64288 , 111.38982 )
	background.canvas:curve_to ( 212.00883 , 95.388876 , 233.64288 , 109.01438 , 220.11919 , 99.462896 )
	background.canvas:curve_to ( 185.20454 , 88.243776 , 204.3471 , 91.540206 , 191.86019 , 88.211626 )
	background.canvas:curve_to ( 134.11762 , 116.48525 , 168.76735 , 88.323156 , 152.91135 , 97.088546 )
	background.canvas:curve_to ( 53.357529 , 219.21933 , 103.31297 , 148.27821 , 86.370189 , 169.83094 )
	background.canvas:curve_to ( 35.66664 , 245.21933 , 43.982797 , 233.24433 , 36.0219 , 244.94433 )
	background.canvas:curve_to ( 23.39325 , 266.71933 , 34.460447 , 246.15302 , 27.878247 , 257.68344 )
	background.canvas:curve_to ( 23.42584 , 318.00793 , 10.94716 , 291.79438 , 10.956099 , 305.86202 )
	background.canvas:curve_to ( 49.131899 , 332.93076 , 28.879939 , 323.32039 , 37.184352 , 328.14125 )
	background.canvas:curve_to ( 59.098059 , 333.46933 , 59.101329 , 336.92728 , 59.726339 , 336.96106 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 491.54669 , 291.26234 )
	background.canvas:curve_to ( 499.81804 , 288.02948 , 495.61878 , 290.20485 , 499.34089 , 288.75007 )
	background.canvas:curve_to ( 508.27429 , 272.21933 , 500.29519 , 287.3089 , 504.10051 , 280.19433 )
	background.canvas:curve_to ( 520.43703 , 249.71933 , 512.44807 , 264.24433 , 517.92131 , 254.11933 )
	background.canvas:curve_to ( 567.31552 , 158.79987 , 542.08243 , 211.86155 , 556.81927 , 183.27988 )
	background.canvas:curve_to ( 572.45409 , 143.10265 , 572.10352 , 147.633 , 573.39599 , 143.68478 )
	background.canvas:curve_to ( 570.43459 , 143.52212 , 571.75124 , 142.66827 , 570.85966 , 142.85345 )
	background.canvas:curve_to ( 569.65819 , 143.59929 , 569.91717 , 144.33603 , 569.6686 , 144.36074 )
	background.canvas:curve_to ( 564.89288 , 141.20277 , 569.64977 , 142.98327 , 567.50538 , 141.90483 )
	background.canvas:curve_to ( 552.68355 , 137.54614 , 562.28038 , 140.5007 , 556.78618 , 138.85522 )
	background.canvas:curve_to ( 543.99816 , 135.63649 , 548.58093 , 136.23707 , 544.6725 , 135.37772 )
	background.canvas:curve_to ( 542.45749 , 135.19994 , 543.32383 , 135.89526 , 542.63052 , 135.69881 )
	background.canvas:curve_to ( 538.64288 , 133.8311 , 542.28445 , 134.70107 , 540.56788 , 134.08509 )
	background.canvas:curve_to ( 515.14288 , 128.20606 , 536.71788 , 133.57711 , 526.14288 , 131.04584 )
	background.canvas:curve_to ( 459.84372 , 134.59959 , 478.76713 , 118.81522 , 467.48222 , 120.11995 )
	background.canvas:line_to ( 457.14288 , 139.71933 )
	background.canvas:line_to ( 457.33643 , 167.64529 )
	background.canvas:curve_to ( 467.53307 , 259.46051 , 457.66403 , 214.91124 , 460.20206 , 237.76487 )
	background.canvas:curve_to ( 483.04929 , 293.20219 , 472.07044 , 272.88853 , 481.42345 , 293.22767 )
	background.canvas:curve_to ( 491.54669 , 291.26234 , 483.65077 , 293.19277 , 487.47459 , 292.31984 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 424.06882 , 268.48784 )
	background.canvas:curve_to ( 424.67741 , 266.74067 , 424.02809 , 267.29485 , 424.30195 , 266.50863 )
	background.canvas:curve_to ( 428.16873 , 232.21933 , 425.3845 , 267.17768 , 425.62186 , 264.83076 )
	background.canvas:curve_to ( 436.17481 , 163.71933 , 430.83083 , 198.13261 , 432.93448 , 180.13375 )
	background.canvas:curve_to ( 440.25347 , 139.46933 , 437.4777 , 157.11933 , 439.3131 , 146.20683 )
	background.canvas:curve_to ( 442.80306 , 127.21933 , 441.19384 , 132.73183 , 442.34115 , 127.21933 )
	background.canvas:curve_to ( 443.64288 , 125.69699 , 443.26496 , 127.21933 , 443.64288 , 126.53428 )
	background.canvas:curve_to ( 458.12591 , 112.15307 , 443.64288 , 122.9048 , 451.82101 , 115.25696 )
	background.canvas:curve_to ( 504.38105 , 113.64178 , 468.90605 , 106.84602 , 474.56002 , 107.02799 )
	background.canvas:curve_to ( 574.14701 , 126.74719 , 529.5931 , 119.23337 , 562.80819 , 125.47277 )
	background.canvas:line_to ( 580.15114 , 127.42203 )
	background.canvas:line_to ( 583.36598 , 117.57068 )
	background.canvas:curve_to ( 588.51391 , 99.719326 , 585.13415 , 112.15244 , 587.45071 , 104.11933 )
	background.canvas:curve_to ( 593.13383 , 81.719326 , 589.5771 , 95.319326 , 591.65606 , 87.219326 )
	background.canvas:curve_to ( 595.2367 , 60.632666 , 595.55041 , 72.725206 , 595.76193 , 70.604136 )
	background.canvas:curve_to ( 590.75128 , 40.839616 , 594.62924 , 49.100176 , 593.47993 , 44.028546 )
	background.canvas:curve_to ( 552.14288 , 28.294406 , 585.41674 , 34.605226 , 571.33166 , 30.028486 )
	background.canvas:curve_to ( 401.85865 , 28.135466 , 533.9488 , 26.650216 , 410.43309 , 26.519586 )
	background.canvas:curve_to ( 371.80704 , 54.219326 , 386.16928 , 31.092176 , 376.46589 , 39.514416 )
	background.canvas:curve_to ( 366.61709 , 133.71933 , 367.85762 , 66.685026 , 364.89177 , 112.11605 )
	background.canvas:curve_to ( 383.86036 , 201.21933 , 368.07274 , 151.94602 , 374.33886 , 176.47516 )
	background.canvas:curve_to ( 409.01465 , 253.21076 , 389.16228 , 214.99778 , 406.10232 , 250.01117 )
	background.canvas:curve_to ( 416.07467 , 263.52258 , 410.2705 , 254.59047 , 413.4475 , 259.23079 )
	background.canvas:curve_to ( 422.49711 , 270.99137 , 419.38013 , 268.92244 , 421.35824 , 271.22282 )
	background.canvas:curve_to ( 424.06882 , 268.48784 , 423.44757 , 270.79822 , 424.11159 , 269.74052 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 711.95671 , 221.35088 )
	background.canvas:curve_to ( 727.5601 , 200.74063 , 715.46582 , 219.03718 , 721.40167 , 211.19662 )
	background.canvas:curve_to ( 751.77132 , 154.71631 , 736.049 , 186.32788 , 750.7693 , 158.34533 )
	background.canvas:curve_to ( 753.60369 , 151.69511 , 752.31016 , 152.76481 , 753.13473 , 151.40527 )
	background.canvas:curve_to ( 753.96287 , 149.97071 , 754.07266 , 151.98495 , 754.23429 , 151.20897 )
	background.canvas:curve_to ( 754.3519 , 148.94789 , 753.64133 , 148.50377 , 753.77688 , 148.14739 )
	background.canvas:curve_to ( 755.17634 , 144.63148 , 754.90135 , 149.71279 , 755.21249 , 148.08381 )
	background.canvas:curve_to ( 752.63058 , 137.16337 , 755.12725 , 139.94368 , 754.73372 , 138.78924 )
	background.canvas:curve_to ( 724.91579 , 126.13028 , 749.76336 , 134.94683 , 739.57413 , 130.89056 )
	background.canvas:curve_to ( 715.91579 , 121.94868 , 718.26037 , 123.96894 , 715.11724 , 122.50858 )
	background.canvas:curve_to ( 714.93704 , 121.7072 , 716.67505 , 121.41633 , 716.3019 , 121.32427 )
	background.canvas:curve_to ( 708.89753 , 121.17748 , 713.72383 , 122.04758 , 711.00605 , 121.80921 )
	background.canvas:curve_to ( 694.25935 , 126.22269 , 702.93322 , 119.39053 , 697.55366 , 121.24465 )
	background.canvas:curve_to ( 693.50369 , 130.21933 , 691.84268 , 129.87453 , 691.77749 , 130.21933 )
	background.canvas:curve_to ( 701.22084 , 128.34758 , 696.66857 , 130.21933 , 701.63461 , 129.01484 )
	background.canvas:curve_to ( 721.12919 , 130.30009 , 700.30141 , 126.86489 , 716.08517 , 128.41288 )
	background.canvas:curve_to ( 730.64288 , 146.11891 , 728.55089 , 133.0769 , 730.64288 , 136.55535 )
	background.canvas:curve_to ( 716.94272 , 186.21933 , 730.64288 , 155.36395 , 728.82603 , 160.68188 )
	background.canvas:curve_to ( 700.64288 , 222.63133 , 706.39115 , 208.89484 , 700.64288 , 221.73584 )
	background.canvas:curve_to ( 711.95671 , 221.35088 , 700.64288 , 224.04563 , 709.3672 , 223.05825 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 691.10826 , 196.21933 )
	background.canvas:curve_to ( 697.69392 , 161.40887 , 698.18022 , 173.29011 , 699.29975 , 167.37248 )
	background.canvas:curve_to ( 689.21269 , 153.21933 , 696.4948 , 156.95567 , 692.62538 , 153.21933 )
	background.canvas:curve_to ( 683.2655 , 178.06661 , 687.15829 , 153.21933 , 686.86629 , 154.43928 )
	background.canvas:curve_to ( 680.19969 , 211.31661 , 680.06003 , 199.09995 , 679.58944 , 204.20366 )
	background.canvas:curve_to ( 683.95723 , 218.92854 , 680.93399 , 219.87553 , 682.4504 , 222.94743 )
	background.canvas:curve_to ( 691.10826 , 196.21933 , 684.4128 , 217.71347 , 687.63076 , 207.49433 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 313.2907 , 684.98015 )
	background.canvas:curve_to ( 311.30877 , 684.21933 , 313.54932 , 684.5617 , 312.65745 , 684.21933 )
	background.canvas:curve_to ( 276.401 , 673.29038 , 308.01956 , 684.21933 , 286.04023 , 677.33803 )
	background.canvas:curve_to ( 256.59309 , 657.12173 , 267.68546 , 669.6306 , 259.61303 , 663.0413 )
	background.canvas:curve_to ( 281.47362 , 588.21933 , 250.34944 , 644.88316 , 259.07467 , 620.72011 )
	background.canvas:curve_to ( 323.10304 , 546.21933 , 303.56174 , 556.16956 , 313.42418 , 546.21933 )
	background.canvas:curve_to ( 322.94671 , 549.73685 , 327.68839 , 546.21933 , 327.61882 , 547.78472 )
	background.canvas:curve_to ( 310.20761 , 560.05024 , 317.71473 , 551.92291 , 312.95008 , 555.7803 )
	background.canvas:curve_to ( 271.989 , 624.21933 , 292.82268 , 587.11804 , 273.84631 , 618.97938 )
	background.canvas:curve_to ( 297.63923 , 664.43285 , 265.52724 , 642.44962 , 271.29077 , 651.48547 )
	background.canvas:line_to ( 310.13558 , 670.57343 )
	background.canvas:line_to ( 320.69946 , 670.6296 )
	background.canvas:curve_to ( 334.38347 , 668.20255 , 330.48803 , 670.68164 , 331.49235 , 670.50351 )
	background.canvas:curve_to ( 344.51974 , 650.71933 , 337.8989 , 665.40471 , 342.92542 , 656.73489 )
	background.canvas:curve_to ( 346.55384 , 637.21933 , 345.10281 , 648.51933 , 346.01816 , 642.44433 )
	background.canvas:curve_to ( 351.08535 , 603.75416 , 347.08953 , 631.99433 , 349.12871 , 616.935 )
	background.canvas:curve_to ( 354.67329 , 578.25416 , 353.04199 , 590.57331 , 354.65656 , 579.09831 )
	background.canvas:curve_to ( 355.54323 , 578.21933 , 354.70009 , 576.90163 , 354.80341 , 576.89749 )
	background.canvas:curve_to ( 359.68908 , 616.18862 , 357.06601 , 580.94011 , 358.64656 , 595.41542 )
	background.canvas:curve_to ( 362.11075 , 650.58516 , 360.25408 , 627.44672 , 361.34383 , 642.92517 )
	background.canvas:curve_to ( 361.58247 , 669.61587 , 363.43351 , 663.79689 , 363.40637 , 664.77461 )
	background.canvas:curve_to ( 348.71688 , 683.60103 , 359.19918 , 675.94193 , 354.69401 , 680.83915 )
	background.canvas:curve_to ( 328.48168 , 685.72777 , 344.68204 , 685.46543 , 342.29681 , 685.71612 )
	background.canvas:curve_to ( 313.2907 , 684.98015 , 319.86802 , 685.73503 , 313.03208 , 685.39861 )
	background.canvas:close_path ( )
	background.canvas:move_to ( 42.154158 , 204.84245 )
	background.canvas:curve_to ( 44.293069 , 202.21933 , 43.099463 , 203.39974 , 44.061973 , 202.21933 )
	background.canvas:curve_to ( 41.533771 , 206.78676 , 45.016448 , 202.21933 , 42.688166 , 206.0733 )
	background.canvas:curve_to ( 42.154158 , 204.84245 , 40.929679 , 207.16011 , 41.208853 , 206.28517 )
	background.canvas:close_path ( )

	background.canvas:set_fill_style ( WHITE, 0.5 )
	background.canvas:fill ( )
	background.color = RED

	background.scaley = -1.1 / camera_scaler
	background.scalex = 1.1 / camera_scaler
	background.depth = -3000 + 1
	display:add_child ( background )


	creditor = Sprite ( 0, 100 )
	creditor.canvas:set_font ( silkscreen14, WHITE )
	creditor.depth = -3000 - 1
	creditor.alpha = 0
	display:add_child ( creditor )

end

function ExitMenu ( )


	display:remove_child ( title )
	title = nil
	display:remove_child ( background )
	background = nil
	display:add_child ( creditor )
	creditor = nil

	display:remove_child ( level_curtain2 )
	level_curtain2 = nil

	HideLevelselectMenu ( )
	HideOptionsMenu ( )
	HideMenuItems ( )

	if music ~= nil and music_volume > 0 then
		music:stop ( )
		music:unload ( )
	end
end




function UpdateMenu ( ms )

	credits_time = credits_time + ms
	if credits_time < 6500 then
		return
	end
	credits_time = 0

	local c = Color ( math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) )
	local effect = Modulate:Create ( background, c )
	effects:AddEffect ( effect, 6000, 0 )



	credits_current = credits_current + 1

	if credits_current > #credits then
		if visitus == nil and #levelselect_gui > 0 then
			local w = silkscreen14:get_width ( text.visitus )
			visitus = CreateButton ( -163, 100, -5000, silkscreen14, text.visitus, WHITE, RED )
			visitus.sprite.alpha = 0
			local effect = Fade:Create ( visitus.sprite, 1 )
			effects:AddEffect ( effect, 1000, 0 )
			visitus.OnLeftButtonPress = function ( button, x, y )
				open_url ( "http://www.2dengine.com/chains/" )
			end
		end
		return
	end

	creditor.canvas:clear ( )
	creditor.canvas:move_to ( -163, 0 )
	creditor.canvas:write ( credits[credits_current] )

	local effect = Fade:Create ( creditor, 1 )
	effects:AddEffect ( effect, 1000, 0 )
	local effect = Fade:Create ( creditor, 0 )
	effects:AddEffect ( effect, 2000, 3500 )
end







