--------------------------------------------------------------------------------
local sysname = {
	[ "BARD" ] = "Bard",
	[ "DRUID" ] = "Druid",
	[ "MAGE" ] = "Mage",
	[ "NECROMANCER" ] = "Necromancer",
	[ "PALADIN" ] = "Paladin",
	[ "PRIEST" ] = "Priest",
	[ "PSIONIC" ] = "Psionic",
	[ "STALKER" ] = "Stalker",
	[ "WARRIOR" ] = "Warrior"
}
local color = {
	[ "BARD" ] = { a = 255, r = 106, g = 230, b = 223 },
	[ "DRUID" ] = { a = 255, r = 255, g = 118, b = 60 },
	[ "MAGE" ] = { a = 255, r = 126, g = 159, b = 255 },
	[ "NECROMANCER" ] = { a = 255, r = 208, g = 69, b = 75 },
	[ "PALADIN" ] = { a = 255, r = 207, g = 220, b = 155 },
	[ "PRIEST" ] = { a = 255, r = 255, g = 207, b = 123 },
	[ "PSIONIC" ] = { a = 255, r = 221, g = 123, b = 245 },
	[ "STALKER" ] = { a = 255, r = 150, g = 204, b = 86 },
	[ "WARRIOR" ] = { a = 255, r = 143, g = 119, b = 75 }
}
--------------------------------------------------------------------------------
for key, color in pairs( color ) do
	for id, component in pairs( color ) do
		color[ id ] = component / 255
	end
end
--------------------------------------------------------------------------------
local function GetClassName( sample )
	if sample then
		local sampletype = type( sample )
		
		if sampletype == "string" then
			if sysname[ sample ] then
				return sample
			else
				LogWarning( "Invalid player class sysName passed: \"", tostring( sample ), "\"" )
			end
			
		elseif sampletype == "number" then
			if unit.IsPlayer( sample ) then
				return unit.GetClass( sample ).className
			end
		end
	end
end
--------------------------------------------------------------------------------
function GetUnitClassIcon( sample )
	local classname = GetClassName( sample )
	return classname and common.GetAddonRelatedGroupTexture( "PlayerClasses", sysname[ classname ] )
end
--------------------------------------------------------------------------------
function GetUnitClassColor( sample )
	local classname = GetClassName( sample )
	return classname and color[ classname ]
end
--------------------------------------------------------------------------------
function GetUnitQualityIcon( quality )

	local tmp
	if quality == 1 then tmp = common.GetAddonRelatedGroupTexture( "PlayerClasses", "silver" )
	elseif quality == 2 then tmp = common.GetAddonRelatedGroupTexture( "PlayerClasses", "gold" )
	elseif quality == 3 then tmp = common.GetAddonRelatedGroupTexture( "PlayerClasses", "copper" )
	elseif quality == 4 or quality == 5 then tmp = common.GetAddonRelatedGroupTexture( "PlayerClasses", "red" )
	elseif quality == 6 then tmp = common.GetAddonRelatedGroupTexture( "PlayerClasses", "gray" )
	else tmp = common.GetAddonRelatedGroupTexture( "PlayerClasses", "alpha" )
	end
	
	return tmp
end
--------------------------------------------------------------------------------













