using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Accounting;
using Server.Multis;
using Server.Mobiles;
using Server.Regions;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
using Server.Misc;
using Server.Items;
using System.Globalization;

namespace Server.Engines.Help
{
	public class HelpGump : Gump
	{
		public static void Initialize()
		{
			EventSink.HelpRequest += new HelpRequestEventHandler( EventSink_HelpRequest );
		}

		private static void EventSink_HelpRequest( HelpRequestEventArgs e )
		{
			foreach ( Gump g in e.Mobile.NetState.Gumps )
			{
				if ( g is HelpGump )
					return;
			}

			e.Mobile.SendGump( new HelpGump( e.Mobile, 1 ) );
		}

		public static bool CheckCombat( Mobile m )
		{
			for ( int i = 0; i < m.Aggressed.Count; ++i )
			{
				AggressorInfo info = m.Aggressed[i];

				if ( DateTime.Now - info.LastCombatTime < TimeSpan.FromSeconds( 30.0 ) )
					return true;
			}

			return false;
		}

		public HelpGump( Mobile from, int page ) : base( 25, 50 )
		{
            this.Closable=true;
			this.Disposable=true;
			this.Dragable=true;
			this.Resizable=false;




			AddPage(0);
			AddImage(0, 0, 2520);
			AddImage(38, 0, 2521);
			AddImage(208, 0, 2522);
			AddImage(0, 38, 2523);
			AddImage(0, 150, 2523);
			AddImage(0, 262, 2523);
			AddImage(0, 374, 2523);
			AddImage(0, 486, 2523);
			AddImage(209, 38, 2525);
			AddImage(209, 150, 2525);
			AddImage(209, 262, 2525);
			AddImage(209, 374, 2525);
			AddImage(209, 486, 2525);
			AddImage(0, 598, 2526);
			AddImage(38, 598, 2527);
			AddImage(208, 598, 2528);
			AddImage(37, 37, 2524);
			AddImage(36, 146, 2524);
			AddImage(36, 255, 2524);
			AddImage(37, 362, 2524);
			AddImage(35, 472, 2524);
			AddImage(36, 486, 2524);
			AddImage(40, 38, 2524);
			AddImage(41, 147, 2524);
			AddImage(41, 252, 2524);
			AddImage(39, 349, 2524);
			AddImage(39, 439, 2524);
			AddImage(39, 488, 2524);
			AddImage(246, 32, 2520);
			AddImage(284, 32, 2521);
			AddImage(1127, 32, 2522);
			AddImage(246, 70, 2523);
			AddImage(246, 182, 2523);
			AddImage(246, 294, 2523);
			AddImage(246, 406, 2523);
			AddImage(246, 518, 2523);
			AddImage(1128, 70, 2525);
			AddImage(1128, 182, 2525);
			AddImage(1128, 294, 2525);
			AddImage(1128, 406, 2525);
			AddImage(1128, 518, 2525);
			AddImage(246, 630, 2526);
			AddImage(284, 630, 2527);
			AddImage(1127, 630, 2528);
			AddImage(283, 69, 2524);
			AddImage(282, 178, 2524);
			AddImage(282, 287, 2524);
			AddImage(283, 394, 2524);
			AddImage(281, 504, 2524);
			AddImage(282, 518, 2524);
			AddImage(286, 70, 2524);
			AddImage(287, 179, 2524);
			AddImage(287, 284, 2524);
			AddImage(285, 381, 2524);
			AddImage(285, 471, 2524);
			AddImage(285, 520, 2524);
			AddImage(454, 32, 2534);
			AddImage(454, 630, 2535);
			AddImage(453, 69, 2524);
			AddImage(452, 178, 2524);
			AddImage(452, 287, 2524);
			AddImage(453, 394, 2524);
			AddImage(451, 504, 2524);
			AddImage(452, 518, 2524);
			AddImage(456, 70, 2524);
			AddImage(457, 179, 2524);
			AddImage(457, 284, 2524);
			AddImage(455, 381, 2524);
			AddImage(455, 471, 2524);
			AddImage(455, 520, 2524);
			AddImage(624, 32, 2521);
			AddImage(624, 630, 2527);
			AddImage(623, 69, 2524);
			AddImage(622, 178, 2524);
			AddImage(622, 287, 2524);
			AddImage(623, 394, 2524);
			AddImage(621, 504, 2524);
			AddImage(622, 518, 2524);
			AddImage(626, 70, 2524);
			AddImage(627, 179, 2524);
			AddImage(627, 284, 2524);
			AddImage(625, 381, 2524);
			AddImage(625, 471, 2524);
			AddImage(625, 520, 2524);
			AddImage(792, 32, 2534);
			AddImage(792, 630, 2535);
			AddImage(791, 69, 2524);
			AddImage(790, 178, 2524);
			AddImage(790, 287, 2524);
			AddImage(791, 394, 2524);
			AddImage(789, 504, 2524);
			AddImage(790, 518, 2524);
			AddImage(794, 70, 2524);
			AddImage(795, 179, 2524);
			AddImage(795, 284, 2524);
			AddImage(793, 381, 2524);
			AddImage(793, 471, 2524);
			AddImage(793, 520, 2524);
			AddImage(960, 32, 2521);
			AddImage(960, 630, 2527);
			AddImage(959, 69, 2524);
			AddImage(958, 178, 2524);
			AddImage(958, 287, 2524);
			AddImage(959, 394, 2524);
			AddImage(957, 504, 2524);
			AddImage(958, 518, 2524);
			AddImage(962, 70, 2524);
			AddImage(963, 179, 2524);
			AddImage(963, 284, 2524);
			AddImage(961, 381, 2524);
			AddImage(961, 471, 2524);
			AddImage(961, 520, 2524);


			AddHtml( 26, 14, 200, 20, @"<BODY><BASEFONT Color=#2a335d><BIG><CENTER>HELP</CENTER></BIG></BASEFONT></BODY>", (bool)false, (bool)false);


			int v = 35;
			int b = 60;
			int i = 15;
			int s = 0;
			string c = "5c4c32";


			s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
			AddButton(v, i, 2536, 2536, 1, GumpButtonType.Reply, 0);
			AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Basics</BIG></BASEFONT></BODY>", (bool)false, (bool)false);

			s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
			AddButton(v, i, 2536, 2536, 2, GumpButtonType.Reply, 0);
			AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Trades</BIG></BASEFONT></BODY>", (bool)false, (bool)false);

			s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
			AddButton(v, i, 2536, 2536, 3, GumpButtonType.Reply, 0);
			AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Guilds</BIG></BASEFONT></BODY>", (bool)false, (bool)false);

			s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
			AddButton(v, i, 2536, 2536, 4, GumpButtonType.Reply, 0);
			AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Homes</BIG></BASEFONT></BODY>", (bool)false, (bool)false);

			s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
			AddButton(v, i, 2536, 2536, 5, GumpButtonType.Reply, 0);
			AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Ships</BIG></BASEFONT></BODY>", (bool)false, (bool)false);

			s++; i=i+30; if ( page == s ){ c = "2a335d"; } else { c = "5c4c32"; }
			AddButton(v, i, 2536, 2536, 6, GumpButtonType.Reply, 0);
			AddHtml( b, i+2, 156, 20, @"<BODY><BASEFONT Color=#" + c + "><BIG>Skills</BIG></BASEFONT></BODY>", (bool)false, (bool)false);


			AddHtml( 298, 46, 604, 20, @"<BODY><BASEFONT Color=#2a335d><BIG>" + ( HelpText( page, 1 ) ).ToUpper() + "</BIG></BASEFONT></BODY>", (bool)false, (bool)false);


			AddHtml( 284, 79, 844, 547, @"<BODY><BASEFONT Color=#5c4c32><BIG>" + HelpText( page, 3 ) + "</BIG></BASEFONT></BODY>", (bool)false, (bool)(bool.Parse(HelpText( page, 2 ))));
		}

		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;

			if ( info.ButtonID > 0 )
				from.SendGump( new Server.Engines.Help.HelpGump( from, info.ButtonID ) );
		}

		public static string HelpText( int page, int part )
		{
			string val = "";

			if ( page == 1 ){ val = HPBasics.HelpPageBasics( part ); }
			else if ( page == 2 ){ val = HPTrades.HelpPageTrades( part ); }
			else if ( page == 3 ){ val = HPGuilds.HelpPageGuilds( part ); }
			else if ( page == 4 ){ val = HPHomes.HelpPageHomes( part ); }
			else if ( page == 5 ){ val = HPShips.HelpPageShips( part ); }
			else if ( page == 6 ){ val = HPSkills.HelpPageSkills( part ); }



			return val;
		}
	}
}