surface.CreateFont( "ChatFont", 13, 800, true, false, "AccountMenu" );

if( AccountMenu ) then

	if( AccountMenu.TitleBar ) then

		AccountMenu.TitleBar:Remove();
		AccountMenu.TitleBar = nil;
		
	end
		
	AccountMenu:Remove();
	AccountMenu = nil;

end

function CreateAccountMenu()
	
	AccountMenu = CreateBPanel( nil, ScrW() / 2 - 175, math.Clamp( ScrH() / 2 - 210, ScrH() * .1 + 70, 9999 ), 307, 93 );
	AccountMenu:CanDrag( false )
	AccountMenu:CanSeeTitle( false )
	AccountMenu:SetBodyColor( Color( 30, 30, 30, 0 ) )
	AccountMenu:SetOutline( false, 0 )

	AccountMenu:AddButton( "Create Account", 10, 15, function() UserNamePanel() end )
	AccountMenu:AddButton( "Disonnect", 120, 15, function() RunConsoleCommand( "disconnect" ) end )
	
	gui.EnableScreenClicker( true )
	
	print( LocalPlayer():Nick() .. ": Account menu prompted." )

end
usermessage.Hook( "ACM", CreateAccountMenu );

function UserNamePanel()

	if( AccountMenu ) then	
		AccountMenu:Remove()
	end

	NamePanel = CreateBPanel( "Enter Name", ( ScrW() * .5 ) - 100, ( ScrH() * .5 ) - 25, 200, 50 )
	NamePanel:CanClose( true )
	NamePanel:CanDrag( false )
	NamePanel:SetBodyColor( Color( 40, 40, 40, 220 ) )
	
	NamePanel:AddLabel( "Username:", "NewChatFont", 13, 8, Color( 255, 255, 255, 255 ) )
	
	local x, y = NamePanel:GetPos();
	
	NamePanel.Entry = vgui.Create( "DTextEntry", NamePanel )
	NamePanel.Entry:SetPos( x + 80, y + 8 )
	NamePanel.Entry:SetSize( 100, 15 )
	NamePanel.Entry:MakePopup()
	
	ApplyMaxCharacters( NamePanel.Entry, 20 )
	
	NamePanel.Register = NamePanel:AddButton( "Register", 60, 25 )
	
	NamePanel.Register.Action = function()
	
		if( string.len( NamePanel.Entry:GetValue() ) < 5 or
			string.len( NamePanel.Entry:GetValue() ) > 25 ) then
		
			CreateOkPanel( "Invalid name.", "Your Username needs to be between 5 and 25 characters." )
			return
		
		end
		
		RunConsoleCommand( "eng_accountcreation", NamePanel.Entry:GetValue() )
		
		ReadMe()
		

	end
	
	gui.EnableScreenClicker( true )

end	

function ReadMe()

	if( NamePanel ) then
		NamePanel:Remove()
	end	
	
	timer.Simple( .2, function() gui.EnableScreenClicker( true ) end )

	ReadPanel = CreateBPanel( nil, ScrW() / 2 - 175, math.Clamp( ScrH() / 2 - 210, ScrH() * .1 + 70, 9999 ), 365, 300 )
	ReadPanel:CanClose( false )
	ReadPanel:CanDrag( false )
	ReadPanel:CanSeeTitle( false )
	ReadPanel:SetBodyColor( Color( 40, 40, 40, 220 ) )
	
	ReadPanel:AddLabel( "Hi " .. LocalPlayer():Nick() .. ",\n\nIt looks like your new to our servers, please read below\nbefore creating a character.\n\nPeople on this server take roleplay seriously, seriously. If\nyou do not enjoy roleplaying seriously, this is not the place\nfor you. We have other servers that may suit you better.\n\n", "AccountMenu", 5, 10, Color( 255, 255, 255, 255 ) )

	ReadPanel.Continue = ReadPanel:AddButton( "Continue", 100, 267);
	
	ReadPanel.Continue.Action = function()
	
		ReadPanel:Remove()
	
		RunConsoleCommand( "eng_charmenu" );
	
	end
	
end	