class InventoryWnd extends UICommonAPI;

const DIALOG_USE_RECIPE				= 1111;				// ¡¤¢à?¬¤¬©¬©¬×| ¡í¬Ù?¬Ý¬©¬´ ¡Æ¬¯¬¡¬°¬¢¬è¬×| ¢à¡Æ¬¡¡í ¢Ò¡×
const DIALOG_POPUP					= 2222;				// ?¬¨¬¡¬®¬¦¬½¡í¬Ù?¬Ý ?¬¤ ¬¢¬è¬¢¢´¥ì¬ª ¬¨¬­?¬é¬×¬À?¬¤¬¢¬è¬×| ¢Ò¬Ù?¬á ¢Ò¡×
const DIALOG_DROPITEM				= 3333;				// ?¬¨¬¡¬®¬¦¬½¬¡¡í ¢à¬»?¬¼?? ¢à¬è¬×¡¾ ¢Ò¡×(¬©¬³¡Æ?)
const DIALOG_DROPITEM_ASKCOUNT		= 4444;				// ?¬¨¬¡¬®¬¦¬½¬¡¡í ¢à¬»?¬¼?? ¢à¬è¬×¡¾ ¢Ò¡×(?¨Ï¡¤?¡Æ?, ¡Æ??¬è¬×| ¢à¡Æ?¬à?¡í?¬»)
const DIALOG_DROPITEM_ALL			= 5555;				// ?¬¨¬¡¬®¬¦¬½¬¡¡í ¢à¬»?¬¼?? ¢à¬è¬×¡¾ ¢Ò¡×(MoveAll ¡í¬å¬¦¬£¬¡¬± ¢Ò¡×)
const DIALOG_DESTROYITEM			= 6666;				// ?¬¨¬¡¬®¬¦¬½¬¡¡í ¬ª¬À¬¢¬è¬¦¬Ý?? ¢à¬è¬×¡¾ ¢Ò¡×(¬©¬³¡Æ?)
const DIALOG_DESTROYITEM_ALL		= 7777;				// ?¬¨¬¡¬®¬¦¬½¬¡¡í ¬ª¬À¬¢¬è¬¦¬Ý?? ¢à¬è¬×¡¾ ¢Ò¡×(MoveAll ¡í¬å¬¦¬£¬¡¬± ¢Ò¡×)
const DIALOG_DESTROYITEM_ASKCOUNT	= 8888;				// ?¬¨¬¡¬®¬¦¬½¬¡¡í ¬ª¬À¬¢¬è¬¦¬Ý?? ¢à¬è¬×¡¾ ¢Ò¡×(?¨Ï¡¤?¡Æ?, ¡Æ??¬è¬×| ¢à¡Æ?¬à?¡í?¬»)
const DIALOG_CRYSTALLIZE			= 9999;				// ?¬¨¬¡¬®¬¦¬½¬¡¡í ¡Æ¬Ò¬¢¢´¬ª¡© ¬©¬´¢Ò¡×
const DIALOG_NOTCRYSTALLIZE		= 9998;				// ¡Æ¬Ò¬¢¢´¬ª¡©¡Æ? ?¬´¡Æ??¬«¬©¬±?¬»?¬£ ¡Æ¬Ø¡Æ¬ß
const DIALOG_DROPITEM_PETASKCOUNT	= 10000;			// ¬¨¬Ü¬¡¬°?????¡© ?¬¨¬¡¬®¬¦¬½¬¡¬® ¥ì¬Ö¡¤¬µ¥ì¬©?¬ì¬¡¡í ¢Ò¡×

const EQUIPITEM_Underwear = 0;
const EQUIPITEM_Head = 1;
const EQUIPITEM_Hair = 2;
const EQUIPITEM_Hair2 = 3;
const EQUIPITEM_Neck = 4;
const EQUIPITEM_RHand = 5;
const EQUIPITEM_Chest = 6;
const EQUIPITEM_LHand = 7;
const EQUIPITEM_REar = 8;
const EQUIPITEM_LEar = 9;
const EQUIPITEM_Gloves = 10;
const EQUIPITEM_Legs = 11;
const EQUIPITEM_Feet = 12;
const EQUIPITEM_RFinger = 13;
const EQUIPITEM_LFinger = 14;
const EQUIPITEM_LBracelet = 15;
const EQUIPITEM_RBracelet = 16;
const EQUIPITEM_Deco1 = 17;
const EQUIPITEM_Deco2 = 18;
const EQUIPITEM_Deco3 = 19;
const EQUIPITEM_Deco4 = 20;
const EQUIPITEM_Deco5 = 21;
const EQUIPITEM_Deco6 = 22;
const EQUIPITEM_Cloak = 23;
const EQUIPITEM_Waist = 24;

const EQUIPITEM_Brooch = 25;

const EQUIPITEM_Jewel1 = 26;
const EQUIPITEM_Jewel2 = 27;
const EQUIPITEM_Jewel3 = 28;
const EQUIPITEM_Jewel4 = 29;
const EQUIPITEM_Jewel5 = 30;
const EQUIPITEM_Jewel6 = 31;

// ?¬¨¡Æ??¬¤?¬£
const EQUIPITEM_AGATHION_MAIN = 32;
const EQUIPITEM_AGATHION_SUB1 = 33;
const EQUIPITEM_AGATHION_SUB2 = 34;
const EQUIPITEM_AGATHION_SUB3 = 35;
const EQUIPITEM_AGATHION_SUB4 = 36;
const EQUIPITEM_TOTAL_CLASSIC = 37;
const INVENTORY_ITEM_TAB = 0;
const INVENTORY_ITEM_1_TAB = 1;
const INVENTORY_ITEM_2_TAB = 2;
const INVENTORY_ITEM_3_TAB = 3;
const INVENTORY_ITEM_4_TAB = 4;
const QUEST_ITEM_TAB = 5;
const ICON_WIDTH = 36;
const INVENTORYWND_MIN_WIDTH = 556;
const ITEMWINDOW_MIN_WIDTH = 339;
const TAB_BG_MIN_WIDTH = 350;
const TAB_BG_LING_MIN_WIDTH = 10;
const TAB_LENGTH = 4;
const HENNA_INDEX = 99;
const Henna_CLASSIC_MAX = 4;
const TIMERID_bRequestedEnableList = 99;
const TIMER_bRequestedEnableList = 1000;
const TIMERID_bRequestedDualInventorySwap = 100;
const TIMER_bRequestedDualInventorySwap = 10000;

/**************************************** ¬¦¬© ?¬¨¬¡¬®¬¥¬¾¬¡¡í ¢à¬»?¬»¡¾¬Ó ¬¡¡×¬©¬³ preTabOrder **********************************************/
var bool bInitedCompleted;
var bool bRequestHennaOnShow;
var bool bRequestedEnableList;
var bool bRequestItemList;
var int preTabOrder;

/**************************************** ¡Æ?¬¢? ¬©¬¼¥ì¬Û ¥ì¬Û **********************************************/
var	ItemWindowHandle m_invenItem;
var	ItemWindowHandle m_questItem;
var	ItemWindowHandle m_equipItem[EQUIPITEM_TOTAL_CLASSIC];
var	TextBoxHandle		m_hAdenaTextBox;
var	TabHandle			m_invenTab;
var	ButtonHandle		m_sortBtn;
//var	ButtonHandle 		m_BtnRotateLeft;
//var	ButtonHandle		m_BtnRotateRight;

//var TextureHandle		m_CloakSlot_Disable;
var TextureHandle m_Talisman_Disable[6];

// ?¬×?¢ç ?¬ã¬ª¡Æ??¬ª¡© ¬¦¬º??¬¤¬¥ ¥ì¬Û
var TextureHandle m_Jewel_Disable[6];

var	ItemWindowHandle	m_invenItem_1;
var	ItemWindowHandle	m_invenItem_2;
var	ItemWindowHandle	m_invenItem_3;
var	ItemWindowHandle	m_invenItem_4;

//var	ItemWindowHandle	m_equipItem_Brooch;
//var TextureHandle       m_BroochEquiped;


// ¡Æ?¡¤¬°¡í¬Ù¬¡¬®¬¢¬à¬×|2¢à¬Ú¬¢¬ç¡Æ??¬¤¬¦¡Æ?¬£¢à¬è¬¨¡Æ
//var ButtonHandle m_BtnWindowExpand;

// 6, 12¬¢¬»¬£?¬×¢ç¬¡¬°??¬¦¬Õ¬×¢ç¢à¬Ú¡Æ¬Ø¬¦¬º??¬¤¬¥
//var TextureHandle m_InventoryItembg;
//var TextureHandle m_InventoryItembg_expand;

//var TextureHandle m_tabbg;
var TextureHandle m_tabbgLine;

var TextBoxHandle m_itemCount;


// ¬©¬è¬¡¬Ù¬¡¬°??¬¦¬Õ¬×¢ç?¬è
//var int currentInvenCol;

// ¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½ ?¬è 
var int pInventoryItemCount;


var	array<ItemID>		m_itemOrder;				// ¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½¬¡¬© ?¬ê?¡©¬×| ¡¤¬°¬¥¬¤?? ¬¡¬ì¬¡¬Ö¬©¬³?¬».
var	Vector				m_clickLocation;			// ?¬¨¬¡¬®¬¦¬½ ¥ì¬Ö¡¤¬µ¬©¬´¢Ò¡× ?¬à¥ì¬â?? ¥ì¬Ö¡¤¬µ¬©¬´ ¬¢¬è¬×| ¬¡¬ì¬¡¬Ö¬©¬±¡Æ¬ß ¬¡¬¸?¬£?¬».

var Array<ItemInfo>		m_EarItemList;
var Array<ItemInfo>		m_FingerItemLIst;
var Array<ItemInfo>		m_DecoItemList;

var int m_NormalInvenCount;	// Added by JoeyPark 2010/09/10 ¬©¬è¬¡¬Ù ¡Æ?¬¢¬è¡Æ¬ß ¬¡¬¸?¬£ ¬¡¬±¢à¬¿¬¦¬½¬¡¬© ¡Æ¢à?¬è.
var int m_QuestInvenCount;	// Added by JoeyPark 2010/09/10 ¬©¬è¬¡¬Ù ¡Æ?¬¢¬è¡Æ¬ß ¬¡¬¸?¬£ ¬¥¬ë??¬¨¢ç¬¦¬½¬¡¬© ¡Æ¢à?¬è.
var bool m_bCurrentState;
var int m_MaxInvenCount;
var int m_MaxQuestItemInvenCount;
var ButtonHandle CollectionBtn;
var AnimTextureHandle CollectionPointAni;
var ButtonHandle ItemAutoPeelBtn;
//var int m_ExtraInvenCount;
// var int m_MeshType;
//var int m_NpcID;

var ButtonHandle		m_hBtnCrystallize;

var WindowHandle        ColorNickNameWnd;

var int                 m_selectedItemTab;

var ButtonHandle        AdenacalculateButton;

//?¬×?¢ç ¬©¬·?? ?¡©¡¾¬Ó ¢à¬è¬¨¡Æ
var ButtonHandle        EnchantJewelButton;
//?¬×?¢ç¬©¬¶ ?¡©¡¾¬Ó ¢à¬è¬¨¡Æ
//var ButtonHandle        JewelButton;

//?¡þ¡¾¬¿?¬ì ¬¤? ?¡©¡¾¬Ó ¢à¬è¬¨¡Æ
var ButtonHandle        AlchemyOpenerBtn;

var bool m_bFirstOpened;

//¬×¬µ¬×¢ç?¬×¡¾¬Ó
var ButtonHandle        ViewHairButton;
//¬©¬Þ?¬à?¬©???¡©¬×¢ç?¬×¡¾¬Ó
var ButtonHandle        ViewAccessoryButton;
//?¬×?¢ç ¬¡¨Ï¥ì¥ì?¬Þ
var WindowHandle JewelWindow;
//?¡þ¡¾¬¿?¬ì ?¬¡¬©¬¢?¬¬
var WindowHandle		AlchemyOpenerWindow;

var ButtonHandle        AlchemyMixCubeWndBtn;
var ButtonHandle        AlchemyItemConversionWndBtn;
var ButtonHandle        AlchemyItemCreateWndBtn;

//?¬Õ¬¨?˜?¬¡¬± ¡Æ¬Ø?¬Þ ¬¡¬°??¬¦¬Õ¬×¢ç¡Æ? ?¡©¬×¢ç¬¢¬è ?¬¬¥ì¥ì¡¤¬± 
var string              cur_state;

var int                 mainClass ;

var bool                bIsPremiumHennaSlot; //branch GD35_0828 2014-2-10 luciper3 - ¬¡?¡¤¬Ò¢à¢ç?¬¦ ¡í¬Ù?¬Ý?¨Ï?¬°

var QuitReportWnd       QuitReportWndScript;

var string              m_EquipWindowName;
var WindowHandle        m_EquipWindow;

/**************************************** ?¬¨¡¾¬Ó?¬¤?¬£ ?¬¨¬¨¢ç ?¬´?? **********************************************/
// ?¬¨¡Æ??¬¤?¬£ ¢à¬è¬¨¡Æ
var WindowHandle        AgathionWindow;

// ?¬¨¡Æ??¬¤?¬£ ?¡©¡Æ¬ß ?¬¿¡¾¬Ó ¢à¬è¬¨¡Æ
var ButtonHandle        AgathionBtn;

// ?¬¨¡Æ??¬¤?¬£ ?¬ã¬ª¡Æ??¬ª¡© ¬¦¬º??¬¤¬¥ ¥ì¬Û(main ¬¨¬é¬©¬¶)
var TextureHandle		m_Agathion_Disable[ 5 ];

var ButtonHandle invenExpandSkillBtn;

var L2Util l2utilScript;

// ?¬¨¬¡¬®¬¦¬½ ???¬´ ?¬¤ clear ¬¡¬î?? itemSwaped ¬¡¬® true¬×¬Û ¬¡¬ì¬¡¬Ö tt 61481
var bool bIsSavedLocalItemIdx ;
var array<int> itemSwapedServerID;
var array<int> itemSwapedServerID_1;
var array<int> itemSwapedServerID_2;
var array<int> itemSwapedServerID_3;
var array<int> itemSwapedServerID_4;
var array<int> itemSwapedServerID_q;
var array<int> itemSwapedServerID_a;
var array<int> itemSwapedIdx;
var array<int> itemSwapedIdx_1;
var array<int> itemSwapedIdx_2;
var array<int> itemSwapedIdx_3;
var array<int> itemSwapedIdx_4;
var array<int> itemSwapedIdx_q;
var array<int> itemSwapedIdx_a;

// ?¬¨¬¡¬®¬¦¬½ ¬×¢ç??¬¨¢ç ?¬±¡¤¬Ò¡Æ? ¥ì¬°¢à¬ê ¥ì¬Û?¬à ?¬¡¬×¬Ù, 
// ¬¤¢à¢à¬ê ¬£¡Æ?¬£ ¬¡¬±¢à¬¿ ?¬¨¬¡¬®¬¦¬½
// ¥ì¬°¢à¬ê ¬£¡Æ?¬£ ¬¥¬ë??¬¨¢ç ?¬¨¬¡¬®¬¦¬½¬¡¬® ¥ì¬Û?¬à ?¬£?¬».
var bool bIsQuestItemList;

// 2018 4?¬ë ¬¡¬®¬ª¬¥ ¬¡¬½?¬é
/**************************************** ?¬¨¬¡¬®¬¦¬½ new ¬©?¡¾¬Ó **********************************************/
var array<ItemInfo> newItems;


/**************************************** ¬ª¢ç¬¡¬Ö ¬¡¬Ö¬£¬ê ¡¾¬×¡Æ? ************************************************/
// ?¡¾¬¦¬¤ ID
var int m_SelectedExpandEquipIdx ;
// ¬¡¬®¬¡¬î?? ?¡¾¬¦¬¤ ¬©¬Á?¬ê ID(?¬¨¬¨?¬¨¬³¬¨¢ç ¡í¬å¬¦¬£¬×| ?¬¿¬¡¡í ¢Ò¡× ¬©¬¬?¬Õ)
var int m_SelectedExpandEquipIdxPrev;

// ?¡¾¬¦¬¤ ¬¦¬º??¬¤¬¥
var TextureHandle m_TalismanAllow;
var ButtonHandle EquipItem_Brooch_Button;
var ButtonHandle EquipItem_RBracelet_Button;
var ButtonHandle EquipItem_LBracelet_Button;

/**************************************** ¬¥?¬×?¬¦¬¯ ?¬Õ  **********************************************/
var WindowHandle        m_InventoryWndCharacterView;
var buttonHandle        m_CharacterViewOpen_BTN;
var buttonHandle        m_CharacterViewClose_BTN;


/**************************************** ?¬¨¬¨?¬¨¬³¬¨¢ç  **********************************************/
// ¬¡¬®¬¨¬³¬¨¢ç ??¬¨¬ë ?¨Ï?¬°
//var bool bSpawnedStoneEffect ;
// ¬©¬Þ?¬à ?¬©???¡©¬×¢ç ?¬×?¨Ï ¬¢¬ì¬¢¬è ¬×¡í¬¢¬è ¡Æ?.
var int bShowhairAccessory ;

var TextureHandle EquipSlotBg_Sigil;
var ItemInfo lasetSelectedItemInfo;
var TextureHandle Hair2SlotDisable_tex;
var WindowHandle equipItem_Henna_Window;
var ButtonHandle equipItem_Henna_Button;
var TextureHandle hennas_Disable4;
var ItemWindowHandle hennaItems[4];
var UIControlGroupButtonAssets SubGroupButtonAsset;
var bool bUnStableSwapping;
var bool bRequestedDualInventorySwap;

/*********************************************************************************************
 * On
 * *******************************************************************************************/
event OnRegisterEvent()
{
	RegisterEvent(EV_InventoryClear); // 2570
	RegisterEvent(EV_InventoryOpenWindow); // 2580
	RegisterEvent(EV_InventoryHideWindow); // 2590
	RegisterEvent(EV_InventoryAddItem); // 2600
	RegisterEvent(EV_InventoryUpdateItem); // 2610
	RegisterEvent(EV_InventoryItemListEnd); // 2620
	RegisterEvent(EV_InventoryAddHennaInfo); // 2630
	RegisterEvent(EV_InventoryToggleWindow);
	RegisterEvent(EV_UpdateUserInfo);
	RegisterEvent(EV_UpdateUserEquipSlotInfo);
	RegisterEvent(EV_Restart);
	RegisterEvent(EV_SetMaxCount);
	//RegisterEvent(EV_ChangeCharacterPawn);
	RegisterEvent(EV_HairAccessoryPriority);
	RegisterEvent(EV_StateChanged);
	RegisterEvent(EV_AlchemySkillListForXML);
	RegisterEvent(EV_ChangedSubjob);
	RegisterEvent(EV_NotifySubjob);
	RegisterEvent(EV_NeedResetUIData);
	// effect test?¬Ý 
	// RegisterEvent(EV_Test_3);
	RegisterEvent(EV_EquipItemTooltipClear);
	RegisterEvent(EV_Hair2SlotEnable);
	RegisterEvent(EV_DualInventoryInfo);
	RegisterEvent(EV_RequestDualInventorySwap);	
}

event OnLoad()
{
	l2utilScript = L2Util(GetScript("L2Util"));
	SetClosingOnESC();

	InitHandleCOD();

	// * ?¡©¢à¬è ¡¾?¬¤? ?¬¤ xml ¬¡¡í ?¬»?¬¤ ¡¤¬°¥ì¬à ¬©¬·?¬±?¬».
	// onLoad ?¬¤ ¬¦¡þ¡¤??¬¥ ¢Ò¬å¬¡¬®?¬Ü ?¡©¢à¬è?? ¬×¬£¬¤¬Ù ¬¡¨Ï¥ì¥ì?¬Þ¬¡¬© ¬©¬¼¥ì¬Û¬¡¡í ¡Æ??¬¨ ???¬ä.
	SetEquipWindowHandle();

	SetHennaWindows();

	//¡¾¬Ó?¡í ¬¡¨Ï¥ì¥ì?¬Þ ¬©¬¼¥ì¬Û ??¬¢¢´
	SetHandles();
	InitScrollBar();
	
	m_bCurrentState = false;
	m_selectedItemTab = INVENTORY_ITEM_TAB;

	//currentInvenCol = GetOptionInt("Game", "ItemInventoryCol");
	//debug("option " @ currentInvenCol);

	// ?¬¨¬¡¬®¬¦¬½¬¥¡© ¡Æ?¡¤¬° 6~12, option.ini ¬¡¬ì¬¡¬Ö ¡Æ? : ¬¤¬¸¬¤¬¬¡¤¬° ?¬©¬©¬Ñ ¥ì¬©?¬ì¡Æ¬¦?? ¬¢¢Ò¬¡¬½ ¥ì¬©?¬ì?¬»¬×¬Û ¢à¡ì¬¢¢Ò¡Æ¬© 6¬¡¬×¡¤¬° ??¬¨¬¤
	//if(currentInvenCol != 9 && currentInvenCol != 12)currentInvenCol = 9;

	//m_bFirstOpened = false;

//	m_BroochEquiped.hideWindow();	
	QuitReportWndScript = QuitReportWnd(GetScript("QuitReportWnd"));
	// -1¬¡? ¬¤?¬¡¡í ¬¡¬Ö¬£¬ê ¬©¬±¬¢¬è ?¬¬¬¡?.(¬¡¬®¬¨¬³¬¨¢ç ?¬ê¬¡?)
	//m_Artifact_Stone.HideWindow();
	InitTabIcon();
	InitHennaGrouBtns();
	InitSwapGroupButton();
	InitDualToDefaultA();
	invenExpandSkillBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".InvenExpandSkillButton");
	//end of branch
}

private function InitSwapGroupButton()
{
	SubGroupButtonAsset = class'UIControlGroupButtonAssets'.static._InitScript(GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".SubUIControlGroupButtonAsset"));
	SubGroupButtonAsset._SetStartInfo("L2UI_ct1.RankingWnd.RankingWnd_SubTabButton", "L2UI_NewTex.Button.SubTabButton_Selected", "L2UI_ct1.RankingWnd.RankingWnd_SubTabButton_Over", true);
	SubGroupButtonAsset._GetGroupButtonsInstance().DelegateOnClickButton = DelegateOnClickButton;
	SubGroupButtonAsset._GetGroupButtonsInstance()._setButtonText(0, GetSystemString(14274));
	SubGroupButtonAsset._GetGroupButtonsInstance()._setButtonText(1, GetSystemString(14275));
	SubGroupButtonAsset._GetGroupButtonsInstance()._setShowButtonNum(2);
	SubGroupButtonAsset._GetGroupButtonsInstance()._fixedWidth(100, 5);
	SubGroupButtonAsset._GetGroupButtonsInstance()._setTopOrder(0, true);	
}

function InitHennaGrouBtns()
{
	local UIControlGroupButtonHighlighting scr;

	scr = class'UIControlGroupButtonHighlighting'.static.InitScript(equipItem_Henna_Window);
	scr._SetBtnTexture("L2UI_CT1.InventoryWnd.Talisman_HennaBTN_Normal", "L2UI_CT1.InventoryWnd.Talisman_HennaBTN_Over", "L2UI_CT1.InventoryWnd.Talisman_HennaBTN_Normal");
	scr.DelegateOnButtonClick = HandleDelegateOnClickBUtton;
	scr.DelegateOnLButtonUp = HandleDelegateOnLButtonUp;
}

function UpdateInvenExpandSkillBtn()
{
	local bool IsCanLevelUpInvenExpandSkill;

	if(m_selectedItemTab == 5)
	{
		invenExpandSkillBtn.HideWindow();
		return;
	}
	if(m_hOwnerWnd.IsShowWindow())
	{
		IsCanLevelUpInvenExpandSkill = class'SkillWnd'.static.Inst().IsCanLevelUpInvenExpandSkill();
		if(IsCanLevelUpInvenExpandSkill)
		{
			invenExpandSkillBtn.ShowWindow();			
		}
		else
		{
			invenExpandSkillBtn.HideWindow();
		}
	}	
}

event OnTimer(int TimerID)
{
	switch(TimerID)
	{
		case TIMERID_bRequestedEnableList:
			bRequestedEnableList = false;
			m_hOwnerWnd.KillTimer(TIMERID_bRequestedEnableList);
			break;
		case TIMERID_bRequestedDualInventorySwap:
			m_hOwnerWnd.KillTimer(TIMERID_bRequestedDualInventorySwap);
			bRequestedDualInventorySwap = false;
			break;
	}
}

event OnEvent(int Event_ID, string param)
{
	local ELanguageType Language;

	// Debug("OnEvent " @ Event_ID);
	switch(Event_ID)
	{
		case EV_InventoryAddItem: //2600
			HandleAddItem(param);
			break;
		case EV_InventoryClear: //2570
			HandleClear();
			break;
		case EV_InventoryOpenWindow: //2580
			HandleOpenWindow(param);
			break;
		case EV_InventoryHideWindow: //2590
			HandleHideWindow();
			break;  
		case EV_InventoryUpdateItem:            //2610		
			// ¬©¬º?¬¾, ?¬¨¡¤¢à?? ?¡©¢à¬è???¡©¬×¬× ?¬×?¨Ï¬¢¬è¥ì¥ì¡¤¬±
			if(Language != LANG_Korean)
			{
				showItemUpdateEffect(param);
			}		
			HandleUpdateItem(param);
			break;
		// ¬¡¬±¢à¬¿ ?¬¨¬¡¬®¬¦¬½ ¥ì¬Û?¬à?¬¡¡Æ¬ß, ?¬±¡¤¬Ò ¬¡¬®??¬¨¢ç
		// ¬¥¬ë??¬¨¢ç ?¬¨¬¡¬®¬¦¬½ ¥ì¬Û?¬à?¬¡¡Æ¬ß, ?¬±¡¤¬Ò ¬¡¬®??¬¨¢ç
		case EV_InventoryItemListEnd: //2620		
			HandleItemListEnd();
			break;
		case EV_InventoryToggleWindow:          //2631
			HandleToggleWindow();
			break;
		case EV_UpdateUserInfo:                 //180
			HandleUpdateUserInfo();
			break;
		case EV_UpdateUserEquipSlotInfo:        //181
			HandleUpdateUserEquipSlotInfo();
			break;
		case EV_Restart:                        //40  
			HandleRestart();
			//~ SaveInventoryOrder();
			break;
		case EV_SetMaxCount:                    //2070
			HandleSetMaxCount(param);
			break;
		//case EV_ChangeCharacterPawn:          //3810
		//	HandleChangeCharacterPawn(param);
		//	break;
		case EV_HairAccessoryPriority:          //9439
			ReceiveHairAccessoryPriority(param);
			break;
		case EV_StateChanged :	
			cur_state = param;			
			break;				
		case EV_ChangedSubjob:
			handleChangedSubjob(param);
		case EV_NotifySubjob:
			handleNotifySubjob(param);
			break;
		case EV_NeedResetUIData:
			checkClassicForm();
			break;
		case EV_EquipItemTooltipClear:
			clearEquipItemTooltip();
			break;
		case EV_Hair2SlotEnable:
			HandleHair2SlotEnable(param);
			break;
		case EV_DualInventoryInfo:
			Handle_EV_DualInventoryInfo(param);
			break;
		case EV_RequestDualInventorySwap:
			Handle_EV_RequestDualInventorySwap();
			break;
		//case EV_Test_3  :	
		//	tmpTest03(param);
		default:
			break;
	};
}

function clearEquipItemTooltip()
{
	local int i;

	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; i++)
		m_equipItem[i].ClearItemTooltip();
}

//function tmpTest03(string param)
//{
//	local string stoneEffect;
//	local int dist, x, y  ;

//	parseString(param, "effect",  stoneEffect);
//	parseInt(param, "dist",  dist);
//	parseInt(param, "x",  x);
//	parseInt(param, "y",  y);	
//	SetArtifactBookEffect(stoneEffect, dist, x, y);
//}

event OnShow()
{
	if(CollectionSystem(GetScript("CollectionSystem"))._IsCollectionOpen())
	{
		m_hOwnerWnd.HideWindow();
		return;
	}
	if(IsShowWindow("PostWriteWnd"))
	{
		HideWindow("InventoryWnd");
	}
	else
	{
		getInstanceL2Util().ItemRelationWindowHide(getCurrentWindowName(string(self)), "AttributeEnchantWnd,AttributeRemoveWnd,UnrefineryWnd,CrystallizationWnd,ItemAttributeChangeWnd,ProgressBox,AlchemyMixCubeWnd");
	}

	CheckShowCrystallizeButton();
	SetAdenaText();
	SetItemCount();

	// ¬ª¢ç¬¡¬Ö ?¨Ï?¬° 9 <-> 12 
	//if(currentInvenCol == 9)
	//	m_InventoryItembg_expand.HideWindow();	
	//else if(currentInvenCol == 12)		
	//	extendInventory(true);

	SetAhclemyOpener();
	ShowHideCharacterViewPortOnShow();
	SwitchEquipBox(m_SelectedExpandEquipIdx);
	handleNewItemOnShow();
	CollectionPointAni.Stop();
	CollectionPointAni.Pause();
	CollectionPointAni.HideWindow();
	if(! bInitedCompleted)
	{
		HennaMenuWnd(GetScript("HennaMenuWnd")).API_C_EX_NEW_HENNA_LIST();
		bInitedCompleted = true;
		bRequestItemList = false;		
	}
	else
	{
		if(bRequestHennaOnShow)
		{
			HennaMenuWnd(GetScript("HennaMenuWnd")).API_C_EX_NEW_HENNA_LIST();
			bRequestHennaOnShow = false;
		}
		API_C_EX_ITEM_USABLE_LIST();
	}
}

event OnHide()
{
	handleNewItemOnHide();
	m_invenTab.SetButtonBlink(6, false);
	if(m_bCurrentState)
	{
		SaveInventoryOrder();
	}
	if(DialogIsMine())
	{
		DialogHide();
	}
	if(class'UIControlContextMenu'.static.GetInstance().IsMine(string(self)))
	{
		class'UIControlContextMenu'.static.GetInstance().Hide();
	}
}

event OnEnterState(name a_CurrentStateName)
{
	m_bCurrentState = true;
}

event OnExitState(name a_CurrentStateName)
{
	m_bCurrentState = false;
}

// ItemWindow Event
event OnDBClickItemWithHandle(ItemWindowHandle a_hItemWindow, int index)
{
	UseItem(a_hItemWindow, index);
}

event OnRClickItemWithHandle(ItemWindowHandle a_hItemWindow, int index)
{
	local ItemInfo info;
	a_hItemWindow.GetItem(index, info);

	if(IsKeyDown(IK_Ctrl))
	{
		CheckNOpenItemAutoPeel(Info.Id.ServerID, Info.Id.ClassID, IsKeyDown(IK_Alt));
		return;
	}
	delNewItem(info);
	UseItem(a_hItemWindow, index);
}

event OnSelectItemWithHandle(ItemWindowHandle a_hItemWindow, int a_Index)
{
	local int i;
	local ItemInfo info;
	local string ItemName;

	// Debug("OnSelectItemWithHandle" @ a_hItemWindow @ a_Index);

	a_hItemWindow.GetSelectedItem(info);

	//TextLink
	if(IsKeyDown(IK_Shift))
	{
		ItemName = GetItemNameAll(Info);
		SetItemTextLink(info.ID, ItemName);
	}
	
	//delNewItemByIndex(a_Index);	
	switch(a_hItemWindow)
	{
		case m_invenItem:
		case m_invenItem_1:
		case m_invenItem_2:
		case m_invenItem_3:
		case m_invenItem_4:
		case m_questItem:
			delNewItem(info);
			CheckCollectionEnableItem(Info);
			return;
		// ¬¦¬©
		case m_equipItem[ EQUIPITEM_RBracelet ] :
			switchEquipBox(EQUIPITEM_RBracelet); break;
		case m_equipItem[ EQUIPITEM_LBracelet ] :
			switchEquipBox(EQUIPITEM_LBracelet); break;
		case m_equipItem[ EQUIPITEM_Brooch ] :
			switchEquipBox(EQUIPITEM_Brooch); break;	
	}	

	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; ++i)
	{
		if(a_hItemWindow != m_equipItem[ i ])
			m_equipItem[ i ].ClearSelect();	
	}

	//if( a_hItemWindow != m_equipItem_Brooch)
	//	m_equipItem_Brooch.ClearSelect();	
}

event OnDropItem(String strTarget, ItemInfo info, int x, int y)
{
	local int toIndex, fromIndex;
	local CrystallizationWnd CrystallizationWndScript;		
	local ItemWindowHandle normalinven;

	// ¡Æ¬Ò¬¢¢´¬ª¡© ?¡þ¥ì?
	CrystallizationWndScript = CrystallizationWnd(GetScript("CrystallizationWnd"));
	

	// ¬¡¬°??¬¦¬Õ¬×¢ç???¡© ?¬£ ¡Æ¬¯¬¡¬® ?¬¨?¬±¬×¬Û ¬¤?¬×¢ç¬©¬±¬¢¬è ?¬¬?¬£?¬».
	if(! isDragSrcInventory(info.DragSrcName))return ;	
	
	if(strTarget == "InventoryItem" || strTarget == "InventoryItem_1" || strTarget == "InventoryItem_2" || strTarget == "InventoryItem_3" || strTarget == "InventoryItem_4")
	{
		//Debug("OnDropItem" @ strTarget @  info.DragSrcName);
		if(info.DragSrcName == strTarget)			// Change Item position
		{
			normalinven = getItemWindowHandleBystrTarget(strTarget);

			toIndex = normalinven.GetIndexAt(x, y, 1, 1);
			
			// Exchange with another item
			
			if(toIndex >= 0)
			{
				fromIndex = normalinven.FindItem(info.ID);
				if(toIndex != fromIndex)
					normalinven.SwapItems(fromIndex, toIndex);
			}
		}
		else if((-1 != InStr(Info.DragSrcName,"EquipItem"))&&(Left(Info.DragSrcName,12)!= "PetEquipItem"))		// Unequip thie item
		{
			//Debug("drpItem" @ info.Name @ info.DragSrcName @ info.ID.classID @ info.SlotBitType);
			handleRequestUnequipItem(info.DragSrcName, info.ID, info.SlotBitType);			
		}
		else if(Left(Info.DragSrcName,12)== "PetEquipItem")		// Pet -> Inventory
		{
			PetWndClassic(GetScript("PetWndClassic")).API_C_EX_PET_UNEQUIP_ITEM(Info.Id.ServerID);
		}
		else if(Info.DragSrcName == "PetInvenWnd")
		{
			if(IsStackableItem(info.ConsumeType)&& info.ItemNum > 1)			// Multiple item?
			{
				if(info.AllItemCount > 0)					// ¬¡¬î?¬° ?¬¦¡¾¬Ø ¡Æ¬¯¬¡¬°¡Æ?
				{
					if(CheckItemLimit(info.ID, info.AllItemCount))
					{
						class'PetAPI'.static.RequestGetItemFromPet(info.ID, info.AllItemCount, false);
					}
				}
				else
				{
					DialogSetID(DIALOG_DROPITEM_PETASKCOUNT);
					DialogSetReservedItemID(info.ID);	// ServerID
					DialogSetParamInt64(info.ItemNum);
					DialogShow(DialogModalType_Modalless, DialogType_NumberPad, MakeFullSystemMsg(GetSystemMessage(72), info.Name), string(Self));
					class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
				}
			}
			else																// Single item?
			{
				//Debug("RequestGetItemFromPet" @ info.Name);
				class'PetAPI'.static.RequestGetItemFromPet(info.ID, 1, false);
			}
		}
	}
	else if(strTarget == "QuestItem")
	{
		if(info.DragSrcName == "QuestItem")			// Change Item position
		{

			toIndex = m_questItem.GetIndexAt(x, y, 1, 1);
			
			if(toIndex >= 0)
			{
				fromIndex = m_questItem.FindItem(info.ID);
				if(toIndex != fromIndex)
					m_questItem.SwapItems(fromIndex, toIndex);
			}
		}
	}
	/* ?¬¨¡Æ??¬¤?¬£ ?¡©?¬Ü?¬¯ ¬×¬À¬¡¬°¬¡¡í ¡¾?¬¤? "EquipItem" ¬¡¬®¬¡¬î?? ¬¤?¬¦¨Ï ¬©¬±¥ì¥ì¡¤¬± ¬©¬±¬¡¬¼. */
	// ?¬¨¡Æ??¬¤?¬£ ¬×¬À¬¡¬°???¡© ?¡©?¬Ü¡¤¬° ¡¾?¬¤?
	//else if((-1 != InStr(info.DragSrcName, "AgathionMain"))&&(-1 != InStr(strTarget, "AgathionSub")))
	//{
	//	handleSwapAgathionSubMain(strTarget);	
	//}
	//// ?¬¨¡Æ??¬¤?¬£ ?¡©?¬Ü???¡© ¬×¬À¬¡¬°¬¡¬×¡¤¬° ¡¾?¬¤?
	//else if((-1 != InStr(info.DragSrcName, "AgathionSub"))&&(-1 != InStr(strTarget, "AgathionMain")))
	//{		
	//	handleSwapAgathionSubMain(info.DragSrcName);		
	//}
	//~ SaveInventoryOrder();
	else if(-1 != InStr(strTarget, "EquipItem")||  strTarget == "ObjectViewportDispatchMsg")		// Equip the item
	{
		//debug("Inven EquipItem: " $info.DragSrcName $" " $string(info.ItemType));
		if(info.DragSrcName == "PetInvenWnd")				// Pet -> Equip
		{
			class'PetAPI'.static.RequestGetItemFromPet(info.ID, 1, true);
		}
		else if(-1 != InStr(info.DragSrcName, "EquipItem"))	//?¬¨¢à¡ì¡Æ¬¯¥ì¥ì ¬©¬±¬¢¬è ?¬¬?¬£?¬». 
		{
		}
		else if(EItemType(info.ItemType)!= ITEM_ETCITEM)
		{	
			RequestUseItem(info.ID);
		}
	}
	else if(strTarget == "TrashButton")					// Destroy item(after confirmation)
	{
		//¬¢¢´?¬Þ¡¾¬· ¬¤¬Á¡Æ? 2013.2.6 ?¬µ??¡Æ¡©¬ª¡©¬¤? ?¡©¡¤¬¢¬¡¬¸¬¡¬×¬×¬Û ¢à¬è¬×¢ç¡¾¬Ó ?¬ª¥ì¬¬.
		if(IsShowWindow("AttributeEnchantWnd")== true)
		{
			AddSystemMessage(4148);
			return;
		}

		if(IsStackableItem(info.ConsumeType)&& info.ItemNum > 1)			// Multiple item?
		{
			if(info.AllItemCount > 0)				// ¬¡¬î?¬° ¢à¬è¬×¡¾ ¡Æ¬¯¬¡¬°¡Æ?
			{				
				DialogSetID(DIALOG_DESTROYITEM_ALL);
				DialogSetReservedItemID(info.ID);	// ServerID
				DialogSetReservedInt2(info.AllItemCount);
				DialogShow(DialogModalType_Modalless,DialogType_Warning, MakeFullSystemMsg(GetSystemMessage(74), info.Name, ""), string(Self));
				class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
			}
			else
			{
				DialogSetID(DIALOG_DESTROYITEM_ASKCOUNT);
				DialogSetReservedItemID(info.ID);	// ServerID
				DialogSetParamInt64(info.ItemNum);
				DialogShow(DialogModalType_Modalless, DialogType_NumberPad, MakeFullSystemMsg(GetSystemMessage(73), info.Name), string(Self));
				class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
			}
		}
		else																// Single item?
		{
			// ¬¨¬¥?¬Ó¬©¬±¡¤¬¢ ¬©¬´¢Ò¡×, ¡Æ¬Ò¬¢¢´¬ª¡©¡Æ? ¡Æ??¬«¬©¬³ ¡í¬å¬ª?¬¡¬®¬×¬Û ¡¾¬¹?¬« ¡Æ¬Ò¬¢¢´¬ª¡©
			if(class'UIDATA_PLAYER'.static.HasCrystallizeAbility()&& class'UIDATA_ITEM'.static.IsCrystallizable(info.ID))			
			{
				// DialogSetID(DIALOG_CRYSTALLIZE);
				// DialogSetReservedItemID(info.ID);
				// DialogShow(DialogModalType_Modalless,DialogType_Warning, MakeFullSystemMsg(GetSystemMessage(2232), info.Name), string(Self));
				CrystallizationWndScript.setItemInfo(info);
				RequestCrystallizeEstimate(info.ID, 1);
			}
			else
			{
				DialogSetID(DIALOG_DESTROYITEM);
				DialogSetReservedItemID(info.ID);	// ServerID
				DialogShow(DialogModalType_Modalless, DialogType_Warning, MakeFullSystemMsg(GetSystemMessage(74), info.Name), string(Self));
				class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
			}
		}
	}
	else if(strTarget == "CrystallizeButton")
	{
		//¬¢¢´?¬Þ¡¾¬· ¬¤¬Á¡Æ? 2013.2.6 ?¬µ??¡Æ¡©¬ª¡©¬¤? ?¡©¡¤¬¢¬¡¬¸¬¡¬×¬×¬Û ¡Æ¬Ò¬¢¢´¬ª¡© ?¬ª¥ì¬¬.
		if(IsShowWindow("AttributeEnchantWnd")== true)
		{
			AddSystemMessage(4148);
			return;
		}
		if(info.DragSrcName == "InventoryItem" || info.DragSrcName == "InventoryItem_1" || info.DragSrcName == "InventoryItem_2" || info.DragSrcName == "InventoryItem_3" || info.DragSrcName == "InventoryItem_4" ||(-1 != InStr(info.DragSrcName, "EquipItem")))
		{
			if(class'UIDATA_PLAYER'.static.HasCrystallizeAbility()&& class'UIDATA_ITEM'.static.IsCrystallizable(info.ID))			// Show Dialog asking confirmation
			{				
				CrystallizationWndScript.setItemInfo(info);
				RequestCrystallizeEstimate(info.ID, 1);

			}
			else
			{
				// ¡Æ¬Ò¬¢¢´¬ª¡© ¬¤?¬¡¬® ?¡©¡¤¬¢ ¬¡¬¸?¬£ ¡Æ¬Ø?¬Þ ?¬¿¡¾¬Ó
				CrystallizationWndScript.cancelCystallizeItem();
				// ¡Æ¬Ò¬¢¢´¬ª¡© ?¬´¡Æ??¬« ¬©¬±?¬»?¬£ ?¬­¢Ò¬é 
				AddSystemMessage(2171);
			}
		}
	}	

	else if(strTarget == "AdenacalculateButton")
	{		
		//¥ì¬Ö¢Ò¬ê¥ì¬ª ?¬¨¬¡¬®¬¦¬½¬¡¬® ¥ì¡¤¬¡¬± ¡Æ¬Ø?¬Þ ¬¤? ?¡©¡¾¬Ó ?¬¤¥ì¥ì
		
		if(IsAdena(info.ID)&& !class'UIAPI_WINDOW'.static.IsShowWindow("AdenaDistributionWnd"))
		{
			callGfxFunction("AdenaDistributionWnd", "RequestDivideAdenaStart","");
		} else 
		addSystemMessage(4158);

	}	
	
	else if(strTarget == "EnchantJewelButton")
	{
		handleJewelDropedOnButton(info);
	}
	else if(strTarget == "CollectionBtn")
	{
		CheckNOpenCollection(Info);
	}
	else if(strTarget == "ItemAutoPeelBtn")
	{
		CheckNOpenItemAutoPeel(Info.Id.ServerID, Info.Id.ClassID, IsKeyDown(IK_Alt));
	}
}

function CheckNOpenCollection(ItemInfo iInfo)
{
	if(iInfo.Id.ClassID < 1)
	{
		CollectionSystem(GetScript("collectionSystem")).API_C_EX_COLLECTION_OPEN_UI();
		return;
	}
	if(! isCollectionItem(iInfo))
	{
		getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(13411));
		return;
	}
	lasetSelectedItemInfo = iInfo;
	OpenCollectionSelectedItem();
}

function CheckNOpenItemAutoPeel(int itemServerID, int ItemClassID, bool isAllItem)
{
	if(ItemClassID > 0)
	{
		if(class'UIDATA_ITEM'.static.IsDefaultActionPeel(ItemClassID) == false)
		{
			getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(1960));
			return;
		}
	}
	OpenItemAutoPeelWnd(itemServerID, isAllItem);
}

// 2018-07-10 ?¬¨¬¡¬®¬¦¬½ ¬¡¬°¬¤|¬¨¢ç ¬¤? ¬¨¬é¬¥??¬®, ¬¨¬ß¬¡¬© ¡¾¬Ó?¬«
function OnDragItemStartTiny(String strID, ItemInfo infItem)
{
	// Debug("OnDragItemStartTiny: " @ strID @ infItem.name);

	// ?¬¨¬¡¬®¬¦¬½ ¬¡¨Ï¥ì¥ì?¬Þ¬×| ¢à¬ë?¬à?? ¬¡¬°¬¤|¬¨¢ç ¬¡¨Ï¥ì¥ì?¬Þ¡Æ? ¢Ò¡Æ ¬¡¬¸?¬»¬×¬Û..
	// ¬¡¬î¬¤?, ¬¡¬Ö?¬ã ¬£¬¬
	if(strID == "InventoryItem" || strID == "InventoryItem_1")
	{		
		if(len(infItem.name)> 0 && GetWindowHandle("ItemEnchantWnd").IsShowWindow())
		{
			GetWindowHandle("ItemEnchantWnd").SetFocus();
		}
		if(len(infItem.Name)> 0 && GetWindowHandle("ItemLookChangeWnd").IsShowWindow())
		{
			GetWindowHandle("ItemLookChangeWnd").SetFocus();
		}
	}
}

// ¡Æ¡Æ¬¡? ?¬¨¬¡¬®¬¦¬½ ¬¤????¡© ?¬¨¬¡¬®¬¦¬½¬¡¡í ?¬¦¡¾¬Ó?¬£ ¡Æ¬¯¬¡? OnDropItem ???¡© ¬©¬º¡Æ¬Ò¬©¬±¥ì¥ì¡¤¬± ¬©¬±¡Æ¬ß ?¨Ï¡¾¬Ó?¡©?¬£ ¢à¬»?¬¼?? ¢à¬è¬×¢ç?¬£ ¡í¬å¬ª?¬×¬× ¬¤?¬×¢ç¬©¬³?¬».
event OnDropItemSource(string strTarget, ItemInfo info)
{
	if(strTarget != "Console")return; 
	if(!isDragSrcInventory(info.DragSrcName))return;
	
	// ¬¡¬°¬¤|¬¨¢ç ¬¤?¬¡¬® ?¡©¡¤¬¢ ¬¡¬¸?¬»¬×¬Û.. ?¬¨¬¡¬®¬¦¬½ ¢à¬»?¬¼?? ¢Ò??¬à¬¨¢ç¬×¢ç¡¾¬Ó¬×| ¬×¡¤?¬£?¬».
	if(IsShowWindow("ItemEnchantWnd")== false && IsShowWindow("AttributeEnchantWnd")== false )
	{
		m_clickLocation = GetClickLocation();
		if(IsStackableItem(info.ConsumeType)&& info.ItemNum > 1)		// ?¬è¡¤¢ç¬¡¬® ¬¡¬¸?¬£ ?¬¨¬¡¬®¬¦¬½
		{
			if(info.AllItemCount > 0)				// ¬¡¬î?¬° ¢à¬è¬×¡¾ ¡Æ¬¯¬¡¬°¡Æ?
			{
				DialogHide();
				DialogSetID(DIALOG_DROPITEM_ALL);
				DialogSetReservedItemID(info.ID);	// ServerID
				DialogSetReservedInt2(info.AllItemCount);
				DialogShow(DialogModalType_Modalless,DialogType_Warning, MakeFullSystemMsg(GetSystemMessage(1833), info.Name, ""), string(Self));
				class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
			}
			else												// ?¬ï¬¡¬¼¬×| ¢à¡Æ?¬à?? ¡Æ¬¯¬¡¬°¡Æ?
			{
				DialogHide();
				DialogSetID(DIALOG_DROPITEM_ASKCOUNT);
				DialogSetReservedItemID(info.ID);	// ServerID
				DialogSetParamInt64(info.ItemNum);
				DialogShow(DialogModalType_Modalless,DialogType_NumberPad, MakeFullSystemMsg(GetSystemMessage(71), info.Name, ""), string(Self));
				class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
			}
		}
		else
		{
			DialogHide();
			DialogSetID(DIALOG_DROPITEM);
			DialogSetReservedItemID(info.ID);	// ServerID
			DialogShow(DialogModalType_Modalless,DialogType_Warning, MakeFullSystemMsg(GetSystemMessage(400), info.Name, ""), string(Self));
			class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
		}
	}
	// "?¬µ?? ¡Æ¡©¬ª¡© ¬¢¬Á???¬£ ¢à¬è¬×¡¾ ?¬è ?¬ê...."
	else if(IsShowWindow("AttributeEnchantWnd")== true)
		AddSystemMessage(4147);
	// "¬¡¬°¬¤|¬¨¢ç ¬¤?¬¡¬® ?¡©¡¤¬¢ ¬¡¬¸?¬¡?¬±?¬». ?¬¨¬¡¬®¬¦¬½¬¡¡í ¢à¬è¬×¡¾ ?¬è ?¬ê?¬¡?¬±?¬».";
	else
		AddSystemMessage(3656);
}

event OnClickButton(string strID)
{
	Debug("OnClickButton" @ strID);
	switch(strID)
	{
		case "InvenExpandSkillButton":
			class'SkillWnd'.static.Inst().ShowAndInvenExpandSkillInfo();
			break;
		case "SortButton":
			switch(m_selectedItemTab)
			{
				case INVENTORY_ITEM_TAB:
					l2utilScript.SortItem(m_invenItem);	//¬¡¬°??¬¦¬Õ¬×¢ç ¬¢¢´¡¤¬¥
					SaveInventoryOrder();
					break;
				case INVENTORY_ITEM_1_TAB:
					l2utilScript.SortItem(m_invenItem_1);
					break;
				case INVENTORY_ITEM_2_TAB:
					l2utilScript.SortItem(m_invenItem_2);
					break;
				case INVENTORY_ITEM_3_TAB:
					l2utilScript.SortItem(m_invenItem_3);
					break;
				case INVENTORY_ITEM_4_TAB:
					l2utilScript.SortItem(m_invenItem_4);
					break;
				case QUEST_ITEM_TAB:
					SortQuestItem();
					break;
				default:
					l2utilScript.SortItem(m_invenItem);	//¬¡¬°??¬¦¬Õ¬×¢ç ¬¢¢´¡¤¬¥
					SaveInventoryOrder();
					break;
			}
			break;
		case "InventoryTab0":	//¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½ ¬¦¬¾ ¬¦¡þ¬×?			
			m_selectedItemTab = INVENTORY_ITEM_TAB;
			m_invenItem.SetScrollPosition(0);
			SetIconOnSelectTabOrder();
			SetItemCount();
			break;
		case "InventoryTab1":	//¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½ ¬¦¬¾ ¬¦¡þ¬×?			
			m_selectedItemTab = INVENTORY_ITEM_1_TAB;
			m_invenItem_1.SetScrollPosition(0);
			SetIconOnSelectTabOrder();
			SetItemCount();
			break;
		case "InventoryTab2":	//¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½ ¬¦¬¾ ¬¦¡þ¬×?			
			m_selectedItemTab = INVENTORY_ITEM_2_TAB;
			m_invenItem_2.SetScrollPosition(0);
			SetIconOnSelectTabOrder();
			SetItemCount();
			break;
		case "InventoryTab3":	//¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½ ¬¦¬¾ ¬¦¡þ¬×?			
			m_selectedItemTab = INVENTORY_ITEM_3_TAB;
			m_invenItem_3.SetScrollPosition(0);
			SetIconOnSelectTabOrder();
			SetItemCount();
			break;
		case "InventoryTab4":	//¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½ ¬¦¬¾ ¬¦¡þ¬×?			
			m_selectedItemTab = INVENTORY_ITEM_4_TAB;
			m_invenItem_4.SetScrollPosition(0);
			SetIconOnSelectTabOrder();
			SetItemCount();
			break;
		case "InventoryTab5":	//¬¥¬ë??¬¨¢ç ?¬¨¬¡¬®¬¦¬½ ¬¦¬¾ ¬¦¡þ¬×?			
			m_selectedItemTab = QUEST_ITEM_TAB;
			m_questItem.SetScrollPosition(0);
			SetIconOnSelectTabOrder();
			SetItemCount();
			break;
		//case "BtnWindowExpand" :  // ¬¡¬°??¬¦¬Õ¬×¢ç¡Æ?¡¤¬°¬ª¢ç¬¡¬Ö¢à¬è¬¨¡Æ
		//	extendInventory(currentInvenCol == 9);
		//	break;			
		case "AdenacalculateButton"://?¬¨¥ì??? ?¬²¢à¬Ú¡¾¬Ó ?¡©¡¾¬Ó ?¬Õ¬¤¡í
			if(! class'UIAPI_WINDOW'.static.IsShowWindow("PrivateShopWndReport"))
			{
				CallGFxFunction("AdenaDistributionWnd", "RequestDivideAdenaStart", "");
			}
			else
			{
				getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(5104));
			}
			break;
		case "HairAccButton":
		case "HairButton":
			ChangeViewAccessoryFunc();
			break;
		case "EnchantJewelButton":
			handleEnchantJewelButton();
			break;
		case "AlchemyOpenerBtn":
		case "AlchemyCloseButton":
			toggleAlchemyOpener();
			break;
		case "AlchemyItemCreateWndBtn":
			//toggleShowAlchemyWindow("alchemyItemCreate");
			break;
		case "AlchemyItemConversionWndBtn":
			toggleShowAlchemyWindow("AlchemyItemConversionWnd");
			AlchemyOpenerWindow.HideWindow();
			break;
		case "AlchemyMixCubeWndBtn":
			toggleShowAlchemyWindow("AlchemyMixCubeWnd");
			AlchemyOpenerWindow.HideWindow();
			break;
		case "CharacterViewOpen_BTN":
			toogleCharacterViewPort(true);
			InventoryWndCharacterView(GetScript("InventoryWndCharacterView")).CharacterClickec();
            break;
		case "CharacterViewClose_BTN":
			toogleCharacterViewPort(false);
			break;

		case "EquipItem_RBracelet_Button":
			switchEquipBox(EQUIPITEM_RBracelet);
			break;
		case "EquipItem_LBracelet_Button":
			switchEquipBox(EQUIPITEM_LBracelet);
			break;
		case "EquipItem_Brooch_Button":
			switchEquipBox(EQUIPITEM_Brooch);
			break;
		case "CollectionBtn":
			CheckNOpenCollection(lasetSelectedItemInfo);
			break;
		case "ItemAutoPeelBtn":
			CheckNOpenItemAutoPeel(0, 0, false);
			break;
		case "EquipItem_Henna_Button":
			SwitchEquipBox(99);
			break;
		case "NotStableSwappingBtn":
			_RQ_C_EX_DUAL_INVENTORY_SWAP(-1);
			break;
	}
}

/********************************************************************************************
 * ¬¤¬¬¡¾¬Ó¬ª¡© ¢à¬¹ ¡¾¬Ó?¡í handle ??¬¨¬¤
 * ******************************************************************************************/
function InitHandleCOD()
{
	m_hOwnerWnd = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath);
	m_invenItem = GetItemWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".InventoryItem");
	m_invenItem_1 = GetItemWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".InventoryItem_1");
	m_invenItem_2 = GetItemWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".InventoryItem_2");
	m_invenItem_3 = GetItemWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".InventoryItem_3");
	m_invenItem_4 = GetItemWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".InventoryItem_4");
	m_questItem = GetItemWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".QuestItem");

	m_invenItem.SetIconDrawType(EItemWindowIconDrawType.ITEMWND_IconDraw_ShowNewlyAcquired);
	m_invenItem_1.SetIconDrawType(EItemWindowIconDrawType.ITEMWND_IconDraw_ShowNewlyAcquired);
	m_invenItem_2.SetIconDrawType(EItemWindowIconDrawType.ITEMWND_IconDraw_ShowNewlyAcquired);
	m_invenItem_3.SetIconDrawType(EItemWindowIconDrawType.ITEMWND_IconDraw_ShowNewlyAcquired);
	m_invenItem_4.SetIconDrawType(EItemWindowIconDrawType.ITEMWND_IconDraw_ShowNewlyAcquired);
	m_questItem.SetIconDrawType(EItemWindowIconDrawType.ITEMWND_IconDraw_ShowNewlyAcquired);
	
	m_hAdenaTextBox = GetTextBoxHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".AdenaText");
	m_invenTab = GetTabHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".InventoryTab");
	m_sortBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".SortButton");
	AlchemyOpenerWindow = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".AlchemyOpener_Window");
	AlchemyMixCubeWndBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".AlchemyOpener_Window.AlchemyMixCubeWndBtn");
	AlchemyItemConversionWndBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".AlchemyOpener_Window.AlchemyItemConversionWndBtn");
	AlchemyItemCreateWndBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".AlchemyOpener_Window.AlchemyItemCreateWndBtn");

	m_hBtnCrystallize = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".CrystallizeButton");
	CollectionBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".CollectionBtn");
	CollectionPointAni = GetAnimTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".CollectionPointAni");
	ItemAutoPeelBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemAutoPeelBtn");
	EnchantJewelButton = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".EnchantJewelButton");
	AdenacalculateButton = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".AdenacalculateButton");
	ColorNickNameWnd = GetWindowHandle("ColorNickNameWnd");
	AlchemyOpenerBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".AlchemyOpenerBtn");

	m_tabbgLine = GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".tabbgLine");
	m_itemCount = GetTextBoxHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemCount");
	m_CharacterViewOpen_BTN = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".CharacterViewOpen_BTN");
	m_CharacterViewClose_BTN = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".CharacterViewClose_BTN");
	m_InventoryWndCharacterView = GetWindowHandle("InventoryWndCharacterView");
	ItemAutoPeelBtn.SetTooltipCustomType(getEquipCustomTooltip(GetSystemString(14039), GetSystemString(14062)));
}

/*
 * ¬¦¡þ¡¤??¬¥ ¢Ò¬å¬¡¬®?¬Ü?? ¬×¬£?¬£ ¬¡¬Ö?¬ã ¬©¬¼¥ì¬Û ¢à¬À¬¡? 
 */
function SetEquipWindowHandle()
{
	local string equipWindow, hyphen, tooltipText;
	local CustomTooltip T;

	// ¬©¬º?¬¾ ¬¦¡þ¡¤??¬¥ ¢à¬è¬¢????¡© ¬©¬·?? UI ¡í¬Ù?¬Ý¬©¬´¬¢¬è ?¨Ï?¬° 
	// ¡í¬Ù?¬Ý ?¬¤ ¢à¬è¬¨¡Æ ?¬ê?¡©¡Æ? "?¬¨¥ì??? ?¬²¢à¬Ú", "¬©¬·??" ¬¡¬® ¬©¬¹?¬¤ ?¬Ý¬¤¬Ó ¥ì¬©¡Æ¬ß, ¬¢¢Ò¡Æ¬©(¥ì¬Ö?¬è¬©¬¢ ¬¡¬±¬¢¢´ ¬¢¬é?¬é)?? ¥ì¬í¢Ò¬å "¡Æ¬Ò¬¢¢´¬ª¡©" ?¬Ý¬¤¬Ó
	m_EquipWindowName = "Equip_classic";
	equipWindow = m_hOwnerWnd.m_WindowNameWithFullPath $ "." $ m_EquipWindowName;
	m_EquipWindow = GetWindowHandle(equipWindow);
	// ¬©¬·?? ?¬×?¢ç ¢à¬è¬¨¡Æ, ¬¡¨Ï¥ì¥ì?¬Þ
	JewelWindow = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".EquipItem_Jewel_Window");
	m_equipItem[EQUIPITEM_Brooch] = GetItemWindowHandle(equipWindow $ ".EquipItem_Brooch");
	m_equipItem[EQUIPITEM_Jewel1] = GetItemWindowHandle(equipWindow $ ".EquipItem_Jewel_Window.EquipItem_Jewel1");
	m_equipItem[EQUIPITEM_Jewel2] = GetItemWindowHandle(equipWindow $ ".EquipItem_Jewel_Window.EquipItem_Jewel2");
	m_equipItem[EQUIPITEM_Jewel3] = GetItemWindowHandle(equipWindow $ ".EquipItem_Jewel_Window.EquipItem_Jewel3");
	m_equipItem[EQUIPITEM_Jewel4] = GetItemWindowHandle(equipWindow $ ".EquipItem_Jewel_Window.EquipItem_Jewel4");
	m_equipItem[EQUIPITEM_Jewel5] = GetItemWindowHandle(equipWindow $ ".EquipItem_Jewel_Window.EquipItem_Jewel5");
	m_equipItem[EQUIPITEM_Jewel6] = GetItemWindowHandle(equipWindow $ ".EquipItem_Jewel_Window.EquipItem_Jewel6");

	m_Jewel_Disable[0] = GetTextureHandle(equipWindow $ ".EquipItem_Jewel_Window.Jewel1_Disable");
	m_Jewel_Disable[1] = GetTextureHandle(equipWindow $ ".EquipItem_Jewel_Window.Jewel2_Disable");
	m_Jewel_Disable[2] = GetTextureHandle(equipWindow $ ".EquipItem_Jewel_Window.Jewel3_Disable");
	m_Jewel_Disable[3] = GetTextureHandle(equipWindow $ ".EquipItem_Jewel_Window.Jewel4_Disable");
	m_Jewel_Disable[4] = GetTextureHandle(equipWindow $ ".EquipItem_Jewel_Window.Jewel5_Disable");
	m_Jewel_Disable[5] = GetTextureHandle(equipWindow $ ".EquipItem_Jewel_Window.Jewel6_Disable");
//	m_equipItem_Brooch.SetTooltipText( GetSystemString(3186));
//	m_equipItem[ EQUIPITEM_Brooch ].SetTooltipText( GetSystemString(3186));
//	EquipItem_Brooch_Button.SetTooltipText( GetSystemString(3186));

	/******************************************** ?¬¨¡Æ??¬¤?¬£ ¬¡¨Ï¥ì¥ì?¬Þ ??¬¢¢´ *********************************************/
	AgathionWindow = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".EquipItem_Agathion_Window");

	// ?¬¨¡Æ??¬¤?¬£ ?¡©¡Æ¬ß ?¬¿¡¾¬Ó ¢à¬è¬¨¡Æ
	AgathionBtn = GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".AgathionButton");

	// ?¬¨¡Æ??¬¤?¬£ ?¬ã¬ª¡Æ??¬ª¡© ¬¦¬º??¬¤¬¥ ¥ì¬Û(main ¬¨¬é¬©¬¶)
	m_Agathion_Disable[0] = GetTextureHandle(equipWindow $ ".EquipItem_Agathion_Window.AgathionMain_Disable");
	m_Agathion_Disable[1] = GetTextureHandle(equipWindow $ ".EquipItem_Agathion_Window.Agathion1_Disable");
	m_Agathion_Disable[2] = GetTextureHandle(equipWindow $ ".EquipItem_Agathion_Window.Agathion2_Disable");
	m_Agathion_Disable[3] = GetTextureHandle(equipWindow $ ".EquipItem_Agathion_Window.Agathion3_Disable");
	m_Agathion_Disable[4] = GetTextureHandle(equipWindow $ ".EquipItem_Agathion_Window.Agathion4_Disable");

	// ?¬¨¡Æ??¬¤?¬£ ?¬¨¬¡¬®¬¦¬½ ¬¡¨Ï¥ì¥ì?¬Þ ¥ì¬Û
	m_equipItem[EQUIPITEM_AGATHION_MAIN] = GetItemWindowHandle(equipWindow $ ".EquipItem_Agathion_Window.EquipItem_AgathionMain");
	m_equipItem[EQUIPITEM_AGATHION_SUB1] = GetItemWindowHandle(equipWindow $ ".EquipItem_Agathion_Window.EquipItem_AgathionSub1");
	m_equipItem[EQUIPITEM_AGATHION_SUB2] = GetItemWindowHandle(equipWindow $ ".EquipItem_Agathion_Window.EquipItem_AgathionSub2");
	m_equipItem[EQUIPITEM_AGATHION_SUB3] = GetItemWindowHandle(equipWindow $ ".EquipItem_Agathion_Window.EquipItem_AgathionSub3");
	m_equipItem[EQUIPITEM_AGATHION_SUB4] = GetItemWindowHandle(equipWindow $ ".EquipItem_Agathion_Window.EquipItem_AgathionSub4");
	hyphen = getHyphenByLanguage();

	T = getAgathionTooltip(GetSystemString(2341) @ GetSystemString(3638), hyphen $ GetSystemString(3643));
	m_Agathion_Disable[0].SetTooltipCustomType(getAgathionTooltip(GetSystemString(2738) @ GetSystemString(3638), hyphen $ GetSystemString(3642)));
	m_Agathion_Disable[1].SetTooltipCustomType(T);
	m_Agathion_Disable[2].SetTooltipCustomType(T);
	m_Agathion_Disable[3].SetTooltipCustomType(T);
	m_Agathion_Disable[4].SetTooltipCustomType(T);

	tooltipText = GetSystemString(2341) @ GetSystemString(3638) $ "\\n" $ hyphen $ GetSystemString(3643);
	m_equipItem[EQUIPITEM_AGATHION_MAIN].SetTooltipText(GetSystemString(2738) @ GetSystemString(3638) $ "\\n" $ hyphen $ GetSystemString(3642));
	m_equipItem[EQUIPITEM_AGATHION_SUB1].SetTooltipText(tooltipText);
	m_equipItem[EQUIPITEM_AGATHION_SUB2].SetTooltipText(tooltipText);
	m_equipItem[EQUIPITEM_AGATHION_SUB3].SetTooltipText(tooltipText);
	m_equipItem[EQUIPITEM_AGATHION_SUB4].SetTooltipText(tooltipText);

	/******************************************** ?¬¨¬¨?¬¨¬³¬¨¢ç ¬¡¨Ï¥ì¥ì?¬Þ ??¬¢¢´ *********************************************/
	Hair2SlotDisable_tex = GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".Equip_classic.Hair2SlotDisable_tex");
	Hair2SlotDisable_tex.HideWindow();	
}

// ¬¦¬ê¬¨¬¢ ¢à¬¹ ¡¾¬Ó?¡í ¬©¬¼¥ì¬Û ¢à¬À¬¡? 
function SetHandles()
{
	local string equipWindow;
	equipWindow = m_hOwnerWnd.m_WindowNameWithFullPath $ "." $ m_EquipWindowName;

	//¬¦¡þ¡¤??¬¥ ?¡©¢à¬è???¡© ?¬î¬¢¬è?¬£ ?¬¨¬¡¬®¬¦¬½
	/*
	 *?¬Ü¡¤¬°¬¥?
	 *?¬¦¬¤¬é
	 *?¡×¬¨¢ç < 151015 ¬¡¬®¬ª¬¥ ¬¤¬Á¡Æ? ¥ì¬¬
	 *¬×¬¢¬¦¬Õ < 151015 ¬¡¬®¬ª¬¥ ¬¤¬Á¡Æ? ¥ì¬¬
	 *¬¦¡í¬×¢ç??¬×¬× < ¬¡¬®¬ª¬¥ ¬¤¬Á¡Æ? ¥ì¬¬
	 *	
	*/

	//----------------------------------- ¬ª¬ë¥ì¬Û¥ì¬Û --------------------------------------------------//

	ViewHairButton = GetButtonHandle(equipWindow $ ".HairButton");
	ViewAccessoryButton = GetButtonHandle(equipWindow $ ".HairAccButton");

	m_equipItem[EQUIPITEM_Head] = GetItemWindowHandle(equipWindow $ ".EquipItem_Head");
	m_equipItem[EQUIPITEM_Hair] = GetItemWindowHandle(equipWindow $ ".EquipItem_Hair");
	m_equipItem[EQUIPITEM_Hair2] = GetItemWindowHandle(equipWindow $ ".EquipItem_Hair2");
	m_equipItem[EQUIPITEM_Neck] = GetItemWindowHandle(equipWindow $ ".EquipItem_Neck");
	m_equipItem[EQUIPITEM_RHand] = GetItemWindowHandle(equipWindow $ ".EquipItem_RHand");
	m_equipItem[EQUIPITEM_Chest] = GetItemWindowHandle(equipWindow $ ".EquipItem_Chest");
	m_equipItem[EQUIPITEM_LHand] = GetItemWindowHandle(equipWindow $ ".EquipItem_LHand");
	m_equipItem[EQUIPITEM_REar] = GetItemWindowHandle(equipWindow $ ".EquipItem_REar");
	m_equipItem[EQUIPITEM_LEar] = GetItemWindowHandle(equipWindow $ ".EquipItem_LEar");
	m_equipItem[EQUIPITEM_Gloves] = GetItemWindowHandle(equipWindow $ ".EquipItem_Gloves");
	m_equipItem[EQUIPITEM_Legs] = GetItemWindowHandle(equipWindow $ ".EquipItem_Legs");
	m_equipItem[EQUIPITEM_Feet] = GetItemWindowHandle(equipWindow $ ".EquipItem_Feet");
	m_equipItem[EQUIPITEM_RFinger] = GetItemWindowHandle(equipWindow $ ".EquipItem_RFinger");
	m_equipItem[EQUIPITEM_LFinger] = GetItemWindowHandle(equipWindow $ ".EquipItem_LFinger");
	m_equipItem[EQUIPITEM_LBracelet] = GetItemWindowHandle(equipWindow $ ".EquipItem_LBracelet");
	m_equipItem[EQUIPITEM_Cloak] = GetItemWindowHandle(equipWindow $ ".EquipItem_Cloak");
	m_equipItem[EQUIPITEM_Waist] = GetItemWindowHandle(equipWindow $ ".EquipItem_Waist");
	m_equipItem[EQUIPITEM_Deco1] = GetItemWindowHandle(equipWindow $ ".EquipItem_Talisman1");
	m_equipItem[EQUIPITEM_Deco2] = GetItemWindowHandle(equipWindow $ ".EquipItem_Talisman2");
	m_equipItem[EQUIPITEM_Deco3] = GetItemWindowHandle(equipWindow $ ".EquipItem_Talisman3");
	m_equipItem[EQUIPITEM_Deco4] = GetItemWindowHandle(equipWindow $ ".EquipItem_Talisman4");
	m_equipItem[EQUIPITEM_Deco5] = GetItemWindowHandle(equipWindow $ ".EquipItem_Talisman5");
	m_equipItem[EQUIPITEM_Deco6] = GetItemWindowHandle(equipWindow $ ".EquipItem_Talisman6");
	m_Talisman_Disable[0] = GetTextureHandle(equipWindow $ ".Talisman1_Disable");
	m_Talisman_Disable[1] = GetTextureHandle(equipWindow $ ".Talisman2_Disable");
	m_Talisman_Disable[2] = GetTextureHandle(equipWindow $ ".Talisman3_Disable");
	m_Talisman_Disable[3] = GetTextureHandle(equipWindow $ ".Talisman4_Disable");
	m_Talisman_Disable[4] = GetTextureHandle(equipWindow $ ".Talisman5_Disable");
	m_Talisman_Disable[5] = GetTextureHandle(equipWindow $ ".Talisman6_Disable");
	m_equipItem[EQUIPITEM_RBracelet] = GetItemWindowHandle(equipWindow $ ".EquipItem_RBracelet");
	//classic???¡© ¬¨¬´?¬ê¬¨¢ç¡¤¬° ¡í¬Ù?¬Ý ¥ì¬¬. ?¬ã¬¨¢ç?¡þ¡í¬Ü¬¡¬® ¡Æ¡Æ¬¡¬×¢à¬©¡¤¬° ¬¡¬®¬×¡×¬¡¡í ¥ì¬°¡Æ? ¥ì¬³ ¡Æ¬Ø?¬Þ ?¬ç ¬©¬ä¡Æ?¬×¡¾ ?¬è ¬¡¬¸¬¡?
	m_equipItem[EQUIPITEM_Underwear] = GetItemWindowHandle(equipWindow $ ".EquipItem_Underwear");
	m_equipItem[EQUIPITEM_LHand].SetDisableTex("L2UI.InventoryWnd.Icon_dualcap");
	m_equipItem[EQUIPITEM_Head].SetDisableTex("L2UI.InventoryWnd.Icon_dualcap");
	m_equipItem[EQUIPITEM_Gloves].SetDisableTex("L2UI.InventoryWnd.Icon_dualcap");
	m_equipItem[EQUIPITEM_Legs].SetDisableTex("L2UI.InventoryWnd.Icon_dualcap");
	m_equipItem[EQUIPITEM_Feet].SetDisableTex("L2UI.InventoryWnd.Icon_dualcap");
	m_equipItem[EQUIPITEM_Hair2].SetDisableTex("L2UI.InventoryWnd.Icon_dualcap");
	EquipItem_Brooch_Button = GetButtonHandle(equipWindow $ ".EquipItem_Brooch_Button");
	EquipItem_RBracelet_Button = GetButtonHandle(equipWindow $ ".EquipItem_RBracelet_Button");
	EquipItem_LBracelet_Button = GetButtonHandle(equipWindow $ ".EquipItem_LBracelet_Button");
	setCustomTooltip();
	//----------------------------------- ¬¦¬ç¬¨¬¢¥ì¬Û --------------------------------------------------//

	m_equipItem[EQUIPITEM_Head].SetTooltipText(GetSystemString(230));
	m_equipItem[EQUIPITEM_Hair].SetTooltipText(GetSystemString(1024));
	m_equipItem[EQUIPITEM_Hair2].SetTooltipText(GetSystemString(1024));
	m_equipItem[EQUIPITEM_Neck].SetTooltipText(GetSystemString(238));
	m_equipItem[EQUIPITEM_RHand].SetTooltipText(GetSystemString(2520));
	m_equipItem[EQUIPITEM_Chest].SetTooltipText(GetSystemString(38));
	EquipSlotBg_Sigil = GetTextureHandle(equipWindow $ ".EquipSlotBg_Sigil");
	SetSigilShieldTextureChange(true);
	m_equipItem[EQUIPITEM_REar].SetTooltipText(GetSystemString(237));
	m_equipItem[EQUIPITEM_LEar].SetTooltipText(GetSystemString(237));
	m_equipItem[EQUIPITEM_Gloves].SetTooltipText(GetSystemString(37));
	m_equipItem[EQUIPITEM_Legs].SetTooltipText(GetSystemString(39));
	m_equipItem[EQUIPITEM_Feet].SetTooltipText(GetSystemString(40));
	m_equipItem[EQUIPITEM_RFinger].SetTooltipText(GetSystemString(239));
	m_equipItem[EQUIPITEM_LFinger].SetTooltipText(GetSystemString(239));
	m_equipItem[EQUIPITEM_LBracelet].SetTooltipText(GetSystemString(1637));
	EquipItem_LBracelet_Button.SetTooltipText(GetSystemString(1637));
	m_equipItem[EQUIPITEM_Cloak].SetTooltipText(GetSystemString(234));
	m_equipItem[EQUIPITEM_Waist].SetTooltipText(GetSystemString(2538));
	m_equipItem[EQUIPITEM_RBracelet].SetTooltipText(GetSystemString(1636));
	EquipItem_RBracelet_Button.SetTooltipText(GetSystemString(1636));
	m_equipItem[EQUIPITEM_Deco1].SetTooltipText(GetSystemString(1638));
	m_equipItem[EQUIPITEM_Deco2].SetTooltipText(GetSystemString(1638));
	m_equipItem[EQUIPITEM_Deco3].SetTooltipText(GetSystemString(1638));
	m_equipItem[EQUIPITEM_Deco4].SetTooltipText(GetSystemString(1638));
	m_equipItem[EQUIPITEM_Deco5].SetTooltipText(GetSystemString(1638));
	m_equipItem[EQUIPITEM_Deco6].SetTooltipText(GetSystemString(1638));
	m_Talisman_Disable[0].SetTooltipText(GetSystemString(1638));
	m_Talisman_Disable[1].SetTooltipText(GetSystemString(1638));
	m_Talisman_Disable[2].SetTooltipText(GetSystemString(1638));
	m_Talisman_Disable[3].SetTooltipText(GetSystemString(1638));
	m_Talisman_Disable[4].SetTooltipText(GetSystemString(1638));
	m_Talisman_Disable[5].SetTooltipText(GetSystemString(1638));
	m_equipItem[EQUIPITEM_Jewel1].SetTooltipText(GetSystemString(3187));
	m_equipItem[EQUIPITEM_Jewel2].SetTooltipText(GetSystemString(3187));
	m_equipItem[EQUIPITEM_Jewel3].SetTooltipText(GetSystemString(3187));
	m_equipItem[EQUIPITEM_Jewel4].SetTooltipText(GetSystemString(3187));
	m_equipItem[EQUIPITEM_Jewel5].SetTooltipText(GetSystemString(3187));
	m_equipItem[EQUIPITEM_Jewel6].SetTooltipText(GetSystemString(3187));
	m_Jewel_Disable[0].SetTooltipText(GetSystemString(3187));
	m_Jewel_Disable[1].SetTooltipText(GetSystemString(3187));
	m_Jewel_Disable[2].SetTooltipText(GetSystemString(3187));
	m_Jewel_Disable[3].SetTooltipText(GetSystemString(3187));
	m_Jewel_Disable[4].SetTooltipText(GetSystemString(3187));
	m_Jewel_Disable[5].SetTooltipText(GetSystemString(3187));
	m_equipItem[EQUIPITEM_Underwear].SetTooltipText(GetSystemString(28));
	m_equipItem[EQUIPITEM_Brooch].SetTooltipText(GetSystemString(3186));
	EquipItem_Brooch_Button.SetTooltipText(GetSystemString(3186));
	m_TalismanAllow = GetTextureHandle(equipWindow $ ".TalismanAllow");
	SetDualSlotBitTypes();
}

private function SetDualSlotBitTypes()
{
	m_equipItem[0].SetDualSlotBitType(1);
	m_equipItem[1].SetDualSlotBitType(64);
	m_equipItem[2].SetDualSlotBitType(65536);
	m_equipItem[3].SetDualSlotBitType(262144);
	m_equipItem[4].SetDualSlotBitType(8);
	m_equipItem[5].SetDualSlotBitType(128);
	m_equipItem[6].SetDualSlotBitType(1024);
	m_equipItem[7].SetDualSlotBitType(256);
	m_equipItem[8].SetDualSlotBitType(2);
	m_equipItem[9].SetDualSlotBitType(4);
	m_equipItem[10].SetDualSlotBitType(512);
	m_equipItem[11].SetDualSlotBitType(2048);
	m_equipItem[12].SetDualSlotBitType(4096);
	m_equipItem[13].SetDualSlotBitType(16);
	m_equipItem[14].SetDualSlotBitType(32);
	m_equipItem[23].SetDualSlotBitType(8192);
	m_equipItem[24].SetDualSlotBitType(268435456);	
}

function SetSigilShieldTextureChange(bool B)
{
	if(B)
	{
		EquipSlotBg_Sigil.SetTexture("L2UI_ct1.InventoryWnd.Inventory_Slot32_SigilShield");
		m_equipItem[EQUIPITEM_LHand].SetTooltipText(GetSystemString(13205));
	}
	else
	{
		EquipSlotBg_Sigil.SetTexture("L2UI_ct1.InventoryWnd.Inventory_Slot32_Sigil");
		m_equipItem[EQUIPITEM_LHand].SetTooltipText(GetSystemString(1987));
	}
}

function CustomTooltip getEquipCustomTooltip(string Title, string Desc)
{
	local CustomTooltip mCustomTooltip;
	local array<DrawItemInfo> drawListArr;

	drawListArr[drawListArr.Length] = addDrawItemText(Title,getInstanceL2Util().BrightWhite,"",true,true);
	drawListArr[drawListArr.Length] = addDrawItemBlank(4);
	drawListArr[drawListArr.Length] = AddCrossLineForCustomToolTip(130);
	drawListArr[drawListArr.Length] = addDrawItemBlank(4);
	drawListArr[drawListArr.Length] = addDrawItemText(Desc, getInstanceL2Util().ColorDesc,"",true,false);
	mCustomTooltip = MakeTooltipMultiTextByArray(drawListArr);
	mCustomTooltip.MinimumWidth = 205;
	setCustomToolTipMinimumWidth(mCustomTooltip);

	return mCustomTooltip;
}

function SetHennaWindows()
{
	local int i;
	local string equipWindow;

	equipWindow = m_hOwnerWnd.m_WindowNameWithFullPath $ "." $ m_EquipWindowName;
	equipItem_Henna_Button = GetButtonHandle(equipWindow $ ".equipItem_Henna_Button");
	equipItem_Henna_Button.SetTooltipCustomType(getEquipCustomTooltip(GetSystemString(13904), GetSystemString(13918) $ "\\n" $ GetSystemString(13919)));
	equipItem_Henna_Window = GetWindowHandle(equipWindow $ ".equipItem_Henna_Window");
	hennas_Disable4 = GetTextureHandle(equipWindow $ ".EquipItem_Henna_Window.henna4_Disable");
	for(i = 0; i < 4; i++)
	{
		hennaItems[i] = GetItemWindowHandle(equipWindow $ ".EquipItem_Henna_Window.hennaItem" $ string(i + 1));
	}
}

function string getHyphenByLanguage()
{	
	// ¬©¬º?¬¾ ¬¨¬ë¬¨¢ç¬¡¬© ¡Æ¬Ø?¬Þ ¬¡??¬± ¬¥¬¼¥ì¬Ö¡Æ? ?¬»¬×| ?¬è ¬¡¬¸?¬¡?¬±?¬».
	if(GetLanguage()== LANG_Korean)
	{
		return "­";
	}
	return "-";
}

function HandleDelegateOnClickBUtton(string btn)
{
	switch(btn)
	{
		case "GroupBaseBtn":
			toggleWindow("HennaMenuWnd", true);
			break;
	}
}

function HandleDelegateOnLButtonUp(WindowHandle wnd, int X, int Y)
{
	switch(wnd)
	{
		case hennaItems[0]:
		case hennaItems[1]:
		case hennaItems[2]:
		case hennaItems[3]:
			HandleChangeHennaDye(int(Right(wnd.GetWindowName(), 1)) - 1);
			break;
	}
}

/********************************************************************************************
 * ¬×¢ç??¬¦¬×¬¨¢ç ¬¤?¬×¢ç 
 * ******************************************************************************************/
function HandleRestart()
{
	bRequestHennaOnShow = false;
	m_bCurrentState = false;
	bInitedCompleted = false;
	bRequestedEnableList = false;
	m_hOwnerWnd.HideWindow();
	InitDualToDefaultA();
}

/********************************************************************************************
 * ?¬»¬¡¬®?¬å¡¤¬°¡¾¬¹ ¬¤?¬×¢ç 
 * ******************************************************************************************/
function HandleDialogOK()
{
	local int id;
	local INT64 reserved2;
	local ItemID sID;
	local INT64 number;
	
	if(DialogIsMine())
	{
		id = DialogGetID();
		reserved2 = DialogGetReservedInt2();
		number = INT64(DialogGetString());
		sID = DialogGetReservedItemID();	// ItemID
		
		if(id == DIALOG_USE_RECIPE || id == DIALOG_POPUP)
		{
			RequestUseItem(sID);
		}
		else if(id == DIALOG_DROPITEM)
		{
			RequestDropItem(sID, 1, m_clickLocation);
		}
		else if(id == DIALOG_DROPITEM_ASKCOUNT)
		{
			if(number == 0)
				number = 1;					// ?¬¨¢à¡ì ?¬ï¬¡¬¼¥ì¥ì ¬¡¬¶¡¤¬£¬©¬±¬¢¬è ?¬¬¬¡¬×¬×¬Û 1¡Æ? ¥ì¬Ö¢Ò¬ê¬¡¬×¡¤¬° ¬¤?¬×¢ç
			RequestDropItem(sID, number, m_clickLocation);
		}
		else if(id == DIALOG_DROPITEM_ALL)
		{
			RequestDropItem(sID, reserved2, m_clickLocation);
		}
		else if(id == DIALOG_DESTROYITEM)
		{
			RequestDestroyItem(sID, 1);
			PlayConsoleSound(IFST_TRASH_BASKET);
		}
		else if(id == DIALOG_DESTROYITEM_ASKCOUNT)
		{
			RequestDestroyItem(sID, number);
			PlayConsoleSound(IFST_TRASH_BASKET);
		}
		else if(id == DIALOG_DESTROYITEM_ALL)
		{
			RequestDestroyItem(sID, reserved2);
			PlayConsoleSound(IFST_TRASH_BASKET);
		}
		else if(id == DIALOG_CRYSTALLIZE)
		{
			RequestCrystallizeItem(sID,1);
			PlayConsoleSound(IFST_TRASH_BASKET);
		}
		else if(id == DIALOG_DROPITEM_PETASKCOUNT)
		{
			class'PetAPI'.static.RequestGetItemFromPet(sID, number, false);
		}
	}
}


/********************************************************************************************
 * ?¬¨¬¡¬®¬¦¬½ ¡í¬Ù?¬Ý ¥ì¬à
 * ******************************************************************************************/
// ?¬©??¡í¬Ù¬×¢ç 
function ChangeViewAccessoryFunc()
{
	local ItemInfo infItem;
	infItem.ID.ClassID = 17192;
	UseSkill(infItem.ID, int(EShortCutItemType.SCIT_SKILL));
}

// ¬¡¬±¢à¬¿ ?¬¨¬¡¬®¬¦¬½
function UseItem(ItemWindowHandle a_hItemWindow, int index)
{
	local ItemInfo	info;

	if(a_hItemWindow.GetItem(index, info))
	{
		if(info.bDisabled == 0)		// lpislhy
		{
			if(info.bRecipe)					// ¬¢|¬¢¢Ò¢à¬ï(¡¤¢à?¬¤¬©¬©)¬×| ¡í¬Ù?¬Ý¬©¬´ ¡Æ¬¯¬¡¬°¬¢¬è ¢à¡Æ?¬à?¡í?¬»
			{
				DialogSetReservedItemID(info.ID);	// ServerID
				DialogSetID(DIALOG_USE_RECIPE);
				DialogShow(DialogModalType_Modalless,DialogType_Warning, GetSystemMessage(798), string(Self));
				class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
			}
			else if(Info.bSimpleExchangeItem)
			{
				class'MultiSellItemExchangeWnd'.static.Inst().OpenWindow(Info.Id.ClassID);					
			}
			else if(info.PopMsgNum > 0)			// ¬¨¬­?¬é ¬×¬À?¬¤¬¢¬è¬×| ?¬×?¨Ï¬¢¬º?¬».
			{
				DialogSetID(DIALOG_POPUP);
				DialogSetReservedItemID(info.ID);	// ServerID
				DialogShow(DialogModalType_Modalless,DialogType_Warning, GetSystemMessage(info.PopMsgNum), string(Self));
				class'DialogBox'.static.Inst().DelegateOnOK = HandleDialogOK;
			}
			else
			{
				RequestUseItem(info.ID);
			}
		}
		else
		{
			if(class'UIDATA_ITEM'.static.IsDefaultActionPeel(Info.Id.ClassID) && class'ItemAutoPeelWnd'.static.Inst().IsItemReady())
			{
				getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(13680));
			}
		}
	}
}

// ?¬×?¢ç ?¬¨¬¡¬®¬¦¬½ ¥ì¬Ö¢Ò¬ê
function handleJewelDropedOnButton(ItemInfo info)
{
	class'ItemJewelEnchantWnd'.static.Inst()._HandleDropedItem(info);
}


/********************************************************************************************
 * ?¬¨¬¡¬®¬¦¬½ ?¬é¥ì?¬¡¬®¬¨¢ç 
 * ******************************************************************************************/
// ?? ?¬¨¬¡¬®¬¦¬½ ¡í¬Ù?¬Ý ¡Æ??¬« ????
function UpdateItemUsability()
{
	m_invenItem.SetItemUsability();
	m_invenItem_1.SetItemUsability();
	m_invenItem_2.SetItemUsability();
	m_invenItem_3.SetItemUsability();
	m_invenItem_4.SetItemUsability();
	m_questItem.SetItemUsability();
}

function API_C_EX_ITEM_USABLE_LIST()
{
	local array<byte> stream;
	local UIPacket._C_EX_ITEM_USABLE_LIST packet;

	if(bRequestedEnableList)
	{
		return;
	}
	m_hOwnerWnd.KillTimer(TIMERID_bRequestedEnableList);
	m_hOwnerWnd.SetTimer(TIMERID_bRequestedEnableList, TIMER_bRequestedEnableList);
	if(! class'UIPacket'.static.Encode_C_EX_ITEM_USABLE_LIST(stream, packet))
	{
		return;
	}
	packet.cDummy = 0;
	class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_ITEM_USABLE_LIST, stream);
	bRequestedEnableList = true;
}

// ?¬¨¬¡¬®¬¦¬½ ?¬é¥ì?¬¡¬®¬¨¢ç
function HandleUpdateItemWithInfo(ItemInfo info, string Type)
{
	local ItemInfo beforeItem;
	local int index;
	local ItemWindowHandle detailItemWindowHandle;
		
	setShowItemCount(info);
	//Debug("HandleUpdateItem" @ type);

	if(type == "add")
	{
		if(IsEquipItem(info))
		{
			QuitReportWndScript.externalAddItem(info);
			EquipItemUpdate(info, true);
		}
		else if(IsQuestItem(info))
		{			
			QuestInvenAddItem(info);
			handleNewItem(info);
		}
		else
		{			
			QuitReportWndScript.externalAddItem(info);
			NormalInvenAddItem(info);
			handleNewItem(info);
		}
	}
	else if(type == "update")
	{
		if(IsEquipItem(info))
		{
			//Debug("handleUpdateItem IsEquipItem" @ IsArtifactRuneItem(info)@ "/" @ info.name ); 
			if(EquipItemFind(info.ID))		// match found
			{
				//debug("¬¡¬®¬©¬¢¡¤¬° ? " $ param);
				EquipItemUpdate(info, true);				
			}
			else 			// not found in equipItemList. In this case, move the item from InvenItemList to EquipItemList
			{				
				InvenDelete(info);				
				EquipItemUpdate(info, true);
			}
		}
		else if(IsQuestItem(info))
		{
			index = m_questItem.FindItem(info.ID);	// ServerID
			if(index != -1)
			{	
				m_questItem.GetItem(index , beforeItem);

				m_questItem.SetItem(index, info);

				// ?¬è¡¤¢ç¬¡¬® ?¬¤?¬à?¡© ¡Æ¬Ø?¬Þ¬×¬× new ¬©??¬¤¬×| ¬©¬º¬¢¬¾.				
				if(beforeItem.itemNum < info.itemNum)handleNewItem(info);
			}
			else		// In this case, Equipped item is being unequipped.
			{
				EquipItemDelete(info.ID);
				QuestInvenAddItem(info);
				handleNewItem(info);
			}			
		}
		else
		{
			index = m_invenItem.FindItem(info.ID);	// ServerID

			if(index != -1)
			{
				m_invenItem.GetItem(index , beforeItem);

				if(beforeItem.ItemNum != Info.ItemNum)
				{
					QuitReportWndScript.externalAddItem(Info);
				}

				m_invenItem.SetItem(index, info);
				detailItemWindowHandle = getItemWindowHandleByItemType(info);				
				detailItemWindowHandle.SetItem(detailItemWindowHandle.FindItem(info.ID), info);
				
				
				if(beforeItem.itemNum < info.itemNum)
				{
//					Debug("itemUpdate" @ info.Name @  beforeItem.itemNum @ info.itemNum);
					handleNewItem(info);
				}
				
			}
			else		// In this case, Equipped item is being unequipped.
			{
				EquipItemDelete(info.ID);				
				NormalInvenAddItem(info);
			}
		}
	}
	else if(type == "delete")
	{
		if(IsEquipItem(info))
		{
			EquipItemDelete(info.ID);
		}
		else if(IsQuestItem(info))
		{
			QuestInvenDelete(info);
		}
		else 
		{
			InvenDelete(info);
		}
	}

	UpdateItemUsability();

	SetAdenaText();
	SetItemCount();
}

function HandleUpdateItem(string param)
{
	local ItemInfo Info;
	local string Type;

	ParseString(param, "type", Type);
	ParamToItemInfo(param, Info);
	HandleUpdateItemWithInfo(Info, Type);
}

// ?¬¨¬¡¬®¬¦¬½ ?¬±¡¤¬Ò¡Æ? ¥ì¬°¢à¬ê ¥ì¬Û?¬à ?¬ª.
// ¬¡¬±¢à¬¿ ?¬¨¬¡¬®¬¦¬½ ?¬±¡¤¬Ò
// ¬¥¬ë??¬¨¢ç ?¬±¡¤¬Ò
function HandleItemListEnd()
{
	// ¬¤?¬¡? ?¬±¡¤¬Ò ?¬¤ ¬¥¬ë??¬¨¢ç ¬×¢ç??¬¨¢ç¡¤¬° ¬¤?¬×¢ç
	if(!bIsQuestItemList)
	{
		bIsQuestItemList = true;
		return;
	}
	SetAdenaText();
	SetItemCount();
	UpdateItemUsability();
	if(bIsSavedLocalItemIdx)
	{
		SaveInventoryOrder();
	}
	if(bRequestItemList)
	{
		bRequestItemList = false;
		ShowWindowWithFocus("InventoryWnd");
		PlayConsoleSound(IFST_INVENWND_OPEN);
	}
}

/********************************************************************************************
 * item add 
 * ******************************************************************************************/
function HandleAddItem(string param)
{
	local ItemInfo info;

	ParamToItemInfo(param, info);
	setShowItemCount(info);

	if(IsEquipItem(info))		
		EquipItemUpdate(info);
	else if(IsQuestItem(info))
		QuestInvenAddItem(info);
	else 
		NormalInvenAddItem(info);
}

function NormalInvenAddItem(ItemInfo newItem)
{	
	local int idx;
	local int CurLimit;
	local int FindIdx;
	
	local ItemInfo curItem;

	local ItemWindowHandle detailItemWindow ;
	
	//local int FindIdxDetail;		
	//Debug("NormalInvenAddItem " @ newItem.Name @ "/" @  newItem.SlotBitType);
	// ?¬¨¡¤¢à?? ¡Æ¡©¬ª¡© ¬¡¬î?¬Ý ?¬¨¬¡¬®¬¦¬½¬¡¬®¢Ò¬å¬×¬Û ?¬è¬¥?¬×¬× ¬¡¬í¡Æ¬ß setItem ¬©¬±¬¢¬è ?¬¬?¬£?¬».
	//if(handleArenaEnchantOnlyEnchanted(newItem))return ;

	FindIdx = -1;	

	CurLimit = m_invenItem.GetItemNum();
	//Debug("NormalInvenAddItem" @  newItem.ID.classID @ newItem.ID.serverID);

//	Debug("NormalInvenAddItem" @  newItem.name @ newItem.Order @ getLocalItemOrder(newItem.ID.serverID, itemSwapedServerID, itemSwapedIdx, newItem.Order)@ bIsSavedLocalItemIdx);

	if(bIsSavedLocalItemIdx)	
		newItem.Order = getLocalItemOrder(newItem.ID.serverID, itemSwapedServerID, itemSwapedIdx, newItem.Order);

	//¬©¬º?¬Ù ¬¡¬¼¬×¢ç?? ?¬¨¬¡¬®¬¦¬½¬¡¬® ¬¡¬¸¬¡¡í ¡Æ¬Ø?¬Þ
	if( m_invenItem.GetItem(newItem.Order, curItem))
		if(!IsValidItemID(curItem.ID))	
			FindIdx = newItem.Order;	
	
	//?¬¨¬¡¬®¬¦¬½¬¡¬® ?¬ê¬¡¡í ¡Æ¬Ø?¬Þ
	if(FindIdx < 0)
		for(idx=0; idx<CurLimit; idx++)
			//?¬å idx¬×| ¬¤??¬¨¢Ò¬å
			if(m_invenItem.GetItem(idx, curItem))
				if(!IsValidItemID(curItem.ID))
				{	
					FindIdx = idx;
					break;
				}			

	if(FindIdx > -1)
		m_invenItem.SetItem(FindIdx, newItem);				
	else
		m_invenItem.AddItem(newItem);
	
	m_NormalInvenCount++;
	
	//???¬° ¬¦¬©?? ?¬»¬¡¬®¡¾¬Ó	
	detailItemWindow = getItemWindowHandleByItemType(newItem);

	if(bIsSavedLocalItemIdx)
		FindIdx = getLocalItemOrderByItemWindow(detailItemWindow, newItem.ID.serverID, -1);
	else 
	{
		FindIdx = -1;	
		//Debug("addNormalItem 0" @ newItem.Name @ FindIdx);

		for(idx=0; idx<CurLimit; idx++)
			if(detailItemWindow.GetItem(idx, curItem))
				if(!IsValidItemID(curItem.ID))
				{				
					FindIdx = idx;
					break;
				}
	}

	//Debug("addNormalItem 1" @ newItem.Name @ FindIdx);
	if(FindIdx > -1)	
		detailItemWindow.SetItem(FindIdx, newItem);		
	else
		detailItemWindow.AddItem(newItem);	
}


function QuestInvenAddItem(ItemInfo newItem)
{
	local int idx;
	local int CurLimit;
	local int FindIdx;
	
	local ItemInfo curItem;	

	FindIdx = -1;
	
	if(bIsSavedLocalItemIdx)FindIdx = getLocalItemOrderByItemWindow(m_questItem, newItem.ID.serverID, -1);	
	else if(m_questItem.GetItem(newItem.Order, curItem))
		if(!IsValidItemID(curItem.ID))FindIdx = newItem.Order ;	

	if(FindIdx < 0)
	{
		CurLimit = m_questItem.GetItemNum();
		for(idx=0; idx<CurLimit; idx++)
		{
			if(m_questItem.GetItem(idx, curItem))
			{
				if(!IsValidItemID(curItem.ID))
				{
					FindIdx = idx;
					break;
				}
			}
		}
	}
	
	if(FindIdx > -1)
		m_questItem.SetItem(FindIdx, newItem);
	else
		m_questItem.AddItem(newItem);

	m_QuestInvenCount++;
}

/********************************************************************************************
 * ¬¡¬Ö?¬ã ¬£¬ê?¬Ý
 * ******************************************************************************************/

// ?¬¨¡Æ??¬¤?¬£ ¬¡¬Ö?¬ã ¬£¬ê?¬Ý
function handleAgathionEquip(ItemInfo a_Info)
{
	local int agathionIndex;

	agathionIndex = GetAgathionIndex(a_Info.Id);
	if(agathionIndex != -1)
	{
		m_equipItem[EQUIPITEM_AGATHION_MAIN + agathionIndex].Clear();
		m_equipItem[EQUIPITEM_AGATHION_MAIN + agathionIndex].AddItem(a_Info);
		m_equipItem[EQUIPITEM_AGATHION_MAIN + agathionIndex].EnableWindow();
	}	
}

// ¡¾¬¯¡Æ¬«¬¡¬® ?¬é¥ì?¬¡¬®¬¨¢ç 
function EarItemUpdate()
{
	local int i;
	local int LEarIndex, REarIndex;

	LEarIndex = -1;
	REarIndex = -1;

	for(i = 0; i < m_EarItemList.Length; ++i)
	{
		switch(IsLOrREar(m_EarItemList[i].ID))
		{
			case -1:
				LEarIndex = i;
				break;
			case 0:
				m_EarItemList.Remove(i, 1);
				i--;
				break;
			case 1:
				REarIndex = i;
				break;
		}
	}

	if(-1 != LEarIndex)
	{
		//~ debug("?¬À¬£¬¬ ¡¾¬¯¡Æ¬«¬¡¬®");
		m_equipItem[EQUIPITEM_LEar].Clear();
		m_equipItem[EQUIPITEM_LEar].AddItem(m_EarItemList[LEarIndex]);
	}

	if(-1 != REarIndex)
	{
		//~ debug("?¬¡¬×?¬£¬¬ ¡¾¬¯¡Æ¬«¬¡¬®");
		m_equipItem[EQUIPITEM_REar].Clear();
		m_equipItem[EQUIPITEM_REar].AddItem(m_EarItemList[REarIndex]);
	}
}

// ¢à¬¿¬¢¬è ?¬é¥ì?¬¡¬®¬¨¢ç
function FingerItemUpdate()
{
	local int i;
	local int LFingerIndex, RFingerIndex;

	LFingerIndex = -1;
	RFingerIndex = -1;

	for(i = 0; i < m_FingerItemList.Length; ++i)
	{
		switch(IsLOrRFinger(m_FingerItemList[i].ID))
		{
		case -1:
			LFingerIndex = i;
			break;
		case 0:
			m_FingerItemList.Remove(i, 1);
			i--;
			break;
		case 1:
			RFingerIndex = i;
			break;
		}
	}

	if(-1 != LFingerIndex)
	{
		m_equipItem[ EQUIPITEM_LFinger ].Clear();
		m_equipItem[ EQUIPITEM_LFinger ].AddItem(m_FingerItemList[ LFingerIndex ]);
	}

	if(-1 != RFingerIndex)
	{
		m_equipItem[ EQUIPITEM_RFinger ].Clear();
		m_equipItem[ EQUIPITEM_RFinger ].AddItem(m_FingerItemList[ RFingerIndex ]);
	}
}

// ¬¡¬Ö?¬ã ?¬é¥ì?¬¡¬®¬¨¢ç
// TODO: kick
function EquipItemUpdate(ItemInfo a_info, optional bool bSwitchExpandEquipBox)
{
	local ItemWindowHandle hItemWnd;
	local ItemInfo TheItemInfo;
	local bool ClearLHand;
	local ItemInfo RHand;
	local ItemInfo Legs;
	local ItemInfo Gloves;
	local ItemInfo Feet;
	local ItemInfo Hair2;
	local int i;
	//~ local int j;
	local int decoIndex;

	local int jewelIndex;	
	
	//Debug("EquipItemUpdate"@ a_Info.Name @ "/" @ a_Info.SlotBitType);

	switch(a_Info.SlotBitType)
	{
		case SBT_UNDERWEAR:		// SBT_UNDERWEAR
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);
			hItemWnd = m_equipItem[ EQUIPITEM_Underwear ];
			break;
		case SBT_REAR:		// SBT_REAR
		case SBT_LEAR:		// SBT_LEAR
		case SBT_REAR + SBT_LEAR:		// SBT_RLEAR
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);
			for(i = 0; i < m_EarItemList.Length; ++i)
			{
				if(IsSameServerID(m_EarItemList[i].ID, a_Info.ID))
				{
					m_EarItemList[i] = a_Info;
					break;
				}
			}

			// ¬×¬ê ¬¤??¬´¬¡¡í ¢Ò¡×¬×¬× ¬¤¬Á¡Æ?
			if(i == m_EarItemList.Length)
			{
				m_EarItemList.Length = m_EarItemList.Length + 1;
				m_EarItemList[m_EarItemList.Length - 1] = a_Info;
			}

			hItemWnd = None;
			EarItemUpdate();
			break;
		case SBT_NECK:		// SBT_NECK
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);
			hItemWnd = m_equipItem[ EQUIPITEM_Neck ];
			break;
		case SBT_RFINGER:	// SBT_RFINGER
		case SBT_LFINGER:	// SBT_LFINGER
		case SBT_RFINGER + SBT_LFINGER:	// SBT_RLFINGER

			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			for(i = 0; i < m_FingerItemList.Length; ++i)
			{
				if(IsSameServerID(m_FingerItemList[ i ].ID, a_Info.ID))
				{
					m_FingerItemList[ i ] = a_Info;
					break;
				}
			}

			// ¬×¬ê ¬¤??¬´¬¡¡í ¢Ò¡×¬×¬× ¬¤¬Á¡Æ?
			if(i == m_FingerItemList.Length)
			{
				m_FingerItemList.Length = m_FingerItemList.Length + 1;
				m_FingerItemList[m_FingerItemList.Length-1] = a_Info;
			}

			hItemWnd = None;
			FingerItemUpdate();
			break;
		case SBT_HEAD:	// SBT_HEAD		
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Head ];
			hItemWnd.EnableWindow();	
			break;
		case SBT_RHAND:	// SBT_RHAND
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);
			SetSigilShieldTextureChange(true);
			hItemWnd = m_equipItem[ EQUIPITEM_RHand ];
			break;
		case SBT_LHAND:	// SBT_LHAND
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_LHand ];
			hItemWnd.EnableWindow();
			break;
		case SBT_GLOVES:	// SBT_GLOVES
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Gloves ];
			hItemWnd.EnableWindow();		
			break;
		case SBT_CHEST:	// SBT_CHEST
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Chest ];			
			break;
		case SBT_LEGS:	// SBT_LEGS
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Legs ];
			hItemWnd.EnableWindow();
			break;
		case SBT_FEET:	// SBT_FEET
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Feet ];
			hItemWnd.EnableWindow();
			break;
		case SBT_BACK:	// SBT_BACK
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Cloak ];		
			hItemWnd.EnableWindow();
			break;	
		case SBT_RLHAND:	// SBT_RLHAND
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_RHand ];
			ClearLHand = true;	

			if(m_equipItem[EQUIPITEM_LHand].GetItem(0,TheItemInfo))
			{
				if(IsSigil(TheItemInfo)|| IsArrow(TheItemInfo))
				{
					ClearLHand = false;
				}
			}
			if(ClearLHand)
			{
				if(Len(a_Info.IconNameEx1)!= 0)
				{
					RHand = a_Info;
					m_equipItem[EQUIPITEM_RHand].Clear();
					m_equipItem[EQUIPITEM_RHand].AddItem(RHand);
					SetSigilShieldTextureChange(false);
				}
				else
				{
					m_equipItem[EQUIPITEM_LHand].Clear();
					SetSigilShieldTextureChange(false);
				}
			}
			break;
		case SBT_ONEPIECE:	// SBT_ONEPIECE
			// ¡í¬å¬¡¬©

			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Chest ];
			a_Info.IconIndex = 1; // ¡í¬å¬¡¬© ?¬¨¬¡¬®¬¥¬¾
			// ¢à¬»¬¢¬è
			Legs = a_Info;
		
			Legs.IconIndex = 2; // ¬©¬±¬¡¬© ?¬¨¬¡¬®¬¥¬¾¬¡¡í ¡¾¬¹¡¤¬¢¬¢¬º?¬». 
			m_equipItem[ EQUIPITEM_Legs ].Clear();
			m_equipItem[ EQUIPITEM_Legs ].AddItem(Legs);
			m_equipItem[ EQUIPITEM_Legs ].DisableWindow();
			break;
		case SBT_HAIR:	// SBT_HAIR
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Hair ];
			break;
		case SBT_ALLDRESS:	// SBT_ALLDRESS
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);
			hItemWnd = m_equipItem[ EQUIPITEM_Chest ];
			Hair2 = a_info;	//?¬ê¡¤??¬£ head¡Æ? ¥ì¬í¡¤¬°¬¡¬¸?¬à?¬Á ¬©¬±¬¢¬è¬×¬× ¬×¬À¬×¬â¬×¢ç ¬¡¬ï?¬Ñ¬£¬é?¬ê???¡© hair2?? ?¬¸?¬¡?¬±?¬». - innowind
			Gloves = a_info;
			Legs = a_info;
			Feet = a_info;
			Hair2.IconName = a_Info.IconNameEx1;
			Gloves.IconName = a_Info.IconNameEx2;
			Legs.IconName = a_Info.IconNameEx3;
			Feet.IconName = a_Info.IconNameEx4;
			m_equipItem[EQUIPITEM_Head].Clear();
			m_equipItem[EQUIPITEM_Head].AddItem(Hair2);
			m_equipItem[EQUIPITEM_Head].DisableWindow();
			m_equipItem[EQUIPITEM_Gloves].Clear();
			m_equipItem[EQUIPITEM_Gloves].AddItem(Gloves);
			m_equipItem[EQUIPITEM_Gloves].DisableWindow();
			m_equipItem[EQUIPITEM_Legs].Clear();
			m_equipItem[EQUIPITEM_Legs].AddItem(Legs);
			m_equipItem[EQUIPITEM_Legs].DisableWindow();
			m_equipItem[EQUIPITEM_Feet].Clear();
			m_equipItem[EQUIPITEM_Feet].AddItem(Feet);
			m_equipItem[EQUIPITEM_Feet].DisableWindow();
			break;
		case SBT_HAIR2:	// SBT_HAIR2
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Hair2 ];
			hItemWnd.EnableWindow();
			break;
		case SBT_HAIRALL:	// SBT_HAIRALL
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);

			hItemWnd = m_equipItem[ EQUIPITEM_Hair ];		
			m_equipItem[ EQUIPITEM_Hair2 ].Clear();
			m_equipItem[ EQUIPITEM_Hair2 ].AddItem(a_info);
			m_equipItem[ EQUIPITEM_Hair2 ].DisableWindow();
			break;
		case SBT_RBRACELET: //SBT_RBracelet
			HandleChkSwitchEquipBox(EQUIPITEM_RBracelet, a_info, bSwitchExpandEquipBox);
			hItemWnd = m_equipItem[ EQUIPITEM_RBracelet ];
			m_equipItem[ EQUIPITEM_RBracelet ].Clear();
			m_equipItem[ EQUIPITEM_RBracelet ].AddItem(a_info);
			m_equipItem[ EQUIPITEM_RBracelet ].EnableWindow();
			break;	
		// ¬¦¡í¬×¢ç??¬×¬× ¥ì¬à
		case SBT_DECO1:	//SBT_Deco1;
		// ?¬¨¡¤¢à?? ¬¢¬ï¬ª??¬µ 
		case SBT_DECO1 + SBT_DECO2:
		case SBT_DECO3 + SBT_DECO4:
		case SBT_DECO5 + SBT_DECO6:
			HandleChkSwitchEquipBox(EQUIPITEM_RBracelet, a_info, bSwitchExpandEquipBox);
			decoIndex = GetDecoIndex(a_info.Id);
			if(decoIndex != -1)
			{
				m_equipItem[ EQUIPITEM_Deco1 + decoIndex ].Clear();
				m_equipItem[ EQUIPITEM_Deco1 + decoIndex ].AddItem(a_info);
				m_equipItem[ EQUIPITEM_Deco1 + decoIndex ].EnableWindow();
			}
			break;
		case 268435456:
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);
			hItemWnd = m_equipItem[ EQUIPITEM_Waist ];
		break;
		case SBT_BROOCH: //Brooch ?¬¨¬¡¬®¬¦¬½¬¡¬© ¡Æ¬Ø?¬Þ
			// m_equipItem_Brooch.Clear();
			//m_equipItem_Brooch.AddItem(a_info);
			//m_equipItem_Brooch.EnableWindow();
			// m_BroochEquiped.ShowWindow();
			HandleChkSwitchEquipBox(EQUIPITEM_Brooch, a_info, bSwitchExpandEquipBox);
			hItemWnd = m_equipItem[ EQUIPITEM_Brooch ];
			m_equipItem[ EQUIPITEM_Brooch ].Clear();
			m_equipItem[ EQUIPITEM_Brooch ].AddItem(a_info);
			m_equipItem[ EQUIPITEM_Brooch ].EnableWindow();
			break;
		case SBT_JEWEL1:	//Brooch_Jewel1;	
			HandleChkSwitchEquipBox(EQUIPITEM_Brooch, a_info,  bSwitchExpandEquipBox);
			jewelIndex = GetJewelIndex(a_info.Id); /// jewel api ¬©¬¬?¬Õ	
		
			if(jewelIndex != -1)
			{
				m_equipItem[EQUIPITEM_Jewel1 + jewelIndex].Clear();
				m_equipItem[EQUIPITEM_Jewel1 + jewelIndex].AddItem(a_info);
				m_equipItem[EQUIPITEM_Jewel1 + jewelIndex].EnableWindow();
			}
		break;
		// 16?¬Ó 12?¬ë ?¬¨¡Æ??¬¤?¬£ ¬×¢ç???¬å¡¤¬° ¡Æ?¬¨¬ß
		case SBT_LBRACELET:	//?¬¨¡Æ??¬¤?¬£ ;	
			//~ debug("?¬¨¬¡¬®¬¦¬½ ¢à¬ê¬ª?" @ a_info.ItemType);
			HandleChkSwitchEquipBox(EQUIPITEM_LBracelet, a_info, bSwitchExpandEquipBox);		
			hItemWnd = m_equipItem[ EQUIPITEM_LBracelet ];
			m_equipItem[ EQUIPITEM_LBracelet ].Clear();
			m_equipItem[ EQUIPITEM_LBracelet ].AddItem(a_info);
			m_equipItem[ EQUIPITEM_LBracelet ].EnableWindow();		
			break;
			//?¬¨¡Æ??¬¤?¬£ ?¡©?¬Ü ¬×¬À¬¡¬°
		case INT64("206158430208"):
			HandleChkSwitchEquipBox(EQUIPITEM_LBracelet, a_info, bSwitchExpandEquipBox);		
			handleAgathionEquip(a_info);	
			break;
		// ?¬¨¬¨?¬¨¬³¬¨¢ç ?¬± 
		default :
			HandleChkSwitchEquipBox(-1, a_info, bSwitchExpandEquipBox);
			break;
	}

	if(None != hItemWnd)
	{
		hItemWnd.Clear();
		hItemWnd.AddItem(a_Info);
	}
}

// ?¬¨¬¡¬®¬¦¬½ ?¬é¥ì?¬¡¬®¬¨¢ç  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function HandleUpdateUserEquipSlotInfo()
{
	EarItemUpdate();
	FingerItemUpdate();

	UpdateTalismanSlotActivation();
	UpdateJewelSlotActivation();//bm
	UpdateAgathionSlotActivation();
}


/********************************************************************************************
 * ¬¡¬Ö?¬ã ¬©¬º¬¢|
 * ******************************************************************************************/
//¬¡¬Ö?¬ã ¬©¬º¬¢| ?¬¤ ¬¦¡í¬×¢ç??¬×¬×, ?¬×?¢ç ?¢à?¬¾ ¬¤?¬×¢ç
function handleRequestUnequipItem(String DragSrcName, itemID infoID, int64 slotbitType)
{	
	local INT64 tmpSlotbitType;

	//Debug("getEquipItemSlotBit" @ DragSrcName);
	if(-1 != InStr(DragSrcName, "Talisman"))
	{		
		//Debug(right(DragSrcName, 1 ));
		switch(right(DragSrcName, 1))
		{
			case "1":
				tmpSlotbitType = SBT_DECO1;
				break;
			case "2":
				tmpSlotbitType = SBT_DECO2;
				break;
			case "3":
				tmpSlotbitType = SBT_DECO3;
				break;
			case "4":
				tmpSlotbitType = SBT_DECO4;
				break;
			case "5":
				tmpSlotbitType = SBT_DECO5;
				break;
			case "6":
				tmpSlotbitType = SBT_DECO6;
				break;
		}
	}
	else if(-1 != InStr(DragSrcName, "Jewel"))
	{
		//Debug(right(DragSrcName, 1 ));
		switch(right(DragSrcName, 1))
		{
			case "1":
				//Debug("1");
				tmpSlotbitType = SBT_JEWEL1;
			break;
			case "2":
				//Debug("2");
				tmpSlotbitType = -9223372036854775808;
			break;
			case "3":
				//Debug("3");
				tmpSlotbitType = SBT_UNDERWEAR;
			break;
			case "4":
				//Debug("4");
				tmpSlotbitType = SBT_REAR;
			break;
			case "5":
				//Debug("5");
				tmpSlotbitType = SBT_LEAR;
			break;
			case "6":
				//Debug("6");
				tmpSlotbitType = SBT_NECK;
			break;
		}
	}	
	else if(-1 != InStr(DragSrcName, "Agathion"))
		tmpSlotbitType =  GetAgathionSlotBitType(right(DragSrcName, 1));
	
	//Debug("SotBitType "  @ tmpSlotbitType @ right(DragSrcName, 3) );

	if(tmpSlotbitType == 0)RequestUnequipItem(infoID, slotbitType);
	else RequestUnequipItem(infoID, tmpSlotbitType);
}

// ¬¡¬Ö¬£¬ê ¬©¬º¬¢| 
function EquipItemDelete(ItemID sID)
{
	local int i;
	local int Index;
	local ItemInfo TheItemInfo;
	//TooltipItem.name = "HIHI";
	//TooltipItem.IconName = "L2ui_ct1.emptyBtn";
	//ClearItemID(TooltipItem.ID);

	//GetTextureHandle(m_WindowName $ ".EquipItem_tooltip").ShowWindow(); 
	//GetTextureHandle(m_WindowName $ ".EquipItem_tooltip").EnableWindow(); 
	//GetTextureHandle(m_WindowName $ ".EquipItem_tooltip").SetTextureCtrlType(ETextureCtrlType.TCT_Control);
	//GetTextureHandle(m_WindowName $ ".EquipItem_tooltip").SetTooltipCustomType(MakeTooltipSimpleText("asdfassdf"));

	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; ++i)
	{
		Index = m_equipItem[ i ].FindItem(sID);	// ServerID
		if(-1 != Index)
		{
			m_equipItem[ i ].Clear();

			//ttp 63832¡¤¬° ¬¤¬Á¡Æ? ¬¦¬ê¬¨¬¢¬¡¡í ?¬×?¨Ï¬¢¬¸¡¾¬Ó ¬¡¡×¬©¬º enable ?¬¤¬¦?
			m_equipItem[ i ].EnableWindow();

			//m_equipItem[ i ].HideWindow();
			//m_equipItem[ i ].AddItem(TooltipItem);
			//m_equipItem[ i ].DisableWindow();			

			// ¬ª¡©¡í¬Þ¬¡¡í ¢à¬è¬×¢ç?¬£ ¡Æ¬Ø?¬Þ, ?¬å¬¡¬¼¬×¢ç?? ¬ª¡Æ ¬×¬â?¬Ù¬¡¬® ¬©??¬¤¥ì¬©?¬à?¬Á¬©¬³?¬».
			if(i == EQUIPITEM_LHand)
			{
				if(m_equipItem[ EQUIPITEM_RHand ].GetItem(0, TheItemInfo))
				{
					if(TheItemInfo.SlotBitType != 16384)
						continue;
				}
			}
			else if(i == EQUIPITEM_RHand)
				SetSigilShieldTextureChange(true);

			//?¬×?¢ç ¬©¬¶ ¡Æ??¬à¥ì? ¬¡¬¸?¬£ ?¬Ü¡¤¬°¬¥? ¡Æ¡Æ¬¡¬® ¡í¬Ú¬¢|
			// ¡¾¬¹¬×¢ç¡Æ¬ß ?¬å ?¬¨¬¡¬®¬¦¬½¬¡¬×¡¤¬° ¬¤¢´?¬è OnSelectItemWithHandle ¬¡¬®??¬¨¢ç¬×| ¢à¬Á¡í¬ï ?¬¤¬¦??¬».
			
			switch(i)
			{
				// ¬×¬À¬¡¬° ?¬¨¬¡¬®¬¦¬½ ¥ì¬Û
				case EQUIPITEM_Brooch :
				case EQUIPITEM_LBracelet :
				case EQUIPITEM_RBracelet :
					setExpandEquipItemButton(i);
					switchEquipBox(i);
				break;
				// ?¡©?¬Ü ?¬¨¬¡¬®¬¦¬½ ¥ì¬Û
				case EQUIPITEM_Deco1:
				case EQUIPITEM_Deco2:
				case EQUIPITEM_Deco3:
				case EQUIPITEM_Deco4:
				case EQUIPITEM_Deco5:
				case EQUIPITEM_Deco6:
					switchEquipBox(EQUIPITEM_RBracelet);
				break;
				case EQUIPITEM_Jewel1:
				case EQUIPITEM_Jewel2:
				case EQUIPITEM_Jewel3:
				case EQUIPITEM_Jewel4:
				case EQUIPITEM_Jewel5:
				case EQUIPITEM_Jewel6:
					switchEquipBox(EQUIPITEM_Brooch);
				break;
				case EQUIPITEM_AGATHION_MAIN :
				case EQUIPITEM_AGATHION_SUB1 :
				case EQUIPITEM_AGATHION_SUB2 :
				case EQUIPITEM_AGATHION_SUB3 :
				case EQUIPITEM_AGATHION_SUB4 :
					switchEquipBox(EQUIPITEM_LBracelet);
				break;
			}
		}
	}
}

// ¬¦¬©¬¡¬×¡¤¬° ?¡¾¬¦¬¤ ¥ì¬©?¬à?¬Á ¬©¬´ ?¬¨¬¡¬®¬¦¬½¥ì¬Û¬¡¬© ?¬å ??¡¤¬¶ ¬¤¢´?¬Þ¡¾¬Ó
// ?¬å ?¬¨¬¡¬®¬¦¬½¬¡¬® ?¬ê¬¡¬×¬×¬Û ¬¦¡þ¬×? ¥ì¬©?¬à ¬¢¬è¬¢¬è ?¬¬?¬£?¬».
// ->>>> ¬¦¬ê¬¨¬¢ ¬¡¬®??¡¤¬° ¢à¬è¬¨¡Æ¬¡¬×¡¤¬° ??¡Æ¬Ø 
// ¬¡¬Ö?¬ã ¬©¬º¬¢| ?¬¤ Show ¬¤?¬×¢ç ¬¢¬º?¬». 
function setExpandEquipItemButton(int i)
{
	switch(i)
	{
		case EQUIPITEM_RBracelet:
			EquipItem_RBracelet_Button.ShowWindow();
		break;
		case EQUIPITEM_LBracelet:
			EquipItem_LBracelet_Button.ShowWindow();
			break;
		case EQUIPITEM_Brooch:
			EquipItem_Brooch_Button.ShowWindow();
			break;
	}
}


/********************************************************************************************
 * ?¬¨¬¡¬®¬¦¬½ ¡í¬Ú¬¢|
 * ******************************************************************************************/
function InvenDelete(ItemInfo item)
{
	local int FindIdx;
	local int DetailFindIdx;
	local ItemInfo ClearItem;

	local itemWindowHandle detailItemWindow;

	detailItemWindow = getItemWindowHandleByItemType(item);
	ClearItemID(ClearItem.ID);
	//?¬¨¬¡¬®¬¥¬¾ ¬ª¡Æ??¬ª¡© ?¬°?¬² ¬¦¬º??¬¤¬¥ ¬¤?¬×¢ç
	ClearItem.IconName = "L2ui_ct1.emptyBtn";
	FindIdx = m_invenItem.FindItem(item.ID);
	DetailFindIdx = detailItemWindow.FindItem(item.ID);

	//Debug("InvenDelete" @ FindIdx @  DetailFindIdx);
	if(FindIdx != -1)
	{
		m_invenItem.SetItem(FindIdx, ClearItem);
		detailItemWindow.SetItem(DetailFindIdx, ClearItem);
		m_NormalInvenCount--;
	}
}

function QuestInvenDelete(ItemInfo item)
{
	local int FindIdx;
	local ItemInfo ClearItem;

	FindIdx = m_questItem.FindItem(item.ID);
	if(FindIdx != -1)
	{
		//¬¢¬è?¬Þ¡Æ¬ß ?¬»?¬¤ ?¬å ??¡¤¬¶ ?¬¨¬¡¬®¬¦¬½¬¡¬×¡¤¬° ¬¤¢´?¬è¬¢¬º?¬».
		m_questItem.DeleteItem(FindIdx);
		m_QuestInvenCount--;

		ClearItemID(ClearItem.ID);
		ClearItem.IconName = "L2ui_ct1.emptyBtn";
		m_questItem.AddItem(ClearItem);		
	}
}

/********************************************************************************************
 * ?¬¨¬¡¬®¬¦¬½ ¬¡¨Ï¥ì¥ì?¬Þ  ¬¦¡þ¬×¢ç?¬à
 * ******************************************************************************************/
function HandleClear()
{
	// tt 61481 ¥ì¬à¬¡¬© ¢à¢ç¬¢| ?¬×?¨Ï¬¢¬è¡Æ¬ß ¬¡¬¸¬¡¡í ¢Ò¡×?¬£ ¬¡¡×¬¥? ¡Æ?¬¡¡í ¬¡¬ì¬¡¬Ö ¬©¬·?¬±?¬».
	if(m_hOwnerWnd.IsShowWindow())saveLocalItemOrder();	

	InvenClear();
	invenItem_1Clear();
	invenItem_2Clear();
	invenItem_3Clear();
	invenItem_4Clear();	
	QuestInvenClear();
	EquipItemClear();
	
	m_EarItemList.Length = 0;
	m_FingerItemLIst.Length = 0;
	m_DecoItemList.Length = 0;

	InvenLimitUpdate();

	bIsQuestItemList = false;
}

// ¬¡¬Ö?¬ã ?¬¨¬¡¬®¬¦¬½ ¬¦¡þ¬×¢ç?¬à 
function EquipItemClear()
{
	local int i;

	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; ++i)
		m_equipItem[i].Clear();

	setExpandEquipItemButton(EQUIPITEM_Brooch);
	setExpandEquipItemButton(EQUIPITEM_LBracelet);
	setExpandEquipItemButton(EQUIPITEM_RBracelet);
}

// ¬¡¬±¢à¬¿ ¬¡¬°?? ¬¦¡þ¬×¢ç?¬à
function InvenClear()
{	
	m_invenItem.Clear();	
	m_NormalInvenCount = 0;
}

function QuestInvenClear()
{	
	m_questItem.Clear();
	m_QuestInvenCount = 0;
}

function invenItem_1Clear()
{
	m_invenItem_1.Clear();
}

function invenItem_2Clear()
{
	m_invenItem_2.Clear();
}

function invenItem_3Clear()
{
	m_invenItem_3.Clear();
}

function invenItem_4Clear()
{
	m_invenItem_4.Clear();
}

/********************************************************************************************
 * ?¬¨¬¡¬®¬¦¬½ ¬¡¡×¬¥? ¬¡¬ì¬¡¬Ö
 * ******************************************************************************************/
// ?¬¨¬¡¬®¬¦¬½¬¡¬© ?¬ê?¡©¬×| local¡¤¬° ¬¡¬ì¬¡¬Ö ¬©¬º ¥ì¬´.
// ?¬¨¬¡¬®¬¦¬½¬¡¡í ?¬¦¡¾¬Õ ¡Æ¬Ø?¬Þ, ?¬¨¬¡¬®¬¦¬½ ¬¦¡þ¬×¢ç?¬à ¬¡¬î?? ¬¡¬ì¬¡¬Ö ¬©¬¶.
function saveLocalItemOrder()
{
	local int  i ;	
	
	bIsSavedLocalItemIdx = true;
	// Debug("saveLocalItemOrder" @ itemSwapedServerID.length);
	for(i = 0 ; i < m_invenItem.GetItemNum(); i ++)
	{		
		saveServerID(m_invenItem, i, itemSwapedServerID, itemSwapedIdx); 		
		saveServerID(m_invenItem_1, i, itemSwapedServerID_1, itemSwapedIdx_1); 		
		saveServerID(m_invenItem_2, i, itemSwapedServerID_2, itemSwapedIdx_2); 		
		saveServerID(m_invenItem_3, i, itemSwapedServerID_3, itemSwapedIdx_3); 		
		saveServerID(m_invenItem_4, i, itemSwapedServerID_4, itemSwapedIdx_4); 				
	}	

	for(i = 0; i < m_questItem.GetItemNum(); i++)		
		saveServerID(m_questItem, i, itemSwapedServerID_q, itemSwapedIdx_q); 
}

function saveServerID(ItemWindowHandle targetWindow, int idx,  out array<int> serverIDList, out array<int> SwapedIdx)
{		
	local iteminfo invenInfo;	

	targetWindow.GetItem(idx , invenInfo);
	
	if(invenInfo.ID.serverID != -1)
	{
		invenInfo.Order = idx;
		idx = serverIDList.length;
		serverIDList.length = serverIDList.length  + 1 ;
		serverIDList[ idx ] = invenInfo.ID.serverID;
		SwapedIdx[ idx ] = invenInfo.Order;
		//Debug( "saveServerID" @ invenInfo.Name @  invenInfo.Order @ targetWindow.GetWindowName());
	}
}


// ?¬¨¬¡¬®¬¦¬½ order¬¡¡í ¬¤?¬¡?
function int getLocalItemOrder(int serverID, array<int> serverIDList, array<int> SwapedIdx, int defaultOrder )
{
	local int i ;
	for(i = 0 ; i < serverIDList.Length ; i ++) 	
	{		
		if(serverIDList[ i ] == serverID)
			return SwapedIdx[ i ];
	}

	return defaultOrder;
}

function int getLocalItemOrderByItemWindow(itemWindowHandle targetWindow, int serverID, int defaultOrder)
{
	switch(targetWindow)
	{				
		case m_invenItem_1:
			return getLocalItemOrder(serverID, itemSwapedServerID_1, itemSwapedIdx_1, defaultOrder);		
		case m_invenItem_2:
			return getLocalItemOrder(serverID, itemSwapedServerID_2, itemSwapedIdx_2, defaultOrder);		
		case m_invenItem_3:
			return getLocalItemOrder(serverID, itemSwapedServerID_3, itemSwapedIdx_3, defaultOrder);		
		case m_invenItem_4:
			return getLocalItemOrder(serverID, itemSwapedServerID_4, itemSwapedIdx_4, defaultOrder);		
		case m_questItem:			
			return getLocalItemOrder(serverID, itemSwapedServerID_q, itemSwapedIdx_q, defaultOrder);
	}
	return defaultOrder;
}

// ?¬¨¬¡¬®¬¦¬½ ¬¡¡×¬¥?¬×| ?¡©¢à¬è?? ¬¡¬ì¬¡¬Ö ¬©¬¶.
function SaveInventoryOrder()
{
	local int idx;
	local int InvenLimit;

	local ItemInfo item;
	local array<ItemID> IDList;
	local array<int> OrderList;
	
	// ¬¡¬±¢à¬¿ ?¬¨¬¡¬®¬¦¬½ ¬¡¡×¬¥? ¬¡¬ì¬¡¬Ö
	InvenLimit = m_invenItem.GetItemNum();
	
	for(idx=0; idx<InvenLimit; idx++)
	{
		if(m_invenItem.GetItem(idx, item))
			if(IsValidItemID(item.ID))
			{
				IDList.Insert(IDList.Length, 1);
				IDList[IDList.Length-1] = item.ID;
				
				OrderList.Insert(OrderList.Length, 1);
				OrderList[OrderList.Length-1] = item.Order;

			//	Debug("¡¾¬Ó?¡í order" @ item.Order @  class'UIDATA_ITEM'.static.GetItemName(item.ID));
			}
	}

	//if(IDList.Length > 0)
	//	RequestSaveInventoryOrder(IDList, OrderList);
	
	if(IDList.Length > 0)
	{
	//	Debug("RequestSaveInventoryOrder");
		RequestSaveInventoryOrder(IDList, OrderList);
	}

	// ¬©¬è¬¡¬Ù 6, 12¡Æ? ¡Æ?¡¤¬°?¡© ¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½ ?¬è¬×| ¬¡¬ì¬¡¬Ö ?¬¤¬¦??¬».
	//SetOptionInt("Game", "ItemInventoryCol",  currentInvenCol);

	// ¬¡¬°??¬¦¬Õ¬×¢ç ¬¡¬ì¬¡¬Ö ¬ª¬¥ false ¬¤?¬×¢ç ¬©¬³?¬».	
	bIsSavedLocalItemIdx = false;
	itemSwapedIdx.Length = 0 ;
	itemSwapedIdx_1.Length = 0 ;
	itemSwapedIdx_2.Length = 0 ;
	itemSwapedIdx_3.Length = 0 ;
	itemSwapedIdx_4.Length = 0 ;
	itemSwapedIdx_q.Length = 0 ;
	itemSwapedIdx_a.Length = 0 ;
	itemSwapedServerID.Length = 0 ;
	itemSwapedServerID_1.Length = 0 ;
	itemSwapedServerID_2.Length = 0 ;
	itemSwapedServerID_3.Length = 0 ;
	itemSwapedServerID_4.Length = 0 ;
	itemSwapedServerID_q.Length = 0 ;
	itemSwapedServerID_a.Length = 0 ;
}

///********************************************************************************************
// * ¬¨¬©?¡Æ ¬©¬¶?¬è ¥ì¬Û
// * ******************************************************************************************/
//// ?¬¨¬¨?¬¨¬³¬¨¢ç ¬¡¬°¡Æ?? ?¬¨¬¨?¬¨¬³¬¨¢ç ¬¡¨Ï¥ì¥ì?¬Þ ¬¨??¬è ¡¤¬Û¬¡¬°¬¢¬è ?¨Ï?¬° 
//function bool IsArtifactRuneItem(ItemInfo info)
//{
//	//Debug("IsArtifactRuneItem0:" @ String(info.slotBitType)@ "/" @ String(info.slotBitType)== "18014398509481984" @ "/" @  info.slotBitType == 18014398509481984);
//	//Debug("IsArtifactRuneItem1:" @info.slotBitType == 18014398509481984);
//	//Debug("IsArtifactRuneItem2:" @info.slotBitType == 144115188075855872);
//	//Debug("IsArtifactRuneItem3:" @info.slotBitType == 1152921504606846976);
//	//Debug("IsArtifactRuneItem4:" @info.slotBitType == 4398046511104);
	
//	switch(info.slotBitType)
//	{   // ?¬¨¬¨?¬¨¬³¬¨¢ç ¬¨??¬è¡¤¬Û 1
//		case ARTIFACTTYE_TYPE1 :
//		// ?¬¨¬¨?¬¨¬³¬¨¢ç ¬¨??¬è¡¤¬Û 2
//		case ARTIFACTTYE_TYPE2 :
//		// ?¬¨¬¨?¬¨¬³¬¨¢ç ¬¨??¬è¡¤¬Û 3
//		case ARTIFACTTYE_TYPE3 :
//		// ?¬¨¬¨?¬¨¬³¬¨¢ç ¬¡¬±¢à¬¿¡¤¬Û
//		case ARTIFACTTYE_NORMAL :
//			return true;
//		break;
//	}
//	//Debug("IsArtifactItem" @ EItemtype(info.ItemType)) ;
//	return false;
//}


// ¬¡¬Ö?¬ã ¬¡¬°¡Æ?
function bool IsEquipItem(out ItemInfo info)
{
	return info.bEquipped;
}

// ¬¥¬ë??¬¨¢ç ?¬¨¬¡¬®¬¦¬½ ¬¡¬°¡Æ??
function bool IsQuestItem(out ItemInfo info)
{
	return EItemType(info.ItemType) == ITEM_QUESTITEM;
}

// ¡¾¬¯¡Æ¬«¬¡¬® ¬¡¬°¡Æ??
function int IsLOrREar(ItemID sID)
{
	local ItemID LEar;
	local ItemID REar;
	local ItemID LFinger;
	local ItemID RFinger;

	GetAccessoryItemID(LEar, REar, LFinger, RFinger);

	if(IsSameServerID(sID, LEar))
		return -1;
	else if(IsSameServerID(sID, REar))
		return 1;
	else
		return 0;
}

// ¢à¬¿¬¢¬è ¬¡¬°¡Æ??
function int IsLOrRFinger(ItemID sID)
{
	local ItemID LEar;
	local ItemID REar;
	local ItemID LFinger;
	local ItemID RFinger;

	GetAccessoryItemID(LEar, REar, LFinger, RFinger);

	if(IsSameServerID(sID, LFinger))
		return -1;
	else if(IsSameServerID(sID, RFinger))
		return 1;
	else
		return 0;
}

//?¡þ?¬¤ ?¬Ý ¬¡¬°¡Æ??
function bool IsBowOrFishingRod(ItemInfo a_Info)
{
	//~ debug("?¬×?¬Þ¡Æ¬©¬¡¬© ¢à¬ê¬ª??"@  a_Info.WeaponType);
	// ¬ª¡Æ, ¡¦¬ì?¬¤?? ¬¦¨Ï¡¤¬°???¬×?¬Þ, ?¬Ù?¬· ¬¦¨Ï¡¤¬°???¬×?¬Þ
	switch(AttackType(a_Info.WeaponType))
	{
		case AT_BOW:
		case AT_FISHINGROD:
		case AT_CROSSBOW:
		case AT_TWOHANDCROSSBOW:
		return true;
	}

	return false;
}

// ¬ª¡©¡í¬Þ ¬¡¬°¡Æ??
function bool IsArrow(ItemInfo a_Info)
{
	return a_Info.bArrow;
}

// ¥ì¬Ö¡¤?¡¾¬¹ ?¬´??¡Æ? ¬¡¬°??¬¦¬Õ¬×¢ç ¬¡¬°¡Æ??
function bool isDragSrcInventory(string DragSrcName)
{
	switch(DragSrcName)
	{
		case "InventoryItem": 
		case "QuestItem": 
		case "PetInvenWnd": 
		case "InventoryItem_1": 
		case "InventoryItem_2": 
		case "InventoryItem_3": 
		case "InventoryItem_4": 
			return true;
	}
	
	if(-1 != InStr(DragSrcName, "EquipItem"))return true ;

	return false;	
}

/*
* ¡í¬Ù?¬Ý ¬©¬±?¬£ ¡Æ¬é¬¡¬® ?¬ê¬¡?
// ¬¡¬Ö?¬¥ ?¬¨¬¡¬®¬¦¬½ ¬¡¬°¡Æ????? 
function INT64 IsDecoItem(ItemInfo a_Info)	// INT -> INT64, Jewel ¬¤¬Á¡Æ? - by y2jinc(2013. 9. 2)
{
	return a_Info.SlotBitType;
}

//¡Æ?¬¡¬°¬¤?¡Æ¬ß, ¬©¬é¬×¬¯¬¤?¡Æ¬ß, ¬ª¡©¢à¡Æ¬¤?¡Æ¬ß, ¡¾?¬ª?¬¤?, ¡í¬å¬¢?¡¾¬×¬×¬¦, ¬¨¬©¬×¬¦¬¤?, ¡Æ?¬¡¬°¬¨¬©¬×¬¦, ¡Æ?¬¡¬°¡¾¬×¬×¬¦, ¬¨¬©¬×¬¦?¬Ý¬©¬Ñ ¬¤?¬¡¬® ¢Ò¡Æ¬¡¬¸¬¡¡í ¡Æ¬Ø?¬Þ ¢à¡ì?¬¤¬©¬±?¬£ ¡¤¬Ù¬¨?
//?¬»¬×?¡í¬Ù¢Ò¬é¬¡¬© ¡Æ?¬¡¬°¡í¬å¬¢? ¬¤????¡© ?¡í¡Æ? ¡¾¬×¬×¬¦¬©¬´¢Ò¡×?¬£ ?¡©¡¤¬¢?¬Á¬©¬¶ --;; - innowind
function bool IsShowInventoryWndUpt()
{
	local WindowHandle m_warehouseWnd;
	local WindowHandle m_privateShopWnd;
	local WindowHandle m_tradeWnd;
	local WindowHandle m_shopWnd;
	local WindowHandle m_multiSellWnd;
	local WindowHandle m_deliverWnd;
	local PrivateShopWnd m_scriptPrivateShopWnd;
	local WindowHandle m_PostBoxWnd, m_PostWriteWnd, m_PostDetailWnd_General, m_PostDetailWnd_SafetyTrade; 

	local WindowHandle m_sellingAgencyWnd;
	
	m_warehouseWnd = GetWindowHandle("WarehouseWnd");					//¡Æ?¬¡¬°¬¤?¡Æ¬ß, ¬©¬é¬×¬¯¬¤?¡Æ¬ß, ¬ª¡©¢à¡Æ¬¤?¡Æ¬ß
	m_privateShopWnd = GetWindowHandle("PrivateShopWnd");					//¡Æ?¬¡¬°¬¨¬©¬×¬¦, ¡Æ?¬¡¬°¡¾¬×¬×¬¦
	m_tradeWnd = GetWindowHandle("TradeWnd");							//¡¾?¬ª?
	m_shopWnd = GetWindowHandle("ShopWnd");							//¡í¬å¬¢?¡¾¬×¬×¬¦, ¬¨¬©¬×¬¦
	m_multiSellWnd = GetWindowHandle("MultiSellWnd");						//¡í¬å¬¢?¡¾¬×¬×¬¦, ¬¨¬©¬×¬¦
	m_deliverWnd = GetWindowHandle("DeliverWnd");							//¬ª¡©¢à¡Æ?¡©?¬ã??
	m_scriptPrivateShopWnd = PrivateShopWnd(GetScript("PrivateShopWnd"));

	m_PostBoxWnd = GetWindowHandle("PostBoxWnd");
	m_PostWriteWnd = GetWindowHandle("PostWriteWnd");
	m_PostDetailWnd_General = GetWindowHandle("PostDetailWnd_General");
	m_PostDetailWnd_SafetyTrade = GetWindowHandle("PostDetailWnd_SafetyTrade");

	m_sellingAgencyWnd = GetWindowHandle("SellingAgencyWnd"); // ¬¨¬©¬×¬¦?¬Ý¬©¬Ñ


	if(m_warehouseWnd.IsShowWindow())
		return false;

	if(m_warehouseWnd.IsShowWindow())
		return false;

	if(m_tradeWnd.IsShowWindow())
		return false;
	
	if(m_shopWnd.IsShowWindow())
		return false;
	
	if(m_multiSellWnd.IsShowWindow())
		return false;
	
	if(m_deliverWnd.IsShowWindow())
		return false;
	
	if(m_privateShopWnd.IsShowWindow()&& m_scriptPrivateShopWnd.m_type == PT_Sell)
		return false;


	if(m_PostBoxWnd.IsShowWindow()|| m_PostWriteWnd.IsShowWindow()|| m_PostDetailWnd_General.IsShowWindow()|| m_PostDetailWnd_SafetyTrade.IsShowWindow())
		return false;

	if(m_sellingAgencyWnd.IsShowWindow())
		return false;
	
	return true;
}
*/


/********************************************************************************************
 * data
 * ******************************************************************************************/
// ¬¡¬î¬¤??? ?¬µ¬©¬±?¬£ ¬¡¬Ö?¬ã ?¬¨¬¡¬®¬¦¬½ ?¬è¡¤¢ç
function int EquipNormalItemGetItemNum()
{
	local int i;
	local int ItemNum;

	// ?¬¨¬¨?¬¨¬³¬¨¢ç ?¬¨¬¡¬®¬¦¬½ ¬¡¬®¬¡¬î ¡¾¬à¬¢¬è
	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; ++i)
	{
		if(m_equipItem[i].m_pTargetWnd != none)
		{
			if(m_equipItem[i].IsEnableWindow())	// ??¬¨¢ç?¬¨¬¡¬®¬¦¬½¬¡? ¬©¬±??¬×¬× ???¬». 
			{
				ItemNum = ItemNum + m_equipItem[i].GetItemNum();
			}
		}
	}
	return ItemNum;
}

// ?¡©¢à¬è ?¬¨¬¡¬®¥ì¬â?? ¥ì¬í¢Ò¬å ?¬¨¬¡¬®¬¦¬½ ¬¡¨Ï¥ì¥ì?¬Þ¬×| ¬¤?¬¡?
function bool EquipItemFind(ItemID sID)
{
	local int i;
	local int Index;
	local ItemInfo iInfo;

	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; ++i)
	{
		if(m_equipItem[i].GetItemNum() > 0)
		{
			m_equipItem[i].GetItem(0, iInfo);
		}
		Index = m_equipItem[i].FindItem(sID);	// ServerID
		if(-1 != Index)
			return true;
	}

	return false;
}


// ?¬¾?¬°???¡© ¬¡¬°??¬¦¬Õ¬×¢ç ¬¥¡ì?¬à¬¨¢ç¬×| ¢à¬À?¬¨ ¡Æ?¢Ò¡× ¡í¬Ù?¬Ý
function int getCurrentInventoryItemCount()
{
	return pInventoryItemCount;
}

//?¬¾?¬°???¡© ¬¡¬°??¬¦¬Õ¬×¢ç ?¬¨¬¡¬®¬¦¬½ ¬¡¨Ï¥ì¥ì?¬Þ ¬¦¬© ¬¡¬®¬×¡×¬¡¡í ¡Æ?¬¢¢ç¡Æ?¢Ò¡× ¡í¬Ù?¬Ý
// ¬©¬è¬¡¬Ù PetInvenWnd ???¡©¬×¬× ¡í¬Ù?¬Ý ¥ì¬¨?¬».
function bool getInventoryItemWndName(string str)
{
	local int i;
	for(i = 0; i <= TAB_LENGTH; ++i)
	{
		if(i == 0)
		{
			if(("InventoryItem")== str)
			{
				return true;
			}
		}
		else if(("InventoryItem_" $ i)== str)
		{
			return true;
		}
	}
	return false;
}

// ?¬¾?¬°???¡©, ?¬¨¬¡¬®¬¦¬½¬¡¡í ¬¡¬°??¬¦¬Õ¬×¢ç?? ¡Æ?¬¢¬è¡Æ¬ß ¬¡¬¸¬¡¬×¬×¬Û, ?¬¨¬¡¬®¬¦¬½ ¬¢¢´?¬×¬×| ?¬ä?¬à ?¬£?¬».(2014.03.18, ?¬¾¬©¬î??¡Æ¬Ø???¡© ¡í¬Ù?¬Ý¬©¬±¡¤¬¢¡Æ¬ß ¬×¬×¥ì¬Û?¬à ?¬ç¬¡?)
// onlyUseClassID = true¡¤¬° ?¬¸¬¡¬×¬×¬Û serverID ¬×| ¡í¬Ù?¬Ý¬©¬±¬¢¬è ?¬¬¡Æ¬ß ?¬¡¬¢¬é classID¡Æ? ¡Æ¡Æ¬¡?¡Æ¬¯¬¡¡í ¬¤??¬£?¬».(?¬è¡¤¢ç?? ?¬¨¬¡¬®¬¦¬½¬×¬× ¡í¬Ù?¬Ý¬©¬º?¬Á ¬©¬³?¬»)
function bool getInventoryItemInfo(ItemID id, out ItemInfo InvenItemInfo, optional bool onlyUseClassID)
{
	local bool bHasItem;
	local int i, index;
	local ItemInfo tempOutItemInfo, tmpItemInfo;

	bHasItem = false;

	// ?¬è¡¤¢ç?? ?¬¨¬¡¬®¬¦¬½¬¡? findItem ¬¡¬×¡¤¬° ?¡©¢à¬è ?¬¨¬¡¬®¥ì¬â ¬¨¬é¬©¬¶¬©¬º?¡© ¬¤?¬¡¬×¬×¬Û ?¬ª¥ì¬©¡Æ¬ß, classID ¬×¬×¬¡¬×¡¤¬° ¡Æ¬­¡í¬è¬©¬º?¬Á ¬©¬³?¬».
	if(onlyUseClassID)	index = m_invenItem.FindItemByClassID(id);
	else index = m_invenItem.FindItem(id);
	
	if(index > -1){ m_invenItem.GetItem(index, InvenItemInfo); bHasItem = true; }

	// ¬¥¬ë??¬¨¢ç ?¬¨¬¡¬®¬¦¬½ 
	index = m_questItem.FindItem(id);
	if(index > -1){ m_questItem.GetItem(index, InvenItemInfo); bHasItem = true; }

	// ¬¡¬Ö?¬ã ??¡¤¬¶ 
	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; i++)
	{
		// index = m_equipItem[i].FindItem(id);
		if(onlyUseClassID)	index = m_equipItem[i].FindItemByClassID(id);
		else index = m_equipItem[i].FindItem(id);

		if(index > -1)
		{
			m_equipItem[i].GetItem(index, tempOutItemInfo);

			switch(i)
			{
				// ?¬¡¬×? ?¬· ?¬ã¡¾? ¬ª¬¥ ¡Æ¡Æ¬¡¬×¬×¬Û ?¬¸¬¢¬è ?¬¬¬¡?
				case EQUIPITEM_LHand :
					m_equipItem[EQUIPITEM_RHand].GetItem(0,tmpItemInfo);
				break;
				// ¬©¬Þ?¬à ?¬©???¡©¬×¢ç 1¡Æ¬ì ?¬ã¡¾?¬ª¬¥ ¡Æ¡Æ¬¡¬×¬×¬Û ?¬¸¬¢¬è ?¬¬¬¡?
				case EQUIPITEM_Hair2:
					m_equipItem[EQUIPITEM_Hair].GetItem(0,tmpItemInfo);		
				break;
			}

			
			// 2015-06-03 ¥ì¬ï¡Æ¬¦ ¡Æ¬ß¬¥??¬» ?¬×?¬± ¬¡¬®¡Æ¬¶ ¬¡¬Á¬×¬ê ¥ì¬©?¬à ¬¡¬¸?¬£¥ì¬ß ¬©¬º?¡© ?¬è¬¢¢´.
			if(tempOutItemInfo.ID.serverID == tmpItemInfo.ID.serverID)continue;
			// ¡¾¬Ó¬¢¬×?¬§..
			//if(InvenItemInfo.ID.serverID == tmpItemInfo.ID.serverID)continue;

			InvenItemInfo = tempOutItemInfo;
			bHasItem = true;
			break;
		}
	}

	return bHasItem;
}

// ¬©¬º?¬Ù ¬¡¬°??¬¦¬Õ¬×¢ç?? ?¬¨¬¡¬®¬¦¬½¬¡¬® ¬×¬à¡Æ? ¬¡¬¸???
function INT64 getItemCountByClassID(int classID)
{
	local int i, itemNum;
	local INT64 totalCount;
	local ItemInfo tempOutItemInfo, tmpItemInfo, info;
	local ItemID ID;

	ID.ClassID = classID;

	class'UIDATA_ITEM'.static.GetItemInfo(ID, info);

	// ?¬è¡¤¢ç?? ?¬¨¬¡¬®¬¦¬½¬¡¬°¡Æ??
	if(IsStackableItem(info.ConsumeType))
	{
		if(getInventoryItemInfo(ID, tempOutItemInfo, true))
		{
			return tempOutItemInfo.ItemNum;
		}
	}
	else
	{
		// ¬¡¬°??¬¦¬Õ¬×¢ç Total
		totalCount = getItemWindowCountByClassID(classID, m_invenItem);
		
		// ¬¥¬ë??¬¨¢ç ?¬¨¬¡¬®¬¦¬½ 
		totalCount = totalCount + getItemWindowCountByClassID(classID, m_questItem);
		
		// ¬¡¬Ö?¬ã ??¡¤¬¶ 
		for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; i++)
		{
			itemNum = m_equipItem[i].GetItemNum();
			
			if(itemNum == 0)continue;

			m_equipItem[i].GetItem(0, tempOutItemInfo);

			switch(i)
			{
				// ?¬¡¬×? ?¬· ?¬ã¡¾? ¬ª¬¥ ¡Æ¡Æ¬¡¬×¬×¬Û ?¬¸¬¢¬è ?¬¬¬¡?
				case EQUIPITEM_LHand :
					m_equipItem[EQUIPITEM_RHand].GetItem(0,tmpItemInfo);
				break;
				// ¬©¬Þ?¬à ?¬©???¡©¬×¢ç 1¡Æ¬ì ?¬ã¡¾?¬ª¬¥ ¡Æ¡Æ¬¡¬×¬×¬Û ?¬¸¬¢¬è ?¬¬¬¡?
				case EQUIPITEM_Hair2:
					m_equipItem[EQUIPITEM_Hair].GetItem(0,tmpItemInfo);		
				break;
			}

			if(tempOutItemInfo.ID.serverID != tmpItemInfo.ID.serverID)
			{
				totalCount = totalCount + getItemWindowCountByClassID(classID, m_equipItem[i]);
			}
		}
	}

	return totalCount;
}

// ?¬¨¬¡¬®¬¦¬½ ¬¡¨Ï¥ì¥ì?¬Þ???¡© ¬©¬º?¬Ù ClassID ?¬¨¬¡¬®¬¦¬½¬¡¬© ?¬è¡¤¢ç¬¡¡í ?¬ä?¬£?¬».
function INT64 getItemWindowCountByClassID(int ClassID, ItemWindowHandle targetItemWindow)
{
	local int i, cnt, index, totalItemNum;
	local ItemInfo tmInfo, tempOutItemInfo;
	
	local ItemInfo info;
	local ItemID ID;

	ID.ClassID = ClassID;

	class'UIDATA_ITEM'.static.GetItemInfo(ID, info);

	// ?¬è¡¤¢ç?? ?¬¨¬¡¬®¬¦¬½¬¡¬°¡Æ??
	if(IsStackableItem(info.ConsumeType))
	{
		index = m_invenItem.FindItemByClassID(ID);
		
		if(getInventoryItemInfo(ID, tempOutItemInfo, true))
		{
			return tempOutItemInfo.ItemNum;
		}
	}

	totalItemNum = targetItemWindow.GetItemNum();
	for(i = 0; i < totalItemNum; i++)
	{
		targetItemWindow.GetItem(i, tmInfo);

		if(tmInfo.Id.ClassID == ClassID)
		{
			cnt++;
		}
	}
	return cnt;
}

// ¬¡¬Ö?¬ã¥ì¬ª?¬¨¬¡¬®¬¦¬½¬¡¡í¬¨¬é¬©¬¶¬©¬³¬×¬â¥ì¬Ù?¬¨¬¡¬®¬¦¬½¬¡¡í¢à¬Ú?¡©¡¤¬°¬×¢ç¬¦¬±¢à¬À?¬£?¬».
// bExceptionEquipItem = true ¬×¬Û¬¡¬Ö?¬ã¬×|¬¨¬é¬©¬¶¬©¬±¬¢¬è?¬¬?¬£?¬».
function array<ItemInfo> getInventoryAllItemArray(optional bool bExceptionEquipItem)
{
        local int index;

        local array<ItemInfo> itemArray, totalItemArray;

        class'UIDATA_INVENTORY'.static.GetAllInvenItem(totalItemArray);

        for(index = 0; index < totalItemArray.Length; index++)
        {
               if(totalItemArray[index].Id.ClassID <= 0)continue;
               itemArray[ itemArray.Length] = totalItemArray[index];
        }
        
        if(bExceptionEquipItem == false)
        {
               // ¬¡¬Ö?¬ã??¡¤¬¶
               itemArray = L2Util(GetScript("L2Util")).pushItemInfoArray(itemArray, getInventoryEquipItemArray()); 
        }

        return itemArray;
}


// ¬¡¬Ö?¬ã¬¤??? ¬¡¬¸?¬£ ?¬¨¬¡¬®¬¦¬½¥ì¬Û¬×¬× ¬×¢ç¬¦¬±
function array<ItemInfo> getInventoryEquipItemArray()
{
	local int i, j ;//, itemNum ;

	local bool isSameItem;

	local array<ItemInfo> itemArray;

	local ItemInfo InvenItemInfo ;//, tmpItemInfo;
	
	// ?¬»¬¦¨Ï ?¬à?¬Ü?¬¦ ¡¤¬ë¬¡¬© ?¬¨¬¡¬®¬¦¬½(¡Æ??? ¬¡¬Ö¬£¬ê ?¬¤ ?¬»¬×? ?¬¨¬¡¬®¬¦¬½¥ì¥ì ¬¡¬Ö¬£¬ê¬¡¬×¡¤¬° ¬¡¬°?¬¥)¢Ò¡×¢à¢ç?? ¡Æ??? ?¬°¬¦¬¯ ¬¡¬¶¡¤¬£ 
	m_equipItem[EQUIPITEM_Chest].GetItem(0, InvenItemInfo );
	if(IsValidItemID(InvenItemInfo.ID))
	{
		itemArray.Length = 1;
		itemArray[ 0 ] = InvenItemInfo;
	}

	// ¬¡¬Ö?¬ã ??¡¤¬¶ 
	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; i++)
	{	
		ClearItemID(InvenItemInfo.ID);

		m_equipItem[i].GetItem(0, InvenItemInfo);
		
		if(!IsValidItemID(InvenItemInfo.id))CONTINUE ;

		// TT 69146 : ¬¡¬¶¡¤¬£ ¥ì¬ª ?¬¨¬¡¬®¬¦¬½ ¬¢¬Á ¡Æ¡Æ¬¡? ¡Æ¬¯¬¡¬® ¬¡¬¸?¬£ ¬¢¬è ¡Æ¬­¡í¬Ù.
		// ?¬©???¡©¬×¢ç, ?¬Ù?¬·¡Æ¬­, ¥ì¬Ñ?¬å?¬´¥ì¬Ö, ?¬è?¥ì?¢à, ?¬ê¬©¬©?? ¥ì¬à¥ì¬à
		isSameItem = false;

		for(j = 0 ; j < itemArray.Length ; j ++)
		{
			if(IsSameServerID(itemArray[j].ID, InvenItemInfo.ID))
			{	
				isSameItem = true;
				continue;
			}
		}

		if(!isSameItem)
		{			
			itemArray.Length = itemArray.Length + 1;
			itemArray[ itemArray.Length - 1 ] = InvenItemInfo;			
		}		
	}

	return itemArray;
}

// ¬¢¢´¬¡¬©¥ì¬ª INDEX ¡Æ?¬¡¬×¡¤¬° ¬¡¬Ö?¬ã ¬¢¢´?¬×¬×| ¢à¬À¬¡?.
function GetEquipedListByIdx(int idx,  out Array<ItemInfo> infos)
{	
	local itemInfo info;

	//Debug("GetEquipedListByIdx" @ m_equipItem[idx].GetItemNum());

	if(m_equipItem[idx].GetItemNum()> 0)
	{
		m_equipItem[idx].GetItem(0 , info);
		infos.Length = infos.Length + 1 ;
		infos[infos.Length -1 ] = info;	
	}
}

// ¬¡¬±¢à¬¿ ¬¡¬°?? ¬¤¬¸?¬Ý ¡Æ?
function int GetMyInventoryLimit()
{
	return m_MaxInvenCount;
}

// ¬¥¬ë??¬¨¢ç ¬¡¬°?? ¬¤¬¸?¬Ý ¡Æ?
function int GetQuestItemInventoryLimit()
{
	return m_MaxQuestItemInvenCount;
}
/********************************************************************************************
 * ¬¢¬ï¬ª? ?¬¨¬¡¬®¬¦¬½ ¬×¢ç??¬¨¢ç ¢à¬À¡¾¬Ó
 * ******************************************************************************************/
// ¬¢¬ï¬ª?(¡¤¬Û)¬©¬º¬¢| ¡Æ??¬« ?¬¨¬¡¬®¬¦¬½ ¬×¢ç¬¦¬± ¢à¬À¡¾¬Ó
function array<ItemInfo> getInventoryEnSoulExtractEnableItemArray()
{
	local int i, ItemNum, Index;
	local array<ItemInfo> itemArray;
	local ItemInfo InvenItemInfo;

	ItemNum = m_invenItem.GetItemNum();

	for(Index = 0; Index < ItemNum; Index++)
	{
		m_invenItem.GetItem(Index, InvenItemInfo);

		// ¬¢¬ï¬ª?¬¡? ¢à¡ì¡¾¬Ó¬×¬× ¡Æ??¬«
		if(InvenItemInfo.Id.ClassID <= 0)
		{
			// [Explicit Continue]
			continue;
		}

		if(InvenItemInfo.itemType == EItemType.ITEM_WEAPON || InvenItemInfo.itemType == EItemType.ITEM_ARMOR || InvenItemInfo.itemType == EItemType.ITEM_ACCESSARY)
		{
		}
		else
		{
			// [Explicit Continue]
			continue;
		}

		if(InvenItemInfo.bSecurityLock)
		{
			// [Explicit Continue]
			continue;
		}

		// ¬¢¬ï¬ª? ¬©¬º¬¢|¡Æ? ¡Æ??¬«¬©¬³ ¬¢¬ï¬ª?¥ì¬©?¬à ¬¡¬¸?¬£ ¢à¡ì¡¾¬Ó ¡Æ¬ã¢Ò¬å?¡í¡¾¬Ó
		if(hasEnsoulOption(InvenItemInfo))
		{
			itemArray.Length = itemArray.Length + 1;
			itemArray[itemArray.Length - 1] = InvenItemInfo;
		}
	}

	// ¬¡¬Ö?¬ã ??¡¤¬¶ 
	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; i++)
	{
		ItemNum = m_equipItem[i].GetItemNum();
		for(Index = 0; Index < ItemNum; Index++)
		{
			m_equipItem[i].GetItem(Index, InvenItemInfo);
			if(EQUIPITEM_LHand == i)
			{
				// [Explicit Continue]
				continue;
			}
			// ¬¢¬ï¬ª?¬¡? ¢à¡ì¡¾¬Ó¬×¬× ¡Æ??¬«
			if(InvenItemInfo.Id.ClassID <= 0)
			{
				// [Explicit Continue]
				continue;
			}
			if(InvenItemInfo.itemType == EItemType.ITEM_WEAPON || InvenItemInfo.itemType == EItemType.ITEM_ARMOR || InvenItemInfo.itemType == EItemType.ITEM_ACCESSARY)
			{
			}
			else
			{
				// [Explicit Continue]
				continue;
			}

			// ¬¢¬ï¬ª? ¬©¬º¬¢|¡Æ? ¡Æ??¬«¬©¬³ ¬¢¬ï¬ª?¥ì¬©?¬à ¬¡¬¸?¬£ ¢à¡ì¡¾¬Ó ¡Æ¬ã¢Ò¬å?¡í¡¾¬Ó
			if(hasEnsoulOption(InvenItemInfo))
			{
				itemArray.Length = itemArray.Length + 1;
				itemArray[itemArray.Length - 1] = InvenItemInfo;
			}
		}
	}

	return itemArray;
}


// ¬¢¬ï¬ª? ¡Æ??¬« ?¬¨¬¡¬®¬¦¬½ ¬×¢ç¬¦¬± ¢à¬À¡¾¬Ó
function array<ItemInfo> getInventoryEnSoulEnableItemArray()
{
	local int i, ItemNum, Index;
	local array<ItemInfo> itemArray;
	local ItemInfo InvenItemInfo;
	local int enSoulNormalCount, enSoulBmCount;

	ItemNum = m_invenItem.GetItemNum();

	for(Index = 0; Index < ItemNum; Index++)
	{
		m_invenItem.GetItem(Index, InvenItemInfo);

		// ¬¢¬ï¬ª?¬¡? ¢à¡ì¡¾¬Ó¬×¬× ¡Æ??¬«
		if(InvenItemInfo.Id.ClassID <= 0)
		{
			// [Explicit Continue]
			continue;
		}

		if(InvenItemInfo.itemType == EItemType.ITEM_WEAPON || InvenItemInfo.itemType == EItemType.ITEM_ARMOR || InvenItemInfo.itemType == EItemType.ITEM_ACCESSARY)
		{
		}
		else
		{
			// [Explicit Continue]
			continue;
		}

		if(InvenItemInfo.bSecurityLock)
		{
			// [Explicit Continue]
			continue;
		}

		// ¬¢¬ï¬ª? ??¡¤¬¶¬¡¬® ¬¡¬¸?¬£ ?¬¨¬¡¬®¬¦¬½ ¡Æ¬ã¢Ò¬å ?¡í¡¾¬Ó		
		enSoulNormalCount = class'UIDATA_ENSOUL'.static.GetEnsoulSlotCount(InvenItemInfo.Id, EIST_NORMAL); // ¬¡¬±¢à¬¿ ¬¢¬ï¬ª? ??¡¤¬¶ ?¬è
		enSoulBmCount = class'UIDATA_ENSOUL'.static.GetEnsoulSlotCount(InvenItemInfo.Id, EIST_BM); // ¬¡?¡¤¬Ò ¬¢¬ï¬ª? ??¡¤¬¶ ?¬è
		// ¥ì¬³¬¢¬Á?? ¬©¬±??¢Ò¬å¥ì¥ì 1¡Æ? ¬¡¬®¡í¬å¬¡¬®¬×¬Û ¬¢¬ï¬ª? ??¡¤¬¶¬¡¬® ¬¡¬¸?¬£ ?¬¨¬¡¬®¬¦¬½)
		if(enSoulNormalCount > 0 || enSoulBmCount > 0)
		{
			itemArray.Length = itemArray.Length + 1;
			itemArray[itemArray.Length - 1] = InvenItemInfo;
		}
	}

	// ¬¡¬Ö?¬ã ??¡¤¬¶ 
	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; i++)
	{
		ItemNum = m_equipItem[i].GetItemNum();
		for(Index = 0; Index < ItemNum; Index++)
		{
			m_equipItem[i].GetItem(Index, InvenItemInfo);
			// ¢à¬Ø¬¨¬²¬¡¬± ¡Æ¬Ø?¬Þ ¢à¡ì?¬¤, ¥ì¬Ñ?¬å ?¬´¥ì¬Ö ¥ì¬à ¢Ò¡×¢à¢ç?? ?¢à?¬¾ ¬¤?¬×¢ç
			if(EQUIPITEM_LHand == i)
			{
				// [Explicit Continue]
				continue;
			}

			// ¬¢¬ï¬ª?¬¡? ¢à¡ì¡¾¬Ó¬×¬× ¡Æ??¬«
			if(InvenItemInfo.Id.ClassID <= 0)
			{
				// [Explicit Continue]
				continue;
			}

			if(InvenItemInfo.itemType == EItemType.ITEM_WEAPON || InvenItemInfo.itemType == EItemType.ITEM_ARMOR || InvenItemInfo.itemType == EItemType.ITEM_ACCESSARY)
			{
			}
			else
			{
				// [Explicit Continue]
				continue;
			}

			if(InvenItemInfo.bSecurityLock)
			{
				// [Explicit Continue]
				continue;
			}

			// ¬¢¬ï¬ª? ??¡¤¬¶¬¡¬® ¬¡¬¸?¬£ ?¬¨¬¡¬®¬¦¬½ ¡Æ¬ã¢Ò¬å ?¡í¡¾¬Ó
			enSoulNormalCount = class'UIDATA_ENSOUL'.static.GetEnsoulSlotCount(InvenItemInfo.Id, EIST_NORMAL); // ¬¡¬±¢à¬¿ ¬¢¬ï¬ª? ??¡¤¬¶ ?¬è
			enSoulBmCount = class'UIDATA_ENSOUL'.static.GetEnsoulSlotCount(InvenItemInfo.Id, EIST_BM); // ¬¡?¡¤¬Ò ¬¢¬ï¬ª? ??¡¤¬¶ ?¬è

			// ¥ì¬³¬¢¬Á?? ¬©¬±??¢Ò¬å¥ì¥ì 1¡Æ? ¬¡¬®¡í¬å¬¡¬®¬×¬Û ¬¢¬ï¬ª? ??¡¤¬¶¬¡¬® ¬¡¬¸?¬£ ?¬¨¬¡¬®¬¦¬½)
			if(enSoulNormalCount > 0 || enSoulBmCount > 0)
			{
				itemArray.Length = itemArray.Length + 1;
				itemArray[itemArray.Length - 1] = InvenItemInfo;
			}
		}
	}

	return itemArray;
}

// ¬¢¬ï¬ª??¢ç ?¬¨¬¡¬®¬¦¬½ ¬×¢ç¬¦¬± ¢à¬À¡¾¬Ó
function array<ItemInfo> getInventoryEnSoulStoneArray()
{
	local int i, itemNum, index;

	local array<ItemInfo> itemArray;

	local ItemInfo InvenItemInfo;
	// local string tmpInfoStr;
	
	// local int enSoulNormalCount, enSoulBmCount;

	itemNum = m_invenItem.GetItemNum();

	// ¬¡¬°??¬¦¬Õ¬×¢ç???¡© ¬¤?¡¾¬Ó
	for(index = 0; index < itemNum; index++)
	{
		m_invenItem.GetItem(index, InvenItemInfo);

		if(InvenItemInfo.EtcItemType == int(EEtcItemType.ITEME_ENSOUL_STONE))
		{
			itemArray.Length = itemArray.Length + 1;
			itemArray[ itemArray.Length - 1 ] = InvenItemInfo;
		}
	}

	// ¬¡¬Ö?¬ã ??¡¤¬¶???¡© ¬¤?¡¾¬Ó
	for(i = 0; i < EQUIPITEM_TOTAL_CLASSIC; i++)
	{
		itemNum = m_equipItem[i].GetItemNum();
		for(index = 0; index < itemNum; index++)
		{
			m_equipItem[i].GetItem(index, InvenItemInfo);
			
			// ¬¦¬×¬¡¬¶¬¡¬® ¡Æ¡Æ?¬»¬×¬Û..
			if(InvenItemInfo.EtcItemType == int(EEtcItemType.ITEME_ENSOUL_STONE))
			{
				itemArray.Length = itemArray.Length + 1;
				itemArray[ itemArray.Length - 1 ] = InvenItemInfo;
			}
		}
	}

	return itemArray;
}

//#ifdef CT26P3
/********************************************************************************************
 * ¬¢¢´¡¤¬¥
 * ******************************************************************************************/
function SortQuestItem()
{
	local int i, j;
	local int invenLimit;
	local ItemInfo item;	
	local itemInfo temp;
	local int numQuest;
	local Array<ItemInfo> QuestList;

	invenLimit = m_questItem.GetItemNum();

	// 1. ?¬¨¬¡¬®¬¦¬½¥ì¬Û¬¡¡í 
	for(i = 0; i < invenLimit; i++)
	{
		m_questItem.GetItem(i, item);

		if(!IsValidItemID(item.ID))
		{
			continue;
		}

		QuestList[numQuest] = item;
		numQuest = numQuest + 1;
	}

	m_questItem.Clear();
	
	ItemboxUpdate(m_questItem, GetQuestItemInventoryLimit());

	for (i = 0 ;i < numQuest ; i++)
	{
		for(j = i ;j < numQuest ; ++j)
		{
			if(QuestList[i].ID.serverID  < QuestList[j].ID.serverID)
			{
				temp = QuestList[i];
				QuestList[i] = QuestList[j];
				QuestList[j] = temp;
			}
		}
	}
	
	for(i = 0; i < numQuest; ++i)
		m_questItem.SetItem(i, QuestList[i]);
}

/********************************************************************************************
 * ?¡©?¬Ü ¬¤?, ??¡¤¬¶ ¬ª¡Æ?? ?¬ã¬ª¡Æ?? ¬¤?¬×¢ç
 * ******************************************************************************************/
// ¬¦¡í¬×¢ç??¬×¬× ??¡¤¬¶ ¬¤?¬×¢ç 
function UpdateTalismanSlotActivation()
{
	local int i, Count;
	local UserInfo User;

	if(GetPlayerInfo(User))
	{
		Count = Max(0, User.nTalismanNum);

		for(i = 0; i < Count; i++)
		{
			m_Talisman_Disable[i].HideWindow();
			m_equipItem[EQUIPITEM_Deco1 + i].EnableWindow();
		}

		for(i = Count; i < 6; i++)
		{
			m_Talisman_Disable[i].ShowWindow();
			m_equipItem[EQUIPITEM_Deco1 + i].DisableWindow();
		}
	}
}

// ?¬¨¡Æ??¬¤?¬£ ??¡¤¬¶ ¬¤?¬×¢ç 
function UpdateAgathionSlotActivation()
{
	local int Count;
	local int i;
	local UserInfo User;
	
	if(GetPlayerInfo(User))
	{
		// ¬×¬À¬¡¬° ¡í¬Ù?¬Ý¬¡¬® ¡Æ??¬« ¬©¬±?¬»¬×¬Û,
		if(User.nAgathionMainNum > 0)
		{
			m_Agathion_Disable[0].HideWindow();
			m_equipItem[EQUIPITEM_AGATHION_MAIN].EnableWindow();
		}
		// ¡Æ??¬« ¬©¬±¬¢¬è ?¬¬?¬»¬×¬Û 
		else
		{
			m_Agathion_Disable[0].ShowWindow();
			m_equipItem[EQUIPITEM_AGATHION_MAIN].DisableWindow();
		}
		Count = Max(0, User.nAgathionSubNum);

		for(i = 1; i < Count + 1; i++)
		{
			m_Agathion_Disable[i].HideWindow();
			m_equipItem[EQUIPITEM_AGATHION_MAIN + i].EnableWindow();
		}
		for(i = Count + 1; i < 5; i++)
		{
			m_Agathion_Disable[i].ShowWindow();
			m_equipItem[ EQUIPITEM_AGATHION_MAIN + i ].DisableWindow();
		}
	}
}

// ?¬×?¢ç ?¬¨¬¡¬®¬¦¬½ ??¡¤¬¶ ¬¤?¬×¢ç 
function UpdateJewelSlotActivation()
{
	local int Count;
	local int i;
	local UserInfo User;

	if(GetPlayerInfo(User))
	{
		//?¬è¬¢¢´
		Count = Max(0, User.nJewelNum);

		for(i = 0; i<Count; i++)
		{
			m_Jewel_Disable[i].HideWindow();
			m_equipItem[EQUIPITEM_Jewel1 + i].EnableWindow();
		}

		for(i = Count; i < 6 ; i++)
		{
			m_Jewel_Disable[i].ShowWindow();
			m_equipItem[EQUIPITEM_Jewel1 + i].DisableWindow();
		}
	}
} 

/********************************************************************************************
 * ¡¾¬Ó?¬« ¢à¬¹ ¬¡¨Ï¥ì¥ì?¬Þ ??¡Æ¬Ø
 * ******************************************************************************************/
// ¬¡?¬¡¬ì ¬¢¢´?¬×?? ¬×¬£¬¤¬Ù ¬¡¨Ï¥ì¥ì?¬Þ ??¡Æ¬Ø //////////////////////////////////////////////////////////////
function HandleUpdateUserInfo()
{
	// Debug("HandleUpdateUserInfo"); 
	if(m_hOwnerWnd.IsShowWindow())
	{
		SetAhclemyOpener();
		InvenLimitUpdate();
		CheckShowCrystallizeButton();
	}
}

function handleChangedSubjob(string param)
{
	parseint(param, "SubjobClassID_0", mainClass);
	//Debug("handleChangedSubjob" @ mainClass);
	SetAhclemyOpener();
}

function handleNotifySubjob(string param)
{
	parseint(param, "SubjobClassID_0", mainClass);
	SetAhclemyOpener();
}

// ?¬¨¬¡¬®¬¦¬½ ¡Æ¬Ò¬¢¢´¬ª¡© ¢à¬è¬¨¡Æ  
function CheckShowCrystallizeButton()
{
	if(class'UIDATA_PLAYER'.static.HasCrystallizeAbility())
	{
		m_hBtnCrystallize.ShowWindow();		
	}
	else
	{
		m_hBtnCrystallize.HideWindow();
	}
}

// ¬¡¬®??¬¨¢ç¬×| ¢à¬À?¬¨, ¬©¬Þ?¬à ?¬©??¬×| ?¬×¬¡¬± ¡Æ¬©¬¢¬è ¬×¡í¡Æ¬©¬¢¬è ¬¤?¬×¢ç
function ReceiveHairAccessoryPriority(string param)
{
	ParseInt(param, "priority", bShowhairAccessory);
	SetHandleHairAccessory();
}

function SetHandleHairAccessory()
{
	ViewHairButton.HideWindow();
	ViewAccessoryButton.HideWindow();

	if(bShowhairAccessory == 0)
		ViewHairButton.ShowWindow();		
	else if(bShowhairAccessory == 1)
		ViewAccessoryButton.ShowWindow();
}

// ?¬¨¬×?¬¦¬¹¬¡¬®?¬à ?¡þ¡¾¬¿?¬ì ¬ª¡Æ??¬ª¡©.
function SetAhclemyOpener()
{
	local userinfo info;

	if(!GetPlayerInfo(info))return ;
	
	// ?¬¨¬×?¬¦¬¹¬¡¬®?¬à ¬¢?¬¢¡¤¬¡¬®¡Æ¬ß, ?¬¨¡¤¢à?? ?¡©¢à¬è¡Æ? ?¬¨?¬³ ¡Æ¬Ø?¬Þ

	//Debug("SetAhclemyOpener" @ GetClassTransferDegree(info.nSubClass)@  mainClass == info.nSubClass);
	if(info.Race == 6)
	{
		AlchemyOpenerBtn.ShowWindow();
		if(GetClassTransferDegree(info.nSubClass)> 1 && mainClass == info.nSubClass)
		{
			toggleAlchemyOpenerTooltip(true);
			AlchemyOpenerBtn.EnableWindow();
			AlchemyOpenerBtn.ShowWindow();
			AlchemyOpenerBtn.SetTexture("L2ui_ct1.InventoryWnd.Alchemyopener", "L2ui_ct1.InventoryWnd.InventoryWnd.Alchemyopener", "L2ui_ct1.InventoryWnd.Alchemyopener_drag");				
		}
		else 
		{
			toggleAlchemyOpenerTooltip(false);
			AlchemyOpenerBtn.disableWindow();
			AlchemyOpenerBtn.HideWindow();
			AlchemyOpenerBtn.SetTexture("L2ui_ct1.InventoryWnd.Alchemyopener_disable", "L2ui_ct1.InventoryWnd.InventoryWnd.Alchemyopener_disable", "L2ui_ct1.InventoryWnd.Alchemyopener_disable");							
			AlchemyOpenerWindow.HideWindow();
		}
	}
	else 
	{
		AlchemyOpenerBtn.hideWindow();
	}	
}
// ??¬¦¨Ï¡¤¬³¢à¬» ??¬¨¬¤
function InitScrollBar()
{
	m_invenItem.SetScrollBarPosition(0, 17, 0);
	m_invenItem_1.SetScrollBarPosition(0, 17, 0);
	m_invenItem_2.SetScrollBarPosition(0, 17, 0);
	m_invenItem_3.SetScrollBarPosition(0, 17, 0);
	m_invenItem_4.SetScrollBarPosition(0, 17, 0);
	m_questItem.SetScrollBarPosition(0, 17, 0);
}

// ¢à¬è¬¨¡Æ ?¬ê?¡©?? ¥ì¬í¢Ò¬å ¢à¬è¬¨¡Æ ¬¡¡×¬¥?¬×| ??¡Æ¬Ø ¬©¬¶ 
function setBottomButtonPostion(out int num, ButtonHandle tmpBottomButton)
{
	local int startX, btnW;	

	//Debug("setBottomButtonPostion" @  tmpBottomButton);


	startX = 232; btnW = 39;
	tmpBottomButton.SetAnchor(m_hOwnerWnd.m_WindowNameWithFullPath, "TopLeft", "TopLeft", StartX + (Num * btnW), 459);
	++num ;
}


/**
 *  ¬¡¬°??¬¦¬Õ¬×¢ç¬×|¬ª¢ç¬¡¬Ö, ¬¤¬Ñ?¬´¬©¬³?¬».
 **/
//function extendInventory(bool flag)
//{
//	local ItemWindowHandle tmpItemWindowHandle;	
//	local int toExpandWidth ;	

//	if(flag)
//	{
//		currentInvenCol = 12;
//		toExpandWidth = 108 ;
		
//		// ¬¡¬°??¬¦¬Õ¬×¢ç¬¦¬º??¬¤¬¥¡¾?¬¤?(6, 12 ¡Æ?¡¤¬°)		
//		m_InventoryItembg_expand.ShowWindow();
		
//		// ¬ª¢ç?¬Ý ¬¤¬Ñ?¬´ ¢à¬è¬¨¡Æ ¬¦¬º??¬¤¬¥ ¡¾?¬¤?
//		m_BtnWindowExpand.SetTexture("L2UI_CT1.frames_df_Btn_Minimize",
//									 "L2UI_ct1.frames_df_btn_Minimize_down",
//									 "L2UI_ct1.frames_df_btn_Minimize_over");	
			
//	}
//	else
//	{
//		//¬¡¬µ?¬¤¡¤¬° ?? ¬¥¡©¬¡¡í ?¬¤¡¤¬¢ ??
//		currentInvenCol = 9;
//		toExpandWidth = 0 ;
//		//¡Æ? col ¬¡¬© ¬¦¨Ï¡¾¬Ó?¬£ 36 ¬¡¬®?¬». col¬¡¬® ¬©¬±?? ?¬¤?¬à?? ¢Ò¡× ¬×¢Ò?¬». 36 ?? ?¬ç¬©¬º ¬¢¬î		
		
//		// ¬¡¬°??¬¦¬Õ¬×¢ç¬¦¬º??¬¤¬¥¡¾?¬¤?(6, 12 ¡Æ?¡¤¬°)		
//		m_InventoryItembg_expand.HideWindow();

//		// ¬ª¢ç?¬Ý ¬¤¬Ñ?¬´ ¢à¬è¬¨¡Æ ¬¦¬º??¬¤¬¥ ¡¾?¬¤?
//		m_BtnWindowExpand.SetTexture("L2UI_ct1.frames_df_btn_Expand",
//									 "L2UI_ct1.frames_df_btn_Expand_down",
//									 "L2UI_ct1.frames_df_btn_Expand_over");
//	}	
	
//	//itemWindowWidth = ITEMWINDOW_MIN_WIDTH + toExpandWidth;	

//	m_hInventoryWnd.SetWindowSize(INVENTORYWND_MIN_WIDTH + toExpandWidth, 394);

//	m_invenItem.SetWindowSize(ITEMWINDOW_MIN_WIDTH + toExpandWidth, 288);

//	m_invenItem_1.SetWindowSize(ITEMWINDOW_MIN_WIDTH + toExpandWidth , 288);
//	m_invenItem_2.SetWindowSize(ITEMWINDOW_MIN_WIDTH + toExpandWidth , 288);
//	m_invenItem_3.SetWindowSize(ITEMWINDOW_MIN_WIDTH + toExpandWidth , 288);
//	m_invenItem_4.SetWindowSize(ITEMWINDOW_MIN_WIDTH + toExpandWidth , 288);
//	m_questItem.SetWindowSize(ITEMWINDOW_MIN_WIDTH + toExpandWidth , 288);	
//	m_tabbg.SetWindowSize(TAB_BG_MIN_WIDTH + toExpandWidth , 321);
//	m_tabbgLine.SetWindowSize(TAB_BG_LING_MIN_WIDTH + toExpandWidth , 23);
	
//	m_invenItem.SetCol(currentInvenCol);
//	m_invenItem_1.SetCol(currentInvenCol);
//	m_invenItem_2.SetCol(currentInvenCol);
//	m_invenItem_3.SetCol(currentInvenCol);
//	m_invenItem_4.SetCol(currentInvenCol);
//	m_questItem.SetCol(currentInvenCol);

//	// ??¬¦¨Ï¡¤¬³¢à¬» ¡í¬å¬¡¡×¡¤¬°, ¬¨¬é¬¥??? ¬¢¬è¬¢¢´

//	if(m_selectedItemTab == INVENTORY_ITEM_TAB)
//	{
//		tmpItemWindowHandle = m_invenItem;	
//	}
//	if(m_selectedItemTab == INVENTORY_ITEM_1_TAB)
//	{
//		tmpItemWindowHandle = m_invenItem_1;			
//	}
//	if(m_selectedItemTab == INVENTORY_ITEM_2_TAB)
//	{
//		tmpItemWindowHandle = m_invenItem_2;		
//	}
//	if(m_selectedItemTab == INVENTORY_ITEM_3_TAB)
//	{
//		tmpItemWindowHandle = m_invenItem_3;
//	}
//	if(m_selectedItemTab == INVENTORY_ITEM_4_TAB)
//	{
//		tmpItemWindowHandle = m_invenItem_4;
//	}
//	else if(m_selectedItemTab == QUEST_ITEM_TAB)
//	{
//		tmpItemWindowHandle = m_questItem;
//	}

//	tmpItemWindowHandle.SetScrollPosition(0);
//	tmpItemWindowHandle.ResizeScrollBar();
//	tmpItemWindowHandle.SetFocus();
//}

// ¬¦¡þ¡¤??¬¥ ¢Ò¬å¬¡¬®?¬Ü, ?¬¨¡¤¢à?? ?¡©¢à¬è ??¡Æ¬Ø
function checkClassicForm()
{
	m_EquipWindow.HideWindow();
	SetEquipWindowHandle();
	SetHennaWindows();
	SetHandles();
	m_EquipWindow.ShowWindow();
	setBottomButtonPositions();
	SwitchEquipBox(EQUIPITEM_Brooch);	
}

function InitTabIcon()
{
	m_invenTab.SetButtonOffsetTex(1, "L2UI_CT1.InventoryWnd.Inventory_Tab_Equip", 14, 8);
	m_invenTab.SetButtonOffsetTex(2, "L2UI_CT1.InventoryWnd.Inventory_Tab_Consume", 14, 7);
	m_invenTab.SetButtonOffsetTex(3, "L2UI_CT1.InventoryWnd.Inventory_Tab_Material", 14, 8);
	m_invenTab.SetButtonOffsetTex(4, "L2UI_CT1.InventoryWnd.Inventory_Tab_Etc", 15, 8);
	m_invenTab.SetButtonOffsetTex(5, "L2UI_CT1.InventoryWnd.Inventory_Tab_Quest", 13, 7);
}

function SetIconOnSelectTabOrder()
{
	switch(preTabOrder)
	{		
		case 1 : 
			m_invenTab.SetButtonOffsetTex(1 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Equip" , 14, 8);
			break;
		case 2 : 
			m_invenTab.SetButtonOffsetTex(2 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Consume" , 14, 7);
			break;
		case 3 :
			m_invenTab.SetButtonOffsetTex(3 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Material" , 14, 8);
			break;
		case 4 :
			m_invenTab.SetButtonOffsetTex(4 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Etc" , 15, 8);
			break;
		case 5 :
			m_invenTab.SetButtonOffsetTex(5 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Quest", 13, 7);
			break;
	}	
	
	preTabOrder = m_invenTab.GetTopIndex();

	switch(preTabOrder)
	{		
		case 1 : 
			m_invenTab.SetButtonOffsetTex(1 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Equip_Select" , 14, 8);
			break;
		case 2 : 
			m_invenTab.SetButtonOffsetTex(2 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Consume_Select" , 14, 7);
			break;
		case 3 :
			m_invenTab.SetButtonOffsetTex(3 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Material_Select" , 14, 8);
			break;
		case 4 :
			m_invenTab.SetButtonOffsetTex(4 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Etc_Select" , 15, 8);
			break;
		case 5 :
			m_invenTab.SetButtonOffsetTex(5 , "L2UI_CT1.InventoryWnd.Inventory_Tab_Quest_Select" , 13, 7);
			break;
	}
}

 // ¬©¬±?¬¾ ¢à¬è¬¨¡Æ ?¬ê?¡© ¡¾?¬¤? ¬©¬¶?¬è   
 function setBottomButtonPositions()
{	
	local int UseClassicJewelEnchantBtn, i;

	// ¬©¬º?¬¾ ¬¦¡þ¡¤??¬¥ ¢à¬è¬¢????¡© ¬©¬·?? UI ¡í¬Ù?¬Ý¬©¬´¬¢¬è ?¨Ï?¬° 
	// ¡í¬Ù?¬Ý ?¬¤ ¢à¬è¬¨¡Æ ?¬ê?¡©¡Æ? "?¬¨¥ì??? ?¬²¢à¬Ú", "¬©¬·??" ¬¡¬® ¬©¬¹?¬¤ ?¬Ý¬¤¬Ó ¥ì¬©¡Æ¬ß, ¬¢¢Ò¡Æ¬©(¥ì¬Ö?¬è¬©¬¢ ¬¡¬±¬¢¢´ ¬¢¬é?¬é)?? ¥ì¬í¢Ò¬å "¡Æ¬Ò¬¢¢´¬ª¡©" ?¬Ý¬¤¬Ó
	GetINIBool("Localize", "UseClassicJewelEnchantBtn", UseClassicJewelEnchantBtn, "L2.ini");	
	if(UseClassicJewelEnchantBtn == 1)
	{
		setBottomButtonPostion(i, AdenacalculateButton);
		setBottomButtonPostion(i, EnchantJewelButton);
		setBottomButtonPostion(i, CollectionBtn);
		setBottomButtonPostion(i, ItemAutoPeelBtn);
		setBottomButtonPostion(i, m_hBtnCrystallize);
		EnchantJewelButton.ShowWindow();
	}
	else 
	{
		setBottomButtonPostion(i, AdenacalculateButton);
		setBottomButtonPostion(i, CollectionBtn);
		setBottomButtonPostion(i, ItemAutoPeelBtn);
		setBottomButtonPostion(i, m_hBtnCrystallize);
		setBottomButtonPostion(i, EnchantJewelButton);
		EnchantJewelButton.HideWindow();
	}
	ItemAutoPeelBtn.ShowWindow();
}


/********************************************************************************************
 * ¬¡¬°?? ¬¢¢´?¬× ¬©??¬¤ 
 * ******************************************************************************************/
// ?¬¨¥ì???
function SetAdenaText()
{
	local string adenaString;

	adenaString = MakeCostString(string(GetAdena()));
	m_hAdenaTextBox.SetText(adenaString);
	m_hAdenaTextBox.SetTooltipString(ConvertNumToText(string(GetAdena())));
}
// ?¬¨¬¡¬®¬¦¬½ ?¬è¡¤¢ç
function SetItemCount()
{
	local int limit;
	local int count;
	local Color countColor;
	
	if(m_selectedItemTab == QUEST_ITEM_TAB)
	{
		countColor.R = 176;
		countColor.G = 155;
		countColor.B = 121;
		countColor.A = 255;
		count = m_QuestInvenCount;
		limit = GetQuestItemInventoryLimit();
	}
	else //if(m_selectedItemTab == INVENTORY_ITEM_TAB)
	{
		countColor.R = 176;
		countColor.G = 155;
		countColor.B = 121;
		countColor.A = 255;
		count = m_NormalInvenCount + EquipNormalItemGetItemNum();
		limit = GetMyInventoryLimit();
	}

	m_itemCount.SetTextColor(countColor);   
	m_itemCount.SetText("(" $ count $ "/" $ limit $ ")");

	// ?¬¾?¬° ¬¢¢´?¬×?¬Ý
	pInventoryItemCount = limit - Count;
	UpdateInvenExpandSkillBtn();
}

// ¬¡¬°??¬¦¬Õ¬×¢ç ¡í¬Ù?¬Ý ?¬´¡Æ? ¬¥¡© ¬©??¬¤ 
function InvenLimitUpdate()
{
	// Changed by JoeyPark 2010/09/09	

	ItemboxUpdate(m_invenItem, GetMyInventoryLimit());

	ItemboxUpdate(m_invenItem_1, GetMyInventoryLimit());
	ItemboxUpdate(m_invenItem_2, GetMyInventoryLimit());
	ItemboxUpdate(m_invenItem_3, GetMyInventoryLimit());
	ItemboxUpdate(m_invenItem_4, GetMyInventoryLimit());
	ItemboxUpdate(m_questItem, GetQuestItemInventoryLimit());
	// End changing
}

// ¬¤¬¸?¬Ý¡Æ? ¬¡¬®¡í¬å ?¡ì¡¾¬¿ ¬©??¬¤ 1
function ItemboxUpdate(ItemWindowHandle hItemWnd, int iInvenLimit)
{
	local int iCount;
	local int iItemCount;
	local int iAddedCount;
	local int iDeletedCount;
	local ItemInfo kClearItem;
	local ItemInfo kCurItem;
	
	kClearItem.IconName = "L2ui_ct1.emptyBtn";
	ClearItemID(kClearItem.ID);
	iItemCount = hItemWnd.GetItemNum();

	if(iItemCount < iInvenLimit)
	{		
		IAddedCount = iInvenLimit - iItemCount;
		for(iCount=0; iCount<iAddedCount; iCount++)
		{
			hItemWnd.AddItem(kClearItem);	
		}
	}
	else if(iItemCount > iInvenLimit)
	{
		iDeletedCount = iItemCount - iInvenLimit;
		for(iCount = hItemWnd.GetItemNum()- 1; iCount >= 0; iCount--)
		{
			if(iDeletedCount > 0)
			{
				hItemWnd.GetItem(iCount, kCurItem);
				if(!IsValidItemID(kCurItem.ID))
				{
					hItemWnd.DeleteItem(iCount);
					iDeletedCount--;
				}
				if(iDeletedCount <= 0)
				{
					break;
				}					
			}
		}
	}
}

// ¬¤¬¸?¬Ý¡Æ? ?¬è¬¥? ??¡Æ¬Ø
function HandleSetMaxCount(string param)
{
	local int ExtraBeltCount;
	//local Userinfo info;	
	
	//Debug("HandleSetMaxCount" @ param);
	ParseInt(param, "Inventory", m_MaxInvenCount);
	ParseInt(param, "questItem", m_MaxQuestItemInvenCount);
	ParseInt(param, "extrabelt", ExtraBeltCount);
	
	// ?¬¨¬×¢Ò 100¬¡¬± ¡Æ¬¯¬¡¬®?¬».
	//	m_MaxArtifactInvenCount = 100;
	//debug("SetMaxCount Called");
	m_invenItem.SetExpandItemNum(0, ExtraBeltCount);
	InvenLimitUpdate();
	SetItemCount();
}

/********************************************************************************************
 * ¡Æ? ¬¡¨Ï¥ì¥ì?¬Þ show<>hide ¬©¬¼¥ì¬Û
 * ******************************************************************************************/
function HandleToggleWindow()
{
	if(m_hOwnerWnd.IsShowWindow())
	{
		m_hOwnerWnd.HideWindow();
		PlayConsoleSound(IFST_INVENWND_CLOSE);
	}
	else
	{
		if(bInitedCompleted)
		{
			if(RefineryWnd(GetScript("RefineryWnd")).isPossableInventoryShow() == false)
			{
				RefineryWnd(GetScript("RefineryWnd")).OnClickButton("exitbutton");
				RefineryWnd(GetScript("RefineryWnd")).setHideAndInventoryShow(true);				
			}
			else
			{
				ShowWindowWithFocus("InventoryWnd");
				PlayConsoleSound(IFST_INVENWND_OPEN);
			}
		}
		else
		{
			bRequestItemList = true;
			RequestItemList();
		}
	}
}

function HandleOpenWindow(string param)
{
	local int Open;

	//?¬Õ¬¨?˜???¬¦¬¹¬¡¬®¬¨¢ç¬¡¬± ¡Æ¬Ø?¬Þ ¬×¢ç¬¦¬±;
	//Debug("HandleOpenWindow"  @ cur_state );
	if(cur_state == "BEAUTYSHOPSTATE")
	{
		return;
	}

	ParseInt(param, "Open", Open);

	if(Open == 0)
	{
		return;
	}
	
	OpenWindow();
}

function OpenWindow()
{
	m_hOwnerWnd.ShowWindow();
	m_hOwnerWnd.SetFocus();
}

function HandleHideWindow()
{
	//branch 110804
	DialogHide();
	HideWindow(m_hOwnerWnd.m_WindowNameWithFullPath);
	//end of branch
}

function handleEnchantJewelButton()
{
	class'ItemJewelEnchantWnd'.static.Inst().ToggleShowWindow();
}

function toggleShowAlchemyWindow(string winName)
{
	if(class'UIAPI_WINDOW'.static.IsShowWindow(winName))
	{
		class'UIAPI_WINDOW'.static.HideWindow(winName);		
	}
	else
	{
		class'UIAPI_WINDOW'.static.ShowWindow(winName);
	}
}

function toggleAlchemyOpener()
{
	if(AlchemyOpenerWindow.IsShowWindow())
	{
		AlchemyOpenerWindow.HideWindow();		
	}
	else
	{
		AlchemyOpenerWindow.ShowWindow();
	}
}

// ?¬Õ ¬¨¬é¬¨¢ç ?¡©¡Æ¬ß ?¬¿?¬£ ¬©¬¶?¬è
function toogleCharacterViewPort(bool bShow)
{
	if(bShow)
	{	
		// "e" ¡Æ?¬¡¬® 0 ¬¡¬° ¡Æ¬Ø?¬Þ ¬¤?¬¡¡í ?¡þ?¬».
		SetINIInt(m_hOwnerWnd.m_WindowNameWithFullPath, "e",  0, "WindowsInfo.ini");
		m_InventoryWndCharacterView.ShowWindow();		
		m_CharacterViewOpen_BTN.HideWindow();
		m_CharacterViewClose_BTN.ShowWindow();
	}
	else 
	{	
		SetINIInt(m_hOwnerWnd.m_WindowNameWithFullPath, "e",  1, "WindowsInfo.ini");
		m_InventoryWndCharacterView.HideWindow();
		m_CharacterViewOpen_BTN.ShowWindow();
		m_CharacterViewClose_BTN.HideWindow();
	}
}

// ?¬Õ ¬¨¬é¬¨¢ç¬×| ¬¡¬ì¬¡¬Ö ¥ì¬ª e ¡Æ??? ¥ì¬í¢Ò¬å ?¬×¬¡¬± ¡Æ¬¯¬¡¬°¬¢¬è ?¬¿¬¡¡í ¡Æ¬¯¬¡¬°¬¢¬è .
function ShowHideCharacterViewPortOnShow()
{
	local int e;
	GetINIInt(m_hOwnerWnd.m_WindowNameWithFullPath, "e",  e, "WindowsInfo.ini");
	toogleCharacterViewPort(e == 0);
}

/********************************************************************************************
 * ¬ª¢ç¬¡¬Ö ¬¡¬Ö¬£¬ê ¡¾¬×¡Æ? 
 * ******************************************************************************************/
// ¬¡¬Ö¬£¬ê ?¬¤ 
// onShow ¢Ò¡× ?¬»?¬¤ ¡¤¬°¥ì¬Ö ¬©¬±?¬£ ?¬¨¬¡¬®¬¦¬½¬¡¬® ?¬¨?¬³ ?¬©¬¢| ¬¡¬Ö¬£¬ê ¬©¬±?¬£ ?¬¨¬¡¬®¬¦¬½¥ì¬Û¬¡¡í ¬¤?¬¦¨Ï ¬©¬±¡¾¬Ó ¬¡¡×¬©¬³ ¬©¬¶?¬è 
function HandleChkSwitchEquipBox(int idx, ItemInfo newInfo, optional bool bSwitchExpandEquipBox)
{
	switch(idx)
	{
		case EQUIPITEM_RBracelet:
			EquipItem_RBracelet_Button.HideWindow();
		break;
		case EQUIPITEM_LBracelet:
			EquipItem_LBracelet_Button.HideWindow();
			break;
		case EQUIPITEM_Brooch:
			EquipItem_Brooch_Button.HideWindow();
			break;
		// ¬¡¬±¢à¬¿ ?¬¨¬¡¬®¬¦¬½ ¬¡¬Ö¬£¬ê ?¬¤ 
		case -1 : 
			break;
	}

	// 2600 ¬¡¬®??¬¨¢ç¡¤¬° ¥ì¬Û?¬à ?¬¡?¬£ ¡Æ¬Ø?¬Þ switch ¬©¬±¬¢¬è ?¬¬?¬£?¬». 
	if(bSwitchExpandEquipBox)
	{
		SwitchEquipBox(idx);
	}
}

// ¬¡¬½¬¡? ¬¡¬Ö?¬ã ¢à¬¼?? ??¬¡¡×¬¥? ¬©¬±¡¾¬Ó 
function SwitchEquipBox(int idx)
{
	if(idx == -1)
	{
		return;
	}

	JewelWindow.HideWindow();
	AgathionWindow.HideWindow();
	equipItem_Henna_Window.HideWindow();
	SetHandleHairAccessory();
	switch(idx)
	{
		case EQUIPITEM_RBracelet:
			m_TalismanAllow.SetAnchor(m_hOwnerWnd.m_WindowNameWithFullPath $ "." $ m_equipItem[idx].GetWindowName(), "TopLeft", "TopLeft", -6, -12);
			break;
		case EQUIPITEM_LBracelet:
			AgathionWindow.ShowWindow();
			m_TalismanAllow.SetAnchor(m_hOwnerWnd.m_WindowNameWithFullPath $ "." $ m_equipItem[idx].GetWindowName(), "TopLeft", "TopLeft", -6, -12);
			break;
		case EQUIPITEM_Brooch:
			JewelWindow.ShowWindow();
			m_TalismanAllow.SetAnchor(m_hOwnerWnd.m_WindowNameWithFullPath $ "." $ m_equipItem[idx].GetWindowName(), "TopLeft", "TopLeft", -6, -12);
			break;
		case HENNA_INDEX:
			equipItem_Henna_Window.ShowWindow();
			m_TalismanAllow.SetAnchor(m_hOwnerWnd.m_WindowNameWithFullPath $ ".equipItem_Henna_Button", "TopLeft", "TopLeft", -4, -10);
			break;
	}
	// Debug("SwitchEquipBox" @  m_SelectedExpandEquipIdxPrev @ m_SelectedExpandEquipIdx);
	// ¡Æ¡Æ¬¡? ¡Æ¬« ¬¦¡þ¬×? ¬©¬±?¬£ ¡Æ¬Ø?¬Þ ?¢à?¬¾ ¬¤?¬×¢ç
	if(m_SelectedExpandEquipIdx != idx)
		m_SelectedExpandEquipIdxPrev = m_SelectedExpandEquipIdx; 
	m_SelectedExpandEquipIdx = idx;
}

/*********************************************************************************************
 * new Item ¬©??¬¤ ¬¢|¡Æ¬¦
 * *******************************************************************************************/
// new Item ¬¡¡í ¬ª¢ç¬¡¬°¬©¬º list¡¤¬° ¬×¬×¥ì¬Û?¬à ?¬¸¬¡?. 

// ¬¤?¬¡¬® ?¡©¡¤¬¢ ¬¡¬¸?¬»¬×¬Û ¢à¬»¡¤¬° new ¬¤?¬×¢ç
function handleNewItem(itemInfo addedItemInfo )
{
	local int index;

	if(addedItemInfo.ID.classID == 57)return;

	if(m_hOwnerWnd.IsShowWindow())
	{
		setNewItem(addedItemInfo);
		//return;
	}
	// ¬©¬è¬¡¬Ù ?¬¨¬¡¬®¬¦¬½ ¡Æ¬ì ?¬è¡¤¢ç ?¬ã¡¾?¬×| ¬©¬º?¡© list ?? ?¬¸?¬à?¬Á ¬©¬¶. ¬¢¬»?¬à¥ì¬Ù ¡Æ¬Ø?¬Þ?¬£ list ???¡© ¬¢|?¬¾
	index = findNewItem(addedItemInfo.ID);

	// ¬×¢ç??¬¨¢ç?? ?¬ê¬¡¬×¬×¬Û ¬×¢ç??¬¨¢ç?? ?¬¸?¬à¢Ò¬å.
	if(index == -1)
	{
		// ?¬è¡¤¢ç¬¡¬® ?¬¤?¬à?¡© ¡Æ¬Ø?¬Þ¬×| ¬¤?¬¦¨Ï ¬©¬º?¬Á ¬©¬¶.
		index = newItems.Length;
		newItems.Length = newItems.Length + 1;
		newItems[ index ] = addedItemInfo;
//		Debug("handleNewItem ¬×¢ç??¬¨¢ç ¡í¬ï??" @ index @  addedItemInfo.name);
	}

	// ¬¤¬¸¬¤¬¬ ?¬è¡¤¢ç¡Æ¬ì, ¬¢¬ç¡Æ¬§¬¡¡í ?¬ã¡¾? ¬©¬º ?¬¤?¬à?¡© ¬¡¬í¬¡¬® ¬¡¬¸¬¡¬×¬×¬Û new ¬©??¬¤ 
	else if(newItems[index].ItemNum < addedItemInfo.ItemNum) 
	{
		newItems[index] = addedItemInfo;
//		Debug("handleNewItem ¬×¢ç??¬¨¢ç ¬¡¬¸¬¡? " @ index @  addedItemInfo.name);
	}
}


function setNewItem(ItemInfo newItem)
{
	local int index;	

	local ItemWindowHandle tmpInven, detailItemWindow;

	if(IsQuestItem(newItem))
	{
		tmpInven = m_questItem;
		index = tmpInven.FindItem(newItem.ID);
	}
	else 
	{
		tmpInven = m_invenItem; 

		detailItemWindow = getItemWindowHandleByItemType(newItem);
		index = detailItemWindow.FindItem(newItem.ID);		

		if(index != -1)detailItemWindow.SetNewlyAcquired(index, true);
		index = tmpInven.FindItem(newItem.ID);
	}

	//Debug("setNewItem" @ newItem.name @ index);
	
	if(index != -1)tmpInven.SetNewlyAcquired(index, true);	
}

function handleNewItemOnShow()
{
	local int i;

	for(i = 0; i < newItems.Length; i ++)
	{
		setNewItem(newItems[i]);
	}
	//newItems.Length = 0;
}

function handleNewItemOnHide()
{
	local int i;

	for(i = 0; i < newItems.Length; i++)
	{
		delNewItem(newItems[i]);
	}
	newItems.Length = 0;
}

function delNewItem(ItemInfo delItem)
{
	local int index;	
	local ItemWindowHandle tmpInven, detailItemWindow;	

	if(IsQuestItem(delItem))
	{
		tmpInven = m_questItem;
		index = tmpInven.FindItem(delItem.ID);
	}
	else 
	{
		tmpInven = m_invenItem;

		detailItemWindow = getItemWindowHandleByItemType(delItem);
		index = detailItemWindow.FindItem(delItem.ID);		

		if(index != -1)detailItemWindow.SetNewlyAcquired(index, false);
		index = tmpInven.FindItem(delItem.ID);		
	}
	
	if(index != -1)tmpInven.SetNewlyAcquired(index, false);
}

function int findNewItem(itemID ID)
{
	local int i;
	for(i = 0; i < newItems.Length; i++)
		if(newItems[i].ID == ID)return i ;

	return -1;
}


/********************************************************************************************
 * Gfx ??¬¦¨Ï¬×¡Æ ¬×¬À?¬¤¬¢¬è?? ¬ª¢à¥ì¬Ø ¥ì¬ª ?¬¨¬¡¬®¬¦¬½ ?¬¨¬¡¬®¬¥¬¾ ¬©??¬¤
 * ******************************************************************************************/
/* 
 * 1. ?¬¨¬¡¬®¬¦¬½¬¡¬® ¡í¬Ú¬¢| ¥ì¬©?¬£ ¡Æ¬Ø?¬Þ
 * 2. ?¬¨¬¡¬®¬¦¬½¬¡¬® ¬¡¬°??¬¦¬Õ¬×¢ç???¡© ?¬î¬¢¬è?¬£ ¡Æ¬Ø?¬Þ ¬¢|?¬¾
 */
function showItemUpdateEffect(string param) 
{
	local int index, i;
	local ItemInfo info, newItem, tmpItem;
	local ItemWindowHandle targetItemWnd;
	local string type, strParam;

	ParseString(param, "type", type);
	ParamToItemInfo(param, newItem);	

	//Debug("showItemUpdateEffect" @ param);
	// ¬¡¬Ö¬£¬ê¬¡¬° ¡Æ¬Ø?¬Þ ¬¡¬Ö¬£¬ê, ¬©¬º¬¢| ¢à¬¿?¢à ?¬¤ ¬¡¬®¬¨¬Ö¬¨¢ç¡Æ? ?¬×¬¡¬®¬¢¬è ?¬¬¥ì¥ì¡¤¬± ¬¤?¬×¢ç
	for(i = 0 ; i < EQUIPITEM_TOTAL_CLASSIC ; i ++)
	{
		m_equipItem[i].GetItem(0, tmpItem); 
		if(IsSameServerID(tmpItem.ID, newItem.ID))return;
	}	

	if(type =="delete")return;

	if(IsEquipItem(newItem))
		return;
	else if(IsQuestItem(newItem))	
		targetItemWnd = m_questItem;	
	else
		targetItemWnd = m_invenItem;

	index = targetItemWnd.FindItem(newItem.ID);
	targetItemWnd.GetItem(index, info);

	// Debug("showItemUpdateEffect" @ info.itemNum @  newItem.itemNum);
	if(info.itemNum < newItem.itemNum)
	{
		strParam = "iconName=" $ newItem.iconName;
		strParam = strParam @ "itemNum="$string(newItem.itemNum - info.itemNum);
		//ParamAdd(strParam, "iconName", newItem.iconName);
		//ParamAdd(strParam, "itemNum", string(newItem.itemNum - info.itemNum));
		getInstanceL2Util().showGfxScreenMessage(strParam , getInstanceL2Util().EGfxScreenMsgType.MSGType_AddItemEffect);
	}
}

function CheckCollectionEnableItem(ItemInfo iInfo)
{
	local CollectionSystem collectionSystemScript;

	collectionSystemScript = CollectionSystem(GetScript("collectionSystem"));
	lasetSelectedItemInfo = iInfo;
	if(collectionSystemScript.API_IsCollectionRegistEnableItem(lasetSelectedItemInfo.Id, -1, -1))
	{
		CollectionPointAni.Stop();
		CollectionPointAni.Pause();
		CollectionPointAni.SetLoopCount(9999999);
		CollectionPointAni.ShowWindow();
		CollectionPointAni.Play();	
	}
	else
	{
		CollectionPointAni.Stop();
		CollectionPointAni.Pause();
		CollectionPointAni.HideWindow();
	}
}

function OpenCollectionSelectedItem()
{
	local CollectionSystem collectionSystemScript;

	collectionSystemScript = CollectionSystem(GetScript("collectionSystem"));
	collectionSystemScript.SetToFindItemInfo(lasetSelectedItemInfo);
	collectionSystemScript.API_C_EX_COLLECTION_OPEN_UI();
}

function OpenItemAutoPeelWnd(int itemServerID, bool isAllItem)
{
	m_hOwnerWnd.HideWindow();
	ItemAutoPeelWnd(GetScript("ItemAutoPeelWnd")).RegisterItem(itemServerID, isAllItem);
}

function HandleHair2SlotEnable(string param)
{
	local int Enable;

	ParseInt(param, "Enable", Enable);
	if(Enable != 1)
	{
		Hair2SlotDisable_tex.ShowWindow();
		if(IsAdenServer())
		{
			Hair2SlotDisable_tex.SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(14104)));			
		}
	}
	else
	{
		Hair2SlotDisable_tex.HideWindow();
	}
}

function CustomTooltip getAgathionTooltip( string title, string desc)
{
	local CustomTooltip T;	
	local L2Util util;
	util = L2Util(GetScript("L2Util"));//bluesun ¬¥???¬¦¬¯¬×¢Ò¬¡¬®¬¢¬à ¬¦¬ê¬¨¬¢ 
	util.setCustomTooltip(T);//bluesun ¬¥???¬¦¬¯¬×¢Ò¬¡¬®¬¢¬à ¬¦¬ê¬¨¬¢
	util.ToopTipInsertText(title , true, false, util.ETooltipTextType.COLOR_GRAY);
	util.ToopTipInsertText(desc , true, true, util.ETooltipTextType.COLOR_GRAY);
	return util.getCustomToolTip();
}

function setCustomTooltip()
{
	local L2Util util;
	local CustomTooltip T;
	//local string tmpTooltipString;	

	//T.MinimumWidth = 125;
	util = L2Util(GetScript("L2Util"));//bluesun ¬¥???¬¦¬¯¬×¢Ò¬¡¬®¬¢¬à ¬¦¬ê¬¨¬¢ 
	util.setCustomTooltip(T);//bluesun ¬¥???¬¦¬¯¬×¢Ò¬¡¬®¬¢¬à ¬¦¬ê¬¨¬¢	

	util.ToopTipMinWidth(150);
	util.ToopTipInsertText(GetSystemString(3265), true, false);
	util.TooltipInsertItemBlank(4);	

	util.ToopTipInsertText(GetSystemString(3270), false, true,util.ETooltipTextType.COLOR_GRAY);			
	AlchemyMixCubeWndBtn.SetTooltipCustomType(util.getCustomToolTip());	
	
	util.setCustomTooltip(T);//bluesun ¬¥???¬¦¬¯¬×¢Ò¬¡¬®¬¢¬à ¬¦¬ê¬¨¬¢
	util.ToopTipMinWidth(150);
	util.ToopTipInsertText(GetSystemString(3266), true, false);
	util.TooltipInsertItemBlank(4);	
	util.ToopTipInsertText(GetSystemString(3271), false, true,util.ETooltipTextType.COLOR_GRAY);			
	AlchemyItemConversionWndBtn.SetTooltipCustomType(util.getCustomToolTip());

	AlchemyItemCreateWndBtn.DisableWindow();
	util.setCustomTooltip(T);//bluesun ¬¥???¬¦¬¯¬×¢Ò¬¡¬®¬¢¬à ¬¦¬ê¬¨¬¢	
	util.ToopTipInsertText(GetSystemString(3312), true, false);
	util.TooltipInsertItemBlank(4);
	util.ToopTipInsertText(GetSystemString(3272), false, true,util.ETooltipTextType.COLOR_GRAY);
	AlchemyItemCreateWndBtn.SetTooltipCustomType(util.getCustomToolTip());
}

function toggleAlchemyOpenerTooltip(bool isOn)
{
	local L2Util util;
	local CustomTooltip T;
	
	util = L2Util(GetScript("L2Util"));//bluesun ¬¥???¬¦¬¯¬×¢Ò¬¡¬®¬¢¬à ¬¦¬ê¬¨¬¢
	util.setCustomTooltip(T);//bluesun ¬¥???¬¦¬¯¬×¢Ò¬¡¬®¬¢¬à ¬¦¬ê¬¨¬¢
	
	util.ToopTipInsertText(GetSystemString(3257), true, false);

	if(!isOn)
	{
		util.ToopTipMinWidth(150);
		util.TooltipInsertItemBlank(4);
		util.ToopTipInsertText(GetSystemMessage(4263), false, true,util.ETooltipTextType.COLOR_GRAY);			
	}
	AlchemyOpenerBtn.SetTooltipCustomType(util.getCustomToolTip());
}


/********************************************************************************************
 * etc, util
 * ******************************************************************************************/
 
function bool IsSigil(ItemInfo a_Info)
{
	if(a_Info.ArmorType == 4)
	{
		return true;
	}
	return false;
}

// int 64 ¬¡¬®¡í¬å¬¡¬© ?¬è?¬£ uc ?? ¬¡¬í?¬à¥ì¥ì int ¡Æ?¬¡¬×¡¤¬° ¬¡¬°?¬¥ ¥ì¬ª?¬». string ¬¡¬×¡¤¬° ¢à¬À?¬¨?¡© ?¬è?¬¤¡¤¬° ¬©¬î??¬ª? ¬©¬º¬¢¬Ñ?¬Á ¬©¬¶.
function INT64 GetAgathionSlotBitType(String keyword)
{
	switch(keyword)
	{
		// ?¬¨¡Æ??¬¤?¬£ ¬×¬À¬¡¬°
		case "n":
			return 16;
		case "1":
			return 32;
		case "2":
			return 64;
		case "3":
			return 128;
		case "4":
			return 256;
	}
	return 0;
}

//¬¦¬×¡Æ¬» ¬¡¬®¬×¡×?? ¥ì¬í¬×? ¬¡¨Ï¥ì¥ì?¬Þ ¬©¬¼¥ì¬Û ¢à¬À¡¾¬Ó
function ItemWindowHandle getItemWindowHandleBystrTarget(string strTarget)
{
	switch(strTarget)
	{
		case "InventoryItem":
			return m_invenItem;
		case "InventoryItem_1":
			return m_invenItem_1;
		case "InventoryItem_2":
			return m_invenItem_2;
		case "InventoryItem_3":
			return m_invenItem_3;
		case "InventoryItem_4":
			return m_invenItem_4;
	}
}

//?¬¨¬¡¬®¬¦¬½ ¬¦¬×¬¡¬¶?? ¥ì¬í¬×? ¬¡¨Ï¥ì¥ì?¬Þ ¢à¬À¡¾¬Ó
function ItemWindowHandle getItemWindowHandleByItemType(ItemInfo item)
{
	if(!IsValidItemID(item.Id))
	{
		return m_invenItem_4;
	}

	switch(class'UIDATA_ITEM'.static.GetInventoryType(item.Id.ClassID))
	{
		case EIIT_EQUIPMENT:
			return m_invenItem_1;
		case EIIT_CONSUMABLE:
			return m_invenItem_2;
		case EIIT_MATERIAL:
			return m_invenItem_3;
		case EIIT_ETC:
		case EIIT_NONE:
			return m_invenItem_4;
		case EIIT_QUEST:
			return m_questItem;
	}
	return NONE;
}

private function DelegateOnClickButton(string parentWndName, string strName, int Index)
{
	_RQ_C_EX_DUAL_INVENTORY_SWAP(Index);	
}

function _ResetbRequestHennaOnShow()
{
	bRequestHennaOnShow = true;	
}

function string GetHennaPotenString(int potenID, int activeStep)
{
	local DyePotentialUIData dyePotentialData;
	local SkillInfo SkillInfo;

	class'UIDATA_HENNA'.static.GetDyePotentialData(potenID, dyePotentialData);
	GetSkillInfo(dyePotentialData.SkillID, activeStep, 0, SkillInfo);
	return (dyePotentialData.EffectName @ SkillInfo.SkillDesc) @ GetSystemString(3351);	
}

private function HandleChangeHennaDye(int hennaItemIndex)
{
	local int X, Y;

	GetClientCursorPos(X, Y);
	class'HennaEnchantWnd'.static.Inst()._ShowContextMenu(hennaItemIndex, X, Y);
	class'UIControlContextMenu'.static.GetInstance().Owner = string(self);	
}

function _Handle_S_EX_NEW_HENNA_POTEN_SELECT(UIPacket._S_EX_NEW_HENNA_POTEN_SELECT packet)
{
	local int Index;
	local ItemInfo iInfo;

	if(packet.cSuccess > 0)
	{
		Index = packet.cSlotID - 1;
		hennaItems[Index].GetItem(0, iInfo);
		iInfo.Description = _GetEffectString(Index);
		hennaItems[Index].SetItem(0, iInfo);
	}	
}

function _Handle_S_EX_NEW_HENNA_LIST(UIPacket._S_EX_NEW_HENNA_LIST henna_list_packet)
{
	local int i, HennaID, hennaLevel;
	local ItemInfo iInfo;

	for(i = 0; i < 4; i++)
	{
		hennaItems[i].Clear();
	}
	if(0 == henna_list_packet.hennaInfoList[3].cActive)
	{
		hennas_Disable4.ShowWindow();		
	}
	else
	{
		hennas_Disable4.HideWindow();
	}

	for(i = 0; i < henna_list_packet.hennaInfoList.Length; i++)
	{
		HennaID = henna_list_packet.hennaInfoList[i].nHennaID;
		if(! class'UIDATA_HENNA'.static.GetItemCheck(HennaID))
		{
			// [Explicit Continue]
			continue;
		}
		class'UIDATA_HENNA'.static.GetHennaDyeItemLevel(HennaID, hennaLevel);
		iInfo.Name = class'UIDATA_HENNA'.static.GetItemNameS(HennaID) @ class'UIDATA_HENNA'.static.GetDescriptionS(HennaID);
		iInfo.AdditionalName = MakeFullSystemMsg(GetSystemMessage(5203), string(hennaLevel));
		iInfo.Description = _GetEffectString(i);
		iInfo.IconName = class'UIDATA_HENNA'.static.GetIconTexS(HennaID);
		hennaItems[i].AddItem(iInfo);
	}	
}

function string _GetEffectString(int Index)
{
	local array<string> effectNames;
	local int selectedNum;

	class'HennaEnchantWnd'.static.Inst()._GetEffectStrings(Index, effectNames, selectedNum);
	if(selectedNum > -1)
	{
		return effectNames[selectedNum];
	}
	return "";	
}

function _RQ_C_EX_DUAL_INVENTORY_SWAP(int Index)
{
	local array<byte> stream;
	local UIPacket._C_EX_DUAL_INVENTORY_SWAP packet;

	if(bRequestedDualInventorySwap || SubGroupButtonAsset.bOnDelayTime)
	{
		getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(13799));
		return;
	}
	if(bUnStableSwapping || Index == -1)
	{
		packet.cSwapSlot = _GetSwapSelectButtonIndex();		
	}
	else
	{
		packet.cSwapSlot = Index;
	}
	if(! class'UIPacket'.static.Encode_C_EX_DUAL_INVENTORY_SWAP(stream, packet))
	{
		return;
	}
	class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_DUAL_INVENTORY_SWAP, stream);
	SubGroupButtonAsset._setDelayTime(TIMER_bRequestedDualInventorySwap);
	SubGroupButtonAsset._tryDelayClick();
	bRequestedDualInventorySwap = true;
	m_hOwnerWnd.SetTimer(TIMERID_bRequestedDualInventorySwap, TIMER_bRequestedDualInventorySwap);
	HideWindowsAtSwap();	
}

private function HideWindowsAtSwap()
{
	GetWindowHandle("ItemJewelEnchantwnd").HideWindow();
	GetWindowHandle("ItemMultiEnchantwnd").HideWindow();
	GetWindowHandle("ItemEnchantWnd").HideWindow();
	class'UIAPI_WINDOW'.static.HideWindow("ItemUpgrade");	
}

private function InitDualToDefaultA()
{
	SubGroupButtonAsset._GetGroupButtonsInstance()._setTopOrder(0, true);
	GetTextBoxHandle("HennaMenuWnd.HennaTitle_txt").SetText(GetSystemString(14284));
	GetTextBoxHandle("HennaEnchantWnd.HennaTitle_txt").SetText(GetSystemString(14284));
	GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".DescriptionMsgWnd").HideWindow();
	GetWindowHandle("DualInventorySwapBtn").HideWindow();
	bRequestedDualInventorySwap = false;
	m_hOwnerWnd.KillTimer(TIMERID_bRequestedDualInventorySwap);	
}

private function Handle_EV_RequestDualInventorySwap()
{
	_RQ_C_EX_DUAL_INVENTORY_SWAP((_GetSwapSelectButtonIndex()) ^ 1);	
}

private function Handle_EV_DualInventoryInfo(string param)
{
	local int cActiveSlot, _bStableSwapping, bSuccess;
	local string SetString;

	ParseInt(param, "cActiveSlot", cActiveSlot);
	ParseInt(param, "bSuccess", bSuccess);
	ParseInt(param, "bStableSwapping", _bStableSwapping);
	switch(cActiveSlot)
	{
		case 0:
			SetString = GetSystemString(14274);
			GetTextBoxHandle("HennaMenuWnd.HennaTitle_txt").SetText(GetSystemString(14284));
			GetTextBoxHandle("HennaEnchantWnd.HennaTitle_txt").SetText(GetSystemString(14284));
			break;
		case 1:
			SetString = GetSystemString(14275);
			GetTextBoxHandle("HennaMenuWnd.HennaTitle_txt").SetText(GetSystemString(14285));
			GetTextBoxHandle("HennaEnchantWnd.HennaTitle_txt").SetText(GetSystemString(14285));
			break;
		default:
			break;
	}
	bUnStableSwapping = _bStableSwapping == 0;
	if(bRequestedDualInventorySwap)
	{
		if(bSuccess == 1)
		{
			if(! bUnStableSwapping)
			{
				getInstanceL2Util().showGfxScreenMessage(MakeFullSystemMsg(GetSystemMessage(13797), SetString));
			}			
		}
		else
		{
			getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(13798));
		}
	}
	SubGroupButtonAsset._GetGroupButtonsInstance()._setTopOrder(cActiveSlot, true);
	if(bUnStableSwapping)
	{
		GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".DescriptionMsgWnd").ShowWindow();
		GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".DescriptionMsgWnd").SetFocus();
		GetWindowHandle("DualInventorySwapBtn").ShowWindow();
		getInstanceL2Util().showGfxScreenMessage(GetSystemString(14281));		
	}
	else
	{
		GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".DescriptionMsgWnd").HideWindow();
		GetWindowHandle("DualInventorySwapBtn").HideWindow();
	}
	if(bRequestedDualInventorySwap)
	{
		HennaMenuWnd(GetScript("HennaMenuWnd")).API_C_EX_NEW_HENNA_LIST();
	}
	bRequestedDualInventorySwap = false;
	m_hOwnerWnd.KillTimer(100);
	if(SubGroupButtonAsset.bOnDelayTime)
	{
		SubGroupButtonAsset._setDelayTime(5000);
		SubGroupButtonAsset._tryDelayClick();
	}
	HideWindowsAtSwap();
	BottomBar(GetScript("BottomBar"))._UpdateDualInventoryControls();	
}

function int _GetSwapSelectButtonIndex()
{
	return SubGroupButtonAsset._GetGroupButtonsInstance()._getSelectButtonIndex();	
}

/**
 * ¬¡¨Ï¥ì¥ì?¬Þ ESC ¬¦¡Æ¡¤¬° ?¬¿¡¾¬Ó ¬¤?¬×¢ç 
 * "Esc" Key
 ***/
function OnReceivedCloseUI()
{
	PlayConsoleSound(IFST_WINDOW_CLOSE);
	GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath).HideWindow();
}
