class MultiSellItemExchangeWnd extends UICommonAPI;

const DIALOG_ID_ITEM_SET_COUNT = 1;
const TIMER_UPDATE_ID = 1;
const TIMER_UPDATEDELAY = 1;

struct MultiSellGroupInfo
{
	var int MultisellID;
	var int tabindex;
	var bool Loaded;
	var array<MultiSellInfo> infoList;
};

struct MultiSellRequestInfo
{
	var MultiSellInfo MultiSellInfo;
	var int MultisellID;
	var int exchangeNum;
	var int lastSelectedIndex;
	var bool needSelected;
};

struct NoStackableItemData
{
	var int ClassID;
	var INT64 Count;
};

struct multiSellData
{
	var int PcCafePoint;
	var int clanPoint;
	var int PvPPoint;
	var int RaidPoint;
	var int craftPoint;
	var INT64 vitalityPoint;
	var INT64 adena;
};

var array<ItemExchangeMultisellUIData> _multiSellTabInfos;
var int _selectedTabIndex;
var array<MultiSellGroupInfo> _multiSellGroupInfos;
var int _tempMultiSellInfoIndex;
var int _tempTabIndex;
var int _tempMultiSellId;
var int _tempShowType;
var array<MultiSellInfo> _tempMultiSellInfoList;
var bool _isWaitingResponse;
var MultiSellRequestInfo _requestInfo;
var multiSellData mData;
var UIData UIDataScript;
var bool hasEItemcheck;
var WindowHandle Me;
var WindowHandle disableWnd;
var WindowHandle totalListEmptyWnd;
var WindowHandle availableListEmptyWnd;
var RichListCtrlHandle itemTotalRichList;
var RichListCtrlHandle itemAvailableRichList;
var UIControlGroupButtonAssets tabGroupButtonAsset;
var UIControlNeedItemList needItemScript;
var TabHandle multiSellTab;
var UIControlNumberInput inputItemScript;
var UIControlDialogAssets exchangeDialog;
var UIControlTextInput searchTextInput;
var TextBoxHandle totalListEmptyTextBox;
var TextBoxHandle availableListEmptyTextBox;

static function MultiSellItemExchangeWnd Inst()
{
	return MultiSellItemExchangeWnd(GetScript("MultiSellItemExchangeWnd"));	
}

function Initialize()
{
	InitControls();	
}

function InitControls()
{
	local string ownerFullPath;
	local WindowHandle needItemWnd, exchangeDialogWnd;
	local RichListCtrlHandle needItemRichList;

	ownerFullPath = m_hOwnerWnd.m_WindowNameWithFullPath;
	UIDataScript = UIData(GetScript("UIData"));
	Me = GetWindowHandle(ownerFullPath);
	disableWnd = GetWindowHandle(ownerFullPath $ ".DisableWnd");
	exchangeDialogWnd = GetWindowHandle(ownerFullPath $ ".UIControlDialogAsset");
	exchangeDialog = class'UIControlDialogAssets'.static.InitScript(exchangeDialogWnd);
	exchangeDialog.DelegateOnCancel = OnExchangeDialogCancel;
	exchangeDialog.DelegateOnClickBuy = OnExchangeDialogConfirm;
	exchangeDialog.SetUseBuyItem(true);
	exchangeDialog.SetUseNeedItem(false);
	exchangeDialog.SetUseNumberInput(false);
	exchangeDialog.SetDisableWindow(disableWnd);
	itemTotalRichList = GetRichListCtrlHandle(ownerFullPath $ ".MultisellTabTotalWnd.ItemTotal_RichList");
	itemTotalRichList.SetSelectedSelTooltip(false);
	itemTotalRichList.SetAppearTooltipAtMouseX(true);
	itemAvailableRichList = GetRichListCtrlHandle(ownerFullPath $ ".MultisellTabEnableWnd.ItemEnable_RichList");
	itemAvailableRichList.SetSelectedSelTooltip(false);
	itemAvailableRichList.SetAppearTooltipAtMouseX(true);
	totalListEmptyWnd = GetWindowHandle(ownerFullPath $ ".MultisellTabTotalWnd.TotalListDisable_Wnd");
	totalListEmptyTextBox = GetTextBoxHandle(totalListEmptyWnd.m_WindowNameWithFullPath $ ".TotalListDisable_Txt");
	availableListEmptyWnd = GetWindowHandle(ownerFullPath $ ".MultisellTabEnableWnd.ListDisable_Wnd");
	availableListEmptyTextBox = GetTextBoxHandle(availableListEmptyWnd.m_WindowNameWithFullPath $ ".ListDisable_Txt");
	multiSellTab = GetTabHandle(ownerFullPath $ ".MultiSellTab");
	tabGroupButtonAsset = class'UIControlGroupButtonAssets'.static._InitScript(GetWindowHandle(ownerFullPath $ ".TopGroupButtonAsset"));
	tabGroupButtonAsset._SetStartInfo("L2UI_NewTex.WindowTab.FlatBrown_Tab_One_Unselected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_One_Unselected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_One_Unselected", true);
	tabGroupButtonAsset._GetGroupButtonsInstance().DelegateOnClickButton = OnTabGroupBtnClicked;
	needItemWnd = GetWindowHandle(ownerFullPath $ ".Bottom_Wnd.NeedItemWnd");
	needItemWnd.SetScript("UIControlNeedItemList");
	needItemScript = UIControlNeedItemList(needItemWnd.GetScript());
	needItemRichList = GetRichListCtrlHandle(needItemWnd.m_WindowNameWithFullPath $ ".NeedItemRichListCtrl");
	needItemScript.SetRichListControler(needItemRichList);
	needItemRichList.SetTooltipType("UIControlNeedItemList");
	inputItemScript = class'UIControlNumberInput'.static.InitScript(GetWindowHandle(ownerFullPath $ ".Bottom_Wnd.InputItemWnd"));
	inputItemScript._SetUseCaculator(true);
	inputItemScript.DelegateGetCountCanBuy = MaxNumCanBuy;
	inputItemScript.delegateOnItemCountEdited = OnItemCountChanged;
	inputItemScript.DelegateESCKey = OnItemCountESCKey;
	inputItemScript.DelegateOnClickInput = OnSetCountBtnClicked;
	inputItemScript.DelegateOnClickBuy = OnExchangeBtnClicked;	
	searchTextInput = class'UIControlTextInput'.static.InitScript(GetWindowHandle(ownerFullPath $ ".ItemExchange_Wnd.ItemFind_Wnd.TextInput"));
	searchTextInput.DelegateOnClear = OnSearchTextInputClear;
	searchTextInput.DelegateOnCompleteEditBox = OnSearchTextInputCompleted;
	searchTextInput.SetDisable(false);
	searchTextInput.SetEdtiable(true);
	searchTextInput.SetDefaultString(GetSystemString(2507));
}

function ResetInfo()
{
	_multiSellGroupInfos.Length = 0;
	_multiSellTabInfos.Length = 0;
	_isWaitingResponse = false;
	ResetTempInfo();	
}

function ResetTempInfo()
{
	_tempMultiSellInfoList.Length = 0;
	_tempMultiSellInfoIndex = 0;
	_tempMultiSellId = 0;
	_tempTabIndex = -1;	
}

function InitTabButtonControls(int SelectedIndex)
{
	local int i;

	for(i = 0; i < _multiSellTabInfos.Length; i++)
	{
		tabGroupButtonAsset._GetGroupButtonsInstance()._setButtonText(i, _multiSellTabInfos[i].MultisellName);
		tabGroupButtonAsset._GetGroupButtonsInstance()._setButtonValue(i, i);
		if(_multiSellTabInfos.Length == 1)
		{
			tabGroupButtonAsset._GetGroupButtonsInstance()._setButtonTexture(i, "L2UI_NewTex.WindowTab.FlatBrown_Tab_One_Unselected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_One_Unselected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_One_Unselected");
			// [Explicit Continue]
			continue;
		}
		if(i == 0)
		{
			tabGroupButtonAsset._GetGroupButtonsInstance()._setButtonTexture(i, "L2UI_NewTex.WindowTab.FlatBrown_Tab_Left_Unselected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_Left_Selected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_Left_Unselected_Over");
			// [Explicit Continue]
			continue;
		}
		if(i == _multiSellTabInfos.Length - 1)
		{
			tabGroupButtonAsset._GetGroupButtonsInstance()._setButtonTexture(i, "L2UI_NewTex.WindowTab.FlatBrown_Tab_Right_Unselected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_Right_Selected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_Right_Unselected_Over");
			// [Explicit Continue]
			continue;
		}
		tabGroupButtonAsset._GetGroupButtonsInstance()._setButtonTexture(i, "L2UI_NewTex.WindowTab.FlatBrown_Tab_Center_Unselected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_Center_Selected", "L2UI_NewTex.WindowTab.FlatBrown_Tab_Center_Unselected_Over");
	}
	tabGroupButtonAsset._GetGroupButtonsInstance()._setShowButtonNum(_multiSellTabInfos.Length);
	tabGroupButtonAsset._GetGroupButtonsInstance()._setAutoWidth(594, 0);
	tabGroupButtonAsset._GetGroupButtonsInstance()._setTopOrder(SelectedIndex, true);	
}

function UpdateTabButtonControls();

function UpdateItemListControls()
{
	local MultiSellGroupInfo groupInfo;
	local int i, N, arrayIndex;
	local bool bNoExchange, bCheck;
	local ItemInfo Info;
	local RichListCtrlRowData tempRowData;
	local array<NoStackableItemData> noStackableItemDataArray;
	local string searchStr;

	if(_selectedTabIndex < _multiSellGroupInfos.Length)
	{
		groupInfo = _multiSellGroupInfos[_selectedTabIndex];
	}
	itemTotalRichList.DeleteAllItem();
	itemAvailableRichList.DeleteAllItem();

	searchStr = searchTextInput.GetString();
	for(i = 0; i < groupInfo.infoList.Length; i++)
	{
		bNoExchange = false;
		bCheck = true;
		noStackableItemDataArray.Length = 0;
		Info = groupInfo.infoList[i].OutputItemInfoList[0];

		for(N = 0; N < groupInfo.infoList[i].InputItemInfoList.Length; N++)
		{
			if(IsStackableItem(groupInfo.infoList[i].InputItemInfoList[N].ConsumeType))
			{
				bCheck = CompareWithInven(groupInfo.infoList[i].InputItemInfoList[N]);				
			}
			else
			{
				arrayIndex = GetNoStackableItemCountArrayIndex(groupInfo.infoList[i].InputItemInfoList[N], noStackableItemDataArray);
				bCheck = CompareWithInven(groupInfo.infoList[i].InputItemInfoList[N], noStackableItemDataArray[arrayIndex]);
			}
			if(bCheck == false)
			{
				bNoExchange = true;
				// [Explicit Continue]
				continue;
			}
		}
		if(searchStr == "" || searchStr != "" && StringMatching(Info.Name, searchStr, " "))
		{
			if(bNoExchange == false)
			{
				Info.ForeTexture = "L2UI_CT1.SellablePanel";
				AddItemRichListCtrl(itemAvailableRichList, Info, i);
			}
			if(true)
			{
				AddItemRichListCtrl(itemTotalRichList, Info, i);
			}
		}
	}
	if(searchStr == "")
	{
		totalListEmptyTextBox.SetText(GetSystemMessage(4357));
		availableListEmptyTextBox.SetText(GetSystemMessage(4357));		
	}
	else
	{
		totalListEmptyTextBox.SetText(GetSystemString(14184));
		availableListEmptyTextBox.SetText(GetSystemString(14184));
	}
	if(itemTotalRichList.GetRecordCount() > 0)
	{
		totalListEmptyWnd.HideWindow();		
	}
	else
	{
		totalListEmptyWnd.ShowWindow();
	}
	if(itemAvailableRichList.GetRecordCount() > 0)
	{
		availableListEmptyWnd.HideWindow();		
	}
	else
	{
		availableListEmptyWnd.ShowWindow();
	}
	if(_requestInfo.needSelected == true)
	{
		_requestInfo.needSelected = false;
		if(_requestInfo.lastSelectedIndex > -1)
		{
			if(multiSellTab.GetTopIndex() == 0)
			{
				for(i = 0; i < itemTotalRichList.GetRecordCount(); i++)
				{
					itemTotalRichList.GetRec(i, tempRowData);
					if(tempRowData.nReserved2 == _requestInfo.lastSelectedIndex)
					{
						itemTotalRichList.SetSelectedIndex(i, true);
						// [Explicit Break]
						break;
					}
				}
			}
			else
			{
				for(i = 0; i < itemAvailableRichList.GetRecordCount(); i++)
				{
					itemAvailableRichList.GetRec(i, tempRowData);
					if(tempRowData.nReserved2 == _requestInfo.lastSelectedIndex)
					{
						itemAvailableRichList.SetSelectedIndex(i, true);
						// [Explicit Break]
						break;
					}
				}
			}
		}
	}	
}

function UpdateItemInfoControls(optional bool modifyList)
{
	local int i;
	local MultiSellInfo MultiSellInfo;

	if(modifyList == false)
	{
		needItemScript.StartNeedItemList(2);
	}
	if(GetSelectedMultiSellInfo(MultiSellInfo))
	{
		for(i = 0; i < MultiSellInfo.InputItemInfoList.Length; i++)
		{
			if(isPointType(MultiSellInfo.InputItemInfoList[i]))
			{
				needItemScript.AddNeedPoint(MultiSellInfo.InputItemInfoList[i].Name, MultiSellInfo.InputItemInfoList[i].IconName, MultiSellInfo.InputItemInfoList[i].ItemNum, getHasItemOrPointCount(MultiSellInfo.InputItemInfoList[i]));
				// [Explicit Continue]
				continue;
			}
			needItemScript.AddNeedItemClassID(MultiSellInfo.InputItemInfoList[i].Id.ClassID, MultiSellInfo.InputItemInfoList[i].ItemNum);
		}
		if(needItemScript.GetMaxNumCanBuy() > 0)
		{
			inputItemScript.SetCount(1);			
		}
		else
		{
			inputItemScript.SetCount(0);
		}		
	}
	else
	{
		inputItemScript.SetCount(0);
	}
}

function UpdateUIControlsWithTimer()
{
	Me.KillTimer(TIMER_UPDATE_ID);
	Me.SetTimer(TIMER_UPDATE_ID, TIMER_UPDATEDELAY);	
}

function UpdateUIControls()
{
	UpdateTabButtonControls();
	UpdateItemListControls();
	UpdateItemInfoControls();	
}

function AddItemRichListCtrl(RichListCtrlHandle itemListCtrl, ItemInfo Info, int Index)
{
	local RichListCtrlRowData Record;
	local string fullNameString, toolTipParam;
	local L2Util util;

	fullNameString = GetItemNameAll(Info, true);
	util = getInstanceL2Util();
	ItemInfoToParam(Info, toolTipParam);
	Record.szReserved = toolTipParam;
	Record.cellDataList.Length = 1;
	Record.nReserved1 = Info.ConsumeType;
	Record.nReserved2 = Index;
	addRichListCtrlTexture(Record.cellDataList[0].drawitems, "l2ui_ct1.ItemWindow_DF_SlotBox_Default", 36, 36, 8, 1);
	AddRichListCtrlItem(Record.cellDataList[0].drawitems, Info, 32, 32, -34, 1);
	if(Info.IconPanel != "")
	{
		addRichListCtrlTexture(Record.cellDataList[0].drawitems, Info.IconPanel, 32, 32, -32, 0);
	}
	if(Info.IsBlessedItem)
	{
		addRichListCtrlTexture(Record.cellDataList[0].drawitems, "Icon.icon_panel.bless_panel", 32, 32, -32, 0);
	}
	if(Info.Enchanted > 0)
	{
	}
	if(Info.ForeTexture != "")
	{
		addRichListCtrlTexture(Record.cellDataList[0].drawitems, Info.ForeTexture, 32, 32, -32, 0);
	}
	if(IsStackableItem(Info.ConsumeType))
	{
		addRichListCtrlString(Record.cellDataList[0].drawitems, fullNameString, util.White, false, 6, 10);
		if(Info.AdditionalName != "")
		{
			addRichListCtrlString(Record.cellDataList[0].drawitems, Info.AdditionalName, util.Yellow03, false, 3, 0);
		}
		if(Info.ItemNum > 0)
		{
			addRichListCtrlString(Record.cellDataList[0].drawitems, "(" $ string(Info.ItemNum) $ ")", util.White, false, 0, 0);			
		}
		else
		{
			addRichListCtrlString(Record.cellDataList[0].drawitems, "(1)", util.White, false, 0, 0);
		}		
	}
	else
	{
		addRichListCtrlString(Record.cellDataList[0].drawitems, fullNameString, util.White, false, 6, 10);
		if(Info.AdditionalName != "")
		{
			addRichListCtrlString(Record.cellDataList[0].drawitems, Info.AdditionalName, util.Yellow03, false, 3, 0);
		}
	}
	itemListCtrl.InsertRecord(Record);	
}

function ShowItemCountDialog()
{
	local ItemInfo Info;

	DialogHide();
	Debug("ShowItemCountDialog");
	DialogSetReservedItemID(Info.Id);
	DialogSetParamInt64(needItemScript.GetMaxNumCanBuy());
	DialogSetID(DIALOG_ID_ITEM_SET_COUNT);
	DialogSetCancelD(DIALOG_ID_ITEM_SET_COUNT);
	disableWnd.ShowWindow();
	disableWnd.SetFocus();
	searchTextInput.SetEdtiable(false);
	DialogShow(DialogModalType_Modalless, DialogType_NumberPad, GetSystemMessage(4362), string(self));
	class'DialogBox'.static.Inst().AnchorToOwner(0, 100);
	class'DialogBox'.static.Inst().DelegateOnCancel = OnItemCountDialogCancel;
	class'DialogBox'.static.Inst().DelegateOnOK = OnItemCountDialogConfirm;
	class'DialogBox'.static.Inst().DelegateOnHide = OnItemCountDialogHide;
	class'DialogBox'.static.Inst().SetDefaultAction(EDefaultCancel);	
}

function ShowExchangeDialog()
{
	local ItemInfo ItemInfo, inputItemInfo;
	local MultiSellInfo MultiSellInfo;
	local int inputItemCnt, i, descId;

	if(DialogIsMine())
	{
		DialogHide();
	}
	if((GetSelectedMultiSellInfo(MultiSellInfo)) == false)
	{
		return;
	}
	if(_selectedTabIndex >= _multiSellGroupInfos.Length)
	{
		return;
	}
	inputItemCnt = int(inputItemScript.GetCount());
	if(inputItemCnt <= 0)
	{
		return;
	}
	hasEItemcheck = false;

	for(i = 0; i < MultiSellInfo.InputItemInfoList.Length; i++)
	{
		inputItemInfo = MultiSellInfo.InputItemInfoList[i];
		if(inputItemInfo.ItemType == 0 || inputItemInfo.ItemType == 1 || inputItemInfo.ItemType == 2)
		{
			if((isPointType(inputItemInfo)) == false)
			{
				hasEItemcheck = true;
			}
		}
	}
	_requestInfo.MultiSellInfo = MultiSellInfo;
	_requestInfo.exchangeNum = inputItemCnt;
	_requestInfo.MultisellID = _multiSellGroupInfos[_selectedTabIndex].MultisellID;
	ItemInfo = MultiSellInfo.OutputItemInfoList[0];
	if(hasEItemcheck)
	{
		descId = 13801;		
	}
	else
	{
		descId = 13800;
	}
	exchangeDialog.SetDialogDesc(MakeFullSystemMsg(GetSystemMessage(descId), GetItemNameAll(ItemInfo)));
	exchangeDialog.SetBuyItemInfo(ItemInfo, int(ItemInfo.ItemNum), 0);
	exchangeDialog.SetItemNum(_requestInfo.exchangeNum);
	exchangeDialog.OKButton.EnableWindow();
	exchangeDialog.Show();
	searchTextInput.SetEdtiable(false);	
}

function int GetNoStackableItemCountArrayIndex(ItemInfo inputItemInfo, out array<NoStackableItemData> noStackableItemDataArray)
{
	local int arrayIndex, nClassID;
	local INT64 noStackableNeedItemNum;
	local array<ItemInfo> hasItemInfoArray;

	if(! IsStackableItem(inputItemInfo.ConsumeType))
	{
		nClassID = inputItemInfo.Id.ClassID;
		noStackableNeedItemNum = class'UIDATA_INVENTORY'.static.FindItemByClassID(nClassID, hasItemInfoArray);
		arrayIndex = GetIndexArray(nClassID, noStackableItemDataArray);
		if(arrayIndex == -1)
		{
			noStackableItemDataArray.Length = noStackableItemDataArray.Length + 1;
			if(noStackableItemDataArray.Length > 0)
			{
				noStackableItemDataArray[noStackableItemDataArray.Length - 1].ClassID = nClassID;
				noStackableItemDataArray[noStackableItemDataArray.Length - 1].Count = noStackableNeedItemNum;
			}
			if(arrayIndex == -1)
			{
				arrayIndex = noStackableItemDataArray.Length - 1;
			}			
		}
		else
		{
			if(noStackableItemDataArray[arrayIndex].Count > 0)
			{
				noStackableItemDataArray[arrayIndex].Count = noStackableItemDataArray[arrayIndex].Count - 1;
			}
		}
	}
	return arrayIndex;	
}

function int GetSelectedItemIndex()
{
	local int selectedListIndex;
	local RichListCtrlRowData Record;

	selectedListIndex = -1;
	if(multiSellTab.GetTopIndex() == 0)
	{
		selectedListIndex = itemTotalRichList.GetSelectedIndex();
		if(selectedListIndex >= 0)
		{
			itemTotalRichList.GetSelectedRec(Record);
			return int(Record.nReserved2);
		}		
	}
	else
	{
		selectedListIndex = itemAvailableRichList.GetSelectedIndex();
		if(selectedListIndex >= 0)
		{
			itemAvailableRichList.GetSelectedRec(Record);
			return int(Record.nReserved2);
		}
	}
	return selectedListIndex;	
}

function bool GetSelectedMultiSellInfo(out MultiSellInfo MultiSellInfo)
{
	local int SelectedIndex;

	SelectedIndex = GetSelectedItemIndex();
	if(SelectedIndex == -1)
	{
		return false;
	}
	if(_selectedTabIndex < _multiSellGroupInfos.Length)
	{
		if(SelectedIndex < _multiSellGroupInfos[_selectedTabIndex].infoList.Length)
		{
			MultiSellInfo = _multiSellGroupInfos[_selectedTabIndex].infoList[SelectedIndex];
			return true;
		}
	}
	return false;	
}

function int GetIndexArray(int ClassID, out array<NoStackableItemData> noStackableItemDataArray)
{
	local int i;

	for(i = 0; i < noStackableItemDataArray.Length; i++)
	{
		if(noStackableItemDataArray[i].ClassID == ClassID)
		{
			return i;
		}
	}
	return -1;	
}

function bool CompareWithInven(ItemInfo Info, optional NoStackableItemData noStackableItemDataInfo)
{
	local ItemInfo InvenItemInfo;
	local bool flag;
	local int hasItemCount;
	local array<ItemInfo> itemInfoArr;

	if(Info.IconName == GetPcCafeItemIconPackageName())
	{
		if(mData.PcCafePoint >= Info.ItemNum)
		{
			return true;
		}		
	}
	else if(Info.IconName == "icon.etc_i.etc_bloodpledge_point_i00")
	{
		if(mData.clanPoint >= Info.ItemNum)
		{
			return true;
		}			
	}
	else if(Info.IconName == "icon.pvp_point_i00")
	{
		if(mData.PvPPoint >= Info.ItemNum)
		{
			return true;
		}				
	}
	else if(Info.IconName == "icon.etc_i.etc_rp_point_i00")
	{
		if(mData.RaidPoint >= Info.ItemNum)
		{
			return true;
		}					
	}
	else if(Info.IconName == "Icon.etc_i.craft_point")
	{
		if(mData.craftPoint >= Info.ItemNum)
		{
			return true;
		}						
	}
	else if(Info.IconName == "icon.etc_sayha_point_01")
	{
		if(mData.vitalityPoint >= Info.ItemNum)
		{
			return true;
		}							
	}
	else if(Info.Id.ClassID > 0)
	{
		itemInfoArr.Length = 0;
		hasItemCount = class'UIDATA_INVENTORY'.static.FindItemByClassID(Info.Id.ClassID, itemInfoArr);
		if(hasItemCount > 0)
		{
			InvenItemInfo = itemInfoArr[0];
			if(IsStackableItem(InvenItemInfo.ConsumeType))
			{
				if(InvenItemInfo.ItemNum >= Info.ItemNum)
				{
					return true;
				}										
			}
			else
			{
				if(noStackableItemDataInfo.ClassID > 0)
				{
					if(noStackableItemDataInfo.Count > 0)
					{
						flag = true;
					}
				}
				return flag;
			}
		}
	}
	return false;	
}

function bool isPointType(ItemInfo Info)
{
	local bool RValue;

	if(Info.IconName == GetPcCafeItemIconPackageName())
	{
		RValue = true;		
	}
	else if(Info.IconName == "icon.etc_i.etc_bloodpledge_point_i00")
	{
		RValue = true;			
	}
	else if(Info.IconName == "icon.pvp_point_i00")
	{
		RValue = true;				
	}
	else if(Info.IconName == "icon.etc_i.etc_rp_point_i00")
	{
		RValue = true;					
	}
	else if(Info.IconName == "Icon.etc_i.craft_point")
	{
		RValue = true;						
	}
	else if(Info.IconName == "icon.etc_sayha_point_01")
	{
		RValue = true;
	}

	return RValue;	
}

function INT64 getHasItemOrPointCount(ItemInfo Info)
{
	local INT64 hasNum;
	local array<ItemInfo> itemInfoArray;
	local int ItemCount;

	if(Info.IconName == GetPcCafeItemIconPackageName())
	{
		hasNum = mData.PcCafePoint;		
	}
	else if(Info.IconName == "icon.etc_i.etc_bloodpledge_point_i00")
	{
		hasNum = mData.clanPoint;			
	}
	else if(Info.IconName == "icon.pvp_point_i00")
	{
		hasNum = mData.PvPPoint;				
	}
	else if(Info.IconName == "icon.etc_i.etc_rp_point_i00")
	{
		hasNum = mData.RaidPoint;					
	}
	else if(Info.IconName == "Icon.etc_i.craft_point")
	{
		hasNum = mData.craftPoint;						
	}
	else if(Info.IconName == "icon.etc_sayha_point_01")
	{
		hasNum = mData.vitalityPoint;							
	}
	else
	{
		ItemCount = class'UIDATA_INVENTORY'.static.FindItemByClassID(Info.Id.ClassID, itemInfoArray);
		if(ItemCount > 0)
		{
			hasNum = itemInfoArray[0].ItemNum;
		}
	}
	return hasNum;	
}

function updateMultiSellData(optional string serverUpdateParam)
{
	local int nPointCount, nPoint, nType, N;
	local UserInfo PlayerInfo;

	GetPlayerInfo(PlayerInfo);
	ParseInt(serverUpdateParam, "NumPoint", nPointCount);
	
	for(N = 0; N < nPointCount; N++)
	{
		ParseInt(serverUpdateParam, "Type" $ string(N), nType);
		ParseInt(serverUpdateParam, "Point" $ string(N), nPoint);
		if(MSIT_RAID_POINT == nType)
		{
			mData.PvPPoint = nPoint;
			// [Explicit Continue]
			continue;
		}
		if(MSIT_PVP_POINT == nType)
		{
			mData.PvPPoint = nPoint;
			// [Explicit Continue]
			continue;
		}
		if(MSIT_PLEDGE_POINT == nType)
		{
			mData.clanPoint = nPoint;
			UIDataScript.setCurrentClanNameValue(nPoint);
			// [Explicit Continue]
			continue;
		}
		if(MSIT_PCCAFE_POINT == nType)
		{
			mData.PcCafePoint = nPoint;
			UIDataScript.setPcCafePoint(nPoint);
			// [Explicit Continue]
			continue;
		}
		if(MSIT_CRAFT_POINT == nType)
		{
			mData.craftPoint = nPoint;
		}
	}
	if(nPointCount <= 0)
	{
		mData.PvPPoint = PlayerInfo.PvPPoint;
		mData.RaidPoint = PlayerInfo.RaidPoint;
		mData.PcCafePoint = UIDataScript.getCurrentPcCafePoint();
		mData.clanPoint = UIDataScript.getCurrentClanNameValue();
		mData.craftPoint = UIDataScript.getCurrentCraftPoint();
	}
	mData.vitalityPoint = UIDataScript.getCurrentVitalityPoint();	
}

function INT64 MaxNumCanBuy()
{
	local MultiSellInfo MultiSellInfo;
	local INT64 Count;

	if(GetSelectedMultiSellInfo(MultiSellInfo))
	{
		if(IsStackableItem(MultiSellInfo.OutputItemInfoList[0].ConsumeType))
		{
			Count = int(needItemScript.GetMaxNumCanBuy());			
		}
		else
		{
			Count = Min(1, int(needItemScript.GetMaxNumCanBuy()));
		}
		return Count;
	}
	return 0;	
}

event OnRegisterEvent()
{
	RegisterEvent(EV_MultiSellInfoListBegin);
	RegisterEvent(EV_MultiSellResultItemInfo);
	RegisterEvent(EV_MultiSellOutputItemInfo);
	RegisterEvent(EV_MultiSellInputItemInfo);
	RegisterEvent(EV_MultiSellInfoListEnd);
	RegisterEvent(EV_MultiSellResult);
	RegisterEvent(EV_ShowSimpleItemExchangeMultisellWnd);
	RegisterEvent(EV_DialogOK);
	RegisterEvent(EV_DialogCancel);	
}

event OnEvent(int Event_ID, string param)
{
	switch(Event_ID)
	{
		case EV_ShowSimpleItemExchangeMultisellWnd:
			Rs_EV_ShowSimpleItemExchangeMultisellWnd(param);
			break;
	}
	if(Me.IsShowWindow() == false)
	{
		return;
	}
	if(Event_ID == EV_MultiSellInfoListBegin)
	{
		ParseInt(param, "ShowType", _tempShowType);
	}
	if(_tempShowType == 4)
	{
		switch(Event_ID)
		{
			case EV_MultiSellInfoListBegin:
				Rs_EV_MultiSellInfoListBegin(param);
				break;
			case EV_MultiSellResultItemInfo:
				Rs_EV_MultiSellResultItemInfo(param);
				break;
			case EV_MultiSellOutputItemInfo:
				Rs_EV_MultiSellOutputItemInfo(param);
				break;
			case EV_MultiSellInputItemInfo:
				Rs_EV_MultiSellInputItemInfo(param);
				break;
			case EV_MultiSellInfoListEnd:
				Rs_EV_MultiSellInfoListEnd(param);
				break;
			case EV_MultiSellResult:
				Nt_EV_MultiSellResult(param);
				break;
		}
	}
}

event OnLoad()
{
	SetClosingOnESC();
	Initialize();	
}

event OnShow()
{
	getInstanceL2Util().ItemRelationWindowHide(getCurrentWindowName(string(self)));
	Me.SetFocus();	
}

event OnHide()
{
	if(DialogIsMine())
	{
		DialogHide();
	}
	exchangeDialog.Hide();
	ResetInfo();
	needItemScript.CleariObjects();
	Me.KillTimer(TIMER_UPDATE_ID);	
}

function OnTimer(int TimerID)
{
	if(TimerID == TIMER_UPDATE_ID)
	{
		UpdateUIControls();
		Me.KillTimer(TIMER_UPDATE_ID);
	}	
}

event OnSearchBtnClicked()
{
	UpdateItemListControls();	
}

event OnSearchTextInputClear()
{
	searchTextInput.Clear();
	UpdateItemListControls();	
}

event OnSearchTextInputCompleted(string Text)
{
	UpdateItemListControls();	
}

event OnTabGroupBtnClicked(string parentWndName, string strName, int Index)
{
	local int MultisellID;

	_selectedTabIndex = Index;
	if(Index < _multiSellTabInfos.Length)
	{
		MultisellID = _multiSellTabInfos[Index].MultisellID;
		if(MultisellID > 0)
		{
			if(Index < _multiSellGroupInfos.Length && _multiSellGroupInfos[Index].MultisellID == MultisellID && _multiSellGroupInfos[Index].Loaded)
			{
				UpdateUIControls();				
			}
			else
			{
				Rq_C_EX_MULTI_SELL_LIST(MultisellID, Index);
			}
		}
	}	
}

event OnClickButton(string btnName)
{
	switch(btnName)
	{
		case "MultiSellTab0":
		case "MultiSellTab1":
			UpdateItemInfoControls();
			break;
		case "BtnFind":
			UpdateItemListControls();
			break;
	}	
}

function OnDBClickListCtrlRecord(string ListCtrlID)
{
	if(Me.IsShowWindow())
	{
		ShowExchangeDialog();
	}	
}

event OnItemCountChanged(INT64 ItemCount)
{
	ItemCount = MAX64(1, ItemCount);
	needItemScript.SetBuyNum(int(ItemCount));	
}

event OnSetCountBtnClicked()
{
	ShowItemCountDialog();	
}

event OnExchangeBtnClicked()
{
	ShowExchangeDialog();	
}

event OnItemCountDialogCancel();

event OnItemCountDialogConfirm()
{
	if(DialogIsMine())
	{
		inputItemScript.SetCount(int(DialogGetString()));
	}	
}

event OnItemCountDialogHide()
{
	disableWnd.HideWindow();
	searchTextInput.SetEdtiable(true);	
}

event OnExchangeDialogConfirm()
{
	local string param;
	local MultiSellInfo MultiSellInfo;

	MultiSellInfo = _requestInfo.MultiSellInfo;
	ParamAdd(param, "MultiSellGroupID", string(_requestInfo.MultisellID));
	ParamAdd(param, "MultiSellInfoID", string(MultiSellInfo.MultiSellInfoID));
	ParamAdd(param, "ItemCount", string(_requestInfo.exchangeNum));
	ParamAdd(param, "Enchant", string(MultiSellInfo.ResultItemInfo.Enchanted));
	ParamAdd(param, "RefineryOp1", string(MultiSellInfo.ResultItemInfo.RefineryOp1));
	ParamAdd(param, "RefineryOp2", string(MultiSellInfo.ResultItemInfo.RefineryOp2));
	ParamAdd(param, "AttrAttackType", string(MultiSellInfo.ResultItemInfo.AttackAttributeType));
	ParamAdd(param, "AttrAttackValue", string(MultiSellInfo.ResultItemInfo.AttackAttributeValue));
	ParamAdd(param, "AttrDefenseValueFire", string(MultiSellInfo.ResultItemInfo.DefenseAttributeValueFire));
	ParamAdd(param, "AttrDefenseValueWater", string(MultiSellInfo.ResultItemInfo.DefenseAttributeValueWater));
	ParamAdd(param, "AttrDefenseValueWind", string(MultiSellInfo.ResultItemInfo.DefenseAttributeValueWind));
	ParamAdd(param, "AttrDefenseValueEarth", string(MultiSellInfo.ResultItemInfo.DefenseAttributeValueEarth));
	ParamAdd(param, "AttrDefenseValueHoly", string(MultiSellInfo.ResultItemInfo.DefenseAttributeValueHoly));
	ParamAdd(param, "AttrDefenseValueUnholy", string(MultiSellInfo.ResultItemInfo.DefenseAttributeValueUnholy));
	addParamEnsoulOptionInfo(MultiSellInfo.ResultItemInfo, param);
	ParamAdd(param, "IsBlessedItem", string(boolToNum(MultiSellInfo.ResultItemInfo.IsBlessedItem)));
	_requestInfo.lastSelectedIndex = GetSelectedItemIndex();
	_requestInfo.needSelected = true;
	RequestMultiSellChoose(param);
	exchangeDialog.Hide();
	searchTextInput.SetEdtiable(true);
}

event OnExchangeDialogCancel()
{
	exchangeDialog.Hide();
	searchTextInput.SetEdtiable(true);
}

event OnClickListCtrlRecord(string ListCtrlID)
{
	switch(ListCtrlID)
	{
		case "ItemTotal_RichList":
			UpdateItemInfoControls();
			break;
		case "ItemEnable_RichList":
			UpdateItemInfoControls();
			break;
	}	
}

event OnItemCountESCKey()
{
	if(multiSellTab.GetTopIndex() == 0)
	{
		itemTotalRichList.SetFocus();		
	}
	else
	{
		itemAvailableRichList.SetFocus();
	}	
}

event OnReceivedCloseUI()
{
	if(exchangeDialog.Me.IsShowWindow())
	{
		exchangeDialog.Hide();		
	}
	else
	{
		PlayConsoleSound(IFST_WINDOW_CLOSE);
		Me.HideWindow();
	}	
}

function OpenWindow(int ItemClassID)
{
	searchTextInput.Clear();
	if(Me.IsShowWindow())
	{
		Me.HideWindow();
		return;
	}
	if(IsPlayerOnWorldRaidServer())
	{
		getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(4047));
		return;
	}
	ResetInfo();
	multiSellTab.SetTopOrder(0, false);
	inputItemScript.SetCount(0);
	disableWnd.HideWindow();
	searchTextInput.SetEdtiable(true);
	updateMultiSellData();
	GetItemExchangeMultisellData(ItemClassID, _multiSellTabInfos);
	_selectedTabIndex = 0;
	hasEItemcheck = false;
	InitTabButtonControls(_selectedTabIndex);
	Rq_C_EX_MULTI_SELL_LIST(_multiSellTabInfos[_selectedTabIndex].MultisellID, _selectedTabIndex);
	UpdateUIControls();
	Me.ShowWindow();	
}

function addEnsoulInfo(int slotType, int slotCount, string param, out ItemInfo Info)
{
	local int N, nEOptionID;

	for(N = 1; N < slotCount + 1; N++)
	{
		ParseInt(param, "EnsoulOptionID_" $ string(slotType) $ "_" $ string(N), nEOptionID);
		Info.EnsoulOption[slotType - 1].OptionArray[N - 1] = nEOptionID;
	}	
}

function Rq_C_EX_MULTI_SELL_LIST(int MultisellID, int tabindex)
{
	local array<byte> stream;
	local UIPacket._C_EX_MULTI_SELL_LIST packet;

	packet.nGroupID = MultisellID;
	if(tabindex < _multiSellGroupInfos.Length)
	{
		if((_multiSellGroupInfos[tabindex].MultisellID == MultisellID) && _multiSellGroupInfos[tabindex].Loaded)
		{
			return;
		}
	}
	if(_isWaitingResponse == true)
	{
		return;
	}
	if(! class'UIPacket'.static.Encode_C_EX_MULTI_SELL_LIST(stream, packet))
	{
		return;
	}
	class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_MULTI_SELL_LIST, stream);
	_isWaitingResponse = true;	
}

function Rs_EV_ShowSimpleItemExchangeMultisellWnd(string param)
{
	local int ItemClassID;

	ParseInt(param, "ItemClassID", ItemClassID);
	OpenWindow(ItemClassID);	
}

function Rs_EV_MultiSellInfoListBegin(string param)
{
	ParseInt(param, "MultiSellGroupID", _tempMultiSellId);
	_tempTabIndex = _selectedTabIndex;	
}

function Rs_EV_MultiSellResultItemInfo(string param)
{
	local int nMultiSellInfoID, nBuyType, nIsBlessedItem, ensoulNormalSlot, ensoulBmSlot;

	local ItemInfo Info;

	ParseInt(param, "MultiSellInfoID", nMultiSellInfoID);
	ParseInt(param, "BuyType", nBuyType);
	ParseInt(param, "Enchanted", Info.Enchanted);
	ParseInt(param, "RefineryOp1", Info.RefineryOp1);
	ParseInt(param, "RefineryOp2", Info.RefineryOp2);
	ParseInt(param, "AttackAttributeType", Info.AttackAttributeType);
	ParseInt(param, "AttackAttributeValue", Info.AttackAttributeValue);
	ParseInt(param, "DefenseAttributeValueFire", Info.DefenseAttributeValueFire);
	ParseInt(param, "DefenseAttributeValueWater", Info.DefenseAttributeValueWater);
	ParseInt(param, "DefenseAttributeValueWind", Info.DefenseAttributeValueWind);
	ParseInt(param, "DefenseAttributeValueEarth", Info.DefenseAttributeValueEarth);
	ParseInt(param, "DefenseAttributeValueHoly", Info.DefenseAttributeValueHoly);
	ParseInt(param, "DefenseAttributeValueUnholy", Info.DefenseAttributeValueUnholy);
	ParseInt(param, "EnsoulOptionNum_" $ string(2), ensoulBmSlot);
	ParseInt(param, "EnsoulOptionNum_" $ string(1), ensoulNormalSlot);
	addEnsoulInfo(2, ensoulBmSlot, param, Info);
	addEnsoulInfo(1, ensoulNormalSlot, param, Info);
	ParseInt(param, "IsBlessedItem", nIsBlessedItem);
	Info.IsBlessedItem = numToBool(nIsBlessedItem);
	_tempMultiSellInfoIndex = _tempMultiSellInfoList.Length;
	_tempMultiSellInfoList.Length = _tempMultiSellInfoList.Length + 1;
	_tempMultiSellInfoList[_tempMultiSellInfoIndex].MultiSellInfoID = nMultiSellInfoID;
	_tempMultiSellInfoList[_tempMultiSellInfoIndex].MultiSellType = nBuyType;
	_tempMultiSellInfoList[_tempMultiSellInfoIndex].ResultItemInfo = Info;	
}

function Rs_EV_MultiSellOutputItemInfo(string param)
{
	local int nMultiSellInfoID, nCurrentOutputItemInfoIndex, nIsBlessedItem, nItemClassID, ensoulNormalSlot, ensoulBmSlot;

	local ItemInfo Info;

	ParseItemID(param, Info.Id);
	class'UIDATA_ITEM'.static.GetItemInfo(Info.Id, Info);
	ParseInt(param, "ClassID", nItemClassID);
	ParseInt(param, "MultiSellInfoID", nMultiSellInfoID);
	ParseINT64(param, "SlotBitType", Info.SlotBitType);
	ParseInt(param, "ItemType", Info.ItemType);
	ParseINT64(param, "ItemCount", Info.ItemNum);
	ParseInt(param, "Enchanted", Info.Enchanted);
	ParseInt(param, "RefineryOp1", Info.RefineryOp1);
	ParseInt(param, "RefineryOp2", Info.RefineryOp2);
	ParseInt(param, "AttackAttributeType", Info.AttackAttributeType);
	ParseInt(param, "AttackAttributeValue", Info.AttackAttributeValue);
	ParseInt(param, "DefenseAttributeValueFire", Info.DefenseAttributeValueFire);
	ParseInt(param, "DefenseAttributeValueWater", Info.DefenseAttributeValueWater);
	ParseInt(param, "DefenseAttributeValueWind", Info.DefenseAttributeValueWind);
	ParseInt(param, "DefenseAttributeValueEarth", Info.DefenseAttributeValueEarth);
	ParseInt(param, "DefenseAttributeValueHoly", Info.DefenseAttributeValueHoly);
	ParseInt(param, "DefenseAttributeValueUnholy", Info.DefenseAttributeValueUnholy);
	ParseInt(param, "EnsoulOptionNum_" $ string(2), ensoulBmSlot);
	ParseInt(param, "EnsoulOptionNum_" $ string(1), ensoulNormalSlot);
	addEnsoulInfo(2, ensoulBmSlot, param, Info);
	addEnsoulInfo(1, ensoulNormalSlot, param, Info);
	ParseInt(param, "IsBlessedItem", nIsBlessedItem);
	Info.IsBlessedItem = numToBool(nIsBlessedItem);
	if(_tempMultiSellInfoList[_tempMultiSellInfoIndex].MultiSellInfoID != nMultiSellInfoID)
	{
		return;
	}
	if(nItemClassID == MSIT_PCCAFE_POINT)
	{
		Info.Name = GetSystemString(1277);
		Info.IconName = GetPcCafeItemIconPackageName();
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;		
	}
	else if(nItemClassID == MSIT_PLEDGE_POINT)
	{
		Info.Name = GetSystemString(1311);
		Info.IconName = "icon.etc_i.etc_bloodpledge_point_i00";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;			
	}
	else if(nItemClassID == MSIT_PVP_POINT)
	{
		Info.Name = GetSystemString(102);
		Info.IconName = "icon.pvp_point_i00";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;				
	}
	else if(nItemClassID == MSIT_RAID_POINT)
	{
		Info.Name = GetSystemString(3183);
		Info.IconName = "icon.etc_i.etc_rp_point_i00";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;					
	}
	else if(nItemClassID == MSIT_CRAFT_POINT)
	{
		Info.Name = GetSystemString(13159);
		Info.IconName = "Icon.etc_i.craft_point";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;						
	}
	else if(nItemClassID == MSIT_VITAL_POINT)
	{
		Info.Name = GetSystemString(2492);
		Info.IconName = "icon.etc_sayha_point_01";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;
	}
	if(0 < Info.Durability)
	{
		Info.CurrentDurability = Info.Durability;
	}
	nCurrentOutputItemInfoIndex = _tempMultiSellInfoList[_tempMultiSellInfoIndex].OutputItemInfoList.Length;
	_tempMultiSellInfoList[_tempMultiSellInfoIndex].OutputItemInfoList.Length = nCurrentOutputItemInfoIndex + 1;
	_tempMultiSellInfoList[_tempMultiSellInfoIndex].OutputItemInfoList[nCurrentOutputItemInfoIndex] = Info;
	_tempMultiSellInfoList[_tempMultiSellInfoIndex].OutputItemInfoList[nCurrentOutputItemInfoIndex].Reserved = _tempMultiSellInfoIndex;	
}

function Rs_EV_MultiSellInputItemInfo(string param)
{
	local int nMultiSellInfoID, nCurrentInputItemInfoIndex, nItemClassID, nIsBlessedItem, ensoulNormalSlot, ensoulBmSlot;

	local ItemInfo Info;

	ParseItemID(param, Info.Id);
	class'UIDATA_ITEM'.static.GetItemInfo(Info.Id, Info);
	ParseInt(param, "MultiSellInfoID", nMultiSellInfoID);
	ParseInt(param, "ClassID", nItemClassID);
	ParseInt(param, "ItemType", Info.ItemType);
	ParseINT64(param, "ItemCount", Info.ItemNum);
	ParseInt(param, "Enchanted", Info.Enchanted);
	ParseInt(param, "RefineryOp1", Info.RefineryOp1);
	ParseInt(param, "RefineryOp2", Info.RefineryOp2);
	ParseInt(param, "AttackAttributeType", Info.AttackAttributeType);
	ParseInt(param, "AttackAttributeValue", Info.AttackAttributeValue);
	ParseInt(param, "DefenseAttributeValueFire", Info.DefenseAttributeValueFire);
	ParseInt(param, "DefenseAttributeValueWater", Info.DefenseAttributeValueWater);
	ParseInt(param, "DefenseAttributeValueWind", Info.DefenseAttributeValueWind);
	ParseInt(param, "DefenseAttributeValueEarth", Info.DefenseAttributeValueEarth);
	ParseInt(param, "DefenseAttributeValueHoly", Info.DefenseAttributeValueHoly);
	ParseInt(param, "DefenseAttributeValueUnholy", Info.DefenseAttributeValueUnholy);
	ParseInt(param, "EnsoulOptionNum_" $ string(2), ensoulBmSlot);
	ParseInt(param, "EnsoulOptionNum_" $ string(1), ensoulNormalSlot);
	addEnsoulInfo(2, ensoulBmSlot, param, Info);
	addEnsoulInfo(1, ensoulNormalSlot, param, Info);
	ParseInt(param, "IsBlessedItem", nIsBlessedItem);
	Info.IsBlessedItem = numToBool(nIsBlessedItem);
	if(_tempMultiSellInfoList[_tempMultiSellInfoIndex].MultiSellInfoID != nMultiSellInfoID)
	{
		return;
	}
	if(nItemClassID == MSIT_PCCAFE_POINT)
	{
		Info.Name = GetSystemString(1277);
		Info.IconName = GetPcCafeItemIconPackageName();
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;		
	}
	else if(nItemClassID == MSIT_PLEDGE_POINT)
	{
		Info.Name = GetSystemString(1311);
		Info.IconName = "icon.etc_i.etc_bloodpledge_point_i00";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;			
	}
	else if(nItemClassID == MSIT_PVP_POINT)
	{
		Info.Name = GetSystemString(102);
		Info.IconName = "icon.pvp_point_i00";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;				
	}
	else if(nItemClassID == MSIT_RAID_POINT)
	{
		Info.Name = GetSystemString(3183);
		Info.IconName = "icon.etc_i.etc_rp_point_i00";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;					
	}
	else if(nItemClassID == MSIT_CRAFT_POINT)
	{
		Info.Name = GetSystemString(13159);
		Info.IconName = "Icon.etc_i.craft_point";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;						
	}
	else if(nItemClassID == MSIT_VITAL_POINT)
	{
		Info.Name = GetSystemString(2492);
		Info.IconName = "icon.etc_sayha_point_01";
		Info.Enchanted = 0;
		Info.ItemType = -1;
		Info.Id.ClassID = 0;							
	}
	else
	{
		Info.Name = class'UIDATA_ITEM'.static.GetItemName(Info.Id);
		Info.IconName = class'UIDATA_ITEM'.static.GetItemTextureName(Info.Id);
	}
	Info.CrystalType = class'UIDATA_ITEM'.static.GetItemCrystalType(Info.Id);
	if(nItemClassID != MSIT_FIELD_CYCLE_POINT)
	{
		nCurrentInputItemInfoIndex = _tempMultiSellInfoList[_tempMultiSellInfoIndex].InputItemInfoList.Length;
		_tempMultiSellInfoList[_tempMultiSellInfoIndex].InputItemInfoList.Length = nCurrentInputItemInfoIndex + 1;
		_tempMultiSellInfoList[_tempMultiSellInfoIndex].InputItemInfoList[nCurrentInputItemInfoIndex] = Info;
	}	
}

function Rs_EV_MultiSellInfoListEnd(string param)
{
	local MultiSellGroupInfo groupInfo;

	groupInfo.infoList = _tempMultiSellInfoList;
	groupInfo.MultisellID = _tempMultiSellId;
	groupInfo.tabindex = _tempTabIndex;
	groupInfo.Loaded = true;
	_multiSellGroupInfos[_tempTabIndex] = groupInfo;
	_isWaitingResponse = false;
	updateMultiSellData();
	UpdateUIControlsWithTimer();
	ResetTempInfo();	
}

function Nt_EV_MultiSellResult(string param)
{
	local int Success, i;

	ParseInt(param, "Success", Success);
	Debug("MultiSellItemExchangeWnd Nt_EV_MultiSellResult" @ string(Success));
	if(hasEItemcheck == true)
	{
		for(i = 0; i < _multiSellGroupInfos.Length; i++)
		{
			_multiSellGroupInfos[i].Loaded = false;
		}
		if(_selectedTabIndex < _multiSellTabInfos.Length)
		{
			Rq_C_EX_MULTI_SELL_LIST(_multiSellTabInfos[_selectedTabIndex].MultisellID, _selectedTabIndex);
		}
		hasEItemcheck = false;
	}	
}
