unit Giko;

interface

uses
	Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
	OleCtrls,	ComCtrls, ExtCtrls, Menus, StdCtrls, MMSystem, DateUtils, Math,
{$IF Defined(DELPRO) }
	SHDocVw,
	MSHTML,
{$ELSE}
	SHDocVw_TLB,
	MSHTML_TLB,
{$IFEND}
	IdHTTP, ActiveX, ActnList, ImgList,
	ToolWin, Buttons, {Clipbrd,} {HTTPApp,} YofUtils, IdComponent,
	ShellAPI,  UrlMon, Tabs, IdGlobal, StrUtils,
	CommCtrl, IniFiles, Dialogs,
	GikoSystem, GikoUtil, Setting, BoardGroup, ThreadControl, ItemDownload,
	Editor, RoundData, RoundName, KeySetting, GikoPanel, Favorite, FavoriteAdd,
	FavoriteArrange, AddressHistory, Preview, HTMLDocumentEvent, Kotehan,
	HintWindow, GikoCoolBar, GikoListView, ToolBarSetting, ToolBarUtil,
	IndividualAbon, Search, ExternalBoardManager, ExternalBoardPlugInMain,
	StdActns, GikoXMLDoc, Variants, ExtActns,IdTCPConnection, IdBaseComponent,
  IdTCPClient;

type
	TGikoTreeType = (gttNone, gtt2ch, gttHistory, gttFavorite);
	TToolBarSettingSenderType = (tssNone, tssMain, tssList, tssBrowser);
	TMinimizeType = (mtNone, mtMinimizing, mtMinimized);

	TBrowserRecord = class;

	TGikoForm = class(TForm)
		StatusBar: TStatusBar;
		MainPanel: TPanel;
		ClientPanel: TPanel;
		TreeSplitter: TSplitter;
		CabinetPanel: TPanel;
		TreeView: TTreeView;
		ThreadMainPanel: TPanel;
		ListSplitter: TSplitter;
		ViewPanel: TPanel;
		ListView: TGikoListView;
		ThreadPanel: TPanel;
		MessagePanel: TPanel;
		MessageBar: TPanel;
		MessageHideButton: TSpeedButton;
		MessageListView: TListView;
		MessageSplitter: TSplitter;
		Panel3: TPanel;
		SpeedButton1: TSpeedButton;
		ToolBar1: TToolBar;
		CabinetSelectToolButton: TToolButton;
		HistoryToolBar: TToolBar;
		ToolButton15: TToolButton;
		ToolButton18: TToolButton;
		ItemIcon16: TImageList;
		ItemIcon32: TImageList;
		HotToobarImageList: TImageList;
		ToobarImageList: TImageList;
		ItemImageList: TImageList;
		ActionList: TActionList;
		LogDeleteAction: TAction;
		KidokuAction: TAction;
		StdToolBarVisibleAction: TAction;
		SearchAction: TAction;
		GikoNaviWebPageAction: TAction;
		AboutAction: TAction;
		ExitAction: TAction;
		MsgBarVisibleAction: TAction;
		StatusBarVisibleAction: TAction;
		LargeIconAction: TAction;
		SmallIconAction: TAction;
		ListIconAction: TAction;
		DetailIconAction: TAction;
		CabinetBBSAction: TAction;
		CabinetHistoryAction: TAction;
		CabinetVisibleAction: TAction;
		MidokuAction: TAction;
		AllSelectAction: TAction;
		UpFolderAction: TAction;
		ListNumberVisibleAction: TAction;
		AllItemAction: TAction;
		LogItemAction: TAction;
		NewItemAction: TAction;
		SelectItemAction: TAction;
		ShowThreadAction: TAction;
		StopAction: TAction;
		MainMenu: TMainMenu;
		FileMenu: TMenuItem;
		DeleteMenu: TMenuItem;
		ExitMenu: TMenuItem;
		KidokuMenu: TMenuItem;
		MidokuMenu: TMenuItem;
		AllSelectMenu: TMenuItem;
		ViewMenu: TMenuItem;
		StdToolBarMenu: TMenuItem;
		CabinetMenu: TMenuItem;
		H1: TMenuItem;
		N4: TMenuItem;
		CabinetVisibleMenu: TMenuItem;
		MessageMenu: TMenuItem;
		StatusBarMenu: TMenuItem;
		MMSep03: TMenuItem;
		LargeIconMenu: TMenuItem;
		SmallIconMenu: TMenuItem;
		ListMenu: TMenuItem;
		DetailMenu: TMenuItem;
		ToolMenu: TMenuItem;
		Find1: TMenuItem;
		RoundMenu: TMenuItem;
		MMSep04: TMenuItem;
		OptionMenu: TMenuItem;
		HelpMenu: TMenuItem;
		G1: TMenuItem;
		N1: TMenuItem;
		AboutMenu: TMenuItem;
		IconStyle: TAction;
		BrowserPopupMenu: TPopupMenu;
		ShowThreadMenu: TMenuItem;
		ShowBoardMenu: TMenuItem;
		ShowBoardAction: TAction;
		ListIconPopupMenu: TPopupMenu;
		LargeIconPMenu: TMenuItem;
		SmallIconPMenu: TMenuItem;
		ListPMenu: TMenuItem;
		DetailPMenu: TMenuItem;
		CabinetCloseAction: TAction;
		ClosePopupMenu: TPopupMenu;
		CloseMenu: TMenuItem;
		OptionAction: TAction;
		U1: TMenuItem;
		N3: TMenuItem;
		B1: TMenuItem;
		S1: TMenuItem;
		N2: TMenuItem;
		A1: TMenuItem;
		L1: TMenuItem;
		N5: TMenuItem;
		S2: TMenuItem;
		RoundAction: TAction;
		ListPopupMenu: TPopupMenu;
		ListRoundPMenu: TMenuItem;
		ListReservPMenu: TMenuItem;
		LPMSep01: TMenuItem;
		ItemRoundPMenu: TMenuItem;
		LPMSep02: TMenuItem;
		KidokuPMenu: TMenuItem;
		MidokuPMenu: TMenuItem;
		AllSelectPMenu: TMenuItem;
		UrlCopyPMenu: TMenuItem;
		LPMSep05: TMenuItem;
		DeletePMenu: TMenuItem;
		LPMSep06: TMenuItem;
		ViewPMenu: TMenuItem;
		LargeIconLPMenu: TMenuItem;
		SmallIconLPMenu: TMenuItem;
		ListLPMenu: TMenuItem;
		DetailLPMenu: TMenuItem;
		T1: TMenuItem;
		B2: TMenuItem;
		N8: TMenuItem;
		URLCopyAction: TAction;
		URLC1: TMenuItem;
		N9: TMenuItem;
		N10: TMenuItem;
		MsgBarCloseAction: TAction;
		ScrollTopAction: TAction;
		ScrollLastAction: TAction;
		ScrollNewAction: TAction;
		ScrollKokoAction: TAction;
		EditorAction: TAction;
		IEAction: TAction;
		ItemReloadAction: TAction;
		BrowserMaxAction: TAction;
		G2: TMenuItem;
		N11: TMenuItem;
		T3: TMenuItem;
		L2: TMenuItem;
		N12: TMenuItem;
		K1: TMenuItem;
		N13: TMenuItem;
		N14: TMenuItem;
		R1: TMenuItem;
		A2: TMenuItem;
		N15: TMenuItem;
		SelectListReloadAction: TAction;
		SelectThreadReloadAction: TAction;
		KokoPopupMenu: TPopupMenu;
		KokomadePMenu: TMenuItem;
		AllPMenu: TMenuItem;
		MenuItem1: TMenuItem;
		MenuItem2: TMenuItem;
		BrowserTabCloseAction: TAction;
		BrowserTabPopupMenu: TPopupMenu;
		Close1: TMenuItem;
		KokomadeAction: TAction;
		ZenbuAction: TAction;
		KokoResAction: TAction;
		SelectItemURLCopyAction: TAction;
		SelectReservAction: TAction;
		NotSelectTabCloseAction: TAction;
		A3: TMenuItem;
		N16: TMenuItem;
		A4: TMenuItem;
		TreePopupMenu: TPopupMenu;
		TreeSelectThreadPupupMenu: TMenuItem;
		TreeSelectBoardPupupMenu: TMenuItem;
		TPMSep01: TMenuItem;
		TreeSelectURLPupupMenu: TMenuItem;
		TreeSelectBoradReload: TAction;
		TreeSelectThreadReload: TAction;
		TreeSelectURLCopy: TAction;
		ListToolBarVisibleAction: TAction;
		BrowserToolBarVisibleAction: TAction;
		T2: TMenuItem;
		L3: TMenuItem;
		B3: TMenuItem;
		BrowserBottomPanel: TGikoPanel;
		CabinetSelectPopupMenu: TPopupMenu;
		H2: TMenuItem;
		ItemReservPMenu: TMenuItem;
		RoundNamePopupMenu: TPopupMenu;
		SelectNewRoundName: TAction;
		SelectDeleteRound: TAction;
		NewBoardAction: TAction;
		N7: TMenuItem;
		B4: TMenuItem;
		LoginAction: TAction;
		L4: TMenuItem;
		KeySettingAction: TAction;
		K2: TMenuItem;
		AllTabCloseAction: TAction;
		A5: TMenuItem;
		A6: TMenuItem;
		C1: TMenuItem;
		V1: TMenuItem;
		N19: TMenuItem;
		D1: TMenuItem;
		D2: TMenuItem;
		MessageImageList: TImageList;
		ProgressBar: TProgressBar;
		ArrangeAction: TAction;
		URL1: TMenuItem;
		NameURLCopyAction: TAction;
		SelectItemNameURLCopyAction: TAction;
		NameUrlCopyPMenu: TMenuItem;
		URLC2: TMenuItem;
		URLN1: TMenuItem;
		N21: TMenuItem;
		URLC3: TMenuItem;
		URLN2: TMenuItem;
		N23: TMenuItem;
		ListCoolBar: TGikoCoolBar;
		ListToolBar: TToolBar;
		ViewNoButton: TToolButton;
		IconToolButton: TToolButton;
		UpFolderButton: TToolButton;
		Sepa01ToolButton: TToolButton;
		AllItemToolButton: TToolButton;
		LogItemToolButton: TToolButton;
		NewItemToolButton: TToolButton;
		ListDownloadToolButton: TToolButton;
		ListThreadDownloadToolButton: TToolButton;
		ToolButton2: TToolButton;
		ToolButton1: TToolButton;
		BrowserCoolBar: TGikoCoolBar;
		BrowserToolBar: TToolBar;
		BrowserSizeButton: TToolButton;
		ToolButton3: TToolButton;
		TopButton: TToolButton;
		LastBotton: TToolButton;
		NewButton: TToolButton;
		KokoButton: TToolButton;
		ToolButton9: TToolButton;
		EditorButton: TToolButton;
		ToolButton11: TToolButton;
		IEButton: TToolButton;
		ToolButton5: TToolButton;
		ItemReloadButton: TToolButton;
		ListNameToolBar: TToolBar;
		ListNameLabel: TLabel;
		FolderImage: TImage;
		BrowserNameToolBar: TToolBar;
		ItemBoardImage: TImage;
		BrowserBoardNameLabel: TLabel;
		ItemImage: TImage;
		BrowserNameLabel: TLabel;
		ActiveLogDeleteAction: TAction;
		D3: TMenuItem;
		N25: TMenuItem;
		N26: TMenuItem;
		ListNameBarVisibleAction: TAction;
		D4: TMenuItem;
		BrowserNameBarVisibleAction: TAction;
		S3: TMenuItem;
		R2: TMenuItem;
		TreeSelectNameURLCopy: TAction;
		TreeSelectNameURLPupupMenu: TMenuItem;
		N27: TMenuItem;
		H3: TMenuItem;
		PaneInitAction: TAction;
		I1: TMenuItem;
		BrowserTabToolBar: TToolBar;
		BrowserTab: TTabControl;
		ToolButton7: TToolButton;
		BrowserMinAction: TAction;
		About1: TMenuItem;
		N28: TMenuItem;
		SelectTextClearAction: TAction;
		MailTextClearAction: TAction;
		NameTextClearAction: TAction;
		S4: TMenuItem;
		N29: TMenuItem;
		N30: TMenuItem;
		LeftmostTabSelectAction: TAction;
		LeftTabSelectAction: TAction;
		RightTabSelectAction: TAction;
		RightmostTabSelectAction: TAction;
		N31: TMenuItem;
		L5: TMenuItem;
		L6: TMenuItem;
		A7: TMenuItem;
		R3: TMenuItem;
		FavoriteMenu: TMenuItem;
		FavoriteAddAction: TAction;
		N32: TMenuItem;
		BoardFavoriteAddMenu: TMenuItem;
		BoardFavoriteAddAction: TAction;
		ThreadFavoriteAddAction: TAction;
		ThreadFavoriteAddMenu: TMenuItem;
		TreeSelectFavoriteAddAction: TAction;
		N33: TMenuItem;
		TreeSelectFavoriteAddPupupMenu: TMenuItem;
		FavoriteArrangeAction: TAction;
		FavoriteTreeView: TTreeView;
		StateIconImageList: TImageList;
		TopPanel: TPanel;
		TopRightPanel: TPanel;
		AnimePanel: TPanel;
		Animate: TAnimate;
		TopCoolPanel: TPanel;
		MainCoolBar: TGikoCoolBar;
		MenuToolBar: TToolBar;
		StdToolBar: TToolBar;
		RoundToolButton: TToolButton;
		ToolButton6: TToolButton;
		ToolButton4: TToolButton;
		ToolButton13: TToolButton;
		AbortToolButton: TToolButton;
		LoginToolButton: TToolButton;
		AddressToolBar: TToolBar;
		AddressComboBox: TComboBox;
		MoveToToolButton: TToolButton;
		MoveToAction: TAction;
		AddressImageList: TImageList;
		AddressBarVisibleAction: TAction;
		AddressToolBarMenu: TMenuItem;
		T4: TMenuItem;
		BrowserTabVisibleAction: TAction;
		Show1: TMenuItem;
		N34: TMenuItem;
		BrowserTabTopAction: TAction;
		BrowserTabBottomAction: TAction;
		T5: TMenuItem;
		B5: TMenuItem;
		N35: TMenuItem;
		BrowserTabTabStyleAction: TAction;
		BrowserTabButtonStyleAction: TAction;
		BrowserTabFlatStyleAction: TAction;
		A8: TMenuItem;
		U2: TMenuItem;
		F1: TMenuItem;
		PreviewTimer: TTimer;
		MonazillaWebPageAction: TAction;
		MonazillaWebPageAction1: TMenuItem;
		GikoHelpAction: TAction;
		N36: TMenuItem;
		H4: TMenuItem;
		KotehanAction: TAction;
		K3: TMenuItem;
		LinkBarVisibleAction: TAction;
		L7: TMenuItem;
		N37: TMenuItem;
		A9: TMenuItem;
		ChevronPopupMenu: TPopupMenu;
		BBS2chWebPageAction: TAction;
		N2N1: TMenuItem;
		N38: TMenuItem;
		GikoFolderOpenAction: TAction;
		F2: TMenuItem;
		LinkToolBar: TToolBar;
		a10: TMenuItem;
		ToolButton8: TToolButton;
		ToolButton10: TToolButton;
		ThreadEditorAction: TAction;
		N39: TMenuItem;
		T6: TMenuItem;
		N40: TMenuItem;
		LinkBarPopupMenu: TPopupMenu;
		ToolBarSettingAction: TAction;
		T7: TMenuItem;
		ToolButton12: TToolButton;
		ToolButton14: TToolButton;
		ThreadPopupMenu: TPopupMenu;
		MenuItem4: TMenuItem;
		MenuItem5: TMenuItem;
		MenuItem6: TMenuItem;
		T8: TMenuItem;
		NameCopyAction: TAction;
		BoardIEAction: TAction;
		URLN3: TMenuItem;
		SelectItemNameCopyAction: TAction;
		SelectItemNameCopyAction1: TMenuItem;
		B6: TMenuItem;
		T9: TMenuItem;
		C2: TMenuItem;
		SelectComboBox: TComboBox;
		MainCoolBarPopupMenu: TPopupMenu;
		StdToolBarVisiblePMenu: TMenuItem;
		AddressToolBarVisiblePMenu: TMenuItem;
		LinkToolBarVisiblePMenu: TMenuItem;
		NG1: TMenuItem;
		NG2: TMenuItem;
		N43: TMenuItem;
		N44: TMenuItem;
		L9: TMenuItem;
		I3: TMenuItem;
		N45: TMenuItem;
		B9: TMenuItem;
		R5: TMenuItem;
		T12: TMenuItem;
		Show3: TMenuItem;
		N46: TMenuItem;
		T13: TMenuItem;
		B10: TMenuItem;
		N47: TMenuItem;
		A12: TMenuItem;
		U4: TMenuItem;
		F4: TMenuItem;
		N48: TMenuItem;
		T14: TMenuItem;
		SelectItemToolButton: TToolButton;
		SelectResToolButton: TToolButton;
		SelectResAction: TAction;
		ToolButton16: TToolButton;
		AllResAction: TAction;
		AllResToolButton: TToolButton;
		N50: TMenuItem;
		A11: TMenuItem;
		S5: TMenuItem;
		Reload: TMenuItem;
		GoBack: TMenuItem;
		GoFoward: TMenuItem;
		EditAction: TAction;
		ReloadAction: TAction;
		GoFowardAction: TAction;
		GoBackAction: TAction;
		SelectComboBoxSplitter: TImage;
		IndividualAbon1: TMenuItem;
		N41: TMenuItem;
		IndividualAbon2: TMenuItem;
		N42: TMenuItem;
		CancellIndividualAbon: TAction;
		AntiIndividualAbon: TMenuItem;
		N49: TMenuItem;
		N51: TMenuItem;
		N52: TMenuItem;
		N53: TMenuItem;
		SearchBoardName: TMenuItem;
    TreeSelectLogDeleteSeparator: TMenuItem;
		TreeSelectSearchBoardName: TAction;
		CabinetFavoriteAction: TAction;
		N54: TMenuItem;
		A13: TMenuItem;
		FavoriteTreePopupMenu: TPopupMenu;
		FavoriteTreeViewRenameAction: TAction;
		FavoriteTreeRenamePopupMenu: TMenuItem;
		FavoriteTreeViewNewFolderAction: TAction;
		FavoriteTreeNewFolderPopupMenu: TMenuItem;
		N56: TMenuItem;
		FavoriteTreeViewDeleteAction: TAction;
		FavoriteTreeDeletePopupMenu: TMenuItem;
		FavoriteToolBar: TToolBar;
		ToolButton17: TToolButton;
		ToolButton19: TToolButton;
		FavoriteTreeViewBrowseFolderAction: TAction;
		FavoriteTreeBrowseFolderPopupMenu: TMenuItem;
		N57: TMenuItem;
		FavoriteTreeReloadPopupMenu: TMenuItem;
		N58: TMenuItem;
		FavoriteTreeURLCopyPopupMenu: TMenuItem;
		FavoriteTreeNameCopyPopupMenu: TMenuItem;
		FavoriteTreeLogDeletePopupMenu: TMenuItem;
		N59: TMenuItem;
		FavoriteTreeNameURLCopyPopupMenu: TMenuItem;
		FavoriteTreeViewReloadAction: TAction;
		FavoriteTreeViewURLCopyAction: TAction;
		FavoriteTreeViewNameCopyAction: TAction;
		FavoriteTreeViewNameURLCopyAction: TAction;
		FavoriteTreeViewLogDeleteAction: TAction;
		OnlyAHundredRes: TAction;
		ToolButton20: TToolButton;
		AHundredResButton: TToolButton;
		N60: TMenuItem;
		ExportFavoriteFileAction1: TMenuItem;
		ExportFavoriteFile: TFileSaveAs;
		ToolButton21: TToolButton;
		CabinetBBSToolButton: TToolButton;
		ToolButton23: TToolButton;
		ToolButton24: TToolButton;
		N6: TMenuItem;
		N17: TMenuItem;
		FavoriteTreeViewBrowseBoardAction: TAction;
		FavoriteTreeViewBrowseThreadAction: TAction;
		UpBoardAction: TAction;
    N18: TMenuItem;
    N20: TMenuItem;
    N24: TMenuItem;
    N62: TMenuItem;
    N61: TMenuItem;
    N63: TMenuItem;
    KoreCopy: TAction;
    N64: TMenuItem;
    dummy1: TMenuItem;
    TreeSelectLogDeletePopupMenu: TMenuItem;
    N65: TMenuItem;
    BBSSelectPopupMenu: TPopupMenu;
		PlugInMenu: TMenuItem;
    TmpToolBar: TToolBar;
    TreeSelectNameCopy: TAction;
    TreeSelectNamePupupMenu: TMenuItem;
    BrowserPanel: TPanel;
    SetFocusForBrowserAction: TAction;
    SetFocusForThreadListAction: TAction;
    SetFocusForCabinetAction: TAction;
    FileRun1: TFileRun;
    ThreadlistMaxAndFocusAction: TAction;
    BrowserMaxAndFocusAction: TAction;
    UpBoardButton: TToolButton;
    SelectTimer: TTimer;
    SelectThreadSave: TMenuItem;
    SelectItemSaveForHTML: TAction;
    FileSaveAs1: TFileSaveAs;
    N55: TMenuItem;
    N66: TMenuItem;
    dat1: TMenuItem;
    SelectItemSaveForDat: TAction;
    LogFolderOpenAction: TAction;
    OpenLogFolder: TMenuItem;
    Browser: TWebBrowser;
    LocalRuleView: TToolButton;
    IdHTTP1: TIdHTTP;
				procedure FormCreate(Sender: TObject);
		procedure FormDestroy(Sender: TObject);
		procedure CabinetPanelHide(Sender: TObject);
		procedure FormClose(Sender: TObject; var Action: TCloseAction);
		procedure ListViewData(Sender: TObject; Item: TListItem);
		procedure ListViewDataFind(Sender: TObject; Find: TItemFind;
			const FindString: String; const FindPosition: TPoint;
			FindData: Pointer; StartIndex: Integer; Direction: TSearchDirection;
			Wrap: Boolean; var Index: Integer);
		procedure ListViewDataHint(Sender: TObject; StartIndex,
			EndIndex: Integer);
		procedure ListViewDataStateChange(Sender: TObject; StartIndex,
			EndIndex: Integer; OldState, NewState: TItemStates);
		procedure BrowserStatusTextChange(Sender: TObject;
			const Text: WideString);
		procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
		procedure TreeViewChanging(Sender: TObject; Node: TTreeNode;
			var AllowChange: Boolean);
		procedure ListViewKeyDown(Sender: TObject; var Key: Word;
			Shift: TShiftState);
		procedure ListViewColumnClick(Sender: TObject; Column: TListColumn);
		procedure MenuToolBarCustomDrawButton(Sender: TToolBar;
			Button: TToolButton; State: TCustomDrawState;
			var DefaultDraw: Boolean);
		procedure BrowserBeforeNavigate2(Sender: TObject;
			const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
			Headers: OleVariant; var Cancel: WordBool);
		procedure ListViewAdvancedCustomDrawItem(Sender: TCustomListView;
			Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
			var DefaultDraw: Boolean);
		procedure TreeViewCustomDraw(Sender: TCustomTreeView;
			const ARect: TRect; var DefaultDraw: Boolean);
		procedure TreeViewCustomDrawItem(Sender: TCustomTreeView;
			Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
		procedure TreeViewExpanded(Sender: TObject; Node: TTreeNode);
		procedure TreeViewDblClick(Sender: TObject);
		procedure ListViewCustomDraw(Sender: TCustomListView;
			const ARect: TRect; var DefaultDraw: Boolean);
		procedure ListViewMouseDown(Sender: TObject; Button: TMouseButton;
			Shift: TShiftState; X, Y: Integer);
		procedure TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
		procedure MessageListViewResize(Sender: TObject);
		procedure ExitActionExecute(Sender: TObject);
		procedure AllSelectActionExecute(Sender: TObject);
		procedure StdToolBarVisibleActionExecute(Sender: TObject);
		procedure MsgBarVisibleActionExecute(Sender: TObject);
		procedure StatusBarVisibleActionExecute(Sender: TObject);
		procedure LargeIconActionExecute(Sender: TObject);
		procedure SmallIconActionExecute(Sender: TObject);
		procedure ListIconActionExecute(Sender: TObject);
		procedure DetailIconActionExecute(Sender: TObject);
		procedure SearchActionExecute(Sender: TObject);
		procedure OptionActionExecute(Sender: TObject);
		procedure GikoNaviWebPageActionExecute(Sender: TObject);
		procedure AboutActionExecute(Sender: TObject);
		procedure CabinetHistoryActionExecute(Sender: TObject);
		procedure	CabinetVisible( isVisible : Boolean );
		procedure CabinetVisibleActionExecute(Sender: TObject);
		procedure AllItemActionExecute(Sender: TObject);
		procedure LogItemActionExecute(Sender: TObject);
		procedure NewItemActionExecute(Sender: TObject);
		procedure SelectItemActionExecute(Sender: TObject);
		procedure ListNumberVisibleActionExecute(Sender: TObject);
		procedure UpFolderActionExecute(Sender: TObject);
		procedure IconStyleExecute(Sender: TObject);
		procedure RoundActionExecute(Sender: TObject);
		procedure StopActionExecute(Sender: TObject);
		procedure MsgBarCloseActionExecute(Sender: TObject);
		procedure BrowserMaxActionExecute(Sender: TObject);
		procedure ScrollTopActionExecute(Sender: TObject);
		procedure ScrollLastActionExecute(Sender: TObject);
		procedure ScrollNewActionExecute(Sender: TObject);
		procedure ScrollKokoActionExecute(Sender: TObject);
		procedure EditorActionExecute(Sender: TObject);
		procedure IEActionExecute(Sender: TObject);
		procedure ShowThreadActionExecute(Sender: TObject);
		procedure ShowBoardActionExecute(Sender: TObject);
		procedure URLCopyActionExecute(Sender: TObject);
		procedure ItemReloadActionExecute(Sender: TObject);
		procedure SelectListReloadActionExecute(Sender: TObject);
		procedure SelectThreadReloadActionExecute(Sender: TObject);
		procedure SelectListReloadActionUpdate(Sender: TObject);
		procedure AllItemActionUpdate(Sender: TObject);
		procedure LogItemActionUpdate(Sender: TObject);
		procedure NewItemActionUpdate(Sender: TObject);
		procedure SelectItemActionUpdate(Sender: TObject);
		procedure UpFolderActionUpdate(Sender: TObject);
		procedure FormResize(Sender: TObject);
		procedure ScrollTopActionUpdate(Sender: TObject);
		procedure ScrollLastActionUpdate(Sender: TObject);
		procedure ScrollNewActionUpdate(Sender: TObject);
		procedure ScrollKokoActionUpdate(Sender: TObject);
		procedure EditorActionUpdate(Sender: TObject);
		procedure IEActionUpdate(Sender: TObject);
		procedure ShowThreadActionUpdate(Sender: TObject);
		procedure ShowBoardActionUpdate(Sender: TObject);
		procedure SelectThreadReloadActionUpdate(Sender: TObject);
		procedure ItemReloadActionUpdate(Sender: TObject);
		procedure LogDeleteActionExecute(Sender: TObject);
		procedure KokomadeActionExecute(Sender: TObject);
		procedure ZenbuActionExecute(Sender: TObject);
		procedure KokoResActionExecute(Sender: TObject);
		procedure ListPopupMenuPopup(Sender: TObject);
		procedure SelectItemURLCopyActionExecute(Sender: TObject);
		procedure SelectItemURLCopyActionUpdate(Sender: TObject);
		procedure AllSelectActionUpdate(Sender: TObject);
		procedure LogDeleteActionUpdate(Sender: TObject);
		procedure BrowserTabCloseActionExecute(Sender: TObject);
		procedure NotSelectTabCloseActionExecute(Sender: TObject);
		procedure TreeSelectBoradReloadExecute(Sender: TObject);
		procedure TreeSelectThreadReloadExecute(Sender: TObject);
		procedure TreeSelectURLCopyExecute(Sender: TObject);
		procedure TreePopupMenuPopup(Sender: TObject);
		procedure ListToolBarVisibleActionExecute(Sender: TObject);
		procedure BrowserToolBarVisibleActionExecute(Sender: TObject);
		procedure BrowserNewWindow2(Sender: TObject; var ppDisp: IDispatch;
			var Cancel: WordBool);
		procedure ListSplitterCanResize(Sender: TObject; var NewSize: Integer;
			var Accept: Boolean);
		procedure ListSplitterMoved(Sender: TObject);
		procedure BrowserTabChange(Sender: TObject);
		procedure BrowserTabMouseDown(Sender: TObject; Button: TMouseButton;
			Shift: TShiftState; X, Y: Integer);
		procedure BrowserTabDragOver(Sender, Source: TObject; X, Y: Integer;
			State: TDragState; var Accept: Boolean);
		procedure BrowserTabDragDrop(Sender, Source: TObject; X, Y: Integer);
		procedure BrowserTabMouseMove(Sender: TObject; Shift: TShiftState; X,
			Y: Integer);
		procedure BrowserDocumentComplete(Sender: TObject;
			const pDisp: IDispatch; var URL: OleVariant);
		procedure SelectReservActionUpdate(Sender: TObject);
		procedure RoundNamePopupMenuPopup(Sender: TObject);
		procedure SelectNewRoundNameExecute(Sender: TObject);
		procedure SelectDeleteRoundExecute(Sender: TObject);
		procedure SelectReservActionExecute(Sender: TObject);
		procedure NewBoardActionExecute(Sender: TObject);
		procedure LoginActionExecute(Sender: TObject);
		procedure KeySettingActionExecute(Sender: TObject);
		procedure AllTabCloseActionExecute(Sender: TObject);
		procedure ArrangeActionExecute(Sender: TObject);
		procedure NameURLCopyActionExecute(Sender: TObject);
		procedure SelectItemNameURLCopyActionExecute(Sender: TObject);
		procedure URLCopyActionUpdate(Sender: TObject);
		procedure NameURLCopyActionUpdate(Sender: TObject);
		procedure BrowserTabCloseActionUpdate(Sender: TObject);
		procedure NotSelectTabCloseActionUpdate(Sender: TObject);
		procedure AllTabCloseActionUpdate(Sender: TObject);
		procedure SelectItemNameURLCopyActionUpdate(Sender: TObject);
		procedure ActiveLogDeleteActionExecute(Sender: TObject);
		procedure ActiveLogDeleteActionUpdate(Sender: TObject);
		procedure ListNameBarVisibleActionExecute(Sender: TObject);
		procedure BrowserNameBarVisibleActionExecute(Sender: TObject);
		procedure TreeSelectNameURLCopyExecute(Sender: TObject);
		procedure PaneInitActionExecute(Sender: TObject);
		procedure FormShow(Sender: TObject);
		procedure BrowserTabToolBarResize(Sender: TObject);
		procedure BrowserMinActionExecute(Sender: TObject);
		procedure SelectTextClearActionExecute(Sender: TObject);
		procedure NameTextClearActionExecute(Sender: TObject);
		procedure MailTextClearActionExecute(Sender: TObject);
		procedure LeftmostTabSelectActionExecute(Sender: TObject);
		procedure LeftTabSelectActionExecute(Sender: TObject);
		procedure RightTabSelectActionExecute(Sender: TObject);
		procedure RightmostTabSelectActionExecute(Sender: TObject);
		procedure LeftmostTabSelectActionUpdate(Sender: TObject);
		procedure LeftTabSelectActionUpdate(Sender: TObject);
		procedure RightTabSelectActionUpdate(Sender: TObject);
		procedure RightmostTabSelectActionUpdate(Sender: TObject);
		procedure FavoriteMenuClick(Sender: TObject);
		procedure FavoriteAddActionExecute(Sender: TObject);
		procedure FavoriteAddActionUpdate(Sender: TObject);
		procedure BoardFavoriteAddActionExecute(Sender: TObject);
		procedure BoardFavoriteAddActionUpdate(Sender: TObject);
		procedure ThreadFavoriteAddActionExecute(Sender: TObject);
		procedure ThreadFavoriteAddActionUpdate(Sender: TObject);
		procedure TreeSelectFavoriteAddActionExecute(Sender: TObject);
		procedure FavoriteArrangeActionExecute(Sender: TObject);
		procedure MainCoolBarResize(Sender: TObject);
		procedure MoveToActionExecute(Sender: TObject);
		procedure AddressToolBarResize(Sender: TObject);
		procedure AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
			Shift: TShiftState);
		procedure AddressBarVisibleActionExecute(Sender: TObject);
		procedure BrowserEnter(Sender: TObject);
		procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
		procedure BrowserTabVisibleActionExecute(Sender: TObject);
		procedure BrowserTabTopActionExecute(Sender: TObject);
		procedure BrowserTabBottomActionExecute(Sender: TObject);
		procedure BrowserTabTabStyleActionExecute(Sender: TObject);
		procedure BrowserTabButtonStyleActionExecute(Sender: TObject);
		procedure BrowserTabFlatStyleActionExecute(Sender: TObject);
		procedure PreviewTimerTimer(Sender: TObject);
		procedure MessageHideButtonClick(Sender: TObject);
		procedure MonazillaWebPageActionExecute(Sender: TObject);
		procedure GikoHelpActionExecute(Sender: TObject);
		procedure ToolButton18Click(Sender: TObject);
		procedure KotehanActionExecute(Sender: TObject);
		procedure LinkBarVisibleActionExecute(Sender: TObject);
		procedure BBS2chWebPageActionExecute(Sender: TObject);
		procedure GikoFolderOpenActionExecute(Sender: TObject);
		procedure MainCoolBarBandInfo(Sender: TObject;
			var BandInfo: PReBarBandInfoA);
		procedure MainCoolBarChevronClick(Sender: TObject;
			RebarChevron: PNMRebarChevron);
		procedure ListCoolBarBandInfo(Sender: TObject;
			var BandInfo: PReBarBandInfoA);
		procedure ListCoolBarChevronClick(Sender: TObject;
			RebarChevron: PNMRebarChevron);
		procedure BrowserCoolBarBandInfo(Sender: TObject;
			var BandInfo: PReBarBandInfoA);
		procedure BrowserCoolBarChevronClick(Sender: TObject;
			RebarChevron: PNMRebarChevron);
		procedure ListViewColumnInfo(Sender: TObject; var Column: PLVColumnA);
		procedure ThreadEditorActionExecute(Sender: TObject);
		procedure ThreadEditorActionUpdate(Sender: TObject);
		procedure ToolBarSettingActionExecute(Sender: TObject);
		procedure NameCopyActionExecute(Sender: TObject);
		procedure BoardIEActionExecute(Sender: TObject);
		procedure SelectItemNameCopyActionExecute(Sender: TObject);
		procedure SelectItemNameCopyActionUpdate(Sender: TObject);
		procedure BoardIEActionUpdate(Sender: TObject);
		procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
			WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
		procedure NameCopyActionUpdate(Sender: TObject);
		procedure SelectComboBoxChange(Sender: TObject);
		procedure SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
			Shift: TShiftState);
		procedure SelectComboBoxExit(Sender: TObject);
		procedure NG1Click(Sender: TObject);
		procedure SelectResActionExecute(Sender: TObject);
		procedure SelectResActionUpdate(Sender: TObject);
		procedure FormKeyUp(Sender: TObject; var Key: Word;
			Shift: TShiftState);
		procedure AllResActionExecute(Sender: TObject);
		procedure AllResActionUpdate(Sender: TObject);
		procedure ReloadClick(Sender: TObject);
		procedure GoBackClick(Sender: TObject);
		procedure GoFowardClick(Sender: TObject);
		procedure SelectComboBoxSplitterMouseMove(Sender: TObject;
			Shift: TShiftState; X, Y: Integer);
		procedure SelectComboBoxSplitterMouseDown(Sender: TObject;
			Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
		procedure SelectComboBoxSplitterMouseUp(Sender: TObject;
			Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
		procedure StatusBarResize(Sender: TObject);
		procedure IndividualAbon1Click(Sender: TObject);
		procedure IndividualAbon2Click(Sender: TObject);
		procedure N42Click(Sender: TObject);
		procedure SelectComboBoxEnter(Sender: TObject);
		procedure AntiIndividualAbonClick(Sender: TObject);
		procedure N51Click(Sender: TObject);
		procedure TreeSelectSearchBoardNameExecute(Sender: TObject);
		procedure CabinetFavoriteActionExecute(Sender: TObject);
		procedure FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
			Y: Integer);
		procedure FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
		procedure FavoriteTreeViewEdited(Sender: TObject; Node: TTreeNode;
			var S: String);
		procedure FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
			Shift: TShiftState);
		procedure FavoriteTreePopupMenuPopup(Sender: TObject);
		procedure FavoriteTreeViewDeleteActionExecute(Sender: TObject);
		procedure FavoriteTreeViewRenameActionExecute(Sender: TObject);
		procedure FavoriteTreeViewNewFolderActionExecute(Sender: TObject);
		procedure ToolButton19Click(Sender: TObject);
		procedure FavoriteTreeViewBrowseFolderActionExecute(Sender: TObject);
		procedure FavoriteTreeViewDblClick(Sender: TObject);
		procedure FavoriteTreeViewLogDeleteActionExecute(Sender: TObject);
		procedure FavoriteTreeViewReloadActionExecute(Sender: TObject);
		procedure FavoriteTreeViewURLCopyActionExecute(Sender: TObject);
		procedure FavoriteTreeViewNameCopyActionExecute(Sender: TObject);
		procedure FavoriteTreeViewNameURLCopyActionExecute(Sender: TObject);
		procedure LinkToolBarDragDrop(Sender, Source: TObject; X, Y: Integer);
		procedure BrowserTabMouseUp(Sender: TObject; Button: TMouseButton;
			Shift: TShiftState; X, Y: Integer);
		procedure LinkToolBarDragOver(Sender, Source: TObject; X, Y: Integer;
			State: TDragState; var Accept: Boolean);
		procedure OnlyAHundredResExecute(Sender: TObject);
		procedure FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
			Y: Integer);
		procedure ListCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
			var Handled: Boolean);
		procedure MainCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
			var Handled: Boolean);
		procedure BrowserCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
			var Handled: Boolean);
		procedure ExportFavoriteFileAccept(Sender: TObject);
		procedure ExportFavoriteFileBeforeExecute(Sender: TObject);
		procedure CabinetBBSActionExecute(Sender: TObject);
		procedure FavoriteTreeViewBrowseThreadActionExecute(Sender: TObject);
		procedure FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
		procedure UpBoardActionExecute(Sender: TObject);
		procedure UpBoardActionUpdate(Sender: TObject);
    procedure BrowserTabContextPopup(Sender: TObject; MousePos: TPoint;
      var Handled: Boolean);
    procedure KoreCopyExecute(Sender: TObject);
    procedure BrowserTabPopupMenuPopup(Sender: TObject);
    procedure MenuToolBarResize(Sender: TObject);
    procedure StdToolBarResize(Sender: TObject);
    procedure LinkToolBarResize(Sender: TObject);
    procedure ListNameToolBarResize(Sender: TObject);
    procedure ListToolBarResize(Sender: TObject);
    procedure BrowserNameToolBarResize(Sender: TObject);
    procedure BrowserToolBarResize(Sender: TObject);
    procedure BrowserTabResize(Sender: TObject);
	procedure TreeViewClick(Sender: TObject);
    procedure TreeViewKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FavoriteTreeViewMouseDown(Sender: TObject;
			Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure MessagePanelResize(Sender: TObject);
		procedure OnResized;
    procedure TreeSelectNameCopyExecute(Sender: TObject);
    procedure FavoriteTreeViewMouseUp(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure OnlyAHundredResUpdate(Sender: TObject);
    procedure SetFocusForBrowserActionExecute(Sender: TObject);
    procedure SetFocusForBrowserActionUpdate(Sender: TObject);
    procedure SetFocusForThreadListActionExecute(Sender: TObject);
    procedure SetFocusForCabinetActionExecute(Sender: TObject);
    procedure BrowserMaxAndFocusActionExecute(Sender: TObject);
    procedure BrowserMaxAndFocusActionUpdate(Sender: TObject);
    procedure ThreadlistMaxAndFocusActionExecute(Sender: TObject);
    procedure ListViewExit(Sender: TObject);
    procedure SetFocusForCabinetActionUpdate(Sender: TObject);
    procedure ListViewSelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure SelectTimerTimer(Sender: TObject);
    procedure SelectItemSaveForHTMLExecute(Sender: TObject);
    procedure KidokuActionExecute(Sender: TObject);
    procedure MidokuActionExecute(Sender: TObject);
    procedure SelectItemSaveForDatExecute(Sender: TObject);
    procedure BrowserPanelCanResize(Sender: TObject; var NewWidth,
      NewHeight: Integer; var Resize: Boolean);
    procedure LogFolderOpenActionExecute(Sender: TObject);
    procedure LogFolderOpenActionUpdate(Sender: TObject);
    procedure LocalRuleViewClick(Sender: TObject);
	private
		{ Private éŒ¾ }
        //RoundList : TRoundList;
		FSortIndex: Integer;
		FSortOrder: Boolean;

		FEnabledCloseButton: Boolean;
//		ThreadCreate: TThreadCreate;

		FClickNode: TTreeNode;
		FHttpState: Boolean;
		FHint: TResPopup;
		FPreviewBrowser: TPreviewBrowser;
		FPreviewURL: string;

		FBrowserSizeHeight: Integer;
		FBrowserSizeWidth: Integer;

//		FFavorite: TFavorite;
		FTabHintIndex: Integer;
		FListStyle: TViewStyle;				//ƒŠƒXƒgƒAƒCƒRƒ“ƒXƒ^ƒCƒ‹
		FItemNoVisible: Boolean;			//ƒŠƒXƒg”Ô†•\Ž¦ƒtƒ‰ƒO
		FViewType: TGikoViewType;			//ƒŠƒXƒgƒAƒCƒeƒ€•\Ž¦ƒ^ƒCƒv
 		FActiveList: TObject;
		FActiveContent: TBrowserRecord;	//
		FActiveBBS : TBBS;
		FHistoryList: TList;					//ƒqƒXƒgƒŠƒŠƒXƒg
		FTreeType: TGikoTreeType;
		FWorkCount: Integer;
		FNameCookie: string;
		FMailCookie: string;
//		FLastRoundTime: TDateTime;
		BrowserNullTab: TBrowserRecord;
//		DoubleClickOccurred: array [TMouseButton] of Boolean;
		FDownloadTitle: string;				//ƒ_ƒEƒ“ƒ[ƒh’†‚Ìƒ^ƒCƒgƒ‹–¼
		FDownloadMax: Integer;				//ƒ_ƒEƒ“ƒ[ƒh’†‚ÌÅ‘åƒTƒCƒY
		FEvent: THTMLDocumentEventSink;//ƒuƒ‰ƒEƒUƒhƒLƒ…ƒƒ“ƒgƒCƒxƒ“ƒg

	  //	Fkeynum : Integer; //ƒL[ƒ{[ƒhƒŒƒXƒ|ƒbƒvƒAƒbƒv—p

		IsDraggingSelectComboBox : Boolean;
		DraggingSelectComboBoxPosition : TPoint;

		FSearchDialog: TSearchDialog;

		FDropSpaceNode: TTreeNode;

		FDragTime : Cardinal;	//ƒŠƒ“ƒN‚ÌD&D—p
		FDragButton : TToolButton;	//ƒŠƒ“ƒN‚ÌD&D—p‚ÉDrag‚µ‚Ä‚éButton•Û‘¶
		FDragWFirst : Boolean;	//WebTab‚ÌD&D—p

		FListViewBackGroundColor : TColor; //ListView‚ÌBackGroundColor
		FUseOddResOddColor : Boolean; //Žæ“¾ƒŒƒX”‚ÆƒXƒŒƒbƒh‚ÌƒŒƒX”‚ªˆá‚Á‚½‚Æ‚«‚É‘¼‚ÌF‚Å•\Ž¦
		FOddColor : TColor;					 //‚»‚ÌF

		FSelectResWord	: string;					// ƒŒƒXižƒ[ƒh
		FIsIgnoreResize	: Boolean;				// ƒŠƒTƒCƒYƒCƒxƒ“ƒg‚ð–³Ž‹‚·‚é‚©‚Ç‚¤‚©
		FIsMinimize			: TMinimizeType;	// Å¬‰»‚µ‚Ä‚¢‚éÅ’†‚©
		FOldFormWidth		: Integer;				// ’¼‘O‚ÌƒEƒBƒ“ƒhƒE‚Ì•
		FToolBarSettingSender : TToolBarSettingSenderType;	// ƒc[ƒ‹ƒo[Ý’è‚ðƒNƒŠƒbƒN‚µ‚½ƒN[ƒ‹ƒo[
		FMouseDownPos		: TPoint; 				// ƒuƒ‰ƒEƒUƒ^ƒu‚Åƒ}ƒEƒX‚ð‰Ÿ‚µ‚½‚Æ‚«‚ÌÀ•W
		FBrowsers: TList;
		procedure SetBoardTreeNode( inBBS : TBBS );
		function SetCategoryListItem(ABBS2ch: TBBS): Integer;
		function SetBoardListItem(Category: TCategory): Integer;
		function SetThreadListItem(Board: TBoard): Integer;
//		function GetRoundName(index: integer): string;

		procedure DownloadEnd(Sender: TObject; Item: TDownloadItem);
		procedure DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
		procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
		procedure WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
		procedure Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);

		procedure SetActiveList(Obj: TObject);
		procedure ListClick;
		procedure ListDoubleClick(Shift: TShiftState);
		procedure BrowserMovement(const AName: string); overload;
		procedure BrowserMovement(const AName: string; BrowserRecord: TBrowserRecord); overload;
		procedure SelectListItem(List: TList);
//		procedure SetProgressValue(Number: Integer; Value: Integer; Max: Integer = -1);
		procedure DeleteTab(ThreadItem: TThreadItem); overload;
		procedure DeleteTab(BrowserRecord: TBrowserRecord); overload;
		function Hook(var Message: TMessage): Boolean;
		procedure AddRoundNameMenu(MenuItem: TMenuItem);
		procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string); overload;
		procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string); overload;
		procedure SetSelectRoundName(Sender: TObject);
		function GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;

		procedure SetMenuFont;
//		procedure CreateFavMenu(Folder: TFavoriteFolder);
		procedure CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
		procedure FavoriteClick(Sender: TObject; ActiveTab: Boolean); overload;
		procedure FavoriteClick(Sender: TObject); overload;
		procedure FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
		procedure SelectTreeNode(Item: TObject; CallEvent: Boolean);
		function OnDocumentContextMenu(Sender: TObject): WordBool;
//		function GetThreadText(sBoard: string; sThread: string; StNum, ToNum: Integer; Title, First: Boolean): string;
		procedure SetResPopupText(ThreadItem : TThreadItem; StNum, ToNum: Integer; Title, First: Boolean);
		procedure ShowTextPopup;
		//procedure ShowTextPopup(HintData: THintData);
//		procedure SetStdToolBar;
//		function GetAction(ActionName: string): TContainedAction;
		procedure SetLinkBar;
		function GetWidthAllToolButton(ToolBar: TToolBar): Integer;
		procedure MenuBarChevronMenu;
		procedure LinkBarChevronMenu;
		procedure ToolBarChevronMenu(ToolBar: TToolBar);
		procedure ModifySelectList;
		procedure FavoriteBrowseFolder( node: TTreeNode );
		procedure LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
		procedure LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
		procedure LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
		procedure LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
		procedure LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
		function TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
		procedure FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
		procedure FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
		procedure FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
		//
		procedure SetListViewBackGroundColor(value: TColor);
		procedure BBSMenuItemOnClick( Sender : TObject );
		//
		procedure KonoresCopy(Number: Integer; ReplaceTag : Boolean);
		// CoolBar ‚ÌÝ’è‚ð•Ï”‚É•Û‘¶
		procedure	SaveCoolBarSettings;
		// CoolBar ‚ÌÝ’è‚ð•Ï”‚©‚ç•œŒ³
		procedure	LoadCoolBarSettings;
		// Å¬‰»‚³‚ê‚é
		procedure OnMinimize;
		// Å¬‰»‚³‚ê‚½
		procedure OnMinimized;
		// CoolBar ‚ªƒTƒCƒY•ÏX‚³‚ê‚½
		procedure	CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
		// TreeView ‚ªƒNƒŠƒbƒN‚³‚ê‚½
		procedure TreeClick( Node : TTreeNode );
		// TreeView ‚ªƒ_ƒuƒ‹ƒNƒŠƒbƒN‚³‚ê‚½
		procedure TreeDoubleClick( Node : TTreeNode );
		// ƒMƒRƒiƒr‚ÌƒƒbƒZ[ƒWƒ‹[ƒv‚ð‰¡Žæ‚è‚µ‚Ü‚·
		procedure HandleAppMessage(var Msg: TMsg; var Handled: Boolean);
		// ƒuƒ‰ƒEƒU‚ÌƒL[ƒ_ƒEƒ“ƒCƒxƒ“ƒg
		// ƒCƒxƒ“ƒg‚ðŽæ‚èˆµ‚Á‚½ê‡‚Í True ‚ð•Ô‚·
		function BrowserKeydown(var Msg: TMsg; Key: Word; State:TShiftState) : Boolean;
		// ŠeŠ‚É‚ ‚éƒLƒƒƒrƒlƒbƒgE BBS ƒƒjƒ…[‚ðƒZƒbƒg^XV
		procedure SetBBSMenu;
		function WebBrowserClick(Sender: TObject): WordBool;
		procedure SkinorCSSFilesCopy(path: string);
	protected
		procedure CreateParams(var Params: TCreateParams); override;
		procedure WndProc(var Message: TMessage); override;
		procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR;
		procedure WMSettingChange(var Message: TWMWinIniChange); message WM_SETTINGCHANGE;
		procedure WMCopyData(var Message: TWMCopyData); message WM_COPYDATA;

	public
		{ Public éŒ¾ }
//		FDownload: TDownload;
		FControlThread: TThreadControl;
		procedure MoveToURL(URL: string);
		procedure InsertBrowserTab(ThreadItem: TThreadItem; ActiveTab: Boolean = True);
		procedure ReloadBBS;
		function GetHttpState: Boolean;
		procedure SetEnabledCloseButton(Enabled: Boolean);
		function GetTreeNode(Data: TObject): TTreeNode;
		procedure AppFormDeactivate(Sender: TObject);
//		procedure CabinetPanelVisible(PanelVisible: Boolean);
		procedure ListViewAllSelect;

		property ListStyle: TViewStyle read FListStyle write FListStyle;
		property ItemNoVisible: Boolean read FItemNoVisible write FItemNoVisible;
		property ViewType: TGikoViewType read FViewType write FViewType;

		property NameCookie: string read FNameCookie write FNameCookie;
		property MailCookie: string read FMailCookie write FMailCookie;

		procedure SetContent(inThread: TBrowserRecord);
		function GetActiveContent: TThreadItem;
		function GetActiveList: TObject;

		property ActiveList: TObject read GetActiveList write SetActiveList;
//		property LastRoundTime: TDateTime read FLastRoundTime write FLastRoundTime;

		procedure SetListViewType(AViewType: TGikoViewType); overload;
		procedure SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean); overload;
		procedure DownloadContent(ThreadItem: TThreadItem; ForceDownload: Boolean = False);
		procedure DownloadList(Board: TBoard; ForceDownload: Boolean = False);
		procedure PlaySound(SoundEventName: string);

		function AddHistory( FavItem: TFavoriteThreadItem ): Boolean;
		procedure DeleteHistory( threadItem: TThreadItem );
		procedure ClearHistory;
		procedure	SaveHistory;
		procedure	LoadHistory;
		procedure ShowBBSTree( inBBS : TBBS );
		procedure ShowBBSTreeOld( inBBS : TBBS );
		procedure ShowHistoryTree;
		procedure SetHistoryTreeNode;
//		procedure SelectTreeNode(Item: TObject);
		procedure AddMessageList(ACaption: string; AObject: TObject; Icon: TGikoMessageIcon);
		procedure SetBrowserTabState;
//		property Favorite: TFavorite read FFavorite write FFavorite;
		procedure SetToolBarPopup;
		procedure ShowFavoriteAddDialog( Item : TObject );
        procedure FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
        procedure RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
		property ListViewBackGroundColor: TColor read FListViewBackGroundColor write SetListViewBackGroundColor;
		property UseOddResOddColor : Boolean read FUseOddResOddColor write FUseOddResOddColor;
		property OddColor : TColor read FOddColor write FOddColor;

		function FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
		procedure OnPlugInMenuItem( Sender : TObject );

	published
		property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
	end;

	TFavoriteMenuItem = class(TMenuItem)
	private
		FData : Pointer;
	public
		property Data: Pointer read FData write FData;
	end;

	TBBSMenuItem = class(TMenuItem)
	private
		FData : Pointer;
	public
		property Data: Pointer read FData write FData;
	end;

	TLinkToolButton = class(TToolButton)
	private
		FData : Pointer;
	public
		property Data: Pointer read FData write FData;
	end;

	TBrowserRecord = class( TObject )
	private
		FBrowser	: TWebBrowser;
		FEvent: THTMLDocumentEventSink;//ƒuƒ‰ƒEƒUƒhƒLƒ…ƒƒ“ƒgƒCƒxƒ“ƒg
		FThread		: TThreadItem;
		FLastSize	: Integer;
		FRepaint	: Boolean;
		FOnlyHundred: Boolean;
	public
		destructor	Destroy; override;
		property	Browser	: TWebBrowser	read FBrowser	write FBrowser;
		property	Thread	: TThreadItem	read FThread	write FThread;
		property	LastSize	: Integer		read FLastSize	write FLastSize;
		property	Repaint		: Boolean		read FRepaint	write FRepaint;
		property	OnlyHundred : Boolean		read FOnlyHundred write FOnlyHundred;
	end;

var
	GikoForm: TGikoForm;

implementation

uses
	About, Option, Round, Splash, Sort, ListSelect,
	NewBoard, MojuUtils,Clipbrd;

const
	CAPTION_NAME: string = 'ƒMƒRƒiƒr';
	BLANK_HTML: string = 'about:blank';
	SELECTCOMBOBOX_NAME: string = ''; // 'ƒXƒŒƒbƒhižŒŸõ';
	SELECTCOMBOBOX_COLOR: TColor = clWindow;
	//D&Dè‡’l
	DandD_THRESHOLD	= 5;	//D&D‚Ìè‡’lipixcel)
	//ƒcƒŠ[EƒŠƒXƒgƒAƒCƒRƒ“
	ITEM_ICON_2CH1					= 0;		//2chƒAƒCƒRƒ“
	ITEM_ICON_2CH2					= 1;		//2chƒAƒCƒRƒ“
	ITEM_ICON_CATEGORY1			= 2;		//ƒJƒeƒSƒŠƒAƒCƒRƒ“
	ITEM_ICON_CATEGORY2			= 3;		//ƒJƒeƒSƒŠƒAƒCƒRƒ“
	ITEM_ICON_BOARD_NOSUBJECT	= 3;	//“Ç‚Ýž‚Ü‚ê‚Ä‚¢‚È‚¢”ÂƒAƒCƒRƒ“
	ITEM_ICON_BOARD1				= 4;		//”ÂƒAƒCƒRƒ“
	ITEM_ICON_BOARD2				= 5;		//”ÂƒAƒCƒRƒ“
	ITEM_ICON_THREADLOG1		= 6;		//ƒXƒŒƒAƒCƒRƒ“iƒƒO‚ ‚èj
	ITEM_ICON_THREADLOG2		= 7;		//ƒXƒŒƒAƒCƒRƒ“iƒƒO‚ ‚èj
	ITEM_ICON_THREAD1				= 8;		//ƒXƒŒƒAƒCƒRƒ“iƒƒO‚È‚µj
	ITEM_ICON_THREAD2				= 9;		//ƒXƒŒƒAƒCƒRƒ“iƒƒO‚È‚µj
	ITEM_ICON_THREADNEW1		= 10;		//ƒXƒŒƒAƒCƒRƒ“iV’…j
	ITEM_ICON_THREADNEW2		= 11;		//ƒXƒŒƒAƒCƒRƒ“iV’…j
	ITEM_ICON_SORT1					= 12;		//ƒ\[ƒgƒAƒCƒRƒ“
	ITEM_ICON_SORT2					= 13;		//ƒ\[ƒgƒAƒCƒRƒ“
	ITEM_ICON_BOARD_LOG			= 17;		//ƒXƒŒƒƒO‚ ‚è”ÂƒAƒCƒRƒ“
	ITEM_ICON_BOARD_NEW			= 18;		//ƒXƒŒV’…”ÂƒAƒCƒRƒ“

	//ƒc[ƒ‹ƒo[ƒAƒCƒRƒ“
	TOOL_ICON_HEIGHT_MAX 		= 16;		//‚‚³Å‘åƒAƒCƒRƒ“
	TOOL_ICON_HEIGHT_MIN 		= 17;		//‚‚³Å¬ƒAƒCƒRƒ“
	TOOL_ICON_HEIGHT_NORMAL = 18;		//‚‚³•W€ƒAƒCƒRƒ“
	TOOL_ICON_WIDTH_MAX 		= 19;		//•Å‘åƒAƒCƒRƒ“
	TOOL_ICON_WIDTH_MIN 		= 20;		//•Å¬ƒAƒCƒRƒ“
	TOOL_ICON_WIDTH_NORMAL 	= 21;		//••W€ƒAƒCƒRƒ“

	TOOL_ICON_FAV_FOLDER		= 30;		//‚¨‹C‚É“ü‚èƒtƒHƒ‹ƒ_ƒAƒCƒRƒ“
	TOOL_ICON_FAV_BOARD			= 31;		//‚¨‹C‚É“ü‚è”ÂƒAƒCƒRƒ“
	TOOL_ICON_FAV_THREAD		= 32;		//‚¨‹C‚É“ü‚èƒXƒŒƒAƒCƒRƒ“

	HTML_FILE_NAME 	= 'temp_preview.html';

	WM_XBUTTONDOWN					= $020B;
	WM_XBUTTONUP						= $020C;
	WM_XBUTTONDBLCLK				= $020D;
	XBUTTON1								= $0001;
	XBUTTON2								= $0002;
	USER_TREECLICK					= WM_USER + 2000;
	USER_RESIZED            = WM_USER + 2001;
	USER_MINIMIZED					= WM_USER + 2002;
	USER_SETLINKBAR					= WM_USER + 2003;
	SELECTTIME_INTERBAL				= 110;

	BROWSER_COUNT		= 5;	//ƒuƒ‰ƒEƒU‚Ì”
{$R *.DFM}

procedure TGikoForm.CreateParams(var Params: TCreateParams);
begin
	inherited;
	if FormStyle in [fsNormal, fsStayOnTop] then begin
		if BorderStyle in [bsSingle, bsSizeable] then begin
			Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
			Params.WndParent := 0;
		end;
	end;
end;

procedure TGikoForm.FormCreate(Sender: TObject);
const
	TVS_NOTOOLTIPS = $0080;
var
	FileName: string;
	Style: DWORD;
	msg: string;
	i: Integer;
	wp: TWindowPlacement;
	s: string;
	newbrowser: TWebBrowser;
begin
{$IFDEF DEBUG}
	AllocConsole;
	Writeln('============================================================');
	Writeln(' ƒMƒRƒiƒrƒfƒoƒbƒO ƒRƒ“ƒ\[ƒ‹');
	Writeln('');
	Writeln(' ‚±‚Ì‰æ–Ê‚ð•Â‚¶‚È‚¢‚Å‚­‚¾‚³‚¢B');
	Writeln(' I—¹Žž‚ÍAƒMƒRƒiƒrƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚Ä‚­‚¾‚³‚¢');
	Writeln('============================================================');
{$ENDIF}
	Application.OnDeactivate := AppFormDeactivate;
	Self.OnDeactivate := AppFormDeactivate;
	Application.HookMainWindow(Hook);
	Application.OnMessage := HandleAppMessage; //‚È‚ñ‚©–³‚­‚Ä‚à‘åä•v‚É‚È‚Á‚½@by@‚à‚¶‚ã
	Self.DoubleBuffered := true;
	FTreeType := gttNone;

	FSearchDialog := nil;
	BrowserNullTab := TBrowserRecord.Create;
	BrowserNullTab.Browser := Browser;
	BrowserNullTab.Browser.Navigate(BLANK_HTML);
	FBrowsers := TList.Create;
	for i := 0 to BROWSER_COUNT -1 do begin
		FBrowsers.Add(TWebBrowser.Create(nil));
		newBrowser := FBrowsers[FBrowsers.Count - 1];
		TOleControl(newBrowser).Parent := BrowserPanel;
		newBrowser.Align := alNone;
		newBrowser.Left	:= 0;
		newBrowser.Top	:= 0;
        //newBrowser.DoubleBuffered := true;
		newBrowser.OnDocumentComplete	:= BrowserDocumentComplete;
		newBrowser.OnBeforeNavigate2 	:= BrowserBeforeNavigate2;
		newBrowser.OnEnter				:= BrowserEnter;
		newBrowser.OnNewWindow2			:= BrowserNewWindow2;
		newBrowser.OnStatusTextChange	:= BrowserStatusTextChange;
		//newBrowser.OnTitleChange		:= BrowserTitleChange;
		newBrowser.Navigate(BLANK_HTML);
		ShowWindow(newBrowser.Handle, SW_HIDE);

	end;
	BrowserNullTab.Browser.BringToFront;
	ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);

	// ‹N“®Žž‚É•Û‘¶‚³‚ê‚Ä‚µ‚Ü‚¤‘Îô
	FIsIgnoreResize := True;

	//Žè‚ÌƒJ[ƒ\ƒ‹
	Screen.Cursors[5] := LoadCursor(HInstance, 'GIKOHAND');


	//ƒAƒhƒŒƒX—š—ð“Ç‚Ýž‚Ý
	AddressHistoryDM.ReadHistory(AddressComboBox.Items, GikoSys.Setting.AddressHistoryCount);

	// ŠO•””Âƒvƒ‰ƒOƒCƒ“‚ðƒ[ƒh(ReadBoardFile, LoadHistory ‚æ‚èæ‚És‚¤‚±‚Æ)
	InitializeBoardPlugIns;

	EnabledCloseButton := True;


	//„‰ñƒf[ƒ^“Ç‚Ýž‚Ý
	RoundList := TRoundList.Create;
	RoundList.LoadRoundBoardFile;

	// ƒ{[ƒhƒtƒ@ƒCƒ‹—ñ‹“(ReadFavorite ‚æ‚èæ‚És‚¤‚±‚Æ)
	GikoSys.ListBoardFile;

	RoundList.LoadRoundThreadFile;

	if RoundList.OldFileRead or ( RoundList.Count[grtItem] > 0 ) then
		GikoSys.ListBoardFile;

	// ƒƒjƒ…[‚É’Ç‰Á
	SetBBSMenu;

	// ƒqƒXƒgƒŠƒŠƒXƒg(LoadHistory ‚æ‚è‚àæ‚És‚¤‚±‚Æ)
	FHistoryList := TList.Create;

	// —š—ð“Ç‚Ýž‚Ý
	LoadHistory;

	//‚¨‹C‚É“ü‚è“Ç‚Ýž‚Ý
//	FFavorite := TFavorite.Create(FavoriteTreeView);
	FavoriteDM.SetFavTreeView(FavoriteTreeView);
	FavoriteDM.ReadFavorite;

	//ƒŠƒXƒgƒXƒ^ƒCƒ‹
	ListView.ViewStyle := GikoSys.Setting.ListStyle;

	//ƒƒCƒ“ƒN[ƒ‹ƒo[ˆÊ’u
//	MainCoolBar.Top := 0;
//	MainCoolBar.Left := 0;

	//ƒAƒjƒƒpƒlƒ‹ˆÊ’u
	AnimePanel.Top := 0;
	AnimePanel.Left := 0;

	//ŠeŽí‰ÂŽ‹ó‘Ô‚È‚ÇÝ’è

	//ƒLƒƒƒrƒlƒbƒg
	CabinetPanel.Width := GikoSys.Setting.CabinetWidth;

	//ƒƒbƒZ[ƒWƒo[
	MsgBarVisibleAction.Checked := GikoSys.Setting.MessageBarVisible;
	MsgBarVisibleActionExecute(nil);
	MessagePanel.Height := GikoSys.Setting.MessegeBarHeight;

	//ƒXƒe[ƒ^ƒXƒo[
	StatusBarVisibleAction.Checked := GikoSys.Setting.StatusBarVisible;
	StatusBarVisibleActionExecute(nil);

	//ƒtƒHƒ“ƒgEFÝ’è
	TreeView.Items.BeginUpdate;
	FavoriteTreeView.Items.BeginUpdate;
	ListView.Items.BeginUpdate;
	try
		TreeView.Font.Name := GikoSys.Setting.CabinetFontName;
		TreeView.Font.Size := GikoSys.Setting.CabinetFontSize;
		TreeView.Font.Color := GikoSys.Setting.CabinetFontColor;
		TreeView.Color := GikoSys.Setting.CabinetBackColor;

		FavoriteTreeView.Font.Name := GikoSys.Setting.CabinetFontName;
		FavoriteTreeView.Font.Size := GikoSys.Setting.CabinetFontSize;
		FavoriteTreeView.Font.Color := GikoSys.Setting.CabinetFontColor;
		FavoriteTreeView.Color := GikoSys.Setting.CabinetBackColor;

		ListView.Font.Name := GikoSys.Setting.ListFontName;
		ListView.Font.Size := GikoSys.Setting.ListFontSize;
		ListView.Font.Color := GikoSys.Setting.ListFontColor;
		//ListView.Color := GikoSys.Setting.ListBackColor;
		ListViewBackGroundColor := GikoSys.Setting.ListBackColor;
		FUseOddResOddColor := GikoSys.Setting.UseOddColorOddResNum;
		FOddColor := GikoSys.Setting.OddColor;

	finally
		TreeView.Items.EndUpdate;
		FavoriteTreeView.Items.EndUpdate;
		ListView.Items.EndUpdate;
	end;
	//ViewNoButton.Down := GikoSys.Setting.ListViewNo;
	ListNumberVisibleAction.Checked := GikoSys.Setting.ListViewNo;

	//ƒuƒ‰ƒEƒUƒ^ƒuƒtƒHƒ“ƒg
	BrowserTab.Font.Name := GikoSys.Setting.BrowserTabFontName;
	BrowserTab.Font.Size := GikoSys.Setting.BrowserTabFontSize;
	FDragWFirst := false;
	SetContent(BrowserNullTab);													//ƒuƒ‰ƒEƒU‚ð‹ó”’•\Ž¦
//	TreeView.TopItem.Expanded := True;				//ƒcƒŠ[ƒgƒbƒv€–Ú‚¾‚¯‚ðŠJ‚­
//	TreeView.Selected := TreeView.Items[0];		//ƒcƒŠ[‚Ìƒgƒbƒv€–Ú‚ð‘I‘ð‚·‚é


	//Å‘å‰»EƒEƒBƒ“ƒhƒEˆÊ’u•œŒ³
	wp.length := sizeof(wp);
	wp.rcNormalPosition.Top := GikoSys.Setting.WindowTop;
	wp.rcNormalPosition.Left := GikoSys.Setting.WindowLeft;
	wp.rcNormalPosition.Bottom := GikoSys.Setting.WindowTop + GikoSys.Setting.WindowHeight;
	wp.rcNormalPosition.Right := GikoSys.Setting.WindowLeft + GikoSys.Setting.WindowWidth;
	wp.showCmd := SW_HIDE;
	SetWindowPlacement(Handle, @wp);

//	SetBounds(GikoSys.Setting.WindowLeft, GikoSys.Setting.WindowTop,
//						GikoSys.Setting.WindowWidth, GikoSys.Setting.WindowHeight);
	if GikoSys.Setting.WindowMax then
			WindowState := wsMaximized;

	//ƒMƒRƒAƒjƒ
	try
		FileName := GikoSys.GetAppDir + 'gikoNavi.avi';
		if FileExists(FileName) then
			Animate.FileName := FileName;
	except
	end;

	//ƒNƒbƒL[
	FNameCookie := '';
	FMailCookie := '';

	//ƒXƒŒ‘S•”•\Ž¦ƒ{ƒ^ƒ“‚ð‰Ÿ‚³‚ê‚½ó‘Ô‚É‚·‚é
	AllItemAction.Checked := True;
	AllResAction.Checked := True;

	//TreeView‚ÌŽ×–‚L‚¢ToolTip‚ð”ñ•\Ž¦
	Style := GetWindowLong(TreeView.Handle, GWL_STYLE);
	Style := Style or TVS_NOTOOLTIPS;
	SetWindowLong(TreeView.Handle, GWL_STYLE, Style);

	// ƒcƒŠ[‚ðƒƒCƒ“‚¾‚¯•\Ž¦‚É‚µ‚ÄÅ‘å‰»
	TreeView.Align := alClient;
	FavoriteTreeView.Align := alClient;
	FavoriteTreeView.Visible := False;

	//ƒuƒ‰ƒEƒUƒTƒCƒY•ÏX‚Ì‰Šú‰»
//	FBrowserSizeFlag := False;
//	FBrowserSizeHeight := ViewPanel.Height;

	FBrowserSizeHeight := GikoSys.Setting.ListHeight;
	FBrowserSizeWidth := GikoSys.Setting.ListWidth;

	ArrangeAction.Checked := not (GikoSys.Setting.ListOrientation = gloVertical);
	ArrangeAction.Execute;

	if GikoSys.Setting.ListOrientation = gloHorizontal then begin
		case GikoSys.Setting.ListWidthState of
			glsMax: begin
				ViewPanel.Width := 1;
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_NORMAL;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
			end;
			glsMin: begin
				ViewPanel.Width := GikoSys.Setting.ListWidth;
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_NORMAL;
			end;
			else begin
				ViewPanel.Width := GikoSys.Setting.ListWidth;
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
			end;
		end;
	end else begin
		case GikoSys.Setting.ListHeightState of
			glsMax: begin
				ViewPanel.Height := 1;
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_NORMAL;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
			end;
			glsMin: begin
				ViewPanel.Height := GikoSys.Setting.ListHeight;
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_NORMAL;
			end;
			else begin
				ViewPanel.Height := GikoSys.Setting.ListHeight;
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
			end;
		end;
	end;

	//ƒvƒƒOƒŒƒXƒo[‚Ì‰Šú‰»
//	ProgressBar.Visible := False;
	ProgressBar.Parent := StatusBar;
	ProgressBar.Top := 2;
	ProgressBar.Left := 0;
	ProgressBar.Width := StatusBar.Panels[0].Width;
	ProgressBar.Height := StatusBar.Height - 2;
	ProgressBar.Position := 0;

	//ƒ_ƒEƒ“ƒ[ƒhƒIƒuƒWƒFƒNƒg
	FControlThread := TThreadControl.Create(True);
	FControlThread.MaxThreadCount := 1;
	FControlThread.Resume;
	FControlThread.OnDownloadEnd := DownloadEnd;
	FControlThread.OnDownloadMsg := DownloadMsg;
	FControlThread.OnWork := Work;
	FControlThread.OnWorkBegin := WorkBegin;
	FControlThread.OnWorkEnd := WorkEnd;
//	ProgressPanel.Width := FControlThread.MaxThreadCount * 12;

	// ižŒŸõ—š—ð
	SelectComboBox.Items.Assign( GikoSys.Setting.SelectTextList );

	//ƒuƒ‰ƒEƒUƒ^ƒuÝ’è
	SetBrowserTabState;

	BrowserBoardNameLabel.Caption := '';
	BrowserNameLabel.Caption := '';
	FWorkCount := 0;

	FTabHintIndex := -1;

	//ƒŠƒ“ƒNƒo[
	SetLinkBar;

	//ƒƒjƒ…[ƒtƒHƒ“ƒg
	SetMenuFont;

	//ƒc[ƒ‹ƒo[Wrapable
	ListToolBar.Wrapable := GikoSys.Setting.ListToolBarWrapable;
	BrowserToolBar.Wrapable := GikoSys.Setting.BrowserToolBarWrapable;

	KeepDefaultToolButton(StdToolBar, TmpToolBar);
	KeepDefaultToolButton(ListToolBar, TmpToolBar);
	KeepDefaultToolButton(BrowserToolBar, TmpToolBar);

	MakeDefaultINIFile();
	//ƒc[ƒ‹ƒ{ƒ^ƒ““Ç‚Ýž‚Ý
	ReadToolBarSetting(ActionList, StdToolBar);
	ReadToolBarSetting(ActionList, ListToolBar);
	try
		for i := ListToolBar.ControlCount - 1 downto 0 do
		begin
			if ListToolBar.Controls[ i ].Action = SelectItemAction then
			begin
				// ƒXƒŒƒbƒhiž‚Ì—×‚ÉƒZƒpƒŒ[ƒ^‚ª‚ ‚éê‡‚Í‰B‚·
				if (i + 1) < ListToolBar.ControlCount then
					if ListToolBar.Controls[ i + 1 ] is TToolButton then
						if TToolButton( ListToolBar.Controls[ i + 1 ] ).Style = tbsSeparator then
							ListToolBar.Controls[ i + 1 ].Visible := False;

				// ƒXƒŒƒbƒhižƒ{ƒ^ƒ“‚ð‰B‚·
				ListToolBar.Controls[ i ].Visible := False;
				// ƒXƒŒƒbƒhižƒtƒB[ƒ‹ƒh‚ð‘}“ü
				SelectComboBox.Parent := ListToolBar;
				SelectComboBox.Left := ListToolBar.Controls[ i ].Left;
				SelectComboBox.Width := GikoSys.Setting.SelectComboBoxWidth;
				// ƒXƒŒƒbƒhiž—p“ÆŽ©ƒZƒpƒŒ[ƒ^‚ð‘}“ü
				SelectComboBoxSplitter.Parent := ListToolBar;
				SelectComboBoxSplitter.Left := SelectComboBox.Left + SelectComboBox.Width;

				break;
			end;
		end;
	except
	end;
	ReadToolBarSetting(ActionList, BrowserToolBar);
	SetToolBarPopup;
	OnlyAHundredRes.Checked := GikoSys.Setting.OnlyAHundredRes;
	//ƒAƒhƒŒƒXƒo[
	AddressComboBox.TabStop := GikoSys.Setting.AddressBarTabStop;

	//ƒN[ƒ‹ƒo[•œŒ³‚ÍFormShow‚ÉˆÚ“®‚µ‚½

	//ƒ{[ƒhƒtƒ@ƒCƒ‹‚ª–³‚¢ê‡‚ÍƒƒbƒZ[ƒW•\Ž¦
	if not FileExists(GikoSys.GetBoardFileName) then begin
		msg := '‚±‚ÌƒƒbƒZ[ƒW‚ÍƒMƒRƒiƒr‚ð‰‚ß‚ÄŽg—p‚·‚é‚Æ‚«‚É‚P‰ñ‚¾‚¯•\Ž¦‚³‚ê‚Ü‚·' + #13#10#13#10
				 + '‚±‚ê‚©‚çAu‚Q‚¿‚á‚ñ‚Ë‚év‚ÌƒAƒhƒŒƒXˆê——‚ðƒ_ƒEƒ“ƒ[ƒh‚µ‚Ü‚·' + #13#10
				 + 'ŽŸ‚Éo‚Ä‚­‚é‰æ–Ê‚ÅAuXVvƒ{ƒ^ƒ“‚ð‰Ÿ‚µ‚Ä‚­‚¾‚³‚¢B';
		MsgBox(SplashWindow.Handle, msg, 'ƒMƒRƒiƒr', MB_OK or MB_ICONINFORMATION);
		NewBoardAction.Execute;
	end;

	//ƒL[Ý’è“Ç‚Ýž‚Ý
	GikoSys.LoadKeySetting(ActionList);

	//ÅI„‰ñŽžŠÔ
//	FLastRoundTime := 0;

	//ResHint
	FHint := TResPopup.Create(Self);

	// ÅŒã‚É‘I‘ð‚³‚ê‚½ƒLƒƒƒrƒlƒbƒg‚Ì•œŒ³
	CabinetVisible( False );
	if GikoSys.Setting.CabinetVisible then begin
		i := CabinetSelectPopupMenu.Items.Count - 1;
		if GikoSys.Setting.CabinetIndex = i - 1 then
			CabinetHistoryAction.Execute
		else if GikoSys.Setting.CabinetIndex = i then
			CabinetFavoriteAction.Execute
		else begin
			if GikoSys.Setting.CabinetIndex < Length( BBSs ) then
				ShowBBSTree( BBSs[ GikoSys.Setting.CabinetIndex ] );
			// ‹N“®Žž‚É•Û‘¶‚³‚ê‚Ä‚µ‚Ü‚¤‘Îô 2
			FIsIgnoreResize := True;
			CabinetBBSAction.Execute;
		end;
	end else begin
		ShowBBSTreeOld( BBSs[ 0 ] );
		PostMessage( Handle, USER_TREECLICK, 0, 0 );
	end;

	// ‹N“®Žž‚É•Û‘¶‚³‚ê‚Ä‚µ‚Ü‚¤‘Îô 3
	FIsIgnoreResize := True;

	//ƒI[ƒgƒƒOƒCƒ“
	if GikoSys.Setting.AutoLogin then
		LoginAction.Execute;

	//ˆø”‚ª‚ ‚Á‚½‚çƒXƒŒ‚ðŠJ‚­i–¢Žæ“¾‚È‚çƒ_ƒEƒ“ƒ[ƒhj
	for i := 1 to ParamCount do	begin
		MoveToURL(ParamStr(i));
	end;
//	SetStdToolBar;
//	SetLinkBar;

	s := GikoSys.FAbon.NGwordname;
	StatusBar.Panels[2].Text := s;
	StatusBar.Panels[2].Width := Max(StatusBar.Canvas.TextWidth(s), 100);
	StatusBarResize(Sender);

	dummy1.Caption	:= ItemReservPMenu.Caption;
	dummy1.Hint     := ItemReservPMenu.Hint;

	//Samba24‚Ìƒtƒ@ƒCƒ‹ƒ`ƒFƒbƒN
	GikoSys.SambaFileExists();

end;

// CoolBar ‚ÌÝ’è‚ð•Ï”‚É•Û‘¶
procedure TGikoForm.SaveCoolBarSettings;
var
	i				: Integer;
	CoolSet	: TCoolSet;
begin

	if IsIconic( Handle ) or FIsIgnoreResize then
		Exit;

	//ƒN[ƒ‹ƒo[•Û‘¶(Main)
	for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
		CoolSet.FCoolID := MainCoolBar.Bands[i].ID;
		CoolSet.FCoolWidth := MainCoolBar.Bands[i].Width;
		CoolSet.FCoolBreak := MainCoolBar.Bands[i].Break;
		GikoSys.Setting.MainCoolSet[i] := CoolSet;
	end;
	//ƒN[ƒ‹ƒo[•Û‘¶(Board)
	for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
		CoolSet.FCoolID := ListCoolBar.Bands[i].ID;
		CoolSet.FCoolWidth := ListCoolBar.Bands[i].Width;
		CoolSet.FCoolBreak := ListCoolBar.Bands[i].Break;
		GikoSys.Setting.ListCoolSet[i] := CoolSet;
	end;
	//ƒN[ƒ‹ƒo[•Û‘¶(Browser)
	for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
		CoolSet.FCoolID := BrowserCoolBar.Bands[i].ID;
		CoolSet.FCoolWidth := BrowserCoolBar.Bands[i].Width;
		CoolSet.FCoolBreak := BrowserCoolBar.Bands[i].Break;
		GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
	end;

end;

// CoolBar ‚ÌÝ’è‚ð•Ï”‚©‚ç•œŒ³
procedure TGikoForm.LoadCoolBarSettings;
var
	i				: Integer;
	CoolSet	: TCoolSet;
begin

	//ƒN[ƒ‹ƒo[•œŒ³(Main)
	MainCoolBar.Bands.BeginUpdate;
	try
//		for i := 0 to MainCoolBar.Bands.Count - 1 do begin
		for i := MAIN_COOLBAND_COUNT - 1 downto 0 do begin
			CoolSet := GikoSys.Setting.MainCoolSet[i];
			if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
				FIsIgnoreResize := False;
				SaveCoolBarSettings;
				Exit;
			end;
			MainCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
			MainCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
			MainCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
		end;
	finally
		MainCoolBar.Bands.EndUpdate;
	end;

	//ƒN[ƒ‹ƒo[•œŒ³(Board)
	ListCoolBar.Bands.BeginUpdate;
	try
//		for i := 0 to ListCoolBar.Bands.Count - 1 do begin
		for i := LIST_COOLBAND_COUNT - 1 downto 0 do begin
			CoolSet := GikoSys.Setting.ListCoolSet[i];
			if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
				FIsIgnoreResize := False;
				SaveCoolBarSettings;
				Exit;
			end;
			ListCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
			ListCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
			ListCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
		end;
	finally
		ListCoolBar.Bands.EndUpdate;
	end;

	//ƒN[ƒ‹ƒo[•œŒ³(Browser)
	BrowserCoolBar.Bands.BeginUpdate;
	try
//		for i := 0 to BrowserCoolBar.Bands.Count - 1 do begin
 		for i := BROWSER_COOLBAND_COUNT - 1 downto 0 do begin
			CoolSet := GikoSys.Setting.BrowserCoolSet[i];
			if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
				FIsIgnoreResize := False;
				SaveCoolBarSettings;
				Exit;
			end;
			BrowserCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
			BrowserCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
			BrowserCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
		end;
	finally
		BrowserCoolBar.Bands.EndUpdate;
	end;

end;

//
//
//
procedure TGikoForm.FormShow(Sender: TObject);
begin
	ShowWindow(Application.Handle, SW_HIDE);

	//FormCreate‚Å‚â‚é‚Æ‰ÂŽ‹Ý’è‚ª”½‰f‚³‚ê‚È‚¢ê‡‚ª‚ ‚é‚Ì‚ÅFormShow‚Å‚â‚é‚±‚Æ‚É‚µ‚½
	//ƒc[ƒ‹ƒo[•\Ž¦
	StdToolBarVisibleAction.Checked := GikoSys.Setting.StdToolBarVisible;
	StdToolBarVisibleActionExecute( nil );
	AddressBarVisibleAction.Checked := GikoSys.Setting.AddressBarVisible;
	AddressBarVisibleActionExecute( nil );
	LinkBarVisibleAction.Checked := GikoSys.Setting.LinkBarVisible;
	LinkBarVisibleActionExecute( nil );
	ListToolBarVisibleAction.Checked := GikoSys.Setting.ListToolBarVisible;
	ListToolBarVisibleActionExecute( nil );
	ListNameBarVisibleAction.Checked := GikoSys.Setting.ListNameBarVisible;
	ListNameBarVisibleActionExecute( nil );
	BrowserToolBarVisibleAction.Checked := GikoSys.Setting.BrowserToolBarVisible;
	BrowserToolBarVisibleActionExecute( nil );
	BrowserNameBarVisibleAction.Checked := GikoSys.Setting.BrowserNameBarVisible;
	BrowserNameBarVisibleActionExecute( nil );

	//ƒuƒ‰ƒEƒUƒ^ƒu
	BrowserTabVisibleAction.Checked := GikoSys.Setting.BrowserTabVisible;
	BrowserTabVisibleActionExecute(nil);

	if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
		BrowserTabTopAction.Checked := True;
		BrowserTabTopActionExecute(nil);
	end else begin
		BrowserTabBottomAction.Checked := True;
		BrowserTabBottomActionExecute(nil);
	end;

	if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
		BrowserTabTabStyleAction.Checked := True;
		BrowserTabTabStyleActionExecute(nil);
	end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
		BrowserTabButtonStyleAction.Checked := True;
		BrowserTabButtonStyleActionExecute(nil);
	end else begin
		BrowserTabFlatStyleAction.Checked := True;
		BrowserTabFlatStyleActionExecute(nil);
	end;

	// CoolBar •œŒ³
	LoadCoolBarSettings;

	FIsIgnoreResize := False;
end;

procedure TGikoForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
//	if GikoForm.WindowState <> wsMinimized then
//		SaveCoolBarSettings;
	if ( GikoSys.Setting.ShowDialogForEnd ) and
			(MessageDlg('ƒMƒRƒiƒr‚ðI—¹‚µ‚Ä‚æ‚ë‚µ‚¢‚Å‚·‚©H', mtConfirmation,[mbOk, mbCancel], 0) = mrCancel ) then begin
		CanClose := false;
			Exit;
	end else begin
		CanClose := True;
	end;
	//Application.HookMainWindow(Hook);
	Application.UnhookMainWindow(Hook);
	Application.Terminate;
end;

procedure TGikoForm.FormDestroy(Sender: TObject);
var
	i: Integer;
//	CoolSet: TCoolSet;
	wp: TWindowPlacement;
	tmpBool: Boolean;
begin
//	Application.OnDeactivate := nil;
//	Self.OnDeactivate := nil;
	try
		//column•
		if GetActiveList is TBBS then begin
			for i := 0 to ListView.Columns.Count - 1 do
				GikoSys.Setting.BBSColumnWidth[i] := ListView.Column[i].Width;
		end else if GetActiveList is TCategory then begin
			for i := 0 to ListView.Columns.Count - 1 do
				GikoSys.Setting.CategoryColumnWidth[i] := ListView.Column[i].Width;
		end else if GetActiveList is TBoard then begin
			for i := 0 to ListView.Columns.Count - 1 do
				GikoSys.Setting.BoardColumnWidth[i] := ListView.Column[i].Width;
		end;
	except
	end;
	try
		//Å‘å‰»EƒEƒBƒ“ƒhƒEˆÊ’u•Û‘¶
		wp.length := sizeof(wp);
		GetWindowPlacement(Handle, @wp);
		GikoSys.Setting.WindowTop := wp.rcNormalPosition.Top;
		GikoSys.Setting.WindowLeft := wp.rcNormalPosition.Left;
		GikoSys.Setting.WindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
		GikoSys.Setting.WindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
		GikoSys.Setting.WindowMax := WindowState = wsMaximized;

		GikoSys.Setting.ListStyle := ListView.ViewStyle;
		GikoSys.Setting.CabinetVisible := CabinetVisibleAction.Checked;
		GikoSys.Setting.CabinetWidth := CabinetPanel.Width;
		GikoSys.Setting.ListHeight := FBrowserSizeHeight;
		GikoSys.Setting.ListWidth := FBrowserSizeWidth;
		if ArrangeAction.Checked then
			GikoSys.Setting.ListOrientation := gloVertical
		else
			GikoSys.Setting.ListOrientation := gloHorizontal;
		GikoSys.Setting.MessegeBarHeight := MessagePanel.Height;
	except
	end;
  // ƒŠƒAƒ‹ƒ^ƒCƒ€‚É•Û‘¶‚³‚ê‚é‚Ì‚ÅA‚Ü‚½AƒEƒBƒ“ƒhƒEƒTƒCƒY‚ª CoolBar ‚æ‚è
	// ¬‚³‚­‚È‚Á‚Ä‚¢‚é‚Æ‚«‚É•Û‘¶‚·‚é‚Æ’l‚ªã‘‚«‚³‚ê‚Ä‚µ‚Ü‚¤‚Ì‚Å‚±‚±‚Å‚Í•Û‘¶‚µ‚È‚¢
	{
		// ªFormDestroy’†‚ÉˆÚ“®‚µ‚½‚Ì‚ÅA‚±‚±‚Å•Û‘¶‚µ‚È‚¢‚Æ‚¢‚¯‚È‚¢‚ÆŽv‚¤Bi‚à‚¶‚ã@2004/04/09j
	// CoolBar •Û‘¶
	if GikoForm.WindowState <> wsMinimized then
		SaveCoolBarSettings;
	}
	try
		GikoSys.Setting.WriteWindowSettingFile;
		GikoSys.Setting.WriteNameMailSettingFile;
	except
	end;

	//‚¨‹C‚É“ü‚è•Û‘¶
	try
		//FavoriteDM‚ÍŽ©“®¶¬ƒtƒH[ƒ€‚È‚Ì‚ÅA‰ð•ú‚ÍŽ©“®“I‚É‚³‚ê‚é
		FavoriteDM.WriteFavorite;
		FavoriteDM.Clear;
	except
	end;

	try
		//ƒ^ƒuƒNƒ[ƒY
		tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
		GikoSys.Setting.ShowDialogForAllTabClose := false;
		AllTabCloseAction.Execute;
        GikoSys.Setting.ShowDialogForAllTabClose := tmpBool;
	except
	end;
	try
		LockWindowUpdate(Self.Handle);
		for i := FBrowsers.Count - 1 downto 0 do begin
			TWebBrowser(FBrowsers[i]).Free;
		end;
		FBrowsers.Clear;
		FBrowsers.Capacity := 0;
	finally
		FBrowsers.Free;
	end;
	try
		if BrowserNullTab <> nil then begin
			BrowserNullTab.Browser := nil;  {*BrowserNullTab‚ÌBrowser‚ÍÝŒvŽž‚É“\‚è•t‚¯‚Ä‚é“z
											 *‚È‚Ì‚Å‚±‚±‚ÅFree‚³‚ê‚é‚Æ¢‚é‚Ì‚Å‚Í‚¸‚µ‚Ä‚µ‚Ü‚¤B
											 *}
			BrowserNullTab.Free;
		end;
	except
	end;
	LockWindowUpdate(0);
	try
		TreeView.Items.BeginUpdate;
		for i := TreeView.Items.Count - 1 downto 0 do begin
			TreeView.Items[i].Free;
		end;
		TreeView.Items.Clear;
		TreeView.Items.EndUpdate;
	except
	end;

	//ƒAƒhƒŒƒX—š—ð•Û‘¶
	try
		//AddressHistoryDM‚ÍŽ©“®¶¬ƒtƒH[ƒ€‚È‚Ì‚ÅA‰ð•ú‚ÍŽ©“®“I‚É‚³‚ê‚éB
		AddressHistoryDM.WriteHistory(AddressComboBox.Items, GikoSys.Setting.AddressHistoryCount);
	except
	end;

	//ƒqƒXƒgƒŠƒŠƒXƒg•Û‘¶
	try
		SaveHistory;
	except
	end;
	try
		try
			ClearHistory;
		except
		end;
	finally
		FHistoryList.Free;
	end;

	//„‰ñƒŠƒXƒg•Û‘¶&”jŠü
	try
		RoundList.SaveRoundFile;
	except
	end;
	try
		try
			RoundList.Clear;
		except
		end;
	finally
		RoundList.Free;
	 end;

	try
		try
			FControlThread.Terminate;
			FControlThread.WaitFor;
		except
		end;
	finally
		FControlThread.Free;
	end;

	// TBBS ‚Í•ÛŽ‚µ‚Ä‚¢‚é TCategory, TBoard, TThreadItem ‚·‚×‚Ä‚ðŠJ•ú‚·‚é
	// TBoard, TThreadItem ‚ÌƒfƒXƒgƒ‰ƒNƒ^‚Íƒvƒ‰ƒOƒCƒ“‚É”jŠü‚ð“`‚¦‚é‚Ì‚Å
	// BoardPluteIns ‚ÌŠJ•ú‚æ‚èæ‚És‚¤‚±‚Æ
	try
		for i := Length( BBSs ) - 1 downto 0 do begin
			if BBSs[ i ] <> nil then
				BBSs[ i ].Free;
			BBSs[ i ] := nil;
		end;
	except
	end;

	try
		for i := Length( BoardPlugIns ) - 1 downto  0 do begin
			if BoardPlugIns[ i ] <> nil then
				BoardPlugIns[ i ].Free;
			BoardPlugIns[ i ] := nil;
		end;
	except
	end;

	try
		if FEvent <> nil then
			FEvent.Free;

		//Hint”jŠü
		if FHint <> nil then begin
			FHint.ReleaseHandle;
			FHint.Free;
			FHint := nil;
		end;
		//Preview”jŠü
		if TPreviewBrowser <> nil then begin
			FPreviewBrowser.Free;
			FPreviewBrowser := nil;
		end;
	except
	end;

end;

//ƒtƒH[ƒ€ƒNƒ[ƒY
procedure TGikoForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
end;
//ƒLƒƒƒrƒlƒbƒg~ƒ{ƒ^ƒ“ƒNƒŠƒbƒN
procedure TGikoForm.CabinetPanelHide(Sender: TObject);
begin
	CabinetVisibleAction.Execute;
//	CabinetPanelVisible(false);
end;

// ŠeŠ‚É‚ ‚éƒLƒƒƒrƒlƒbƒgE BBS ƒƒjƒ…[‚ðƒZƒbƒg^XV
procedure TGikoForm.SetBBSMenu;
var
	i			: Integer;
	item	: TBBSMenuItem;
begin

	// ƒƒjƒ…[‚ðíœ
	for i := CabinetSelectPopupMenu.Items.Count - 1 downto 0 do begin
		try
			if CabinetSelectPopupMenu.Items[ i ] is TBBSMenuItem then begin
				CabinetSelectPopupMenu.Items[ i ].Free;
				CabinetMenu.Items[ i ].Free;
				BBSSelectPopupMenu.Items[ i ].Free;
			end;
		except
		end;
	end;

	// ƒƒjƒ…[‚ðÝ’è
	for i := Length( BBSs ) - 1 downto 0 do begin
		try
			item					:= TBBSMenuItem.Create( PopupMenu );
			item.Caption	:= BBSs[ i ].Title;
			item.Data			:= BBSs[ i ];
			item.OnClick	:= BBSMenuItemOnClick;
			CabinetSelectPopupMenu.Items.Insert( 0, item );
			item					:= TBBSMenuItem.Create( PopupMenu );
			item.Caption	:= BBSs[ i ].Title;
			item.Data			:= BBSs[ i ];
			item.OnClick	:= BBSMenuItemOnClick;
			CabinetMenu.Insert( 0, item );
			item					:= TBBSMenuItem.Create( PopupMenu );
			item.Caption	:= BBSs[ i ].Title;
			item.Data			:= BBSs[ i ];
			item.OnClick	:= BBSMenuItemOnClick;
			BBSSelectPopupMenu.Items.Insert( 0, Item );
		except
		end;
	end;

end;

procedure TGikoForm.ReloadBBS;
var
	i			: Integer;
	tmpBool: Boolean;
begin
	//ƒ^ƒuƒNƒ[ƒY
	tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
	GikoSys.Setting.ShowDialogForAllTabClose := false;
	AllTabCloseAction.Execute;
	GikoSys.Setting.ShowDialogForAllTabClose := tmpBool;

	SetContent(BrowserNullTab);
	//TreeViewƒNƒŠƒAiBBS2ch.Free‚ÌŒã‚ÉƒNƒŠƒA‚·‚é‚ÆXPƒXƒ^ƒCƒ‹Žž‚ÉƒGƒ‰[o‚éj
	TreeView.Items.Clear;

	//BBS”jŠü
	try
		for i := Length( BBSs ) - 1 downto 0 do begin
			if BBSs[ i ] <> nil then
				BBSs[ i ].Free;
			BBSs[ i ] := nil;
		end;
	except
	end;

	ActiveList := nil;

	FTreeType := gttNone;

	GikoSys.ListBoardFile;		//ƒ{[ƒhƒtƒ@ƒCƒ‹“Çž

	// BBS ƒƒjƒ…[‚ÌXV
	SetBBSMenu;

	ShowBBSTree( BBSs[ 0 ] );

	// —š—ð“Ç‚Ýž‚Ý
	SaveHistory;
	ClearHistory;
	LoadHistory;

	//‚¨‹C‚É“ü‚è“Ç‚Ýž‚Ý
	FavoriteDM.WriteFavorite;
	FavoriteDM.Clear;
	FavoriteDM.ReadFavorite;

	SetLinkBar;

end;

//ƒ{[ƒhƒcƒŠ[Ý’è
procedure TGikoForm.SetBoardTreeNode(
	inBBS : TBBS
);
var
	i, j, k: integer;
	Root: TTreeNode;
	CategoryNode: TTreeNode;
	BoardNode: TTreeNode;
	Category: TCategory;
	Board: TBoard;
begin
	// ”ÂƒŠƒXƒg‚ÌÝ’è
	FActiveBBS := inBBS;
	TreeView.Items.BeginUpdate;
	TreeView.Items.Clear;
	try
  	if not inBBS.IsBoardFileRead then
    	GikoSys.ReadBoardFile( inBBS );
		try
			if SplashWindow <> nil then
				SplashWindow.ProgressBar.Max := inBBS.Count;
		except
		end;

		Root								:= TreeView.Items.Add( nil, inBBS.Title );
		Root.ImageIndex			:= ITEM_ICON_2CH1;
		Root.SelectedIndex	:= ITEM_ICON_2CH2;
		Root.Data						:= inBBS;
		for i := 0 to inBBS.Count - 1 do begin
			Category := TCategory(inBBS.Items[i]);
			CategoryNode := TreeView.Items.AddChild(Root, Category.Title);
			CategoryNode.Data := Category;
			CategoryNode.ImageIndex := ITEM_ICON_CATEGORY1;
			CategoryNode.SelectedIndex := ITEM_ICON_CATEGORY2;

			for j := 0 to Category.Count - 1 do begin
				Board := TBoard(Category.Items[j]);
				Board.BeginUpdate;
				BoardNode := TreeView.Items.AddChild(CategoryNode, Board.Title);
				BoardNode.Data := Board;
				//if (Board.LastGetTime = 0) or (Board.LastGetTime = ZERO_DATE) then begin
				if not Board.IsLogFile then begin
					BoardNode.ImageIndex := ITEM_ICON_BOARD_NOSUBJECT;
					BoardNode.SelectedIndex := ITEM_ICON_BOARD_NOSUBJECT;
				end else begin
					BoardNode.ImageIndex := ITEM_ICON_BOARD1;
					BoardNode.SelectedIndex := ITEM_ICON_BOARD2;
					for k := 0 to Board.Count - 1 do begin
						if Board.Items[ k ].IsLogFile then begin
							BoardNode.ImageIndex := ITEM_ICON_BOARD_LOG;
							BoardNode.SelectedIndex := ITEM_ICON_BOARD_LOG;

							Break;
						end;
					end;
				end;
				Board.EndUpdate;
			end;

			CategoryNode.Expanded := Category.NodeExpand;

			if SplashWindow <> nil then begin
				SplashWindow.ProgressBar.StepIt;
				Application.ProcessMessages;
			end;
		end;
	finally
		TreeView.Items.EndUpdate;
	end;
end;

function TGikoForm.SetCategoryListItem(ABBS2ch: TBBS): Integer;
const
	COLUMN: array[0..0] of string = ('ƒJƒeƒSƒŠ–¼');
var
	ListColumn: TListColumn;
	i: Integer;
begin
	ListView.Items.BeginUpdate;
	try
		Screen.Cursor := crHourGlass;

		ListView.Columns.Clear;
		for i := 0 to Length(COLUMN) - 1 do begin
			ListColumn := ListView.Columns.Add;
			ListColumn.Caption := COLUMN[i];
			ListColumn.Width := GikoSys.Setting.BBSColumnWidth[i];
		end;

		ListView.Items.Count := 0;
		ListView.Items.Clear;
		ListView.Items.Count := ABBS2ch.Count;

//		UpFolderAction.Enabled := False;
//		AllItemAction.Enabled := False;
//		LogItemAction.Enabled := False;
//		NewItemAction.Enabled := False;
//		SelectItemAction.Enabled := False;
//		ListDownloadToolButton.Enabled := False;
//		BoardReservToolButton.Enabled := False;
//		ListThreadDownloadToolButton.Enabled := False;

		ListNameLabel.Caption := ABBS2ch.Title;
		FolderImage.Picture := nil;
		ItemIcon16.GetBitmap(1, FolderImage.Picture.Bitmap);

		FSortIndex := 0;
		FSortOrder := False;
		ListViewColumnClick(nil, ListView.Column[0]);

		Result := ABBS2ch.Count;
	finally
		Screen.Cursor := crDefault;
		ListView.Items.EndUpdate;
	end;
end;

function TGikoForm.SetBoardListItem(Category: TCategory): Integer;
const
	COLUMN: array[0..2] of string = ('”Â–¼', '„‰ñ—\–ñ', 'Žæ“¾“úŽž');
var
	ListColumn: TListColumn;
	i: Integer;
begin
	ListView.Items.BeginUpdate;
	try
		Screen.Cursor := crHourGlass;

		ListView.Columns.Clear;
		for i := 0 to Length(COLUMN) - 1 do begin
			ListColumn := ListView.Columns.Add;
			ListColumn.Caption := COLUMN[i];
			ListColumn.Width := GikoSys.Setting.CategoryColumnWidth[i];
		end;

		ListView.Items.Count := 0;
		ListView.Items.Clear;
		ListView.Items.Count := Category.Count;

//		UpFolderAction.Enabled := True;
//		AllItemAction.Enabled := False;
//		LogItemAction.Enabled := False;
//		NewItemAction.Enabled := False;
//		SelectItemAction.Enabled := False;
//		ListDownloadToolButton.Enabled := False;
//		BoardReservToolButton.Enabled := False;
//		ListThreadDownloadToolButton.Enabled := False;

		ListNameLabel.Caption := Category.Title;
		FolderImage.Picture := nil;
		ItemIcon16.GetBitmap(3, FolderImage.Picture.Bitmap);

		FSortIndex := 0;
		FSortOrder := False;
		ListViewColumnClick(nil, ListView.Column[0]);

		Result := Category.Count;
	finally
		Screen.Cursor := crDefault;
		ListView.Items.EndUpdate;
	end;
end;

function TGikoForm.SetThreadListItem(Board: TBoard): Integer;
const
	COLUMN: array[0..7] of string = ('ƒXƒŒƒbƒh–¼', 'ƒJƒEƒ“ƒg', 'Žæ“¾', 'V’…',
																	 '–¢“Ç', '„‰ñ—\–ñ', 'Žæ“¾“úŽž', 'ƒXƒŒì¬“úŽž');
	COLUMN_ALIGNMENT: array[0..7] of TAlignment = (taLeftJustify, taRightJustify,
																								 taRightJustify, taRightJustify,
																								 taRightJustify, taLeftJustify,
																								 taLeftJustify, taLeftJustify);
	//No, ƒXƒŒƒbƒh–¼, ƒJƒEƒ“ƒg, „‰ñ—\–ñ, Žæ“¾“úŽž
var
	ListColumn: TListColumn;
	i: Integer;
begin
	ListView.Items.BeginUpdate;
	try
		Screen.Cursor := crHourGlass;

		// ƒ`ƒ‰‚Â‚«–hŽ~‚Ì‚½‚ßA•ÏX‚³‚ê‚Ä‚¢‚éê‡‚Ì‚Ý
		// ¦–¼Ì‚Íˆá‚¤‚ªƒJƒ‰ƒ€”‚ª“¯‚¶A‚Æ‚¢‚Á‚½ê‡‚É‘Îˆ‚Å‚«‚È‚¢‚Ì‚Å’ˆÓ
		if ListView.Columns.Count <> (High( COLUMN ) - Low( COLUMN ) + 1) then
		begin
			ListView.Columns.Clear;
			for i := 0 to Length(COLUMN) - 1 do begin
				ListColumn := ListView.Columns.Add;
				ListColumn.Caption := COLUMN[i];
				ListColumn.Width := GikoSys.Setting.BoardColumnWidth[i];
				ListColumn.Alignment := COLUMN_ALIGNMENT[i];
			end;
		end;

		ListView.Items.Count := 0;
		ListView.Items.Clear;

		case GikoForm.ViewType of
			gvtAll: ListView.Items.Count := Board.Count;
			gvtLog: ListView.Items.Count := Board.GetLogThreadCount;
			gvtNew: ListView.Items.Count := Board.GetNewThreadCount;
			gvtUser: ListView.Items.Count := Board.GetUserThreadCount;
		end;

		ListNameLabel.Caption := Board.Title;
		FolderImage.Picture := nil;
		ItemIcon16.GetBitmap(5, FolderImage.Picture.Bitmap);

		FSortIndex := 0;
		FSortOrder := False;
		ListViewColumnClick(nil, ListView.Column[0]);

		Result := Board.Count;
	finally
		Screen.Cursor := crDefault;
		ListView.Items.EndUpdate;
	end;
end;

procedure TGikoForm.ListViewData(Sender: TObject; Item: TListItem);
var
//	FileName: string;
//	DateTime: TDateTime;
	BoardCnt: Integer;
	BBS: TBBS;
	Category: TCategory;
	Board: TBoard;
	ThreadItem: TThreadItem;
	RepStr: string;
		ActivListObj : TObject;
begin
	ActivListObj := ActiveList;
	if ActivListObj is TBBS then begin
		BBS := TBBS(ActivListObj);

		ListView.StateImages := nil;

		if BBS = nil then Exit;
		if BBS.Count <= 0 then Exit;
		if Item = nil then Exit;
		if Item.Index >= BBS.Count then Exit;
		if ListView.Items.Count = 0 then Exit;

		if not (BBS.Items[Item.index] is TCategory) then Exit;
		Category := TCategory(BBS.Items[Item.index]);

		if Category = nil then Exit;

		if ListNumberVisibleAction.Checked then
			Item.Caption := IntToStr(Category.No) + ': ' + Category.Title
		else
			Item.Caption := Category.Title;

		Item.ImageIndex := ITEM_ICON_CATEGORY1;
		Item.Data := Category;
	end else if ActivListObj is TCategory then begin
		Category := TCategory(ActivListObj);

		ListView.StateImages := nil;

		if Category = nil then Exit;
		if Category.Count <= 0 then Exit;
		if Item = nil then Exit;
		if Item.Index >= Category.Count then Exit;
		if ListView.Items.Count = 0 then Exit;

		if not (Category.Items[Item.Index] is TBoard) then Exit;
		Board := TBoard(Category.Items[Item.Index]);

		if Board = nil then Exit;

		if ListNumberVisibleAction.Checked then
			Item.Caption := IntToStr(Board.No) + ': ' + Board.Title
		else
			Item.Caption := Board.Title;

		if Item.SubItems.Count <> 2 then begin
			Item.SubItems.Clear;
			Item.SubItems.Add('');
			Item.SubItems.Add('');
		end;

		Item.ImageIndex := ITEM_ICON_BOARD1;

		if Board.Round then
			Item.SubItems[0] := Board.RoundName	// '—\–ñ'
		else
			Item.SubItems[0] := '';

		if Board.RoundDate = ZERO_DATE then begin
			Item.SubItems[1] := '';
		end else
			Item.SubItems[1] := FormatDateTime('yyyy/mm/dd hh:mm:ss', Board.RoundDate);
		Item.Data := Board;
	end else if ActivListObj is TBoard then begin
		Board := TBoard(ActivListObj);

		if GikoSys.Setting.ListIconVisible then
			ListView.StateImages := StateIconImageList
		else
			ListView.StateImages := nil;

		case GikoForm.ViewType of
			gvtAll: BoardCnt := Board.Count;
			gvtLog: BoardCnt := Board.GetLogThreadCount;
			gvtNew: BoardCnt := Board.GetNewThreadCount;
			gvtUser: BoardCnt := Board.GetUserThreadCount;
			else
				BoardCnt := 0;
		end;

//		if Board = nil then Exit;
		if BoardCnt <= 0 then Exit;
		if Item = nil then Exit;
		if Item.Index > BoardCnt then Exit;
		if ListView.Items.Count = 0 then Exit;

//		if not (Board.Items[Item.Index] is TThreadItem) then Exit;

		ThreadItem := nil;
		case GikoForm.ViewType of
			gvtAll: if Item.Index >= Board.Count then Exit else
								ThreadItem := TThreadItem(Board.Items[Item.Index]);
			gvtLog:		ThreadItem := Board.GetLogThread(Item.Index);
			gvtNew:		ThreadItem := Board.GetNewThread(Item.Index);
			gvtUser:	ThreadItem := Board.GetUserThread(Item.Index);
		end;

		if ThreadItem = nil then Exit;

//		if ListNumberVisibleAction.Checked then
//			RepStr := IntToStr(ThreadItem.No) + ': ' + ThreadItem.Title
//		else
		RepStr := ThreadItem.Title;
		RepStr := CustomStringReplace(RepStr, '&lt;', '<' );
		RepStr := CustomStringReplace(RepStr, '&gt;', '>' );
		RepStr := CustomStringReplace(RepStr, '&quot;', '"' );
		RepStr := CustomStringReplace(RepStr, '&amp;', '&' );
		//RepStr := StringReplace(RepStr, '—M', ',', [rfReplaceAll]);

		if Item.SubItems.Count <> 7 then begin
			Item.SubItems.Clear;
			Item.SubItems.Add('');
			Item.SubItems.Add('');
			Item.SubItems.Add('');
			Item.SubItems.Add('');
			Item.SubItems.Add('');
			Item.SubItems.Add('');
            Item.SubItems.Add('');
		end;

		if ListNumberVisibleAction.Checked then
			Item.Caption := IntToStr(ThreadItem.No) + ': ' + RepStr
		else
			Item.Caption := RepStr;

		case ThreadItem.AgeSage of
			gasNone: Item.StateIndex := -1;
			gasNew:	Item.StateIndex := 0;
			gasAge:	Item.StateIndex := 1;
			gasSage: Item.StateIndex := 2;
		end;

		if ThreadItem.IsLogFile then begin
			Item.ImageIndex := ITEM_ICON_THREADLOG1;
			Item.SubItems[0] := IntToStr(ThreadItem.AllResCount);
			Item.SubItems[1] := IntToStr(ThreadItem.Count);
			if ThreadItem.NewResCount = 0 then
				Item.SubItems[2] := ''
			else
				Item.SubItems[2] := IntToStr(ThreadItem.NewResCount);
			Item.SubItems[3] := '';
			if ThreadItem.Round then
				Item.SubItems[4] := ThreadItem.RoundName
			else
				Item.SubItems[4] := '';
			if ThreadItem.RoundDate = ZERO_DATE then begin
				Item.SubItems[5] := '';
			end else
				Item.SubItems[5] := FormatDateTime('yyyy/mm/dd hh:mm:ss', ThreadItem.RoundDate);
			if ThreadItem.NewArrival then
				Item.ImageIndex := ITEM_ICON_THREADNEW1;
            if ThreadItem.CreateDate = ZERO_DATE then begin
		 		Item.SubItems[6] := '';
 			end else
 				Item.SubItems[6] := FormatDateTime('yyyy/mm/dd hh:mm:ss', ThreadItem.CreateDate);

		end else begin
			Item.ImageIndex := ITEM_ICON_THREAD1;
			Item.SubItems[0] := IntToStr(ThreadItem.AllResCount);
			Item.SubItems[1] := '';
			Item.SubItems[2] := '';
			Item.SubItems[3] := '';
			Item.SubItems[4] := '';
			Item.SubItems[5] := '';
            if not GikoSys.Setting.CreationTimeLogs then
				if ThreadItem.CreateDate = ZERO_DATE then
		 			Item.SubItems[6] := ''
 				else
 					Item.SubItems[6] := FormatDateTime('yyyy/mm/dd hh:mm:ss', ThreadItem.CreateDate);

		end;

		Item.Data := ThreadItem;
	end;
end;

procedure TGikoForm.ListViewDataFind(Sender: TObject; Find: TItemFind;
	const FindString: String; const FindPosition: TPoint; FindData: Pointer;
	StartIndex: Integer; Direction: TSearchDirection; Wrap: Boolean;
	var Index: Integer);
begin

//
end;

procedure TGikoForm.ListViewDataHint(Sender: TObject; StartIndex,
	EndIndex: Integer);
begin
//
end;

procedure TGikoForm.ListViewDataStateChange(Sender: TObject; StartIndex,
	EndIndex: Integer; OldState, NewState: TItemStates);
begin
//
end;

procedure TGikoForm.BrowserStatusTextChange(Sender: TObject; const Text: WideString);
var
	p: TPoint;
	s: string;
	tmp2: string;
	URL: string;
	ATitle: Boolean;

	threadItem	: TThreadItem;
	board				: TBoard;
	Protocol, Host, Path, Document, Port, Bookmark: string;

	wkInt: Integer;
	wkIntSt: Integer;
	wkIntTo: Integer;
	ActiveFileName: string;
	e: IHTMLElement;
	Ext: string;
	buf: string;
	PathRec: TPathRec;
begin
	if not( TObject(Sender) is TWebBrowser )then
		Exit;
	try
		try
			if (TWebBrowser(Sender) <> nil) and (not TWebBrowser(Sender).Busy) and (Assigned(TWebBrowser(Sender).Document)) then begin
				if LowerCase(OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset) <> 'shift_jis' then begin
					OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset := 'shift_jis';
				end;
			end;
		except
		end;
	finally
	end;
	if PreviewTimer.Enabled then
		PreviewTimer.Enabled := False;
	Application.CancelHint;
	try
		if GetActiveContent <> nil then
			ActiveFileName := ChangeFileExt(ExtractFileName(GetActiveContent.FileName), '')
		else
			ActiveFileName := '';
	except
		FActiveContent := nil;
		Exit;
	end;

	StatusBar.Panels[1].Text := Text;

	if FHint <> nil then begin
		FHint.ReleaseHandle;
		FHint.ClearAllRes;
	end;
	if FPreviewBrowser <> nil then
		ShowWindow(FPreviewBrowser.Handle, SW_HIDE);

	if not GikoSys.Setting.UnActivePopup then
		if not GikoForm.Active then
			Exit;

//file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10
//file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10-15

	s := '';
	Ext := AnsiLowerCase(ExtractFileExt(Text));
	if (Pos('http://', Text) = 1) and (GikoSys.Setting.PreviewVisible) and
			((Ext = '.jpg') or (Ext = '.jpeg') or (Ext = '.gif') or (Ext = '.png')) then begin
		if FPreviewBrowser = nil then begin
			FPreviewBrowser := TPreviewBrowser.Create(Self);
			ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
			TOleControl(FPreviewBrowser).Parent := nil;
		end;
		FPreviewBrowser.Navigate(BLANK_HTML);//‘O‰ñ‚ÌƒvƒŒƒrƒ…[‰æ‘œÁ‹Ž—p
		FPreviewURL := Text;
		PreviewTimer.Interval := GikoSys.Setting.PreviewWait;
		PreviewTimer.Enabled := True;
	end else if (Pos('about:blank', Text) = 1) or (Pos('http://', Text) = 1) or (Pos('mailto:', Text) = 1) then begin
		if Pos('mailto:', Text) = 1 then begin
			s := StringReplace(Text, 'mailto:', '', [rfIgnoreCase]);
			//ƒMƒRƒiƒrƒXƒŒ ƒp[ƒg3‚Ì466Ž‚ÉŠ´ŽÓ
			GetCursorPos(p);
			p.x := p.x - TWebBrowser(Sender).ClientOrigin.x;
			p.y := p.y - TWebBrowser(Sender).ClientOrigin.y;
			e := IHTMLDocument2(TWebBrowser(Sender).Document).elementFromPoint(p.x, p.y);
			if (Assigned(e)) then begin
				tmp2 := ZenToHan(e.Get_outerText);
				if (GikoSys.IsNumeric(tmp2)) then begin
					//‚“‚ÍƒŒƒX”Ô†‚Á‚Û‚¢‚Á‚·B
					wkIntSt := StrToInt(tmp2);
					wkIntTo := StrToInt(tmp2);
						//s := GetThreadText(wkBBS, wkKey, wkIntSt, wkIntTo, False, False);
					FHint.PopupType := gptThread;
					SetResPopupText(GetActiveContent, wkIntSt, wkIntTo, False, False);
				end else begin
					FHint.PopupType := gptRaw;
					FHint.Caption := s;
				end;
			end;
		end else begin
			threadItem := GetActiveContent;
			if Pos('about:blank..', Text) = 1 then begin
				if AnsiPos('http://jbbs.shitaraba.com/', threadItem.URL) <> 0 then begin
					URL := Copy(threadItem.URL, 1,  LastDelimiter('/',threadItem.URL));
					Gikosys.GetPopupResNumber(Text,PathRec.FSt,PathRec.FTo);
					if ( PathRec.FSt <> 0 ) and ( PathRec.FTo <> 0 ) then
						buf := IntToStr(PathRec.FSt) + '-' + IntToStr(PathRec.FTo)
					else if( PathRec.FSt <> 0 ) then
						buf := IntToStr(PathRec.FSt);
				end else if AnsiPos('machi.to/bbs/', threadItem.URL) <> 0 then begin
					URL := threaditem.URL;
					buf := Copy(Text,AnsiPos('&st=',Text),Length(Text)-AnsiPos('&st=',Text) + 1);
				end else begin
					URL := Copy(threadItem.URL, 1,  LastDelimiter('/',threadItem.URL));
					buf := Copy(Text,LastDelimiter('/',Text)+1,Length(Text)-LastDelimiter('/',Text));
				end;
				URL := URL + buf;
			end else begin
				URL := Text;
			end;
			PathRec := Gikosys.Parse2chURL2(URL);
			Gikosys.GetPopupResNumber(URL,PathRec.FSt,PathRec.FTo);
			GikoSys.ParseURI( URL, Protocol, Host, Path, Document, Port, Bookmark );

			if PathRec.FDone or (not GikoSys.Is2chHost( Host )) then begin

				URL := GikoSys.GetBrowsableThreadURL( URL );
				wkIntSt := PathRec.FSt;
				wkIntTo := PathRec.FTo;

				if (wkIntSt = 0) and (wkIntTo = 0) then begin
					wkIntSt := 1;
					wkIntTo := 1;
				end else if (wkIntSt = 0) and (wkIntTo > 0) then begin
					wkIntSt := wkIntTo;
				end else if (wkIntSt > 0) and (wkIntTo = 0) then begin
					wkIntTo := wkIntSt;
				end else if wkIntSt > wkIntTo then begin
					wkInt := wkIntTo;
					wkIntTo := wkIntSt;
					wkIntSt := wkInt;
				end;
				//if wkIntSt = 0 then
				//	wkIntSt := 1;
				//if wkINtTo = 0 then
				//	wkIntTo := 1;
				//if PathRec.FFirst then
				//	wkIntSt := 1;
				if PathRec.FStBegin then
					wkIntSt := 1;
				if PathRec.FToEnd then
					wkIntTo := 9999;

				//ATitle := ActiveFileName <> PathRec.FKey;
				if (FActiveContent <> nil) and (FActiveContent.Thread.URL = URL) then
					ATitle := false
				else
					ATitle := true;

				threadItem := BBSsFindThreadFromURL( URL );

				if (threadItem = nil) and GikoSys.Is2chHost( Host ) then begin
					board := BBSs[ 0 ].FindBBSID( PathRec.FBBS );
					if board <> nil then begin
						if not board.IsThreadDatRead then
							GikoSys.ReadSubjectFile( board );
						threadItem := board.FindThreadFromFileName( PathRec.FKey + '.dat' );
					end;
				end;

				if threadItem <> nil then begin
					//HintData := GetThreadText(PathRec.FBBS, PathRec.FKey, wkIntSt, wkIntTo, ATitle, PathRec.FFirst);
					FHint.PopupType := gptThread;
					SetResPopupText( threadItem, wkIntSt, wkIntTo, ATitle, PathRec.FFirst );
				end;
			end;
		end;

		//if s <> '' then
		//	ShowTextPopup(s);
		if FHint.PopupType = gptRaw then begin
			if FHint.Caption <> '' then
				ShowTextPopup;
		end else begin
			if (FHint.ResCount <> 0) or (FHint.Title <> '') then
				ShowTextPopup;
		end;
	end;
end;

procedure TGikoForm.SetEnabledCloseButton(Enabled: Boolean);
var
	SysMenu: HMenu;
	//SysMenuApp: HMenu;
begin
	FEnabledCloseButton := Enabled;
	SysMenu := GetSystemMenu(Handle, False);
	//SysMenuApp := GetSystemMenu(Application.Handle, False);

	if Enabled then begin
		EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
		//EnableMenuItem(SysMenuApp, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
	end else begin
		EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
		//EnableMenuItem(SysMenuApp, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
	end;

	DrawMenuBar(Handle);
	//DrawMenuBar(Application.Handle);
end;

procedure TGikoForm.TreeViewChanging(Sender: TObject; Node: TTreeNode;
	var AllowChange: Boolean);
begin
	if FTreeType = gtt2ch then
		FSortIndex := -1;
end;

procedure TGikoForm.ListViewKeyDown(Sender: TObject; var Key: Word;
	Shift: TShiftState);
begin
	if GetActiveList is TBoard then begin
		if Key = VK_BACK then begin
//		UpFolderButtonClick(Sender);
		end else if Key = VK_SPACE then begin
			ListDoubleClick(Shift);
		end else if Key = VK_RETURN then begin
			ListClick;
		end;
	end else begin // TBBS, TCategory
		if Key = VK_BACK then begin
//		UpFolderButtonClick(Sender);
		end else if Key = VK_SPACE then begin
			ListClick;
		end else if Key = VK_RETURN then begin
			ListDoubleClick(Shift);
		end;
	end;
end;

function TGikoForm.GetHttpState: Boolean;
begin
	Result := FHttpState;
end;

procedure TGikoForm.ListViewColumnClick(Sender: TObject;
	Column: TListColumn);
var
	i: Integer;
	wkBBS: TBBS;
	wkCategory: TCategory;
	wkBoard: TBoard;
begin
	if FSortIndex = Column.Index then
		FSortOrder := not FSortOrder
	else
		FSortOrder := False;

	for i := 0 to ListView.Columns.Count - 1 do
		ListView.Column[i].ImageIndex := -1;
	if FSortOrder then
		ListView.Column[Column.Index].ImageIndex := ITEM_ICON_SORT1
	else
		ListView.Column[Column.Index].ImageIndex := ITEM_ICON_SORT2;

	Sort.SortNoFlag := ListNumberVisibleAction.Checked;

	//if TObject(TreeView.Selected.Data) is TBBS then begin
	if TObject( FActiveList ) is TBBS then begin
		//wkBBS := TBBS(TreeView.Selected.Data);
		wkBBS := TBBS( FActiveList );
		Sort.SortOrder := FSortOrder;
		Sort.SortIndex := Column.Index;
		wkBBS.Sort(CategorySortProc);
		ListView.Refresh;
	//end else if TObject(TreeView.Selected.Data) is TCategory then begin
	end else if TObject( FActiveList ) is TCategory then begin
		//wkCategory := TCategory(TreeView.Selected.Data);
		wkCategory := TCategory( FActiveList );
		Sort.SortOrder := FSortOrder;
		Sort.SortIndex := Column.Index;
		wkCategory.CustomSort(BoardSortProc);
		ListView.Refresh;
	//end else if TObject(TreeView.Selected.Data) is TBoard then begin
	end else if TObject( FActiveList ) is TBoard then begin
		//wkBoard := TBoard(TreeView.Selected.Data);
		wkBoard := TBoard( FActiveList );
		Sort.SortOrder := FSortOrder;
		Sort.SortIndex := Column.Index;
		wkBoard.CustomSort(ThreadItemSortProc);
		ListView.Refresh;
	end;
	FSortIndex := Column.Index;
end;

procedure TGikoForm.MenuToolBarCustomDrawButton(Sender: TToolBar;
	Button: TToolButton; State: TCustomDrawState; var DefaultDraw: Boolean);
var
	ARect: TRect;
begin
	DefaultDraw := True;
	Exit;
	DefaultDraw := False;
	if (cdsSelected in State) or (cdsHot in State) then begin
		Sender.Canvas.Brush.Color := clHighlight;
		Sender.Canvas.Font.Color := clHighlightText;
	end else begin
		Sender.Canvas.Brush.Color := clBtnFace;
		Sender.Canvas.Font.Color := clBtnText;
	end;
	ARect := Rect(Button.Left, Button.Top, Button.Left + Button.Width, Button.Top + Button.Height);
	Sender.Canvas.FillRect(ARect);
	DrawText(Sender.Canvas.Handle, PChar(Button.Caption), -1, ARect, DT_SINGLELINE or DT_VCENTER or DT_CENTER);
end;

function TGikoForm.GetTreeNode(Data: TObject): TTreeNode;
var
	Nodes: TTreeNodes;
	i: integer;
begin
	Nodes := TreeView.Items;

	for i := 0 to Nodes.Count - 1 do begin
		if Nodes.Item[i].Data = Data then begin
			Result := Nodes.Item[i];
			Exit;
		end;
	end;
	Result := nil;
end;

procedure TGikoForm.BrowserBeforeNavigate2(Sender: TObject;
	const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
	Headers: OleVariant; var Cancel: WordBool);
var
	sNo: string;
	p: TPoint;
const
	kMenuName: string = 'menu:';
begin

	if Pos(kMenuName, URL) <> 0 then begin
		sNo := Copy( URL, Pos( kMenuName, URL ) + Length( kMenuName ), Length( URL ) );
		
		if not GikoSys.IsNumeric(sNo) then Exit;

		Cancel := True;
		GetCursorpos(p);
		KokoPopupMenu.Tag := StrToInt(sNo);
		KokoPopupMenu.Popup(p.x, p.y);
	end else if Pos('mailto', LowerCase(URL)) <> 0 then begin
		Cancel := not GikoSys.Setting.OpenMailer;
	end;

end;

procedure TGikoForm.ListViewAdvancedCustomDrawItem(Sender: TCustomListView;
	Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
	var DefaultDraw: Boolean);
var
	ThreadItem: TThreadItem;
begin
//	TListView(Sender).Canvas.Font.Style := [];
	if TObject(Item.Data) is TThreadItem then begin
		ThreadItem := TThreadItem(Item.Data);
		if ( FUseOddResOddColor ) and ( ThreadItem.Count <> 0 ) and ( ThreadItem.AllResCount <> ThreadItem.Count) then begin
						ListView.Canvas.Brush.Color := FOddColor;
				end else begin
					ListView.Canvas.Brush.Color := FListViewBackGroundColor;
				end;
//		if (ThreadItem.Kokomade <> ThreadItem.Count) and (ThreadItem.IsLogFile) then
		if ThreadItem.UnRead then
			TListView(Sender).Canvas.Font.Style := [fsBold];
	end;
end;

procedure TGikoForm.AppFormDeactivate(Sender: TObject);
begin
    Application.ProcessMessages;
	if Application.Terminated then
		Exit;
	if PreviewTimer.Enabled then
		PreviewTimer.Enabled := False;
	//ƒtƒH[ƒJƒX‚ª‘¼‚ÌƒAƒvƒŠ‚É•Ï‚í‚Á‚½‚Æ‚«‚Éƒqƒ“ƒg‚ðÁ‹Ž
	if FHint <> nil then begin
		FHint.ReleaseHandle;
		FHint.ClearAllRes;
//		FHint.Free;
//		FHint := nil;
	end;
	if FPreviewBrowser <> nil then
		ShowWindow(FPreviewBrowser.Handle, SW_HIDE);

end;

procedure TGikoForm.TreeViewCustomDraw(Sender: TCustomTreeView;
	const ARect: TRect; var DefaultDraw: Boolean);
var
	NodeRect: TRect;
	i, j: Integer;
	IsBoardNode: Boolean;
	Cnt: Integer;
	CntText: string;
	TextWidth: Integer;
	TextRect: TRect;
	Board: TBoard;
	Category: TCategory;
	Bitmap: TBitmap;
	NodeWidth: Integer;
begin
	DefaultDraw := True;

	if FTreeType = gttHistory then Exit;

	TreeView.Canvas.Font.Color := clBlue;
	IsBoardNode := False;
	for i := 0 to TreeView.Items.Count - 1 do begin
		Cnt := 0;
		if not TreeView.Items[i].IsVisible then
			continue;

		if TObject(TreeView.Items[i].Data) is TCategory then begin
			if TreeView.Items[i].Expanded then
				continue;

			IsBoardNode := False;
			Category := TCategory(TreeView.Items[i].Data);
			for j := 0 to Category.Count - 1 do begin
				Board := Category.Items[j];
				if Board <> nil then begin
					if Board.UnRead > 0 then begin
						Cnt := 1;
						Break;
					end;
				end;
			end;
			if Cnt <> 1 then
				continue;
		end else if TObject(TreeView.Items[i].Data) is TBoard then begin
			IsBoardNode := True;
			Board := TBoard(TreeView.Items[i].Data);
			Cnt := Board.UnRead;
			if Cnt <= 0 then
				continue;
		end else
			continue;

		Bitmap := TBitmap.Create;
		try
			Bitmap.Canvas.Font.Assign(TreeView.Canvas.Font);
			Bitmap.Canvas.Font.Style := [fsBold];
			NodeWidth := Bitmap.Canvas.TextWidth(TreeView.Items[i].Text);
		finally
			Bitmap.Free;
		end;

		NodeRect := TreeView.Items[i].DisplayRect(True);

		if IsBoardNode then
			CntText := '(' + IntToStr(Cnt) + ')'
		else if Cnt = 1 then
			CntText := '(+)';


		TextWidth := TreeView.Canvas.TextWidth(CntText);

		TextRect := Rect(NodeRect.Left + NodeWidth + 8,
										 NodeRect.Top,
										 NodeRect.Left + NodeWidth + TextWidth + 8,
										 NodeRect.Bottom);
		DrawText(TreeView.Canvas.Handle,
						 PChar(CntText),
						 -1,
						 TextRect,
						 DT_SINGLELINE or DT_VCENTER);
	end;
	TreeViewCustomDrawItem(nil, nil, [], DefaultDraw);
end;

procedure TGikoForm.TreeViewCustomDrawItem(Sender: TCustomTreeView;
	Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var
	Board: TBoard;
	Category: TCategory;
	i: Integer;
begin
	DefaultDraw := True;

	if FTreeType = gttHistory then Exit;

	TreeView.Canvas.Font.Style := [];
	if Node <> nil then begin
		if TObject(Node.Data) is TCategory then begin
			Category := TCategory(Node.Data);
			for i := 0 to Category.Count - 1 do begin
				Board := Category.Items[i];
				if Board <> nil then begin
					if Board.UnRead > 0 then begin
						TreeView.Canvas.Font.Style := [fsBold];
						Break;
					end;
				end;
			end;
		end else if TObject(Node.Data) is TBoard then begin
			Board := TBoard(Node.Data);
			if Board.UnRead > 0 then
				TreeView.Canvas.Font.Style := [fsBold];
		end;
	end;
end;

procedure TGikoForm.TreeViewExpanded(Sender: TObject; Node: TTreeNode);
begin
	TreeView.Invalidate;

	if TObject(Node.Data) is TBBS then begin
		TBBS(Node.Data).NodeExpand := True;
	end else if TObject(Node.Data) is TCategory then begin
		TCategory(Node.Data).NodeExpand := True;
	end else if TObject(Node.Data) is TBoard then begin
		TBoard(Node.Data).NodeExpand := True;
	end;
end;

{procedure TGikoForm.CabinetPanelVisible(PanelVisible: Boolean);
begin
	TreeSplitter.Visible := PanelVisible;
	CabinetPanel.Visible := PanelVisible;
	CabinetToolButton.Down := PanelVisible;
end;}

procedure TGikoForm.ListViewAllSelect;
begin
	ListView.SetFocus;
	ListView.SelectAll;
end;

procedure TGikoForm.TreeViewDblClick(Sender: TObject);
var
	APoint: TPoint;
	HitTest: THitTests;
begin
	GetCursorPos(APoint);
	APoint := TreeView.ScreenToClient(APoint);
	HitTest := TreeView.GetHitTestInfoAt(APoint.x, APoint.y);
	if not (htOnLabel in HitTest) then Exit;

	TreeDoubleClick( TreeView.Selected );
end;

procedure TGikoForm.DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
begin
	AddMessageList(Msg, nil, Icon);
end;

procedure TGikoForm.DownloadEnd(Sender: TObject; Item: TDownloadItem);
var
	ATitle: string;
	s: string;
	boardPlugIn : TBoardPlugIn;
	i: Integer;
begin
	try
		if Item.DownType = gdtBoard then
			ATitle := Item.Board.Title
		else
			ATitle := Item.ThreadItem.Title;
		if ATitle = '' then
			ATitle := 'i–¼Ì•s–¾j';

		if Item.State in [gdsComplete, gdsDiffComplete] then begin
			//³íI—¹
			if Item.DownType = gdtBoard then begin
				//”Â
				Item.SaveListFile;
				AddMessageList(ATitle + ' [ƒXƒŒˆê——Žæ“¾Š®—¹]', nil, gmiOK);
				if GetActiveList = Item.Board then begin
					FActiveList := nil;
					SetActiveList(Item.Board);
				end;
				Item.Board.Modified := True;
				Item.Board.IsThreadDatRead := True;
				PlaySound('New');
			end else if Item.DownType = gdtThread then begin
				//ƒXƒŒ
				Item.SaveItemFile;
				Item.ThreadItem.NewArrival := True;
				if (Item.ThreadItem.IsBoardPlugInAvailable) and (Item.ThreadItem.Title = '') then begin
					boardPlugIn		:= Item.ThreadItem.BoardPlugIn;
					Item.ThreadItem.Title := GikoSys.DivideStrLine(boardPlugIn.GetDat( DWORD( Item.ThreadItem ), 1 )).FTitle;
					ATitle := Item.ThreadItem.Title;
				end else if ATitle = 'i–¼Ì•s–¾j' then begin
					ATitle := GikoSys.DivideStrLine(GikoSys.ReadThreadFile(Item.ThreadItem.GetThreadFileName, 1)).FTitle;
				end;
				for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
					if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = Item.ThreadItem then
						TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
				end;
				if GikoSys.Setting.BrowserTabVisible then begin
					if GetActiveContent = Item.ThreadItem then
						InsertBrowserTab(Item.ThreadItem)
					else if (ListView.Selected <> nil ) and ( TObject(ListView.Selected.Data) is TThreadItem ) and ( Item.ThreadItem = TThreadItem(ListView.Selected.Data)) then
						InsertBrowserTab(Item.ThreadItem, True)
					else
						InsertBrowserTab(Item.ThreadItem, False);
				end else begin
					if (GetActiveContent = Item.ThreadItem) or (FActiveContent = nil) or(FActiveContent.Browser = BrowserNullTab.Browser) then
                    	InsertBrowserTab(Item.ThreadItem);
				end;

				if Item.State = gdsComplete then begin
					PlaySound('New');
					AddMessageList(ATitle + ' [ƒXƒŒŽæ“¾Š®—¹]', nil, gmiOK);
				end else begin
					PlaySound('NewDiff');
					AddMessageList(ATitle + ' [ƒXƒŒ·•ªŽæ“¾Š®—¹]', nil, gmiOK);
				end;

				//„‰ñ‚ ‚è‚Ìê‡•‚P‚O‚O‚O’´‚Í„‰ñíœ
				if (Item.ThreadItem.Round) and (Item.ThreadItem.Count > 1000) then begin
					Item.ThreadItem.Round := False;
					Item.ThreadItem.RoundName := '';
					AddMessageList('š1000”­Œ¾‚ð’´‚¦‚½‚Ì‚Å„‰ñ‚ðíœ‚µ‚Ü‚µ‚½ - [' + Item.ThreadItem.Title + ']', nil, gmiOK);
				end;

				TreeView.Refresh;
			end;
			ListView.Refresh;
		end else if Item.State = gdsNotModify then begin
			//•ÏXƒiƒV
{			if (Item.DownType = gdtThread) and (AddHistory(Item.ThreadItem)) then begin
				//SetContent(Item.ThreadItem);
				InsertBrowserTab(Item.ThreadItem);
			end;}
			AddMessageList(ATitle + ' [–¢XV]', nil, gmiSAD);
			PlaySound('NoChange');
			Screen.Cursor := crDefault;
		end else if Item.State = gdsAbort then begin
			//’†’f
			AddMessageList(ATitle + ' [’†’f]', nil, gmiSAD);
		end else if Item.State = gdsError then begin
			//ƒGƒ‰[
			s := Item.ErrText;
			if s <> '' then
				s := ':' + s;
			AddMessageList(ATitle + ' [ƒGƒ‰[(' + IntToStr(Item.ResponseCode) + s + ')]', nil, gmiNG);
//			if Item.ResponseCode = 302 then
//				AddMessageList('”Â‚ªˆÚ“]‚µ‚½‚©‚à‚µ‚ê‚È‚¢‚Ì‚Å”ÂXV‚ðs‚Á‚Ä‚­‚¾‚³‚¢B', nil, gmiNG);
			PlaySound('Error');
		end;
	finally
		Item.Free;
		Dec(FWorkCount);
		if FWorkCount < 0 then FWorkCount := 0;
		if FWorkCount = 0 then begin
			try
				Animate.Active := False;
			finally
				Screen.Cursor := crDefault;
			end;
		end;

	end;
end;

procedure TGikoForm.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
begin
//	SetProgressValue(Number, 0, AWorkCountMax);
//	ProgressBar.Visible := True;
	ProgressBar.Position := 0;
	ProgressBar.Max := AWorkCountMax;
	FDownloadTitle := AWorkTitle;
	StatusBar.Panels[1].Text := FDownloadTitle + ' - ƒ_ƒEƒ“ƒ[ƒh‚ðŠJŽn‚µ‚Ü‚·';
	FDownloadMax := AWorkCountMax;
end;

procedure TGikoForm.WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
begin
	ProgressBar.Position := 0;
	if FDownloadMax <> 0 then
		StatusBar.Panels[1].Text := FDownloadTitle + ' - ƒ_ƒEƒ“ƒ[ƒh‚ªŠ®—¹‚µ‚Ü‚µ‚½';
end;

procedure TGikoForm.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);
begin
	ProgressBar.Position := AWorkCount;
//	SetProgressValue(Number, AWorkCount);
	StatusBar.Panels[1].Text := FDownloadTitle + ' - ƒ_ƒEƒ“ƒ[ƒh’† (' + IntToStr(AWorkCount) + '/' + IntToStr(FDownloadMax) + ')';
end;

{
procedure TGikoForm.SetProgressValue(Number: Integer; Value: Integer; Max: Integer = -1);
var
	Component: TComponent;
begin
	Component := FindComponent('ProgressBar' + IntToStr(Number + 1));
	if Component <> nil then begin
		if not (Component is TProgressBar) then Exit;
		if Max <> -1 then
			TProgressBar(Component).Max := Max;
		TProgressBar(Component).Position := Value;
	end;
end;
}

procedure TGikoForm.AddMessageList(ACaption: string; AObject: TObject; Icon: TGikoMessageIcon);
var
	ListItem: TListItem;
begin
	MessageListView.Items.BeginUpdate;
	try
		ListItem := MessageListView.Items.Add;
		ListItem.Caption := ACaption;
		ListItem.Data := AObject;
		ListItem.MakeVisible(False);
		case Icon of
			gmiOK:	 ListItem.ImageIndex := 0;
			gmiSAD:	ListItem.ImageIndex := 1;
			gmiNG:	 ListItem.ImageIndex := 2;
			gmiWhat: ListItem.ImageIndex := 3;
		end;
	finally
		MessageListView.Items.EndUpdate;
	end;
end;

{procedure TGikoForm.BrowserTabChange(Sender: TObject);
var
	index: Integer;
	ThreadItem: TThreadItem;
begin
	ThreadItem := GetActiveContent;
	if ThreadItem <> nil then begin
		SetContent(ThreadItem);
	end;
end;}

procedure TGikoForm.InsertBrowserTab(ThreadItem: TThreadItem; ActiveTab: Boolean = True);

var
	i, j, idx: Integer;
	favItem : TFavoriteThreadItem;
	newBrowser	: TBrowserRecord;
begin

	if Threaditem = nil then Exit;

	if ThreadItem.IsLogFile then begin
		//‚¨‹C‚É“ü‚è‚Ì‘S‚ÄŠJ‚­‚Æ‚©‚â‚é‚ÆA¡ŠJ‚¢‚Ä‚éƒXƒŒ‚Ìbrowser‚ð•t‚¯‘Ö‚¦‚é‹°‚ê‚ª‚ ‚é
		//í‚É‚S”Ô–Ú‚ÉActive‚Ìƒuƒ‰ƒEƒU‚ª—ˆ‚È‚¢‚æ‚¤‚ÉˆÚ“®‚³‚¹‚é
		if (FActiveContent <> nil) and (FActiveContent.FBrowser <> nil) and
			(FActiveContent.FBrowser <> BrowserNullTab.Browser)then begin
			j := FBrowsers.IndexOf(FActiveContent.FBrowser);
			if j = BROWSER_COUNT - 1 then
				FBrowsers.Move(BROWSER_COUNT - 1, 0);
		end;
		favItem := TFavoriteThreadItem.Create(ThreadItem.URL, ThreadItem.Title );
		if not AddHistory( favItem ) then
			favItem.Free;

		for i := 0 to BrowserTab.Tabs.Count - 1 do begin
			if TObject(BrowserTab.Tabs.Objects[i]) is TBrowserRecord then begin
				if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
					if TBrowserRecord(BrowserTab.Tabs.Objects[i]).FBrowser = nil then begin
						for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
							if TBrowserRecord(BrowserTab.Tabs.Objects[j]).FBrowser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
								TBrowserRecord(BrowserTab.Tabs.Objects[j]).FBrowser := nil;
								if TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent <> nil then begin
									TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent.Free;
									TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent := nil;
								end;
								break;
							end;
						end;
						TBrowserRecord(BrowserTab.Tabs.Objects[i]).FBrowser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
						TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
						FBrowsers.Move(BROWSER_COUNT - 1, 0);
					end;
					if ActiveTab then begin
						BrowserTab.TabIndex := i;
							BrowserTab.OnChange(nil);
						BrowserTab.Repaint;
					end;
					Exit;
				end;
			end;
		end;
		idx := BrowserTab.TabIndex;
		if GikoSys.Setting.BrowserTabAppend = gtaFirst then begin
			newBrowser := TBrowserRecord.Create;
			for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
				if TBrowserRecord(BrowserTab.Tabs.Objects[j]).FBrowser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
					TBrowserRecord(BrowserTab.Tabs.Objects[j]).FBrowser := nil;
					if TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent <> nil then begin
						TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent.Free;
						TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent := nil;
					end;
					break;
				end;
			end;
			newBrowser.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
			FBrowsers.Move(BROWSER_COUNT - 1, 0);
			//newBrowser.Browser.Navigate(BLANK_HTML);
			newBrowser.thread := ThreadItem;
			newBrowser.Repaint := true;
			newBrowser.OnlyHundred := GikoSys.OnlyAHundredRes;

			BrowserTab.Tabs.InsertObject(0, GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
			if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
				DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 1 ] ) );
			end;// else begin
			//end;
			BrowserTab.Repaint;
			if ActiveTab then begin
				BrowserTab.TabIndex := 0;
			end;

		end else begin
			newBrowser := TBrowserRecord.Create;
			for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
				if TBrowserRecord(BrowserTab.Tabs.Objects[j]).FBrowser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
					TBrowserRecord(BrowserTab.Tabs.Objects[j]).FBrowser := nil;
					if TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent <> nil then begin
						TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent.Free;
						TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent := nil;
					end;
					break;
				end;
			end;
			newBrowser.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
			FBrowsers.Move(BROWSER_COUNT - 1, 0);
			//newBrowser.Browser.Navigate(BLANK_HTML);
			newBrowser.thread := ThreadItem;
			newBrowser.OnlyHundred := GikoSys.OnlyAHundredRes;
			newBrowser.Repaint := true;

			i := BrowserTab.Tabs.AddObject(GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
			if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
				DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 0 ] ) );
			end;
			//end;
			BrowserTab.Repaint;
			if ActiveTab then begin
				if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 0) then
					BrowserTab.TabIndex := 0
				else
					BrowserTab.TabIndex := i;
			end;
		end;
		if(ActiveTab) or (idx = -1) then begin
			BrowserTab.OnChange(nil);
		end;
	end else begin
		if BrowserNullTab = nil then begin
			BrowserNullTab := TBrowserRecord.Create;
			BrowserNullTab.Browser := Browser;
		end;
		BrowserNullTab.thread := ThreadItem;
		BrowserTab.TabIndex := -1;
		SetContent(BrowserNullTab);
	end;

	if GikoSys.Setting.URLDisplay then
		AddressComboBox.Text := ThreadItem.URL;

end;

procedure TGikoForm.SetContent(inThread : TBrowserRecord);
var
	BBSID: string;
	FileName: string;
	sTitle: string;
//	HtmlName: string;
	doc:  Variant;
	s: string;
//	OldCursor: TCursor;
	i: Integer;
	url: OleVariant;
	idx: Integer;
	ThreadItem: TThreadItem;
	Thread: TBrowserRecord;
	ThreadTitle, ThreadPTitle: string;
	ThreadScrollTop: Integer;
	ThreadIsLog, ThreadUnRead, ThreadNewArraical: boolean;
begin
	Thread := inThread;
	idx := BrowserTab.TabIndex;
	if (FActiveContent <> nil) and
		(FActiveContent.Thread <> Thread.Thread) and
		(Assigned(FActiveContent.Browser.Document)) then begin
		try
		try
			Sleep(1);
			//Application.ProcessMessages;
			FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document).Body).ScrollTop;
			//if FActiveContent.Browser <> BrowserNullTab.Browser then
			//	TOleControl(FActiveContent.Browser).Visible := false;
		except
			on E: Exception do
				MsgBox(Handle, E.Message, 'SetContent[<-ScrollTop]', 0);
		end;
		finally
		end;
	end;
	if not (Assigned(Thread)) or (Thread.Thread = nil) then begin
		Thread.Browser.Navigate(BLANK_HTML);
		BrowserBoardNameLabel.Caption := '';
		ItemBoardImage.Picture := nil;
		BrowserNameLabel.Caption := '';
		ItemImage.Picture := nil;
		BrowserNullTab.Thread := nil;
		//TOleControl(BrowserNullTab.Browser).Visible := true;
		ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
		FActiveContent := nil;
		Exit;
	end	else if Thread.Browser = nil then begin
		if FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then
			FBrowsers.Move(BROWSER_COUNT - 1, 0);
		for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
			if TBrowserRecord(BrowserTab.Tabs.Objects[i]).FBrowser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
				TBrowserRecord(BrowserTab.Tabs.Objects[i]).FBrowser := nil;
				if TBrowserRecord(BrowserTab.Tabs.Objects[i]).FEvent <> nil then begin
					TBrowserRecord(BrowserTab.Tabs.Objects[i]).FEvent.Free;
					TBrowserRecord(BrowserTab.Tabs.Objects[i]).FEvent := nil;
				end;
				break;
			end;
		end;
		Thread.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
		FBrowsers.Move(BROWSER_COUNT - 1, 0);
	end;
	ThreadTitle := Thread.Thread.Title;
	ThreadPTitle := Thread.Thread.ParentBoard.Title;
	ThreadScrollTop := Thread.Thread.ScrollTop;
	ThreadIsLog := Thread.Thread.IsLogFile;
	ThreadItem := Thread.Thread;
	ThreadNewArraical :=  Thread.Thread.NewArrival;
	ThreadUnRead := Thread.Thread.UnRead;
	BBSID := ThreadItem.ParentBoard.BBSID;
	FileName := ThreadItem.FileName;

	if GetCapture = ListView.Handle then
		ReleaseCapture;

	Screen.Cursor := crHourGlass;


	try
		if ThreadItem.UnRead then begin
			ThreadItem.ParentBoard.UnRead := ThreadItem.ParentBoard.UnRead - 1;
			if ThreadItem.ParentBoard.UnRead < 0 then ThreadItem.ParentBoard.UnRead := 0;
			TreeView.Refresh;
		end;
	   //	LockWindowUpdate(Self.Handle);
		if(FActiveContent <> nil) and (FActiveContent <> Thread) then begin
			if (FActiveContent.Browser <> BrowserNullTab.Browser) then
				ShowWindow(FActiveContent.Browser.Handle, SW_HIDE);
		end;
		ShowWindow(Thread.FBrowser.Handle, SW_SHOW);
		//LockWindowUpdate(0);
		if (not Assigned(Thread.Browser.Document)) then begin
			Thread.Browser.Navigate('about:blank');
		end;
		FActiveContent := Thread;
		while (Thread.Browser.ReadyState <> READYSTATE_COMPLETE) and
				(Thread.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
			Application.ProcessMessages;
			if idx <> BrowserTab.TabIndex then begin
				Exit;
			end;
		end;
		if not ThreadIsLog then begin
			Self.Caption := CAPTION_NAME ;
			try
				s := '<HTML><BODY><CENTER>‚±‚ÌƒXƒŒƒbƒh‚ÍŽæ“¾‚µ‚Ä‚¢‚Ü‚¹‚ñ</CENTER></BODY></HTML>';
				doc := Idispatch( olevariant(Thread.Browser.ControlInterface).Document) as IHTMLDocument2;
				doc.open;
				doc.charset := 'Shift_JIS';
				doc.Write(s);
				doc.Close;
			finally
			end;
		end else begin
			Self.Caption := CAPTION_NAME + ' - [' + ThreadTitle + ']';
			//Thread.Repaint‚ÍAƒXƒLƒ““™‚ÌÝ’è‚ð•ÏX‚µ‚½‚Æ‚«AThread‚ðƒ_ƒEƒ“ƒ[ƒh‚µ‚½‚Æ‚«
			//V‹K‚ÉThread‚ðŠJ‚¢‚½‚Æ‚«‚É^‚É‚È‚Á‚Ä‚¢‚éB
			if(Thread.Repaint) or (Thread.OnlyHundred <> GikoSys.OnlyAHundredRes)then begin
				//Thread.LastSize := ThreadItem.Size;
				Thread.Repaint := false;
				try
					Thread.Browser.OnStatusTextChange := nil;
					doc := Idispatch( olevariant(Thread.Browser.ControlInterface).Document) as IHTMLDocument2;
					GikoSys.CreateHTML2(doc, ThreadItem, sTitle);

			//		if (Assigned(Thread.Browser)) and (Thread.Browser <> nil) then
					Thread.Browser.OnStatusTextChange := BrowserStatusTextChange;
					//‚È‚º‚©‚±‚±‚Å–¾Ž¦“I‚ÉDocumentComplete‚ðŒÄ‚Î‚È‚¢‚Æ‚¤‚Ü‚­‚¢‚©‚È‚¢
					//’Ç‹L@200406/19
					//Visible‚Ì‚Æ‚«‚µ‚©DocumentComplete‚ÍŒÄ‚Î‚ê‚È‚¢‚ç‚µ‚¢
					Thread.FBrowser.OnDocumentComplete(Thread.FBrowser, Thread.FBrowser.Parent, url);
					Thread.OnlyHundred := GikoSys.OnlyAHundredRes;
					Application.ProcessMessages;
					//‚±‚±‚ÅApplication.ProcessMessages‚ðŒÄ‚Ô‚±‚Æ‚É‚æ‚Á‚ÄWebBrowser‚ðXV‚³‚¹‚éB
					//‘Š‚µ‚È‚¢‚Æˆê‰æ–Ê•ª‚µ‚©•`‰æ‚Å‚«‚Ä‚È‚¢‚Ì‚Å‚»‚êˆÈã‚ÌƒXƒNƒ[ƒ‹—Ê‚ðŽw’è‚µ‚Ä‚à–³Œø‚É‚È‚é
					//@by‚à‚¶‚ã(2004/01/20)
					try
						//if (Assigned(Thread)) and (Assigned(ThreadItem))then begin
							if(Thread <> nil) and (ThreadItem <>nil) then begin
								if ThreadUnRead then
									BrowserMovement('new', Thread)
								else if ThreadScrollTop <> 0 then begin
									try
										doc.Body.ScrollTop := ThreadScrollTop;
									except
										on E: Exception do
											MsgBox(Handle, E.Message, 'SetContent[ScrollTop<-]', 0);
									end;
								end;
						//	end;
						end else begin
							FActiveContent := nil;
							BrowserTab.Repaint;
							Exit;
						end;
					except
						FActiveContent := nil;
						BrowserTab.Repaint;
						Exit;
					end;
				finally
					 //	Application.ProcessMessages;
				end;
			end;
			ThreadItem.UnRead := False;
			ListView.Refresh;
		end;
		if (Assigned(Thread)) and (Assigned(Thread.Thread)) and (Thread <> nil) and (ThreadItem <>nil) then begin
			//FActiveContent := Thread;

			BrowserBoardNameLabel.Caption := ThreadPTitle;
			ItemIcon16.GetBitmap(4, ItemBoardImage.Picture.Bitmap);
			BrowserNameLabel.Caption := ThreadTitle;
			ItemImage.Picture := nil;
			if ThreadIsLog then
				if ThreadNewArraical then
					ItemImageList.GetBitmap(2, ItemImage.Picture.Bitmap)
				else
					ItemImageList.GetBitmap(0, ItemImage.Picture.Bitmap)
			else
				ItemImageList.GetBitmap(1, ItemImage.Picture.Bitmap);

			ItemImage.Left := BrowserBoardNameLabel.Left + BrowserBoardNameLabel.Width + 8;
			BrowserNameLabel.Left := ItemImage.Left + 20;
		end else begin
			FActiveContent := nil;
		end;
	finally
		Screen.Cursor := crDefault;
	end;
end;

function TGikoForm.GetActiveContent: TThreadItem;
begin
	try
		if( Assigned(FActiveContent) ) and (Assigned(FActiveContent.Thread))
			and (FActiveContent <> nil) and (FActiveContent.Thread <> nil) then
			Result := FActiveContent.Thread
		else begin
            FActiveContent := nil;
			Result := nil;
		end;
	except
		FActiveContent := nil;
		Result := nil;
	end;
end;

procedure TGikoForm.SetActiveList(Obj: TObject);
var
	i		: Integer;
	idx	: Integer;
begin
//	if FActiveList <> Obj then begin
		FActiveList := Obj;

		if ListView.Selected <> nil then
			idx := ListView.Selected.Index
		else
			idx := -1;
		ListView.Items.Count := 0;
		ListView.Items.Clear;
		ListView.Selected := nil;
//	ListView.Columns.Clear;

		Self.Caption := CAPTION_NAME;
		//Application.Title := CAPTION_NAME;

		if Obj is TBBS then begin
			for i := 0 to ListView.Columns.Count - 1 do
				ListView.Column[i].Width := GikoSys.Setting.BBSColumnWidth[i];
			SetCategoryListItem(TBBS(Obj));
		end else if Obj is TCategory then begin
			for i := 0 to ListView.Columns.Count - 1 do
				ListView.Column[i].Width := GikoSys.Setting.CategoryColumnWidth[i];
			SetBoardListItem(TCategory(Obj));
		end else if Obj is TBoard then begin
			SetThreadListItem(TBoard(Obj));
		end;

		if idx >= 0 then begin
			ListView.ItemIndex := idx;
			ListView.ItemFocused := ListView.Items.Item[ idx ];
		end;
//	end;
end;


//ššƒqƒƒ†ƒLƒƒ‚
//‚»‚Ì‚¤‚¿interface‚ðŽg‚¤
function TGikoForm.GetActiveList: TObject;
begin
	Result := FActiveList;
end;

procedure TGikoForm.SetListViewType(AViewType: TGikoViewType);
begin
	SetListViewType(AViewType, '', False);
end;

procedure TGikoForm.SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean);
var
	Board: TBoard;
begin
	if ActiveList is TBoard then begin
		Board := TBoard(ActiveList);

		Board.ParentCategory.ParenTBBS.SelectText := SelectText;
		Board.ParentCategory.ParenTBBS.KubetsuChk := KubetsuChk;
//		Board.SelectText := SelectText;
//		Board.KubetsuChk := KubetsuChk;
		ViewType := AViewType;
		SetActiveList(Board);
		SetThreadListItem(Board);
	end;
end;

procedure TGikoForm.ListViewCustomDraw(Sender: TCustomListView;
	const ARect: TRect; var DefaultDraw: Boolean);
var
	s: string;
	p: TPoint;
//	Board: TBoard;
begin
	if ListView.Items.Count = 0 then begin
		DefaultDraw := True;

		ListView.Canvas.Brush.Color := ListView.Color;
		ListView.Canvas.FillRect(ARect);

		case ViewType of
			gvtAll: begin
				ListView.Canvas.Font.Color := clWindowText;
				s := '‚±‚Ìƒrƒ…[‚É‚ÍƒAƒCƒeƒ€‚ª‚ ‚è‚Ü‚¹‚ñB';
			end;
			gvtLog: begin
				ListView.Canvas.Font.Color := clBlue;
				s := '‚±‚Ìƒrƒ…[‚É‚ÍƒƒO—L‚èƒAƒCƒeƒ€‚ª‚ ‚è‚Ü‚¹‚ñB';
			end;
			gvtNew: begin
				ListView.Canvas.Font.Color := clGreen;
				s := '‚±‚Ìƒrƒ…[‚É‚ÍV’…ƒAƒCƒeƒ€‚ª‚ ‚è‚Ü‚¹‚ñB';
			end;
			gvtUser: begin
				ListView.Canvas.Font.Color := clNavy;
				s := '‚±‚Ìƒrƒ…[‚É‚Íƒ^ƒCƒgƒ‹‚ªu%sv‚ðŠÜ‚ÞƒAƒCƒeƒ€‚ª‚ ‚è‚Ü‚¹‚ñB';
				if GetActiveList is TBoard then
					s := Format(s, [TBoard(GetActiveList).ParentCategory.ParenTBBS.SelectText]);
//					SelectText]);
			end;
			else begin
				s := '';
			end;
		end;

		p := Point((ListView.ClientWidth div 2) - (ListView.Canvas.TextWidth(s) div 2),
							 (ListView.ClientHeight div 2) - (ListView.Canvas.TextHeight(s) div 2));
		ListView.Canvas.TextOut(p.X, p.Y, s);
	end else begin
		DefaultDraw := True;
	end;
end;

procedure TGikoForm.DownloadList(Board: TBoard; ForceDownload: Boolean = False);
var
	Item: TDownloadItem;
begin
	if not Board.IsThreadDatRead then
		GikoSys.ReadSubjectFile(Board);
	Item := TDownloadItem.Create;
	try
		Item.Board := Board;
		Item.DownType := gdtBoard;
		Item.ForceDownload := ForceDownload;
//		AbortToolButton.Enabled := True;
//		Animate.Active := True;
//		FDownload.Add(Item);
		FControlThread.AddItem(Item);
//		Animate.Active := False;
//		AbortToolButton.Enabled := False;
		if FWorkCount = 0 then begin
			try
				Animate.Active := True;
			except
			end;
			Screen.Cursor := crAppStart;
		end;
		Inc(FWorkCount);
	finally
		//Item.Free;
	end;
end;

procedure TGikoForm.DownloadContent(ThreadItem: TThreadItem; ForceDownload: Boolean = False);
var
	Item: TDownloadItem;
begin
	Item := TDownloadItem.Create;
	try
		Item.ThreadItem := ThreadItem;
		Item.DownType := gdtThread;
		Item.ForceDownload := ForceDownload;
//		AbortToolButton.Enabled := True;
//		Animate.Active := True;
//		FDownload.Add(Item);
		FControlThread.AddItem(Item);
//		Animate.Active := False;
//		AbortToolButton.Enabled := False;
		if FWorkCount = 0 then begin
			try
				Animate.Active := True;
			except
			end;
			Screen.Cursor := crAppStart;
		end;
		Inc(FWorkCount);
	finally
//		Item.Free;
	end;
end;

procedure TGikoForm.PlaySound(SoundEventName: string);
var
	FileName: string;
begin
	FileName := GikoSys.Setting.FindSoundFileName(SoundEventName);
	if FileExists(FileName) then begin
		if not sndPlaySound(PChar(FileName), SND_ASYNC or SND_NOSTOP) then begin
			sndPlaySound(nil, SND_SYNC);
			Application.ProcessMessages;
			Sleep(10);
			sndPlaySound(PChar(FileName), SND_ASYNC);
		end;
	end;
end;

function TGikoForm.AddHistory( favItem : TFavoriteThreadItem ): Boolean;
var
	i: Integer;
	Item: TFavoriteThreadItem;
	Node: TTreeNode;
begin
//	Result := False;
//	if (GetActiveContent = ThreadItem) and
//			(ThreadItem.Count <= ThreadItem.Kokomade) then
//		Exit;
//	if GetActiveContent = ThreadItem then
//		Exit;

	Result := True;
	if FTreeType = gttHistory then
  	TreeView.Selected := nil;

	for i := 0 to FHistoryList.Count - 1 do begin
		if TObject(FHistoryList[i]) is TFavoriteThreadItem then begin
			Item := TFavoriteThreadItem(FHistoryList[i]);
			if Item.URL = favItem.URL then begin
//				SetContent(ThreadItem);
				FHistoryList.Move(i, 0);
				if FTreeType = gttHistory then
					if TreeView.Items.GetFirstNode <> TreeView.Items[ i ] then
						TreeView.Items[ i ].MoveTo( TreeView.Items.GetFirstNode, naInsert );
								Result := false;
				Exit;
			end;
		end;
	end;

	if FHistoryList.Count > 0 then
		FHistoryList.Insert( 0, favItem )
	else
		FHistoryList.Add( favItem );
//	SetContent(ThreadItem);

	if FTreeType = gttHistory then begin
		Node := TreeView.Items.Add( nil, favItem.Title );
		Node.MoveTo( TreeView.Items.GetFirstNode, naInsert );
		{
		if favItem.NewArrival then begin
			Node.ImageIndex := ITEM_ICON_THREADNEW1;
			Node.SelectedIndex := ITEM_ICON_THREADNEW2;
		end else begin
			Node.ImageIndex := ITEM_ICON_THREADLOG1;
			Node.SelectedIndex := ITEM_ICON_THREADLOG2;
		end;
		}
		// •‰‰×‚ð‚©‚¯‚½‚­‚È‚¢‚Ì‚Å NewArrival ‚Ìƒ`ƒFƒbƒN‚ðs‚í‚È‚¢
		// ¦favItem.Item ƒvƒƒpƒeƒB‚Í dat ‚Ì“Ç‚Ýž‚Ý‚ð•K—v‚Æ‚·‚é
		Node.ImageIndex := ITEM_ICON_THREADLOG1;
		Node.SelectedIndex := ITEM_ICON_THREADLOG2;
		Node.Data := favItem;
	end;
end;

procedure TGikoForm.DeleteHistory( threadItem: TThreadItem );
var
	i: Integer;
begin
	for i := 0 to FHistoryList.Count - 1 do begin
		if threadItem.URL = TFavoriteThreadItem( FHistoryList.Items[i] ).URL then begin
			TFavoriteThreadItem( FHistoryList.Items[ i ] ).Free;
			FHistoryList.Delete(i);
            FHistoryList.Capacity := FHistoryList.Count;
			Break;
		end;
	end;
end;

procedure TGikoForm.ClearHistory;
var
	i : Integer;
begin
	//FHistoryList.Clear;

	try
		for i := FHistoryList.Count - 1 downto 0 do begin
			if TObject(FHistoryList[ i ]) is TFavoriteThreadItem then
            	TFavoriteThreadItem(FHistoryList[ i ]).Free
            else if TObject(FHistoryList[ i ]) is TFavoriteBoardItem then
                TFavoriteBoardItem(FHistoryList[ i ]).Free;

			//FHistoryList.Delete(i);
        end;
	except
	end;

	FHistoryList.Clear;
    FHistoryList.Capacity := FHistoryList.Count;

end;

procedure TGikoForm.SaveHistory;
var
	i, bound	: Integer;
	saveList	: TstringList;
begin

	saveList := TStringList.Create;
	try
		FHistoryList.Pack;
        FHistoryList.Capacity := FHistoryList.Count;
		saveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>');
		saveList.Add('<address>');
		bound := FHistoryList.Count - 1;
		for i := bound downto 0 do begin
			// title ‚Í¡‚Ì‚Æ‚±‚ëŽg‚Á‚Ä‚¢‚È‚¢
			saveList.Add(
				'<history url="' + HtmlEncode( TFavoriteThreadItem( FHistoryList[ i ] ).URL ) + '"' +
				' title="' + HtmlEncode( TFavoriteThreadItem( FHistoryList[ i ] ).Title ) + '"/>');
		end;
		saveList.Add('</address>');
		saveList.SaveToFile( GikoSys.GetConfigDir + 'History.xml' );
	finally
		saveList.Free;
	end;

end;

procedure TGikoForm.LoadHistory;
var
	i, bound		: Integer;
	fileName		: string;
	XMLDoc			: IXMLDocument;
	XMLNode			: IXMLNode;
	HistoryNode	: IXMLNode;
	s						: string;
	favItem			: TFavoriteThreadItem;
begin

	fileName := GikoSys.GetConfigDir + 'History.xml';

	if FileExists( fileName ) then begin
		try
            XMLDoc := IXMLDocument.Create;
			//XMLDoc := LoadXMLDocument(FileName);
            LoadXMLDocument(FileName, XMLDoc);
			try
				XMLNode := XMLDoc.DocumentElement;

				if XMLNode.NodeName = 'address' then begin
					bound := XMLNode.ChildNodes.Count - 1;
					for i := 0 to bound do begin
						HistoryNode := XMLNode.ChildNodes[i];
						if HistoryNode.NodeName = 'history' then begin
							//if FReadCount >= sl.Count then begin
								s := Trim(HistoryNode.Attributes['url']);
								if s <> '' then begin
									favItem := TFavoriteThreadItem.Create(
										s, HistoryNode.Attributes[ 'title' ] );
									if not AddHistory( favItem ) then
                                    	favItem.Free;
								end;
							//end;
						end;
					end;
				end;
			finally
				XMLDoc.Free;
			end;
		except
		end;
	end;

end;

procedure TGikoForm.ShowBBSTreeOld(
	inBBS : TBBS
);
var
	i, b		: Integer;
	item		: TMenuItem;
begin
	try
		FavoriteTreeView.Visible := False;
		FavoriteToolBar.Hide;
		TreeView.Visible := True;

		b := CabinetSelectPopupMenu.Items.Count - 1;
		for i := 0 to b do begin
			item := CabinetSelectPopupMenu.Items[ i ];
			if item is TBBSMenuItem then begin
				if TBBSMenuItem( item ).Data = inBBS then begin
					item.Checked := True;
					// CabinetMenu ?? CabinetSelectPopupMenu ??????????????
					CabinetMenu.Items[ i ].Checked := True;
					GikoSys.Setting.CabinetIndex := i;
					Continue;
				end;
			end;
			item.Checked := False;
			// CabinetMenu ?? CabinetSelectPopupMenu ??????????????
			CabinetMenu.Items[ i ].Checked := False;
		end;
		CabinetSelectToolButton.Caption := inBBS.Title;

		CabinetHistoryAction.Checked := False;
		CabinetFavoriteAction.Checked := False;

		if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS) then begin
			FTreeType := gtt2ch;
			HistoryToolBar.Hide;
			SetBoardTreeNode( inBBS );
			TreeView.Items.GetFirstNode.Expanded := True;				//?c???[?g?b?v???????J??
			//?c???[??g?b?v?????I????
			if GetActiveList = nil then
				TreeView.Selected := TreeView.Items[0]
			else begin
				for i := 0 to TreeView.Items.Count - 1 do begin
					if TreeView.Items[i].Data = GetActiveList then begin
						TreeView.Selected := TreeView.Items[i];
						Exit;
					end;
				end;
				TreeView.Selected := TreeView.Items[0]
			end;
		end;
	except
	end;

end;

procedure TGikoForm.ShowBBSTree(
	inBBS : TBBS
);
var
	i, b		: Integer;
	item		: TMenuItem;
begin

	try
		FavoriteTreeView.Visible := False;
		FavoriteToolBar.Hide;
		TreeView.Visible := True;

		b := CabinetSelectPopupMenu.Items.Count - 1;
		for i := 0 to b do begin
			item := CabinetSelectPopupMenu.Items[ i ];
			if item is TBBSMenuItem then begin
				if TBBSMenuItem( item ).Data = inBBS then begin
					item.Checked := True;
					// CabinetMenu ‚Í CabinetSelectPopupMenu ‚Æ“¯‚¶‚ÆŒˆ‚ß‚¤‚¿‚µ‚¿‚á‚¤
					CabinetMenu.Items[ i ].Checked := True;
					GikoSys.Setting.CabinetIndex := i;
					Continue;
				end;
			end;
			item.Checked := False;
			// CabinetMenu ‚Í CabinetSelectPopupMenu ‚Æ“¯‚¶‚ÆŒˆ‚ß‚¤‚¿‚µ‚¿‚á‚¤
			CabinetMenu.Items[ i ].Checked := False;
		end;
		CabinetSelectToolButton.Caption := inBBS.Title;

		CabinetHistoryAction.Checked := False;
		CabinetFavoriteAction.Checked := False;

		if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS) then begin
			FTreeType := gtt2ch;
			HistoryToolBar.Hide;
			SetBoardTreeNode( inBBS );
			TreeView.Items.GetFirstNode.Expanded := True;				//ƒcƒŠ[ƒgƒbƒv€–Ú‚¾‚¯‚ðŠJ‚­
			//ƒcƒŠ[‚Ìƒgƒbƒv€–Ú‚ð‘I‘ð‚·‚é
			if GetActiveList = nil then begin
				try
					TreeClick( TreeView.Items[0] );
				except
				end;
			end else begin
				for i := 0 to TreeView.Items.Count - 1 do begin
					if TreeView.Items[i].Data = GetActiveList then begin
						TreeClick( TreeView.Items[i] );
						Exit;
					end;
				end;
				TreeClick( TreeView.Items[0] );
			end;
		end;
	except
	end;

end;

procedure TGikoForm.ShowHistoryTree;
var
	i, b : Integer;
	item : TMenuItem;
begin
	if CabinetPanel.Visible then begin
		if FTreeType = gttHistory then begin
			CabinetVisible( False );
			CabinetHistoryAction.Checked := False;
		end else begin
			CabinetHistoryAction.Checked := True;
		end;
	end else begin
	 	CabinetVisible( True );
		CabinetHistoryAction.Checked := True;
	end;

	// BBS...BBS, History, Favorite
	GikoSys.Setting.CabinetIndex := CabinetSelectPopupMenu.Items.Count - 2;

	FavoriteTreeView.Visible := False;
	TreeView.Visible := True;

	CabinetBBSAction.Checked := False;
	CabinetFavoriteAction.Checked := False;

	if FTreeType <> gttHistory then begin
		b := CabinetSelectPopupMenu.Items.Count - 1;
		for i := 0 to b do begin
			item := CabinetSelectPopupMenu.Items[ i ];
			if item is TBBSMenuItem then begin
				item.Checked := False;
				// CabinetMenu ‚Í CabinetSelectPopupMenu ‚Æ“¯‚¶‚ÆŒˆ‚ß‚¤‚¿‚µ‚¿‚á‚¤
				CabinetMenu.Items[ i ].Checked := False;
			end;
		end;

		FTreeType := gttHistory;
		HistoryToolBar.Show;
		FavoriteToolBar.Hide;
		SetHistoryTreeNode;
		CabinetSelectToolButton.Caption := '—š—ðƒŠƒXƒg';
	end;
end;

procedure TGikoForm.SetHistoryTreeNode;
var
	i: Integer;
	Node: TTreeNode;
	Item: TFavoriteThreadItem;
begin
	TreeView.Items.BeginUpdate;
	try
		TreeView.Items.Clear;
		for i := 0 to FHistoryList.Count - 1 do begin
			Item := TFavoriteThreadItem(FHistoryList[i]);
			Node := TreeView.Items.Add(nil, Item.Title);
			{
			if Item.Item.NewArrival then begin
				Node.ImageIndex := ITEM_ICON_THREADNEW1;
				Node.SelectedIndex := ITEM_ICON_THREADNEW2;
			end else begin
				Node.ImageIndex := ITEM_ICON_THREADLOG1;
				Node.SelectedIndex := ITEM_ICON_THREADLOG2;
			end;
			}
			// •‰‰×‚ð‚©‚¯‚½‚­‚È‚¢‚Ì‚Å NewArrival ‚Ìƒ`ƒFƒbƒN‚ðs‚í‚È‚¢
			// ¦Item.Item ƒvƒƒpƒeƒB‚Í dat ‚Ì“Ç‚Ýž‚Ý‚ð•K—v‚Æ‚·‚é
			Node.ImageIndex := ITEM_ICON_THREADLOG1;
			Node.SelectedIndex := ITEM_ICON_THREADLOG2;
			Node.Data := Item;
		end;
	finally
		TreeView.Items.EndUpdate;
	end;
end;

procedure TGikoForm.SelectTreeNode(Item: TObject; CallEvent: Boolean);
var
	ChangeEvent: TTVChangedEvent;
	ChangingEvent: TTVChangingEvent;
	i: Integer;
	bbs : TBBS;
begin
	if Item is TCategory then
		bbs := TCategory( Item ).ParenTBBS
	else if Item is TBoard then
		bbs := TBoard( Item ).ParentCategory.ParenTBBS
	else
		bbs := nil;

	if (FTreeType = gtt2ch) and (FActiveBBS = bbs) then begin
		ChangeEvent := nil;
		ChangingEvent := nil;

		if not CallEvent then begin
			ChangeEvent := TreeView.OnChange;
			ChangingEvent := TreeView.OnChanging;
		end;
		try
			if not CallEvent then begin
				TreeView.OnChange := nil;
				TreeView.OnChanging := nil;
			end;
			//Application.ProcessMessages;
			for i := 0 to TreeView.Items.Count - 1 do begin
				if TreeView.Items[i].Data = Item then begin
					TreeView.Items[i].Selected := True;
					if CallEvent then
						TreeClick(TreeView.Items[i]);
					Break;
				end;
			end;
			//Application.ProcessMessages;
		finally
			if not CallEvent then begin
				TreeView.OnChange := ChangeEvent;
				TreeView.OnChanging := ChangingEvent;
			end;
		end;
	end else begin
		if GetActiveList is TBBS then begin
			for i := 0 to ListView.Columns.Count - 1 do
				GikoSys.Setting.BBSColumnWidth[i] := ListView.Column[i].Width;
		end else if GetActiveList is TCategory then begin
			for i := 0 to ListView.Columns.Count - 1 do
				GikoSys.Setting.CategoryColumnWidth[i] := ListView.Column[i].Width;
		end else if GetActiveList is TBoard then begin
			for i := 0 to ListView.Columns.Count - 1 do
				GikoSys.Setting.BoardColumnWidth[i] := ListView.Column[i].Width;
		end;

		if (Item is TBBS) or (Item is TCategory) then begin
			ListView.Columns.Clear;
			SetActiveList( Item );
		end else if Item is TBoard then begin
			if not TBoard( Item ).IsThreadDatRead then begin
				Screen.Cursor := crHourGlass;
				try
					if not TBoard( Item ).IsThreadDatRead then
						GikoSys.ReadSubjectFile(TBoard( Item ));
				finally
					Screen.Cursor := crDefault;
				end;
			end;
			SetActiveList( Item );
		end;

		if Item is TBoard then begin // not TCategory
			if GikoSys.Setting.ListOrientation = gloHorizontal then begin
				if GikoSys.Setting.ListWidthState = glsMax then begin
					BrowserMinAction.Execute;
					if GikoForm.Visible then
						ListView.SetFocus;
				end;
			end else begin
				if GikoSys.Setting.ListHeightState = glsMax then begin
					BrowserMinAction.Execute;
					if GikoForm.Visible then
						ListView.SetFocus;
				end;
			end;
		end;
	end;
end;

procedure TGikoForm.ListViewMouseDown(Sender: TObject;
	Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
	listItem		: TListItem;
	threadItem	: TThreadItem;
//	t: Cardinal;
begin
	case Button of
	mbMiddle:
		begin
			if not (GetActiveList is TBoard) then Exit;
			listItem := ListView.GetItemAt( X, Y );
			if listItem = nil then Exit;
			if not (TObject(listItem.Data) is TThreadItem) then Exit;

			threadItem := TThreadItem(ListItem.Data);
			InsertBrowserTab(threadItem, False);
			if threadItem.IsLogFile then
				ListView.UpdateItems(listItem.Index, listItem.Index);
		end;
	mbLeft:
		begin
            //‚±‚±‚ÅDblClickE‚í‚È‚¢‚ÆAClickƒCƒxƒ“ƒg‚ª—Dæ‚µ‚Ä‹N‚«‚Ä‚µ‚Ü‚¤‚Ì‚Å
			if (ssDouble in Shift) then
				ListDoubleClick(Shift)
			else
				ListClick;
		end;
	end;
{	if ssDouble in Shift then begin
		DoubleClickOccurred[Button] := True;
	end else begin
		DoubleClickOccurred[Button] := False;
		t := GetTickCount+GetDoubleClickTime;
		while GetTickCount < t do begin
			Application.ProcessMessages;
			if DoubleClickOccurred[Button] then
				Exit;
		end;
	end;

	if ssDouble in Shift then begin
		case Button of
			mbLeft: ListDoubleClick;
//			mbMiddle: ;
//			mbRight:	;
		end;
	end else begin
		case Button of
			mbLeft: ListClick;
//			mbMiddle: ;
//			mbRight:	;
		end;
	end;}
end;

procedure TGikoForm.ListClick;
var
	ListItem: TListItem;
	ThreadItem: TThreadItem;
begin
	if ListView.SelCount <> 1 then Exit;
	ListItem := ListView.Selected;
	if ListItem = nil then Exit;
	if not (TObject(ListItem.Data) is TThreadItem) then Exit;

	ThreadItem := TThreadItem(ListItem.Data);
	if ThreadItem.IsLogFile then begin
//		if AddHistory(ThreadItem) then
//		SetContent(ThreadItem);
		InsertBrowserTab(ThreadItem);
		ListView.UpdateItems(ListItem.Index, ListItem.Index);
	end else begin
//		SetContent(ThreadItem);
		InsertBrowserTab(ThreadItem);
	end;

	if GikoSys.Setting.BrowserAutoMaximize = gbmClick then begin
		if GikoSys.Setting.ListOrientation = gloHorizontal then begin
			if GikoSys.Setting.ListWidthState = glsMin then begin
				BrowserMaxAndFocusAction.Execute;
			end;
		end else begin
			if GikoSys.Setting.ListHeightState = glsMin then begin
				BrowserMaxAndFocusAction.Execute;
			end;
		end;
	end;
end;

procedure TGikoForm.ListDoubleClick(Shift: TShiftState);
var
	ThreadItem: TThreadItem;
	shiftDown: Boolean;
begin
	shiftDown := (ssShift in Shift);

	if ListView.Selected = nil then Exit;

	if TObject(ListView.Selected.Data) is TCategory then begin
		SelectTreeNode(ListView.Selected.Data, True);
//		TreeView.Selected.Expanded := True;
//		TreeView.Selected.Item[ListView.Selected.Index].Selected := True;
		//TreeViewChange(nil, TreeView.Selected);
	end else if TObject(ListView.Selected.Data) is TBoard then begin
		SelectTreeNode(ListView.Selected.Data, True);
//		TreeView.Selected.Expanded := True;
//		TreeView.Selected.Item[ListView.Selected.Index].Selected := True;
		//TreeViewChange(nil, TreeView.Selected);
	end else if TObject(ListView.Selected.Data) is TThreadItem then begin
		//if TObject(ListView.Selected.Data) is TThreadItem then begin
			Application.ProcessMessages;
			ThreadItem := TThreadItem(ListView.Selected.Data);
			DownloadContent(ThreadItem, shiftDown);
		//end;
		
		if GikoSys.Setting.BrowserAutoMaximize = gbmDoubleClick then begin
			if GikoSys.Setting.ListOrientation = gloHorizontal then begin
				if GikoSys.Setting.ListWidthState = glsMin then begin
					BrowserMaxAndFocusAction.Execute;
				end;
			end else begin
				if GikoSys.Setting.ListHeightState = glsMin then begin
					BrowserMaxAndFocusAction.Execute;
				end;
			end;
		end;
	end;
end;
procedure TGikoForm.BrowserMovement(const AName: string; BrowserRecord: TBrowserRecord);
var
	top: Integer;
	item: OleVariant;
	nm: OleVariant;
	activeBrower :TWebBrowser;
begin
//	OleVariant(Browser.Document).parentWindow.location.hash := AName;

	while (BrowserRecord.Browser.ReadyState <> READYSTATE_COMPLETE) and
				(BrowserRecord.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
		Application.ProcessMessages;
	end;

	// Access Violation ‚ª‹N‚«‚éŽ–‚ª‚ ‚é‚Ì‚Å¡Œã—vƒ`ƒFƒbƒN
	if(BrowserRecord <> nil) and (BrowserRecord.FBrowser <> nil) then begin
		activeBrower := BrowserRecord.FBrowser;
		try
			top := 0;
			nm := AName;
			item := OleVariant( activeBrower.Document as IHTMLDocument2).anchors.item(nm);
			repeat
				top := top + item.offsetTop;
				item := item.offsetParent;
			until AnsiCompareText(item.tagName, 'body' ) = 0;

			OleVariant(activeBrower.Document as IHTMLDocument2).body.scrollTop := top;
		except
		end;
	end;
end;

procedure TGikoForm.BrowserMovement(const AName: string);
var
	top: Integer;
	item: OleVariant;
	nm: OleVariant;
	activeBrower :TWebBrowser;
begin
//	OleVariant(Browser.Document).parentWindow.location.hash := AName;
	{
	while (Browser.ReadyState <> READYSTATE_COMPLETE) and
				(Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
		Application.ProcessMessages;
	end;
	}
	// Access Violation ‚ª‹N‚«‚éŽ–‚ª‚ ‚é‚Ì‚Å¡Œã—vƒ`ƒFƒbƒN
	if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0) then begin
		activeBrower := FActiveContent.Browser;
		try
			top := 0;
			nm := AName;
			item := OleVariant( activeBrower.Document as IHTMLDocument2).anchors.item(nm);
			repeat
				top := top + item.offsetTop;
				item := item.offsetParent;
			until AnsiCompareText(item.tagName, 'body' ) = 0;

			OleVariant(activeBrower.Document as IHTMLDocument2).body.scrollTop := top;
		except
		end;
	end;
end;

procedure TGikoForm.TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
begin
	if TObject(Node.Data) is TBBS then begin
		TBBS(Node.Data).NodeExpand := False;
	end else if TObject(Node.Data) is TCategory then begin
		TCategory(Node.Data).NodeExpand := False;
	end else if TObject(Node.Data) is TBoard then begin
		TBoard(Node.Data).NodeExpand := False;
	end;
end;

procedure TGikoForm.MessageListViewResize(Sender: TObject);
begin
//	MessageListView.Column[0].Width := MessageListView.ClientWidth - 16;
end;

procedure TGikoForm.SelectListItem(List: TList);
var
//	TmpTreeNode: TTreeNode;
	TmpListItem: TListItem;
begin
	List.Clear;
	TmpListItem := ListView.Selected;
	while TmpListItem <> nil do begin
		List.Add(TmpListItem.Data);
		TmpListItem := ListView.GetNextItem(TmpListItem, sdAll, [isSelected]);
	end;
    
end;

procedure TGikoForm.ExitActionExecute(Sender: TObject);
begin
	Close;
end;

procedure TGikoForm.AllSelectActionExecute(Sender: TObject);
begin
	ListViewAllSelect;
end;

procedure TGikoForm.StdToolBarVisibleActionExecute(Sender: TObject);
var
	CoolBand: TCoolBand;
begin
	CoolBand := GetCoolBand(MainCoolBar, StdToolBar);
	if CoolBand = nil then
		Exit;
	GikoSys.Setting.StdToolBarVisible := StdToolBarVisibleAction.Checked;
	CoolBand.Visible := GikoSys.Setting.StdToolBarVisible;
//	StdToolBar.Visible := StdToolBarVisibleAction.Checked;
//	AnimePanel.Visible := StdToolBar.Visible or ListToolBar.Visible;

	//StdToolBarVisibleAction.Checked := GikoSys.Setting.StdToolBarVisible;
	StdToolBarVisiblePMenu.Checked := GikoSys.Setting.StdToolBarVisible;
end;

procedure TGikoForm.AddressBarVisibleActionExecute(Sender: TObject);
var
	CoolBand: TCoolBand;
begin
	CoolBand := GetCoolBand(MainCoolBar, AddressToolBar);
	if CoolBand = nil then
		Exit;
	GikoSys.Setting.AddressBarVisible := AddressBarVisibleAction.Checked;
	CoolBand.Visible := GikoSys.Setting.AddressBarVisible;
	//AddressBarVisibleAction.Checked := GikoSys.Setting.AddressBarVisible;
	AddressToolBarVisiblePMenu.Checked := GikoSys.Setting.AddressBarVisible;
end;

procedure TGikoForm.LinkBarVisibleActionExecute(Sender: TObject);
var
	CoolBand: TCoolBand;
begin
	CoolBand := GetCoolBand(MainCoolBar, LinkToolBar);
	if CoolBand = nil then
		Exit;
	GikoSys.Setting.LinkBarVisible := LinkBarVisibleAction.Checked;
	CoolBand.Visible := GikoSys.Setting.LinkBarVisible;
				//LinkBarVisibleAction.Checked := GikoSys.Setting.LinkBarVisible;
				LinkToolBarVisiblePMenu.Checked := GikoSys.Setting.LinkBarVisible;
end;

procedure TGikoForm.ListToolBarVisibleActionExecute(Sender: TObject);
var
	CoolBand: TCoolBand;
begin
	CoolBand := GetCoolBand(ListCoolBar, ListToolBar);
	if CoolBand = nil then
		Exit;
	CoolBand.Visible := ListToolBarVisibleAction.Checked;
//	ListToolBar.Visible := ListToolBarVisibleAction.Checked;
//	AnimePanel.Visible := StdToolBar.Visible or ListToolBar.Visible;
	GikoSys.Setting.ListToolBarVisible := ListToolBarVisibleAction.Checked;
end;

procedure TGikoForm.ListNameBarVisibleActionExecute(Sender: TObject);
var
	CoolBand: TCoolBand;
begin
	CoolBand := GetCoolBand(ListCoolBar, ListNameToolBar);
	if CoolBand = nil then
		Exit;
	CoolBand.Visible := ListNameBarVisibleAction.Checked;
	GikoSys.Setting.ListNameBarVisible := ListNameBarVisibleAction.Checked;
end;

procedure TGikoForm.BrowserToolBarVisibleActionExecute(Sender: TObject);
var
	CoolBand: TCoolBand;
begin
	CoolBand := GetCoolBand(BrowserCoolBar, BrowserToolBar);
	if CoolBand = nil then
		Exit;
	CoolBand.Visible := BrowserToolBarVisibleAction.Checked;
//	BrowserToolBar.Visible := BrowserToolBarVisibleAction.Checked;
	GikoSys.Setting.BrowserToolBarVisible := BrowserToolBarVisibleAction.Checked;
end;

procedure TGikoForm.BrowserNameBarVisibleActionExecute(Sender: TObject);
var
	CoolBand: TCoolBand;
begin
	CoolBand := GetCoolBand(BrowserCoolBar, BrowserNameToolBar);
	if CoolBand = nil then
		Exit;
	CoolBand.Visible := BrowserNameBarVisibleAction.Checked;
	GikoSys.Setting.BrowserNameBarVisible := BrowserNameBarVisibleAction.Checked;
end;

procedure TGikoForm.MsgBarVisibleActionExecute(Sender: TObject);
begin
	MessageSplitter.Visible := MsgBarVisibleAction.Checked;
	MessagePanel.Top := MessageSplitter.Top + MessageSplitter.Height;
	MessageSplitter.Top := MessagePanel.Top + 1;
	MessagePanel.Visible := MsgBarVisibleAction.Checked;
	GikoSys.Setting.MessageBarVisible := MsgBarVisibleAction.Checked;
end;

procedure TGikoForm.StatusBarVisibleActionExecute(Sender: TObject);
begin
	StatusBar.Visible := StatusBarVisibleAction.Checked;
	GikoSys.Setting.StatusBarVisible := StatusBarVisibleAction.Checked;
end;

procedure TGikoForm.IconStyleExecute(Sender: TObject);
begin
	case ListView.ViewStyle of
		vsIcon: SmallIconAction.Execute;
		vsSmallIcon: ListIconAction.Execute;
		vsList: DetailIconAction.Execute;
		vsReport: LargeIconAction.Execute;
	end;
end;

procedure TGikoForm.LargeIconActionExecute(Sender: TObject);
begin
	ListView.ViewStyle := vsIcon;
	LargeIconAction.Checked := True;
end;

procedure TGikoForm.SmallIconActionExecute(Sender: TObject);
begin
	ListView.ViewStyle := vsSmallIcon;
	SmallIconAction.Checked := True;
end;

procedure TGikoForm.ListIconActionExecute(Sender: TObject);
begin
	ListView.ViewStyle := vsList;
	ListIconAction.Checked := True;
end;

procedure TGikoForm.DetailIconActionExecute(Sender: TObject);
begin
	ListView.ViewStyle := vsReport;
	DetailIconAction.Checked := True;
end;

procedure TGikoForm.SearchActionExecute(Sender: TObject);
var
	chk: TObject;
begin

	if FSearchDialog = nil then begin
		if (GikoForm.GetActiveList is TCategory) or (GikoForm.GetActiveList is TBoard) then
			chk := GikoForm.GetActiveList
		else
			chk := nil;

		FSearchDialog := TSearchDialog.Create(Self, chk);
		FSearchDialog.SearchComboBox.Items.Assign( GikoSys.Setting.SelectTextList );
	end;

	try
		FSearchDialog.Show;
	except
	end;
	
end;

procedure TGikoForm.OptionActionExecute(Sender: TObject);
var
	Dlg: TOptionDialog;
begin
	Dlg := TOptionDialog.Create(Self);
	try
		Dlg.ShowModal;
	finally
		Dlg.Release;
	end;
end;

procedure TGikoForm.GikoNaviWebPageActionExecute(Sender: TObject);
const
	URL_GIKONAVI: string = 'http://gikonavi.sourceforge.jp/';
begin
	GikoSys.OpenBrowser(URL_GIKONAVI, gbtAuto);
end;

procedure TGikoForm.MonazillaWebPageActionExecute(Sender: TObject);
const
	URL_MONAZILLA: string = 'http://www.monazilla.org/';
begin
	GikoSys.OpenBrowser(URL_MONAZILLA, gbtAuto);
end;

procedure TGikoForm.BBS2chWebPageActionExecute(Sender: TObject);
const
	URL_2ch: string = 'http://www.2ch.net/';
begin
	GikoSys.OpenBrowser(URL_2ch, gbtAuto);
end;

procedure TGikoForm.GikoFolderOpenActionExecute(Sender: TObject);
begin
//	GikoSys.OpenBrowser(GikoSys.GetAppDir, gbtIE);
	GikoSys.CreateProcess('explorer.exe', '/e,"' + GikoSys.GetAppDir + '"');
end;

procedure TGikoForm.AboutActionExecute(Sender: TObject);
var
	Dlg: TAboutDialog;
begin
	Dlg := TAboutDialog.Create(Self);
	try
		Dlg.ShowModal;
	finally
		Dlg.Release;
	end;
end;

procedure TGikoForm.CabinetHistoryActionExecute(Sender: TObject);
begin
	ShowHistoryTree;
end;

procedure	TGikoForm.CabinetVisible( isVisible : Boolean );
begin
	TreeSplitter.Visible := isVisible;
	CabinetPanel.Visible := isVisible;
	CabinetVisibleAction.Checked := isVisible;
end;

procedure TGikoForm.CabinetVisibleActionExecute(Sender: TObject);
begin
	case FTreeType of
	gttHistory:		CabinetHistoryAction.Execute;
	gttFavorite:	CabinetFavoriteAction.Execute;
	else
		CabinetBBSAction.Execute;
	end;
end;

procedure TGikoForm.AllItemActionExecute(Sender: TObject);
begin
	try
		if ViewType <> gvtAll then
			SetListViewType(gvtAll);
		AllItemAction.Checked := True;
		LogItemAction.Checked := False;
		NewItemAction.Checked := False;
		//SelectItemAction.Checked := False;
		// SelectComboBox ‚Ì—š—ð‚ðXV‚µ‚Ä‚¨‚­
		ModifySelectList;
		// SelectComboBox ‚Ì’l‚ðƒNƒŠƒA
		if SelectComboBox.Parent <> nil then begin
			SelectComboBox.Text := SELECTCOMBOBOX_NAME;
			SelectComboBox.Color := SELECTCOMBOBOX_COLOR;
			ListView.SetFocus;
		end;
	except
	end;
end;

procedure TGikoForm.LogItemActionExecute(Sender: TObject);
begin
	try
		if ViewType <> gvtLog then
			SetListViewType(gvtLog);
		AllItemAction.Checked := False;
		LogItemAction.Checked := True;
		NewItemAction.Checked := False;
		//SelectItemAction.Checked := False;
		// SelectComboBox ‚Ì—š—ð‚ðXV‚µ‚Ä‚¨‚­
		ModifySelectList;
		// SelectComboBox ‚Ì’l‚ðƒNƒŠƒA
		if SelectComboBox.Parent <> nil then begin
			SelectComboBox.Text := SELECTCOMBOBOX_NAME;
			SelectComboBox.Color := SELECTCOMBOBOX_COLOR;
			ListView.SetFocus;
		end;
	except
	end;
end;

procedure TGikoForm.NewItemActionExecute(Sender: TObject);
begin
	try

		if ViewType <> gvtNew then
			SetListViewType(gvtNew);
		AllItemAction.Checked := False;
		LogItemAction.Checked := False;
		NewItemAction.Checked := True;
		//SelectItemAction.Checked := False;
		// SelectComboBox ‚Ì—š—ð‚ðXV‚µ‚Ä‚¨‚­
		ModifySelectList;
		// SelectComboBox ‚Ì’l‚ðƒNƒŠƒA
		if SelectComboBox.Parent <> nil then begin
			SelectComboBox.Text := SELECTCOMBOBOX_NAME;
			SelectComboBox.Color := SELECTCOMBOBOX_COLOR;
			ListView.SetFocus;
		end;
	except
	end;
end;

procedure TGikoForm.SelectItemActionExecute(Sender: TObject);
var
	idx: Integer;
	Dlg: TListSelectDialog;
begin
	try
		if SelectComboBox.Parent <> nil then begin
			if SelectComboBox.Left + SelectComboBox.Width < ListToolBar.Width then begin
				// SelectComboBox ‚ª‚ ‚éê‡‚ÍƒtƒH[ƒJƒX‚ðˆÚ‚·
				SelectComboBox.SetFocus;
				exit;
			end;
		end;
	except
	end;

	if SelectComboBox.Text = SELECTCOMBOBOX_NAME then begin
		SelectComboBox.Text := '';
		SelectComboBox.Color := clWindow;
	end;

	AllItemAction.Checked := False;
	LogItemAction.Checked := False;
	NewItemAction.Checked := False;
	//SelectItemAction.Checked := True;
	ModifySelectList;
	Dlg := TListSelectDialog.Create(Self);
	try
		Dlg.SelectComboBox.Items.Assign(GikoSys.Setting.SelectTextList);
		Dlg.SelectComboBox.Text := SelectComboBox.Text;
		Dlg.ShowModal;
		if Dlg.ModalResult = mrCancel then begin
			if Length( SelectComboBox.Text ) = 0 then begin
				AllItemAction.Checked := True;
				SelectComboBox.Text := SELECTCOMBOBOX_NAME;
				SelectComboBox.Color := SELECTCOMBOBOX_COLOR;
			end;

			if GetActiveList is TBoard then
				SetListViewType(gvtUser, TBoard(GetActiveList).ParentCategory.ParenTBBS.SelectText , Dlg.KubetsuCheckBox.Checked);
		end else begin
			idx := GikoSys.Setting.SelectTextList.IndexOf(Dlg.SelectComboBox.Text);
			if idx <> -1 then
				GikoSys.Setting.SelectTextList.Delete(idx);
			GikoSys.Setting.SelectTextList.Insert(0, Dlg.SelectComboBox.Text);
			while Dlg.SelectComboBox.Items.Count > 100 do begin
				Dlg.SelectComboBox.Items.Delete(Dlg.SelectComboBox.Items.Count - 1);
			end;

			if Length( Dlg.SelectComboBox.Text ) = 0 then begin
				SelectComboBox.Text := SELECTCOMBOBOX_NAME;
				SelectComboBox.Color := SELECTCOMBOBOX_COLOR;
			end else begin
				SelectComboBox.Text := Dlg.SelectComboBox.Text;
				SelectComboBox.Color := clWindow;
			end;
			SetListViewType(gvtUser, Dlg.SelectComboBox.Text, Dlg.KubetsuCheckBox.Checked);
		end;
	finally
		Dlg.Release;
	end;
end;

procedure TGikoForm.ListNumberVisibleActionExecute(Sender: TObject);
begin
	GikoSys.Setting.ListViewNo := ListNumberVisibleAction.Checked;
	ListView.Refresh;
end;

procedure TGikoForm.UpFolderActionExecute(Sender: TObject);
begin
	if GetActiveList is TBoard then begin
//		if FTreeType = gtt2ch then
			SelectTreeNode(TBoard(GetActiveList).ParentCategory, True);
		//SetActiveList(TBoard(GetActiveList).ParentCategory);
	end else if GetActiveList is TCategory then begin
//		if FTreeType = gtt2ch then
			SelectTreeNode(TCategory(GetActiveList).ParenTBBS, True);
		//SetActiveList(TCategory(GetActiveList).ParenTBBS);
	end;
//	if TreeView.Selected = nil then Exit;
//	if TreeView.Selected.Level = 0 then Exit;
//	TreeView.Selected.Parent.Selected := True;
end;

procedure TGikoForm.RoundActionExecute(Sender: TObject);
var
	Dlg: TRoundDialog;
begin
	Dlg := TRoundDialog.Create(Self);
	try
		Dlg.ShowModal;
	finally
		Dlg.Release;
	end;
end;

procedure TGikoForm.StopActionExecute(Sender: TObject);
begin
	FControlThread.DownloadAbort;
	if FWorkCount <> 0 then FWorkCount := 0;
	try
		Animate.Active := False;
	except
	end;
	Screen.Cursor := crDefault;
end;

procedure TGikoForm.MsgBarCloseActionExecute(Sender: TObject);
begin
//	MessagePanel.Visible := False;
//	MessageSplitter.Visible := False;
//	MsgBarVisibleAction.Checked := False;
	MsgBarVisibleAction.Execute;
end;

procedure TGikoForm.BrowserMaxActionExecute(Sender: TObject);
begin
	if GikoSys.Setting.ListOrientation = gloHorizontal then begin
		case GikoSys.Setting.ListWidthState of
			glsMax: begin
				//’Êí•\Ž¦‚É‚·‚é
				ViewPanel.Width := FBrowserSizeWidth;
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
				GikoSys.Setting.ListWidthState := glsNormal;
			end;
			glsMin, glsNormal: begin
				//Å‘å•\Ž¦‚É‚·‚é
				if GikoSys.Setting.ListWidthState = glsNormal then
					FBrowserSizeWidth := ViewPanel.Width;
				ViewPanel.Width := 1;
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_NORMAL;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
				GikoSys.Setting.ListWidthState := glsMax;
			end;
		end;
	end else begin
		case GikoSys.Setting.ListHeightState of
			glsMax: begin
				//’Êí•\Ž¦‚É‚·‚é
				ViewPanel.Height := FBrowserSizeHeight;
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
				GikoSys.Setting.ListHeightState := glsNormal;
			end;
			glsMin, glsNormal: begin
				//Å‘å•\Ž¦‚É‚·‚é
				if GikoSys.Setting.ListHeightState = glsNormal then
					FBrowserSizeHeight := ViewPanel.Height;
				ViewPanel.Height := 1;
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_NORMAL;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
				GikoSys.Setting.ListHeightState := glsMax;
			end;
		end;
	end;
//	Mouse.CursorPos := BrowserSizeButton.ClientToScreen(Point(
//												System.Round(BrowserToolBar.ButtonWidth div 2),
//												System.Round(BrowserToolBar.ButtonHeight div 2)));
	//BrowserTab.OnChange(nil);
end;

procedure TGikoForm.BrowserMinActionExecute(Sender: TObject);
begin

	if GikoSys.Setting.ListOrientation = gloHorizontal then begin
		case GikoSys.Setting.ListWidthState of
			glsMax, glsNormal: begin
				//Å¬•\Ž¦‚É‚·‚é
				if GikoSys.Setting.ListWidthState = glsNormal then
					FBrowserSizeWidth := ViewPanel.Width;
				ViewPanel.Width := ThreadMainPanel.Width - 80;
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_NORMAL;
				GikoSys.Setting.ListWidthState := glsMin;
			end;
			glsMin: begin
				//’Êí•\Ž¦‚É‚·‚é
				ViewPanel.Width := FBrowserSizeWidth;
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
				GikoSys.Setting.ListWidthState := glsNormal;
			end;
		end;
	end else begin
		case GikoSys.Setting.ListHeightState of
			glsMax, glsNormal: begin
				//Å¬•\Ž¦‚É‚·‚é
				if GikoSys.Setting.ListHeightState = glsNormal then
					FBrowserSizeHeight := ViewPanel.Height;
				ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_NORMAL;
				GikoSys.Setting.ListHeightState := glsMin;
			end;
			glsMin: begin
				//’Êí•\Ž¦‚É‚·‚é
				ViewPanel.Height := FBrowserSizeHeight;
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
				GikoSys.Setting.ListHeightState := glsNormal;
			end;
		end;
	end;
end;

procedure TGikoForm.ScrollTopActionExecute(Sender: TObject);
begin
	BrowserMovement('top');
end;

procedure TGikoForm.ScrollLastActionExecute(Sender: TObject);
begin
	BrowserMovement('bottom');
end;

procedure TGikoForm.ScrollNewActionExecute(Sender: TObject);
begin
	BrowserMovement('new');
end;

procedure TGikoForm.ScrollKokoActionExecute(Sender: TObject);
begin
	BrowserMovement('koko');
end;

procedure TGikoForm.EditorActionExecute(Sender: TObject);
var
	Editor: TEditorForm;
	Item: TThreadItem;
	msg: string;
begin
	Item := GetActiveContent;
	if Item = nil then Exit;
	Editor := TEditorForm.Create(Self);
	Editor.SetThreadItem(Item);
    GikoSys.LoadEditorKeySetting(Editor.ActionList);
	Editor.Show;
	Editor.BodyEdit.SetFocus;
end;

procedure TGikoForm.IEActionExecute(Sender: TObject);
begin
	ShowThreadAction.Execute;
end;

procedure TGikoForm.ShowThreadActionExecute(Sender: TObject);
var
	ThreadItem: TThreadItem;
begin
	ThreadItem := GetActiveContent;
	if ThreadItem = nil then Exit;
	GikoSys.OpenBrowser(ThreadItem.URL, gbtAuto);
end;

procedure TGikoForm.ShowBoardActionExecute(Sender: TObject);
var
	ThreadItem: TThreadItem;
begin
	ThreadItem := GetActiveContent;
	if ThreadItem = nil then Exit;
	GikoSys.OpenBrowser(ThreadItem.ParentBoard.URL, gbtAuto);
end;

//(Thread)URL‚ðƒRƒs[
procedure TGikoForm.URLCopyActionExecute(Sender: TObject);
var
	s: string;
begin
	s := '';
	if TObject(GetActiveContent) is TBoard then
		s := s + TBoard(GetActiveContent).URL + #13#10
	else if TObject(GetActiveContent) is TThreadItem then
		s := s + TThreadItem(GetActiveContent).URL + #13#10;
	if s <> '' then
		Clipboard.AsText := s;
end;

//(Thread)ƒXƒŒƒbƒh–¼‚ðƒRƒs[
procedure TGikoForm.NameCopyActionExecute(Sender: TObject);
var
	s: string;
begin
	s := '';
	if TObject(GetActiveContent) is TBoard then
		s := s + TBoard(GetActiveContent).Title + #13#10
	else if TObject(GetActiveContent) is TThreadItem then
		s := s + TThreadItem(GetActiveContent).Title + #13#10;
	if s <> '' then
		Clipboard.AsText := s;
end;

//(Thread)ƒXƒŒƒbƒh–¼‚ÆURL‚ðƒRƒs[
procedure TGikoForm.NameURLCopyActionExecute(Sender: TObject);
var
	s: string;
begin
	s := '';
	if TObject(GetActiveContent) is TBoard then
		s := s + TBoard(GetActiveContent).Title + #13#10 + TBoard(GetActiveContent).URL + #13#10
	else if TObject(GetActiveContent) is TThreadItem then
		s := s + TThreadItem(GetActiveContent).Title + #13#10 + TThreadItem(GetActiveContent).URL + #13#10;
	if s <> '' then
		Clipboard.AsText := s;
end;

procedure TGikoForm.ItemReloadActionExecute(Sender: TObject);
var
	ThreadItem: TThreadItem;
	shiftDown: Boolean;
begin
	ThreadItem := GetActiveContent;
	shiftDown := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
	if ThreadItem <> nil then
		DownloadContent(ThreadItem, shiftDown);
end;

procedure TGikoForm.SelectListReloadActionExecute(Sender: TObject);
var
	i: Integer;
	List: TList;
	msg: string;
	shiftDown: Boolean;
begin
	shiftDown := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
	if GetActiveList is TCategory then begin
		List := TList.Create;
		try
			SelectListItem(List);
			if List.Count > 5 then begin
				msg := '5ŒÂˆÈã‚ÍŽw’è‚Å‚«‚Ü‚¹‚ñ' + #13#10
						 + '‚Q‚¿‚á‚ñ‚Ë‚é•‰‰×ŒyŒ¸‚É‚²‹¦—Í‚­‚¾‚³‚¢';
				MsgBox(Handle, msg, 'Œx', MB_ICONEXCLAMATION);
				Exit;
			end;
			for i := 0 to List.Count - 1 do begin
				if TObject(List[i]) is TBoard then
					DownloadList(TBoard(List[i]), shiftDown);
			end;
		finally
			List.Free;
		end;
	end else if GetActiveList is TBoard then begin
		DownloadList(TBoard(GetActiveList), shiftDown);
	end;
end;

procedure TGikoForm.SelectThreadReloadActionExecute(Sender: TObject);
var
	List: TList;
	i: Integer;
	msg: string;
	shiftDown: Boolean;
begin
	shiftDown := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
	List := TList.Create;
	try
		SelectListItem(List);
		if List.Count > 10 then begin
			msg := '10ŒÂˆÈã‚ÍŽw’è‚Å‚«‚Ü‚¹‚ñ' + #13#10
					 + '‚Q‚¿‚á‚ñ‚Ë‚é•‰‰×ŒyŒ¸‚É‚²‹¦—Í‚­‚¾‚³‚¢';
			MsgBox(Handle, msg, 'Œx', MB_ICONEXCLAMATION);
			Exit;
		end;
		for i := 0 to List.Count - 1 do begin
			if TObject(List[i]) is TThreadItem then
				DownloadContent(TThreadItem(List[i]), shiftDown);
		end;
	finally
		List.Free;
	end;
end;

procedure TGikoForm.SelectListReloadActionUpdate(Sender: TObject);
begin
	if (GetActiveList is TCategory) and (ListView.SelCount > 0) then
		SelectListReloadAction.Enabled := True
	else if GetActiveList is TBoard then
		SelectListReloadAction.Enabled := True
	else
		SelectListReloadAction.Enabled := False;
end;

procedure TGikoForm.SelectThreadReloadActionUpdate(Sender: TObject);
begin
	if (GetActiveList is TBoard) and (ListView.SelCount > 0) then
		SelectThreadReloadAction.Enabled := True
	else
		SelectThreadReloadAction.Enabled := False;
end;

procedure TGikoForm.AllItemActionUpdate(Sender: TObject);
begin
	AllItemAction.Enabled := (GetActiveList is TBoard);
end;

procedure TGikoForm.LogItemActionUpdate(Sender: TObject);
begin
	LogItemAction.Enabled := (GetActiveList is TBoard);
end;

procedure TGikoForm.NewItemActionUpdate(Sender: TObject);
begin
	NewItemAction.Enabled := (GetActiveList is TBoard);
end;

procedure TGikoForm.SelectItemActionUpdate(Sender: TObject);
begin
	SelectItemAction.Enabled := (GetActiveList is TBoard);
end;

procedure TGikoForm.UpFolderActionUpdate(Sender: TObject);
begin
	UpFolderAction.Enabled := not (GetActiveList is TBBS);
end;

procedure TGikoForm.ThreadEditorActionUpdate(Sender: TObject);
begin
	ThreadEditorAction.Enabled := (GetActiveList is TBoard);
end;

procedure TGikoForm.FormResize(Sender: TObject);
var
	doc						: Variant;
begin
	MessageListView.Column[0].Width := MessageListView.ClientWidth - 32;
	MainCoolBar.Width := TopPanel.Width - TopRightPanel.Width;

	if GikoSys.Setting.ListOrientation = gloHorizontal then begin
		if GikoSys.Setting.ListWidthState = glsMin then begin
			// Å¬•\Ž¦‚É‚·‚é
			ViewPanel.Width := ThreadMainPanel.Width - 80;
		end;
	end else begin
		if GikoSys.Setting.ListHeightState = glsMin then begin
			// Å¬•\Ž¦‚É‚·‚é
			ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
		end;
	end;

	if FIsMinimize = mtMinimized then begin
		if FActiveContent <> nil then begin
			//Application.ProcessMessages;
			doc := Idispatch( olevariant(FActiveContent.Browser.ControlInterface).Document) as IHTMLDocument2;
			doc.Body.ScrollTop := FActiveContent.Thread.ScrollTop;
			FIsMinimize := mtNone;
		end;
	end;

	FIsIgnoreResize := True;
	PostMessage( Handle, USER_RESIZED, 0, 0 );
end;

procedure TGikoForm.ScrollTopActionUpdate(Sender: TObject);
begin
	ScrollTopAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
end;

procedure TGikoForm.ScrollLastActionUpdate(Sender: TObject);
begin
	ScrollLastAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
end;

procedure TGikoForm.ScrollNewActionUpdate(Sender: TObject);
begin
	ScrollNewAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
end;

procedure TGikoForm.ScrollKokoActionUpdate(Sender: TObject);
begin
	ScrollKokoAction.Enabled := (GetActiveContent <> nil)
													and (GetActiveContent.IsLogFile)
													and (GetActiveContent.Kokomade <> -1);

end;

procedure TGikoForm.EditorActionUpdate(Sender: TObject);
begin
	EditorAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.IEActionUpdate(Sender: TObject);
begin
	IEAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.ShowThreadActionUpdate(Sender: TObject);
begin
	ShowThreadAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.ShowBoardActionUpdate(Sender: TObject);
begin
	ShowBoardAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.ItemReloadActionUpdate(Sender: TObject);
begin
	ItemReloadAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.URLCopyActionUpdate(Sender: TObject);
begin
	URLCopyAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.NameCopyActionUpdate(Sender: TObject);
begin
	NameCopyAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.NameURLCopyActionUpdate(Sender: TObject);
begin
	NameURLCopyAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.BrowserTabCloseActionUpdate(Sender: TObject);
begin
	BrowserTabCloseAction.Enabled := (BrowserTab.Tabs.Count > 0);
end;

procedure TGikoForm.NotSelectTabCloseActionUpdate(Sender: TObject);
begin
	NotSelectTabCloseAction.Enabled := (BrowserTab.Tabs.Count > 1);
end;

procedure TGikoForm.AllTabCloseActionUpdate(Sender: TObject);
begin
	AllTabCloseAction.Enabled := (BrowserTab.Tabs.Count > 0);
end;

procedure TGikoForm.ActiveLogDeleteActionUpdate(Sender: TObject);
begin
	ActiveLogDeleteAction.Enabled := GetActiveContent <> nil;
end;

procedure TGikoForm.LogDeleteActionExecute(Sender: TObject);
const
	DEL_MSG = 'ƒƒOƒtƒ@ƒCƒ‹‚ðíœ‚µ‚Ü‚·B‚æ‚ë‚µ‚¢‚Å‚·‚©H';
	DEL_TITLE = 'íœŠm”F';
var
	ThreadItem: TThreadItem;
	TmpListItem: TListItem;
	List: TList;
	i: Integer;
begin
	List := TList.Create;
	try
		TmpListItem := ListView.Selected;
		while TmpListItem <> nil do begin
			if TObject(TmpListItem.Data) is TThreadItem then begin
				ThreadItem := TThreadItem(TmpListItem.Data);
				if ThreadItem.IsLogFile then
					List.Add(ThreadItem);
			end;
			TmpListItem := ListView.GetNextItem(TmpListItem, sdAll, [isSelected]);
		end;

		if GikoSys.Setting.DeleteMsg and (List.Count > 0) then begin
			if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) <> IDYES then
				Exit;
		end;

		for i := 0 to List.Count - 1 do begin
			ThreadItem := TThreadItem(List[i]);
			DeleteHistory(ThreadItem);
			DeleteTab(ThreadItem);
			ThreadItem.DeleteLogFile;
		end;
		ListView.Refresh;
	finally
		List.Free;
	end;
end;
procedure TGikoForm.DeleteTab(BrowserRecord: TBrowserRecord);
var
	i, j, idx: Integer;
	doc: Variant;
begin
	idx := BrowserTab.TabIndex;
	FTabHintIndex := -1;
	for i := 0 to BrowserTab.Tabs.Count - 1 do begin
		if TBrowserRecord(BrowserTab.Tabs.Objects[i]) = BrowserRecord then begin
			BrowserTab.Tabs.BeginUpdate;
			try
				if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
					doc := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser.Document;
					TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := doc.Body.ScrollTop;
				end;
			except
				TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := 0;
			end;
			if( FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[i]) ) then
				FActiveContent := nil;
			if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
				j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser);
				if j <> -1 then
					FBrowsers.Move(j, BROWSER_COUNT - 1);
			end;
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
			BrowserTab.Tabs.Delete(i);
			if idx > i then begin
				BrowserTab.TabIndex := idx - 1;
			end else begin
				if BrowserTab.Tabs.Count -1 >= idx then
					BrowserTab.TabIndex := idx
				else
					BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
			end;
			if BrowserTab.Tabs.Count = 0 then begin
				BrowserNullTab.Thread := nil;
			end;
			if(BrowserTab.TabIndex <> -1) and
				( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
				for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
					if(TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser
						 = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) )then
					begin
						TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser := nil;
						if TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent <> nil then begin
							TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent.Free;
							TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent := nil;
						end;
						break;
					end;
				end;
				TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
					 :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
				TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
				FBrowsers.Move(BROWSER_COUNT - 1, 0);
			end;
			BrowserTab.Tabs.EndUpdate;
			if( FActiveContent = nil) then
				BrowserTab.OnChange(nil);
			Exit;
		end;
	end;
end;
procedure TGikoForm.DeleteTab(ThreadItem: TThreadItem);
var
	i, j, idx: Integer;
	doc: Variant;
begin
	idx := BrowserTab.TabIndex;
	FTabHintIndex := -1;
	for i := 0 to BrowserTab.Tabs.Count - 1 do begin
		if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
			BrowserTab.Tabs.BeginUpdate;
			try
				if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
					doc := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser.Document;
					TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := doc.Body.ScrollTop;

				end;
			except
				TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := 0;
			end;
			if(FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[i])) then
				FActiveContent := nil;
			if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
				j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser);
				if j <> -1 then
					FBrowsers.Move(j, BROWSER_COUNT - 1);
			end;
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
			BrowserTab.Tabs.Delete(i);
			if idx > i then begin
				BrowserTab.TabIndex := idx - 1;
			end else begin
				if BrowserTab.Tabs.Count -1 >= idx then
					BrowserTab.TabIndex := idx
				else
					BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
			end;
			if(BrowserTab.TabIndex <> -1) and
				( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
				for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
					if(TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser
						 = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) )then
					begin
						TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser := nil;
						if TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent <> nil then begin
							TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent.Free;
							TBrowserRecord(BrowserTab.Tabs.Objects[j]).FEvent := nil;
						end;
						break;
					end;
				end;
				TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
					 :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
				TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
				FBrowsers.Move(BROWSER_COUNT - 1, 0);
			end;

			BrowserTab.Tabs.EndUpdate;
			if( FActiveContent = nil) then
				BrowserTab.OnChange(nil);
			Exit;
		end;
	end;
end;

procedure TGikoForm.KokomadeActionExecute(Sender: TObject);
var
	No: Integer;
	ThreadItem: TThreadItem;
begin
	No := KokoPopupMenu.Tag;
	if No = 0 then Exit;
	ThreadItem := GetActiveContent;
	if ThreadItem = nil then Exit;
	ThreadItem.Kokomade := No;
	FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
	FActiveContent.FRepaint := true;
	InsertBrowserTab(FActiveContent.Thread, true);
	Application.ProcessMessages;
end;

procedure TGikoForm.ZenbuActionExecute(Sender: TObject);
var
	ThreadItem: TThreadItem;
begin
	ThreadItem := GetActiveContent;
	if ThreadItem = nil then Exit;
	ThreadItem.Kokomade := -1;
	FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
	FActiveContent.FRepaint := true;
	InsertBrowserTab(FActiveContent.Thread, true);
	Application.ProcessMessages;
end;

function TGikoForm.Hook(var Message: TMessage): Boolean;
begin
	Result := False;
	case Message.Msg of
	CM_APPKEYDOWN:
		Result := True;
	end;
end;

procedure TGikoForm.KokoResActionExecute(Sender: TObject);
var
	Editor: TEditorForm;
	Item: TThreadItem;
	msg: string;
	Number: Integer;
begin
	Number := KokoPopupMenu.Tag;
	if Number = 0 then Exit;
	Item := GetActiveContent;
	if Item = nil then Exit;

	Editor := TEditorForm.Create(Self);
	Editor.SetThreadItem(Item);
	Editor.BodyEdit.Text := '>>' + IntToStr(Number) + #13#10;
	Editor.Show;
	Editor.BodyEdit.SetFocus;
end;

procedure TGikoForm.ListPopupMenuPopup(Sender: TObject);
begin
	ItemRoundPMenu.Visible := (GetActiveList is TBoard);
	ItemReservPMenu.Visible := (GetActiveList is TBoard);
	LPMSep01.Visible := (GetActiveList is TBoard);
	ListRoundPMenu.Visible := (GetActiveList is TCategory);// or (GetActiveList is TBoard);
	ListReservPMenu.Visible := (GetActiveList is TCategory);// or (GetActiveList is TBoard);
	LPMSep02.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
	KidokuPMenu.Visible := (GetActiveList is TBoard);
	MidokuPMenu.Visible := (GetActiveList is TBoard);
	UrlCopyPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
	NameUrlCopyPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
	AllSelectPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
	LPMSep05.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
	DeletePMenu.Visible := (GetActiveList is TBoard);
	LPMSep06.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
	BoardFavoriteAddMenu.Visible := (GetActiveList is TCategory);
	ThreadFavoriteAddMenu.Visible := (GetActiveList is TBoard);

	AddRoundNameMenu(ItemReservPMenu);
	AddRoundNameMenu(ListReservPMenu);
end;

procedure TGikoForm.BoardIEActionExecute(Sender: TObject);
var
	URL: string;
begin
	if GetActiveList is TBoard then begin
		URL := TBoard(GetActiveList).URL;
		GikoSys.OpenBrowser(URL, gbtAuto);
	end;
end;

procedure TGikoForm.SelectItemURLCopyActionExecute(Sender: TObject);
var
	List: TList;
	i: Integer;
	s: string;
begin
	s := '';
	List := TList.Create;
	try
		SelectListItem(List);
		for i := 0 to List.Count - 1 do begin
			if TObject(List[i]) is TBoard then
				s := s + TBoard(List[i]).URL + #13#10
			else if TObject(List[i]) is TThreadItem then
				s := s + TThreadItem(List[i]).URL + #13#10;
		end;
		if s <> '' then
			Clipboard.AsText := s;
	finally
		List.Free;
	end;
end;

procedure TGikoForm.SelectItemNameCopyActionExecute(Sender: TObject);
var
	List: TList;
	i: Integer;
	s: string;
begin
	s := '';
	List := TList.Create;
	try
		SelectListItem(List);
		for i := 0 to List.Count - 1 do begin
			if TObject(List[i]) is TBoard then
				s := s + TBoard(List[i]).Title + #13#10
			else if TObject(List[i]) is TThreadItem then
				s := s + TThreadItem(List[i]).Title + #13#10;
		end;
		if s <> '' then
			Clipboard.AsText := s;
	finally
		List.Free;
	end;
end;

procedure TGikoForm.SelectItemNameURLCopyActionExecute(Sender: TObject);
var
	List: TList;
	i: Integer;
	s: string;
begin
	s := '';
	List := TList.Create;
	try
		SelectListItem(List);
		for i := 0 to List.Count - 1 do begin
			if TObject(List[i]) is TBoard then
				s := s + TBoard(List[i]).Title + #13#10 + TBoard(List[i]).URL + #13#10
			else if TObject(List[i]) is TThreadItem then
				s := s + TThreadItem(List[i]).Title + #13#10 + TThreadItem(List[i]).URL + #13#10;
		end;
		if s <> '' then
			Clipboard.AsText := s;
	finally
		List.Free;
	end;
end;

procedure TGikoForm.BoardIEActionUpdate(Sender: TObject);
begin
	if GetActiveList is TBoard then
		BoardIEAction.Enabled := True
	else
		BoardIEAction.Enabled := False;
end;

procedure TGikoForm.SelectItemURLCopyActionUpdate(Sender: TObject);
begin
	if ((GetActiveList is TBoard) or (GetActiveList is TCategory))and (ListView.SelCount > 0) then
		SelectItemURLCopyAction.Enabled := True
	else
		SelectItemURLCopyAction.Enabled := False;
end;

procedure TGikoForm.SelectItemNameCopyActionUpdate(Sender: TObject);
begin
	if ((GetActiveList is TBoard) or (GetActiveList is TCategory))and (ListView.SelCount > 0) then
		SelectItemNameCopyAction.Enabled := True
	else
		SelectItemNameCopyAction.Enabled := False;
end;

procedure TGikoForm.SelectItemNameURLCopyActionUpdate(Sender: TObject);
begin
	if ((GetActiveList is TBoard) or (GetActiveList is TCategory))and (ListView.SelCount > 0) then
		SelectItemNameURLCopyAction.Enabled := True
	else
		SelectItemNameURLCopyAction.Enabled := False;
end;

procedure TGikoForm.AllSelectActionUpdate(Sender: TObject);
begin
	if ListView.SelCount > 0 then
		AllSelectAction.Enabled := True
	else
		AllSelectAction.Enabled := False;
end;

procedure TGikoForm.LogDeleteActionUpdate(Sender: TObject);
begin
	if (GetActiveList is TBoard) and (ListView.SelCount > 0) then
		LogDeleteAction.Enabled := True
	else
		LogDeleteAction.Enabled := False;
end;

procedure TGikoForm.BrowserTabCloseActionExecute(Sender: TObject);
var
	idx: Integer;
//	ThreadItem: TThreadItem;
begin
	idx := BrowserTab.TabIndex;
	if idx <> -1 then begin
		if BrowserTab.Tabs.Objects[idx] <> nil then begin
			//ThreadItem := TThreadItem(BrowserTab.Tabs.Objects[idx]);
			DeleteTab(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
		end;
	end;
end;

procedure TGikoForm.NotSelectTabCloseActionExecute(Sender: TObject);
var
	i: Integer;
	idx: Integer;
begin
	idx := BrowserTab.TabIndex;
	if idx = -1 then Exit;
	BrowserTab.Tabs.BeginUpdate;
	for i := BrowserTab.Tabs.Count - 1 downto BrowserTab.TabIndex + 1 do begin
		TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
		BrowserTab.Tabs.Delete(i);
	end;
	if idx > 0 then begin
		for i := BrowserTab.TabIndex - 1 downto 0 do begin
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
			BrowserTab.Tabs.Delete(i);
		end;
	end;
	BrowserTab.Tabs.EndUpdate;
end;

procedure TGikoForm.AllTabCloseActionExecute(Sender: TObject);
var
	i: Integer;
begin
	if GikoSys.Setting.ShowDialogForAllTabClose then
		if(MessageDlg('‘S‚Ä‚Ìƒ^ƒu‚ð•Â‚¶‚Ä‚æ‚ë‚µ‚¢‚Å‚·‚©H', mtConfirmation,[mbOk, mbCancel], 0) = mrCancel ) then
			Exit;

	FActiveContent := nil;
	BrowserNullTab.Thread := nil;
	BrowserTab.OnChange := nil;
	BrowserTab.Tabs.BeginUpdate;
	for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
		TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
	end;
	BrowserTab.Tabs.Clear;
	BrowserTab.Tabs.EndUpdate;
	BrowserTab.OnChange := BrowserTabChange;
	SetContent(BrowserNullTab);
	Self.Caption := CAPTION_NAME ;
end;

procedure TGikoForm.TreeSelectBoradReloadExecute(Sender: TObject);
var
	Board: TBoard;
	TmpTreeNode: TTreeNode;
begin
	TmpTreeNode := FClickNode;
	TreeView.Selected := FClickNode;
	Board := nil;

	if TObject(TmpTreeNode.Data) is TBoard then
		Board := TBoard(TmpTreeNode.Data)
	else if TObject(TmpTreeNode.Data) is TFavoriteBoardItem then
		Board := TFavoriteBoardItem(TmpTreeNode.Data).Item;

	if Board <> nil then
		DownloadList(Board);
end;

procedure TGikoForm.TreeSelectThreadReloadExecute(Sender: TObject);
var
	ThreadItem: TThreadItem;
	TmpTreeNode: TTreeNode;
begin
	TmpTreeNode := FClickNode;
	TreeView.Selected := FClickNode;
	ThreadItem := nil;

	if TObject(TmpTreeNode.Data) is TThreadItem then
		ThreadItem := TThreadItem(TmpTreeNode.Data)
	else if TObject(TmpTreeNode.Data) is TFavoriteThreadItem then
		ThreadItem := TFavoriteThreadItem(TmpTreeNode.Data).Item;

	if ThreadItem <> nil then
		DownloadContent(ThreadItem);
end;

procedure TGikoForm.TreeSelectURLCopyExecute(Sender: TObject);
var
	TmpTreeNode: TTreeNode;
	s: string;
begin
	TmpTreeNode := FClickNode;
	TreeView.Selected := FClickNode;
	if TObject(TmpTreeNode.Data) is TBoard then begin
		s := TBoard(TmpTreeNode.Data).URL + #13#10;
	end else if TObject(TmpTreeNode.Data) is TFavoriteBoardItem then begin
		s := TFavoriteBoardItem(TmpTreeNode.Data).URL + #13#10;
	end else if (TObject(TmpTreeNode.Data) is TThreadItem) then begin
		s := TThreadItem(TmpTreeNode.Data).URL + #13#10;
	end else if TObject(TmpTreeNode.Data) is TFavoriteThreadItem then begin
		s := TFavoriteThreadItem(TmpTreeNode.Data).URL + #13#10;
	end;
	Clipboard.AsText := s;
end;

procedure TGikoForm.TreeSelectNameURLCopyExecute(Sender: TObject);
var
	TmpTreeNode: TTreeNode;
	s: string;
begin
	TmpTreeNode := FClickNode;
	TreeView.Selected := FClickNode;
	if TObject(TmpTreeNode.Data) is TBoard then begin
		s := TBoard(TmpTreeNode.Data).Title + #13#10 + TBoard(TmpTreeNode.Data).URL + #13#10;
	end else if TObject(TmpTreeNode.Data) is TFavoriteBoardItem then begin
		s := TFavoriteBoardItem(TmpTreeNode.Data).Item.Title + #13#10 + TFavoriteBoardItem(TmpTreeNode.Data).URL + #13#10;
	end else if (TObject(TmpTreeNode.Data) is TThreadItem) then begin
		s := TThreadItem(TmpTreeNode.Data).Title + #13#10 + TThreadItem(TmpTreeNode.Data).URL + #13#10;
	end else if TObject(TmpTreeNode.Data) is TFavoriteThreadItem then begin
		s := TFavoriteThreadItem(TmpTreeNode.Data).Item.Title + #13#10 + TFavoriteThreadItem(TmpTreeNode.Data).URL + #13#10;
	end;
	Clipboard.AsText := s;
end;

procedure TGikoForm.TreePopupMenuPopup(Sender: TObject);
begin
	FClickNode := TreeView.Selected;
	if FClickNode = nil then begin
		TreeSelectThreadPupupMenu.Visible := False;
		TreeSelectBoardPupupMenu.Visible := False;
		TPMSep01.Visible := False;
		TreeSelectURLPupupMenu.Visible := False;
		TreeSelectNamePupupMenu.Visible := False;
		TreeSelectNameURLPupupMenu.Visible := False;
		TreeSelectFavoriteAddPupupMenu.Visible := False;
		TreeSelectLogDeleteSeparator.Visible := False;
		TreeSelectLogDeletePopupMenu.Visible := False;
	end else if TObject(FClickNode.Data) is TBoard then begin
		TreeSelectThreadPupupMenu.Visible := False;
		TreeSelectBoardPupupMenu.Visible := True;
		TPMSep01.Visible := True;
		TreeSelectURLPupupMenu.Visible := True;
		TreeSelectNamePupupMenu.Visible := True;
		TreeSelectNameURLPupupMenu.Visible := True;
		TreeSelectFavoriteAddPupupMenu.Visible := True;
		TreeSelectLogDeleteSeparator.Visible := False;
		TreeSelectLogDeletePopupMenu.Visible := False;
	end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
		TreeSelectThreadPupupMenu.Visible := False;
		TreeSelectBoardPupupMenu.Visible := True;
		TPMSep01.Visible := True;
		TreeSelectURLPupupMenu.Visible := True;
		TreeSelectNamePupupMenu.Visible := True;
		TreeSelectNameURLPupupMenu.Visible := True;
		TreeSelectFavoriteAddPupupMenu.Visible := True;
		TreeSelectLogDeleteSeparator.Visible := False;
		TreeSelectLogDeletePopupMenu.Visible := False;
	end else if (TObject(FClickNode.Data) is TThreadItem) then begin
		TreeSelectThreadPupupMenu.Visible := True;
		TreeSelectBoardPupupMenu.Visible := False;
		TPMSep01.Visible := True;
		TreeSelectURLPupupMenu.Visible := True;
		TreeSelectNamePupupMenu.Visible := True;
		TreeSelectNameURLPupupMenu.Visible := True;
		TreeSelectFavoriteAddPupupMenu.Visible := True;
		TreeSelectLogDeleteSeparator.Visible := True;
		TreeSelectLogDeletePopupMenu.Visible := True;
	end else if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
		TreeSelectThreadPupupMenu.Visible := True;
		TreeSelectBoardPupupMenu.Visible := False;
		TPMSep01.Visible := True;
		TreeSelectURLPupupMenu.Visible := True;
		TreeSelectNamePupupMenu.Visible := True;
		TreeSelectNameURLPupupMenu.Visible := True;
		TreeSelectFavoriteAddPupupMenu.Visible := True;
		TreeSelectLogDeleteSeparator.Visible := True;
		TreeSelectLogDeletePopupMenu.Visible := True;
	end else if (TObject(FClickNode.Data) is TCategory) then begin
		TreeSelectThreadPupupMenu.Visible := False;
		TreeSelectBoardPupupMenu.Visible := False;
		TPMSep01.Visible := False;
		TreeSelectURLPupupMenu.Visible := False;
		TreeSelectNamePupupMenu.Visible := True;
		TreeSelectNameURLPupupMenu.Visible := False;
		TreeSelectFavoriteAddPupupMenu.Visible := False;
		TreeSelectLogDeleteSeparator.Visible := False;
		TreeSelectLogDeletePopupMenu.Visible := False;
	end else if FClickNode.IsFirstNode then begin
		TreeSelectThreadPupupMenu.Visible := False;
		TreeSelectBoardPupupMenu.Visible := False;
		TPMSep01.Visible := False;
		TreeSelectURLPupupMenu.Visible := False;
		TreeSelectNamePupupMenu.Visible := True;
		TreeSelectNameURLPupupMenu.Visible := False;
		TreeSelectFavoriteAddPupupMenu.Visible := False;
		TreeSelectLogDeleteSeparator.Visible := False;
		TreeSelectLogDeletePopupMenu.Visible := False;
	end else begin
		TreeSelectThreadPupupMenu.Visible := False;
		TreeSelectBoardPupupMenu.Visible := False;
		TPMSep01.Visible := False;
		TreeSelectURLPupupMenu.Visible := False;
		TreeSelectNamePupupMenu.Visible := False;
		TreeSelectNameURLPupupMenu.Visible := False;
		TreeSelectFavoriteAddPupupMenu.Visible := False;
		TreeSelectLogDeleteSeparator.Visible := False;
		TreeSelectLogDeletePopupMenu.Visible := False;
	end;
end;

procedure TGikoForm.BrowserNewWindow2(Sender: TObject;
	var ppDisp: IDispatch; var Cancel: WordBool);
var
	Text: string;
	Html: string;
	URL: string;
	idx: Integer;
	wkIntSt: Integer;
	wkIntTo: Integer;
begin

	Cancel := True;
	if (IHTMLDocument2(TWebBrowser(Sender).Document).activeElement <> nil) then begin
		Text := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerText;
		Html := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerHTML;
		if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
			or (AnsiPos('„„', Text) = 1) or (AnsiPos('„', Text) = 1) then begin
			if GikoSys.Setting.ResAnchorJamp then begin
				Text := ZenToHan(Text);

				if(AnsiPos('>>', Text) = 1) then begin
					Text := Copy(Text, 3, Length(Text) - 2);
				end else begin
					Text := Copy(Text, 2, Length(Text) - 1);
				end;
				if AnsiPos('-', Text) <> 0 then begin
					wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
					Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
					wkIntTo := StrToIntDef(Text, 0);
					if wkIntTo < wkIntSt then
						wkIntSt := wkIntTo;
				end else
					wkIntSt := StrToIntDef(Text, 0);

				if wkIntSt <> 0 then
					BrowserMovement(IntToStr(wkIntSt));
			end;
		end else begin
			URL := GikoSys.GetHRefText(Html);
			URL := GikoSys.HTMLDecode(URL);
			if( AnsiPos('http://', URL) = 1) or (AnsiPos('https://', URL) = 1) or
				( AnsiPos('ftp://', URL) = 1) then begin
				//ƒAƒhƒŒƒXƒo[‚Ì—š—ð
				if GikoSys.Setting.LinkAddAddressBar then begin
					idx := AddressComboBox.Items.IndexOf(URL);
					if idx = -1 then begin
						AddressComboBox.Items.Insert(0, URL);
						if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
							AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
					end else begin
						AddressComboBox.Items.Delete(idx);
						AddressComboBox.Items.Insert(0, URL);
					end;
				end;
				MoveToURL( URL );
			end;
		end;
	end;

{	ShiftDown := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
	CtrlDown := GetAsyncKeyState(VK_CONTROL) = Smallint($8001);

	if ShiftDown then
		Memo1.Lines.Add('ShiftDown');
	if CtrlDown then
		Memo1.Lines.Add('CtrlDown');

	if	(IHTMLDocument2(TWebBrowser(Sender).Document).activeElement <> nil) then	begin
		Text := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerText;
		Url := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerHTML;



		URL := GetHRefText(URL);

		ParseURI(URL, Protocol, Host, path, Document, Port, Bookmark);

		b := Parse2chURL(path, document, bbs, num);
		memo1.Lines.Add('bbs: ' + bbs);
		memo1.Lines.Add('key: ' + num);
		if b then
			Memo1.Lines.Add('Parse2chURL: True')
		else
			Memo1.Lines.Add('Parse2chURL: False');

//	AppPath := 'C:\Borland\Projects\Test\TestBrowser\TestBrowser.exe';

	end;}
end;

procedure TGikoForm.ListSplitterCanResize(Sender: TObject;
	var NewSize: Integer; var Accept: Boolean);
begin
	if GikoSys.Setting.ListOrientation = gloHorizontal then begin
		if ViewPanel.Width < 2 then begin
			ViewPanel.Width := 1;
			BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_NORMAL;
			BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
			GikoSys.Setting.ListWidthState := glsMax;
		end else if ViewPanel.Width > (ThreadMainPanel.Width - 80) then begin
			BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
			BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_NORMAL;
			GikoSys.Setting.ListWidthState := glsMin;
		end else begin
			BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
			BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
			GikoSys.Setting.ListWidthState := glsNormal;
		end;
	end else begin
		if ViewPanel.Height < 2 then begin
			ViewPanel.Height := 1;
			BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_NORMAL;
			BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
			GikoSys.Setting.ListHeightState := glsMax;
		end else if ViewPanel.Height > (ThreadMainPanel.Height - BrowserCoolBar.Height - 7) then begin
			BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
			BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_NORMAL;
			GikoSys.Setting.ListHeightState := glsMin;
		end else begin
			BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
			BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
			GikoSys.Setting.ListHeightState := glsNormal;
		end;
	end;
end;

procedure TGikoForm.ListSplitterMoved(Sender: TObject);
begin
	if Mouse.Capture <> 0 then
		Exit;
	if GikoSys.Setting.ListOrientation = gloHorizontal then begin
		if (ViewPanel.Width > 1) and (ViewPanel.Width <= (ThreadMainPanel.Width - 80)) then
			FBrowserSizeWidth := ViewPanel.Width;
	end else begin
		if (ViewPanel.Height > 1) and (ViewPanel.Height <= (ThreadMainPanel.Height - BrowserCoolBar.Height)) then
			FBrowserSizeHeight := ViewPanel.Height;
	end;
{	if (Mouse.Capture = 0) and (ViewPanel.Height > 1) and (not ArrangeAction.Checked) then
		FBrowserSizeHeight := ViewPanel.Height
	else if (Mouse.Capture = 0) and (ViewPanel.Width > 1) and (ArrangeAction.Checked) then
		FBrowserSizeWidth := ViewPanel.Width;}
end;

procedure TGikoForm.BrowserTabChange(Sender: TObject);
var
	i, j: Integer;
	idx: Integer;
begin

//	if NewTab = -1 then
//	ThreadItem := nil;
	if not BrowserTab.Dragging then begin
		FTabHintIndex := -1;
		BrowserTab.Hint := '';
		idx := BrowserTab.TabIndex;
		if idx = -1 then begin
			BrowserNullTab.Thread := nil;
			SetContent(BrowserNullTab);

		end else if(BrowserTab.Tabs.Objects[idx] <> nil) and (BrowserTab.Tabs.Objects[idx] is TBrowserRecord) then begin
			if TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser <> nil then begin
				j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser);
				if j <> -1 then
					FBrowsers.Move(j ,0);
			end else begin
				if( FActiveContent <> nil ) and (FActiveContent.Browser <> nil) and
					(FActiveContent.Browser <> BrowserNullTab.Browser) and
					(FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1])) then
					FBrowsers.Move(BROWSER_COUNT - 1, 0);

				for i := 0 to BrowserTab.Tabs.Count - 1 do begin
					if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
						TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser := nil;
						TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
						if TBrowserRecord(BrowserTab.Tabs.Objects[i]).FEvent <> nil then begin
							TBrowserRecord(BrowserTab.Tabs.Objects[i]).FEvent.Free;
							TBrowserRecord(BrowserTab.Tabs.Objects[i]).FEvent := nil;
						end;
					end;
				end;
				TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
				TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Repaint := true;
				FBrowsers.Move(BROWSER_COUNT - 1, 0);
			end;
			TOleControl(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser).BringToFront;
			GikoSys.OnlyAHundredRes := TBrowserRecord(BrowserTab.Tabs.Objects[idx]).OnlyHundred;
			OnlyAHundredRes.Checked := TBrowserRecord(BrowserTab.Tabs.Objects[idx]).OnlyHundred;
			SetContent(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));

			if (GikoSys.Setting.URLDisplay) and (GetActiveContent <> nil) then
				AddressComboBox.Text := GetActiveContent.URL;

			if ((TreeView.Visible) and (TreeView.Focused)) or ((FavoriteTreeView.Visible) and (FavoriteTreeView.Focused)) or
				(ListView.Focused) or (SelectComboBox.Focused) or (AddressComboBox.Focused)
			then
			else
            	SetFocusForBrowserAction.Execute;	

		end;

	end;

end;


procedure TGikoForm.BrowserTabMouseDown(Sender: TObject;
	Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
	p: TPoint;
	p2: TPoint;
	idx: Integer;
begin
	if Button = mbMiddle then begin
		// ƒ}ƒEƒX’†ƒ{ƒ^ƒ“
		GetCursorPos(p);
		p2 := p;
		p := BrowserTab.ScreenToClient(p);
		idx := BrowserTab.IndexOfTabAt(p.X, p.Y);
		if idx <> -1 then
			DeleteTab(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
	//end else if Button = mbRight then begin
	//PopupMenu‚ÅBrowserTabPoupMenu‚ðŽw’è‚µ‚Ä‚¢‚é‚Ì‚Å‚±‚±‚Å‚í‚´‚í‚´ŒÄ‚Ño‚·‚Æ‚Qd‚É‚È‚é
	//OnContextPopup‚Å‚à‚µ‚àActive‚ÈTabˆÈŠO‚ÅŒÄ‚Ño‚³‚ê‚½‚çTab‚ðØ‚è‘Ö‚¦‚é‚æ‚¤‚É‚µ‚½B
{		// ƒ}ƒEƒX‰Eƒ{ƒ^ƒ“
		GetCursorPos(p);
		p2 := p;
//		GetCursorPos(p2);
		p := BrowserTab.ScreenToClient(p);
//		idx := BrowserTab.ItemAtPos(p);
		idx := BrowserTab.IndexOfTabAt(p.X, p.Y);
		if idx <> -1 then begin
			OldIndex := BrowserTab.TabIndex;
			BrowserTab.TabIndex := idx;
			if OldIndex <> idx then
				BrowserTab.OnChange(nil);
			BrowserTabPopupMenu.Tag := idx;
			BrowserTabPopupMenu.Popup(p2.X, p2.Y);
		end;
}
	end else if BUtton = mbLeft then begin
		FDragWFirst := true;
		FMouseDownPos.X := X;
		FMouseDownPos.Y := Y;
	end;

end;

procedure TGikoForm.SetBrowserTabState;
var
//	i: Integer;
	CoolBand: TCoolBand;
begin
	BrowserBottomPanel.AutoSize := False;
	if GikoSys.Setting.BrowserTabVisible then begin
		if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
			BrowserTab.Style := tsTabs;
			if GikoSys.Setting.BrowserTabPosition = gtpTop then
				BrowserTab.TabPosition := tpTop
			else
				BrowserTab.TabPosition := tpBottom;
		end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
			BrowserTab.TabPosition := tpTop;
			BrowserTab.Style := tsButtons;
		end else begin
			BrowserTab.TabPosition := tpTop;
			BrowserTab.Style := tsFlatButtons
		end;

		if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
			BrowserTab.Parent := BrowserTabToolBar;
			BrowserBottomPanel.Hide;
			CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
			if CoolBand <> nil then
				CoolBand.Visible := True;
//			BrowserTab.Parent := BrowserTopPanel;
//			BrowserTab.Parent := BrowserCoolBar;
//			BrowserTab.Top := 26;
//			BrowserTopPanel.Height := 44;

		end else begin
			BrowserTab.Parent := BrowserBottomPanel;
			BrowserTab.Top := 0;
			BrowserTab.Left := 0;
			BrowserBottomPanel.Show;
			CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
			if CoolBand <> nil then
				CoolBand.Visible := False;
//			BrowserTopPanel.Height := 26;
		end;
		BrowserTab.Show;
	end else begin
		CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
		if CoolBand <> nil then
			CoolBand.Visible := False;
		BrowserBottomPanel.Visible := False;
//		BrowserTab.Visible := False;
//		BrowserTopPanel.Height := 26;
		AllTabCloseAction.Execute;
	end;
end;

procedure TGikoForm.BrowserTabDragOver(Sender, Source: TObject; X,
	Y: Integer; State: TDragState; var Accept: Boolean);
var
	idx: Integer;
begin
	idx := BrowserTab.IndexOfTabAt(X, Y);
	Accept := (Source = BrowserTab) and (BrowserTab.TabIndex <> idx);
end;

procedure TGikoForm.BrowserTabDragDrop(Sender, Source: TObject; X,
	Y: Integer);
var
	idx: Integer;
begin
	idx := BrowserTab.IndexOfTabAt(X, Y);
	if idx <> -1 then
		BrowserTab.Tabs.Move(BrowserTab.TabIndex, idx);
end;

procedure TGikoForm.BrowserTabMouseMove(Sender: TObject;
	Shift: TShiftState; X, Y: Integer);
var
	TabIdx: Integer;
	ThreadItem: TThreadItem;
begin

	TabIdx := BrowserTab.IndexOfTabAt(x, y);

	if ( ssLeft in Shift ) and ( BrowserTab.Style = tsTabs ) then begin
		if FDragWFirst = false then begin
			FDragWFirst := true;
		end else begin
			BrowserTab.EndDrag(false);
			BrowserTab.BeginDrag(false, DandD_THRESHOLD);
			FDragWFirst := false;
		end;
	end else begin
		BrowserTab.EndDrag(false);
		FDragWFirst := false;
	end;
	
	if (FTabHintIndex <> TabIdx) and (TabIdx <> -1) then begin
		Application.CancelHint;
		ThreadItem := TBrowserRecord(BrowserTab.Tabs.Objects[TabIdx]).Thread;
		if ThreadItem.Title <> BrowserTab.Tabs[TabIdx] then begin
			BrowserTab.Hint := ThreadItem.Title;
			Application.ShowHint := True;
		end else begin
			BrowserTab.Hint := '';
			Application.ShowHint := True;
		end;
		FTabHintIndex := TabIdx;
	end;

end;

procedure TGikoForm.BrowserDocumentComplete(Sender: TObject;
	const pDisp: IDispatch; var URL: OleVariant);
var
	FDispHtmlDocument: DispHTMLDocument;
	BrowserRecord :TBrowserRecord;
	i :Integer;
begin
//	AddMessageList('DocumentComplete', nil);
	if TObject(Sender) is TWebBrowser then begin
		if TWebBrowser(Sender) <> Browser then begin
			BrowserRecord := nil;
			for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
				if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(Sender) then begin
						BrowserRecord := TBrowserRecord(BrowserTab.Tabs.Objects[i]);
						break;
				end;
			end;
			if BrowserRecord <> nil then begin
				if BrowserRecord.FEvent <> nil then
					BrowserRecord.FEvent.Free;
				FDispHtmlDocument := Idispatch(OleVariant(BrowserRecord.Browser.ControlInterface).Document) as DispHTMLDocument;
				BrowserRecord.FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
				BrowserRecord.FEvent.OnContextMenu := OnDocumentContextMenu;
				BrowserRecord.FEvent.OnClick := WebBrowserClick;  //’Ç‰Á‚µ‚½OnClickƒCƒxƒ“ƒg
			end;
		end else begin
        	if GetActiveContent <> nil then begin
				FDispHtmlDocument := Idispatch(OleVariant(Browser.ControlInterface).Document) as DispHTMLDocument;
				if FEvent <> nil then
					FEvent.Free;
				FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
				FEvent.OnContextMenu := OnDocumentContextMenu;
				FEvent.OnClick := WebBrowserClick;  //’Ç‰Á‚µ‚½OnClickƒCƒxƒ“ƒg
			end;
		end;
	end;
end;

procedure TGikoForm.SelectReservActionUpdate(Sender: TObject);
var
	i: Integer;
	List: TList;
begin
	if (GetActiveList is TBoard) and (ListView.SelCount > 0) then begin
		List := TList.Create;
		try
			SelectListItem(List);
			for i := 0 to List.Count - 1 do begin
				if TObject(List[i]) is TThreadItem then begin
					if TThreadItem(List[i]).IsLogFile then begin
						SelectReservAction.Enabled := True;
						Exit;
					end;
				end;
			end;
			SelectReservAction.Enabled := False;
		finally
			List.Free;
		end;
	end else if (GetActiveList is TCategory) and (ListView.SelCount > 0) then
		SelectReservAction.Enabled := True
	else
		SelectReservAction.Enabled := False;
end;

procedure TGikoForm.RoundNamePopupMenuPopup(Sender: TObject);
begin
	AddRoundNameMenu(RoundNamePopupMenu.Items);
end;

procedure TGikoForm.AddRoundNameMenu(MenuItem: TMenuItem);
var
	i: Integer;
	Item: TMenuItem;
begin
	MenuItem.Clear;
	Item := TMenuItem.Create(Self);
	Item.Caption := 'V‚µ‚¢–¼‘O‚Å„‰ñ—\–ñ(&N)...';
	Item.OnClick := SelectNewRoundNameExecute;
	MenuItem.Add(Item);
	Item := TMenuItem.Create(Self);
	Item.Caption := '„‰ñƒŠƒXƒg‚©‚çíœ(&D)';
	Item.OnClick := SelectDeleteRoundExecute;
	MenuItem.Add(Item);
	Item := TMenuItem.Create(Self);
	Item.Caption := '-';
	MenuItem.Add(Item);
	for i := 0 to RoundList.RoundNameList.Count - 1 do begin
		Item := TMenuItem.Create(Self);
		Item.Caption := RoundList.RoundNameList[i];
		Item.OnClick := SetSelectRoundName;
		MenuItem.Add(Item);
	end;
end;

procedure TGikoForm.SelectNewRoundNameExecute(Sender: TObject);
var
	s: string;
	Dlg: TRoundNameDialog;

begin
	Dlg := TRoundNameDialog.Create(Self);
	try
		Dlg.ShowModal;
		if Dlg.ModalResult <> mrCancel then begin
			s := Trim(Dlg.RoundNameEdit.Text);
			RoundList.RoundNameList.Add(s);
			SetSelectItemRound(True, s, TMenuItem(Sender).Parent.Name);
            ListView.Refresh;
		end;
	finally
		Dlg.Free;
	end;
end;
procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string);
var
    threadItem : TThreadItem;
begin
    if ParentName <> 'dummy1' then begin
    	SetSelectItemRound(RoundFlag, RoundName);
    end else begin
    	threadItem := GetActiveContent;
		if threadItem <> nil then begin
        	threadItem.RoundName := RoundName;
            threadItem.Round := RoundFlag;
        end;
    end;
end;

procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string);
var
	i: Integer;
	List: TList;
begin
	List := TList.Create;
	try
		SelectListItem(List);
		for i := 0 to List.Count - 1 do begin
			if TObject(List[i]) is TBoard then begin
				TBoard(List[i]).RoundName := RoundName;
				TBoard(List[i]).Round := RoundFlag;
			end else if TObject(List[i]) is TThreadItem then begin
				if TThreadItem(List[i]).IsLogFile then begin
					TThreadItem(List[i]).RoundName := RoundName;
					TThreadItem(List[i]).Round := RoundFlag;
				end;
			end;
		end;
	finally
		List.Free;
	end;
end;

procedure TGikoForm.SelectDeleteRoundExecute(Sender: TObject);
begin
	SetSelectItemRound(False, '', TMenuItem(Sender).Parent.Name);
	ListView.Refresh;
end;

procedure TGikoForm.SelectReservActionExecute(Sender: TObject);
begin
	// ‚±‚ÌƒRƒƒ“ƒgíœ‚µ‚Ä‚Í‘Ê–Ú
end;

procedure TGikoForm.SetSelectRoundName(Sender: TObject);
var
	MenuItem: TMenuItem;
begin
	if Sender is TMenuItem then begin
		MenuItem := TMenuItem(Sender);
		SetSelectItemRound(True, StripHotKey(MenuItem.Caption), TMenuItem(Sender).Parent.Name);
		ListView.Refresh;
	end;
end;

procedure TGikoForm.NewBoardActionExecute(Sender: TObject);
var
	Dlg: TNewBoardDialog;
	Msg: string;
	i: Integer;
begin
	for i := 0 to Screen.CustomFormCount - 1 do begin
		if TObject(Screen.CustomForms[i]) is TEditorForm then begin
			Msg := 'ƒŒƒXƒGƒfƒBƒ^‚ð‘S‚Ä•Â‚¶‚Ä‚­‚¾‚³‚¢';
			MsgBox(Handle, Msg, 'ƒGƒ‰[', MB_OK or MB_ICONSTOP);
			Exit;
		end;
	end;
	Dlg := TNewBoardDialog.Create(Self);
	try
		Dlg.ShowModal;
	finally
		Dlg.Release;
	end;
end;

procedure TGikoForm.LoginActionExecute(Sender: TObject);
var
	TmpCursor: TCursor;
	msg : String;
begin
	if GikoSys.Dolib.Connected then begin
		//ƒƒOƒAƒEƒg
		GikoSys.Dolib.Disconnect;
		LoginAction.Checked := False;
		AddMessageList('ƒƒOƒAƒEƒg‚µ‚Ü‚µ‚½', nil, gmiOK);
		LoginAction.Caption := 'ƒƒOƒCƒ“(&L)';
	end else begin
		TmpCursor := Screen.Cursor;
		Screen.Cursor := crHourGlass;
		try
            //’ÊíƒƒOƒCƒ“
            if not GikoSys.Setting.ForcedLogin then begin
				GikoSys.Dolib.ClientUA := 'gikoNavi/1.00';
				GikoSys.Dolib.UserName := GikoSys.Setting.UserID;
				GikoSys.Dolib.Password := GikoSys.Setting.Password;
				if GikoSys.Setting.ReadProxy then begin
					GikoSys.Dolib.ProxyAddress := GikoSys.Setting.ReadProxyAddress;
					GikoSys.Dolib.ProxyPort := GikoSys.Setting.ReadProxyPort;
				end else begin
					GikoSys.Dolib.ProxyAddress := '';
					GikoSys.Dolib.ProxyPort := 0;
				end;
				if GikoSys.Dolib.Connect then begin
					LoginAction.Checked := True;
					AddMessageList('ƒƒOƒCƒ“‚µ‚Ü‚µ‚½ - ' + GikoSys.Setting.UserID, nil, gmiOK);
					LoginAction.Caption := 'ƒƒOƒAƒEƒg(&L)';
                    LoginToolButton.Style := tbsCheck;
				end else begin
		//			MsgBox(Handle, 'ƒƒOƒCƒ“o—ˆ‚Ü‚¹‚ñ‚Å‚µ‚½', 'ƒGƒ‰[', MB_OK or MB_ICONSTOP);
					AddMessageList(GikoSys.Dolib.ErrorMsg, nil, gmiNG);
					PlaySound('Error');
					LoginAction.Checked := False;
					LoginToolButton.Down := False;
					LoginToolButton.Style := tbsButton;
				end;
        	end else begin
				msg := '‹­§ƒƒOƒCƒ“ƒ‚[ƒh‚Å‚ÍCƒT[ƒo‚ÌØ–¾‘‚Ì—LŒø«‚ðƒ`ƒFƒbƒN‚µ‚Ü‚¹‚ñB' + #13#10
						+ '‹U‘•ƒT[ƒo‚Ìê‡A‚ ‚È‚½‚ÌƒpƒXƒ[ƒh“‚Ü‚ê‚é‰Â”\«‚ª‚ ‚è‚Ü‚·B' + #13#10
                        + '‚±‚Ìƒ‚[ƒh‚ÅƒƒOƒCƒ“‚ðŽŽ‚Ý‚Ü‚·‚©H' + #13#10;
                if MsgBox(Handle, msg, 'Œx', MB_YESNO or MB_ICONEXCLAMATION) = IDYES	 then begin
                    GikoSys.Dolib.ClientUA := 'gikoNavi/1.00';
                    GikoSys.Dolib.UserName := GikoSys.Setting.UserID;
                    GikoSys.Dolib.Password := GikoSys.Setting.Password;
                    if GikoSys.Setting.ReadProxy then begin
                        GikoSys.Dolib.ProxyAddress := GikoSys.Setting.ReadProxyAddress;
                        GikoSys.Dolib.ProxyPort := GikoSys.Setting.ReadProxyPort;
                    end else begin
                        GikoSys.Dolib.ProxyAddress := '';
                        GikoSys.Dolib.ProxyPort := 0;
                    end;
                    //SSLáŠQ—p‹­§ƒƒOƒCƒ“
                    GikoSys.Dolib.ForcedConnect;
                    if GikoSys.Dolib.Connect then begin
                        LoginAction.Checked := True;
                        AddMessageList('‹­§ƒƒOƒCƒ“‚µ‚Ü‚µ‚½ - ' + GikoSys.Setting.UserID, nil, gmiOK);
                        LoginAction.Caption := 'ƒƒOƒAƒEƒg(&L)';
                        LoginToolButton.Style := tbsCheck;
                    end else begin
            //			MsgBox(Handle, 'ƒƒOƒCƒ“o—ˆ‚Ü‚¹‚ñ‚Å‚µ‚½', 'ƒGƒ‰[', MB_OK or MB_ICONSTOP);
                        AddMessageList(GikoSys.Dolib.ErrorMsg, nil, gmiNG);
                        PlaySound('Error');
						LoginAction.Checked := False;
                        LoginToolButton.Down := False;
                        LoginToolButton.Style := tbsButton;
                    end;
            	end else begin
	                LoginAction.Checked := False;
                    LoginToolButton.Down := False;
                    LoginToolButton.Style := tbsButton;
                end;
            end;
		finally
			Screen.Cursor := TmpCursor;
		end;
	end;
end;

procedure TGikoForm.KeySettingActionExecute(Sender: TObject);
var
	Dlg: TKeySettingForm;
begin
	Dlg := TKeySettingForm.Create(Self);
	try
		if Dlg.ShowModal = mrOk then
			GikoSys.SaveKeySetting(ActionList);
            GikoSys.SaveEditorKeySetting(Dlg.EditorForm.ActionList);
	finally
		Dlg.Release;
	end;
end;

procedure TGikoForm.ArrangeActionExecute(Sender: TObject);
begin
	if ArrangeAction.Checked then begin
		//c
		ViewPanel.Align := alNone;
		ListSplitter.Align := alNone;
		ThreadPanel.Align := alNone;

		ViewPanel.Width := FBrowserSizeWidth;
		ViewPanel.Align := alLeft;

		ListSplitter.Width := 5;
		ListSplitter.Align := alLeft;

		ViewPanel.Left := -10;

		ThreadPanel.Align := alClient;

		GikoSys.Setting.ListOrientation := gloHorizontal;
		case GikoSys.Setting.ListWidthState of
			glsMax: begin
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_NORMAL;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
				ViewPanel.Width := 1;
			end;
			glsNormal: begin
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_MIN;
			end;
			glsMin: begin
				BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_WIDTH_NORMAL;
				ViewPanel.Width := ThreadMainPanel.Width - 80;
			end;
		end;
	end else begin
		//‰¡
		ViewPanel.Align := alNone;
		ListSplitter.Align := alNone;
		ThreadPanel.Align := alNone;

		ViewPanel.Height := FBrowserSizeHeight;
		ViewPanel.Align := alTop;

		ListSplitter.Height := 5;
		ListSplitter.Align := alTop;

		ViewPanel.Top := -10;

		ThreadPanel.Align := alClient;
		GikoSys.Setting.ListOrientation := gloVertical;
		case GikoSys.Setting.ListHeightState of
			glsMax: begin
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_NORMAL;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
				ViewPanel.Height := 1;
			end;
			glsNormal: begin
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_MIN;
			end;
			glsMin: begin
				BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
				BrowserMinAction.ImageIndex := TOOL_ICON_HEIGHT_NORMAL;
				ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
			end;
		end;
	end;

end;

procedure TGikoForm.PaneInitActionExecute(Sender: TObject);
begin
	CabinetPanel.Width := 150;
	MessagePanel.Height := 40;

	FBrowserSizeWidth := 200;
	FBrowserSizeHeight := 200;
	if ArrangeAction.Checked then begin
		ViewPanel.Width := FBrowserSizeWidth;
	end else begin
		ViewPanel.Height := FBrowserSizeHeight;
	end;
	if GikoSys.Setting.ListOrientation = gloHorizontal then begin
		if GikoSys.Setting.ListHeightState = glsMax then begin
			BrowserMaxAction.ImageIndex := TOOL_ICON_HEIGHT_MAX;
			GikoSys.Setting.ListHeightState := glsNormal;
		end;
	end else begin
		if GikoSys.Setting.ListWidthState = glsMax then begin
			BrowserMaxAction.ImageIndex := TOOL_ICON_WIDTH_MAX;
			GikoSys.Setting.ListWidthState := glsNormal;
		end;
	end;
end;

procedure TGikoForm.ActiveLogDeleteActionExecute(Sender: TObject);
const
	DEL_MSG = 'ƒƒOƒtƒ@ƒCƒ‹‚ðíœ‚µ‚Ü‚·B‚æ‚ë‚µ‚¢‚Å‚·‚©H';
	DEL_TITLE = 'íœŠm”F';
var
	idx: Integer;
	ThreadItem: TThreadItem;
begin
	idx := BrowserTab.TabIndex;
	if idx <> -1 then begin
		if BrowserTab.Tabs.Objects[idx] <> nil then begin
			if GikoSys.Setting.DeleteMsg then
				if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) <> IDYES then
				Exit;
			ThreadItem := TBrowserRecord(BrowserTab.Tabs.Objects[idx]).FThread;
			DeleteTab(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
			ThreadItem.DeleteLogFile;
			if ThreadItem.ParentBoard = FActiveList then
				ListView.Refresh;
		end;
	end;
end;

function TGikoForm.GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
var
	i: Integer;
begin
	Result := nil;
	if CoolBar = nil then
		Exit;
	for i := 0 to CoolBar.Bands.Count - 1 do begin
		if CoolBar.Bands[i].Control = Control then begin
			Result := CoolBar.Bands[i];
			Exit;
		end;
	end;
end;

procedure TGikoForm.BrowserTabToolBarResize(Sender: TObject);
begin
	if BrowserTab.Parent = BrowserTabToolBar then
		BrowserTab.Width := BrowserTabToolBar.Width;
end;

procedure TGikoForm.SelectTextClearActionExecute(Sender: TObject);
begin
	GikoSys.Setting.SelectTextList.Clear;
	SelectComboBox.Items.Clear;
	SelectComboBox.Text := '';
	SetListViewType( gvtAll );
end;

procedure TGikoForm.NameTextClearActionExecute(Sender: TObject);
var
	i: Integer;
begin
	GikoSys.Setting.NameList.Clear;
	for i := 0 to Screen.CustomFormCount - 1 do begin
		if TObject(Screen.CustomForms[i]) is TEditorForm then
			TEditorForm(Screen.CustomForms[i]).NameComboBox.Items.Clear;
	end;
end;

procedure TGikoForm.MailTextClearActionExecute(Sender: TObject);
var
	i: Integer;
begin
	GikoSys.Setting.MailList.Clear;
	for i := 0 to Screen.CustomFormCount - 1 do begin
		if TObject(Screen.CustomForms[i]) is TEditorForm then
			TEditorForm(Screen.CustomForms[i]).MailComboBox.Items.Clear;
	end;
end;

procedure TGikoForm.LeftmostTabSelectActionExecute(Sender: TObject);
begin
	if BrowserTab.Tabs.Count > 0 then begin
		BrowserTab.TabIndex := 0;
		BrowserTab.OnChange(nil);
	end;
end;

procedure TGikoForm.LeftTabSelectActionExecute(Sender: TObject);
begin
	if BrowserTab.Tabs.Count > 0 then begin
		if BrowserTab.TabIndex = -1 then begin
			BrowserTab.TabIndex := 0;
			BrowserTab.OnChange(nil);
		end else if BrowserTab.TabIndex > 0 then begin
			BrowserTab.TabIndex := BrowserTab.TabIndex - 1;
			BrowserTab.OnChange(nil);
		end;
	end;
end;

procedure TGikoForm.RightTabSelectActionExecute(Sender: TObject);
begin
	if BrowserTab.Tabs.Count > 0 then begin
		if BrowserTab.TabIndex = -1 then begin
			BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
			BrowserTab.OnChange(nil);
		end else if BrowserTab.TabIndex < (BrowserTab.Tabs.Count - 1) then begin
			BrowserTab.TabIndex := BrowserTab.TabIndex + 1;
			BrowserTab.OnChange(nil);
		end;
	end;
end;

procedure TGikoForm.RightmostTabSelectActionExecute(Sender: TObject);
begin
	if BrowserTab.Tabs.Count > 0 then begin
		BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
		BrowserTab.OnChange(nil);
	end;
end;

procedure TGikoForm.LeftmostTabSelectActionUpdate(Sender: TObject);
begin
	LeftmostTabSelectAction.Enabled := (BrowserTab.TabIndex <> 0) and (BrowserTab.Tabs.Count > 0);
end;

procedure TGikoForm.LeftTabSelectActionUpdate(Sender: TObject);
begin
	LeftTabSelectAction.Enabled := (BrowserTab.TabIndex <> 0) and (BrowserTab.Tabs.Count > 0);
end;

procedure TGikoForm.RightTabSelectActionUpdate(Sender: TObject);
begin
	RightTabSelectAction.Enabled := (BrowserTab.TabIndex <> BrowserTab.Tabs.Count - 1) and (BrowserTab.Tabs.Count > 0);
end;

procedure TGikoForm.RightmostTabSelectActionUpdate(Sender: TObject);
begin
	RightmostTabSelectAction.Enabled := (BrowserTab.TabIndex <> BrowserTab.Tabs.Count - 1) and (BrowserTab.Tabs.Count > 0);
end;

procedure TGikoForm.WMSettingChange(var Message: TWMWinIniChange);
begin
	SetMenuFont;
end;

procedure TGikoForm.SetMenuFont;
begin
//	GikoSys.MenuFont(MenuToolBar.Font);
//	MenuToolBar.Buttons[0].AutoSize := False;
//	MenuToolBar.Buttons[0].AutoSize := True;
//	MenuToolBar.Font.Color := clMenuText;
	GikoSys.MenuFont(MainCoolBar.Font);
	MenuToolBar.Buttons[0].AutoSize := False;
	MenuToolBar.Buttons[0].AutoSize := True;
	MainCoolBar.AutoSize := False;
	MainCoolBar.AutoSize := True;

	GikoSys.MenuFont(ListCoolBar.Font);
	GikoSys.MenuFont(BrowserCoolBar.Font);
//	MenuToolBar.Font.Color := clMenuText;
end;

procedure TGikoForm.FavoriteMenuClick(Sender: TObject);
var
	NewMenu: TMenuItem;
begin
	FavoriteMenu.Clear;

	//‚¨‹C‚É“ü‚è‚Ì’Ç‰Á
	NewMenu := TMenuItem.Create(MainMenu);
	NewMenu.Action := FavoriteAddAction;
	FavoriteMenu.Add(NewMenu);
	//‚¨‹C‚É“ü‚è‚Ì®—
	NewMenu := TMenuItem.Create(FavoriteMenu);
	NewMenu.Action := FavoriteArrangeAction;
	FavoriteMenu.Add(NewMenu);
	//ƒZƒpƒŒ[ƒ^
	NewMenu := TMenuItem.Create(FavoriteMenu);
	NewMenu.Caption := '-';
	FavoriteMenu.Add(NewMenu);

	CreateFavMenu(FavoriteDM.TreeView.Items.GetFirstNode, FavoriteMenu);
end;

procedure TGikoForm.CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
var
	i: Integer;
	NewMenu: TMenuItem;
begin
	for i := 0 to Node.Count - 1 do begin
		NewMenu := TFavoriteMenuItem.Create(Self);
		NewMenu.AutoHotkeys := maAutomatic;
		NewMenu.Caption := CustomStringReplace(Node.Item[i].Text, '&', '&&');
		TFavoriteMenuItem(NewMenu).Data := Node.Item[i].Data;
		MenuItem.Add(NewMenu);

		if TObject(Node.Item[i].Data) is TFavoriteFolder then begin
			NewMenu.ImageIndex := TOOL_ICON_FAV_FOLDER;
			CreateFavMenu(Node.Item[i], NewMenu);
		end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin
			NewMenu.ImageIndex := TOOL_ICON_FAV_BOARD;
			NewMenu.OnClick := FavoriteClick;
		end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin
			NewMenu.ImageIndex := TOOL_ICON_FAV_THREAD;
			NewMenu.OnClick := FavoriteClick;
		end;
	end;
end;

procedure TGikoForm.ShowFavoriteAddDialog( Item : TObject );
var
	Dlg			: TFavoriteAddDialog;
	i				: Integer;
	Items		: ^TTreeNodes;
	ItemURL	: string;
	Data		: Pointer;
begin

	Items := @(FavoriteTreeView.Items);
	if Item is TFavoriteBoardItem then
		Item := TFavoriteBoardItem( Item ).Item
	else if Item is TFavoriteThreadItem then
		Item := TFavoriteThreadItem( Item ).Item;
	if Item is TBoard then begin
		ItemURL := TBoard( Item ).URL;
		for i := Items^.Count - 1 downto 0 do begin
			Data := Items^.Item[ i ].Data;
			if TObject( Data ) is TFavoriteBoardItem then begin
                if ItemURL = TFavoriteThreadItem( Data ).URL then begin
					if Application.MessageBox( 'Šù‚É‚¨‹C‚É“ü‚è‚É“o˜^‚³‚ê‚Ä‚¢‚Ü‚·B‚»‚ê‚Å‚à’Ç‰Á‚µ‚Ü‚·‚©H', '‚¨‹C‚É“ü‚è‚Ì’Ç‰Á', MB_YESNO ) = IDNO then
						Exit;
					Break;
				end;
			end;
		end;
		Dlg := TFavoriteAddDialog.Create(Self);
		try
			Dlg.SetBoard( TBoard( Item ) );
			Dlg.ShowModal;
		finally
			Dlg.Release;
		end;
	end else if Item is TThreadItem then begin
		ItemURL := TThreadItem( Item ).URL;
		for i := Items^.Count - 1 downto 0 do begin
			Data := Items^.Item[ i ].Data;
			if TObject( Data ) is TFavoriteThreadItem then begin
                if ItemURL = TFavoriteThreadItem( Data ).URL then begin
					if Application.MessageBox( 'Šù‚É‚¨‹C‚É“ü‚è‚É“o˜^‚³‚ê‚Ä‚¢‚Ü‚·B‚»‚ê‚Å‚à’Ç‰Á‚µ‚Ü‚·‚©H', '‚¨‹C‚É“ü‚è‚Ì’Ç‰Á', MB_YESNO ) = IDNO then
						Exit;
					Break;
				end;
			end;
		end;
		Dlg := TFavoriteAddDialog.Create(Self);
		try
			Dlg.SetThreadItem( TThreadItem( Item ) );
			Dlg.ShowModal;
		finally
			Dlg.Release;
		end;
	end;

	SetLinkBar;
end;

procedure TGikoForm.FavoriteAddActionExecute(Sender: TObject);
begin
	ShowFavoriteAddDialog(GetActiveContent);
end;

procedure TGikoForm.FavoriteClick(Sender: TObject);
begin

	FavoriteClick( Sender, True );

end;

procedure TGikoForm.FavoriteClick(Sender: TObject; ActiveTab: Boolean);
var
	Board: TBoard;
	ThreadItem: TThreadItem;
	FavBoard: TFavoriteBoardItem;
	FavThread: TFavoriteThreadItem;
	Item: TObject;
begin
//	Item := nil;
	if Sender is TFavoriteMenuItem then
		Item := TFavoriteMenuItem(Sender).Data
	else if Sender is TLinkToolButton then
		Item := TLinkToolButton(Sender).Data
	else if Sender is TTreeNode then
		Item := TTreeNode( Sender ).Data
	else
		Exit;

	if TObject(Item) is TFavoriteBoardItem then begin
		FavBoard := TFavoriteBoardItem(Item);
		Board := FavBoard.Item;
		if Board <> nil then begin
			if (FTreeType = gtt2ch) and (FActiveBBS <> Board.ParentCategory.ParenTBBS) then
				ShowBBSTree( Board.ParentCategory.ParenTBBS );
			SelectTreeNode(Board, True);
		end;
	end else if TObject(Item) is TFavoriteThreadItem then begin
		FavThread := TFavoriteThreadItem(Item);
		ThreadItem := FavThread.Item;
		if ThreadItem = nil then
			Exit;

		InsertBrowserTab(ThreadItem, ActiveTab);

		if GikoSys.Setting.ListOrientation = gloHorizontal then begin
			if GikoSys.Setting.ListWidthState = glsMin then begin
				BrowserMaxAndFocusAction.Execute;
			end;
		end else begin
			if GikoSys.Setting.ListHeightState = glsMin then begin
				BrowserMaxAndFocusAction.Execute;
			end;
		end;
	end;
end;

procedure TGikoForm.FavoriteAddActionUpdate(Sender: TObject);
begin
	FavoriteAddAction.Enabled := (GetActiveContent <> nil);
end;

procedure TGikoForm.BoardFavoriteAddActionExecute(Sender: TObject);
begin
	if TObject(ListView.Selected.Data) is TBoard then
		ShowFavoriteAddDialog(TObject(ListView.Selected.Data));
end;

procedure TGikoForm.BoardFavoriteAddActionUpdate(Sender: TObject);
begin
	BoardFavoriteAddAction.Enabled := (GetActiveList is TCategory) and (ListView.SelCount > 0);
end;

procedure TGikoForm.ThreadFavoriteAddActionExecute(Sender: TObject);
begin
	if TObject(ListView.Selected.Data) is TThreadItem then
		ShowFavoriteAddDialog(TObject(ListView.Selected.Data));
end;

procedure TGikoForm.ThreadFavoriteAddActionUpdate(Sender: TObject);
begin
	ThreadFavoriteAddAction.Enabled := (GetActiveList is TBoard) and (ListView.SelCount > 0);
end;

procedure TGikoForm.TreeSelectFavoriteAddActionExecute(Sender: TObject);
begin
	ShowFavoriteAddDialog(TObject(FClickNode.Data));
end;

procedure TGikoForm.FavoriteArrangeActionExecute(Sender: TObject);
var
	Dlg: TFavoriteArrangeDialog;
begin
	Dlg := TFavoriteArrangeDialog.Create(Self);
	try
		Dlg.ShowModal;
	finally
		Dlg.Release;
	end;
	PostMessage( Handle, USER_SETLINKBAR, 0, 0 );
end;

procedure TGikoForm.BBSMenuItemOnClick(
	Sender	: TObject
);
begin

	if Sender is TBBSMenuItem then
		ShowBBSTree( TBBSMenuItem( Sender ).Data );

end;

procedure TGikoForm.MainCoolBarResize(Sender: TObject);
begin
	TopPanel.Height := Max(MainCoolBar.Height, AnimePanel.Height);
end;

procedure TGikoForm.MoveToActionExecute(Sender: TObject);
var
	URL: string;
	idx: Integer;
begin
	URL := Trim(AddressComboBox.Text);
	MoveToURL(URL);

	idx := AddressComboBox.Items.IndexOf(URL);
	if idx = -1 then begin
		AddressComboBox.Items.Insert(0, URL);
		if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
			AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
	end else begin
		AddressComboBox.Items.Delete(idx);
		AddressComboBox.Items.Insert(0, URL);
	end;
end;

procedure TGikoForm.MoveToURL(URL: string);

var
	protocol, host, path, document, port, bookmark : string;
	URL2, protocol2, host2, path2, document2, port2, bookmark2 : string;
	tmp1, tmp2: string;
	BBSID, BBSKey: string;
	Board: TBoard;
	ThreadItem: TThreadItem;
	i, bi					: Integer;
	boardURL			: string;
	tmpThread			: TThreadItem;
//	category			: TCategory;
//	categoryNode	: TTreeNode;
//	boardNode			: TTreeNode;
	shiftDown			: Boolean;
	ctrlDown			: Boolean;
begin

	GikoSys.ParseURI( URL, protocol, host, path, document, port, bookmark );
	GikoSys.Parse2chURL( URL, path, document, BBSID, BBSKey );


	shiftDown	:= GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
    ctrlDown	:= GetAsyncKeyState(VK_CONTROL) = Smallint($8001);
    if shiftDown then begin
    	GikoSys.OpenBrowser(URL, gbtUserApp);
        Exit;
    end else if ctrlDown then begin
    	GikoSys.OpenBrowser(URL, gbtIE);
        Exit;
	end;

	//===== ƒvƒ‰ƒOƒCƒ“
	try
		//ì‹Æ’†//
		bi := High( BoardPlugIns );
		for i := Low( BoardPlugIns ) to bi do begin
			if Assigned( Pointer( BoardPlugIns[ i ].Module ) ) then begin
				case BoardPlugIns[ i ].AcceptURL( URL ) of
				atThread:
					begin
						tmpThread		:= TThreadItem.Create( BoardPlugIns[ i ], URL );
						boardURL		:= tmpThread.BoardPlugIn.GetBoardURL( DWORD( tmpThread ) );
						Board				:= BBSsFindBoardFromURL( boardURL );
						if Board = nil then begin
							// ¦ì‚Á‚Ä‚à’Ç‰Á‚·‚é‚Æ‚±‚ë‚ª–³‚¢‚Ì‚ÅŒƒ‚µ‚­•Û—¯
							//GikoSys.OpenBrowser(URL, gbtUserApp);
							//Exit;
							{
							Board := GikoSys.GetUnknownBoard( tmpThread.BoardPlugIn, boardURL );
							if (FTreeType = gtt2ch) and (FActiveBBS = BBSs[ 1 ]) then
								ShowBBSTree( BBSs[ 1 ] );
							}
						end else begin
							if not Board.IsThreadDatRead then begin
								GikoSys.ReadSubjectFile( Board );
								Exit;
							end;
						end;

						ThreadItem := Board.FindThreadFromFileName( tmpThread.FileName );
						if ThreadItem = nil then begin
							ThreadItem := tmpThread;
							Board.Insert( 0, ThreadItem );
							if ActiveList is TBoard then begin
								if TBoard(ActiveList) = Board then
									ListView.Items.Count := ListView.Items.Count + 1;
							end;
							InsertBrowserTab( ThreadItem );
							DownloadContent( ThreadItem );
							Exit;
						end else begin
							tmpThread.Free;
							InsertBrowserTab( ThreadItem );
							if not ThreadItem.IsLogFile then begin
								DownloadContent( ThreadItem );
							end;
							Exit;
						end;

						//Exit;
					end;

				atBoard:
					begin
						Board := BBSsFindBoardFromURL( URL );
						if Board <> nil then begin
							if FActiveBBS <> Board.ParentCategory.ParenTBBS then
								ShowBBSTree( Board.ParentCategory.ParenTBBS );
							SelectTreeNode( Board, True );
							Exit;
						end;
					end;
				end;
			end;
		end;
	except
		// exception ‚ª”­¶‚µ‚½ê‡‚Í“à•”ˆ—‚É”C‚¹‚½‚¢‚Ì‚Å‚±‚±‚Å‚Í‰½‚à‚µ‚È‚¢
	end;


	if (Length( Trim(BBSKey) ) > 0) and (Length( Trim(BBSID) ) > 0) then begin
		boardURL := GikoSys.Get2chThreadURL2BoardURL( URL );
		Board := BBSsFindBoardFromURL( boardURL );
		if Board = nil then
			Board := BBSsFindBoardFromBBSID( BBSID );

		if Board = nil then begin
			// ¦ì‚Á‚Ä‚à’Ç‰Á‚·‚é‚Æ‚±‚ë‚ª–³‚¢‚Ì‚ÅŒƒ‚µ‚­•Û—¯
			//@‰ß‹ŽƒƒO‘qŒÉ‚©‚çAƒ_ƒEƒ\‚µ‚½ƒXƒŒ‚ª”­Œ©‚Å‚«‚È‚¢‚Ì‚Å‚±‚±‚Å’T‚·‚æ‚¤‚É‚·‚é (2004/01/22)
			Board := BBSs[ 0 ].FindBBSID( Copy(BBSID, 1 , Length(BBSID) - 1) );
		end;
		if Board = nil then begin
			 // “ü‚é‚×‚«”Â‚ªŒ©‚Â‚©‚ç‚È‚©‚Á‚½‚Ì‚ÅA•’Ê‚Ìƒuƒ‰ƒEƒU‚ÅŠJ‚­
			 GikoSys.OpenBrowser(URL, gbtUserApp);
			 Exit;
		end else begin
			// ŠO•”‚Ì”Â‚È‚Ì‚É2ch‚ÌURL‚É‚³‚ê‚Ä‚µ‚Ü‚Á‚½“z‚ð‚±‚±‚ÅŠm”F‚·‚é
			URL2 :=  Board.URL;
			GikoSys.ParseURI(URL2 , protocol2, host2, path2, document2, port2, bookmark2 );
			tmp1 := Copy(host, AnsiPos('.', host) + 1, Length(host));
			tmp2 := Copy(host2, AnsiPos('.', host2) + 1, Length(host2));
			if (tmp1 <> tmp2) then begin
				GikoSys.OpenBrowser(URL, gbtUserApp);
				Exit;
			end;
		end;

		if not Board.IsThreadDatRead then
			GikoSys.ReadSubjectFile(Board);
		URL := GikoSys.Get2chBrowsableThreadURL( URL );
		ThreadItem := Board.FindThreadFromURL( URL );
		//@‰ß‹ŽƒƒO‘qŒÉ‚©‚çAƒ_ƒEƒ\‚µ‚½ƒXƒŒ‚ª”­Œ©‚Å‚«‚È‚¢‚Ì‚Å‚±‚±‚Å’T‚·‚æ‚¤‚É‚·‚é (2004/01/22)
		if ThreadItem = nil then begin
			ThreadItem := Board.FindThreadFromFileName( BBSKey + '.dat' );
		end;

		if ThreadItem = nil then begin
			//shift -> Ý’èƒuƒ‰ƒEƒUi–³‚¯‚ê‚ÎIEj
			//ctrl	-> IE
			{shiftDown	:= GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
			ctrlDown	:= GetAsyncKeyState(VK_CONTROL) = Smallint($8001);
			if shiftDown then
				GikoSys.OpenBrowser(URL, gbtUserApp)
			else if ctrlDown then
				GikoSys.OpenBrowser(URL, gbtIE)
			else begin
			}
			ThreadItem := TThreadItem.Create( nil, URL );
			ThreadItem.FileName := ChangeFileExt(BBSKey, '.dat');
			if AnsiPos(Host, Board.URL) = 0 then
				ThreadItem.DownloadHost := Host
			else
				ThreadItem.DownloadHost := '';
			Board.Insert(0, ThreadItem);
			if ActiveList is TBoard then begin
				if TBoard(ActiveList) = Board then
					ListView.Items.Count := ListView.Items.Count + 1;
			end;
			InsertBrowserTab(ThreadItem);
			DownloadContent(ThreadItem);
			{end;}
		end else begin
			if ThreadItem.IsLogFile then
				InsertBrowserTab(ThreadItem)
			else begin
				if AnsiPos(Host, Board.URL) = 0 then
					ThreadItem.DownloadHost := Host
				else
					ThreadItem.DownloadHost := '';
				InsertBrowserTab(ThreadItem);
				DownloadContent(ThreadItem);
			end;
		end;
	end else begin
    Board := BBSsFindBoardFromURL( URL );
    if Board = nil then begin
			GikoSys.OpenBrowser(URL, gbtAuto);
    end else begin
	  if FActiveBBS <> Board.ParentCategory.ParenTBBS then
        ShowBBSTree( Board.ParentCategory.ParenTBBS );
      SelectTreeNode( Board, True );
    end;
	end;
end;

procedure TGikoForm.AddressToolBarResize(Sender: TObject);
begin
	AddressComboBox.Width := AddressToolBar.Width - MoveToToolButton.Width - 10;
	CoolBarResized( Sender, MainCoolBar );
end;

procedure TGikoForm.AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
	Shift: TShiftState);
begin
	if Key = VK_RETURN then
		MoveToAction.Execute;
end;

procedure TGikoForm.BrowserEnter(Sender: TObject);
begin
	Browser.DoObjectVerb(OLEIVERB_UIACTIVATE);
end;

procedure TGikoForm.WMCopyData(var Message: TWMCopyData);
var
	CDS:PCopyDataStruct;
	PC:PChar;
	sURL: string;
begin
	CDS := Message.CopyDataStruct;
	GetMem(PC, CDS^.cbData);
	try
		lstrcpy(PC,CDS^.lpData);
		SetString(sURL, PC,lstrlen(PC));
		MoveToURL(sURL);
	finally
		FreeMem(PC);
	end;
	Message.Result := 1;
end;

procedure TGikoForm.WndProc(var Message: TMessage);
begin
	try
		case Message.Msg of
		CM_DIALOGCHAR:
			if not (ssAlt in KeyDataToShiftState(TWMChar(Message).KeyData)) then
				Exit;
		WM_SYSCOMMAND:
			if Message.WParam = SC_MINIMIZE then
				OnMinimize;
		USER_TREECLICK:
			TreeClick( TreeView.Selected );
		USER_RESIZED:
			OnResized;
		USER_MINIMIZED:
			OnMinimized;
		USER_SETLINKBAR:
			SetLinkBar;
		end;

		inherited;
	except
	end;
end;

procedure TGikoForm.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
var
	hComboEdit: THandle;
//	KeyData: Integer;
begin
	Handled := False;
	if AddressComboBox.Focused or SelectComboBox.Focused then begin
		if Msg.CharCode in [VK_BACK] then begin
			hComboEdit := GetFocus;
			if hComboEdit <> 0 then
				SendMessage(hComboEdit, WM_CHAR, Msg.CharCode, Msg.KeyData);
//				SendMessage(hComboEdit, WM_CHAR, Msg.CharCode, $000E0001);
			Handled := True;
		end;
		if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT] then begin
			hComboEdit := GetFocus;
			if hComboEdit <> 0 then
				SendMessage(hComboEdit, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
			Handled := True;
		end;
{	end else begin
		//ƒƒjƒ…[‚Ìƒtƒ@ƒCƒ‹(F)‚Æ‚©‚ÅF‚ð’P‘Ì‚Å‰Ÿ‚µ‚½‚Æ‚«‚É‘I‘ð‚³‚ê‚Ä‚µ‚Ü‚¤Œ»Û‚ð‰ñ”ð
		KeyData := Msg.KeyData;
		if (KeyData and $20000000) = 0 then begin
			if Msg.CharCode in [Ord('F'), Ord('V'), Ord('B'), Ord('R'),
													Ord('A'), Ord('T'), Ord('H')] then begin
				if not ActionList.IsShortCut(Msg) then begin
					Handled := True;
				end;
			end;
		end;}
	end;
end;

procedure TGikoForm.BrowserTabVisibleActionExecute(Sender: TObject);
begin
	GikoSys.Setting.BrowserTabVisible := BrowserTabVisibleAction.Checked;
	SetBrowserTabState;
end;

procedure TGikoForm.BrowserTabTopActionExecute(Sender: TObject);
begin
	BrowserTabBottomAction.Checked := False;
	BrowserTabTopAction.Checked := True;
	GikoSys.Setting.BrowserTabPosition := gtpTop;
	SetBrowserTabState;
end;

procedure TGikoForm.BrowserTabBottomActionExecute(Sender: TObject);
begin
	BrowserTabTopAction.Checked := False;
	BrowserTabBottomAction.Checked := True;
	GikoSys.Setting.BrowserTabPosition := gtpBottom;
	SetBrowserTabState;
end;

procedure TGikoForm.BrowserTabTabStyleActionExecute(Sender: TObject);
begin
	BrowserTabButtonStyleAction.Checked := False;
	BrowserTabFlatStyleAction.Checked := False;
	BrowserTabTabStyleAction.Checked := True;
	GikoSys.Setting.BrowserTabStyle := gtsTab;
	SetBrowserTabState;
end;

procedure TGikoForm.BrowserTabButtonStyleActionExecute(Sender: TObject);
begin
	BrowserTabTabStyleAction.Checked := False;
	BrowserTabFlatStyleAction.Checked := False;
	BrowserTabButtonStyleAction.Checked := True;
	GikoSys.Setting.BrowserTabStyle := gtsButton;
	SetBrowserTabState;
end;

procedure TGikoForm.BrowserTabFlatStyleActionExecute(Sender: TObject);
begin
	BrowserTabFlatStyleAction.Checked := True;
	BrowserTabTabStyleAction.Checked := False;
	BrowserTabButtonStyleAction.Checked := False;
	GikoSys.Setting.BrowserTabStyle := gtsFlat;
	SetBrowserTabState;
end;

procedure TGikoForm.PreviewTimerTimer(Sender: TObject);
var
	p: TPoint;
	ARect: TRect;
	sl: TStringList;
	html: string;
	HtmlFileName: string;

	NavURL: OleVariant;
	Flags: OleVariant;
	TargetFrameName: OleVariant;
	PostData: OleVariant;
	Headers: OleVariant;
	WindowHeight: Integer;
	WindowWidth: Integer;

//	Style: Longint;
	Referer: string;
	Protocol, Host, Path, Document, Port, Bookmark: string;
begin
	PreviewTimer.Enabled := False;

	GetCursorpos(p);

	case GikoSys.Setting.PreviewSize of
		gpsXSmall: begin
			WindowWidth := 128;
			WindowHeight := 96;
		end;
		gpsSmall: begin
			WindowWidth := 256;
			WindowHeight := 192;
		end;
		gpsLarge: begin
			WindowWidth := 512;
			WindowHeight := 384;
		end;
		gpsXLarge: begin
			WindowWidth := 640;
			WindowHeight := 480;
		end;
		else begin	//gpsMedium
			WindowWidth := 384;
			WindowHeight := 288;
		end;
	end;

	ARect := Rect(0, 0, WindowWidth, WindowHeight);

	case GikoSys.Setting.PopupPosition of
		gppRightTop: 		OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) -	15);
		gppRight: 			OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
		gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
		gppTop:					OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) -	15);
		gppCenter:			OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
		gppBottom:			OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
		gppLeftTop:			OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) -	15);
		gppLeft:				OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
		gppLeftBottom: 	OffsetRect(ARect, p.x + 15, p.y + 15);		//ƒMƒRƒiƒrƒXƒŒ ƒp[ƒg‚P‚Ì453Ž‚ÉŠ´ŽÓ
	end;

	html := '<html><head>'#13#10
				+ '<SCRIPT>'#13#10
				+ 'function init() {'#13#10
				+ '	if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
				+ '	} else {'#13#10
				+ '		var dh, ih;'#13#10
				+ '		dh = document.body.clientWidth / document.body.clientHeight;'#13#10
				+ '		ih = Image1.width / Image1.height;'#13#10
				+ '		if (document.body.clientWidth < document.body.clientHeight) {'#13#10
				+ '			if (ih > dh)'#13#10
				+ '				Image1.width = document.body.clientWidth;'#13#10
				+ '			else'#13#10
				+ '				Image1.height = document.body.clientHeight;'#13#10
				+ '		} else {'#13#10
				+ '			if (ih < dh)'#13#10
				+ '				Image1.height = document.body.clientHeight;'#13#10
				+ '			else'#13#10
				+ '				Image1.width = document.body.clientWidth;'#13#10
				+ '		}'#13#10
				+ '	}'#13#10
				+ '	Message.style.display = "none";'#13#10
				+ '}'#13#10
				+ '</SCRIPT>'#13#10
				+ '</head>'#13#10
				+ '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
				+ '<div align="center" id="Message">ƒvƒŒƒrƒ…[ì¬’†</div>'#13#10
				+ '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
				+ '</body></html>';
	sl := TStringList.Create;
	try
		try
			HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
			sl.Text := AnsiReplaceStr(html, '%ImageURL%', FPreviewURL);
			sl.SaveToFile(HtmlFileName);
		finally
			sl.Free;
		end;
	except
	end;

	NavURL := HtmlFileName;
	Flags := 0;
	TargetFrameName := '';
	PostData := '';

	GikoSys.ParseURI(FPreviewURL, Protocol, Host, Path, Document, Port, Bookmark);
	Referer := Protocol + '://' + Host;
	if Port <> '' then
		Referer := Referer + ':' + Port;
	Referer := Referer + Path;
	Headers := 'Referer: ' + Referer;
	FPreviewBrowser.Navigate(NavURL, Flags, TargetFrameName, PostData, Headers);
	if ARect.Top + WindowHeight > Screen.DesktopHeight then
		ARect.Top := Screen.DesktopHeight - WindowHeight;
	if ARect.Left + WindowWidth > Screen.DesktopWidth then
		ARect.Left := Screen.DesktopWidth - WindowWidth;
	if ARect.Left < Screen.DesktopLeft then ARect.Left := Screen.DesktopLeft;
	if ARect.Bottom < Screen.DesktopTop then ARect.Bottom := Screen.DesktopTop;

	SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST, ARect.Left, ARect.Top, WindowWidth, WindowHeight, SWP_NOACTIVATE or SWP_HIDEWINDOW);
	ShowWindow(FPreviewBrowser.Handle, SW_SHOWNOACTIVATE);

//	Style := GetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE);
//	SetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE, Style xor WS_EX_APPWINDOW);

end;

procedure TGikoForm.WMSetCursor(var Message: TWMSetCursor);
begin
	if PreviewTimer.Enabled then
		PreviewTimer.Enabled := False;
	if (FHint <> nil) and (IsWindowVisible(FHint.Handle)) then begin
		FHint.ReleaseHandle;
		FHint.ClearAllRes;
	end;
	if (FPreviewBrowser <> nil) and (IsWindowVisible(FPreviewBrowser.Handle)) then
		ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
	Message.Result := 1;
	inherited;
end;

procedure TGikoForm.MessageHideButtonClick(Sender: TObject);
begin
	MsgBarCloseAction.Execute;
end;

function TGikoForm.OnDocumentContextMenu(Sender: TObject): WordBool;
var
	Doc: IHtmlDocument2;
	Range: IHTMLTxtRange;
	s: string;
	Num: Integer;
	ThreadItem: TThreadItem;
begin
	Result := False;
	Doc := FactiveContent.FBrowser.Document as IHtmlDocument2;
	if Assigned(Doc) then begin
		Range := Doc.selection.createRange as IHTMLTxtRange;
		s := CustomStringReplace(Range.text, '@', ' ');//‘SŠp‹ó”’‚ð”¼Šp‹ó”’‚É
		s := ZenToHan(Trim(s));
		if GikoSys.IsNumeric(s) then begin

			ThreadItem := GetActiveContent;
			if ThreadItem <> nil then begin
				Num := StrToInt(s);
				FHint.PopupType := gptThread;
				SetResPopupText(ThreadItem, Num, Num, False, False);
				if FHint.ResCount <> 0 then
					ShowTextPopup;
				Result := False;
			end else
				Result := True;
		end else begin
			Result := True;
		end;
	end;
end;

procedure TGikoForm.SetResPopupText(threadItem: TThreadItem; StNum, ToNum: Integer; Title, First: Boolean);
var
	i: Integer;
	tmp: string;
	FileName: string;
	Line: Integer;

	wkInt: Integer;

	Res: TResRec;
	Header: string;
	Body: string;
    boardPlugIn : TBoardPlugIn;
begin
	try
		if StNum > ToNum then begin
			wkInt := StNum;
			StNum := ToNum;
			ToNum := wkInt;
		end;

		//Å‘å10ƒŒƒX‚Ü‚Å•\Ž¦
		if StNum + 10 < ToNum then
			ToNum := StNum + 10;

		//ƒ^ƒCƒgƒ‹•\Ž¦
		if Title then
				if ThreadItem <> nil then
					FHint.Title := ThreadItem.Title;

        if ThreadItem <> nil then begin
            if ThreadItem.IsBoardPlugInAvailable then begin
                //===== ƒvƒ‰ƒOƒCƒ“‚É‚æ‚é•\Ž¦
                boardPlugIn		:= ThreadItem.BoardPlugIn;

                // ƒtƒHƒ“ƒg‚âƒTƒCƒY‚ÌÝ’è
                // •¶ŽšƒR[ƒh‚Íƒvƒ‰ƒOƒCƒ“‚É”C‚¹‚é
                for i := StNum to ToNum do begin
                    Line := i;
					//‚±‚±‚Å‚Q‚¿‚á‚ñ‚Ë‚é‚Ìdat‚ÌŒ`Ž®‚Å‚Ps“Ç‚Ýž‚ß‚ê‚Î¥¥¥B«“Ç‚ß‚é‚æ‚¤‚É‚È‚Á‚½
					tmp := boardPlugIn.GetDat( DWORD( threadItem ), i );
                    if (tmp <> '') And ( not GikoSys.FAbon.CheckAbonPopupRes(tmp) And( not GikoSys.FAbon.CheckIndividualAbonList(line))) then begin
                        Res := GikoSys.DivideStrLine(tmp);
                        if (GikoSys.Setting.ShowMail = false) or (Length(res.FMailTo) = 0) then
                        	Header := IntToStr(Line) + ' –¼‘OF ' + Res.FName + ' “Še“úF ' + Res.FDateTime
                        else
                        	Header := IntToStr(Line) + ' –¼‘OF ' + Res.FName + ' [' + res.FMailTo + '] “Še“úF ' + Res.FDateTime;


                        Body := CustomStringReplace(Res.FBody, '<br> ', #10,true);
                        Body := CustomStringReplace(Body, '<br>', #10,true);
                        Body := CustomStringReplace(Body, '</a>', '',true);
                        Body := GikoSys.DeleteLink(Body);
                        Body := CustomStringReplace(Body, '&lt;', '<');
                        Body := CustomStringReplace(Body, '&gt;', '>');
                        Body := CustomStringReplace(Body, '&quot;', '"');
                        Body := CustomStringReplace(Body, '&amp;', '&');
                        Body := CustomStringReplace(Body, '&nbsp;', ' ');

                        FHint.Add(Header, Body);
                        //FHint.Title := '';
                    end;
                end;
            end else begin
                for i := StNum to ToNum do begin
                    Line := i;
                    FileName := ThreadItem.FilePath;
                    tmp := GikoSys.ReadThreadFile(FileName, Line);
                    if (tmp <> '') And ( not GikoSys.FAbon.CheckAbonPopupRes(tmp) And( not GikoSys.FAbon.CheckIndividualAbonList(line))) then begin
                        Res := GikoSys.DivideStrLine(tmp);
                        if (GikoSys.Setting.ShowMail = false) or (Length(res.FMailTo) = 0) then 
	                        Header := IntToStr(Line) + ' –¼‘OF ' + Res.FName + ' “Še“úF ' + Res.FDateTime
                        else
                        	Header := IntToStr(Line) + ' –¼‘OF ' + Res.FName + ' [' + res.FMailTo + '] “Še“úF ' + Res.FDateTime; 

                        Body := CustomStringReplace(Res.FBody, '<br> ', #10,true);
                        Body := CustomStringReplace(Body, '<br>', #10,true);
                        Body := CustomStringReplace(Body, '</a>', '',true);
                        Body := GikoSys.DeleteLink(Body);
                        Body := CustomStringReplace(Body, '&lt;', '<');
                        Body := CustomStringReplace(Body, '&gt;', '>');
                        Body := CustomStringReplace(Body, '&quot;', '"');
                        Body := CustomStringReplace(Body, '&amp;', '&');
                         Body := CustomStringReplace(Body, '&nbsp;', ' ');
                        FHint.Add(Header, Body);
                        //FHint.Title := '';    //‚½‚Ô‚ñ‚±‚ê‚Í‚¢‚ç‚È‚¢‚ñ‚¾‚¯‚Ç‚ËB‚à‚¶‚ã   ‚â‚Á‚Ï‚è‚¢‚ç‚È‚©‚Á‚½i2004/01/13j
                    end;
                end;
            end;
        end;
    finally
    end;
end;

procedure TGikoForm.ShowTextPopup;
var
	p: TPoint;
	ARect: TRect;
begin
//	if Trim(s) = '' then
//		Exit;
	try
		FHint.Font.Name := GikoSys.Setting.HintFontName;
		FHint.Font.Size := GikoSys.Setting.HintFontSize;
		FHint.Font.Color := GikoSys.Setting.HintFontColor;
		FHint.Color := GikoSys.Setting.HintBackColor;
		FHint.HeaderBold := GikoSys.Setting.ResPopupHeaderBold;
		GetCursorpos(p);
		if FHint.PopupType = gptRaw then
			ARect := FHint.CalcHintRect(Screen.Width, FHint.Caption, nil)
		else
			ARect := FHint.CalcHintRect(Screen.Width, '', nil);
		case GikoSys.Setting.PopupPosition of
			gppRightTop: 		OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) -	15);
			gppRight: 			OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
			gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
			gppTop:					OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) -	15);
			gppCenter:			OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
			gppBottom:			OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
			gppLeftTop:			OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) -	15);
			gppLeft:				OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
			gppLeftBottom: 	OffsetRect(ARect, p.x + 15, p.y + 15);		//ƒMƒRƒiƒrƒXƒŒ ƒp[ƒg‚P‚Ì453Ž‚ÉŠ´ŽÓ
		end;
		//FHint.ActivateHint(ARect, s);
		if FHint.PopupType = gptRaw then
			FHint.ActivateHint(ARect, FHint.Caption)
		else
			FHint.ActivateHint(ARect, '');
	except
		FHint.ReleaseHandle;
		FHint.ClearAllRes;
	end;
end;

procedure TGikoForm.GikoHelpActionExecute(Sender: TObject);
var
	FileName: string;
begin
	FileName := GikoSys.GetAppDir + 'batahlp.chm';
	if not FileExists(FileName) then begin
		MsgBox(
			Handle,
			'ƒwƒ‹ƒv‚ªŒ©‚Â‚©‚è‚Ü‚¹‚ñ‚Å‚µ‚½' + #13#10 +
			'ƒwƒ‹ƒvƒtƒ@ƒCƒ‹‚ðƒMƒRƒiƒr‚ÌƒtƒHƒ‹ƒ_‚É’u‚¢‚Ä‚­‚¾‚³‚¢' + #13#10 +
			'ƒwƒ‹ƒv‚ÍƒMƒRƒiƒr‚ÌƒTƒCƒg‚É’u‚¢‚Ä‚ ‚è‚Ü‚·',
			'ƒGƒ‰[',
			MB_ICONSTOP);
		Exit;
	end;
	ShellExecute(Handle, 'open', PChar(FileName), '', PChar(GikoSys.GetAppDir), SW_SHOW);
end;

procedure TGikoForm.ToolButton18Click(Sender: TObject);
begin
	if FTreeType = gttHistory then begin
        ClearHistory;
		FHistoryList.Clear;
		TreeView.Items.Clear;
	end;
end;

procedure TGikoForm.KotehanActionExecute(Sender: TObject);
var
	Dlg: TKotehanDialog;
begin
	Dlg := TKotehanDialog.Create(Self);
	try
		Dlg.ShowModal;
	finally
		Dlg.Release;
	end;
end;

procedure TGikoForm.SetLinkBar;
var
	i: Integer;
	j: Integer;
	ToolButton: TLinkToolButton;
	MenuItem: TMenuItem;
	oldIgnoreResize : Boolean;
begin
	oldIgnoreResize := FIsIgnoreResize;
	FIsIgnoreResize := True;
	MainCoolBar.Bands.BeginUpdate;
	try
		LinkBarPopupMenu.Items.Clear;
		for i := LinkToolBar.ButtonCount - 1 downto 0 do
			//LinkToolBar.RemoveControl(LinkToolBar.Buttons[i]);
            LinkToolBar.Buttons[i].Free;
		for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
			if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
				for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
					ToolButton := TLinkToolButton.Create(LinkToolBar);
//                    ToolButton.Parent := LinkToolBar;
					if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteFolder then begin
						MenuItem := TMenuItem.Create(Self);
						CreateFavMenu(FavoriteTreeView.Items[i].Item[j], MenuItem);
						LinkBarPopupMenu.Items.Add(MenuItem);
						ToolButton.MenuItem := MenuItem;
						ToolButton.ImageIndex := TOOL_ICON_FAV_FOLDER;
					end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteBoardItem then begin
						ToolButton.ImageIndex := TOOL_ICON_FAV_BOARD;
						ToolButton.OnClick := FavoriteClick;
					end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteThreadItem then begin
						ToolButton.ImageIndex := TOOL_ICON_FAV_THREAD;
						ToolButton.OnClick := FavoriteClick;
					end;
					ToolButton.Caption := FavoriteTreeView.Items[i].Item[j].Text;
					ToolButton.Left := 10000;
					ToolButton.Data := FavoriteTreeView.Items[i].Item[j].Data;
					ToolButton.AutoSize := True;
					ToolButton.OnDragDrop := LinkToolButtonDragDrop;
					ToolButton.OnDragOver := FavoriteDragOver;
					ToolButton.OnMouseDown := LinkToolButtonOnMouseDown;
					ToolButton.OnMouseMove := LinkToolButtonOnMouseMove;
					ToolButton.OnMouseUp := LinkToolButtonOnMouseUp;
					ToolButton.OnStartDrag := LinkToolButtonStartDrag;
					//ToolButton.DragMode := dmAutomatic;
					ToolButton.DragMode := dmManual;
					ToolButton.PopupMenu := FavoriteTreePopupMenu;

					LinkToolBar.InsertControl(ToolButton);
				end;
				break;
			end;
		end;
{		if LinkToolBar.ButtonCount = 0 then begin
			ToolButton := TLinkToolButton.Create(LinkToolBar);
			ToolButton.Style := tbsButton;
			ToolButton.ImageIndex := -1;
			ToolButton.Caption := '';
			LinkToolBar.InsertControl(ToolButton);
		end;}
	finally
		MainCoolBar.Bands.EndUpdate;
		LoadCoolBarSettings;
		FIsIgnoreResize := oldIgnoreResize;
	end;
end;

procedure TGikoForm.FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
var
	Node: TTreeNode;
	bound: TRect;
	height: Integer;
	Change: Boolean;
begin

	if Sender = FavoriteTreeView then begin
		Node := FavoriteTreeView.GetNodeAt(X, Y);

		if Node = nil then
			Exit;

		bound := Node.DisplayRect( False );
		height := bound.Bottom - bound.Top;
		if (bound.Top + height / 2) <= Y then
			Node := FavoriteTreeView.GetNodeAt(X, Y + height);

		if Node = nil then
			Exit;

		if Node.IsFirstNode then
			Exit;

		Change := True;

		if FDropSpaceNode <> nil then
			if FDropSpaceNode.AbsoluteIndex = Node.AbsoluteIndex then
				Change := False;

		if Change then begin
			if FDropSpaceNode <> nil then
				FDropSpaceNode.Free;

			FDropSpaceNode := FavoriteDM.TreeView.Items.AddChildObject(Node.Parent, '', nil );
			FDropSpaceNode.MoveTo( Node, naInsert );
			FDropSpaceNode.ImageIndex := -1;
			FDropSpaceNode.SelectedIndex := -1;
		end;
	end;

	if Source = FavoriteTreeView then begin
		if FavoriteTreeView.Selected = FavoriteTreeView.Items.GetFirstNode then begin
			Accept := False;
			Exit;
		end;
		Accept := True;
	end else if Source = BrowserTab then
		Accept := True
	else if Source = ListView then
		Accept := True
	else if Source is TLinkToolButton then
		Accept := True
	else if Source = TreeView then
		Accept := True
	else
		Accept := False;
end;

procedure TGikoForm.FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin

	FavoriteDragOver( Sender, Source, X, Y, State, Accept );

end;
procedure TGikoForm.LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
begin
	 //	FDragging := true;
end;

procedure TGikoForm.LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
var
	SenderNode: TTreeNode;
	LinkToolButton: TLinkToolButton;
begin

	LinkToolButton := TLinkToolButton( Sender );
	SenderNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );

	FavoriteDragDrop( SenderNode, Source );

end;

procedure TGikoForm.LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
	favButton			: TLinkToolButton;
	favThreadItem	: TFavoriteThreadItem;
begin

	case Button of
	mbMiddle:
		begin
			if Sender is TLinkToolButton then begin
				favButton := TLinkToolButton( Sender );
				if TObject( favButton.Data ) is TFavoriteThreadItem then begin
					favThreadItem := TFavoriteThreadItem( favButton.Data );
					if favThreadItem.Item <> nil then
						InsertBrowserTab( favThreadItem.Item, False );
				end;
			end;
		end;
	end;

end;

procedure TGikoForm.LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
	Now : Cardinal;
begin
	TToolButton( Sender ).DragMode := dmManual;
	if ssLeft in Shift then begin
//		TToolButton( Sender ).Down := true;   // ƒŠƒ“ƒNƒc[ƒ‹ƒo[‚Ì‹““®•sR‚ÌŒ´ˆö‚Ì‚æ‚¤‚È‚Ì‚ÅƒRƒƒ“ƒgƒAƒEƒg‚µ‚½(2003-dec-02)
		if FDragTime = 0 then begin
			FDragTime := GetTickCount();
		end else begin
			Now := GetTickCount();
			if (Now - FDragTime) > 500 then begin
				if FDragButton <> TToolButton( Sender ) then begin
					try
						FDragButton := TToolButton( Sender );
						TToolButton(Sender).BeginDrag(false ,5);
						FDragTime := 0;
					except
						{$IF Defined(debug)}
						ShowMessage('Error');
						{$IFEND}
					end;
				end;
			end;
		end;
	end else begin
		FDragTime := 0;
	end;
end;

procedure TGikoForm.LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
	FDragTime := 0;
end;

function TGikoForm.GetWidthAllToolButton(ToolBar: TToolBar): Integer;
var
	i: Integer;
begin
	Result := 0;
	for i := 0 to ToolBar.ButtonCount - 1 do
		Result := Result + ToolBar.Buttons[i].Width;
end;

procedure TGikoForm.MainCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
var
	Control : TWinControl;
	i, idx	: Integer;
begin
	Control := FindControl(BandInfo^.hwndChild);
	if Control = nil then
		Exit;
	idx := 0;
	for i := MainCoolBar.Bands.Count - 1 downto 0 do begin
		if MainCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
			idx := MainCoolBar.Bands[ i ].ID;
			Break;
		end;
	end;
	Canvas.Font.Handle := GetStockObject( DEFAULT_GUI_FONT );
	if (Control = MenuToolBar) or (Control = StdToolBar) then begin
		BandInfo^.fMask				:= BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
		BandInfo^.fStyle			:= BandInfo.fStyle or RBBS_USECHEVRON;
		BandInfo^.cxMinChild	:= 0;
		BandInfo^.cx					:= GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth;
		BandInfo^.cxIdeal			:= GetWidthAllToolButton(TToolBar(Control));
	end else if Control = LinkToolBar then begin
		BandInfo^.fMask				:= BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
		BandInfo^.fStyle			:= BandInfo.fStyle or RBBS_USECHEVRON;
		BandInfo^.cxMinChild	:= 0;
		BandInfo^.cx					:= GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( 'ƒŠƒ“ƒN' );
		BandInfo^.cxIdeal			:= GetWidthAllToolButton(TToolBar(Control));
	end else begin // AddressToolBar
		BandInfo^.fMask				:= BandInfo.fMask or RBBIM_CHILDSIZE;
		BandInfo^.cxMinChild	:= 0;
		BandInfo^.cx					:= GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( 'ƒAƒhƒŒƒX' );
	end;
end;

procedure TGikoForm.MainCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
var
	i : Integer;
	Idx: Integer;
	p: TPoint;
begin
	ChevronPopupMenu.Items.Clear;
	Idx := 0;
	for i := 0 to MainCoolBar.Bands.Count - 1 do begin
		if MainCoolBar.Bands[ i ].Visible then begin
			if Idx = Int64(RebarChevron^.uBand) then begin
				Idx := i;
				break;
			end;
			Inc( Idx );
		end;
	end;
	if (Idx >= 0) and (MainCoolBar.Bands.Count > Idx) then begin
		if MainCoolBar.Bands[Idx].Control = MenuToolbar then begin
			MenuBarChevronMenu;
		end else if MainCoolBar.Bands[Idx].Control = StdToolbar then begin
			ToolBarChevronMenu(StdToolBar);
		end else if MainCoolBar.Bands[Idx].Control = LinkToolbar then begin
			LinkBarChevronMenu;
		end else
			Exit;
		p := MainCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
		ChevronPopupMenu.Popup(p.x, p.y);
	end;
end;

procedure TGikoForm.MenuBarChevronMenu;
	procedure SetSubMenu(MenuItem: TMenuItem; PopupItem: TMenuItem);
	var
		i: Integer;
		Item: TMenuItem;
	begin
		MenuItem.Click;
		for i := 0 to MenuItem.Count - 1 do begin
//			Item := nil;
			if MenuItem[i] is TFavoriteMenuItem then begin
				Item := TFavoriteMenuItem.Create(Self);
				TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(MenuItem[i]).Data;
			end else
				Item := TMenuItem.Create(Self);
			Item.Caption := MenuItem[i].Caption;
			Item.Action := MenuItem[i].Action;
			Item.ImageIndex := MenuItem[i].ImageIndex;
			Item.OnClick := MenuItem[i].OnClick;
			PopupItem.Add(Item);
			if MenuItem[i].Count > 0 then
				SetSubMenu(MenuItem[i], Item);
		end;
	end;
var
	i: Integer;
	w: Integer;
	bw: Integer;
	Item: TMenuItem;
begin
	ChevronPopupMenu.Items.Clear;
	ChevronPopupMenu.Images := MainMenu.Images;
	bw := GetWidthAllToolButton(MenuToolBar);
	if MenuToolBar.Width < bw then begin
		w := 0;
		for i := 0 to MenuToolBar.ButtonCount - 1 do begin
			w := w + MenuToolBar.Buttons[i].Width;
			if MenuToolBar.Width <= w then begin
				Item := TMenuItem.Create(Self);
				Item.Caption := MenuToolBar.Buttons[i].MenuItem.Caption;
				//Item.Action := MenuToolBar.Buttons[i].MenuItem.Action;
				ChevronPopupMenu.Items.Add(Item);
				SetSubMenu(MenuToolbar.Buttons[i].MenuItem, Item);
			end;
		end;
	end;
end;

procedure TGikoForm.ToolBarChevronMenu(ToolBar: TToolBar);
	procedure SetSubMenu(PopupMenu: TPopupMenu; PopupItem: TMenuItem);
	var
		i: Integer;
		Item: TMenuItem;
	begin
		if Assigned(PopupMenu.OnPopup) then
			PopupMenu.OnPopup(nil);
		for i := 0 to PopupMenu.Items.Count - 1 do begin
//			Item := nil;
			if PopupMenu.Items[i] is TFavoriteMenuItem then begin
				Item := TFavoriteMenuItem.Create(Self);
				TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(PopupMenu.Items[i]).Data;
			end else
			Item := TMenuItem.Create(Self);
			Item.Caption := PopupMenu.Items[i].Caption;
			Item.Action := PopupMenu.Items[i].Action;
			Item.ImageIndex := PopupMenu.Items[i].ImageIndex;
			Item.OnClick := PopupMenu.Items[i].OnClick;
			PopupItem.Add(Item);
		end;
	end;
var
	i: Integer;
	w: Integer;
	bw: Integer;
	Item: TMenuItem;
begin
	ChevronPopupMenu.Items.Clear;
	ChevronPopupMenu.Images := ToolBar.HotImages;
	bw := GetWidthAllToolButton(ToolBar);
	if ToolBar.Width < bw then begin
		w := 0;
		for i := 0 to ToolBar.ButtonCount - 1 do begin
			w := w + ToolBar.Buttons[i].Width;
			if ToolBar.Width <= w then begin
				Case ToolBar.Buttons[i].Tag of
				0:
					begin
						Item := TMenuItem.Create(Self);
						if ToolBar.Buttons[i].Style = tbsSeparator then
							Item.Caption := '-'
						else begin
							Item.Caption := ToolBar.Buttons[i].Caption;
							Item.Action := ToolBar.Buttons[i].Action;
							//Item.Visible := True;
						end;
						ChevronPopupMenu.Items.Add(Item);
						if ToolBar.Buttons[i].DropdownMenu <> nil then begin
							Item.Action := nil;
							Item.OnClick := nil;
							SetSubMenu(ToolBar.Buttons[i].DropdownMenu, Item);
						end;
					end;
				else
					// «—ˆ‚Ì‚½‚ß‚Ì—\–ñ
				end;
			end;
		end;
	end;
end;

procedure TGikoForm.LinkBarChevronMenu;
var
	i: Integer;
	j: Integer;
	w: Integer;
	Item: TFavoriteMenuItem;
	bw: Integer;
	Button: TLinkToolButton;
begin
	ChevronPopupMenu.Items.Clear;
	ChevronPopupMenu.Images := LinkToolBar.Images;
	bw := GetWidthAllToolButton(LinkToolBar);
	if LinkToolBar.Width < bw then begin
		w := 0;
		for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
			if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
				for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
					w := w + LinkToolBar.Buttons[j].Width;
					if LinkToolBar.Width <= w then begin
						if LinkToolBar.Buttons[j] is TLinkToolButton then begin
							Button := TLinkToolButton(LinkToolBar.Buttons[j]);
							Item := TFavoriteMenuItem.Create(Self);
							if TObject(Button.Data) is TFavoriteFolder then begin
								CreateFavMenu(FavoriteTreeView.Items[i].Item[j], Item);
							end else if TObject(Button.Data) is TFavoriteBoardItem then begin
								Item.OnClick := FavoriteClick;
							end else if TObject(Button.Data) is TFavoriteThreadItem then begin
								Item.OnClick := FavoriteClick;
							end;
							Item.Data := Button.Data;
							Item.Caption := LinkToolBar.Buttons[j].Caption;
							Item.ImageIndex := LinkToolBar.Buttons[j].ImageIndex;
							ChevronPopupMenu.Items.Add(Item);
						end;
					end;
				end;
				break;
			end;
		end;
	end;
end;

procedure TGikoForm.ListCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
var
	Control: TWinControl;
	i, idx	: Integer;
begin
	Control := FindControl(BandInfo^.hwndChild);
	if Control = nil then
		Exit;
	idx := 0;
	for i := ListCoolBar.Bands.Count - 1 downto 0 do begin
		if ListCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
			idx := ListCoolBar.Bands[ i ].ID;
			Break;
		end;
	end;
	if Control = ListToolBar then begin
		BandInfo^.fMask				:= BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
		BandInfo^.fStyle			:= BandInfo.fStyle or RBBS_USECHEVRON;
		BandInfo^.cxMinChild	:= 0;
		BandInfo^.cx					:= GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
		BandInfo^.cxIdeal			:= GetWidthAllToolButton(TToolBar(Control));
	end else begin
		BandInfo^.fMask				:= BandInfo.fMask or RBBIM_CHILDSIZE;
		BandInfo^.cxMinChild	:= 0;
		BandInfo^.cx					:= GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
	end;
end;

procedure TGikoForm.ListCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
var
	Idx: Integer;
	p: TPoint;
begin
	ChevronPopupMenu.Items.Clear;
	Idx := RebarChevron^.uBand;
	if (Idx >= 0) and (ListCoolBar.Bands.Count > Idx) then begin
		if ListCoolBar.Bands[Idx].Control = ListToolBar then begin
			ToolBarChevronMenu(ListToolBar);
		end else
			Exit;
		p := ListCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
		ChevronPopupMenu.Popup(p.x, p.y);
	end;
end;

procedure TGikoForm.BrowserCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
var
	Control: TWinControl;
	i, idx	: Integer;
begin
	Control := FindControl(BandInfo^.hwndChild);
	if Control = nil then
		Exit;
	idx := 0;
	for i := BrowserCoolBar.Bands.Count - 1 downto 0 do begin
		if BrowserCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
			idx := BrowserCoolBar.Bands[ i ].ID;
			Break;
		end;
	end;
	if Control = BrowserToolBar then begin
		BandInfo^.fMask				:= BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
		BandInfo^.fStyle			:= BandInfo.fStyle or RBBS_USECHEVRON;
		BandInfo^.cxMinChild	:= 0;
		BandInfo^.cx					:= GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
		BandInfo^.cxIdeal			:= GetWidthAllToolButton(TToolBar(Control));
	end else begin
		BandInfo^.fMask				:= BandInfo.fMask or RBBIM_CHILDSIZE;
		BandInfo^.cxMinChild	:= 0;
		BandInfo^.cx					:= GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
	end;
end;

procedure TGikoForm.BrowserCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
var
	Idx: Integer;
	p: TPoint;
begin
	ChevronPopupMenu.Items.Clear;
	Idx := RebarChevron^.uBand;
	if (Idx >= 0) and (BrowserCoolBar.Bands.Count > Idx) then begin
		if BrowserCoolBar.Bands[Idx].Control = BrowserToolBar then
			ToolBarChevronMenu(BrowserToolBar)
		else
			Exit;
		p := BrowserCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
		ChevronPopupMenu.Popup(p.x, p.y);
	end;
end;

procedure TGikoForm.ListViewColumnInfo(Sender: TObject;	var Column: PLVColumnA);
begin
	if Column^.iImage = -1 then begin
		Column^.mask := Column^.mask or LVCF_FMT;
	end else begin
		Column^.mask := Column^.mask or LVCF_FMT or LVCF_IMAGE;
		Column^.fmt := Column^.fmt or LVCFMT_IMAGE or LVCFMT_BITMAP_ON_RIGHT;
	end;
end;

procedure TGikoForm.ThreadEditorActionExecute(Sender: TObject);
var
	Editor: TEditorForm;
begin
	if not (GetActiveList is TBoard) then
		Exit;
	Editor := TEditorForm.Create(Self);
	Editor.SetBoard(TBoard(GetActiveList));
	Editor.Show;
	Editor.BodyEdit.SetFocus;
end;

procedure TGikoForm.ToolBarSettingActionExecute(Sender: TObject);
var
	Dlg: TToolBarSettingDialog;
	i: Integer;
	//Component: TComponent;
begin
	Dlg := TToolBarSettingDialog.Create(Self, ActionList);
	try
		Dlg.AddToolBar(StdToolBar, gttStandard);
		Dlg.AddToolBar(ListToolBar, gttList);
		Dlg.AddToolBar(BrowserToolBar, gttBrowser);
		case FToolBarSettingSender of
		tssMain:		Dlg.ToolBarIndex := 0;
		tssList:		Dlg.ToolBarIndex := 1;
		tssBrowser: Dlg.ToolBarIndex := 2;
		end;
		{
		if ToolBarSettingAction.ActionComponent.GetParentComponent is TPopupMenu then begin
			Component := TPopupMenu( ToolBarSettingAction.ActionComponent.GetParentComponent ).PopupComponent;

			if Component = MainCoolBar then
				Dlg.ToolBarComboBox.ItemIndex := 0
			else if Component = ListCoolBar then
				Dlg.ToolBarComboBox.ItemIndex := 1
			else if Component = BrowserCoolBar then
				Dlg.ToolBarComboBox.ItemIndex := 2;
		end;
		}
		if Dlg.ShowModal = mrOK then begin
			SetToolBarPopup;

			//Å“K•‚ðÄÝ’è‚·‚é‚½‚ß‚É“K“–‚ÈƒvƒƒpƒeƒB‚ð‚¢‚¶‚­‚é
			for i := 0 to MainCoolBar.Bands.Count - 1 do begin
				MainCoolBar.Bands[i].MinWidth := MainCoolBar.Bands[i].MinWidth + 1;
				MainCoolBar.Bands[i].MinWidth := MainCoolBar.Bands[i].MinWidth - 1;
			end;
			for i := 0 to ListCoolBar.Bands.Count - 1 do begin
				ListCoolBar.Bands[i].MinWidth := ListCoolBar.Bands[i].MinWidth + 1;
				ListCoolBar.Bands[i].MinWidth := ListCoolBar.Bands[i].MinWidth - 1;
			end;
			for i := 0 to BrowserCoolBar.Bands.Count - 1 do begin
				BrowserCoolBar.Bands[i].MinWidth := BrowserCoolBar.Bands[i].MinWidth + 1;
				BrowserCoolBar.Bands[i].MinWidth := BrowserCoolBar.Bands[i].MinWidth - 1;
			end;
			SaveToolBarSetting(StdToolBar);
			SaveToolBarSetting(ListToolBar);
			for i := ListToolBar.ControlCount - 1 downto 0 do
			begin
				if ListToolBar.Controls[ i ].Action = SelectItemAction then
				begin
					// ƒXƒŒƒbƒhiž‚Ì—×‚ÉƒZƒpƒŒ[ƒ^‚ª‚ ‚éê‡‚Í‰B‚·
					if (i + 1) < ListToolBar.ControlCount then
						if ListToolBar.Controls[ i + 1 ] is TToolButton then
							if TToolButton( ListToolBar.Controls[ i + 1 ] ).Style = tbsSeparator then
								ListToolBar.Controls[ i + 1 ].Visible := False;

					// ƒXƒŒƒbƒhižƒ{ƒ^ƒ“‚ð‰B‚·
					ListToolBar.Controls[ i ].Visible := False;
					// ƒXƒŒƒbƒhižƒtƒB[ƒ‹ƒh‚ð‘}“ü
					SelectComboBox.Left := ListToolBar.Controls[ i ].Left;
					SelectComboBox.Width := GikoSys.Setting.SelectComboBoxWidth;
					SelectComboBox.Parent := ListToolBar;
					// ƒXƒŒƒbƒhiž—p“ÆŽ©ƒZƒpƒŒ[ƒ^‚ð‘}“ü
					SelectComboBoxSplitter.Left := SelectComboBox.Left + SelectComboBox.Width;
					SelectComboBoxSplitter.Parent := ListToolBar;

					break;
				end;
			end;
			SaveToolBarSetting(BrowserToolBar);
		end;
	finally
		Dlg.Release;
		FToolBarSettingSender := tssNone;
	end;
end;

function TGikoForm.FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
var
	i : Integer;
begin

	for i := bar.ButtonCount - 1 downto 0 do begin
		if bar.Buttons[ i ].Action = action then begin
			Result := bar.Buttons[ i ];
			Exit;
		end;
	end;

	Result := nil;

end;

procedure TGikoForm.SetToolBarPopup;
var
	i									: Integer;
	aIEButton					: TToolButton;
	aCabinetBBSButton	: TToolButton;
begin
	for i := 0 to StdToolBar.ButtonCount - 1 do begin
	end;
	for i := 0 to ListToolBar.ButtonCount - 1 do begin
		if ListToolBar.Buttons[i].Action = IconStyle then
			ListToolBar.Buttons[i].DropdownMenu := ListIconPopupMenu;
		if ListToolBar.Buttons[i].Action = SelectReservAction then
			ListToolBar.Buttons[i].DropdownMenu := RoundNamePopupMenu;
	end;
	aIEButton					:= FindToolBarButton( BrowserToolBar, IEAction );
	if aIEButton <> nil then
		aIEButton.DropdownMenu					:= BrowserPopupMenu;
	aCabinetBBSButton	:= FindToolBarButton( StdToolBar, CabinetBBSAction );
	if aCabinetBBSButton <> nil then
		aCabinetBBSButton.DropdownMenu	:= BBSSelectPopupMenu;
end;

procedure TGikoForm.FormMouseWheel(Sender: TObject; Shift: TShiftState;
	WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
	Wnd: THandle;
	delta: Integer;
//	msg: TMessage;
const
	ICON_SIZE = 16;
begin
	Handled := False;
	Wnd := WindowFromPoint(MousePos);
	Handled := True;
	if WheelDelta > 0 then
		Delta := -1
	else
		Delta := 1;

	if (Wnd = BrowserTab.Handle) or
		 (Wnd = BrowserTab.Parent.Handle) then begin
		BrowserTab.ScrollTabs(Delta);
	end else if Wnd = ListView.Handle then begin
		if ListView.ViewStyle = vsList then
			ListView.Scroll( Delta * Mouse.WheelScrollLines * Abs( ListView.Font.Height ) + Delta * ICON_SIZE, 0 )
		else
			ListView.Scroll( 0, Delta * Mouse.WheelScrollLines * Abs( ListView.Font.Height ) + Delta * ICON_SIZE );
	end else begin
		Handled := False;
	end;
end;


procedure TGikoForm.SelectComboBoxChange(Sender: TObject);
begin
	if Length( SelectComboBox.Text ) = 0 then
	begin
		AllItemAction.Checked := True;
		LogItemAction.Checked := False;
		NewItemAction.Checked := False;
	end else begin
		// ƒ`ƒ‰‚Â‚­‚ÆŒ™‚¾‚©‚çAˆê‰ž‰Ÿ‚µ‚Ä‚ ‚é‚Æ‚«‚¾‚¯ˆ—‚·‚é
		if AllItemAction.Checked then
						AllItemAction.Checked := False;
		if LogItemAction.Checked then
						LogItemAction.Checked := False;
		if NewItemAction.Checked then
						NewItemaction.Checked := False;
	end;

	if Length( SelectComboBox.Text ) = 0 then
		SetListViewType( gvtAll )
	else
		SetListViewType( gvtUser, SelectComboBox.Text, false);
end;

procedure TGikoForm.SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
	Shift: TShiftState);
begin

	if Key = VK_Return then
	begin
		ModifySelectList;
	end else if Length( SelectComboBox.Text ) = 0 then
	begin
		AllItemAction.Checked := True;
		LogItemAction.Checked := False;
		NewItemAction.Checked := False;
	end else begin
		// ƒ`ƒ‰‚Â‚­‚ÆŒ™‚¾‚©‚çAˆê‰ž‰Ÿ‚µ‚Ä‚ ‚é‚Æ‚«‚¾‚¯ˆ—‚·‚é
		if AllItemAction.Checked then
			AllItemAction.Checked := False;
		if LogItemAction.Checked then
			LogItemAction.Checked := False;
		if NewItemAction.Checked then
			NewItemaction.Checked := False;
	end;

end;

procedure TGikoForm.SelectComboBoxExit(Sender: TObject);
begin

	ModifySelectList;

	if Length( SelectComboBox.Text ) = 0 then
	begin
		SelectComboBox.Text := SELECTCOMBOBOX_NAME;
		SelectComboBox.Color := SELECTCOMBOBOX_COLOR;
	end;

end;

// i‚èž‚ÝŒŸõ‚Ì—š—ðXV
procedure TGikoForm.ModifySelectList;
var
	idx : Integer;
	oldText : string;
begin

	try
		if SelectComboBox.Parent = nil then
			exit;

		if Length( SelectComboBox.Text ) > 0 then
		begin
			oldText := SelectComboBox.Text;
			idx := GikoSys.Setting.SelectTextList.IndexOf( oldText );
			if idx <> -1 then
				GikoSys.Setting.SelectTextList.Delete( idx );
			idx := SelectComboBox.Items.IndexOf( oldText );
			if idx <> -1 then
				SelectComboBox.Items.Delete( idx );
			GikoSys.Setting.SelectTextList.Insert( 0, oldText );
			SelectComboBox.Items.Insert( 0, oldText );
			SelectComboBox.Text := oldText;
		end;
	except
	end;

end;

//NGƒ[ƒhƒtƒ@ƒCƒ‹‚ð•ÒW‚·‚é‚½‚ß‚ÉŠJ‚­
procedure TGikoForm.NG1Click(Sender: TObject);
begin
	GikoSys.FAbon.EditNGwords;
end;
//NGƒ[ƒhƒtƒ@ƒCƒ‹‚ðÄ“Ç‚Ýž‚Ý‚·‚é
procedure TGikoForm.SelectResActionExecute(Sender: TObject);
var
	Dlg: TListSelectDialog;
	ThreadItem : TThreadItem;
	FilterList : TStringList;
	i, idx : Integer;
begin
	Dlg := TListSelectDialog.Create(Self);
	try
		Dlg.SelectComboBox.Items.Assign(GikoSys.Setting.SelectTextList);
		Dlg.SelectComboBox.Text := FSelectResWord;
		Dlg.ShowModal;
		if Dlg.ModalResult = mrOK then begin
			if Length( Dlg.SelectComboBox.Text ) = 0 then begin
				// ‹ó“ü—Í‚Å OK ‚Í‘SƒŒƒX•\Ž¦‚Æ“¯ˆÓ‹`
				AllResAction.Execute;
			end else begin
				// ƒ{ƒ^ƒ“‚ÌXV
				AllResAction.Checked := False;
				SelectResAction.Checked := True;

				// ÅŒã‚ÉÝ’è‚µ‚½‚à‚Ì‚ðŠo‚¦‚Ä‚¨‚­
				FSelectResWord := Dlg.SelectComboBox.Text;

				// ŒŸõ—š—ð‚ÌXV
				idx := GikoSys.Setting.SelectTextList.IndexOf(Dlg.SelectComboBox.Text);
				if idx <> -1 then
					GikoSys.Setting.SelectTextList.Delete(idx);
				GikoSys.Setting.SelectTextList.Insert(0, Dlg.SelectComboBox.Text);
				while Dlg.SelectComboBox.Items.Count > 100 do begin
					Dlg.SelectComboBox.Items.Delete(Dlg.SelectComboBox.Items.Count - 1);
				end;

				try
					if SelectComboBox.Parent <> nil then
						SelectComboBox.Items.Assign( GikoSys.Setting.SelectTextList );
				except
				end;

				// ƒtƒBƒ‹ƒ^‚ÌÝ’è
				FilterList := TStringList.Create;
				try
					GikoSys.FSelectResFilter.Reverse := True;
					FilterList.Delimiter := ' '; //‹æØ‚èŽq‚ð”¼ŠpƒXƒy[ƒX‚ÉÝ’è
					FilterList.DelimitedText := Dlg.SelectComboBox.Text;

					GikoSys.FSelectResFilter.LoadFromStringList( FilterList );
				finally
					FilterList.Destroy;
				end;

				// ƒXƒŒƒbƒh‚ÌÄ•`‰æ
				for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
                    TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
				end;
				ThreadItem := GetActiveContent;
				if ThreadItem <> nil then
					InsertBrowserTab( ThreadItem, True );
			end;
		end else if Length( FSelectResWord ) > 0 then begin
			// ƒ{ƒ^ƒ“‚ÌXV
			AllResAction.Checked := False;
			SelectResAction.Checked := True;
		end;
	finally
		Dlg.Release;
	end;

end;

procedure TGikoForm.SelectResActionUpdate(Sender: TObject);
begin
	SelectResAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
end;

procedure TGikoForm.FormKeyUp(Sender: TObject; var Key: Word;
	Shift: TShiftState);
begin
end;

// ‘S‚Ä‚ÌƒŒƒX‚ð•\Ž¦
procedure TGikoForm.AllResActionExecute(Sender: TObject);
var
	ThreadItem : TThreadItem;
	FilterList : TStringList;
	i: Integer;
begin
	if(FActiveContent <> nil) and (FActiveContent.FBrowser <> nil )
		and (FActiveContent.FBrowser.Busy) then Exit;

	// ƒ{ƒ^ƒ“‚ÌXV
	AllResAction.Checked := True;
	SelectResAction.Checked := False;

	if Length( FSelectResWord ) > 0 then begin
		// ƒtƒBƒ‹ƒ^•¶Žš—ñ‚ð‹ó‚É‚·‚é
		FilterList := TStringList.Create;
		try
			GikoSys.FSelectResFilter.LoadFromStringList( FilterList );
			GikoSys.FSelectResFilter.Reverse := False;
		finally
			FilterList.Destroy;
		end;

		FSelectResWord := '';

		// ƒXƒŒƒbƒh‚ðÄ•`‰æ
		for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
		end;
		ThreadItem := GetActiveContent;
		if ThreadItem <> nil then
			InsertBrowserTab( ThreadItem, True );
	end;
end;

procedure TGikoForm.AllResActionUpdate(Sender: TObject);
begin
	AllResAction.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
end;

procedure TGikoForm.ReloadClick(Sender: TObject);
var
	ThreadItem : TThreadItem;
	i: Integer;
begin
	if GikoSys.FAbon.ReLoadFromNGwordFile =false then begin
		MsgBox(Handle, 'NGƒ[ƒhƒtƒ@ƒCƒ‹‚ÌÄ“Ç‚Ýž‚Ý‚ÉŽ¸”s‚µ‚Ü‚µ‚½', 'ƒGƒ‰[', MB_OK or MB_ICONEXCLAMATION);
	end else begin
		for i := BrowserTab.Tabs.Count - 1 downto 0 do
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
			
		ThreadItem := GetActiveContent;
		if ThreadItem <> nil then
			InsertBrowserTab( ThreadItem, True );
	end;

end;

procedure TGikoForm.GoBackClick(Sender: TObject);
var
	ThreadItem : TThreadItem;
	s: string;
	i: Integer;
begin
	if GikoSys.FAbon.GoForward =false then begin
		MsgBox(Handle, 'ˆê‚Â‘O‚ÌNGƒ[ƒhƒtƒ@ƒCƒ‹‚Ì“Ç‚Ýž‚Ý‚ÉŽ¸”s‚µ‚Ü‚µ‚½', 'ƒGƒ‰[', MB_OK or MB_ICONEXCLAMATION);
	end else begin
		s := GikoSys.FAbon.NGwordname;
		StatusBar.Panels.Items[2].Text := s;
		StatusBar.Panels[2].Width := Max(StatusBar.Canvas.TextWidth(s), 100);
		StatusBarResize(Sender);
		for i := BrowserTab.Tabs.Count - 1 downto 0 do
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;

		ThreadItem := GetActiveContent;
		if ThreadItem <> nil then
			InsertBrowserTab( ThreadItem, True );
	end;

end;

procedure TGikoForm.GoFowardClick(Sender: TObject);
var
	ThreadItem : TThreadItem;
	s: string;
	i: Integer;
begin
	if GikoSys.FAbon.GoBack =false then begin
		MsgBox(Handle, 'ˆê‚ÂŒã‚ë‚ÌNGƒ[ƒhƒtƒ@ƒCƒ‹‚Ì“Ç‚Ýž‚Ý‚ÉŽ¸”s‚µ‚Ü‚µ‚½', 'ƒGƒ‰[', MB_OK or MB_ICONEXCLAMATION);
	end else begin
		s := GikoSys.FAbon.NGwordname;
		StatusBar.Panels.Items[2].Text := s;
		StatusBar.Panels[2].Width := Max(StatusBar.Canvas.TextWidth(s), 100);
		StatusBarResize(Sender);
		for i := BrowserTab.Tabs.Count - 1 downto 0 do
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;

		ThreadItem := GetActiveContent;
		if ThreadItem <> nil then
			InsertBrowserTab( ThreadItem, True );
	end;

end;

procedure TGikoForm.SelectComboBoxSplitterMouseMove(Sender: TObject;
	Shift: TShiftState; X, Y: Integer);
var
	pos : TPoint;
	w : Integer;
begin
	If (SelectComboBox.Parent <> nil) and (IsDraggingSelectComboBox) Then begin
		pos.X := X;
		pos.Y := Y;
		pos := SelectComboBoxSplitter.ClientToScreen( pos );
		w := SelectComboBox.Width + (pos.X - DraggingSelectComboBoxPosition.X);

		If w <= 50 Then Begin
			// ŽŸ‚ÌˆÚ“®‚ÌŠî€‚ªu‰ß‚¬‚Ä‚µ‚Ü‚Á‚½ˆÊ’uv‚Å‚Í‚È‚­
			// uŽ~‚Ü‚Á‚½(50pixel)ˆÊ’uv‚É‚È‚é‚æ‚¤‚É
			pos.X := pos.X + (50 - w);

			// ¬‚³‚­‚È‚è‚·‚¬‚È‚¢‚æ‚¤‚É
			w := 50;
		End;

		// ƒ`ƒ‰‚Â‚«ŒyŒ¸‚Ìˆ×
		If SelectComboBox.Width <> w Then Begin
			SelectComboBox.Width := w;
			GikoSys.Setting.SelectComboBoxWidth := w;
			DraggingSelectComboBoxPosition := pos;
		End;
	End;
end;

procedure TGikoForm.SelectComboBoxSplitterMouseDown(Sender: TObject;
	Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
	pos : TPoint;
begin
	IsDraggingSelectComboBox := True;
	pos.X := X;
	pos.Y := Y;
	DraggingSelectComboBoxPosition := SelectComboBoxSplitter.ClientToScreen( pos );
end;

procedure TGikoForm.SelectComboBoxSplitterMouseUp(Sender: TObject;
	Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
	IsDraggingSelectComboBox := False;
end;

procedure TGikoForm.StatusBarResize(Sender: TObject);
begin
	StatusBar.Panels[1].Width := StatusBar.Width -
															 StatusBar.Panels[0].Width -
															 StatusBar.Panels[2].Width;
end;
//ŒÂ•Ê‚ ‚Ú[‚ñu’Êív
procedure TGikoForm.IndividualAbon1Click(Sender: TObject);
var
	ThreadItem : TThreadItem;
	i: Integer;
begin
	GikoSys.FAbon.AddIndividualAbon(KokoPopupMenu.Tag,1);
	ThreadItem := GetActiveContent;
	for i := BrowserTab.Tabs.Count - 1 downto 0 do
		TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;

	if ThreadItem <> nil then
		InsertBrowserTab( ThreadItem, True );
end;
//ŒÂ•Ê‚ ‚Ú[‚ñu“§–¾v
procedure TGikoForm.IndividualAbon2Click(Sender: TObject);
var
	ThreadItem : TThreadItem;
	i: Integer;
begin
	GikoSys.FAbon.AddIndividualAbon(KokoPopupMenu.Tag,0);
	ThreadItem := GetActiveContent;
	for i := BrowserTab.Tabs.Count - 1 downto 0 do
		TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
	if ThreadItem <> nil then
		InsertBrowserTab( ThreadItem, True );
end;
//ŒÂ•Ê‚ ‚Ú[‚ñ‰ðœij
procedure TGikoForm.AntiIndividualAbonClick(Sender: TObject);
var
	ThreadItem : TThreadItem;
	msg : String;
	i: Integer;
begin
	if GikoSys.FAbon.GetAbonResCount <> 0 then begin
		GikoSys.FAbon.DeleteIndividualAbon(KokoPopupMenu.Tag);
		ThreadItem := GetActiveContent;
		for i := BrowserTab.Tabs.Count - 1 downto 0 do
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
		if ThreadItem <> nil then
			InsertBrowserTab( ThreadItem, True );
	end else begin
		msg := '‚±‚ÌƒXƒŒƒbƒh‚Å‚ÍŒÂ•Ê‚ ‚Ú`‚ñ‚ðs‚Á‚Ä‚Ü‚¹‚ñ';
		MsgBox(Handle, msg, 'ƒƒbƒZ[ƒW', MB_OK);
	end;
end;
//ŒÂ•Ê‚ ‚Ú[‚ñ‰ðœ
procedure TGikoForm.N42Click(Sender: TObject);
var
	IndividualForm :TIndividualAbonForm;
	ThreadItem : TThreadItem;
	i : Integer;
	msg : String;
begin
	IndividualForm := TIndividualAbonForm.Create(Self);
	try
		if GikoSys.FAbon.GetAbonResCount <> 0 then begin
			for i :=0 to GikoSys.FAbon.GetAbonResCount-1 do begin
			IndividualForm.ComboBox1.Items.Add(GikoSys.FAbon.GetAbonResString(i));
			end;
			if IndividualForm.ShowModal = mrOK then begin
				GikoSys.FAbon.DeleteIndividualAbon(IndividualForm.ResNumber);
		end;
		for i := BrowserTab.Tabs.Count - 1 downto 0 do
			TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
		ThreadItem := GetActiveContent;
		if ThreadItem <> nil then
			InsertBrowserTab( ThreadItem, True );
		end else begin
			msg := '‚±‚ÌƒXƒŒƒbƒh‚Å‚ÍŒÂ•Ê‚ ‚Ú`‚ñ‚ðs‚Á‚Ä‚Ü‚¹‚ñ';
			MsgBox(Handle, msg, 'ƒƒbƒZ[ƒW', MB_OK);
		end;
	finally
		IndividualForm.Free;
	end;
end;

procedure TGikoForm.SelectComboBoxEnter(Sender: TObject);
begin

	if (Length( SelectComboBox.Text ) = 0) or
		(SelectComboBox.Text = SELECTCOMBOBOX_NAME) then
	begin
		SelectComboBox.Text := '';
		SelectComboBox.Color := clWindow;
	end;

end;

procedure TGikoForm.N51Click(Sender: TObject);
begin
	N42Click(Sender);
end;
//”Â–¼ŒŸõ
procedure TGikoForm.TreeSelectSearchBoardNameExecute(Sender: TObject);
var
	s : String;
	msg : String;
	CurItem : TTreeNode;
	next : boolean;
begin
	if InputQuery('”Â–¼ŒŸõ','”Â–¼‚Ì“ü—Í',s) then begin
		next := true;
		while next do begin
			if TreeView.Selected = nil then
				CurItem := TreeView.Items.GetFirstNode
			else begin
				CurItem := TreeView.Selected.GetNext;
				if CurItem = nil then
					CurItem := TreeView.Items.GetFirstNode;
			end;
			while CurItem <> nil do begin
				if (CurItem.ImageIndex <> 2) and (VaguePos(s,CurItem.Text) <> 0) then begin
					break;
				end;
				CurItem := CurItem.GetNext;
			end;
			try
				if CurItem = nil then begin
					msg := 'æ“ª‚É–ß‚è‚Ü‚·‚©H';
					if MsgBox(Handle, msg, '', MB_YESNO or MB_ICONEXCLAMATION) = mrYes	then begin
						CurItem := TreeView.Items.GetFirstNode;
					end else begin
						Exit;
					end;
					TreeView.Select(CurItem);
					TreeView.SetFocus;
				end else begin
					TreeView.Select(CurItem);
					TreeView.SetFocus;
					msg := 'ŽŸ‚És‚«‚Ü‚·‚©H';
					if MsgBox(Handle, msg, '', MB_YESNO or MB_ICONEXCLAMATION) = mrYes	then begin
						next := true;
					end else begin
						next := false;
					end;
				end;

			except
				Exit;
			end;
		end;
	end;
end;

procedure TGikoForm.CabinetFavoriteActionExecute(Sender: TObject);
var
	i, b : Integer;
	item : TMenuItem;
begin

	if CabinetPanel.Visible then begin
		if FTreeType = gttFavorite then begin
			CabinetVisible( False );
			CabinetFavoriteAction.Checked := False;
		end else begin
			CabinetFavoriteAction.Checked := True;
		end;
	end else begin
		CabinetVisible( True );
		CabinetFavoriteAction.Checked := True;
	end;

	// BBS...BBS, History, Favorite
	GikoSys.Setting.CabinetIndex := CabinetSelectPopupMenu.Items.Count - 1;

	b := CabinetSelectPopupMenu.Items.Count - 1;
	for i := 0 to b do begin
		item := CabinetSelectPopupMenu.Items[ i ];
		if item is TBBSMenuItem then begin
			item.Checked := False;
			// CabinetMenu ‚Í CabinetSelectPopupMenu ‚Æ“¯‚¶‚ÆŒˆ‚ß‚¤‚¿‚µ‚¿‚á‚¤
			CabinetMenu.Items[ i ].Checked := False;
		end;
	end;

	// ƒLƒƒƒrƒlƒbƒgƒc[ƒ‹ƒo[‹y‚ÑƒLƒƒƒrƒlƒbƒg‚Ì•\Ž¦Ø‘Ö
	HistoryToolBar.Hide;
	FavoriteToolBar.Show;
	TreeView.Visible := False;
	FavoriteTreeView.Visible := True;

	CabinetSelectToolButton.Caption := '‚¨‹C‚É“ü‚è';
	FTreeType := gttFavorite;

	// ƒƒjƒ…[‹y‚Ñƒ{ƒ^ƒ“‚Ìƒ`ƒFƒbƒN‚ðÝ’è
	CabinetBBSAction.Checked := False;
	CabinetHistoryAction.Checked := False;

	// ‚¨‹C‚É“ü‚è‚ÌƒcƒŠ[‚ð“WŠJ
	FavoriteTreeView.Items.GetFirstNode.Expanded := True;

end;

procedure TGikoForm.FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
begin

	if (SenderNode = nil) or (SourceNode = nil) or (SenderNode = SourceNode) then
		Exit;

	if TObject(SenderNode.Data) is TFavoriteFolder then
		SourceNode.MoveTo(SenderNode, naAddChild)
	else
		SourceNode.MoveTo(SenderNode, naInsert);

end;

procedure TGikoForm.FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
var
	Node: TTreeNode;
	FavNode: TTreeNode;
	FavoBoardItem: TFavoriteBoardItem;
	FavoThreadItem: TFavoriteThreadItem;
	Board: TBoard;
	ThreadItem: TThreadItem;
begin

	if (SenderNode = nil) or (Source = nil) then
		Exit;

	if not (TObject(SenderNode.Data) is TFavoriteFolder) then
		FavNode := SenderNode.Parent
	else
		FavNode := SenderNode;

	Node := nil;

	if Source is TBoard then begin
		Board := TBoard( Source );
		FavoBoardItem			 	:= TFavoriteBoardItem.CreateWithItem( Board );
		Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, FavoBoardItem);
		Node.ImageIndex := 15;
		Node.SelectedIndex := 15;
	end else if Source is TFavoriteBoardItem then begin
		FavoBoardItem := TFavoriteBoardItem( Source );
		Board := FavoBoardItem.Item;
		if Board <> nil then
			if not Board.IsThreadDatRead then
				GikoSys.ReadSubjectFile(Board);
		Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, Source);
		Node.ImageIndex := 15;
		Node.SelectedIndex := 15;
	end else if Source is TThreadItem then begin
		ThreadItem := TThreadItem( Source );
		FavoThreadItem				:= TFavoriteThreadItem.CreateWithItem( ThreadItem );
		Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
		Node.ImageIndex := 16;
		Node.SelectedIndex := 16;
	end else if Source is TBrowserRecord then begin
		ThreadItem := TBrowserRecord( Source ).FThread;
		FavoThreadItem				:= TFavoriteThreadItem.CreateWithItem( ThreadItem );
		Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
		Node.ImageIndex := 16;
		Node.SelectedIndex := 16;
	end else if Source is TFavoriteThreadItem then begin
		FavoThreadItem := TFavoriteThreadItem( Source );
		ThreadItem := FavoThreadItem.Item;
		Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, Source);
		Node.ImageIndex := 16;
		Node.SelectedIndex := 16;
	end;

	if not (TObject(SenderNode.Data) is TFavoriteFolder) then
		if Node <> nil then
			FavoriteMoveTo( SenderNode, Node );

end;

procedure TGikoForm.FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
var
	idx: Integer;
	SourceNode: TTreeNode;
	LinkToolButton: TLinkToolButton;
begin

	if SenderNode = nil then
		Exit;

	if not (TObject( SenderNode.Data ) is TFavoriteFolder) then
		if FDropSpaceNode <> nil then
			SenderNode := FDropSpaceNode;

	if Source = FavoriteTreeView then begin

		SourceNode := FavoriteTreeView.Selected;
		FavoriteMoveTo( SenderNode, SourceNode );

	end else if Source is TLinkToolButton then begin

		LinkToolButton := TLinkToolButton( Source );
		//ShowMessage(LinkToolButton.Text);
		SourceNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
		FavoriteMoveTo( SenderNode, SourceNode );

	end else if Source = BrowserTab then begin

		idx := BrowserTab.TabIndex;
		FavoriteAddTo( SenderNode, BrowserTab.Tabs.Objects[idx] );
	end else if Source = ListView then begin

		FavoriteAddTo( SenderNode, ListView.Selected.Data );

	end else if Source = TreeView then begin

		FavoriteAddTo( SenderNode, TreeView.Selected.Data );

	end;

	SetLinkBar;

end;

procedure TGikoForm.FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
	Y: Integer);
var
	SenderNode: TTreeNode;
begin

	SenderNode := FavoriteTreeView.GetNodeAt(X, Y);
	if SenderNode <> nil then begin
		FavoriteDragDrop( SenderNode, Source );
	end;

	if FDropSpaceNode <> nil then begin
		FDropSpaceNode.Free;
		FDropSpaceNode := nil;
	end;

end;

procedure TGikoForm.FavoriteTreeViewEdited(Sender: TObject;
	Node: TTreeNode; var S: String);
begin

	FavoriteTreeView.ReadOnly := True;
	SetLinkBar;

end;

procedure TGikoForm.FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
	Shift: TShiftState);
begin

	Case Key of
	VK_F2:
		begin
			FClickNode := FavoriteTreeView.Selected;
			FavoriteTreeViewRenameActionExecute( Sender );
		end;
	VK_DELETE:
		begin
			FClickNode := FavoriteTreeView.Selected;
			FavoriteTreeViewDeleteActionExecute( Sender );
		end;
	VK_RETURN:
		begin
		FavoriteClick( FavoriteTreeView.Selected );
		FavoriteTreeView.Selected.Expanded := not FavoriteTreeView.Selected.Expanded;
		end;
	VK_SPACE:
		FavoriteTreeViewDblClick( Sender );
	end;

end;

procedure TGikoForm.FavoriteTreePopupMenuPopup(Sender: TObject);
var
	i: Integer;
	LinkToolButton: TLinkToolButton;
begin

	if FavoriteTreePopupMenu.PopupComponent = FavoriteTreeView then begin
	
		FClickNode := FavoriteTreeView.Selected;

	end else if FavoriteTreePopupMenu.PopupComponent is TLinkToolButton then begin

		LinkToolButton := TLinkToolButton( FavoriteTreePopupMenu.PopupComponent );
		for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
			if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
				FClickNode := FavoriteTreeView.Items[i];
				Break;
			end;
		end;
		for i := 0 to FClickNode.Count - 1 do begin
			if FClickNode.Item[i].Data = LinkToolButton.Data then begin
				FClickNode := FClickNode.Item[i];
				Break;
			end;
		end;

	end;

	if FClickNode = nil then begin
		FavoriteTreeBrowseFolderPopupMenu.Visible := False;
		FavoriteTreeDeletePopupMenu.Visible := False;
		FavoriteTreeRenamePopupMenu.Visible := False;
		FavoriteTreeNewFolderPopupMenu.Visible := False;
		//FavoriteTreeBrowseBoardPopupMenu.Visible := False;
		//FavoriteTreeBrowseThreadPopupMenu.Visible := False;
		FavoriteTreeURLCopyPopupMenu.Visible := False;
		FavoriteTreeNameCopyPopupMenu.Visible := False;
		FavoriteTreeNameURLCopyPopupMenu.Visible := False;
		FavoriteTreeReloadPopupMenu.Visible := False;
		FavoriteTreeLogDeletePopupMenu.Visible := False;
	end else if FClickNode.IsFirstNode then begin
		FavoriteTreeBrowseFolderPopupMenu.Visible := True;
		FavoriteTreeDeletePopupMenu.Visible := False;
		FavoriteTreeRenamePopupMenu.Visible := False;
		FavoriteTreeNewFolderPopupMenu.Visible := True;
		//FavoriteTreeBrowseBoardPopupMenu.Visible := False;
		//FavoriteTreeBrowseThreadPopupMenu.Visible := False;
		FavoriteTreeURLCopyPopupMenu.Visible := False;
		FavoriteTreeNameCopyPopupMenu.Visible := True;
		FavoriteTreeNameURLCopyPopupMenu.Visible := False;
		FavoriteTreeReloadPopupMenu.Visible := False;
		FavoriteTreeLogDeletePopupMenu.Visible := False;
	end else if FClickNode.Text = Favorite.FAVORITE_LINK_NAME then begin
		FavoriteTreeBrowseFolderPopupMenu.Visible := True;
		FavoriteTreeDeletePopupMenu.Visible := True;
		FavoriteTreeRenamePopupMenu.Visible := False;
		FavoriteTreeNewFolderPopupMenu.Visible := True;
		//FavoriteTreeBrowseBoardPopupMenu.Visible := False;
		//FavoriteTreeBrowseThreadPopupMenu.Visible := False;
		FavoriteTreeURLCopyPopupMenu.Visible := False;
		FavoriteTreeNameCopyPopupMenu.Visible := True;
		FavoriteTreeNameURLCopyPopupMenu.Visible := False;
		FavoriteTreeReloadPopupMenu.Visible := False;
		FavoriteTreeLogDeletePopupMenu.Visible := False;
	end else if TObject(FClickNode.Data) is TFavoriteFolder then begin
		FavoriteTreeBrowseFolderPopupMenu.Visible := True;
		FavoriteTreeDeletePopupMenu.Visible := True;
		FavoriteTreeRenamePopupMenu.Visible := True;
		FavoriteTreeNewFolderPopupMenu.Visible := True;
		//FavoriteTreeBrowseBoardPopupMenu.Visible := False;
		//FavoriteTreeBrowseThreadPopupMenu.Visible := False;
		FavoriteTreeURLCopyPopupMenu.Visible := False;
		FavoriteTreeNameCopyPopupMenu.Visible := True;
		FavoriteTreeNameURLCopyPopupMenu.Visible := False;
		FavoriteTreeReloadPopupMenu.Visible := False;
		FavoriteTreeLogDeletePopupMenu.Visible := False;
	end else if TObject(FClickNode.Data) is TFavoriteThreadItem then begin
		FavoriteTreeBrowseFolderPopupMenu.Visible := False;
		FavoriteTreeDeletePopupMenu.Visible := True;
		FavoriteTreeRenamePopupMenu.Visible := True;
		FavoriteTreeNewFolderPopupMenu.Visible := True;
		//FavoriteTreeBrowseBoardPopupMenu.Visible := True;
		//FavoriteTreeBrowseThreadPopupMenu.Visible := True;
		FavoriteTreeURLCopyPopupMenu.Visible := True;
		FavoriteTreeNameCopyPopupMenu.Visible := True;
		FavoriteTreeNameURLCopyPopupMenu.Visible := True;
		FavoriteTreeReloadPopupMenu.Visible := True;
		FavoriteTreeLogDeletePopupMenu.Visible := True;
	end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
		FavoriteTreeBrowseFolderPopupMenu.Visible := False;
		FavoriteTreeDeletePopupMenu.Visible := True;
		FavoriteTreeRenamePopupMenu.Visible := True;
		FavoriteTreeNewFolderPopupMenu.Visible := True;
		//FavoriteTreeBrowseBoardPopupMenu.Visible := True;
		//FavoriteTreeBrowseThreadPopupMenu.Visible := False;
		FavoriteTreeURLCopyPopupMenu.Visible := True;
		FavoriteTreeNameCopyPopupMenu.Visible := True;
		FavoriteTreeNameURLCopyPopupMenu.Visible := True;
		FavoriteTreeReloadPopupMenu.Visible := True;
		FavoriteTreeLogDeletePopupMenu.Visible := False;
	end else begin
		FavoriteTreeBrowseFolderPopupMenu.Visible := False;
		FavoriteTreeDeletePopupMenu.Visible := False;
		FavoriteTreeRenamePopupMenu.Visible := False;
		FavoriteTreeNewFolderPopupMenu.Visible := False;
		//FavoriteTreeBrowseBoardPopupMenu.Visible := False;
		//FavoriteTreeBrowseThreadPopupMenu.Visible := False;
		FavoriteTreeURLCopyPopupMenu.Visible := False;
		FavoriteTreeNameCopyPopupMenu.Visible := False;
		FavoriteTreeNameURLCopyPopupMenu.Visible := False;
		FavoriteTreeReloadPopupMenu.Visible := False;
		FavoriteTreeLogDeletePopupMenu.Visible := False;
	end;

end;

procedure TGikoForm.FavoriteTreeViewDeleteActionExecute(Sender: TObject);
const
	DEL_LINK_MSG = 'gƒŠƒ“ƒNh‚ÍƒŠƒ“ƒNƒo[—pƒtƒHƒ‹ƒ_‚Å‚·Bíœ‚µ‚Ä‚æ‚ë‚µ‚¢‚Å‚·‚©H';
	DEL_MSG = 'g^0h‚ðíœ‚µ‚Ü‚·B‚æ‚ë‚µ‚¢‚Å‚·‚©H';
	DEL_TITLE = 'íœŠm”F';
begin

	if FClickNode = nil then
		Exit;
	if FClickNode.IsFirstNode then
		Exit;
	if FClickNode.Text = Favorite.FAVORITE_LINK_NAME then begin
		if MsgBox(Handle, DEL_LINK_MSG, DEL_TITLE, MB_YESNO or MB_ICONQUESTION) <> ID_YES then
			Exit;
	end else if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then begin
		if MsgBox(Handle, StringReplace( DEL_MSG, '^0', FClickNode.Text, [rfReplaceAll] ) , DEL_TITLE, MB_YESNO or MB_ICONQUESTION) <> ID_YES then
			Exit;
	end;

	//FDeleteList.Add(FClickNode.Data);
	//SetDeleteItemList(FClickNode);

	FClickNode.Delete;

	SetLinkBar;

end;

procedure TGikoForm.FavoriteTreeViewRenameActionExecute(Sender: TObject);
var
	node : TTreeNode;
begin

	if FClickNode = nil then
		Exit;
	if FClickNode.IsFirstNode then
		Exit;
	if FClickNode.Text = Favorite.FAVORITE_LINK_NAME then
		Exit;
	FavoriteTreeView.ReadOnly := False;
	if (FTreeType = gttFavorite) and (CabinetPanel.Visible) then begin
		node := FClickNode.Parent;
		while node <> nil do begin
			node.Expanded	:= True;
			node					:= node.Parent;
		end;
		FClickNode.EditText;
	end else begin
		FClickNode.Text := InputBox( '–¼‘O‚Ì•ÏX', '‚¨‹C‚É“ü‚è‚ÌV‚µ‚¢–¼‘O‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢', FClickNode.Text );
	end;

	SetLinkBar;

end;

procedure TGikoForm.FavoriteTreeViewNewFolderActionExecute(
	Sender: TObject);
var
	NewFavFolder: TFavoriteFolder;
	Node: TTreeNode;
begin

	if FClickNode = nil then
		Exit;

	try
		if not (TObject(FClickNode.Data) is TFavoriteFolder) then begin
			FavoriteTreeView.Selected := FClickNode.Parent;
			FClickNode := FClickNode.Parent;
		end;

		NewFavFolder := TFavoriteFolder.Create;
		Node := FavoriteTreeView.Items.AddChildObject(FClickNode, 'V‚µ‚¢ƒtƒHƒ‹ƒ_', NewFavFolder);
		Node.ImageIndex := 14;
		Node.SelectedIndex := 14;
	//			FClickNode.Selected.Expanded := True;
		FavoriteTreeView.Selected := Node;
		FClickNode := Node;
		FavoriteTreeViewRenameAction.Execute;
	finally
	end;

end;

procedure TGikoForm.ToolButton19Click(Sender: TObject);
begin

	FavoriteArrangeActionExecute( nil );
	
end;

procedure TGikoForm.FavoriteBrowseFolder( node: TTreeNode );
var
	i: Integer;
begin

	if not (TObject(node.Data) is TFavoriteFolder) then
		exit;

	for i := 0 to node.Count - 1 do
	begin
		if TObject(node.Item[i].Data) is TFavoriteFolder then
			FavoriteBrowseFolder( node.Item[i] )
		else if TObject(node.Item[i].Data) is TFavoriteThreadItem then
			FavoriteClick( node.Item[i], False );
	end;

end;

procedure TGikoForm.FavoriteTreeViewBrowseFolderActionExecute(
	Sender: TObject);
begin

	FavoriteBrowseFolder( FClickNode );
	//BrowserTab.OnChange(nil);

end;

procedure TGikoForm.FavoriteTreeViewDblClick(Sender: TObject);
begin

	FClickNode := FavoriteTreeView.Selected;
	FavoriteTreeViewReloadActionExecute( Sender );

end;

procedure TGikoForm.FavoriteTreeViewLogDeleteActionExecute(
	Sender: TObject);
const
	DEL_MSG = 'ƒƒOƒtƒ@ƒCƒ‹‚ðíœ‚µ‚Ü‚·B‚æ‚ë‚µ‚¢‚Å‚·‚©H';
	DEL_TITLE = 'íœŠm”F';
var
	ThreadItem: TThreadItem;
	FavThread: TFavoriteThreadItem;
begin

	if FClickNode = nil then Exit;
	if not (TObject(FClickNode.Data) is TFavoriteThreadItem) then Exit;

	FavThread := TFavoriteThreadItem( FClickNode.Data );
	ThreadItem := FavThread.Item;

	try
		if GikoSys.Setting.DeleteMsg then begin
			if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) <> IDYES then
				Exit;
		end;

		DeleteHistory(ThreadItem);
		DeleteTab(ThreadItem);
		ThreadItem.DeleteLogFile;

		ListView.Refresh;
	finally
	end;

end;

procedure TGikoForm.FavoriteTreeViewReloadActionExecute(Sender: TObject);
var
	ThreadItem: TThreadItem;
	FavThread: TFavoriteThreadItem;
	Board: TBoard;
	FavBoard: TFavoriteBoardItem;
	shiftDown: Boolean;
begin

	if FClickNode = nil then Exit;

	shiftDown := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);

	if TObject( FClickNode.Data ) is TFavoriteThreadItem then begin
		FavThread := TFavoriteThreadItem( FClickNode.Data );
		ThreadItem := FavThread.Item;
		if ThreadItem <> nil then
			DownloadContent(ThreadItem, shiftDown);
	end else if TObject( FClickNode.Data ) is TFavoriteBoardItem then begin
		FavBoard := TFavoriteBoardItem( FClickNode.Data );
		Board := FavBoard.Item;
		DownloadList(Board, shiftDown);
	end;

end;

procedure TGikoForm.FavoriteTreeViewURLCopyActionExecute(Sender: TObject);
var
	FavThread	: TFavoriteThreadItem;
	FavBoard	: TFavoriteBoardItem;
	s					: string;
begin

	if FClickNode = nil then Exit;

	if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin

		FavThread := TFavoriteThreadItem( FClickNode.Data );
		s := FavThread.URL + #13#10;
		if s <> '' then
			Clipboard.AsText := s;

	end else if (TObject(FClickNode.Data) is TFavoriteBoardItem) then begin

		FavBoard := TFavoriteBoardItem( FClickNode.Data );
		s := FavBoard.URL + #13#10;
		if s <> '' then
			Clipboard.AsText := s;

	end;

end;

procedure TGikoForm.FavoriteTreeViewNameCopyActionExecute(Sender: TObject);
var
	ThreadItem: TThreadItem;
	FavThread: TFavoriteThreadItem;
	Board: TBoard;
	FavBoard: TFavoriteBoardItem;
	s: string;
begin

	if FClickNode = nil then Exit;

	if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin

		FavThread := TFavoriteThreadItem( FClickNode.Data );
		ThreadItem := FavThread.Item;

		try
			s := ThreadItem.Title + #13#10;
			if s <> '' then
				Clipboard.AsText := s;
		finally
		end;

	end else if (TObject(FClickNode.Data) is TFavoriteBoardItem) then begin

		FavBoard := TFavoriteBoardItem( FClickNode.Data );
		Board := FavBoard.Item;
		if Board <> nil then
			if not Board.IsThreadDatRead then
				GikoSys.ReadSubjectFile(Board);

		try
			s := Board.Title + #13#10;
			if s <> '' then
				Clipboard.AsText := s;
		finally
		end;

	end;

end;

procedure TGikoForm.FavoriteTreeViewNameURLCopyActionExecute(
	Sender: TObject);
var
	ThreadItem: TThreadItem;
	FavThread: TFavoriteThreadItem;
	Board: TBoard;
	FavBoard: TFavoriteBoardItem;
	s: string;
begin

	if FClickNode = nil then Exit;

	if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin

		FavThread := TFavoriteThreadItem( FClickNode.Data );
		ThreadItem := FavThread.Item;

		try
			s := ThreadItem.URL + #13#10 + ThreadItem.Title + #13#10;
			if s <> '' then
				Clipboard.AsText := s;
		finally
		end;

	end else if (TObject(FClickNode.Data) is TFavoriteBoardItem) then begin

		FavBoard := TFavoriteBoardItem( FClickNode.Data );
		Board := FavBoard.Item;
		if Board <> nil then
			if not Board.IsThreadDatRead then
				GikoSys.ReadSubjectFile(Board);

		try
			s := Board.URL + #13#10 + Board.Title + #13#10;
			if s <> '' then
				Clipboard.AsText := s;
		finally
		end;

	end;

end;

function TGikoForm.TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
var
	Found: TTreeNode;
	i: Integer;
begin

	for i := 0 to Node.Count - 1 do begin
		if Node.Item[i].Data = FindPointer then begin
			Result := Node.Item[i];
			Exit;
		end else if Node.Item[i].Count > 0 then begin
			Found := TreeNodeDataFind( Node.Item[i], FindPointer );
			if Found <> nil then begin
				Result := Found;
				Exit;
			end;
		end;
	end;

	Result := nil;

end;

procedure TGikoForm.LinkToolBarDragDrop(Sender, Source: TObject; X,
	Y: Integer);
var
	i: Integer;
	SenderNode: TTreeNode;
begin

	SenderNode := nil;
	for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
		if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
			SenderNode := FavoriteTreeView.Items[i];
			Break;
		end;
	end;

	FavoriteDragDrop( SenderNode, Source );

end;

procedure TGikoForm.BrowserTabMouseUp(Sender: TObject;
	Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
	if FDragWFirst <> true then begin
		FDragWFirst := false;
	end else if (X = FMouseDownPos.X) and (Y = FMouseDownPos.Y) then begin
		if GikoSys.Setting.ListOrientation = gloHorizontal then begin
			if GikoSys.Setting.ListWidthState = glsMin then begin
				BrowserMaxAndFocusAction.Execute;
			end;
		end else begin
			if GikoSys.Setting.ListHeightState = glsMin then begin
				BrowserMaxAndFocusAction.Execute;
			end;
 		end;
	end;
end;

procedure TGikoForm.LinkToolBarDragOver(Sender, Source: TObject; X,
	Y: Integer; State: TDragState; var Accept: Boolean);
begin

	FavoriteDragOver( Sender, Source, X, Y, State, Accept );

end;

procedure TGikoForm.OnlyAHundredResExecute(Sender: TObject);
begin
	if (FActiveContent <> nil) and (FActiveContent.FBrowser.Busy) then begin
		AHundredResButton.Down := not AHundredResButton.Down;
		Exit; 
	end;
	GikoSys.OnlyAHundredRes := OnlyAHundredRes.Checked;
	if FActiveContent <> nil then begin
		SetContent(FActiveContent);
	end;
end;

procedure TGikoForm.FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
	Y: Integer);
begin

	if FDropSpaceNode <> nil then begin
		FDropSpaceNode.Free;
		FDropSpaceNode := nil;
		SetLinkBar;
	end;

end;

procedure TGikoForm.ListCoolBarContextPopup(Sender: TObject;
	MousePos: TPoint; var Handled: Boolean);
begin

	FToolBarSettingSender := tssList;
	MousePos := ListCoolBar.ClientToScreen( MousePos );
	MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );

end;

procedure TGikoForm.MainCoolBarContextPopup(Sender: TObject;
	MousePos: TPoint; var Handled: Boolean);
begin

	FToolBarSettingSender := tssMain;
	MousePos := MainCoolBar.ClientToScreen( MousePos );
	MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );

end;

procedure TGikoForm.BrowserCoolBarContextPopup(Sender: TObject;
	MousePos: TPoint; var Handled: Boolean);
begin

	FToolBarSettingSender := tssBrowser;
	MousePos := BrowserCoolBar.ClientToScreen( MousePos );
	MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );

end;
procedure TGikoForm.ExportFavoriteFileAccept(Sender: TObject);
begin

	if FavoriteDM.SaveFavoriteFile( ExportFavoriteFile.Dialog.FileName ) Then begin
		ShowMessage('ƒtƒ@ƒCƒ‹‚ðo—Í‚µ‚Ü‚µ‚½');
	end else begin
		ShowMessage('ƒtƒ@ƒCƒ‹‚Ìo—Í‚ÉŽ¸”s‚µ‚Ü‚µ‚½');
	end;
end;
procedure TGikoForm.SetListViewBackGroundColor(value: TColor);
begin
	if FListViewBackGroundColor <> value then begin
			FListViewBackGroundColor := value;
				ListView.Color := FListViewBackGroundColor;
		end;
end;
procedure TGikoForm.ExportFavoriteFileBeforeExecute(Sender: TObject);
begin
	ExportFavoriteFile.Dialog.FileName := FavoriteDM.GetFavoriteFilePath;
end;

procedure TGikoForm.CabinetBBSActionExecute(Sender: TObject);
begin

	if CabinetPanel.Visible then begin
		if FTreeType = gtt2ch then begin
			CabinetVisible( False );

			CabinetBBSAction.Checked := False;
		end else begin
			CabinetBBSAction.Checked := True;
		end;
	end else begin
		CabinetVisible( True );
		CabinetBBSAction.Checked := True;
	end;

	if FActiveBBS = nil then
		ShowBBSTree( BBSs[ 0 ] )
	else
		ShowBBSTree( FActiveBBS );

end;

procedure TGikoForm.FavoriteTreeViewBrowseThreadActionExecute(
	Sender: TObject);
var
	threadItem	: TThreadItem;
begin

	if FClickNode = nil then Exit;

	if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin

		threadItem := TFavoriteThreadItem( FClickNode.Data ).Item;
		if threadItem = nil then
			Exit;
		GikoSys.OpenBrowser( threadItem.URL, gbtAuto );

	end;

end;

procedure TGikoForm.FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
var
	threadItem	: TThreadItem;
	boardItem		: TBoard;
begin

	if FClickNode = nil then Exit;

	if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin

		threadItem := TFavoriteThreadItem( FClickNode.Data ).Item;
		if threadItem = nil then
			Exit;
		GikoSys.OpenBrowser( threadItem.ParentBoard.URL, gbtAuto );

	end else if (TObject(FClickNode.Data) is TFavoriteBoardItem) then begin

		boardItem := TFavoriteBoardItem( FClickNode.Data ).Item;
		if boardItem = nil then
			Exit;
		GikoSys.OpenBrowser( boardItem.URL, gbtAuto );

	end;

end;

procedure TGikoForm.UpBoardActionExecute(Sender: TObject);
begin

	SelectTreeNode( GetActiveContent.ParentBoard, True );

end;

procedure TGikoForm.UpBoardActionUpdate(Sender: TObject);
begin

	UpBoardAction.Enabled := GetActiveContent <> nil;

end;

procedure TGikoForm.BrowserTabContextPopup(Sender: TObject;
	MousePos: TPoint; var Handled: Boolean);
var
	idx : Integer;
begin
		idx := BrowserTab.IndexOfTabAt(MousePos.X, MousePos.Y);
		if BrowserTab.TabIndex <> idx then begin
		BrowserTab.TabIndex := idx;
			BrowserTab.OnChange(nil);
		end;

end;

procedure TGikoForm.KoreCopyExecute(Sender: TObject);
begin
	KonoresCopy(KokoPopupMenu.Tag, true);
end;
procedure TGikoForm.KonoresCopy(Number: Integer; ReplaceTag : Boolean);
var
	ThreadItem: TThreadItem;
	tmp: string;
	FileName: string;
	Res: TResRec;
	Header: string;
	Body: string;
	boardPlugIn : TBoardPlugIn;
begin
	if Number = 0 then Exit;
	ThreadItem := GetActiveContent;

	if ThreadItem <> nil then begin
		if ThreadItem.IsBoardPlugInAvailable then begin
			//===== ƒvƒ‰ƒOƒCƒ“‚É‚æ‚é•\Ž¦
			boardPlugIn		:= ThreadItem.BoardPlugIn;

			// ƒtƒHƒ“ƒg‚âƒTƒCƒY‚ÌÝ’è
			// •¶ŽšƒR[ƒh‚Íƒvƒ‰ƒOƒCƒ“‚É”C‚¹‚é
			//‚±‚±‚Å‚Q‚¿‚á‚ñ‚Ë‚é‚Ìdat‚ÌŒ`Ž®‚Å‚Ps“Ç‚Ýž‚ß‚ê‚Î¥¥¥B
			tmp := boardPlugIn.GetDat( DWORD( threadItem ), Number );
		end else begin
      FileName := ThreadItem.FilePath;
      tmp := GikoSys.ReadThreadFile(FileName, Number);
		end;
		if tmp <> '' then begin
			Res := GikoSys.DivideStrLine(tmp);

			Header := IntToStr(Number) + ' F' + Res.FName + ' F' + Res.FDateTime + #13#10;
			if ReplaceTag then begin
				Header := CustomStringReplace(Header, '</b>', '',true);
				Header := CustomStringReplace(Header, '<b>', '',true);
			end;
			if ThreadItem.IsBoardPlugInAvailable then begin
				Body := CustomStringReplace(Res.FBody, '<br>', #13#10,true);
				Body := CustomStringReplace(Body, '<br>', #13#10,true);
			end else begin
				Body := CustomStringReplace(Res.FBody, ' <br> ', #13#10,true);
				Body := CustomStringReplace(Body, ' <br>', #13#10,true);
				Body := CustomStringReplace(Body, '<br> ', #13#10,true);
				Body := CustomStringReplace(Body, '<br>', #13#10,true);

			end;
			Body := CustomStringReplace(Body, '</a>', '',true);

			Body := GikoSys.DeleteLink(Body);
			if ReplaceTag then begin
				Body := CustomStringReplace(Body, '&lt;', '<');
				Body := CustomStringReplace(Body, '&gt;', '>');
				Body := CustomStringReplace(Body, '&quot;', '"');
				Body := CustomStringReplace(Body, '&amp;', '&');
				//Body := CustomStringReplace(Body, '&nbsp;', ' ');
			end;

			Header := Header + Body;

			Clipboard.SetTextBuf( PChar(Header) );
		end;
	end;
end;


procedure TGikoForm.BrowserTabPopupMenuPopup(Sender: TObject);
begin
	AddRoundNameMenu(dummy1);
end;

procedure TGikoForm.FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
begin
	FavoriteDM.URLReplace(oldURLs, newURLs);
end;

procedure TGikoForm.RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
begin
	RoundList.URLReplace(oldURLs, newURLs);
end;

// Å¬‰»‚³‚ê‚é
procedure TGikoForm.OnMinimize;
begin
	FIsMinimize := mtMinimizing;
	if FActiveContent <> nil then
		FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
	PostMessage( Handle, USER_MINIMIZED, 0, 0 );
end;

// Å¬‰»‚³‚ê‚½
procedure TGikoForm.OnMinimized;
begin
	FIsMinimize := mtMinimized;
	FIsIgnoreResize := False;
end;

procedure TGikoForm.CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
var
	coolSet 			: TCoolSet;
	toolbar				: TToolBar;
	band					: TCoolBand;
	affectedBand	: TCoolBand;
	i							: Integer;
begin
	if (FOldFormWidth = Width) and not IsIconic( Handle ) and not FIsIgnoreResize then begin
		FIsIgnoreResize := True;
		PostMessage( Handle, USER_RESIZED, 0, 0 );
		if not (Sender is TToolBar) or (CoolBar = nil) then
			Exit;
		toolbar := TToolBar( Sender );
		band := nil;
		// •ÏX‚³‚ê‚½ƒN[ƒ‹ƒo[‚Ì’l‚ð•Û‘¶
		if CoolBar = MainCoolBar then begin
			for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
				CoolSet.FCoolID := CoolBar.Bands[i].ID;
				CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
				CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
				GikoSys.Setting.MainCoolSet[i] := CoolSet;
			end;
		end else if CoolBar = ListCoolBar then begin
			for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
				CoolSet.FCoolID := CoolBar.Bands[i].ID;
				CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
				CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
				GikoSys.Setting.ListCoolSet[i] := CoolSet;
			end;
		end else if CoolBar = BrowserCoolBar then begin
			for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
				CoolSet.FCoolID := CoolBar.Bands[i].ID;
				CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
				CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
				GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
			end;
		end;
		// •‚Ì•ÏX‚³‚ê‚½ƒoƒ“ƒh‚ðŒ©‚Â‚¯‚é
		affectedBand := nil;
		for i := CoolBar.Bands.Count - 1 downto 0 do begin
			if CoolBar.Bands[ i ].Control.Handle = toolbar.Handle then begin
				band	:= CoolBar.Bands[ i ];
				if band.Break or (i = 0) then begin
					if i + 1 < CoolBar.Bands.Count then
						if not CoolBar.Bands[ i + 1 ].Break then
							affectedBand := CoolBar.Bands[ i + 1 ];
				end else begin
					if i > 0 then
						affectedBand := CoolBar.Bands[ i - 1 ];
				end;
				Break;
			end;
		end;
		// ƒhƒ‰ƒbƒO’†‚Í band.Width ‚ªXV‚³‚ê‚È‚¢‚Ì‚ÅA“à‘¤‚ÌƒTƒCƒY‚©‚ç‚Ð‚Ë‚èo‚·
		if CoolBar = MainCoolBar then begin
			coolSet := GikoSys.Setting.MainCoolSet[ band.ID ];
			coolSet.FCoolWidth := toolbar.Width + 25;
			GikoSys.Setting.MainCoolSet[ band.ID ] := coolSet;
			if affectedBand <> nil then begin
				coolSet := GikoSys.Setting.MainCoolSet[ affectedBand.ID ];
				coolSet.FCoolWidth := affectedBand.Control.Width + 25;
				GikoSys.Setting.MainCoolSet[ affectedBand.ID ] := coolSet;
			end;
		end else if CoolBar = ListCoolBar then begin
			coolSet := GikoSys.Setting.ListCoolSet[ band.ID ];
			coolSet.FCoolWidth := toolbar.Width + 25;
			GikoSys.Setting.ListCoolSet[ band.ID ] := coolSet;
			if affectedBand <> nil then begin
				coolSet := GikoSys.Setting.ListCoolSet[ affectedBand.ID ];
				coolSet.FCoolWidth := affectedBand.Control.Width + 25;
				GikoSys.Setting.ListCoolSet[ affectedBand.ID ] := coolSet;
			end;
		end else if CoolBar = BrowserCoolBar then begin
			coolSet := GikoSYs.Setting.BrowserCoolSet[ band.ID ];
			coolSet.FCoolWidth := toolbar.Width + 25;
			GikoSys.Setting.BrowserCoolSet[ band.ID ] := coolSet;
			if affectedBand <> nil then begin
				coolSet := GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ];
				coolSet.FCoolWidth := affectedBand.Control.Width + 25;
				GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ] := coolSet;
			end;
		end;
	end;
end;

procedure TGikoForm.MenuToolBarResize(Sender: TObject);
begin
	CoolBarResized( Sender, MainCoolBar );
end;

procedure TGikoForm.StdToolBarResize(Sender: TObject);
begin
	CoolBarResized( Sender, MainCoolBar );
end;

procedure TGikoForm.LinkToolBarResize(Sender: TObject);
begin
	CoolBarResized( Sender, MainCoolBar );
end;

procedure TGikoForm.ListNameToolBarResize(Sender: TObject);
begin
	CoolBarResized( Sender, ListCoolBar );
end;

procedure TGikoForm.ListToolBarResize(Sender: TObject);
begin
	CoolBarResized( Sender, ListCoolBar );
end;

procedure TGikoForm.BrowserNameToolBarResize(Sender: TObject);
begin
	CoolBarResized( Sender, BrowserCoolBar );
end;

procedure TGikoForm.BrowserToolBarResize(Sender: TObject);
begin
	CoolBarResized( Sender, BrowserCoolBar );
end;

procedure TGikoForm.BrowserTabResize(Sender: TObject);
begin
	CoolBarResized( Sender, BrowserCoolBar );
end;

// *************************************************************************
// ExternalBoardPlugInMain
// ƒvƒ‰ƒOƒCƒ“ƒƒjƒ…[‚Ì€–Ú‚ªŽÀs‚³‚ê‚½
// *************************************************************************
procedure TGikoForm.OnPlugInMenuItem( Sender : TObject );
var
	item				: TMenuItem;
	boardPlugIn	: TBoardPlugIn;
begin

	if not (Sender is TMenuItem) then
		Exit;

	item := TMenuItem( Sender );
	if not Assigned( Pointer( item.Tag ) ) then
		Exit;

	// ƒvƒ‰ƒOƒCƒ“‚Ìƒƒjƒ…[ƒnƒ“ƒhƒ‰‚ðŒÄ‚Ño‚·
	boardPlugIn := TBoardPlugIn( item.Tag );
	boardPlugIn.PlugInMenu( item.Handle );

end;
// TreeView ‚ªƒNƒŠƒbƒN‚³‚ê‚½
procedure TGikoForm.TreeClick( Node : TTreeNode );
var
	i: Integer;
begin

	if Node = nil then
		Exit;

	if FTreeType = gttHistory then begin
		if Node <> nil then
			if TObject( Node.Data ) is TFavoriteThreadItem then
				if GetActiveContent <> TFavoriteThreadItem( Node.Data ).Item then
					FavoriteClick( Node );
		Exit;
	end;

	if GetActiveList is TBBS then begin
		for i := 0 to ListView.Columns.Count - 1 do
			GikoSys.Setting.BBSColumnWidth[i] := ListView.Column[i].Width;
	end else if GetActiveList is TCategory then begin
		for i := 0 to ListView.Columns.Count - 1 do
			GikoSys.Setting.CategoryColumnWidth[i] := ListView.Column[i].Width;
	end else if GetActiveList is TBoard then begin
		for i := 0 to ListView.Columns.Count - 1 do
			GikoSys.Setting.BoardColumnWidth[i] := ListView.Column[i].Width;
	end;

	if TObject(Node.Data) is TBBS then begin
		SetActiveList(Node.data);
	end else if TObject(Node.Data) is TCategory then begin
		SetActiveList(Node.data);
	end else if TObject(Node.Data) is TBoard then begin
		if not TBoard(Node.Data).IsThreadDatRead then begin
			Screen.Cursor := crHourGlass;
			try
        if not TBoard(Node.Data).IsThreadDatRead then
					GikoSys.ReadSubjectFile(Node.Data);
			finally
				Screen.Cursor := crDefault;
			end;
		end;
		SetActiveList(Node.data);
	end;

	if TObject( Node.Data ) is TBoard then begin // not TCategory
		if GikoSys.Setting.ListOrientation = gloHorizontal then begin
			if GikoSys.Setting.ListWidthState = glsMax then begin
				BrowserMinAction.Execute;
				if GikoForm.Visible then
					ListView.SetFocus;
			end;
		end else begin
			if GikoSys.Setting.ListHeightState = glsMax then begin
				BrowserMinAction.Execute;
				if GikoForm.Visible then
					ListView.SetFocus;
			end;
		end;
	end;

end;

// TreeView ‚ªƒ_ƒuƒ‹ƒNƒŠƒbƒN‚³‚ê‚½
procedure TGikoForm.TreeDoubleClick( Node : TTreeNode );
var
	Board				: TBoard;
	ThreadItem	: TThreadItem;
	shiftDown	: Boolean;
begin

	if Node = nil then Exit;

	shiftDown	:= GetAsyncKeyState(VK_SHIFT) = Smallint($8001);

	if FTreeType = gtt2ch then begin
		if not (TObject(Node.Data) is TBoard) then Exit;
		Board := TBoard(Node.Data);
		DownloadList(Board, shiftDown);
	end else if FTreeType = gttHistory then begin
		if not (TObject(Node.Data) is TFavoriteThreadItem) then Exit;
		ThreadItem := TFavoriteThreadItem(Node.Data).Item;
		DownloadContent(ThreadItem, shiftDown);
	end;

end;

procedure TGikoForm.TreeViewClick(Sender: TObject);
begin
	TreeClick( TreeView.Selected );
end;

procedure TGikoForm.TreeViewKeyDown(Sender: TObject; var Key: Word;
	Shift: TShiftState);
begin
	if Key = VK_BACK then begin
//		UpFolderButtonClick(Sender);
	end else if Key = VK_SPACE then begin
		TreeDoubleClick( TreeView.Selected );
	end else if Key = VK_RETURN then begin
		TreeClick( TreeView.Selected );
        TreeView.Selected.Expanded := not TreeView.Selected.Expanded;
	end;
end;

// ƒuƒ‰ƒEƒU‚ÌƒL[ƒ_ƒEƒ“ƒCƒxƒ“ƒg    //‚È‚ñ‚©Žg‚í‚È‚­‚Ä‚à“®‚¢‚Ä‚é‹C‚ª‚·‚é@by‚à‚¶‚ã
// ƒCƒxƒ“ƒg‚ðŽæ‚èˆµ‚Á‚½ê‡‚Í True ‚ð•Ô‚·
function TGikoForm.BrowserKeydown(var Msg: TMsg; Key: Word; State:TShiftState) : Boolean;
var
	iOIPAO		: IOleInPlaceActiveObject;
	Dispatch	: IDispatch;
begin
	Result := False;
	if Key = VK_BACK then begin
		UpBoardAction.Execute;
		Result := True;
	{end else if Key in [VK_ESCAPE..VK_HELP] then begin
		// \ŽšAPage UpAPage Down “™‚Í Browser ‚ªŸŽè‚ÉŽó‚¯Žæ‚é‚Ì‚ÅƒCƒxƒ“ƒg‚ðƒJƒbƒg
		Result := True;
	}
	end else if(Key in [VK_SPACE..VK_HELP]) and
		not(ssCtrl in State) and not(ssAlt in State) and not (ssShift in State) then begin
		Result := True;
	end else begin
		// ‚»‚êˆÈŠO‚ÌƒCƒxƒ“ƒg‚Í Browser ‚É—¬‚·
		if(FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
			Dispatch := FActiveContent.Browser.Application;
			if Dispatch <> nil then begin
				Dispatch.QueryInterface( IOleInPlaceActiveObject, iOIPAO );
				if iOIPAO <> nil then
					iOIPAO.TranslateAccelerator( Msg );
			end;
		end;
		// ƒMƒRƒiƒr‚ÅŽg‚¤ƒVƒ‡[ƒgƒJƒbƒg‚ÍŽó‚¯Žæ‚è‚½‚¢‚Ì‚ÅƒCƒxƒ“ƒg‚ÍƒJƒbƒg‚µ‚È‚¢
		//Result := False;
	end;

end;

// ƒMƒRƒiƒr‚ÌƒƒbƒZ[ƒWƒ‹[ƒv‚ð‰¡Žæ‚è‚µ‚Ü‚·
procedure TGikoForm.HandleAppMessage(var Msg: TMsg; var Handled: Boolean);

//var
//	key				: Word;
begin
	case Msg.message of
	{WM_KEYDOWN:
		if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
			if IsDialogMessage( FActiveContent.Browser.Handle, Msg ) then begin
				key := Msg.wParam;
				Handled := BrowserKeyDown( Msg, key, KeyDataToShiftState( Msg.lParam ) );
			end;
		end;}

	WM_XBUTTONDOWN:
		case Msg.wParam shr 16 of
			XBUTTON1:
			begin
					if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
						if IsDialogMessage( FActiveContent.Browser.Handle, Msg ) then begin
							UpBoardAction.Execute;
							Handled := True;
						end;
					end;
					if not Handled then begin
						if IsDialogMessage( ListView.Handle, Msg ) then begin
							UpFolderAction.Execute;
							Handled := True;
						end;
					end;
			end;
			XBUTTON2:
		end;
	end;
end;

procedure TGikoForm.FavoriteTreeViewMouseDown(Sender: TObject;
	Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
	favItem				: TTreeNode;
	favThreadItem	: TFavoriteThreadItem;
begin

	case Button of
	mbLeft:
		begin
			FMouseDownPos.X := X;
			FMouseDownPos.Y := Y;
		end;
	mbMiddle:
		begin
			favItem := FavoriteTreeView.GetNodeAt( X, Y );
			if favItem = nil then Exit;

			if TObject( favItem.Data ) is TFavoriteThreadItem then begin
				favThreadItem := TFavoriteThreadItem( favItem.Data );
				if favThreadItem.Item <> nil then
					InsertBrowserTab( favThreadItem.Item, False );
			end;
		end;
	end;

end;

procedure TGikoForm.MessagePanelResize(Sender: TObject);
begin

	if FIsIgnoreResize then
		Exit;

	if GikoSys.Setting.ListOrientation = gloVertical then begin
		if GikoSys.Setting.ListHeightState = glsMin then begin
			// Å¬•\Ž¦‚É‚·‚é
			ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
		end;
	end;

end;

procedure TGikoForm.OnResized;
begin

	FOldFormWidth := Width;
	FIsIgnoreResize := False;

end;

procedure TGikoForm.TreeSelectNameCopyExecute(Sender: TObject);
var
	s: string;
begin
	TreeView.Selected := FClickNode;
	s := FClickNode.Text;
	Clipboard.AsText := s;
end;

procedure TGikoForm.FavoriteTreeViewMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin

	if (abs( X - FMouseDownPos.X ) < Mouse.DragThreshold) and
		 (abs( Y - FMouseDownPos.Y ) < Mouse.DragThreshold) then begin
		FavoriteClick( TObject( FavoriteTreeView.Selected ) );
	end;

end;

destructor	TBrowserRecord.Destroy;
var
	doc :OleVariant;
begin
	if Self.FEvent <> nil then
		Self.FEvent.Free;
	if Self.FBrowser <> nil then begin
		if Self.Thread <> nil then begin
			doc := Idispatch( olevariant(Self.FBrowser.ControlInterface).Document) as IHTMLDocument2;
			Self.Thread.ScrollTop := doc.Body.ScrollTop;
		end;
		//TOleControl(Self.FBrowser).Visible := false;
		ShowWindow(Self.FBrowser.Handle, SW_HIDE);
	end;

end;

procedure TGikoForm.OnlyAHundredResUpdate(Sender: TObject);
begin
	OnlyAHundredRes.Enabled := (GetActiveContent <> nil) and (GetActiveContent.IsLogFile);
end;

function TGikoForm.WebBrowserClick(Sender: TObject): WordBool;
begin
  result := true;
  try
	if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then
		FActiveContent.FBrowser.SetFocus;
  except
  end;
end;

procedure TGikoForm.SetFocusForBrowserActionExecute(Sender: TObject);
begin
	FActiveContent.FBrowser.SetFocus;
end;

procedure TGikoForm.SetFocusForBrowserActionUpdate(Sender: TObject);
begin
	if( FActiveContent <> nil) and (FActiveContent.Browser <> nil) and
		(FActiveContent.Browser <> BrowserNullTab.Browser) then
		SetFocusForBrowserAction.Enabled := true
	else
		SetFocusForBrowserAction.Enabled := false;
end;

procedure TGikoForm.SetFocusForThreadListActionExecute(Sender: TObject);
var
	rct: TRect;
begin
	if FActiveContent <> nil then
		WebBrowserClick(FActiveContent.Browser); //ˆê‰ñBrowser‚É“–‚Ä‚È‚¢‚Æ“®‚©‚È‚¢‚Æ‚«‚ª‚ ‚é
	ListView.SetFocus;
	if( ListView.Items.Count > 0 ) and (ListView.ItemFocused = nil) then
		ListView.Items.Item[0].Selected := true //‘I‘ðƒAƒCƒeƒ€‚ª–³‚¢‚Æ‚«‚Íæ“ª‚Ì‚ð‘I‘ð‚·‚é
	else begin
		ListView.Scroll(-ListView.ClientWidth, -ListView.ClientHeight);
		rct := ListView.ItemFocused.DisplayRect(drBounds);
		ListView.Scroll(0, 2 * rct.Top - rct.Bottom);
		if ListView.ViewStyle <> vsReport then begin
			ListView.Scroll(rct.Left, 0);
		end;
	end;
end;

procedure TGikoForm.SetFocusForCabinetActionExecute(Sender: TObject);
begin
	if FActiveContent <> nil then
		WebBrowserClick(FActiveContent.Browser); //ˆê‰ñBrowser‚É“–‚Ä‚È‚¢‚Æ“®‚©‚È‚¢‚Æ‚«‚ª‚ ‚é
	if TreeView.Visible then begin
		TreeView.SetFocus;
		if(TreeView.Items.Count > 0) and ( TreeView.Selected = nil ) then
			TreeView.Items.Item[0].Selected := true;
	end else if FavoriteTreeView.Visible then begin
		FavoriteTreeView.SetFocus;
		if(FavoriteTreeView.Items.Count > 0) and (FavoriteTreeView.Selected = nil) then
			FavoriteTreeView.Items.Item[0].Selected := true;
	end;
end;
procedure TGikoForm.SetFocusForCabinetActionUpdate(Sender: TObject);
begin
	SetFocusForCabinetAction.Enabled := CabinetPanel.Visible;
end;

//ƒuƒ‰ƒEƒU‚ðÅ‘å‰»‚µ‚ÄƒtƒH[ƒJƒX‚ð“–‚Ä‚éB
procedure TGikoForm.BrowserMaxAndFocusActionExecute(Sender: TObject);
begin
	BrowserMaxAction.Execute;
	SetFocusForBrowserAction.Execute;
end;

procedure TGikoForm.BrowserMaxAndFocusActionUpdate(Sender: TObject);
begin
	if( FActiveContent <> nil) and (FActiveContent.Browser <> nil) and
		(FActiveContent.Browser <> BrowserNullTab.Browser) then
		BrowserMaxAndFocusAction.Enabled := true
	else
		BrowserMaxAndFocusAction.Enabled := false;
end;
//ƒXƒŒƒbƒhˆê——‚ðÅ‘å‰»‚µ‚ÄƒtƒH[ƒJƒX‚ð“–‚Ä‚é
procedure TGikoForm.ThreadlistMaxAndFocusActionExecute(Sender: TObject);
begin
	BrowserMinAction.Execute;
	SetFocusForThreadListAction.Execute;
end;

procedure TGikoForm.ListViewExit(Sender: TObject);
begin
	ListView.Repaint;
end;


procedure TGikoForm.ListViewSelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
begin

	if not (GikoSys.Setting.BrowserTabVisible) and (Item <> nil) then
			if (TObject( Item.Data ) is TThreadItem) then begin
				SelectTimer.Interval := GikoSys.Setting.SelectInterval;
			end else
				SelectTimer.Interval := 0
	else
		SelectTimer.Interval := 0;

end;

procedure TGikoForm.SelectTimerTimer(Sender: TObject);
begin
	if not (ListView.Selected = nil) then
		if( FActiveContent = nil) or
				(GetActiveContent <> TThreadItem(ListView.Selected.Data) ) then begin
			SelectTimer.Interval := 0;
			ListClick;
		end;
end;

procedure TGikoForm.SelectItemSaveForDatExecute(Sender: TObject);
var
	List: TList;
	i: Integer;
begin
	List := TList.Create;
	try
		Screen.Cursor := crHourGlass;
		SelectListItem(List);
		if ((GikoSys.Setting.ListOrientation = gloVertical) and
			(GikoSys.Setting.ListHeightState = glsMax)) or
			((GikoSys.Setting.ListOrientation = gloHorizontal) and
			(GikoSys.Setting.ListWidthState = glsMax)) then
			ShowMessage('ƒXƒŒƒbƒhˆê——‚ð•\Ž¦‚µ‚Ä‚­‚¾‚³‚¢')
		else if(List.Count = 0) then
			ShowMessage('ƒXƒŒƒbƒh‚ð‘I‘ð‚µ‚Ä‚­‚¾‚³‚¢')
		else begin
			FileSaveAs1.Dialog.Title := '‘I‘ðƒXƒŒƒbƒh‚ðdat‚Ì‚Ü‚Ü•Û‘¶';
			FileSaveAs1.Dialog.Filter := 'DATƒtƒ@ƒCƒ‹(*.dat)|*.dat';
			for i := 0 to List.Count - 1 do begin
				if (TObject(List[i]) is TThreadItem) and (TThreadItem(List[i]).IsLogFile) then begin
					FileSaveAs1.Dialog.FileName := TThreadItem(List[i]).FileName;
					if FileSaveAs1.Execute then begin
						//‚È‚º‚©ƒLƒƒƒ“ƒZƒ‹‚Å‚à‚±‚Á‚¿‚É“ü‚Á‚Ä‚­‚é
						if ExtractFilePath(FileSaveAs1.Dialog.FileName) <> '' then begin
							CopyFile(PChar(TThreadItem(List[i]).FilePath),
								PChar(FileSaveAs1.Dialog.FileName), true);
						end;
					end;
				end;
			end;
		end;
	finally
		Screen.Cursor := crDefault;
		List.Free;
	end;

end;

procedure TGikoForm.SelectItemSaveForHTMLExecute(Sender: TObject);
var
	List: TList;
	i: Integer;
	html: TStringList;
	title: string;
begin
	List := TList.Create;
	try
		Screen.Cursor := crHourGlass;
		SelectListItem(List);
		if ((GikoSys.Setting.ListOrientation = gloVertical) and
			(GikoSys.Setting.ListHeightState = glsMax)) or
			((GikoSys.Setting.ListOrientation = gloHorizontal) and
			(GikoSys.Setting.ListWidthState = glsMax))	then
			ShowMessage('ƒXƒŒƒbƒhˆê——‚ð•\Ž¦‚µ‚Ä‚­‚¾‚³‚¢')
		else if(List.Count = 0) then
			ShowMessage('ƒXƒŒƒbƒh‚ð‘I‘ð‚µ‚Ä‚­‚¾‚³‚¢')
		else begin
			FileSaveAs1.Dialog.Title := '‘I‘ðƒXƒŒƒbƒh‚ðHTML‰»‚µ‚Ä•Û‘¶';
			FileSaveAs1.Dialog.Filter := 'HTMLƒtƒ@ƒCƒ‹(*.html)|*.html';
			for i := 0 to List.Count - 1 do begin
				if (TObject(List[i]) is TThreadItem) and (TThreadItem(List[i]).IsLogFile) then begin
					FileSaveAs1.Dialog.FileName := TThreadItem(List[i]).Title + '.html';
					if FileSaveAs1.Execute then begin
						//‚È‚º‚©ƒLƒƒƒ“ƒZƒ‹‚Å‚à‚±‚Á‚¿‚É“ü‚Á‚Ä‚­‚é
						if ExtractFilePath(FileSaveAs1.Dialog.FileName) <> '' then begin
							html := TStringList.Create;
							title := TThreadItem(List[i]).Title;
							try
								GikoSys.CreateHTML3(html, TThreadItem(List[i]), title);
								html.SaveToFile(FileSaveAs1.Dialog.FileName);
								SkinorCSSFilesCopy(ExtractFilePath(FileSaveAs1.Dialog.FileName));
							finally
								html.Free;
							end;
						end;
					end;
				end;
			end;
		end;
	finally
		Screen.Cursor := crDefault;
		List.Free;
	end;
end;
procedure TGikoForm.SkinorCSSFilesCopy(path: string);
var
	tmp, tmpD, tmpF: string;
	current: string;
	dirs: TStringList;
	files: TStringList;
	i, j: Integer;
begin
	if GikoSys.Setting.UseSkin then begin
		current := ExtractFilePath(GikoSys.GetSkinDir);
		tmp := GikoSys.Setting.CSSFileName;
	end else if GikoSys.Setting.UseCSS then begin
		current := ExtractFilePath(GikoSys.GetStyleSheetDir);
		tmp := ExtractFilePath(GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName);
	end;
	dirs := TStringList.Create;
	try
		dirs.Add(tmp);
		if tmp <> current then begin
			GikoSys.GetDirectoryList(current, '*.*', dirs, true);
			for i := 0 to dirs.Count - 1 do begin
				files := TStringList.Create;
				try
					gikoSys.GetFileList(dirs[i], '*.*', files, true);
					tmpD := CustomStringReplace(dirs[i], GikoSys.GetConfigDir, path);
					if (AnsiPos(dirs[i], tmp) <> 0) and not (DirectoryExists(tmpD)) then
						ForceDirectories(tmpD);

					if(dirs[i] = tmp) and (dirs[i] <> current) then begin
						for j := 0 to files.Count - 1 do begin
							tmpF := CustomStringReplace(files[j], GikoSys.GetConfigDir, path);
							if not FileExists(tmpF) then begin
								CopyFile(PChar(files[j]), PChar(tmpF),True);
							end;
						end;
					end;
				finally
					files.Free;
				end;
			end;
		end else begin
			tmpD := CustomStringReplace(dirs[0], GikoSys.GetConfigDir, path);
			if not DirectoryExists(tmpD) then
				ForceDirectories(tmpD);
			tmpF := CustomStringReplace(GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName
					, GikoSys.GetConfigDir, path);
			if not FileExists(tmpF) then begin
				CopyFile(PChar(GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName)
					, PChar(tmpF), True);
			end;
		end;
	finally
		dirs.Free;
	end;


end;
procedure TGikoForm.KidokuActionExecute(Sender: TObject);
var
	List: TList;
	i: Integer;
begin
	List := TList.Create;
	try
		SelectListItem(List);
		for i := 0 to List.Count - 1 do begin
			if TObject(List[i]) is TThreadItem then begin
				TThreadItem(List[i]).UnRead := false;
				TThreadItem(List[i]).ParentBoard.UnRead := TThreadItem(List[i]).ParentBoard.UnRead - 1;
			end;
		end;
		if TreeView.Visible then
			TreeView.Refresh;
	finally
		List.Free;
	end;
end;

procedure TGikoForm.MidokuActionExecute(Sender: TObject);
var
	List: TList;
	i: Integer;
begin
	List := TList.Create;
	try
		SelectListItem(List);
		for i := 0 to List.Count - 1 do begin
			if TObject(List[i]) is TThreadItem then begin
				TThreadItem(List[i]).UnRead := true;
				TThreadItem(List[i]).ParentBoard.UnRead := TThreadItem(List[i]).ParentBoard.UnRead + 1;
			end;
		end;
		if TreeView.Visible then
			TreeView.Refresh;
	finally
		List.Free;
	end;
end;

procedure TGikoForm.BrowserPanelCanResize(Sender: TObject; var NewWidth,
  NewHeight: Integer; var Resize: Boolean);
var
	i: Integer;
begin
	for i := 0 to BROWSER_COUNT - 1 do
		SetWindowPos(TWebBrowser(FBrowsers[i]).Handle, HWND_NOTOPMOST, 0, 0, NewWidth, NewHeight, SWP_NOMOVE + SWP_NOZORDER);

	if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
		SetWindowPos(FActiveContent.Browser.Handle, HWND_NOTOPMOST, 0, 0, NewWidth, NewHeight, SWP_NOMOVE + SWP_NOZORDER);
	end;
end;

procedure TGikoForm.LogFolderOpenActionExecute(Sender: TObject);
var
	List: TList;
begin
	if ((GikoSys.Setting.ListOrientation = gloVertical) and
		(GikoSys.Setting.ListHeightState = glsMax)) or
		((GikoSys.Setting.ListOrientation = gloHorizontal) and
		(GikoSys.Setting.ListWidthState = glsMax))	then begin
		if(GetActiveContent <> nil) then begin
			GikoSys.CreateProcess('explorer.exe', '/e,"' + ExtractFilePath(GetActiveContent.FilePath) + '"');
		end;
	end else if GetActiveList is TCategory then begin
		List := TList.Create;
		try
			SelectListItem(List);
			GikoSys.CreateProcess('explorer.exe', '/e,"' + ExtractFilePath(TBoard(List[0]).FilePath) + '"');
		finally
			List.Free;
		end;
	end else if GetActiveList is TBoard then begin
		GikoSys.CreateProcess('explorer.exe', '/e,"' + ExtractFilePath(TBoard(GetActiveList).FilePath) + '"');
	end;

end;

procedure TGikoForm.LogFolderOpenActionUpdate(Sender: TObject);
begin
	if (GetActiveList is TCategory) and (ListView.SelCount > 0) then
		LogFolderOpenAction.Enabled := True
	else if GetActiveList is TBoard then
		LogFolderOpenAction.Enabled := True
	else
		LogFolderOpenAction.Enabled := False;
end;

procedure TGikoForm.LocalRuleViewClick(Sender: TObject);
var
        RefURL,
        RefeURL,
        RuleURL,
        RuleTxt:String;
        FBoard: TBoard;
        Indy: TIdHTTP;
        FileStream: TFileStream;
begin
        //ƒ[ƒJƒ‹ƒ‹[ƒ‹Žæ“¾ by ’èŠú•Ö
	RefURL := GikoSys.UrlToServer(FBoard.URL)
		+ GikoSys.UrlToID(FBoard.URL)
		+ '/';
        //ŽŽ‚µ‚Éƒ[ƒJƒ‹ƒ‹[ƒ‹Žæ“¾‚à
        RuleURL := RefURL
                + 'head.txt';
        //Žæ“¾`
	RuleTxt := Indy.Get(RuleURL);
        //FileStream.Create('head.txt', fmCreate) := Indy.Get(RuleURL, FileStream);
        //ŽŽŒ±•\Ž¦`
        if RuleTxt = '' then begin
                ShowMessage('ƒ[ƒJƒ‹ƒ‹[ƒ‹Žæ“¾Ž¸”s');
        end;
        ShowMessage(RuleTxt);

end;

initialization
				OleInitialize(nil);
finalization
				OleUninitialize;

end.
