class Shortcut extends UICommonAPI;

const CHAT_WINDOW_NORMAL = 0;
const CHAT_WINDOW_TRADE = 1;
const CHAT_WINDOW_PARTY = 2;
const CHAT_WINDOW_CLAN = 3;
const CHAT_WINDOW_ALLY = 4;
const CHAT_WINDOW_COUNT = 5;
const CHAT_WINDOW_SYSTEM = 5;		// 시스템 메시지 창

const DIALOGID_Gohome = 44420;

var bool m_chatstateok;

event OnRegisterEvent()
{
	RegisterEvent(EV_ShortcutCommand);
	RegisterEvent(EV_StateChanged);
	RegisterEvent(EV_ShowWindow);
	RegisterEvent(EV_DialogOK);
	RegisterEvent(EV_DialogCancel);
}

event OnEvent(int a_EventID, string a_Param)
{
	switch(a_EventID)
	{
		case EV_ShortcutCommand:
			HandleShortcutCommand(a_Param);
			break;
		case EV_StateChanged:
			HandleStateChange(a_Param);
			break;
		case EV_ShowWindow:
			HandleShortcutKeyEvent(a_Param);
			break;
		case EV_DialogOK:
			HandleDialogOK();
			break;
	}
}

private function OptionMuteModeChange()
{
	local int currentMODE;

	currentMODE = GetOptionInt("Audio", "MODE");
	if(currentMODE == 2)
	{
		currentMODE = 0;		
	}
	else
	{
		currentMODE++;
	}
	SetOptionInt("Audio", "MODE", currentMODE);
	Debug("Shorcut OptionMuteModeChanged");
	OptionWnd(GetScript("OptionWnd"))._InitAudioOption();	
}

function HandleShortcutKeyEvent(string a_Param)
{
	local string wndname;
	local OptionWnd o_script;
	local ShortcutWnd s_script;
	local WindowHandle TempWnd;
	local string TargetName;

	ParseString(a_Param, "Name", wndname);
	o_script = OptionWnd(GetScript("OptionWnd"));
	s_script = ShortcutWnd(GetScript("ShortcutWnd"));
	if(getInstanceUIData().getIsClassicServer())
	{
		TargetName = TargetStatusWndClassic(GetScript("TargetStatusWndClassic")).g_NameStr;		
	}
	else
	{
		TargetName = TargetStatusWnd(GetScript("TargetStatusWnd")).g_NameStr;
	}

	switch(wndname)
	{
		case "GMWnd":
		case "GMClanWnd":
		case "GMDetailStatusWnd":
		case "GMInventoryWnd":
		case "GMMagicSkillWnd":
		case "GMQuestWnd":
		case "GMWarehouseWnd":
		case "GMSnoopWnd":
		case "GMPetitionWnd":
			if(! IsBuilderPC())
			{
				return;
			}
			break;
	}

	switch(wndname)
	{
		case "InventoryWnd":
			ExecuteEvent(EV_InventoryToggleWindow);	
			break;
		case "MacroWnd":
			ExecuteEvent(EV_MacroShowListWnd);
			break;
		case "PartyMatchWnd":
			HandlePartyMatchingOnOff();
			break;
		case "BoardWnd":
			TempWnd = GetWindowHandle("BoardWnd");
			if(TempWnd.IsShowWindow())
			{
				TempWnd.HideWindow();
			}
			else
			{
				ExecuteEvent(EV_ShowBBS);
			}
			break;
		case "MinimapWnd":
			RequestOpenMinimap();
			break;
		
		case "HelpHtmlWnd":
			HandleShowHelpHtmlWnd();
			break;
		
		case "FN_HideDropItemSilhauette":
			if (GetOptionBool("ScreenInfo", "HideDropItem"))
			{
				SetOptionBool("ScreenInfo", "HideDropItem", false);
			}
			else
			{
				SetOptionBool("ScreenInfo", "HideDropItem", true);
			}
			o_script.InitScreenInfoOption();
			break;
		case "FN_SendTargetedCharacterMessage":
			if (TargetName == "")
			{
			}
			else
			{
				/*
				 *roleback chatMessage > chatWnd
				 */
				//callGFxFunction("ChatMessage","sendWhisper", t_script.g_NameStr);
				SetChatMessage("\"" $ TargetName $ " ");
			}
			break;
			//
		case "FN_MuteAllAudio":
			OptionMuteModeChange();
			break;
		case "FN_SHORTCUTEXPAND":
			s_script.OnClickExpandShortcutButton();
			break;
		case "FN_UILocReset":
			o_script.SetDefaultPositionByClick();
			break;
		case "SystemMenuWnd":
			break;
		//메뉴 리뉴얼로인하여 추가.
		//우편함
		case "Post":
			HandleShowPostBoxWnd();
			break;		
		//단축키 변경창
		case "ShortcutAssign":
			HandleShowShortcutAssignWnd();
			break;
		//인스턴스존
		case "InstancedZone":
			if(class'UIAPI_WINDOW'.static.IsShowWindow("InstancedZoneHistoryWnd"))
			{
				class'UIAPI_WINDOW'.static.HideWindow("InstancedZoneHistoryWnd");
			}
			else
			{
				RequestInzoneWaitingTime();
			}
			break;
		//동영상 녹화
		case "Rec":
			HandleShowMovieCaptureWnd();
			break;
		//리플레이 녹화
		case "Replayrec":
			DoAction(class'UICommonAPI'.static.GetItemID(55));
			break;
		//상품인벤토리
		case "Productinven":
			HandleShowProductInventory();
			break;
		//판매상점
		case "ShopSell":
			if(class'UIAPI_WINDOW'.static.IsShowWindow("PrivateShopWnd"))
			{
				PrivateShopWnd(GetScript("PrivateShopWnd")).OnClickButton("StopButton");
			}
			else
			{
				DoAction(class'UICommonAPI'.static.GetItemID(10));
			}
			break;
		//구매상점
		case "ShopBuy":
			if(class'UIAPI_WINDOW'.static.IsShowWindow("PrivateShopWnd"))
			{
				PrivateShopWnd(GetScript("PrivateShopWnd")).OnClickButton("StopButton");
			}
			else
			{
				DoAction(class'UICommonAPI'.static.GetItemID(28));
			}
			break;
		//일괄판매상점
		case "ShopSellAll":
			if(class'UIAPI_WINDOW'.static.IsShowWindow("PrivateShopWnd"))
			{
				PrivateShopWnd(GetScript("PrivateShopWnd")).OnClickButton("StopButton");
			}
			else
			{
				DoAction(class'UICommonAPI'.static.GetItemID(61));
			}
			break;
		//상점검색
		case "ShopSearch":
			DoAction(class'UICommonAPI'.static.GetItemID(57));
			break;
		//진정
		case "Petition":
			HandleShowPetitionBegin();
			break;
		//홈페이지
		case "Homepage":
			linkHomepage();
			break;
		//PC방 포인트
		case "PcRoom":
			HandleToggleShowPCCafeEventWnd();
			break;
		default:
			WindowOpenOrClose(WNDName);
		break;
	}
}


/* ****************************************************
 * 윈도우 열고 닫기 
 **************************************************** */

// 서버 타입에 의한 윈도우 이름 받기
function string getWindowNameByServerType(string wndname)
{
	if(wndname == "ChatMessage")
	{
		wndname = "ChatWnd";		
	}

	// 클래식 윈도우
	else if (getInstanceUIData().getisClassicServer())
	{
		wndname = GetClassicWindowName(wndname);
		if(wndname == "ClanWndClassic")
		{
			wndname = "ClanWndClassicNew";
		}
	}

	return wndname;
}

// 클래식 윈도우로 따로 만들어져 있는 윈도우들 목록
function string GetClassicWindowName (string WNDName)
{
	switch (WNDName)
	{
		case "ClanWnd":
		case "DetailStatusWnd":
			return WNDName $ "Classic";
		case "QuestTreeWnd":
			if(IsAdenServer())
			{
				return "QuestWnd";
			}
	}
	return WNDName;
}

// 사운드 받기
function getSoundTypeByWndName (string WndName, out EInterfaceSoundType openSound, out EInterfaceSoundType closeSound) 
{
	switch  (WNDName) //사운드 세팅
	{	
	case "MagicSkillWnd":
		openSound = IFST_MAPWND_OPEN;
		closeSound = IFST_MAPWND_CLOSE;
		break;
	case "ActionWnd":
	case "DetailStatusWnd":
	case "DetailStatusWndClassic":
		openSound =  IFST_WINDOW_OPEN;
		closeSound = IFST_WINDOW_CLOSE;
		break;	
	default :
		openSound = IFST_STATUSWND_OPEN;
		closeSound = IFST_STATUSWND_CLOSE;
		break;
	}
}

function WindowOpenOrClose(string WNDName)
{
	local EInterfaceSoundType openSound, closeSound;	

	local WindowHandle WNDNameHandle;
	local int tempVars;	
	//local int nUsePledgeV2Live, nUsePledgeV2Classic;
	WndName = getWindowNameByServerType (WndName);
	WNDNameHandle = GetWindowHandle (WndName) ;

	getSoundTypeByWndName(WndName, openSound, closeSound) ;	
	//Debug ("WindowOpenOrClose" @ WndName);
	switch (WNDName) 
	{
		case "TeleportMapWnd":
			if(USE_XML_TELEPORT_UI)
			{
				if (Class'UIAPI_WINDOW'.static.IsShowWindow("TeleportWnd"))
				{
					Class'UIAPI_WINDOW'.static.HideWindow("TeleportWnd");
				}
				else
				{
					if(class'UIDATA_PLAYER'.static.IsInDethrone())
					{
						getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(4047));
						return;
					}
					class'UIAPI_WINDOW'.static.ShowWindow("TeleportWnd");
				}
			}
			else
			{
				if(class'UIAPI_WINDOW'.static.IsShowWindow(wndname))
				{
					class'UIAPI_WINDOW'.static.HideWindow(wndname);					
				}
				else
				{
					if(class'UIDATA_PLAYER'.static.IsInDethrone())
					{
						getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(4047));
						return;
					}
					TeleportMapWnd(GetScript("TeleportMapWnd")).RQ_C_EX_Teleport_UI();
				}
			}
			break;
		case "RadarMapWnd" :
			toggleWindow(wndname);
			break;
		case "OptionWnd":
			toggleShowOptionWnd();
			break;
		// 채팅창에 붙어 있는 월드맵 채트 박스 처리
		case "ChatWnd":		
			if(WNDNameHandle.IsShowWindow())
			{
				callGFxFunction("WorldChatBox","ToggleShowWnd", "hide");
				WNDNameHandle.HideWindow();
				PlayConsoleSound(closeSound);
			}
			else
			{
				GetINIBool("global", "UseWorldChatSpeaker", tempVars, "chatfilter.ini");		
				if(bool(tempVars))
				{
					callGFxFunction("WorldChatBox","ToggleShowWnd", "show");
				}

				WNDNameHandle.ShowWindow();
				WNDNameHandle.SetFocus();
				PlayConsoleSound(openSound);
			}		
			break;

		case "ClanWnd":
		case "ClanWndClassicNew":
			if(getInstanceUIData().getIsClassicServer())
			{
				//GetINIBool ("Localize", "UsePledgeV2Classic", nUsePledgeV2Classic, "L2.ini");

				// 혈맹 리뉴얼 UI 사용
				if (getInstanceL2Util().isClanV2())
					toggleWindow("ClanGfxWnd", true, true);
				else
					toggleWindow("ClanWndClassicNew", true, true);
			}
			else
			{
				// 라이브
				//GetINIBool ("Localize", "UsePledgeV2Live", nUsePledgeV2Live, "L2.ini");

				// 혈맹 리뉴얼 UI 사용
				//if (nUsePledgeV2Live > 0)
				//	toggleWindow("ClanGfxWnd", true, true);
				//else
				//	toggleWindow("ClanWnd", true, true);

				if(getInstanceL2Util().isClanV2())
				{
					toggleWindow("ClanGfxWnd", true, true);
				}
				else
				{
					toggleWindow("ClanWnd", true, true);
				}
			}

			break;
		case "MagicSKillWnd":
			if(IsUseRenewalSkillWnd())
			{
				if(class'UIAPI_WINDOW'.static.IsShowWindow("SkillWnd"))
				{
					class'UIAPI_WINDOW'.static.HideWindow("SkillWnd");
					PlayConsoleSound(closeSound);					
				}
				else
				{
					class'UIAPI_WINDOW'.static.ShowWindow("SkillWnd");
					PlayConsoleSound(openSound);
				}				
			}
			else
			{
				if(WNDNameHandle.IsShowWindow())
				{
					WNDNameHandle.HideWindow();
					PlayConsoleSound(closeSound);					
				}
				else
				{
					WNDNameHandle.ShowWindow();
					WNDNameHandle.SetFocus();
					PlayConsoleSound(openSound);
				}
			}
			break;
		// 기본 showhide
		Default :
			if(WNDNameHandle.IsShowWindow())
			{
				WNDNameHandle.HideWindow();
				PlayConsoleSound(closeSound);
			}
			else
			{
				WNDNameHandle.ShowWindow();
				WNDNameHandle.SetFocus();
				PlayConsoleSound(openSound);
			}
			break;
	}
}

function toggleShowOptionWnd()
{
	local OptionWnd win;
	win = OptionWnd(GetScript("OptionWnd"));
	win.ToggleOpenMeWnd(false); //옵션창만 열기
}

/**
 * 단축키 창 열기
 */
function HandleShowShortcutAssignWnd()
{
	local OptionWnd win;	
	win = OptionWnd(GetScript("OptionWnd"));
	win.ToggleOpenMeWnd(true);  //숏컷 창으로 열기 
}

function HandleToggleShowQuestWNd()
{
	local WindowHandle win;

	if(IsAdenServer())
	{
		win = GetWindowHandle("QuestWnd");
	}
	else
	{
		win = GetWindowHandle("QuestTreeWnd");
	}
	Debug("HandleToggleShowQuestWNd " @ win.GetWindowName());
	if(win.IsShowWindow())
	{
		win.HideWindow();
	}
	else
	{
		RequestRequestReceivedPostList();
	}
}

// 빌더 명령어에 의해 창을 감추고 보여주는 함수 PC방 포인트
function HandleToggleShowPCCafeEventWnd()
{
}

/**
 * 동영상 녹화 창 열기
 */
function HandleShowMovieCaptureWnd()
{
	local bool tmpBool;
	local WindowHandle win;	
	local WindowHandle win1;	

	win = GetWindowHandle("MovieCaptureWnd_Expand");
	win1 = GetWindowHandle("MovieCaptureWnd");

	tmpBool =IsNowMovieCapturing();

	//켑쳐 되고 있다면
	if(tmpBool)
	{
		win.HideWindow();
		//확장 창이 보여 진다면
		if (win.IsShowWindow())
		{
			PlayConsoleSound(IFST_WINDOW_CLOSE);
			win.HideWindow();
		}
		else 
		{			
			PlayConsoleSound(IFST_WINDOW_OPEN);
			win.ShowWindow();
			win.SetFocus();
		}
	} 
	//아니라면 일반 창 열고 닫기
	else 
	{
		if (win1.IsShowWindow())
		{
			PlayConsoleSound(IFST_WINDOW_CLOSE);
			win1.HideWindow();
		} 
		else
		{	
			PlayConsoleSound(IFST_WINDOW_OPEN);
			win1.ShowWindow();
			win1.SetFocus();

		}
	}	
}

/**
 * 진정 창 열기
 */
function HandleShowPetitionBegin()
{
	local WindowHandle win;	
	local WindowHandle win1;	
	local WindowHandle win2;	
	local PetitionMethod useNewPetition;

	win = GetWindowHandle("NewUserPetitionWnd");
	win1 = GetWindowHandle("UserPetitionWnd");
	win2 = GetWindowHandle("WebPetitionWnd");

	useNewPetition = GetPetitionMethod();

	if(useNewPetition == PetitionMethod_New)
	{
		if(win.IsShowWindow())
		{
			PlayConsoleSound(IFST_WINDOW_CLOSE);
			win.HideWindow();
		}
		else
		{
			PlayConsoleSound(IFST_WINDOW_OPEN);
			RequestShowPetitionAsMethod();
		}
	}
	else if(useNewPetition == PetitionMethod_Default)
	{
		if (win1.IsShowWindow())
		{
			PlayConsoleSound(IFST_WINDOW_CLOSE);
			win1.HideWindow();
		}
		else
		{
			PlayConsoleSound(IFST_WINDOW_OPEN);
			win1.ShowWindow();
			win1.SetFocus();
		}
	}
	else if(useNewPetition == PetitionMethod_Web)
	{
		if (win2.IsShowWindow())
		{
			PlayConsoleSound(IFST_WINDOW_CLOSE);
			win2.HideWindow();
		}
		else
		{
			PlayConsoleSound(IFST_WINDOW_OPEN);
			RequestShowPetitionAsMethod();
		}
	}
}

/**
 * 홈페이지 열기
 */
function linkHomePage()
{
	class'UICommonAPI'.static.DialogSetID(DIALOGID_Gohome);
	class'UICommonAPI'.static.DialogShow(DialogModalType_Modalless, DialogType_OKCancel, GetSystemMessage(3208), string(Self));
}

//홈페이지 링크(10.1.18 문선준 추가)
function HandleDialogOK()
{	
	if(! class'UICommonAPI'.static.DialogIsOwnedBy(string(Self)))
		return;

	switch(class'UICommonAPI'.static.DialogGetID())
	{
	case DIALOGID_Gohome:
		OpenL2Home();
		break;
	}
}

//상품 인벤토리 열기
function HandleShowProductInventory()
{
	local WindowHandle win;	
	local WindowHandle win1;	
	local L2Util util;
	
	win = GetWindowHandle("ProductInventoryWnd");
	win1 = GetWindowHandle("ShopWnd");
	util = L2Util(GetScript("L2Util"));	

	//보여지면 닫기
	if(win.isShowWindow())
	{
		PlayConsoleSound(IFST_INVENWND_CLOSE);
		win.HideWindow();
	}
	//아니면 열기
	else 
	{	
		util.ItemRelationWindowHide("ProductInventoryWnd");

		if(!win1.IsShowWindow())
		{
			PlayConsoleSound(IFST_INVENWND_OPEN);
			win.ShowWindow();
			win.SetFocus();
		}
	}
}

/**
 * 우폄함 열기
 */
function HandleShowPostBoxWnd()
{
	local WindowHandle win;
	win = GetWindowHandle("PostBoxWnd");
	
	if(win.IsShowWindow())
	{
		win.HideWindow();
		PlayConsoleSound(IFST_WINDOW_CLOSE);
	}
	else
	{
		PlayConsoleSound(IFST_WINDOW_OPEN);
		RequestRequestReceivedPostList();
	}
}

Function ClosePartyMatchingWnd()
{
	local WindowHandle TaskWnd;
	local PartyMatchWnd p_script;
	p_script = PartyMatchWnd(GetScript("PartyMatchWnd"));
	
	if(CREATE_ON_DEMAND==0)
		TaskWnd = GetHandle("PartyMatchWnd");
	else
		TaskWnd = GetWindowHandle("PartyMatchWnd");

	TaskWnd.HideWindow();
	p_script.OnSendPacketWhenHiding();
}

function HandleShowBBS ()
{
	local string param;

	if (GetWindowHandle("IngameWebWnd").IsShowWindow())
	{
		GetWindowHandle("IngameWebWnd").HideWindow();
		return;
	}
	param = "";
	ParamAdd(param,"Category","bbs");
	ExecuteEvent(EV_InGameWebWnd_Info,param);
}

function HandleShowHelpHtmlWnd()
{
	local AgeWnd script1;	// 등급표시 스크립트 가져오기

	class'HelpWnd'.static.ShowHelp();
	script1 = AgeWnd(GetScript("AgeWnd"));
	if(script1.bBlock == false)
	{
		script1.startAge();
	}
}

function HandlePartyMatchingOnOff()
{
	local WindowHandle PartyMatchRoomWnd;
	local windowHandle PartyMatchWnd;
	local PartyMatchRoomWnd p2_script;
	local L2Util util;

	if (getInstanceUIData().getIsArenaServer()) 
	{
		util = L2Util(GetScript("L2Util"));	
		util.showGfxScreenMessage ( GetSystemMessage (5517)) ;
	}

	PartyMatchWnd = GetWindowHandle("PartyMatchWnd");
	PartyMatchRoomWnd = GetWindowHandle("PartyMatchRoomWnd"); 
	
	
	//class'UIAPI_WINDOW'.static.IsMinimizedWindow("PartyMatchRoomWnd")
	p2_script = PartyMatchRoomWnd(GetScript("PartyMatchRoomWnd"));

	if(PartyMatchWnd.IsShowWindow())
	{
		ClosePartyMatchingWnd();
	}
	else
	{
		if (PartyMatchRoomWnd.IsShowWindow())
		{					
			PartyMatchRoomWnd.HideWindow();	
			//p2_script.ExitPartyRoom();		
			
			p2_script.OnSendPacketWhenHiding();
			PartyMatchWnd.SetTimer(1991, 500);			
		}
		else
		{	
			class'PartyMatchAPI'.static.RequestOpenPartyMatch();			
		}
	}
}

function OnTimer(int TimerID)
{
	if(TimerID == 1991)
	{		
		ClosePartyMatchingWnd();	
		class'UIAPI_WINDOW'.static.KillUITimer("ShortcutTab",1991); 		
	}
}

function HandleShortcutCommand(String a_Param)
{
	local String Command;
	
	if(ParseString(a_Param, "Command", Command))
	{
		switch(Command)
		{
			case "CloseAllWindow":		// alt + w
				HandleCloseAllWindow();
				break;
			case "ShowChatWindow":		// alt + j
			
				HandleShowChatWindow();
				//if (m_chatstateok == true)
				//{
				//	HandleShowChatWindow();
				//}
				break;
			case "SetPrevChatType":		// alt + page up	
			HandleSetPrevChatType();
			break;
			case "SetNextChatType":		// alt + page down
			HandleSetNextChatType();
			break;
			case "shortcutreset":
			class'ShortcutAPI'.static.RestoreDefault();
			break;
			case "shortcutsave":
			class'ShortcutAPI'.static.Save();
			break;
			case "shortcutload":
			class'ShortcutAPI'.static.RequestList();
			break;
			case "test":
			HandleShortcutTest();
			break;
			case "printshortcut":
			HandlePrintShortcut();
			break;

			case "getPrevTarget" :if (getInstanceUIData().getIsArenaServer()) ExecuteCommand("/targetPrev") ; break;
			case "getNextTarget" :if (getInstanceUIData().getIsArenaServer()) ExecuteCommand("/targetNext") ; break;
			case "useRunSkill" : if (getInstanceUIData().getIsArenaServer()) setUseSkill (18651)  ;break;		
			case "useBaseRecallSkill" : if (getInstanceUIData().getIsArenaServer()) setUseSkill (18652) ; break;

			case "AutoPlay":
				if (getInstanceUIData().getIsLiveServer())
				{
					AutoUseItemWnd(GetScript("AutoUseItemWnd")).OnClickButton("AutoTargetAll_BTN");
				}
				else
				{
					YetiQuickSlotWnd(GetScript("YetiQuickSlotWnd")).OnAutoHunt_All_BtnClick();
				}
			break;
			case "HideAllWindow":
				//Debug("HandleShortcutCommand" @ a_Param) ;
				HandleHideAllWindow();
		}
	}
}

function setUseSkill (int skillID) 
{
	local itemID skillItemID;
	skillItemID.ClassID = skillID;
	UseSkill(skillItemID, int(EShortCutItemType.SCIT_SKILL));
}


function HandleHideAllWindow()
{

}

function HandlePrintShortcut()
{
	local Array<ShortcutCommandItem> commandlist;
	local Array<string> grouplist;
	local int i;
	class'ShortcutAPI'.static.GetGroupList(groupList);
	for(i = 0 ; i < grouplist.Length ; ++i)
	{
		//debug("Group : " $ grouplist[i]);
		commandlist.Length = 0;
		class'ShortcutAPI'.static.GetGroupCommandList(grouplist[i], commandlist);
		//for(j=0 ; j < commandlist.Length ; ++j)
			//debug("key : " $ commandlist[j].Key $ ", subkey1 : " $ commandlist[j].subkey1 $ ", subkey2 : " $ commandlist[j].subkey2 $ ", action : " $ commandlist[j].sAction $ ", command : " $ commandlist[j].sCommand $ ", id : " $ commandlist[j].id);
	}
	grouplist.Length = 0;
	class'ShortcutAPI'.static.GetActiveGroupList(grouplist);
	for(i=0 ; i<grouplist.Length ; ++i)
	{
		//debug("ActiveGroup : " $ grouplist[i]);
	}
}

function HandleForceShowChatWindow (bool bOpen)
{
	local WindowHandle Handle;
	local int tempVars;

	Handle = GetWindowHandle("ChatWnd");
	if (bOpen)
	{
		Handle.ShowWindow();
		GetINIBool("global","SystemMsgWnd",tempVars,"chatfilter.ini");
		if (bool(tempVars))
		{
			if (getInstanceUIData().getIsLiveServer())
			{
				Class'UIAPI_WINDOW'.static.ShowWindow("SystemMsgWnd");
			}
		}
	}
	else
	{
		Handle.HideWindow();
		GetINIBool("global","SystemMsgWnd",tempVars,"chatfilter.ini");
		if (!bool(tempVars))
		{
			Class'UIAPI_WINDOW'.static.HideWindow("SystemMsgWnd");
		}
	}
}

//~ function HandleShortcutTest()
//~ {
	//~ local ShortcutCommandItem item;
	//~ local array<ShortcutCommandItem> items;
	//~ local int i;
	//~ item.sCommand = "ZoomIn";
	//~ item.key = "MouseWheelUp";
	//~ item.subkey1 = "";
	//~ item.subkey2 = "";
	//~ item.sState = "GamingState";
	//~ if(class'ShortcutAPI'.static.AssignShortcut(item))
		//~ Log("ShortcutAssign Success ZoomIn");
	//~ item.sCommand = "ZoomOut";
	//~ item.key = "MouseWheelDown";
	//~ item.subkey1 = "";
	//~ item.subkey2 = "";
	//~ item.sState = "GamingState";
	//~ if(class'ShortcutAPI'.static.AssignShortcut(item))
		//~ Log("ShortcutAssign Success ZoomOut");
	//~ item.sCommand = "TurnBack";
	//~ item.key = "MiddleMouse";
	//~ item.subkey1 = "";
	//~ item.subkey2 = "";
	//~ item.sState = "GamingState";
	//~ if(class'ShortcutAPI'.static.AssignShortcut(item))
		//~ Log("ShortcutAssign Success TurnBack");

	//~ item.sCommand = "ShowInventoryWindow";
	//~ item.key = "i";
	//~ item.subkey1 = "alt";
	//~ item.subkey2 = "";
	//~ item.sState = "GamingState";
	//~ if(class'ShortcutAPI'.static.AssignShortcut(item))
		//~ Log("ShortcutAssign Success TurnBack ShowInventoryWindow");

	//~ item.sCommand = "PKKey";
	//~ item.key = "Ctrl";
	//~ item.subkey1 = "";
	//~ item.subkey2 = "";
	//~ item.sState = "";
	//~ item.sCategory = "";
	//~ if(class'ShortcutAPI'.static.AssignSpecialKey(item))
		//~ Log("SpecialKeyAssign Success PKKey");

	//~ class'ShortcutAPI'.static.GetCommandItems(items);
	//~ for(i=0 ; i<items.Length ; ++i)
	//~ {
		//~ Log("Shortcut " $ i $ ": key(" $ items[i].key $ "), subkey1(" $ items[i].subkey1 $ "), subkey2(" $ items[i].subkey2 $ "), command(" $ items[i].sCommand $ "), state(" $ items[i].sState $ "), category(" $ items[i].sCategory $ ")");
	//~ }
//~ }

function HandleShortcutTest()
{
}

/*
 * rollback chatmessage > chatWnd 2012.11.01
 */
function HandleShowChatWindow()		// alt + j
{
	local WindowHandle handle;
	local int tempVars;

	handle = GetWindowHandle("ChatWnd");
	
	if(handle.IsShowWindow())
	{
		handle.HideWindow();
		GetINIBool("global", "SystemMsgWnd", tempVars, "chatfilter.ini");
		
		if(!bool(tempVars))
		{
			class'UIAPI_WINDOW'.static.HideWindow("SystemMsgWnd");
		}
			
	}
	else
	{
		handle.ShowWindow();
		GetINIBool("global", "SystemMsgWnd", tempVars, "chatfilter.ini");
		
		if(bool(tempVars))
		{
			if (getInstanceUIData().getIsLiveServer())
				class'UIAPI_WINDOW'.static.ShowWindow("SystemMsgWnd");
		}
	}

	/* chatMessage 용

	local WindowHandle handle;

	if(CREATE_ON_DEMAND==0)
		handle = GetHandle("ChatMessage");
	else
		handle = GetWindowHandle("ChatMessage");
	
	if(handle.IsShowWindow())
	{
		handle.HideWindow();
			
	}
	else
	{
		handle.ShowWindow();
	}
	*/
}



function HandleSetPrevChatType()		// alt + page up
{	
	/*
	 *rollback chatmessage > chatWnd
	 
	callGFxFunction("ChatMessage","setRemoteTabSelect", "true");
	*/
	
	local ChatWnd chatWndScript;			// 채팅 윈도우 클래스
	
	chatWndScript = ChatWnd(GetScript("ChatWnd"));	// 스크립트를 가져온다.
	
	//debug("chatWndScript.m_chatType" $ chatWndScript.m_chatType);
	switch (chatWndScript.m_chatType.UI)	
	{
		case CHAT_WINDOW_NORMAL:
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(4, true);
			chatWndScript.HandleTabClick("ChatTabCtrl4");
			break;
		case CHAT_WINDOW_TRADE:
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(0, true);
			chatWndScript.HandleTabClick("ChatTabCtrl0");
			break;
		case CHAT_WINDOW_PARTY:
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(1, true);
			chatWndScript.HandleTabClick("ChatTabCtrl1");
			break;
		case CHAT_WINDOW_CLAN:
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(2, true);
			chatWndScript.HandleTabClick("ChatTabCtrl2");
			break;
		case CHAT_WINDOW_ALLY:
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(3, true);
			chatWndScript.HandleTabClick("ChatTabCtrl3");
			break;		
	}
}

function HandleSetNextChatType()		// alt + page down
{
	/*
	 *rollback chatmessage > chatWnd
	 
	callGFxFunction("ChatMessage","setRemoteTabSelect", "false");
	*/

	local ChatWnd chatWndScript;			// 채팅 윈도우 클래스
	
	chatWndScript = ChatWnd(GetScript("ChatWnd"));	// 스크립트를 가져온다.
	
	//debug("chatWndScript.m_chatType" $ chatWndScript.m_chatType);
	switch (chatWndScript.m_chatType.UI)	
	{
		case CHAT_WINDOW_NORMAL:
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(1, true);
			chatWndScript.HandleTabClick("ChatTabCtrl1");
			break;
		case CHAT_WINDOW_TRADE:
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(2, true);
			chatWndScript.HandleTabClick("ChatTabCtrl2");
			break;
		case CHAT_WINDOW_PARTY:
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(3, true);
			chatWndScript.HandleTabClick("ChatTabCtrl3");
			break;
		case CHAT_WINDOW_CLAN:
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(4, true);
			chatWndScript.HandleTabClick("ChatTabCtrl4");
			break;
		case CHAT_WINDOW_ALLY:
			////chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_NORMAL);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_TRADE);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_PARTY);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_CLAN);
			//chatWndScript.ChatTabCtrl.MergeTab(CHAT_WINDOW_ALLY);
			chatWndScript.ChatTabCtrl.SetTopOrder(0, true);
			chatWndScript.HandleTabClick("ChatTabCtrl0");
			break;		
	}
}

// alt + w
function HandleCloseAllWindow()
{
	local WindowHandle handle;
	local int i;
	local array<string> WndList;
	local array<string> GFxWndList;
	
	local PrivateShopWnd PrivateShopWndScript;
	local ItemAutoPeelWnd ItemAutoPeelScript;

	/*
	 *2012.12.12 개인판매 창이 alt W로 닫힐 때 오류 발생
	 */
	PrivateShopWndScript = PrivateShopWnd(GetScript("PrivateShopWnd"));
	PrivateShopWndScript.RequestQuit();

	ItemAutoPeelScript = ItemAutoPeelWnd(GetScript("ItemAutoPeelWnd"));
	ItemAutoPeelScript.CloseWindow();
	if(class'UIDATA_PLAYER'.static.IsInDethrone() == false)
	{
		class'RecipeAPI'.static.RequestRecipeShopManageQuit();
		Debug("--> RequestRecipeShopManageQuit");
		class'EnchantAPI'.static.RequestExCancelEnchantItem();
		Debug("--> RequestExCancelEnchantItem");
	}
	WndList[WndList.Length] = "ActionWnd";
	WndList[WndList.Length] = "AttributeEnchantWnd";
	WndList[WndList.Length] = "AttributeRemoveWnd";
	WndList[WndList.Length] = "BoardWnd";
	WndList[WndList.Length] = "CalculatorWnd";
	WndList[WndList.Length] = getWindowNameByServerType ("ClanWnd");
	WndList[WndList.Length] = "ConsoleWnd";
	WndList[WndList.Length] = "CouponEventWnd";
	WndList[WndList.Length] = "DeliverWnd";
	WndList[WndList.Length] = "SelectDeliverWnd";
	WndList[WndList.Length] = getWindowNameByServerType ("DetailStatusWnd");
	WndList[WndList.Length] = "MailBtnWnd";
	WndList[WndList.Length] = "HelpHtmlWnd";
	WndList[WndList.Length] = "HelpWnd";
	WndList[WndList.Length] = "HennaInfoWnd";
	WndList[WndList.Length] = "HennaListWnd";

	WndList[WndList.Length] = "HennaInfoWndLive";
	WndList[WndList.Length] = "HennaListWndLive";
	WndList[WndList.Length] = "HennaEngraveWndLive";

	WndList[WndList.Length] = "HeroTowerWnd";
	WndList[WndList.Length] = "HeroTowerWndWorld";
	WndList[WndList.Length] = "InventoryWnd";
	WndList[WndList.Length] = "ItemEnchantWnd";
	WndList[WndList.Length] = "XMasSealWnd";
	WndList[WndList.Length] = "MacroEditWnd";
	WndList[WndList.Length] = "MacroListWnd";
	WndList[WndList.Length] = "MagicSkillWnd";
	//WndList[WndList.Length] = "MainWnd";
	WndList[WndList.Length] = "ManorCropInfoChangeWnd";
	WndList[WndList.Length] = "ManorCropInfoSettingWnd";
	WndList[WndList.Length] = "ManorCropSellChangeWnd";
	WndList[WndList.Length] = "ManorCropSellWnd";
	//WndList[WndList.Length] = "ManorInfo_Crop";
	//WndList[WndList.Length] = "ManorInfo_Default";
	//WndList[WndList.Length] = "ManorInfo_Seed";
	WndList[WndList.Length] = "ManorInfoWnd";
	WndList[WndList.Length] = "ManorSeedInfoChangeWnd";
	WndList[WndList.Length] = "ManorSeedInfoSettingWnd";
	WndList[WndList.Length] = "ManorShopWnd";
	//WndList[WndList.Length] = "MinimapWnd";
	//WndList[WndList.Length] = "MinimapWnd_Expand";
	//WndList[WndList.Length] = "MoviePlayerWnd";
	WndList[WndList.Length] = "MultiSellWnd";
	WndList[WndList.Length] = "OptionWnd";
	WndList[WndList.Length] = "PetitionFeedBackWnd";
	WndList[WndList.Length] = "PetitionWnd";
	WndList[WndList.Length] = "UserPetitionWnd";
	WndList[WndList.Length] = "PetWnd";
	WndList[WndList.Length] = "PetWndClassic";
	WndList[WndList.Length] = "PrivateShopWnd";
	WndList[WndList.Length] = "QuestListWnd";
	WndList[WndList.Length] = "QuestTreeWnd";	
	WndList[WndList.Length] = "RecipeBookWnd";
	WndList[WndList.Length] = "RecipeBuyListWnd";
	WndList[WndList.Length] = "RecipeBuyManufactureWnd";
	WndList[WndList.Length] = "RecipeManufactureWnd";
	WndList[WndList.Length] = "RecipeShopWnd";
	WndList[WndList.Length] = "RecipeTreeWnd";
	WndList[WndList.Length] = "RefineryWnd";
	WndList[WndList.Length] = "ReplayListWnd";
	WndList[WndList.Length] = "ReplayLogoWnd";
	//WndList[WndList.Length] = "ScenePlayerWnd";
	WndList[WndList.Length] = "ShopWnd";
	WndList[WndList.Length] = "SiegeInfoWnd";
	//WndList[WndList.Length] = "SkillEnchantInfoWnd";
	//WndList[WndList.Length] = "SkillEnchantWnd";
	//WndList[WndList.Length] = "SSQMainBoard";
	//WndList[WndList.Length] = "SSQMainBoard_SSQMainEventWnd";
	//WndList[WndList.Length] = "SSQMainBoard_SSQSealStatusWnd";
	//WndList[WndList.Length] = "SSQMainBoard_SSQStatusWnd";
	WndList[WndList.Length] = "SummonedWnd";
	//WndList[WndList.Length] = "SystemMenuWnd";
	WndList[WndList.Length] = "TownMapWnd";
	WndList[WndList.Length] = "TradeWnd";
	WndList[WndList.Length] = "SkillTrainClanTreeWnd";
	//WndList[WndList.Length] = "SkillTrainInfoSubWndEnchant";
	//WndList[WndList.Length] = "SkillTrainInfoSubWndNormal";
	WndList[WndList.Length] = "SkillTrainInfoWnd";
	WndList[WndList.Length] = "SkillTrainListWnd";
	WndList[WndList.Length] = "TutorialViewerWnd";
	WndList[WndList.Length] = "unrefineryWnd";
	WndList[WndList.Length] = "WarehouseWnd";

	//파티 매칭
	WndList[WndList.Length] = "PartyMatchWnd";
	//인맥
	WndList[WndList.Length] = "PersonalConnectionsWnd";
	
	//2012.12.17 창 목록 추가 
	WndList[WndList.Length] = "NPCDialogWnd";
	WndList[WndList.Length] = "PostBoxWnd";
	WndList[WndList.Length] = "NewUserPetitionWnd";
	WndList[WndList.Length] = "ProductInventoryWnd";
	WndList[WndList.Length] = "GiftInventoryWnd";
	//2013.01.03 창 목록 추가 > 언급 된 닫히지 않는 창 목록 입니다.
	WndList[WndList.Length] = "AuctionWnd";
	WndList[WndList.Length] = "BlockCurWnd";
	WndList[WndList.Length] = "BlockEnterWnd";
	WndList[WndList.Length] = "CleftEnterWnd";
	WndList[WndList.Length] = "CleftCurWnd";
	WndList[WndList.Length] = "ColorNickNameWnd";
	WndList[WndList.Length] = "DominionWarInfoWnd";
	WndList[WndList.Length] = "FileRegisterWnd";
	WndList[WndList.Length] = "KillPointRankWnd";
	WndList[WndList.Length] = "MagicskillGuideWnd";
	WndList[WndList.Length] = "miniGame1Wnd";
	WndList[WndList.Length] = "NewPetitionWnd";
	//해외 사용 여부 확인 필요
	WndList[WndList.Length] = "PetitionFeedBackWnd";
	WndList[WndList.Length] = "PostWriteWnd";
	WndList[WndList.Length] = "PremiumItemGetWnd";
	WndList[WndList.Length] = "PVPDetailedWnd";
	WndList[WndList.Length] = "QuesthtmlWnd";
	WndList[WndList.Length] = "SeedShopWnd";
	WndList[WndList.Length] = "SellingAgencyWnd";
	WndList[WndList.Length] = "TeleportBookMarkWnd";
	WndList[WndList.Length] = "WebPetitionWnd";
	//2013.08.22 접속공지창 추가
	WndList[WndList.Length] = "IngameNoticeWnd";
	//2013.09.09 쥬엘 인첸 창 추가
	WndList[WndList.Length] = "ItemJewelEnchantWnd";
	//게임 이용 제한 윈도우
	WndList[WndList.Length] = "PlayerAgeWnd";
		// path to awaken 
	if (GetLanguage() != 0)
		WndList[WndList.Length] = "BR_PathWnd";
	// 오늘의 할일
	WndList[WndList.Length] = "ToDoListWnd";
	// 오늘의 할일 혈맹
	WndList[WndList.Length] = "ToDoListClanWnd";
	//인벤토리 보기 윈도우
	WndList[WndList.Length] = "InventoryViewer";
	// 집혼 
	WndList[WndList.Length] = "EnsoulWnd";
	WndList[WndList.Length] = "AttendCheckWnd";
	WndList[WndList.Length] = "SiegeReportWnd";
	WndList[WndList.Length] = "AgitDecoWnd";
	WndList[WndList.Length] = "MonsterArenaResultWnd";
	WndList[WndList.Length] = "MacroPresetWnd";
	WndList[WndList.Length] = "IngameWebWnd";
	WndList[WndList.Length] = "MonsterBookDetailedInfo";
	WndList[WndList.Length] = "PrivateShopWndHistory";
	WndList[WndList.Length] = "ItemLockWnd";
	WndList[WndList.Length] = "OlympiadWnd";
	WndList[WndList.Length] = "OlympiadRandomChallengeWnd";
	WndList[WndList.Length] = "RestartMenuWndReportDamage";
	WndList[WndList.Length] = "RestartMenuWndReportLostItem";
	WndList[WndList.Length] = "TimeZoneWnd";
	WndList[WndList.Length] = "RankingWnd";
	WndList[WndList.Length] = "AutoPotionSubWnd";
	WndList[WndList.Length] = "AutoUseItemInventory";
	WndList[WndList.Length] = "SiegeCastleInfoWnd";
	WndList[WndList.Length] = "SiegeWnd";
	WndList[WndList.Length] = "SiegeMercenaryWnd";
	WndList[WndList.Length] = "SiegeInfoMCWWnd";
	WndList[WndList.Length] = "EventletterCollectorWnd";
	WndList[WndList.Length] = "RandomCraftChargingWnd";
	WndList[WndList.Length] = "RandomCraftWnd";
	WndList[WndList.Length] = "MenuEntireWnd";
	WndList[WndList.Length] = "FortressBattleInfoWnd";
	WndList[WndList.Length] = "LocationShareWnd";
	WndList[WndList.Length] = "MoveLocationWnd";
	WndList[WndList.Length] = "MarbleGameWnd";
	WndList[WndList.Length] = "HomunculusWnd";
	WndList[WndList.Length] = "PetExtractWnd";
	WndList[WndList.Length] = "UIControlContextMenu";
	WndList[WndList.Length] = "FestivalRankingWnd";
	WndList[WndList.Length] = "FestivaRankingWindowTooltip";
	WndList[WndList.Length] = "FestivalRankingBonusWnd";
	WndList[WndList.Length] = "RestoreLostPropertyWnd";
	WndList[WndList.Length] = "SuppressWnd";
	WndList[WndList.Length] = "SuppressDrawWnd";
	WndList[WndList.Length] = "BlackCouponWnd";
	WndList[WndList.Length] = "InfoFightWndClassic";
	WndList[WndList.Length] = "ClanShopWndClassic";
	WndList[WndList.Length] = "DethroneCharacterCreatewnd";
	WndList[WndList.Length] = "DethroneWnd";
	WndList[WndList.Length] = "DethroneResultWnd";
	WndList[WndList.Length] = "ColorNickNameWndClassic";
	WndList[WndList.Length] = "PrivateShopFindWnd";
	WndList[WndList.Length] = "HennaEnchantWnd";
	WndList[WndList.Length] = "HennaMenuWnd";
	WndList[WndList.Length] = "WorldSiegeBoardWnd";
	WndList[WndList.Length] = "WorldSiegeInfoMCWWnd";
	WndList[WndList.Length] = "WorldSiegeMercenaryWnd";
	WndList[WndList.Length] = "WorldSiegeRankingWnd";
	WndList[WndList.Length] = "WorldSiegeWnd";
	WndList[WndList.Length] = "HennaDyeEnchantWnd";
	WndList[WndList.Length] = "ItemMultiEnchantWnd";
	WndList[WndList.Length] = "WorldExchangeRegiWnd";
	WndList[WndList.Length] = "WorldExchangeBuyWnd";
	WndList[WndList.Length] = "FestivalWRankingWnd";
	WndList[WndList.Length] = "FestivalWRankingWindowTooltip";
	WndList[WndList.Length] = "FestivalWRankingBonusWnd";
	WndList[WndList.Length] = "HeroBookWnd";
	WndList[WndList.Length] = "HeroBookCraftChargingWnd";
	WndList[WndList.Length] = "TeleportWnd";
	WndList[WndList.Length] = "MultiSellItemExchangeWnd";
	WndList[WndList.Length] = "AbilityUIWnd";
	WndList[WndList.Length] = "RevengeWnd";
	WndList[WndList.Length] = "DethroneFireStateWnd";
	WndList[WndList.Length] = "DethroneFireEnchantWnd";
	WndList[WndList.Length] = "QuitReportInstantZoneWnd";
	WndList[WndList.Length] = "QuestProgressWnd";
	if(IsUseRenewalSkillWnd())
	{
		WndList[WndList.Length] = "SkillWnd";
		WndList[WndList.Length] = "SkillSpExtractWnd";
		WndList[WndList.Length] = "SkillEnchantWnd";
	}
	if(IsAdenServer())
	{
		WndList[WndList.Length] = "MagicLampWnd";
		WndList[WndList.Length] = "QuestWnd";
		WndList[WndList.Length] = "QuestAcceptableListWnd";
	}
	//WndList[79]="ShortcutAssignWnd"; //옵션과 통합 2012.3.27
	
	for (i=0;i<WndList.Length; ++i)
	{			
		handle = GetWindowHandle(WndList[i]);
		if (WndList[i] == "");
		if(handle.IsShowWindow())
        {
			if(handle.GetWindowName() == "RefineryWnd")
			{
				RefineryWnd(GetScript("RefineryWnd")).OnClickButton("exitbutton");
				// [Explicit Continue]
				continue;
			}
			handle.HideWindow();
        }
	}
	
	//2012.12.17 Gfx 창 목록 추가 
	GFxWndList[GFxWndList.Length] = "ClanSearch";
	GFxWndList[GFxWndList.Length] = "InstancedZoneHistoryWnd";
	GFxWndList[GFxWndList.Length] = "OptionWnd";
	GFxWndList[GFxWndList.Length] = "CardExchange";
	GFxWndList[GFxWndList.Length] = "CardExchangeB";
	GFxWndList[GFxWndList.Length] = "CardExchangeC";
	GFxWndList[GFxWndList.Length] = "AdenaDistributionWnd";
	GFxWndList[GFxWndList.Length] = "AlchemyMixCubeWnd";
	GFxWndList[GFxWndList.Length] = "AlchemyOpener";
	GFxWndList[GFxWndList.Length] = "AlchemyItemConversionWnd";
	GFxWndList[GFxWndList.Length] = "FactionWnd";
	GFxWndList[GFxWndList.Length] = "VipInfoWnd";
	GFxWndList[GFxWndList.Length] = "IngameShopWnd";
	GFxWndList[GFxWndList.Length] = "LuckyGame";
	GFxWndList[GFxWndList.Length] = "MonsterBookWnd";
	GFxWndList[GFxWndList.Length] = "MiniMapGFxWnd";
	GFxWndList[GFxWndList.Length] = "EventInfoWnd";
	GFxWndList[GFxWndList.Length] = "CardDrawEventWnd";
	GFxWndList[GFxWndList.Length] = "ArenaRankingWnd";
	GFxWndList[GFxWndList.Length] = "ClanRaidsWnd";
	GFxWndList[GFxWndList.Length] = "ClanGfxWnd";
	GFxWndList[GFxWndList.Length] = "ElementalSpiritWnd";
	GFxWndList[GFxWndList.Length] = "JobChangeWnd";
	GFxWndList[GFxWndList.Length] = "RankingHistoryWnd";
	GFxWndList[GFxWndList.Length] = "MiniMapGfxWnd";
	GFxWndList[GFxWndList.Length] = "ShopLcoinWnd";
	GFxWndList[GFxWndList.Length] = "ShopLcoinCraftWnd";

	for (i=0 ; i< GFxWndList.length ; i++)
	{
		if (class'UIAPI_WINDOW'.static.IsShowWindow (GFxWndList[i]))
		{
			if ( GFxWndList[i]  == "AdenaDistributionWnd")
			{
				//아데나 분배 창이 보여 지고 있을 때 alt + W로 취소 하게 되면, 
				CallGFxFunction("AdenaDistributionWnd", "RequestDivideAdenaCancel", "");
			}
			class'UIAPI_WINDOW'.static.HideWindow(GFxWndList[i]);
		}
	}
}

function HandleStateChange(String state)
{
	local FlightShipCtrlWnd scriptShip;
	local FlightTransformCtrlWnd scriptTrans;
	//local	MainMenu	                scriptMain;		

	scriptShip = FlightShipCtrlWnd(GetScript("FlightShipCtrlWnd"));
	scriptTrans = FlightTransformCtrlWnd(GetScript("FlightTransformCtrlWnd"));
	//scriptMain = MainMenu (GetScript("MainMenu"));
	
	if(state == "GAMINGSTATE")
	{	
		if(GetChatFilterBool("Global", "EnterChatting")) // GetOptionBool("Game", "EnterChatting"));
		{
			class'ShortcutAPI'.static.ActivateGroup("TempStateShortcut");
		}
		
		// 향상된 셰이더 로딩때문에 추가
		if(scriptShip.isNowActiveFlightShipShortcut) 	// 비행정 조종 모드라면		
		{
			if( GetChatFilterBool ("Global", "EnterChatting"))	{class'ShortcutAPI'.static.DeactivateGroup("TempStateShortcut");}
			class'ShortcutAPI'.static.ActivateGroup("FlightStateShortcut");
			//scriptMain.changeEnterChat("FlightStateShortcut");
		}
		else if (scriptTrans.isNowActiveFlightTransShortcut) // 비행 변신체 모드라면
		{
			
			if( GetChatFilterBool ("Global", "EnterChatting"))	{class'ShortcutAPI'.static.DeactivateGroup("TempStateShortcut");}
			class'ShortcutAPI'.static.ActivateGroup("FlightTransformShortcut");
			//scriptMain.changeEnterChat("FlightTransformShortcut");
		}		
	}
}
