function TradeClass_OnLoad()
	this:RegisterEvent("TRADE_SHOW");
end

function TradeClass_OnEvent()
	if ( event == "TRADE_SHOW" ) then
		if (UnitIsPlayer("NPC")) then
			local icon = getglobal("TradeClassIcon");
			local texture = getglobal("TradeClassIconTexture");
			local _, texturefile = UnitClass("NPC");

			if (icon and texture) then
				if (not texturefile or texturefile == "Not specified") then
					texturefile = "UNKNOWN";
				end

				if ( not icon:IsVisible() ) then
					icon:Show();
				end

				texture:SetTexture("Interface\\AddOns\\TradeClass\\Icons\\"..texturefile..".tga");
			end

			-- 채팅창에 표시
			local msg = "  |cFFFFFF00[거래대상]|r |cFF00FF00"..UnitName("NPC").."|r";
			local guildName = GetGuildInfo("NPC");
			if guildName then
				msg = msg.." <|cFF00CCFF"..guildName.."|r>";
			end
			msg = msg.." : LV.|cFFFFFF00"..UnitLevel("NPC").."|r |cFF0099FF"..UnitRace("NPC").."|r";

			TradeClass_UnitClass = {
--[[
				["WARRIOR"]	= "B39442",
				["PRIEST"]	= "FFFFFF",
				["MAGE"]	= "00FFFF",
				["SHAMAN"]	= "FF71A8",
				["WARLOCK"]	= "8D54FB",
				["DRUID"]	= "FF8A00",
				["ROGUE"]	= "FFFF00",
				["HUNTER"]	= "00FF00",
				["PALADIN"]	= "FF71A8",
]]
				["WARRIOR"]	= "C79C6E",
				["PRIEST"]	= "FFFFFF",
				["MAGE"]	= "69CDF0",
				["SHAMAN"]	= "00DCBB",
				["WARLOCK"]	= "8D54FB",
				["DRUID"]	= "FF7D0B",
				["ROGUE"]	= "FFF569",
				["HUNTER"]	= "ABD473",
				["PALADIN"]	= "F58DBB",
			};
			local lClass,eClass = UnitClass("NPC");
			msg = msg.." |cFF"..TradeClass_UnitClass[eClass]..lClass.."|r";
			DEFAULT_CHAT_FRAME:AddMessage(msg);

			-- 거래창에 표시
			local race = UnitRace("NPC");
			if race == "나이트 엘프" then
				race = "나엘";
			elseif race == "블러드 엘프" then
				race = "블엘";
			end

			if lClass == "흑마법사" then
				lClass = "흑마";
			elseif lClass == "드루이드" then
				lClass = "드루";
			end

			local msg2 = "LV.|cFFFFFF00"..UnitLevel("NPC").."|r |cFF0099FF"..race.."|r |cFF"..TradeClass_UnitClass[eClass]..lClass.."|r";
			TradeClassText:SetText(msg2);
			TradeClassText:Show();
			if guildName then
				TradeClassGuildText:SetText("<|cFF00CCFF"..guildName.."|r>");
				TradeClassGuildText:Show();
			end
		end
	end
end
