local GlobalAddonName, ExRT = ...

local GetTime, IsEncounterInProgress, CanInspect, CheckInteractDistance, RAID_CLASS_COLORS, GetInstanceInfo = GetTime, IsEncounterInProgress, CanInspect, CheckInteractDistance, RAID_CLASS_COLORS, GetInstanceInfo
local string_match, string_gsub, string_sub, table_sort, table_wipe, table_insert, tonumber, pairs, ipairs, string_trim, format, min, max, floor = string.match, string.gsub, string.sub, table.sort, table.wipe, table.insert, tonumber, pairs, ipairs, string.trim, format, min, max, floor
local UnitIsDeadOrGhost, UnitIsConnected, UnitSpellHaste, UnitName, UnitClass, UnitCreatureFamily, UnitIsDead, UnitIsGhost, UnitGUID = UnitIsDeadOrGhost, UnitIsConnected, UnitSpellHaste, UnitName, UnitClass, UnitCreatureFamily, UnitIsDead, UnitIsGhost, UnitGUID

local RaidInCombat, ClassColorNum, AntiSpam, GetDifficultyForCooldownReset, DelUnitNameServer, ReverseInt, NumberInRange = ExRT.mds.RaidInCombat, ExRT.mds.classColorNum, ExRT.mds.AntiSpam, ExRT.mds.GetDifficultyForCooldownReset, ExRT.mds.delUnitNameServer, ExRT.mds.reverseInt, ExRT.mds.NumberInRange
local GetEncounterTime, UnitCombatlogname, GetUnitInfoByUnitFlag, ScheduleTimer, CancelTimer, GetRaidDiffMaxGroup, round, table_wipe2 = ExRT.mds.GetEncounterTime, ExRT.mds.UnitCombatlogname, ExRT.mds.GetUnitInfoByUnitFlag, ExRT.mds.ScheduleTimer, ExRT.mds.CancelTimer, ExRT.mds.GetRaidDiffMaxGroup, ExRT.mds.Round, ExRT.mds.table_wipe

local VExRT, VExRT_CDE = nil

local module = ExRT.mod:New("ExCD2",ExRT.L.cd2)
module._C = {}
module.db.spellDB = {
{31821,	"PALADIN",	nil,			{31821,	180,	6},	nil,			nil,			},	--Аура благочестия
{62618,	"PRIEST",	nil,			{62618,	180,	10},	nil,			nil,			},	--Слово силы: Барьер
{97462,	"WARRIOR",	nil,			{97462,	180,	10},	{97462,	180,	10},	nil,			},	--Ободряющий клич
{159916,"MAGE",		{159916,120,	6},	nil,			nil,			nil,			},	--Amplify Magic
{76577,	"ROGUE",	{76577,	180,	5},	nil,			nil,			nil,			},	--Дымовая шашка
{51052,	"DEATHKNIGHT",	{51052,	120,	3},	nil,			nil,			nil,			},	--Зона антимагии
{98008,	"SHAMAN",	nil,			nil,			nil,			{98008,	180,	6},	},	--Тотем духовной связи
{115310,"MONK",		nil,			nil,			nil,			{115310,180,	0},	},	--Восстановление сил
{64843,	"PRIEST",	nil,			nil,			{64843,	180,	8},	nil,			},	--Божественный гимн
{740,	"DRUID",	nil,			nil,			nil,			nil,{740,180,	8},	},	--Спокойствие
{108280,"SHAMAN",	nil,			nil,			nil,			{108280,180,	10},	},	--Тотем целительного прилива
{108281,"SHAMAN",	{108281,120,	10},	nil,			nil,			nil,			},	--Наставления предков
{15286,	"PRIEST",	nil,			nil,			nil,			{15286,	180,	15},	},	--Объятия вампира
{172106,"HUNTER",	{172106,180,	6},	nil,			nil,			nil,			},	--Aspect of the Fox
{161642,"NO",		{161642,0,	0},	nil,			nil,			nil,			},	--Resurrecting [Raid Combat Res]
{20484,	"DRUID",	{20484,	600,	0},	nil,			nil,			nil,			},	--Возрождение
{20707,	"WARLOCK",	{20707,	600,	0},	nil,			nil,			nil,			},	--Камень души
{61999,	"DEATHKNIGHT",	{61999,	600,	0},	nil,			nil,			nil,			},	--Воскрешение союзника
{20608,	"SHAMAN",	{21169,	1800,	0},	nil,			nil,			nil,			},	--Реинкарнация
{47788,	"PRIEST",	nil,			nil,			{47788,	180,	10},	nil,			},	--Оберегающий дух
{33206,	"PRIEST",	nil,			{33206,	180,	8},	nil,			nil,			},	--Подавление боли
{6940,	"PALADIN",	{6940,	120,	12},	nil,			nil,			{6940,	90,	12},	},	--Длань жертвенности
{102342,"DRUID",	nil,			nil,			nil,			nil,{102342,60,	12},	},	--Железная кора
{114030,"WARRIOR",	{114030,120,	12},	nil,			nil,			nil,			},	--Бдительность
{1022,	"PALADIN",	{1022,	300,	10},	nil,			nil,			nil,			},	--Длань защиты
{106898,"DRUID",	{106898,120,	8},	nil,			{77764,	120,	8},	{77761,	120,	8},	},	--Тревожный рев
{73325,	"PRIEST",	{73325,	90,	0},	nil,			nil,			nil,			},	--Духовное рвение
{115176,"MONK",		{115176,180,	8},	nil,			nil,			nil,			},	--Дзен-медитация
{108199,"DEATHKNIGHT",	{108199,60,	0},	nil,			nil,			nil,			},	--Хватка Кровожада
{110913,"WARLOCK",	{110913,180,	8},	nil,			nil,			nil,			},	--Темная сделка
{116849,"MONK",		nil,			nil,			nil,			{116849,100,	12},	},	--Исцеляющий кокон
{114039,"PALADIN",	{114039,30,	6},	nil,			nil,			nil,			},	--Длань очищения
{118038,"WARRIOR",	nil,			{118038,120,	8},	{118038,120,	8},	nil,			},	--Бой насмерть
{1044,	"PALADIN",	{1044,	25,	6},	nil,			nil,			nil,			},	--Длань свободы
{633,	"PALADIN",	{633,	600,	0},	nil,			nil,			nil,			},	--Возложение рук
{2825,	"SHAMAN",	{2825,	300,	40},	nil,			nil,			nil,			},	--Жажда крови
{80353,	"MAGE",		{80353,	300,	40},	nil,			nil,			nil,			},	--Искажение времени
--{id,	class,		all specs,		spec1,			spec2={spellid,cd,duration},spec3,spec4		},	--name
}

module.db.Cmirror = module._C
module.db.dbCountDef = #module.db.spellDB
module.db.findspecspells = {
	[7268] = 62,[30451] = 62,[114923] = 62,[44425] = 62,
	[11366] = 63,[133] = 63,[2948] = 63,
	[30455] = 64,[116] = 64,[112948] = 64,
	[20473] = 65,[85222] = 65,[82326] = 65,[82327] = 65,
	[53600] = 66,[119072] = 66,[159556] = 66,[31935] = 66,
	[53385] = 70,[879] = 70,[85256] = 70,[31884] = 70,
	[12294] = 71,[167105] = 71,[163201] = 71,
	[85288] = 72,[23881] = 72,[100130] = 72,
	[20243] = 73,[23922] = 73,[6572] = 73,[2565] = 73,
	[2912] = 102,[48505] = 102,[93402] = 102,[78674] = 102,
	[5221] = 103,[106785] = 103,[1079] = 103,[1822] = 103,
	[33745] = 104,[6807] = 104,[62606] = 104,
	[8936] = 105,[48438] = 105,[18562] = 105,[33763] = 105,
	[56222] = 250,[48982] = 250,[49222] = 250,
	[49143] = 251,[49020] = 251,[49184] = 251,[130735] = 251,
	[49206] = 252,[85948] = 252,[55090] = 252,
	[34026] = 253,[82692] = 253,[19574] = 253,
	[19434] = 254,[53209] = 254,
	[53301] = 255,[77767] = 255,
	[152118] = 256,[81700] = 256,[47750] = 256,[132157] = 256,[47666] = 256,
	[34861] = 257,[139] = 257,[64844] = 257,
	[147193] = 258,[34914] = 258,[8092] = 258,[2944] = 258,
	[1329] = 259,[111240] = 259,
	[84617] = 260,[51690] = 260,[13750] = 260,
	[51713] = 261,[53] = 261,[14183] = 261,
	[165462] = 262,[51505] = 262,[61882] = 262,
	[60103] = 263,[1535] = 263,[17364] = 263,
	[1064] = 264,[61295] = 264,[77472] = 264,[108280] = 264,
	[103103] = 265,[30108] = 265,[48181] = 265,[980] = 265,
	[105174] = 266,[6353] = 266,[157695] = 266,[603] = 266,
	[29722] = 267,[348] = 267,[157701] = 267,
	[119582] = 268,[115308] = 268,[121253] = 268,[115295] = 268,
	[117418] = 269,[107428] = 269,[152174] = 269,[116740] = 269,
	[115151] = 270,[115175] = 270,[116670] = 270,
}
module.db.classNames = {"WARRIOR","PALADIN","HUNTER","ROGUE","PRIEST","DEATHKNIGHT","SHAMAN","MAGE","WARLOCK","MONK","DRUID"}
module.db.specByClass = {
	["HUNTER"] = {0,253,254,255,},
	["WARRIOR"] = {0,71,72,73,},
	["PALADIN"] = {0,65,66,70,},
	["MAGE"] = {0,62,63,64,},
	["PRIEST"] = {0,256,257,258,},
	["MONK"] = {0,268,269,270,},
	["WARLOCK"] = {0,265,266,267,},
	["SHAMAN"] = {0,262,263,264,},
	["ROGUE"] = {0,259,260,261,},
	["DRUID"] = {0,102,103,104,105,},
	["DEATHKNIGHT"] = {0,250,251,252,},
}
module.db.specIcons = {
	[62] = "Interface\\Icons\\Spell_Holy_MagicalSentry",
	[63] = "Interface\\Icons\\Spell_Fire_FireBolt02",
	[64] = "Interface\\Icons\\Spell_Frost_FrostBolt02",
	[65] = "Interface\\Icons\\Spell_Holy_HolyBolt",
	[66] = "Interface\\Icons\\Ability_Paladin_ShieldoftheTemplar",
	[70] = "Interface\\Icons\\Spell_Holy_AuraOfLight",
	[71] = "Interface\\Icons\\Ability_Warrior_SavageBlow",
	[72] = "Interface\\Icons\\Ability_Warrior_InnerRage",
	[73] = "Interface\\Icons\\Ability_Warrior_DefensiveStance",
	[102] = "Interface\\Icons\\Spell_Nature_StarFall",
	[103] = "Interface\\Icons\\Ability_Druid_CatForm",
	[104] = "Interface\\Icons\\Ability_Racial_BearForm",
	[105] = "Interface\\Icons\\Spell_Nature_HealingTouch",
	[250] = "Interface\\Icons\\Spell_Deathknight_BloodPresence",
	[251] = "Interface\\Icons\\Spell_Deathknight_FrostPresence",
	[252] = "Interface\\Icons\\Spell_Deathknight_UnholyPresence",
	[253] = "INTERFACE\\ICONS\\ability_hunter_bestialdiscipline",
	[254] = "Interface\\Icons\\Ability_Hunter_FocusedAim",
	[255] = "INTERFACE\\ICONS\\ability_hunter_camouflage",
	[256] = "Interface\\Icons\\Spell_Holy_PowerWordShield",
	[257] = "Interface\\Icons\\Spell_Holy_GuardianSpirit",
	[258] = "Interface\\Icons\\Spell_Shadow_ShadowWordPain",
	[259] = "Interface\\Icons\\Ability_Rogue_Eviscerate",
	[260] = "Interface\\Icons\\Ability_BackStab",
	[261] = "Interface\\Icons\\Ability_Stealth",
	[262] = "Interface\\Icons\\Spell_Nature_Lightning",
	[263] = "Interface\\Icons\\Spell_Shaman_ImprovedStormstrike",
	[264] = "Interface\\Icons\\Spell_Nature_MagicImmunity",
	[265] = "Interface\\Icons\\Spell_Shadow_DeathCoil",
	[266] = "Interface\\Icons\\Spell_Shadow_Metamorphosis",
	[267] = "Interface\\Icons\\Spell_Shadow_RainOfFire",
	[268] = "Interface\\Icons\\spell_monk_brewmaster_spec",
	[269] = "Interface\\Icons\\spell_monk_windwalker_spec",
	[270] = "Interface\\Icons\\spell_monk_mistweaver_spec",
}
module.db.specInDBase = {
	[253] = 4,	[254] = 5,	[255] = 6,
	[71] = 4,	[72] = 5,	[73] = 6,
	[65] = 4,	[66] = 5,	[70] = 6,
	[62] = 4,	[63] = 5,	[64] = 6,
	[256] = 4,	[257] = 5,	[258] = 6,
	[265] = 4,	[266] = 5,	[267] = 6,
	[250] = 4,	[251] = 5,	[252] = 6,
	[259] = 4,	[260] = 5,	[261] = 6,
	[102] = 4,	[103] = 5,	[104] = 6,	[105] = 7,
	[268] = 4,	[269] = 5,	[270] = 6,
	[262] = 4,	[263] = 5,	[264] = 6,
	[0] = 3,
}

do
	local specList = {
		[62] = "MAGEDPS1",
		[63] = "MAGEDPS2",
		[64] = "MAGEDPS3",
		[65] = "PALADINHEAL",
		[66] = "PALADINTANK",
		[70] = "PALADINDPS",
		[71] = "WARRIORDPS1",
		[72] = "WARRIORDPS2",
		[73] = "WARRIORTANK",
		[102] = "DRUIDDPS1",
		[103] = "DRUIDDPS2",
		[104] = "DRUIDTANK",
		[105] = "DRUIDHEAL",
		[250] = "DEATHKNIGHTTANK",
		[251] = "DEATHKNIGHTDPS1",
		[252] = "DEATHKNIGHTDPS2",
		[253] = "HUNTERDPS1",
		[254] = "HUNTERDPS2",
		[255] = "HUNTERDPS3",
		[256] = "PRIESTHEAL1",
		[257] = "PRIESTHEAL2",
		[258] = "PRIESTDPS",
		[259] = "ROGUEDPS1",
		[260] = "ROGUEDPS2",
		[261] = "ROGUEDPS3",
		[262] = "SHAMANDPS1",
		[263] = "SHAMANDPS2",
		[264] = "SHAMANHEAL",
		[265] = "WARLOCKDPS1",
		[266] = "WARLOCKDPS2",
		[267] = "WARLOCKDPS3",
		[268] = "MONKTANK",
		[269] = "MONKDPS",
		[270] = "MONKHEAL",
		[0] = "NO",
	}
	module.db.specInLocalizate = setmetatable({},{__index = function (t,k)
		if tonumber(k) then
			return specList[k] 
		else
			for i,val in pairs(specList) do
				if val == k then
					return i
				end
			end
		end
	end})
end

module.db.inspectDB = {}
module.db.inspectQuery = {}
module.db.inspectItemsOnly = {}
module.db.inspectID = nil
module.db.inspectCleared = nil
module.db.inspectTimer = 0

module.db.historyUsage = {}

module.db.testMode = nil
module.db.isEncounter = nil

local cdsNav_wipe,cdsNav_set = nil
do
	local cdsNavData = {}
	local nilData = {}
	module.db.cdsNav = setmetatable({}, {
		__index = function (t,k) 
			return cdsNavData[k] or nilData
		end
	})
	function cdsNav_wipe()
		table.wipe(cdsNavData)
	end
	function cdsNav_set(playerName,spellID,pos)
		local e = cdsNavData[playerName]
		if not e then
			e = {}
			cdsNavData[playerName] = e
		end
		e[spellID] = pos
	end
end

do
	local sessionData = {}
	local nilData = {}
	module.db.session_gGUIDs = setmetatable({}, {
		__index = function (t,k) 
			return sessionData[k] or nilData
		end,
		__newindex = function (t,k,v)
			local e = sessionData[k]
			if not e then
				e = {}
				sessionData[k] = e
			end
			if v > 0 then
				e[v] = true
			else
				e[-v] = nil
			end
		end
	})	
end

module.db.session_Pets = {}
module.db.session_PetOwner = {}

module.db.spell_isTalent = {		-- SpellID талантов
	[55694]=2,	[103840]=2,	[107570]=4,	[46968]=4,	[118000]=4,	[114028]=5,	[114029]=5,	
	[114030]=5,	[107574]=6,	[12292]=6,	[46924]=6,	[152277]=7,	[176289]=7,	[85499]=1,	
	[105593]=2,	[20066]=2,	[115750]=2,	[114163]=3,	[20925]=3,	[114039]=4,	[105809]=5,	
	[114165]=6,	[114158]=6,	[114157]=6,	[156910]=7,	[157007]=7,	[152262]=7,	[109248]=2,	
	[19386]=2,	[19577]=2,	[109304]=3,	[120679]=4,	[131894]=5,	[121818]=5,	[117050]=6,	
	[109259]=6,	[120360]=6,	[74001]=2,	[36554]=4,	[137619]=6,	[152151]=7,	[152150]=7,	
	[19236]=1,	[112833]=1,	[123040]=3,	[129250]=3,	[108920]=4,	[8122]=4,	[10060]=5,	
	[109964]=5,	[121135]=6,	[127632]=6,	[110744]=6,	[122121]=6,	[120517]=6,	[120644]=6,	
	[123693]=1,	[115989]=1,	[49039]=2,	[51052]=2,	[96268]=3,	[108194]=3,	[48743]=5,	
	[108199]=6,	[108200]=6,	[108201]=6,	[152280]=7,	[152279]=7,	[108270]=1,	[108271]=1,	
	[51485]=2,	[108273]=2,	[108285]=3,	[108287]=3,	[16166]=4,	[16188]=4,	[108281]=5,	
	[117014]=6,	[157153]=7,	[152256]=7,	[152255]=7,	[157913]=1,	[108843]=1,	[108978]=2,	
	[11426]=2,	[113724]=3,	[111264]=3,	[102051]=3,	[110959]=4,	[11958]=4,	[55342]=6,	
	[152087]=7,	[153626]=7,	[153561]=7,	[153595]=7,	[108359]=1,	[5484]=2,	[6789]=2,	
	[30283]=2,	[108416]=3,	[110913]=3,	[111397]=4,	[108482]=4,	[108501]=5,	[108503]=5,	
	[137587]=6,	[108508]=6,	[152108]=7,	[116841]=1,	[115098]=2,	[124081]=2,	[123986]=2,	
	[116844]=4,	[119392]=4,	[119381]=4,	[122278]=5,	[122783]=5,	[116847]=6,	[123904]=6,	
	[157535]=7,	[152175]=7,	[152173]=7,	[102280]=1,	[102401]=1,	[108238]=2,	[102351]=2,	
	[102359]=3,	[132469]=3,	[102560]=4,	[102543]=4,	[102558]=4,	[33891]=4,	[99]=5,	
	[102793]=5,	[5211]=5,	[108291]=6,	[108292]=6,	[108293]=6,	[108294]=6,	[124974]=6,	
	[155835]=7,	
}

-- 1:01 22.09.2014; build 18918
module.db.spell_talentsList = {
	["WARRIOR"] = {
		103826,103827,103828,
		55694,29838,103840,
		{56636,169679,169680},29725,{1464,169683,169685},
		107570,46968,118000,
		114028,114029,114030,
		107574,12292,46924,
		152278,152277,{176289,152276},
	},
	["PALADIN"] = {
		85499,87172,26023,
		105593,20066,115750,
		85804,114163,{148039,20925},
		114039,114154,105622,
		105809,{53376,171648},86172,
		114165,114158,114157,
		{156910,152263},{157007,152262},{157047,152261,157048},
	},
	["HUNTER"] = {
		109215,109298,118675,
		109248,19386,19577,
		109304,109260,109212,
		177667,120679,109306,
		131894,130392,121818,
		117050,109259,120360,
		162534,{152245,163485},{152244,155228},
	},
	["ROGUE"] = {
		14062,108208,108209,
		26679,108210,74001,
		31230,108211,79008,
		138106,36554,108212,
		131511,154904,108216,
		114014,137619,114015,
		152152,152151,152150,
	},
	["PRIEST"] = {
		19236,112833,108945,
		64129,121536,108942,
		{109186,162448},123040,{129250,139139},
		108920,8122,605,
		109142,10060,{109964,109175,162452},
		{121135,127632},{110744,122121},{120517,120644},
		{152118,155245,155246},{152117,155361},{152116,155271},
	},
	["DEATHKNIGHT"] = {
		161497,123693,115989,
		49039,51052,114556,
		96268,50041,108194,
		45529,81229,51462,
		48743,108196,119975,
		108199,108200,108201,
		152281,152280,152279,
	},
	["SHAMAN"] = {
		30884,108270,108271,
		63374,51485,108273,
		108285,108284,108287,
		16166,16188,108283,
		147074,108281,108282,
		{165477,117012,165479},117013,117014,
		{152257,157153},152256,{152255,157154},
	},
	["MAGE"] = {
		157913,108843,108839,
		108978,140468,11426,
		113724,111264,102051,
		110959,86949,11958,
		{114923,44457,112948},157976,{157980,157981,157997},
		55342,116011,1463,
		{155147,155148,155149},152087,{153626,153561,153595},
	},
	["WARLOCK"] = {
		108359,108370,{108371,174848},
		5484,6789,30283,
		108415,108416,110913,
		111397,111400,108482,
		108499,108501,{108503,171975},
		108505,137587,108508,
		{152109,157695,157696},152108,152107,
	},
	["MONK"] = {
		115173,116841,115174,
		115098,124081,123986,
		121817,115396,115399,
		116844,119392,119381,
		122280,122278,122783,
		116847,123904,115008,
		{157533,157535,152175},{157676,157675,152174},{152173,173841},
	},
	["DRUID"] = {
		131768,102280,102401,
		145108,108238,102351,
		{102355,106707},102359,132469,
		{114107,158476,158477,158478},{102560,102543,102558,33891},{33831,102703,102706,102693},
		99,102793,5211,
		{108291,108292,108293,108294},{108373,158497,158501,158504},124974,
		{152222,155580,155578,155577},{152221,155672,80313,155675},{152220,171746,155835,155834},
	},
}
module.db.spell_glyphsList = {
	["WARRIOR"] = {
		[94374]=true,	[58356]=true,	[63328]=true,	[63325]=true,	[58387]=true,	[63329]=true,	[159708]=true,	[58386]=true,
	},
	["PALADIN"] = {
		[63223]=true,	[146955]=true,	[54939]=true,	[162604]=true,	[159573]=true,	[171929]=true,	[159548]=true,
	},
	["HUNTER"] = {
		[63068]=true,
	},
	["ROGUE"] = {
		[63249]=true,	[56819]=true,	[89758]=true,	[63253]=true,	[56805]=true,	[146629]=true,	[56799]=true,	[159638]=true,	[159635]=true,
	},
	["PRIEST"] = {
		[55688]=true,	[55678]=true,	[120584]=true,	[63229]=true,	[159598]=true,	[171921]=true,	[159628]=true,	[159626]=true,
	},
	["DEATHKNIGHT"] = {
		[58686]=true,	[146646]=true,	[58673]=true,	[63331]=true,	[159428]=true,
	},
	["SHAMAN"] = {
		[55446]=true,	[63270]=true,	[55443]=true,	[55454]=true,	[55451]=true,	[63291]=true,	[55441]=true,	[55442]=true,	[55455]=true,	[171933]=true,	[159640]=true,	[159643]=true,	[159648]=true,	[159650]=true,
	},
	["MAGE"] = {
		[115703]=true,	[146659]=true,	[56368]=true,	[56376]=true,	[62210]=true,
	},
	["WARLOCK"] = {
		[63309]=true,	[146964]=true,	[146962]=true,	[159665]=true,	[159697]=true,
	},
	["MONK"] = {
		[171926]=true,	[123391]=true,	[123023]=true,
	},
	["DRUID"] = {
		[62970]=true,	[114223]=true,	[116216]=true,	[116238]=true,	[59219]=true,	[116203]=true,	[54825]=true,	[171924]=true,	[159445]=true,
	}
}
module.db.spell_charge_fix = {		--Спелы с зарядами
	[6940]=105622,
	[1022]=105622,
	[1044]=105622,
	[1038]=105622,
	[100]=103827,
	[108839]=108839,
	[77801]=108505,
	[113860]=108505,
	[113858]=108505,
	[113861]=108505,
	[1953]=146659,
	[80240]=146962,
	[109132]=1,
	[115008]=1,
	[19263]=1,
	[148467]=1,
	[61336]=1,
	[4987]=171929,
	[115450]=171926,
	[88423]=171924,
	[527]=171921,
	[77130]=171933,
	[115295]=1,
}
module.db.spell_durationByTalent_fix = {	--Изменение длительности талантом\глифом   вид: [спелл] = {spellid глифа\таланта, изменение времени (-10;10;*0.5;*1.5)}
	[31884] = {53376,"*1.5"},
	[31842] = {53376,"*1.5"},
	[76577] = {56819,2},
	[1719] = {94374,"*1.5"},
	[53271] = {63068,4},
	[79140] = {63249,10},
	[1856] = {89758,2},
	[5277] = {56799,5},
	[15286] = {120584,-5},
	[48792] = {58673,"*0.25"},
	[77606] = {63331,4},
	[79206] = {55446,5,159650,-7},
	[108269] = {55442,-2},
	[11129] = {56368,"*2"},
	[12042] = {62210,"*2"},
	[61336] = {114223,"*0.5"},
	[52174] = {159708,3},
	[47585] = {159598,3},	
	[51533] = {159640,-15},
	[113860] = {159665,"*0.5"},
	[113861] = {159665,"*0.5"},
	[113858] = {159665,"*0.5"},
	[112071] = {159445,45},
}
module.db.spell_cdByTalent_fix = {		--Изменение кд талантом\глифом   вид: [спелл] = {spellid глифа\таланта, изменение времени (-60;60);spellid2,time2;spellid3,time3;...}
	[498] = {114154,"*0.5"},
	[633] = {54939,120,	114154,"*0.5"},
	[642] = {114154,"*0.5"},
	[100] = {103826,-8},
	[781] = {118675,-10},
	[19263] = {118675,-60},
	[148467] = {118675,-60},
	[109132] = {115173,-5},
	[115008] = {115173,-5},
	[31821] = {146955,-60},
	[6343] = {58356,3},
	[23920] = {63328,-5},
	[52174] = {63325,-15},
	[6673] = {58387,-30},
	[1784] = {63253,-4},
	[1766] = {56805,-2},
	[64044] = {55688,-10},
	[6346] = {55678,-60},
	[47585] = {63229,-15},
	[47528] = {58686,-1},
	[48792] = {58673,"*0.5"},
	[77606] = {63331,-30},
	[51490] = {63270,-10,	131549,"*0.5"},
	[8056] = {55443,-2},
	[58875] = {55454,"*0.75"},
	[57994] = {55451,3},
	[51514] = {63291,-10},
	[8177] = {55441,20,159643,-3},
	[2894] = {55455,"*0.5"},
	[2139] = {115703,4},
	[11129] = {56368,"*2",	123101,"*0.8"},
	[122] = {56376,-5},
	[12042] = {62210,"*2"},
	[48020] = {63309,-4},
	[104773] = {146964,-60,159697,60},
	[80240] = {146962,35},
	[48438] = {62970,2},
	[61336] = {114223,-40},
	[106839] = {116216,5},
	[1850] = {59219,-60},
	[871] = {63329,120},
	[1044] = {159573,-5},
	[1856] = {159638,-60},
	[5277] = {159635,-30},
	[4987] = {171929,4},
	[115450] = {171926,4},
	[88423] = {171924,4},
	[527] = {171921,4},
	[77130] = {171933,4},
	[586] = {159628,60},
	[15487] = {159626,-25},
	[48982] = {159428,10},
	[51533] = {159640,-60},
	[30823] = {159648,60},
	[79206] = {159650,-60},
	[113860] = {159665,"*0.5"},
	[113861] = {159665,"*0.5"},
	[113858] = {159665,"*0.5"},
	[115080] = {123391,120},
	[119996] = {123023,-5},

	[31842] = {144613,-60,162604,"*0.5"},
	[1719] = {123144,-90},
	[12975] = {123146,-60},
	[55233] = {123079,-20},
	[20473] = {123103,-1},
	[31850] = {123104,-60},
	[12472] = {123101,"*0.5"},
	[45438] = {131619,-30},
	[34861] = {123113,-4},
	[18562] = {123089,-3,	38417,-2},
	[102342] = {131739,-30},
	[116680] = {138289,-5},
	[113656] = {123149,-5},
}
module.db.tierSetsSpells = {	--[specID.tierID.tierMark] = {2P Bonus Spell ID, 4P Bonus Spell ID}
	[65161] = {nil,144613},		--> Paladin,Holy,T16
	[65141] = {nil,123103},		--> Paladin,Holy,T14
	[66141] = {123104,nil},		--> Paladin,Tank,T14
	[71141] = {nil,123144},		--> Warrior,DPS,T14
	[73141] = {123146,nil},		--> Warrior,Tank,T14
	[250151] = {138195,nil},	--> DK,Tank,T15
	[250141] = {123079,nil},	--> DK,Tank,T14
	[62141] = {nil,123101},		--> Mage,DPS,T14
	[62162] = {nil,131619},		--> Mage,DPS,A15
	[256141] = {nil,123113},	--> Priest,Heal,T14
	[262162] = {nil,131549},	--> Shaman,Elem,A15
	[104141] = {123086,nil},	--> Druid,Tank,T14
	[105141] = {nil,123089},	--> Druid,Heal,T14
	[105162] = {38417,131739},	--> Druid,Heal,A15
	[270151] = {nil,138289},	--> Monk,Heal,T15
	[269141] = {123149,nil},	--> Monk,DPS,T14
	[259141] = {nil,123122},	--> Rogue,DPS,T14
	[11171] = {{165437},{166677}},	--> Druid T17
	[7171] = {{165605},nil},	--> Shaman T17
}
module.db.tierSetsList = {	-- [itemID] = specID.tierID.tierMark
	[99377] = 65161, [99378] = 65161, [99375] = 65161, [99376] = 65161, [99374] = 65161, [99133] = 65161, [99124] = 65161, [99125] = 65161, [99134] = 65161, [99135] = 65161, [99626] = 65161, [99666] = 65161, [99656] = 65161, [99648] = 65161, [99665] = 65161, [99003] = 65161, [98980] = 65161, [99076] = 65161, [98982] = 65161, [98979] = 65161,
	[87108] = 65141, [87107] = 65141, [87106] = 65141, [87105] = 65141, [87104] = 65141, [85344] = 65141, [85345] = 65141, [85346] = 65141, [85347] = 65141, [85348] = 65141, [86684] = 65141, [86685] = 65141, [86686] = 65141, [86687] = 65141, [86688] = 65141,
	[87113] = 66141, [87112] = 66141, [87111] = 66141, [87110] = 66141, [87109] = 66141, [85319] = 66141, [85320] = 66141, [85321] = 66141, [85322] = 66141, [85323] = 66141, [86659] = 66141, [86660] = 66141, [86661] = 66141, [86662] = 66141, [86663] = 66141,
	[87196] = 71141, [87195] = 71141, [87194] = 71141, [87193] = 71141, [87192] = 71141,  [85332] = 71141, [85329] = 71141, [85330] = 71141, [85331] = 71141, [85333] = 71141, [86669] = 71141, [86670] = 71141, [86671] = 71141, [86672] = 71141, [86673] = 71141,	
	[87201] = 73141, [87199] = 73141, [87200] = 73141, [87198] = 73141, [87197] = 73141, [85324] = 73141, [85325] = 73141, [85326] = 73141, [85327] = 73141, [85328] = 73141, [86664] = 73141, [86665] = 73141, [86666] = 73141, [86667] = 73141, [86668] = 73141,	
	[96574] = 250151, [96575] = 250151, [96576] = 250151, [96578] = 250151, [96577] = 250151, [95230] = 250151, [95231] = 250151, [95232] = 250151, [95233] = 250151, [95234] = 250151, [95830] = 250151, [95831] = 250151, [95832] = 250151, [95833] = 250151, [95834] = 250151,	
	[86922] = 250141, [86921] = 250141, [86919] = 250141, [86920] = 250141, [86918] = 250141, [85314] = 250141, [85315] = 250141, [85316] = 250141, [85317] = 250141, [85318] = 250141, [86654] = 250141, [86655] = 250141, [86656] = 250141, [86657] = 250141, [86658] = 250141,	
	[87011] = 62141, [87010] = 62141, [87009] = 62141, [87008] = 62141, [87007] = 62141, [85374] = 62141, [85375] = 62141, [85376] = 62141, [85377] = 62141, [85378] = 62141, [86714] = 62141, [86715] = 62141, [86716] = 62141, [86717] = 62141, [86718] = 62141,	
	[84413] = 62162, [84414] = 62162, [84415] = 62162, [84416] = 62162, [84417] = 62162, [84837] = 62162, [84855] = 62162, [84875] = 62162, [84904] = 62162, [84917] = 62162, [85016] = 62162, [85031] = 62162, [85062] = 62162, [85068] = 62162, [85085] = 62162, [88251] = 62162, [88252] = 62162, [88253] = 62162, [88254] = 62162, [88255] = 62162, [91232] = 62162, [91233] = 62162, [91234] = 62162, [91235] = 62162, [91236] = 62162, [91237] = 62162, [91238] = 62162, [91239] = 62162, [91240] = 62162, [91241] = 62162, [91585] = 62162, [91587] = 62162, [91589] = 62162, [91591] = 62162, [91593] = 62162, [93499] = 62162, [93500] = 62162, [93501] = 62162, [93502] = 62162, [93503] = 62162, [94362] = 62162, [94381] = 62162, [94389] = 62162, [94431] = 62162, [94451] = 62162, [98825] = 62162, [98826] = 62162, [98827] = 62162, [98828] = 62162, [98829] = 62162, [99852] = 62162, [99853] = 62162, [99854] = 62162, [99855] = 62162, [99856] = 62162, [100032] = 62162, [100051] = 62162, [100059] = 62162, [100101] = 62162, [100121] = 62162, [100328] = 62162, [100329] = 62162, [100330] = 62162, [100331] = 62162, [100332] = 62162, [100333] = 62162, [100334] = 62162, [100335] = 62162, [100336] = 62162, [100337] = 62162, [100592] = 62162, [100611] = 62162, [100619] = 62162, [100661] = 62162, [100681] = 62162, [102648] = 62162, [102667] = 62162, [102673] = 62162, [102715] = 62162, [102735] = 62162, [102845] = 62162, [102864] = 62162, [102870] = 62162, [102912] = 62162, [102932] = 62162, [103224] = 62162, [103225] = 62162, [103226] = 62162, [103227] = 62162, [103228] = 62162, [103421] = 62162, [103422] = 62162, [103423] = 62162, [103424] = 62162, [103425] = 62162,
	[85359] = 256141, [85360] = 256141, [85361] = 256141, [85362] = 256141, [85363] = 256141, [86699] = 256141, [86700] = 256141, [86701] = 256141, [86702] = 256141, [86703] = 256141, [87114] = 256141, [87115] = 256141, [87116] = 256141, [87117] = 256141, [87118] = 256141,
	[85379] = 104141, [85380] = 104141, [85381] = 104141, [85382] = 104141, [85383] = 104141, [86719] = 104141, [86720] = 104141, [86721] = 104141, [86722] = 104141, [86723] = 104141, [86938] = 104141, [86939] = 104141, [86940] = 104141, [86941] = 104141, [86942] = 104141,
	[85354] = 105141, [85355] = 105141, [85356] = 105141, [85357] = 105141, [85358] = 105141, [86694] = 105141, [86695] = 105141, [86696] = 105141, [86697] = 105141, [86698] = 105141, [86928] = 105141, [86929] = 105141, [86930] = 105141, [86931] = 105141, [86932] = 105141,
	[84483] = 262162, [84484] = 262162, [84485] = 262162, [84486] = 262162, [84487] = 262162, [84798] = 262162, [84845] = 262162, [84860] = 262162, [84879] = 262162, [84924] = 262162, [84988] = 262162, [85012] = 262162, [85036] = 262162, [85048] = 262162, [85079] = 262162, [88216] = 262162, [88217] = 262162, [88218] = 262162, [88219] = 262162, [88220] = 262162, [91380] = 262162, [91381] = 262162, [91382] = 262162, [91383] = 262162, [91384] = 262162, [91385] = 262162, [91386] = 262162, [91387] = 262162, [91388] = 262162, [91389] = 262162, [91733] = 262162, [91735] = 262162, [91737] = 262162, [91739] = 262162, [91741] = 262162, [93590] = 262162, [93591] = 262162, [93592] = 262162, [93593] = 262162, [93594] = 262162, [94350] = 262162, [94408] = 262162, [94409] = 262162, [94459] = 262162, [94497] = 262162, [98905] = 262162, [98906] = 262162, [98907] = 262162, [98908] = 262162, [98909] = 262162, [99927] = 262162, [99928] = 262162, [99929] = 262162, [99930] = 262162, [99931] = 262162, [100020] = 262162, [100078] = 262162, [100079] = 262162, [100129] = 262162, [100167] = 262162, [100470] = 262162, [100471] = 262162, [100472] = 262162, [100473] = 262162, [100474] = 262162, [100475] = 262162, [100476] = 262162, [100477] = 262162, [100478] = 262162, [100479] = 262162, [100580] = 262162, [100638] = 262162, [100639] = 262162, [100689] = 262162, [100727] = 262162, [102637] = 262162, [102692] = 262162, [102693] = 262162, [102743] = 262162, [102781] = 262162, [102834] = 262162, [102889] = 262162, [102890] = 262162, [102940] = 262162, [102978] = 262162, [103299] = 262162, [103300] = 262162, [103301] = 262162, [103302] = 262162, [103303] = 262162, [103496] = 262162, [103497] = 262162, [103498] = 262162, [103499] = 262162, [103500] = 262162,
	[84385] = 105162, [84386] = 105162, [84387] = 105162, [84388] = 105162, [84389] = 105162, [84833] = 105162, [84850] = 105162, [84882] = 105162, [84907] = 105162, [84927] = 105162, [85026] = 105162, [85043] = 105162, [85051] = 105162, [85071] = 105162, [85082] = 105162, [88201] = 105162, [88202] = 105162, [88203] = 105162, [88204] = 105162, [88205] = 105162, [91172] = 105162, [91173] = 105162, [91174] = 105162, [91175] = 105162, [91176] = 105162, [91177] = 105162, [91178] = 105162, [91179] = 105162, [91180] = 105162, [91181] = 105162, [91420] = 105162, [91422] = 105162, [91424] = 105162, [91426] = 105162, [91428] = 105162, [91525] = 105162, [91527] = 105162, [91529] = 105162, [91531] = 105162, [91533] = 105162, [93466] = 105162, [93467] = 105162, [93468] = 105162, [93469] = 105162, [93470] = 105162, [98797] = 105162, [98798] = 105162, [98799] = 105162, [98800] = 105162, [98801] = 105162, [99819] = 105162, [99820] = 105162, [99821] = 105162, [99822] = 105162, [99823] = 105162, [100041] = 105162, [100042] = 105162, [100107] = 105162, [100147] = 105162, [100162] = 105162, [100268] = 105162, [100269] = 105162, [100270] = 105162, [100271] = 105162, [100272] = 105162, [100273] = 105162, [100274] = 105162, [100275] = 105162, [100276] = 105162, [100277] = 105162, [100601] = 105162, [100602] = 105162, [100667] = 105162, [100707] = 105162, [100722] = 105162, [102657] = 105162, [102658] = 105162, [102721] = 105162, [102761] = 105162, [102776] = 105162, [102854] = 105162, [102855] = 105162, [102918] = 105162, [102958] = 105162, [102973] = 105162, [103192] = 105162, [103193] = 105162, [103194] = 105162, [103195] = 105162, [103196] = 105162, [103389] = 105162, [103390] = 105162, [103391] = 105162, [103392] = 105162, [103393] = 105162,
	[95270] = 270151, [95271] = 270151, [95272] = 270151, [95273] = 270151, [95274] = 270151, [95900] = 270151, [95901] = 270151, [95902] = 270151, [95903] = 270151, [95904] = 270151, [96644] = 270151, [96645] = 270151, [96646] = 270151, [96647] = 270151, [96648] = 270151,
	[85394] = 269141, [85395] = 269141, [85396] = 269141, [85397] = 269141, [85398] = 269141, [86734] = 269141, [86735] = 269141, [86736] = 269141, [86737] = 269141, [86738] = 269141, [87084] = 269141, [87085] = 269141, [87086] = 269141, [87087] = 269141, [87088] = 269141,
	[85299] = 259141, [85300] = 259141, [85301] = 259141, [85302] = 259141, [85303] = 259141, [86639] = 259141, [86640] = 259141, [86641] = 259141, [86642] = 259141, [86643] = 259141, [87124] = 259141, [87125] = 259141, [87126] = 259141, [87127] = 259141, [87128] = 259141,
	[115540] = 11171, [115541] = 11171, [115542] = 11171, [115543] = 11171, [115544] = 11171, 
	[115575] = 7171, [115576] = 7171, [115577] = 7171, [115578] = 7171, [115579] = 7171, 
	
}

module.db.spell_casting_list = {		--Спелы, каст которых подсвечивать
	[20484]=2,
	[20707]=3,
	--[635]=2.5,	--> Holy Light, for test
	[64382]=1.5,
	[10326]=1.7,
	[20066]=1.7,
	[32375]=1.5,
	[61882]=2.5,
	[51514]=1.7,
	[117014]=2,
	[73920]=2,
	[112948]=1.5,
	[102051]=1.5,
	[2120]=2,
	[31687]=1.5,
	[29893]=3,
	[123986]=1,
}

local spell_casting_data_set = nil
do
	local castingData = {}
	local nilData = {}
	module.db.spell_casting_data = setmetatable({}, {
		__index = function (t,k) 
			return castingData[k] or nilData
		end
	})
	function spell_casting_data_set(playerName,spellID,timeNow,timeCasting)
		local playerData = castingData[playerName]
		if not playerData then
			playerData = {}
			castingData[playerName] = playerData
		end
		local spellData = playerData[spellID]
		if not spellData then
			spellData = {}
			playerData[spellID] = spellData
		end
		spellData[1] = timeNow
		spellData[2] = timeCasting
		spellData[3] = timeNow + timeCasting
	end
end

module.db.spell_talentReplaceOther = {		--Спелы, показ которых нужно убрать при наличии таланта (талант заменяет эти спелы)
	[85673] = 114163,
	[3411] = 114029,
	[853] = 105593,
	[34433] = 123040,
	[47476] = 108194,
	[2484] = 51485,
	[66] = 110959,
	[109132] = 115008,
	[101546] = 116847,
	[5246] = 176289,
	[23920] = 114028,
	[43265] = 152280,
	[45438] = 157913,
}

module.db.spell_aura_list = {		--Спелы, время действия которых отменять при отмене бафа 	[buff_sid] = spellID
	[109964]=109964,
	[33206]=33206,
	[47788]=47788,
	[6940]=6940,
	[1022]=1022,
	[15286]=15286,
	[115176]=115176,
	[110913]=110913,
	[116849]=116849,
	[108281]=108281,
	[102342]=102342,
	[114039]=114039,
	[118038]=118038,
	[1044]=1044,
	[1038]=1038,
	[114030]=114030,
	[147833]=3411,
	[114192]=114192,
	[31850]=31850,
	[74001]=74001,
	[79140]=79140,
	[114018]=114018,
	[112833]=112833,
	[47585]=47585,
	[48707]=48707,
	[110960]=110959,
	[45438]=45438,
	[32612]=66,
	[116680]=116680,
	[122470]=122470,
	[122278]=122278,
	[112071]=112071,
}
module.db.spell_speed_list = {		--Спелы, которым менять время действия на основании спелхасты
	[740]=true,
	[64843]=true,
}
module.db.spell_afterCombatReset = {	--Принудительный сброс кд после боя с боссом (для спелов с кд менее 5 мин.)
	[740]=true,
	[86659]=true,
	[161642]=true,
}
module.db.spell_afterCombatNotReset = {	--Запрещать сброс кд после боя с боссом (для петов, например; для спелов с кд 5 и более мин., для анха)
	[90355]=true,
	[126393]=true,
	[53478]=true,
	[55709]=true,
	[20608]=true,
	[21169]=true,
	[159931]=true,
	[159956]=true,
}
module.db.spell_reduceCdByHaste = {	--Заклинания, кд которых уменьшается хастой
	[20473]=true,
}
module.db.spell_readiness = {		--Заклинания, на которые влияет *readiness*	(SoO trinkets)
	[71] = {[52174]=true,[1160]=true,[871]=true,[118000]=true,[12292]=true,[107574]=true,[107570]=true,[46924]=true,[46968]=true},
	[72] = {[52174]=true,[1160]=true,[871]=true,[118000]=true,[12292]=true,[107574]=true,[107570]=true,[46924]=true,[46968]=true},
	[73] = {[52174]=true,[1719]=true,[1160]=true,[871]=true,[12975]=true},
	
	[65] = {},
	[66] = {[86659]=true,[31884]=true,[31850]=true,[1022]=true,[498]=true,[642]=true},
	[70] = {[86698]=true,[31884]=true,[1044]=true,[1022]=true,[498]=true,[642]=true,[114039]=true},
	
	[253] = {[51753]=true,[3045]=true,[5384]=true,[781]=true,[19574]=true},
	[254] = {[51753]=true,[3045]=true,[5384]=true,[781]=true},
	[255] = {[51753]=true,[3045]=true,[5384]=true,[781]=true,[3674]=true},

	[259] = {[121471]=true,[31224]=true,[2983]=true,[5277]=true,[79140]=true,[1856]=true},
	[260] = {[121471]=true,[31224]=true,[2983]=true,[5277]=true,[51690]=true,[13750]=true},
	[261] = {[121471]=true,[31224]=true,[2983]=true,[5277]=true,[1856]=true,[51713]=true},
	
	[256] = {},
	[257] = {},
	[258] = {},
	
	[250] = {[77575]=true,[48707]=true,[48792]=true,[49222]=true,[55233]=true,[49028]=true},
	[251] = {[77575]=true,[42650]=true,[48707]=true,[48792]=true,[47568]=true,[51271]=true,[50034]=true},
	[252] = {[77575]=true,[42650]=true,[48707]=true,[48792]=true,[49206]=true,[49016]=true},

	[262] = {},
	[263] = {[79206]=true,[2894]=true,[30823]=true,[51533]=true,[2062]=true},
	[264] = {},
	
	[62] = {},
	[63] = {},
	[64] = {},
	
	[265] = {},
	[266] = {},
	[267] = {},
	
	[268] = {[119996]=true,[115176]=true,[115213]=true,[115295]=true,[115203]=true,[122057]=true},
	[269] = {[119996]=true,[115176]=true,[115288]=true,[115203]=true,[101545]=true,[113656]=true},
	[270] = {},
	
	[102] = {},
	[103] = {[106898]=true,[61336]=true,[106952]=true,[22812]=true,[1850]=true,[5217]=true},
	[104] = {[106898]=true,[61336]=true,[106952]=true,[22812]=true,[106922]=true,[102795]=true},
	[105] = {},
	
	[0] = {},
}
module.db.spell_resetOtherSpells = {	--Заклинания, которые откатывают другие заклинания
	[11958]={45438,122},
	[108285]={108269,8177,51485,8143,5394,108270,108273},
	[14185]={1856,2983,5277},
}
module.db.spell_sharingCD = {		--Заклинания, которые запускают кд на другие заклинания 	[spellID] = {[otherSpellID] = CD}
	[102060]={[6552]=15,},
	[6552]={[102060]=15,},
	[106898]={[77764]=120,[77761]=120,},
	[77764]={[106898]=120,[77761]=120,},
	[77761]={[77764]=120,[106898]=120,},
}
module.db.spell_reduceCdCast = {	--Заклинания, применение которых уменьшает время восстановления других заклинаний
	[2098]={13750,-10,51690,-10,2983,-10},
	[121411]={13750,-10,51690,-10,2983,-10},
	[5185]={{132158,54825},-2},
	[5176]={{112071,166677},-3},
	[2912]={{112071,166677},-3},
	[17364]={{51533,165605},-5},
}
module.db.spell_increaseDurationCast = {	--Заклинания, продляющие время действия
	[12294]={{118038,58386},2},
	[100130]={{118038,58386},0.25},
}
module.db.spell_dispellsFix = {}
module.db.spell_dispellsList = {	--Заклинания-диспелы (мгновенно откатываются, если ничего не диспелят)
	[4987] = true,
	[527] = true,
	[51886] = true,
	[77130] = true,
	[475] = true,
	[115450] = true,
	[2782] = true,
	[88423] = true,
}
module.db.spell_notInCLEU_fix = {	--Заклинания, которые не отображаются в комбат-логе; выполнять проверку по UNIT_SPELLCAST_SUCCEEDED
	[86659] = true,
}

module.db.spell_startCDbyAuraFade = {	--Заклинания, кд которых запускается только при спадении ауры
	[89485]=true,
	[132158]=true,
	[34477]=true,
}
module.db.spell_reduceCdByAuraFade = {	--Заклинания, кд которых уменьшается при спадении ауры до окончания времени действия. !Важно обязательное время действия для таких заклинаний
	[31850]={{31850,159548},-120},
}
module.db.spell_battleRes = {		--Заклинания-воскрешения [WOD]
	[20484]=true,
	[20707]=true,
	[61999]=true,
	[126393]=true,
	[161642]=true,
	[159931]=true,
	[159956]=true,
}
module.db.resurrect_data = {}
module.db.resurrect_count = 0
module.db.isResurectDisabled = nil

module.db.def_col = {			--Стандартные положения в колонках
	["31821;2"]=1,
	["62618;2"]=1,
	["97462;2"]=1,
	["97462;3"]=1,
	["114203;1"]=1,
	["76577;1"]=1,
	["115213;4"]=1,
	["51052;1"]=1,
	["98008;4"]=1,
	["115310;4"]=1,
	["64843;3"]=1,
	["740;5"]=1,
	["108280;4"]=1,
	["108281;1"]=1,
	["172106;1"]=1,
	["172106;1"]=1,
	["161642;1"]=3,
	["20484;1"]=3,
	["20707;1"]=3,
	["61999;1"]=3,
	["64901;1"]=3,
	["47788;3"]=2,
	["33206;2"]=2,
	["6940;1"]=2,
	["6940;4"]=2,
	["102342;5"]=2,
	["114030;1"]=2,
	["1022;1"]=2,
	["16190;4"]=3,
	["114207;1"]=3,
	["120668;1"]=3,
	["106898;1"]=3,
	["77764;3"]=3,
	["77761;4"]=3,
	["29166;1"]=3,
	["73325;1"]=3,
	["108968;1"]=2,
	["142723;4"]=2,
	["115176;1"]=3,
	["57934;1"]=3,
	["108199;1"]=3,
	["110913;1"]=2,
	["116849;4"]=2,
	["114039;1"]=2,
	["118038;2"]=3,
	["118038;3"]=3,
	["1044;1"]=3,
	["1038;1"]=3,
	["633;1"]=2,
	["109964;2"]=3,
	["2825;1"]=3,
	["80353;1"]=3,
	["20608;1"]=3,
}

module.db.petsAbilities = {	--> PetTypes = HUNTERS[ Tenacity [1], Cunning = [2], Ferocity[3] ]
	[0] = 						{},
	[ExRT.L.creatureNames["Basilisk"]] = 		{1,	{159733,45},	},
	[ExRT.L.creatureNames["Bat"]] = 		{2,	},
	[ExRT.L.creatureNames["Bear"]] = 		{1,	{50256,10},	},
	[ExRT.L.creatureNames["Beetle"]] = 		{1,	{90339,60,12},	},
	[ExRT.L.creatureNames["Bird of Prey"]] = 	{2,	},
	[ExRT.L.creatureNames["Boar"]] = 		{1,	},
	[ExRT.L.creatureNames["Carrion Bird"]] = 	{3,	{24423,6},	},
	[ExRT.L.creatureNames["Cat"]] = 		{3,	{24450,10},	{93435,45},	},
	[ExRT.L.creatureNames["Chimaera"]] = 		{2,	{54644,10},	},
	[ExRT.L.creatureNames["Core Hound"]] = 		{3,	{90355,360,40},	},
	[ExRT.L.creatureNames["Crab"]] = 		{1,	{159926,60,12},	},
	[ExRT.L.creatureNames["Crane"]] = 		{2,	{159931,600},	},
	[ExRT.L.creatureNames["Crocolisk"]] = 		{1,	{50433,10},	},
	[ExRT.L.creatureNames["Devilsaur"]] = 		{3,	{159953,60},	{54680,8},	},
	[ExRT.L.creatureNames["Direhorn"]] = 		{1,	{137798,30},	},
	[ExRT.L.creatureNames["Dog"]] = 		{3,	},
	[ExRT.L.creatureNames["Dragonhawk"]] = 		{2,	},
	[ExRT.L.creatureNames["Fox"]] = 		{3,	{160011,120},	},
	[ExRT.L.creatureNames["Goat"]] = 		{3,	},
	[ExRT.L.creatureNames["Gorilla"]] = 		{1,	},
	[ExRT.L.creatureNames["Hyena"]] = 		{3,	{128432,90},	},
	[ExRT.L.creatureNames["Monkey"]] = 		{2,	{160044,120},	},
	[ExRT.L.creatureNames["Moth"]] = 		{3,	{159956,600},	},
	[ExRT.L.creatureNames["Nether Ray"]] = 		{2,	{90355,360,40},	},
	[ExRT.L.creatureNames["Porcupine"]] = 		{1,	},
	[ExRT.L.creatureNames["Quilen"]] = 		{3,	{126393,600},	},
	[ExRT.L.creatureNames["Raptor"]] = 		{3,	{160052,45},	},
	[ExRT.L.creatureNames["Ravager"]] = 		{2,	},
	["Clefthoof"] = 				{1,	},					-- Clefthoof[WOD] = Rhino
	[ExRT.L.creatureNames["Scorpid"]] = 		{1,	{160060,6},	},
	[ExRT.L.creatureNames["Serpent"]] = 		{2,	{128433,90},	},
	[ExRT.L.creatureNames["Shale Spider"]] = 	{1,	{160063,60,12},	},
	[ExRT.L.creatureNames["Silithid"]] = 		{2,	{160065,10},	},
	[ExRT.L.creatureNames["Spider"]] = 		{2,	{160067,10},	},
	[ExRT.L.creatureNames["Spirit Beast"]] = 	{3,	{90328,10},	{90361,30},	},
	[ExRT.L.creatureNames["Sporebat"]] = 		{2,	},
	[ExRT.L.creatureNames["Tallstrider"]] = 	{3,	{160073,45},	},
	[ExRT.L.creatureNames["Turtle"]] = 		{1,	{26064,60,12},	},
	[ExRT.L.creatureNames["Warp Stalker"]] = 	{1,	{35346,15},	},
	[ExRT.L.creatureNames["Wasp"]] = 		{3,	},
	[ExRT.L.creatureNames["Water Strider"]] = 	{2,	},
	[ExRT.L.creatureNames["Wind Serpent"]] = 	{2,	},
	[ExRT.L.creatureNames["Wolf"]] = 		{3,	{24604,45},	},
	[ExRT.L.creatureNames["Worm"]] = 		{1,	{93433,14},	},
	[1] = 						{0,	{53478,360,20},	{61685,25},	{63900,10},	},
	[2] = 						{0,	{53490,180,12},	{61684,32,16},	{53480,60,12},	},
	[3] = 						{0,	{61684,32,16},	{55709,480},	},
	[ExRT.L.creatureNames["Ghoul"]] = 		{0,	{91837,45,10},	{91802,30},	{91797,60},	},
	[ExRT.L.creatureNames["Felguard"]] = 		{0,	{89751,45,6},	{89766,30},	{30151,15},	},
	[ExRT.L.creatureNames["Felhunter"]] = 		{0,	{19647,24},	{19505,15},	},
	[ExRT.L.creatureNames["Fel Imp"]] = 		{0,	{115276,30},	},
	[ExRT.L.creatureNames["Imp"]] = 		{0,	{89808,10},	{119899,30,12},	{89792,20},	},
	[ExRT.L.creatureNames["Observer"]] = 		{0,	{115781,24},	{115284,15},	},
	[ExRT.L.creatureNames["Shivarra"]] = 		{0,	{115770,25},	{115268,30},	},
	[ExRT.L.creatureNames["Succubus"]] = 		{0,	{6360,25},	{6358,30},	},
	[ExRT.L.creatureNames["Voidlord"]] = 		{0,	{115236,10}	},
	[ExRT.L.creatureNames["Voidwalker"]] = 		{0,	{17735,10},	{17767,120,20},	{115232,10},	},
	[ExRT.L.creatureNames["Wrathguard"]] = 		{0,	{115831,45,6},	},
	[ExRT.L.creatureNames["Water Elemental"]] = 	{0,	{135029,25,4},	{33395,25},	},
}
module.db.spell_isPetAbility = {}
do
	for petName,petData in pairs(module.db.petsAbilities) do
		for i=2,#petData do
			module.db.spell_isPetAbility[petData[i][1]] = petName
		end
	end
end

module.db.inspect_statsNames = {
	haste = {ExRT.L.cd2InspectHaste,ExRT.L.cd2InspectHasteGem},
	mastery = {ExRT.L.cd2InspectMastery,ExRT.L.cd2InspectMasteryGem},
	crit = {ExRT.L.cd2InspectCrit,ExRT.L.cd2InspectCritGem,ExRT.L.cd2InspectCritGemLegendary},
	spirit = {ExRT.L.cd2InspectSpirit,ExRT.L.cd2InspectAll},
	
	intellect = {ExRT.L.cd2InspectInt,ExRT.L.cd2InspectIntGem,ExRT.L.cd2InspectAll},
	agility = {ExRT.L.cd2InspectAgi,ExRT.L.cd2InspectAll},
	strength = {ExRT.L.cd2InspectStr,ExRT.L.cd2InspectStrGem,ExRT.L.cd2InspectAll},
	spellpower = {ExRT.L.cd2InspectSpd},
	
	multistrike = {ExRT.L.cd2InspectMultistrike,ExRT.L.cd2InspectMultistrikeGem},
	versatility = {ExRT.L.cd2InspectVersatility,ExRT.L.cd2InspectVersatilityGem},
	leech = {ExRT.L.cd2InspectLeech},
	armor = {ExRT.L.cd2InspectBonusArmor},
	avoidance = {ExRT.L.cd2InspectAvoidance},
	speed = {ExRT.L.cd2InspectSpeed},
	
}

module.db.inspect_radinessTrinkets = {
	[105472] = {[572] = 0.4675, [576] = 0.4852, [580] = 0.5036, [584] = 0.5227, [588] = 0.5425, [592] = 0.5630, [596] = 0.5843, [463] = 0.1693,},
	[104476] = {[566] = 0.4420, [570] = 0.4589, [574] = 0.4763, [578] = 0.4944, [582] = 0.5131, [586] = 0.5325, [590] = 0.5527, [463] = 0.1693,},
	[105223] = {[559] = 0.4141, [563] = 0.4299, [567] = 0.4462, [571] = 0.4631, [575] = 0.4807, [579] = 0.4990, [583] = 0.5179, [463] = 0.1693,},
	[102292] = {[553] = 0.3961, [557] = 0.4065, [561] = 0.4219, [565] = 0.4379, [569] = 0.4545, [573] = 0.4717, [577] = 0.4896, [463] = 0.1693,},
	[-1]     = {[546] = 0.3670, [550] = 0.3809, [554] = 0.3954, [558] = 0.4104, [562] = 0.4260, [566] = 0.4420, [570] = 0.4589, [463] = 0.1693,},
	[104725] = {[540] = 0.3470, [544] = 0.3602, [548] = 0.3738, [552] = 0.3879, [556] = 0.4026, [560] = 0.4179, [564] = 0.4337, [463] = 0.1693,},
	[104974] = {[528] = 0.3103, [532] = 0.3220, [536] = 0.3342, [540] = 0.3470, [544] = 0.3602, [548] = 0.3738, [552] = 0.3879, [463] = 0.1693,},
	
	[105491] = {[572] = 0.4675, [576] = 0.4852, [580] = 0.5036, [584] = 0.5227, [588] = 0.5425, [592] = 0.5630, [596] = 0.5843, [463] = 0.1693,},
	[104495] = {[566] = 0.4420, [570] = 0.4589, [574] = 0.4763, [578] = 0.4944, [582] = 0.5131, [586] = 0.5325, [590] = 0.5527, [463] = 0.1693,},
	[105242] = {[559] = 0.4141, [563] = 0.4299, [567] = 0.4462, [571] = 0.4631, [575] = 0.4807, [579] = 0.4990, [583] = 0.5179, [463] = 0.1693,},
	[102298] = {[553] = 0.3961, [557] = 0.4065, [561] = 0.4219, [565] = 0.4379, [569] = 0.4545, [573] = 0.4717, [577] = 0.4896, [463] = 0.1693,},
	[104744] = {[540] = 0.3470, [544] = 0.3602, [548] = 0.3738, [552] = 0.3879, [556] = 0.4026, [560] = 0.4179, [564] = 0.4337, [463] = 0.1693,},
	[104993] = {[528] = 0.3103, [532] = 0.3220, [536] = 0.3342, [540] = 0.3470, [544] = 0.3602, [548] = 0.3738, [552] = 0.3879, [463] = 0.1693,},
	
	[105568] = {[572] = 0.2337, [576] = 0.2426, [580] = 0.2518, [584] = 0.2613, [588] = 0.2713, [592] = 0.2817, [596] = 0.2925, [463] = 0.0846,},
	[104572] = {[566] = 0.2210, [570] = 0.2294, [574] = 0.2381, [578] = 0.2471, [582] = 0.2565, [586] = 0.2662, [590] = 0.2763, [463] = 0.0846,},
	[105319] = {[559] = 0.2071, [563] = 0.2149, [567] = 0.2231, [571] = 0.2316, [575] = 0.2405, [579] = 0.2497, [583] = 0.2593, [463] = 0.0846,},
	[102306] = {[553] = 0.1958, [557] = 0.2032, [561] = 0.2110, [565] = 0.2191, [569] = 0.2275, [573] = 0.2362, [577] = 0.2453, [463] = 0.0846,},
	[-2]     = {[546] = 0.1835, [550] = 0.1904, [554] = 0.1976, [558] = 0.2051, [562] = 0.2129, [566] = 0.2210, [570] = 0.2294, [463] = 0.0846,},
	[104821] = {[540] = 0.1735, [544] = 0.1801, [548] = 0.1869, [552] = 0.1940, [556] = 0.2013, [560] = 0.2089, [564] = 0.2167, [463] = 0.0846,},
	[105070] = {[528] = 0.1551, [532] = 0.1610, [536] = 0.1671, [540] = 0.1735, [544] = 0.1801, [548] = 0.1869, [552] = 0.1940, [463] = 0.0846,},	
}
module.db.inspect_amplifyTrinkets = {
	[105474] = {[572] = 8.35568, [576] = 8.67297, [580] = 9.00231, [584] = 9.34667, [588] = 9.70153, [592] = 10.0698, [596] = 10.4521, [463] = 3.02629,},
	[104478] = {[566] = 7.90138, [570] = 8.20142, [574] = 8.51285, [578] = 8.83605, [582] = 9.17152, [586] = 9.51972, [590] = 9.88115, [463] = 3.02629,},
	[105225] = {[559] = 7.40248, [563] = 7.68357, [567] = 7.97534, [571] = 8.27819, [575] = 8.59254, [579] = 8.91882, [583] = 9.25750, [463] = 3.02629,},
	[102299] = {[553] = 7.00000, [557] = 7.26581, [561] = 7.54172, [565] = 7.82810, [569] = 8.12536, [573] = 8.43390, [577] = 8.75417, [463] = 3.02629,},
	[-1]     = {[546] = 6.55803, [550] = 6.80705, [554] = 7.06554, [558] = 7.33383, [562] = 7.61232, [566] = 7.90138, [570] = 8.20142, [463] = 3.02629,},
	[104727] = {[540] = 6.20145, [544] = 6.43694, [548] = 6.68137, [552] = 9.93508, [556] = 7.19843, [560] = 7.47177, [564] = 7.75550, [463] = 3.02629,},
	[104976] = {[528] = 5.54543, [532] = 5.75600, [536] = 5.97458, [540] = 6.20145, [544] = 6.43694, [548] = 6.68137, [552] = 6.93508, [463] = 3.02629,},

	[105422] = {[572] = 8.35568, [576] = 8.67297, [580] = 9.00231, [584] = 9.34667, [588] = 9.70153, [592] = 10.0698, [596] = 10.4521, [463] = 3.02629,},
	[104426] = {[566] = 7.90138, [570] = 8.20142, [574] = 8.51285, [578] = 8.83605, [582] = 9.17152, [586] = 9.51972, [590] = 9.88115, [463] = 3.02629,},
	[105173] = {[559] = 7.40248, [563] = 7.68357, [567] = 7.97534, [571] = 8.27819, [575] = 8.59254, [579] = 8.91882, [583] = 9.25750, [463] = 3.02629,},
	[102293] = {[553] = 7.00000, [557] = 7.26581, [561] = 7.54172, [565] = 7.82810, [569] = 8.12536, [573] = 8.43390, [577] = 8.75417, [463] = 3.02629,},
	[104675] = {[540] = 6.20145, [544] = 6.43694, [548] = 6.68137, [552] = 9.93508, [556] = 7.19843, [560] = 7.47177, [564] = 7.75550, [463] = 3.02629,},
	[104924] = {[528] = 5.54543, [532] = 5.75600, [536] = 5.97458, [540] = 6.20145, [544] = 6.43694, [548] = 6.68137, [552] = 6.93508, [463] = 3.02629,},

	[105609] = {[572] = 8.35568, [576] = 8.67297, [580] = 9.00231, [584] = 9.34667, [588] = 9.70153, [592] = 10.0698, [596] = 10.4521, [463] = 3.02629,},
	[104613] = {[566] = 7.90138, [570] = 8.20142, [574] = 8.51285, [578] = 8.83605, [582] = 9.17152, [586] = 9.51972, [590] = 9.88115, [463] = 3.02629,},
	[105360] = {[559] = 7.40248, [563] = 7.68357, [567] = 7.97534, [571] = 8.27819, [575] = 8.59254, [579] = 8.91882, [583] = 9.25750, [463] = 3.02629,},
	[102305] = {[553] = 7.00000, [557] = 7.26581, [561] = 7.54172, [565] = 7.82810, [569] = 8.12536, [573] = 8.43390, [577] = 8.75417, [463] = 3.02629,},
	[104862] = {[540] = 6.20145, [544] = 6.43694, [548] = 6.68137, [552] = 9.93508, [556] = 7.19843, [560] = 7.47177, [564] = 7.75550, [463] = 3.02629,},
	[105111] = {[528] = 5.54543, [532] = 5.75600, [536] = 5.97458, [540] = 6.20145, [544] = 6.43694, [548] = 6.68137, [552] = 6.93508, [463] = 3.02629,},
}
do
	local newRadiness = {}
	local readinessDD = {105472,104476,105223,102292,104725,104974,-1}
	for _,id in ipairs(readinessDD) do
		for ilvl,coeff in pairs(module.db.inspect_radinessTrinkets[id]) do
			newRadiness[ilvl] = coeff
		end
	end
	module.db.inspect_radinessTrinkets[112947] = newRadiness
	module.db.inspect_radinessTrinkets[112703] = newRadiness
	newRadiness = {}
	local readinessTank = {105568,104572,105319,102306,104821,105070,-2}
	for _,id in ipairs(readinessTank) do
		for ilvl,coeff in pairs(module.db.inspect_radinessTrinkets[id]) do
			newRadiness[ilvl] = coeff
		end
	end
	module.db.inspect_radinessTrinkets[112792] = newRadiness
	local newAmplify = {}
	local amplify = {105474,104478,105225,102299,104727,104976,-1}
	for _,id in ipairs(amplify) do
		for ilvl,coeff in pairs(module.db.inspect_amplifyTrinkets[id]) do
			newAmplify[ilvl] = coeff
		end
	end
	module.db.inspect_amplifyTrinkets[112426] = newAmplify
	module.db.inspect_amplifyTrinkets[112948] = newAmplify
	module.db.inspect_amplifyTrinkets[112850] = newAmplify
	
	-- Amplify trinkets at level 100: same
	-- Readiness trinkets at level 100 (91+): X/25 effective	ONLY TOOLTIP BUG???? YES :(
end

module.db.itemsToSpells = {	-- Тринкеты вида [item ID] = spellID
	[113931] = 176878,
	[113969] = 176874,
	[118876] = 177597,
	[118878] = 177594,
	[118880] = 177592,
	[118882] = 177189,
	[118884] = 176460,
	[113905] = 176873,
	[113834] = 176876,
	[113835] = 176875,
	[113842] = 176879,
	[110002] = 165531,
	[110003] = 165543,
	[110008] = 165535,
	[110012] = 165532,
	[110013] = 165543,
	[110017] = 165534,
	[110018] = 165535,
	[114488] = 176883,
	[114489] = 176882,
	[114490] = 176884,
	[114491] = 176881,
	[114492] = 176885,
	[109997] = 165485,
	[109998] = 165542,
	[110007] = 165532,
}
do
	for itemID,spellID in pairs(module.db.itemsToSpells) do
		module.db.spell_isTalent[spellID] = true
	end
end

module.db.itemsSlotTable = {
	1,	--INVSLOT_HEAD
	2,	--INVSLOT_NECK
	3,	--INVSLOT_SHOULDER
	15,	--INVSLOT_BACK
	5,	--INVSLOT_CHEST
	9,	--INVSLOT_WRIST
	10,	--INVSLOT_HAND
	6,	--INVSLOT_WAIST
	7,	--INVSLOT_LEGS
	8,	--INVSLOT_FEET
	11,	--INVSLOT_FINGER1
	12,	--INVSLOT_FINGER2
	13,	--INVSLOT_TRINKET1
	14,	--INVSLOT_TRINKET2
	16,	--INVSLOT_MAINHAND
	17,	--INVSLOT_OFFHAND
}

module.db.playerName = nil

module.db.notAClass = { r = 0.8, g = 0.8, b = 0.8, colorStr = "ffcccccc" }

local colorSetupFrameColorsNames = {"Default","Active","Cooldown","Cast"}
local colorSetupFrameColorsObjectsNames = {"Text","Background","TimeLine"}
local globalGUIDs = nil

module.db.maxLinesInCol = 30
module.db.maxColumns = 10

module.db.colsDefaults = {
	iconSize = 16,
	iconGray = true,
	iconPosition = 1,
	textureFile = ExRT.mds.barImg,
	textureBorderSize = 0,
	fontSize = 12,
	fontName = ExRT.mds.defFont,
	frameLines = 15,
	frameAlpha = 100,
	frameScale = 100,
	frameWidth = 130,
	frameColumns = 1,
	frameBetweenLines = 0,
	frameBlackBack = 0,
	methodsStyleAnimation = 1,
	methodsTimeLineAnimation = 1,
	
	textureBorderColorR = 0,	textureBorderColorG = 0,	textureBorderColorB = 0,	textureBorderColorA = 1,
	
	textureColorTextDefaultR = 1,	textureColorTextDefaultG = 1,	textureColorTextDefaultB = 1,
	textureColorTextActiveR = 1,	textureColorTextActiveG = 1,	textureColorTextActiveB = 1,
	textureColorTextCooldownR = 1,	textureColorTextCooldownG = 1,	textureColorTextCooldownB = 1,
	textureColorTextCastR = 1,	textureColorTextCastG = 1,	textureColorTextCastB = 1,

	textureColorBackgroundDefaultR = 0,	textureColorBackgroundDefaultG = 1,	textureColorBackgroundDefaultB = 0,
	textureColorBackgroundActiveR = 0,	textureColorBackgroundActiveG = 1,	textureColorBackgroundActiveB = 0,
	textureColorBackgroundCooldownR = 1,	textureColorBackgroundCooldownG = 0,	textureColorBackgroundCooldownB = 0,
	textureColorBackgroundCastR = 1,	textureColorBackgroundCastG = 1,	textureColorBackgroundCastB = 0,

	textureColorTimeLineDefaultR = 0,	textureColorTimeLineDefaultG = 1,	textureColorTimeLineDefaultB = 0,
	textureColorTimeLineActiveR = 0,	textureColorTimeLineActiveG = 1,	textureColorTimeLineActiveB = 0,
	textureColorTimeLineCooldownR = 1,	textureColorTimeLineCooldownG = 0,	textureColorTimeLineCooldownB = 0,
	textureColorTimeLineCastR = 1,		textureColorTimeLineCastG = 1,		textureColorTimeLineCastB = 0,
	
	textureAlphaBackground = 0.3,
	textureAlphaTimeLine = 0.8,
	textureAlphaCooldown = 1,
	
	textTemplateLeft = "%name%",
	textTemplateRight = "%time%",
	textTemplateCenter = "",
}

module.db.colsInit = {
	iconGeneral = true,
	textureGeneral = true,
	methodsGeneral = true,
	frameGeneral = true,
	fontGeneral = true,
	textGeneral = true,
	
	iconGray = true,
	textureAnimation = true,
	
	fontOutline = true,
	fontShadow = false,
}

module.frame = CreateFrame("Frame",nil,UIParent)
module.frame.animation = CreateFrame("Frame")
module.frame:SetPoint("CENTER",UIParent, "CENTER", 0, 0)
module.frame:EnableMouse(true)
module.frame:SetMovable(true)
module.frame:RegisterForDrag("LeftButton")
module.frame:SetScript("OnDragStart", function(self) 
	if self:IsMovable() then 
		self:StartMoving() 
	end 
end)
module.frame:SetScript("OnDragStop", function(self)
	self:StopMovingOrSizing()
	VExRT.ExCD2.Left = self:GetLeft()
	VExRT.ExCD2.Top = self:GetTop()
end)
module.frame.texture = module.frame:CreateTexture(nil, "BACKGROUND")
module.frame.texture:SetTexture(0,0,0,0.3)
module.frame.texture:SetAllPoints()
module:RegisterHideOnPetBattle(module.frame)

module.frame.colFrame = {}

function module.frameCreateLine(parent)
	local self = CreateFrame("Frame",nil,parent)
	self:SetBackdrop({bgFile = ExRT.mds.barImg})
	self:SetBackdropColor(1,1,1,0.1)

	self.t = self:CreateTexture(nil, "BACKGROUND")
	self.t:SetTexture(ExRT.mds.barImg)
	self.t:SetDrawLayer("BACKGROUND", 2)

	self.t_special = self:CreateTexture(nil, "BACKGROUND")
	self.t_special:SetTexture(ExRT.mds.barImg)
	self.t_special:SetDrawLayer("BACKGROUND", 2)
	self.t_special:SetAllPoints()
	self.t_special:Hide()

	self.spark = self:CreateTexture(nil, "BACKGROUND")
	self.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
	self.spark:SetBlendMode("ADD")
	self.spark:SetPoint("CENTER",self.t,"RIGHT", 0,0)
	self.spark:SetDrawLayer("BACKGROUND", 3)
	self.spark:SetAlpha(0.5)
	self.t:Hide()
	self.spark:Hide()

	self.icon = CreateFrame("Frame",nil,self)
	self.icon:SetPoint("TOPLEFT", 0, 0)
	self.icon.t = self.icon:CreateTexture(nil, "BACKGROUND")
	self.icon.t:SetAllPoints()
	
	self.center = ExRT.lib.CreateText(self,0,0,nil,0,0,"CENTER",nil,ExRT.mds.defFont,12,nil,nil,1,1,1,nil,nil,true)
	self.unitName = ExRT.lib.CreateText(self,100,0,nil,1,0,nil,nil,ExRT.mds.defFont,12,nil,nil,1,1,1,nil,nil,true)
	self.time = ExRT.lib.CreateText(self,40,0,"TOPRIGHT",1,0,"RIGHT",nil,ExRT.mds.defFont,12,nil,nil,1,1,1,nil,nil,true)
	self.iconText = ExRT.lib.CreateText(self.icon,0,0,nil,0,0,"CENTER","BOTTOM",ExRT.mds.defFont,12,nil,nil,1,1,1,nil,nil,true)

	self.cooldown = CreateFrame("Cooldown", nil, self, "CooldownFrameTemplate")
	self.cooldown:SetDrawEdge(false)
	self.cooldown:SetAllPoints(self.icon)
	
	self.border = {}
	self.border.top = self:CreateTexture(nil, "BACKGROUND")
	self.border.bottom = self:CreateTexture(nil, "BACKGROUND")
	self.border.left = self:CreateTexture(nil, "BACKGROUND")
	self.border.right = self:CreateTexture(nil, "BACKGROUND")
	
	self.clickFrame = CreateFrame("Button",nil,self)
	self.clickFrame:SetAllPoints()
	self.clickFrame:Hide()
	
	return self
end

for i=1,module.db.maxColumns do
	module.frame.colFrame[i] = CreateFrame("Frame",nil,module.frame)
	module.frame.colFrame[i]:EnableMouse(false)
	module.frame.colFrame[i]:SetMovable(false)
	module.frame.colFrame[i]:RegisterForDrag("LeftButton")
	module.frame.colFrame[i]:SetScript("OnDragStart", function(self) 
		if self:IsMovable() then 
			self:StartMoving() 
		end 
	end)
	module.frame.colFrame[i]:SetScript("OnDragStop", function(self)
		self:StopMovingOrSizing()
		VExRT.ExCD2.colSet[i].posX = self:GetLeft()
		VExRT.ExCD2.colSet[i].posY = self:GetTop()
	end)	
	module.frame.colFrame[i].texture = module.frame.colFrame[i]:CreateTexture(nil, "BACKGROUND")
	module.frame.colFrame[i].texture:SetTexture(0,0,0,0)
	module.frame.colFrame[i].texture:SetAllPoints()
	
	module.frame.colFrame[i].lockTexture = module.frame.colFrame[i]:CreateTexture(nil, "BACKGROUND")
	module.frame.colFrame[i].lockTexture:SetTexture(0,0,0,0)
	module.frame.colFrame[i].lockTexture:SetAllPoints()

	module.frame.colFrame[i].lines = {}
	for j=1,module.db.maxLinesInCol do
		module.frame.colFrame[i].lines[j] = module.frameCreateLine(module.frame.colFrame[i])	
		module.frame.colFrame[i].lines[j]:Hide()
	end
	
	module:RegisterHideOnPetBattle(module.frame.colFrame[i])
end

--> DB Upvaules
local _C, _db, _mainFrame = module._C, module.db, module.frame

local scantip = CreateFrame("GameTooltip", "ExRTExCD2ScanningTooltip", nil, "GameTooltipTemplate")
scantip:SetOwner(UIParent, "ANCHOR_NONE")

local function InspectNext()
	if RaidInCombat() or (InspectFrame and InspectFrame:IsShown()) then
		return
	end
	local nowTime = GetTime()
	if not module.db.inspectCleared then
		--ClearInspectPlayer()
	end
	for name,timeAdded in pairs(module.db.inspectQuery) do
		if name and CanInspect(name) and CheckInteractDistance(name,1) then
			NotifyInspect(name)
			module.db.inspectQuery[name] = nil
			return
		elseif (timeAdded + 300) < nowTime or not UnitName(name) then
			module.db.inspectQuery[name] = nil
		end
	end
end

local function InspectQueue()
	if RaidInCombat() then
		return
	end
	local n = GetNumGroupMembers() or 0
	local timeAdded = GetTime()
	for j=1,n do
		local name,_,subgroup,_,_,_,_,online = GetRaidRosterInfo(j)
		if name and not module.db.inspectDB[name] and online then
			module.db.inspectQuery[name] = timeAdded
		end
	end
end

local function ClearTierSetsInfoFromUnit(name)
	for tierUID,tierData in pairs(module.db.tierSetsSpells) do
		if tierData[1] then
			if type(tierData[1]) ~= "table" then
				module.db.session_gGUIDs[name] = -tierData[1]
			else
				for i=1,#tierData[1] do
					module.db.session_gGUIDs[name] = -tierData[1][i]
				end
			end
		end
		if tierData[2] then
			if type(tierData[2]) ~= "table" then
				module.db.session_gGUIDs[name] = -tierData[2]
			else
				for i=1,#tierData[2] do
					module.db.session_gGUIDs[name] = -tierData[2][i]
				end
			end
		end
	end
	for itemID,spellID in pairs(module.db.itemsToSpells) do
		module.db.session_gGUIDs[name] = -spellID
	end
end

local InspectItems = nil
do
	local ITEM_LEVEL = ITEM_LEVEL or "NO DATA FOR ITEM_LEVEL"
	local ITEM_LEVEL_fix = string_gsub(ITEM_LEVEL,"%%d","(%%d+)")
	function InspectItems(name,inspectedName,inspectSavedID)
		if module.db.inspectCleared or module.db.inspectID ~= inspectSavedID then
			return
		end
		module.db.inspectDB[name] = module.db.inspectDB[name] or {}
		local inspectData = module.db.inspectDB[name]
		inspectData['radiness'] = 0
		inspectData['amplify'] = 0
		inspectData['ilvl'] = 0
		inspectData['tiersets'] = {}
		inspectData['items'] = {}
		for stateName,stateData in pairs(module.db.inspect_statsNames) do
			inspectData[stateName] = 0
		end
		local ilvl_count = 0
		ClearTierSetsInfoFromUnit(name)
		for i=1,#module.db.itemsSlotTable do
			local itemSlotID = module.db.itemsSlotTable[i]
			local itemLink = GetInventoryItemLink(inspectedName, itemSlotID)
			if itemLink then
				inspectData['items'][itemSlotID] = itemLink
				--scantip:SetHyperlink(itemLink)
				scantip:SetInventoryItem(inspectedName, itemSlotID)
				local itemID = string_match(itemLink,"item:(%d+):")
				for j=2, scantip:NumLines() do
					local tooltipLine = _G["ExRTExCD2ScanningTooltipTextLeft"..j]
					local text = tooltipLine:GetText()
					if text and text ~= "" then
						for stateName,stateData in pairs(module.db.inspect_statsNames) do
							inspectData[stateName] = inspectData[stateName] or 0
							local findText = text:gsub(",","")
							for k=1,#stateData do
								local findData = string_match(findText,stateData[k])
								if findData then
									local cR,cG,cB = tooltipLine:GetTextColor()
									cR = abs(cR - 0.5)
									cG = abs(cG - 0.5)
									cB = abs(cB - 0.5)
									if cR < 0.01 and cG < 0.01 and cB < 0.01 then
										findData = 0
									end
									inspectData[stateName] = inspectData[stateName] + tonumber(findData)
								end
							end
						end
						
						local ilvl = string_match(text,ITEM_LEVEL_fix)
						if ilvl then
							ilvl = tonumber(ilvl)
							inspectData['ilvl'] = inspectData['ilvl'] + ilvl
							ilvl_count = ilvl_count + 1
						end
						if ilvl and itemID then
							local n_itemID = tonumber(itemID)
							local trinketTable = module.db.inspect_radinessTrinkets[n_itemID]
							if trinketTable then
								inspectData['radiness'] = trinketTable[ilvl] or 0
							end
							
							local amplifyTable = module.db.inspect_amplifyTrinkets[n_itemID]
							if amplifyTable then
								if inspectData['amplify'] > 0 then
									inspectData['amplify'] = ((inspectData['amplify']/100 + 1) * ( (amplifyTable[ilvl] or 0)/100 + 1 ) - 1) * 100
								else
									inspectData['amplify'] = (amplifyTable[ilvl] or 0)
								end
							end
						end
					end
				end
				scantip:ClearLines()
				itemID = tonumber(itemID or 0)
				local tierSetID = module.db.tierSetsList[itemID]
				if tierSetID then
					inspectData['tiersets'][tierSetID] = inspectData['tiersets'][tierSetID] and inspectData['tiersets'][tierSetID] + 1 or 1
				end
				local isTrinket = module.db.itemsToSpells[itemID]
				if isTrinket then
					module.db.session_gGUIDs[name] = isTrinket
				end
			end
		end
		--if ilvl_count > 0 then
		if inspectData['items'][17] then
			inspectData['ilvl'] = inspectData['ilvl'] / 16
		else
			inspectData['ilvl'] = inspectData['ilvl'] / 15	
		end
		if inspectData.level and inspectData.level > 90 then	--Wait for more info about readiness trinkets at level 100 !!!
			inspectData['radiness'] = 0
			inspectData['amplify'] = 0
		end
		for tierUID,count in pairs(inspectData['tiersets']) do
			local p2 = module.db.tierSetsSpells[tierUID][1]
			local p4 = module.db.tierSetsSpells[tierUID][2]
			if p2 and count >= 2 then
				if type(p2) ~= "table" then
					module.db.session_gGUIDs[name] = p2
				else
					for i=1,#p2 do
						module.db.session_gGUIDs[name] = p2[i]
					end
				end
			end
			if p4 and count >= 4 then
				if type(p4) ~= "table" then
					module.db.session_gGUIDs[name] = p4
				else
					for i=1,#p4 do
						module.db.session_gGUIDs[name] = p4[i]
					end
				end
			end
		end
	end
end

hooksecurefunc("NotifyInspect", function() module.db.inspectID = GetTime() module.db.inspectCleared = nil end)
hooksecurefunc("ClearInspectPlayer", function() module.db.inspectCleared = true end)

local function SaveCDtoVar()
	if not AntiSpam("ExCD2SaveCD",30) or module.db.testMode then 
		return 
	end
	table_wipe(VExRT.ExCD2.Save)
	local _ctime = GetTime()
	for i, unitSpellData in pairs(_C) do
		if unitSpellData[4] + unitSpellData[3] - _ctime > 0 then
			VExRT.ExCD2.Save[ (unitSpellData[1] or "?")..(unitSpellData[2][1] or 0) ] = {unitSpellData[4],unitSpellData[3]}
		else
			VExRT.ExCD2.Save[ (unitSpellData[1] or "?")..(unitSpellData[2][1] or 0) ] = nil
		end	
	end
end

local function AfterCombatResetFunction(isArena)
	for i, unitSpellData in pairs(_C) do
		local uSpecID = module.db.specInDBase[globalGUIDs[unitSpellData[1]] or 0]
		if not unitSpellData[2][uSpecID] and unitSpellData[2][3] then
			uSpecID = 3
		end

		if (unitSpellData[3] > 0 and (module.db.spell_afterCombatReset[unitSpellData[2][1]] or (unitSpellData[2][uSpecID] and unitSpellData[2][uSpecID][2] >= (isArena and 0 or 300) or unitSpellData[3] >= (isArena and 0 or 300)))) and (not module.db.spell_afterCombatNotReset[unitSpellData[2][1]] or isArena) then
			unitSpellData[4] = 0 
			unitSpellData[6] = 0 
			unitSpellData[7] = 0 
		end
	end
	ExRT.mds.ResetAntiSpam("ExCD2SaveCD")
	SaveCDtoVar()
end

local function TestMode(h)
	if not h then
		for i, _data in pairs(_C) do
			local uSpecID = module.db.specInDBase[VExRT.ExCD2.gnGUIDs[_data[1]] or 0]
			if not _data[2][uSpecID] then
				uSpecID = 3
			end
			if _data[2][uSpecID] then
				if math.random(0,100) < 80 then
					_data[3] = _data[2][uSpecID][2]
					_data[4] = GetTime() - math.random(0,_data[2][uSpecID][2]) - math.random(0,100)/100
					_data[5] = _data[2][uSpecID][3]
				end
			end
		end
	else
		for i, _data in pairs(_C) do
			_data[4] = 0
			_data[5] = 0
		end
	end
end

local function SetTextColorLR(self,cR,cG,cB,gray,doGray)
	self.unitName:SetTextColor(cR,cG,cB,1)
	self.time:SetTextColor(cR,cG,cB,1)
	self.center:SetTextColor(cR,cG,cB,1)
	if not doGray then
		if gray then
			self.icon.t:SetDesaturated(true)
		else
			self.icon.t:SetDesaturated(nil)
		end
	end
end

local function LinesEnableOrDisable(self,D,isClassColor)
	if isClassColor then
		SetTextColorLR(self,self.classColor.r,self.classColor.g,self.classColor.b,nil)	
	elseif not D then
		SetTextColorLR(self,self.optionColorTextDefault.r,self.optionColorTextDefault.g,self.optionColorTextDefault.b,nil)
	elseif D == 1 then
		SetTextColorLR(self,self.optionColorTextActive.r,self.optionColorTextActive.g,self.optionColorTextActive.b,nil)
	elseif D == -1 then
		SetTextColorLR(self,self.optionColorTextCooldown.r,self.optionColorTextCooldown.g,self.optionColorTextCooldown.b,self.optionGray)
	elseif D == 2 then
		SetTextColorLR(self,self.optionColorTextCast.r,self.optionColorTextCast.g,self.optionColorTextCast.b,nil)
	end
end

local function TimeStr(t,hideMinute)
	t = t + 1
	if t > 3600 then
		return "1+hour"
	elseif t < 1 then
		return ""
	elseif hideMinute and t < 11 then
		return format("%.01f",t - 1)
	elseif hideMinute and t < 60 then
		return format("%d",t)
	else
		return format("%1.1d:%2.2d",t/60,t%60)
	end
end

do
	local LOffline,LDead = ExRT.L.cd2StatusOffline, ExRT.L.cd2StatusDead
	local inColsCount = {}
	local inspectQueueTimer = 0
	function module:timer(elapsed)
		if not _db.isEncounter and IsEncounterInProgress() then
			_db.isEncounter = true
			table_wipe(_db.resurrect_data)
			_db.resurrect_count = 0
			do
				local _,_,difficulty = GetInstanceInfo()
				if difficulty == 14 or difficulty == 15 or difficulty == 16 then
					_db.isResurectDisabled = true
					for i,data in pairs(_C) do
						if module.db.spell_battleRes[ data[2][1] ] then
							data[4] = 0
						end
					end
				end
			end
		elseif _db.isEncounter and not IsEncounterInProgress() then
			_db.isEncounter = nil
			table_wipe(_db.resurrect_data)
			_db.isResurectDisabled = nil
			if GetDifficultyForCooldownReset() then
				AfterCombatResetFunction()
			end
		end

		local ctime_ = GetTime()

		for i=1,_db.maxColumns do inColsCount[i] = 0 end

		for i, _data in pairs(_C) do
			local _parent = _data[2]
			local _spellID =  _parent[1]
			local _name = _data[1]
			local _specID = globalGUIDs[_name] or 0
			local uSpecID = _db.specInDBase[_specID] or 3
			
			local t_ = _data[4] + _data[3] - ctime_

			if VExRT_CDE[_spellID] and 
			(_parent[uSpecID] or (not _parent[uSpecID] and _parent[3])) and 
			(not _db.spell_isTalent[_spellID] or _db.session_gGUIDs[_name][_spellID]) and 
			(not _db.spell_isPetAbility[_spellID] or _db.session_Pets[_name] == _db.spell_isPetAbility[_spellID] or (_db.session_Pets[_name] and _db.petsAbilities[_db.session_Pets[_name]] and _db.petsAbilities[_db.session_Pets[_name]][1] == _db.spell_isPetAbility[_spellID]) or t_ > 0) and
			(not _db.spell_talentReplaceOther[_spellID] or not _db.session_gGUIDs[_name][_db.spell_talentReplaceOther[_spellID]]) and
			(not _data.specialCheck or _data.specialCheck()) then
			
				local ColNum = 1
				if _parent[uSpecID] then
					ColNum = VExRT.ExCD2.CDECol[_parent[uSpecID][1]..";"..(uSpecID-2)] or _db.def_col[_parent[uSpecID][1]..";"..(uSpecID-2)] or 1
				elseif _parent[3] then
					ColNum = VExRT.ExCD2.CDECol[_parent[3][1]..";1"] or _db.def_col[_parent[3][1]..";1"] or 1
				end
				local _Column = _mainFrame.colFrame[ColNum]
				
				if not _Column.optionShownOnCD or t_ > 0 then
					inColsCount[ColNum] = inColsCount[ColNum] + 1
					local LineNum = inColsCount[ColNum]
					local _line = _Column.lines[LineNum]
					
					if LineNum <= _Column.optionLinesMax and _line then
						local timetogo = t_
						local d_ = _data[4] + _data[5] - ctime_
	
						local lineStatus = nil
	
						local spellName = _data[10]
						local spellTexture = _data[11]
						if _line.iconNow ~= spellTexture then
							_line.iconNow = spellTexture
							_line.icon.t:SetTexture(spellTexture)
						end
	
						local name = _data[9]
						
						local offStatus = ""
	
						local isCharge = _db.spell_charge_fix[_spellID]
						if isCharge and _db.session_gGUIDs[_name][isCharge] then	
							local t2_ = _data[6] + _data[3] - ctime_
							d_ = _data[7] + _data[5] - ctime_
							if t_ > 0 and t2_ > 0 and d_ < 0 then
								t_ = t_ < t2_ and t_ or t2_
								timetogo = t_
							elseif t_ < 0 and t2_ > 0 and d_ < 0 then
								timetogo = t2_
							elseif t_ > 0 and t2_ < 0 and d_ < 0 then
								local t3_ = t_
								timetogo = t_
								t_ = t2_
								t2_ = t3_
							end
						end
						local isVirtualUser = _name == "*"
						
						local unitIsDead = UnitIsDeadOrGhost(_name) and not _db.testMode and not isVirtualUser
						local unitIsDisconnected = (not UnitIsConnected(_name)) and not _db.testMode and not isVirtualUser
						local casting_data = _db.spell_casting_data[_name][_spellID]
						if (unitIsDead or unitIsDisconnected) or (t_ > 0 and d_ <= 0) then
							lineStatus = -1
							if unitIsDisconnected then
								offStatus = LOffline
							elseif unitIsDead then
								offStatus = LDead
							end
						elseif d_ > 0 then
							timetogo = d_
							lineStatus = 1
						elseif casting_data and casting_data[3] >= ctime_ then
							name = "> " .. name
							lineStatus = 2
						else
							lineStatus = nil
						end
						
						_line.isDead = lineStatus == -1
						
						if _line.optionAlphaCooldown < 1 then
							if lineStatus == -1 then
								_line:SetAlpha(_line.optionAlphaCooldown)
							else
								_line:SetAlpha(1)
							end
						end

						_line.classColor = RAID_CLASS_COLORS[ _parent[2] ] or _db.notAClass

						LinesEnableOrDisable(_line,lineStatus,_Column.optionClassColorText)
						
						if _data.specialAddText then
							name = name .. (_data.specialAddText() or "")
						end
												
						local textLeft = _Column.textTemplateLeft
						local textRight = _Column.textTemplateRight
						local textCenter = _Column.textTemplateCenter
						
						local longtime = TimeStr(timetogo)
						local shorttime = TimeStr(timetogo,true)
						local name_time = ((t_ > 0 or d_ > 0) and longtime) or name
						local name_stime = ((t_ > 0 or d_ > 0) and shorttime) or name
						textLeft = string_gsub(textLeft,"%%time%%",longtime)
						textLeft = string_gsub(textLeft,"%%stime%%",shorttime)
						textLeft = string_gsub(textLeft,"%%name%%",name)
						textLeft = string_gsub(textLeft,"%%name_time%%",name_time)
						textLeft = string_gsub(textLeft,"%%name_stime%%",name_stime)
						textLeft = string_gsub(textLeft,"%%spell%%",spellName)
						textLeft = string_gsub(textLeft,"%%status%%",offStatus)
						textRight = string_gsub(textRight,"%%time%%",longtime)
						textRight = string_gsub(textRight,"%%stime%%",shorttime)
						textRight = string_gsub(textRight,"%%name%%",name)
						textRight = string_gsub(textRight,"%%name_time%%",name_time)
						textRight = string_gsub(textRight,"%%name_stime%%",name_stime)
						textRight = string_gsub(textRight,"%%spell%%",spellName)
						textRight = string_gsub(textRight,"%%status%%",offStatus)
						textCenter = string_gsub(textCenter,"%%time%%",longtime)
						textCenter = string_gsub(textCenter,"%%stime%%",shorttime)
						textCenter = string_gsub(textCenter,"%%name%%",name)
						textCenter = string_gsub(textCenter,"%%name_time%%",name_time)
						textCenter = string_gsub(textCenter,"%%name_stime%%",name_stime)
						textCenter = string_gsub(textCenter,"%%spell%%",spellName)
						textCenter = string_gsub(textCenter,"%%status%%",offStatus)

						_line.unitName:SetText(string_trim(textLeft))
						_line.time:SetText(string_trim(textRight))
						_line.center:SetText(string_trim(textCenter))
						
						if _line.optionIconName then
							_line.iconText:SetText(name)
						end
						
						if _line.optionCooldown then
							if d_ > 0 then
								_line.cooldown:SetReverse(true)
								_line.cooldown:SetCooldown(_data[4],_data[5])
								_line.cooldown:Show()
							elseif t_ > 0 then
								_line.cooldown:SetReverse(false)
								_line.cooldown:SetCooldown(_data[4],_data[3])
								_line.cooldown:Show()
							elseif _line.isDead then
								_line.cooldown:SetReverse(false)
								_line.cooldown:SetCooldown(ctime_+1,1)
								_line.cooldown:Show()
							else
								_line.cooldown:Hide()
							end
						end
						
						if not _Column.optionAnimation then
							if _line.optionClassColorBackground then
								_line:SetBackdropColor(_line.classColor.r,_line.classColor.g,_line.classColor.b,self.optionAlphaBackground)
							end
							if _line.optionTimeLineAnimation == 2 then
								if lineStatus == -1 then
									_line.t:Hide()
								else
									_line.t:Show()
								end
								if _line.optionClassColorTimeLine then
									_line:SetBackdropColor(_line.classColor.r,_line.classColor.g,_line.classColor.b,self.optionAlphaTimeLine)
								end
							end
						end

						_line.link = _data
						_line:Show()
					end
				end
			end
	
		end
		for i=1,_db.maxColumns do
			local y = _mainFrame.colFrame[i].optionLinesMax
			inColsCount[i] = min(inColsCount[i],y)
			for j=(inColsCount[i]+1),_db.maxLinesInCol do
				local _line = _mainFrame.colFrame[i].lines[j]
				_line:Hide()
				_line.link = nil
			end
		end
	
		SaveCDtoVar()
		
		_db.inspectTimer = _db.inspectTimer + elapsed
		if _db.inspectTimer > 3.5 then
			inspectQueueTimer = inspectQueueTimer + _db.inspectTimer
			_db.inspectTimer = 0
			if inspectQueueTimer > 60 then
				inspectQueueTimer = 0
				InspectQueue()
			end
			InspectNext()
		end
	end
end

local function AnimationAndSparkLine(self,cooldown,active,charge,cast,notAvailable)
	if self.optionClassColorBackground then
		self.optionColorBackgroundDefault = self.classColor
		self.optionColorBackgroundActive = self.classColor
		self.optionColorBackgroundCooldown = self.classColor
		self.optionColorBackgroundCast = self.classColor
	end
	if self.optionClassColorTimeLine then
		self.optionColorTimeLineDefault = self.classColor
		self.optionColorTimeLineActive = self.classColor
		self.optionColorTimeLineCooldown = self.classColor
		self.optionColorTimeLineCast = self.classColor
	end
	
	if active then
		self.t:SetVertexColor(self.optionColorTimeLineActive.r,self.optionColorTimeLineActive.g,self.optionColorTimeLineActive.b,self.optionAlphaTimeLine)
		self:SetBackdropColor(self.optionColorBackgroundActive.r,self.optionColorBackgroundActive.g,self.optionColorBackgroundActive.b,self.optionAlphaBackground)
		
		self.t:SetWidth(ReverseInt(active,1,self.optionStyleAnimation==2)*self.t.ln+1)
		self.t:Show()
		self.spark:Show()
		self.t_special:Hide()
	elseif cooldown then
		self.t:SetVertexColor(self.optionColorTimeLineCooldown.r,self.optionColorTimeLineCooldown.g,self.optionColorTimeLineCooldown.b,self.optionAlphaTimeLine)
		self:SetBackdropColor(self.optionColorBackgroundCooldown.r,self.optionColorBackgroundCooldown.g,self.optionColorBackgroundCooldown.b,self.optionAlphaBackground)
		
		self.t:SetWidth(ReverseInt(cooldown,1,not (self.optionStyleAnimation==2))*self.t.ln+1)
		self.t:Show()
		self.spark:Show()
		self.t_special:Hide()
	elseif cast then
		self.t:SetVertexColor(self.optionColorTimeLineCast.r,self.optionColorTimeLineCast.g,self.optionColorTimeLineCast.b,self.optionAlphaTimeLine)
		self:SetBackdropColor(self.optionColorBackgroundCast.r,self.optionColorBackgroundCast.g,self.optionColorBackgroundCast.b,self.optionAlphaBackground)
		
		self.t:SetWidth(ReverseInt(cast,1,self.optionStyleAnimation==2)*self.t.ln+1)
		self.t:Show()
		self.spark:Show()
		self.t_special:Hide()
	elseif charge then
		self.t:SetVertexColor(0,0,0,0)
		--self:SetBackdropColor(self.optionColorBackgroundDefault.r,self.optionColorBackgroundDefault.g,self.optionColorBackgroundDefault.b,self.optionTimeLineAnimation == 2 and self.optionAlphaTimeLine or self.optionAlphaBackground)
		self:SetBackdropColor(self.optionColorBackgroundDefault.r,self.optionColorBackgroundDefault.g,self.optionColorBackgroundDefault.b,self.optionAlphaBackground)
		
		self.t:SetWidth(ReverseInt(charge,1,not (self.optionStyleAnimation==2))*self.t.ln+1)
		self.t:Show()
		self.spark:Show()
		if self.optionTimeLineAnimation == 2 then
			self.t_special:SetVertexColor(self.optionColorTimeLineDefault.r,self.optionColorTimeLineDefault.g,self.optionColorTimeLineDefault.b,self.optionAlphaTimeLine)
			self.t_special:Show()
		else
			self.t_special:Hide()
		end
	elseif notAvailable then
		self.t:SetVertexColor(0,0,0,0)
		self:SetBackdropColor(self.optionColorBackgroundCooldown.r,self.optionColorBackgroundCooldown.g,self.optionColorBackgroundCooldown.b,self.optionAlphaBackground)
		
		self.t:Hide()
		self.spark:Hide()
		self.t_special:Hide()
	else
		if self.optionTimeLineAnimation == 1 then
			self.t:SetVertexColor(0,0,0,0)
		elseif self.optionTimeLineAnimation == 2 then
			self.t:SetVertexColor(self.optionColorTimeLineDefault.r,self.optionColorTimeLineDefault.g,self.optionColorTimeLineDefault.b,self.optionAlphaTimeLine)
		end
		self:SetBackdropColor(self.optionColorBackgroundDefault.r,self.optionColorBackgroundDefault.g,self.optionColorBackgroundDefault.b,self.optionAlphaBackground)
		
		self.t:SetWidth(self.t.ln)
		self.t:Show()
		self.spark:Hide()
		self.t_special:Hide()
	end
end

module.frame.animation.anim = module.frame.animation:CreateAnimationGroup()
module.frame.animation.timer = module.frame.animation.anim:CreateAnimation()
module.frame.animation.timer.tmr = 0
do
	local animationTimer = 0
	module.frame.animation.timer:SetScript("OnUpdate", function(self,elapsed) 
		animationTimer = animationTimer + elapsed
		if animationTimer < 0.01 then
			return
		end
		animationTimer = 0
		local ctime_ = GetTime()
		for i=1,_db.maxColumns do			
			if _mainFrame.colFrame[i].optionAnimation then
				for j=1,_db.maxLinesInCol do
					local index = _mainFrame.colFrame[i].lines[j]
					local link = index.link
					if link then
						local t_ = 1.01
						local c_ = nil
						local a_ = 1.01
						local cast_ = 1.01
						if link[3]~=0 then 
							t_ = (ctime_-link[4])/link[3]
						end
						local _mainSpellID = link[2][1]
						
						if link[5]~=0 then 
							a_ = (ctime_-link[4])/link[5]
						end					
	
						local isCharge = _db.spell_charge_fix[_mainSpellID]
						if isCharge and _db.session_gGUIDs[link[1]][isCharge] then 
							local t2_ = (ctime_-link[6])/max(link[3],1) 
							if t_ <= 1 and t2_ <= 1 then
								t_ = t_ > t2_ and t_ or t2_
							elseif t_ <= 1 and t2_ > 1 then
								c_ = t_
								t_ = 1.01
							elseif t2_ <= 1 and t_ > 1 then
								c_ = t2_
							end
							
							if link[5]~=0 then
								a_ = (ctime_-link[7])/link[5]
							end
						end
						
						local casting_data = _db.spell_casting_data[ link[1] ][_mainSpellID]
						if casting_data and casting_data[3] >= ctime_ and t_ > 1 then
							if casting_data[2] ~= 0 then
								cast_ = (ctime_-casting_data[1])/casting_data[2]
							end
						end
						AnimationAndSparkLine(index,t_ <= 1 and t_,a_ <= 1 and a_,c_,cast_ <= 1 and cast_,index.isDead)
					end
				end
			end 
		end
	end)
end
module.frame.animation.timer:SetDuration(1)
module.frame.animation.anim:SetLooping("REPEAT")

local function GetNumGroupMembersFix() 
	local n = GetNumGroupMembers() or 0
	if module.db.testMode then
		return 25
	elseif n == 0 and VExRT.ExCD2.NoRaid then 
		return 1
	else
		return n
	end
end

local function GetRaidRosterInfoFix(j) 
	local h1,h2,h3,h4,h5,h6 = GetRaidRosterInfo(j)
	if j == 1 and not h1 and VExRT.ExCD2.NoRaid then
		h1 = UnitName("player")
		h5,h6 = UnitClass("player")
		return h1,1,h6
	elseif not module.db.testMode then
		return h1,h3,h6
	elseif module.db.testMode then
		if h1 then
			return h1,h3,h6
		end
		local i = math.random(1,11)

		local namesList = {}
		for unitName, specID in pairs(VExRT.ExCD2.gnGUIDs) do
			namesList[#namesList+1] = {unitName}
			for className, classSpecs in pairs(module.db.specByClass) do
				for spec_i=1,#classSpecs do
					if classSpecs[spec_i] == specID then
						namesList[#namesList][2] = className
					end
				end
			end
		end
		if #namesList == 0 or #namesList < 25 then
			h1 = ExRT.L.classLocalizate[module.db.classNames[i]]..tostring(j)
			h6 = module.db.classNames[i]
		else
			i = math.random(1,#namesList)
			h1 = namesList[i][1]
			h6 = namesList[i][2]
		end

		return h1,1,h6
	end
end

local function RaidResurrectSpecialCheck()
	local _,_,difficulty = GetInstanceInfo()
	if difficulty == 14 or difficulty == 15 or difficulty == 16 then
		return true
	end
end
local function RaidResurrectSpecialText()
	local timeNow = GetEncounterTime()
	if timeNow then
		local _,_,difficultyID,_,_,_,_,_,instanceGroupSize = GetInstanceInfo()
		instanceGroupSize = (difficultyID == 16 and 20) or instanceGroupSize or 20
		local chargeTime = 5400 / instanceGroupSize
		local count = floor(timeNow / chargeTime) + 1 - _db.resurrect_count
		if count > 1 then
			return " ("..count..")"
		end
	end
end

local function SortRoster(a,b) 
	return a[8] < b[8]
end

local function UpdateRoster()
	local n = GetNumGroupMembersFix()
	if n > 0 then
		for i, val in pairs(_C) do val[8] = nil end
		local gMax = GetRaidDiffMaxGroup()
		local isInRaid = IsInRaid()
		for j=1,n do
			local name,subgroup,class = GetRaidRosterInfoFix(j)
			if name and subgroup <= gMax then
				for i,spellData in ipairs(module.db.spellDB) do
					if spellData[2] == class or spellData[2] == "ALL" then
						local alreadyInCds = nil
						local prior = format("%.02d%.06d%s",VExRT.ExCD2.Priority[spellData[1]] or 15,spellData[1] or 0,name or "?")
						local sName = format("%s%d",name or "?",spellData[1] or 0)
						local lastUse,nowCd = 0,0
						if VExRT.ExCD2.Save[sName] and NumberInRange(VExRT.ExCD2.Save[sName][1] + VExRT.ExCD2.Save[sName][2] - GetTime(),0,2000,false,true) then
							lastUse,nowCd = VExRT.ExCD2.Save[sName][1],VExRT.ExCD2.Save[sName][2]
						end
						
						local spellName,_,spellTexture = GetSpellInfo(spellData[1])
						spellTexture = spellTexture or "Interface\\Icons\\INV_MISC_QUESTIONMARK"
						local shownName = DelUnitNameServer(name)
						
						for l=3,7 do
							if spellData[l] then
								local h = module.db.cdsNav[name][spellData[l][1]]
								if h then
									_C[h][2] = spellData
									if not (lastUse == 0 and nowCd == 0 and _C[h][3] and _C[h][3] ~= 0 and _C[h][4] and _C[h][4] ~= 0) then
										_C[h][3] = nowCd
										_C[h][4] = lastUse
									end
									_C[h][8] = prior
									alreadyInCds = true
									
									_C[h][10] = spellName
									_C[h][11] = spellTexture
								end
							end
						end

						if not alreadyInCds then
							_C [#_C + 1] = {name,spellData,nowCd,lastUse,0,0,0,prior,shownName,spellName,spellTexture}
							--[[ 
								[1] name;
								[2] main link;
								[3] spell cd;
								[4] spell last use;
								[5] время действия;
								[6] кд чарджа;
								[7] юз при чардже;
								[8] сторка для сортировки;
								[9] отображаемое на полосе имя;
								[10] отображаемое имя заклинания;
								[11] отображаемая иконка заклинания;
							--]]
						end
					end
				end
				module.db.session_gGUIDs[name] = 1
				if isInRaid then
					module.main:UNIT_PET("raid"..j)
				end
			end
		end
		
		--WOD Raid resurrect
		do
			local findResSpell = ExRT.mds.table_find(module.db.spellDB,161642,1)
			if findResSpell then
				local spellData = module.db.spellDB[findResSpell]
				local h = module.db.cdsNav["*"][spellData[3][1]]
				local prior = format("%.02d%.06d%s",VExRT.ExCD2.Priority[spellData[1]] or 15,spellData[1] or 0,"*")
				if not h then
					local spellName,_,spellTexture = GetSpellInfo(spellData[1])
					_C [#_C + 1] = {"*",spellData,0,0,0,0,0,prior,ExRT.L.cd2Resurrect,ExRT.L.cd2Resurrect,spellTexture,specialCheck = RaidResurrectSpecialCheck,specialAddText = RaidResurrectSpecialText}
				else
					_C[h][8] = prior
				end
			end
		end

		for i, val in pairs(_C) do
			if not val[8] then
				_C[i] = nil
			end
		end
		local j = 1
		for i, val in pairs(_C) do
			_C[j] = _C[i]
			if i > j then
				_C[i] = nil
			end
			j = j + 1
		end

		table_sort(_C,SortRoster)
		cdsNav_wipe()
		for i=1,#_C do
			for l=3,7 do 
				if _C[i][2][l] then
					cdsNav_set(_C[i][1],_C[i][2][l][1],i)
				end 
			end
		end
	else
		table_wipe(_C)
		cdsNav_wipe()
	end
	if module.db.testMode then TestMode() end
end

local CLEUstartCD = nil
do
	local function DispellSchedule(sLink)
		if not module.db.spell_dispellsFix[ sLink[1] ] then
			sLink[3] = 0
		end
		module.db.spell_dispellsFix[ sLink[1] ] = nil
	end
	function CLEUstartCD(i)
		local ctime_ = GetTime()
		local sLink = _C[i]
		local uSpecID = module.db.specInDBase[globalGUIDs[sLink[1]] or 0]
		if not sLink[2][uSpecID] and not sLink[2][3] then
			return
		elseif not sLink[2][uSpecID] then
			uSpecID = 3
		end
		local spellID = sLink[2][uSpecID][1]
		sLink[3] = sLink[2][uSpecID][2]
		sLink[5] = sLink[2][uSpecID][3]
		
		--Talents / Glyphs
		if module.db.spell_durationByTalent_fix[spellID] then
			for j=1,#module.db.spell_durationByTalent_fix[spellID],2 do
				if module.db.session_gGUIDs[sLink[1]][module.db.spell_durationByTalent_fix[spellID][j]] then
					if tonumber(module.db.spell_durationByTalent_fix[spellID][j+1]) then
						sLink[5] = sLink[5] + module.db.spell_durationByTalent_fix[spellID][j+1]
					else
						local timeFix = tonumber( string_sub( module.db.spell_durationByTalent_fix[spellID][j+1] , 2 ) )
						sLink[5] = sLink[5] * timeFix
					end
				end
			end
		end
		if module.db.spell_cdByTalent_fix[spellID] then
			for j=1,#module.db.spell_cdByTalent_fix[spellID],2 do
				if module.db.session_gGUIDs[sLink[1]][module.db.spell_cdByTalent_fix[spellID][j]] then
					if tonumber(module.db.spell_cdByTalent_fix[spellID][j+1]) then
						sLink[3] = sLink[3] + module.db.spell_cdByTalent_fix[spellID][j+1]
					else
						local timeFix = tonumber( string_sub( module.db.spell_cdByTalent_fix[spellID][j+1] , 2 ) )
						sLink[3] = sLink[3] * timeFix
					end
				end
			end
		end
		--Charges
		local isCharge = module.db.spell_charge_fix[sLink[2][1]]
		if isCharge and (sLink[4]+sLink[3]) >= ctime_ then
			sLink[6] = sLink[4] + sLink[3]
			sLink[7] = ctime_
			module.db.session_gGUIDs[sLink[1]] = isCharge
		elseif isCharge and module.db.session_gGUIDs[sLink[1]][isCharge] then
			if (sLink[6]+sLink[3]) >= ctime_ then
				sLink[4] = sLink[6] + sLink[3]
			else
				sLink[4] = ctime_
			end
			sLink[7] = ctime_
		else
			sLink[4] = ctime_
		end
		--Haste/Readiness
		if module.db.spell_speed_list[spellID] then
			sLink[5] = sLink[5] / (1+ (UnitSpellHaste(sLink[1]) or 0) /100)
		end
		if module.db.spell_reduceCdByHaste[spellID] then
			sLink[3] = sLink[3] / (1 + (UnitSpellHaste(sLink[1]) or 0) /100) 
		end
		if module.db.spell_readiness[globalGUIDs[sLink[1]] or 0] and module.db.spell_readiness[globalGUIDs[sLink[1]] or 0][spellID] then
			sLink[3] = sLink[3] / (1 + ( (module.db.inspectDB[sLink[1]] and module.db.inspectDB[sLink[1]]['radiness'] or 0) or 0) )
		end
		--Dispels
		if module.db.spell_dispellsList[spellID] then
			ScheduleTimer(DispellSchedule, 0.5, sLink)
		end
		--WOD Battle Res
		do
			if _db.spell_battleRes[spellID] then
				local _,_,difficultyID,_,_,_,_,_,instanceGroupSize = GetInstanceInfo()
				if difficultyID == 14 or difficultyID == 15 or difficultyID == 16 then
					instanceGroupSize = (difficultyID == 16 and 20) or instanceGroupSize or 20
					local chargeTime = 5400 / instanceGroupSize
					local timeNow = GetEncounterTime()
					if timeNow then
						local timeDiff = timeNow - (chargeTime * _db.resurrect_count)
						if timeDiff < chargeTime then
							sLink[4] = ctime_ - timeDiff
							sLink[3] = chargeTime
						end
					end
				end
			end
		end
		
		module.db.historyUsage[#module.db.historyUsage + 1] = {time(),sLink[2][uSpecID][1],sLink[1],GetEncounterTime()}
	end
end

function module:Enable()
	VExRT.ExCD2.enabled = true
	if not VExRT.ExCD2.SplitOpt then 
		module.frame:Show()
		module:ReloadAllSplits()
	else
		module:ReloadAllSplits()
	end
	module.frame.animation.anim:Play() 

	module:RegisterSlash()
	module:RegisterTimer()
	module:RegisterEvents('PLAYER_SPECIALIZATION_CHANGED','SCENARIO_UPDATE','GROUP_ROSTER_UPDATE','INSPECT_READY','UNIT_INVENTORY_CHANGED','PLAYER_EQUIPMENT_CHANGED','COMBAT_LOG_EVENT_UNFILTERED','UNIT_PET','UNIT_SPELLCAST_SUCCEEDED','UNIT_FLAGS','PLAYER_LOGOUT','ZONE_CHANGED_NEW_AREA')
end

function module:Disable()
	VExRT.ExCD2.enabled = nil
	if not VExRT.ExCD2.SplitOpt then 
		module.frame:Hide()
	else
		for i=1,module.db.maxColumns do 
			module.frame.colFrame[i]:Hide()
		end 
	end
	module.frame.animation.anim:Stop()
	
	module:UnregisterSlash()
	module:UnregisterTimer()
	module:UnregisterEvents('PLAYER_SPECIALIZATION_CHANGED','SCENARIO_UPDATE','GROUP_ROSTER_UPDATE','INSPECT_READY','UNIT_INVENTORY_CHANGED','PLAYER_EQUIPMENT_CHANGED','COMBAT_LOG_EVENT_UNFILTERED','UNIT_PET','UNIT_SPELLCAST_SUCCEEDED','UNIT_FLAGS','PLAYER_LOGOUT','ZONE_CHANGED_NEW_AREA')
end


function module.main:ADDON_LOADED()
	VExRT = _G.VExRT
	VExRT.ExCD2 = VExRT.ExCD2 or {NoRaid = true}
	
	if VExRT.Addon.Version < 2126 then
		if VExRT.ExCD2.colSet then
			for i=1,module.db.maxColumns+1 do
				if VExRT.ExCD2.colSet[i] and not VExRT.ExCD2.colSet[i].fontOutline then
					VExRT.ExCD2.colSet[i].fontShadow = true
				end
			end
		end
	end
	if VExRT.Addon.Version < 2302 then
		if VExRT.ExCD2.colSet then
			for i=1,module.db.maxColumns+1 do
				if VExRT.ExCD2.colSet[i] then
					VExRT.ExCD2.colSet[i].textGeneral = true
				end
			end
		end
	end
	
	if VExRT.ExCD2.Left and VExRT.ExCD2.Top then
		module.frame:ClearAllPoints()
		module.frame:SetPoint("TOPLEFT",UIParent,"BOTTOMLEFT",VExRT.ExCD2.Left,VExRT.ExCD2.Top)
	end
	
	VExRT.ExCD2.CDE = VExRT.ExCD2.CDE or {}
	VExRT.ExCD2.CDECol = VExRT.ExCD2.CDECol or {}
	if UnitFactionGroup("player") == "Alliance" then	--> BL Faction Fix
		for i,spellData in ipairs(module.db.spellDB) do
			if spellData[1] == 2825 then
				spellData[1] = 32182
				spellData[3][1] = 32182
				break
			end
		end
	end
	VExRT_CDE = VExRT.ExCD2.CDE
	
	if not VExRT.ExCD2.colSet then
		VExRT.ExCD2.colSet = {}
		for i=1,module.db.maxColumns+1 do
			VExRT.ExCD2.colSet[i] = {}
			for optName,optVal in pairs(module.db.colsInit) do
				VExRT.ExCD2.colSet[i][optName] = optVal
			end
			if i <= 3 then 
				VExRT.ExCD2.colSet[i].enabled = true
			end
		end
	end
	for i=1,module.db.maxColumns+1 do
		VExRT.ExCD2.colSet[i] = VExRT.ExCD2.colSet[i] or {}
	end
	
	VExRT.ExCD2.default_userCD = VExRT.ExCD2.default_userCD or {}
	VExRT.ExCD2.default_userDuration = VExRT.ExCD2.default_userDuration or {}
	do
		for spellID,spellData in pairs(VExRT.ExCD2.default_userCD) do
			for i=1,#module.db.spellDB do
				if module.db.spellDB[i][1] == spellID then
					for j=1,5 do
						if spellData[j] and module.db.spellDB[i][2+j] then
							module.db.spellDB[i][2+j][2] = spellData[j]
						end
					end
				end
			end
		end
	
		for spellID,spellData in pairs(VExRT.ExCD2.default_userDuration) do
			for i=1,#module.db.spellDB do
				if module.db.spellDB[i][1] == spellID then
					for j=1,5 do
						if spellData[j] and module.db.spellDB[i][2+j] then
							module.db.spellDB[i][2+j][3] = spellData[j]
						end
					end
				end
			end
		end
	end
	
	VExRT.ExCD2.userDB = VExRT.ExCD2.userDB or {}
	for i=1,#VExRT.ExCD2.userDB do
		module.db.spellDB[i+module.db.dbCountDef] = VExRT.ExCD2.userDB[i]
	end

	VExRT.ExCD2.Priority = VExRT.ExCD2.Priority or {}

	VExRT.ExCD2.gnGUIDs = VExRT.ExCD2.gnGUIDs or {}
	if VExRT.ExCD2.gnGUIDs and ExRT.mds.table_len(VExRT.ExCD2.gnGUIDs) > 500 then
		table_wipe(VExRT.ExCD2.gnGUIDs)
	end
	globalGUIDs = VExRT.ExCD2.gnGUIDs

	if VExRT.ExCD2.lock then
		module.frame.texture:SetTexture(0, 0, 0, 0)
		module.frame:EnableMouse(false)
		ExRT.lib.AddShadowComment(module.frame,1)
	else
		module.frame.texture:SetTexture(0, 0, 0, 0.3)
		module.frame:EnableMouse(true)
		ExRT.lib.AddShadowComment(module.frame,nil,ExRT.L.cd2)
	end

	module:SplitExCD2Window() 
	module:ReloadAllSplits()
	
	VExRT.ExCD2.Save = VExRT.ExCD2.Save or {}
	AntiSpam("ExCD2SaveCD",15)

	if not VExRT.ExCD2.enabled then
		if not VExRT.ExCD2.SplitOpt then 
			module.frame:Hide() 
		else
			for i=1,module.db.maxColumns do 
				module.frame.colFrame[i]:Hide() 
			end 
		end
	else
		module:Enable()
		ScheduleTimer(UpdateRoster,10)
		module:RegisterEvents('PLAYER_ENTERING_WORLD')
	end
	
	module.db.playerName = UnitName("player")
	if module.db.playerName then
		module.db.inspectQuery[module.db.playerName] = GetTime()
	end	
end

function module.main:PLAYER_ENTERING_WORLD()
	UpdateRoster()
	
	module:UnregisterEvents('PLAYER_ENTERING_WORLD')
end

function module.main:PLAYER_LOGOUT()
	ExRT.mds.ResetAntiSpam("ExCD2SaveCD")
	SaveCDtoVar()
end

function module.main:PLAYER_SPECIALIZATION_CHANGED(arg)
	if arg and UnitName(arg) then
		local name = UnitCombatlogname(arg)
		VExRT.ExCD2.gnGUIDs[name] = nil
		module.db.inspectDB[name] = nil
		local _,class = UnitClass(name)
		if module.db.spell_talentsList[class] then
			for i=1,18 do
				if type(module.db.spell_talentsList[class][i]) == "table" then
					for j=1,#module.db.spell_talentsList[class][i] do
						module.db.session_gGUIDs[name] = -(module.db.spell_talentsList[class][i][j] or 0)
					end
				else
					module.db.session_gGUIDs[name] = -(module.db.spell_talentsList[class][i] or 0)
				end
			end
		end
		if module.db.spell_glyphsList[class] then
			for spellId,_ in pairs(module.db.spell_glyphsList[class]) do
				module.db.session_gGUIDs[name] = -spellId
			end
		end
		module.db.inspectQuery[name] = GetTime()
	end
end
		
function module.main:SCENARIO_UPDATE()
	AfterCombatResetFunction()
end

do
	local scheduledUpdateRoster = nil
	local function funcScheduledUpdate()
		scheduledUpdateRoster = nil
		UpdateRoster()
		InspectQueue()
	end
	function module.main:GROUP_ROSTER_UPDATE()
		if not scheduledUpdateRoster then
			scheduledUpdateRoster = ScheduleTimer(funcScheduledUpdate,2)
		end
	end
end

do
	local lastInspectTime = {}
	function module.main:INSPECT_READY(arg)
		if not module.db.inspectCleared then
			local time_ = GetTime()
			if arg and lastInspectTime[arg] and (time_ - lastInspectTime[arg]) < 0.2 then
				return
			end
			if arg then
				lastInspectTime[arg] = time_
			end
			local _,_,_,race,_,name,realm = GetPlayerInfoByGUID(arg)
			if name then
				if realm and realm ~="" then name = name.."-"..realm end
				local inspectedName = name
				if UnitName("target") == DelUnitNameServer(name) then 
					inspectedName = "target"
				elseif not UnitName(name) then
					return
				end
				module.db.inspectTimer = 0
				local _,class,classID = UnitClass(inspectedName)
				
				for i,slotID in ipairs(module.db.itemsSlotTable) do
					local link = GetInventoryItemLink(inspectedName, slotID)
				end
				ScheduleTimer(InspectItems, 1.5, name, inspectedName, module.db.inspectID)
	
				if module.db.inspectDB[name] and module.db.inspectItemsOnly[name] then
					module.db.inspectItemsOnly[name] = nil
					return
				end
				module.db.inspectItemsOnly[name] = nil
				
				if module.db.inspectDB[name] then
					table_wipe(module.db.inspectDB[name])
				else
					module.db.inspectDB[name] = {}
				end
				local data = module.db.inspectDB[name]
				
				data.spec = round( GetInspectSpecialization(inspectedName) )
				if data.spec < 1000 then
					VExRT.ExCD2.gnGUIDs[name] = data.spec
				end
				data.class = class
				data.level = UnitLevel(inspectedName)
				data.race = race
				data.time = time()
				for i=1,6 do
					data[i] = 0
				end
				data.talentsIDs = {}
				for i=0,20 do
					local t_id,_,_,t = GetTalentInfo((i-i%3)/3+1,i%3+1,nil,true,inspectedName)
					if t then
						data[(i-i%3)/3+1] = i%3+1
						data.talentsIDs[(i-i%3)/3+1] = t_id
					end
					local talentID = module.db.spell_talentsList[class] and module.db.spell_talentsList[class][i+1]
					if talentID then
						if type(talentID) == "table" then
							for j,sID in ipairs(talentID) do
								if t then
									module.db.session_gGUIDs[name] = sID
								else
									module.db.session_gGUIDs[name] = -sID
								end
							end
						else
							if t then
								module.db.session_gGUIDs[name] = talentID
							else
								module.db.session_gGUIDs[name] = -talentID
							end
						end
					end
				end
				for i=1,6 do
					local _,_,_,t = GetGlyphSocketInfo(i,nil,1,inspectedName)
					data[i+7] = t
					if t and module.db.spell_glyphsList[class][t] then
						module.db.session_gGUIDs[name] = t
					end
				end
				InspectItems(name, inspectedName, module.db.inspectID)
			end
		end
	end
end

function module.main:UNIT_INVENTORY_CHANGED(arg)
	if RaidInCombat() then
		return
	end
	local name = UnitCombatlogname(arg or "?")
	if arg and name and name ~= module.db.playerName then
		module.db.inspectItemsOnly[name] = true
		module.db.inspectQuery[name] = GetTime()
	end
end

function module.main:PLAYER_EQUIPMENT_CHANGED()
	if RaidInCombat() then
		return
	end
	local name = UnitCombatlogname("player")
	module.db.inspectItemsOnly[name] = true
	module.db.inspectQuery[name] = GetTime()
end

do
	local prevDiff = nil
	local scheduledUpdateRoster = nil
	local function funcScheduledUpdate()
		scheduledUpdateRoster = nil
		UpdateRoster()
		InspectQueue()
	end
	function module.main:ZONE_CHANGED_NEW_AREA()
		local _,_,difficulty = GetInstanceInfo()
		if difficulty == 8 or prevDiff == 8 then
			local n = GetNumGroupMembers() or 0
			if IsInRaid() then
				n = min(n,5)
				for j=1,n do
					local name,_,subgroup = GetRaidRosterInfo(j)
					if name and subgroup == 1 then
						module.db.inspectItemsOnly[name] = true
						module.db.inspectQuery[name] = GetTime()
					end
				end
			else
				for j=1,5 do
					local uid = "party"..j
					if j==5 then
						uid = "player"
					end
					local name = ExRT.mds.UnitCombatlogname(uid)
					if name then
						module.db.inspectItemsOnly[name] = true
						module.db.inspectQuery[name] = GetTime()
					end
				end
			end
		end
		prevDiff = difficulty
		
		if select(2, IsInInstance()) == "arena" then
			AfterCombatResetFunction(true)
		end
		if not scheduledUpdateRoster then
			scheduledUpdateRoster = ScheduleTimer(funcScheduledUpdate,10)
		end
	end
end

function module.main:UNIT_PET(arg)
	local name = UnitCombatlogname(arg)
	if name then
		_db.session_Pets[name] = UnitCreatureFamily(arg.."pet")
		if _db.session_Pets[name] then
			_db.session_PetOwner[UnitGUID(arg.."pet")] = name
		end
	end
end

do
	local _spell_notInCLEU_fix = module.db.spell_notInCLEU_fix
	--Be care about spell with charges here. USS event can be fire twice in raid for raidX and partyX unitID's
	function module.main:UNIT_SPELLCAST_SUCCEEDED(unitID,_,_,_,spellID)
		if _spell_notInCLEU_fix[spellID] then
			local name = UnitCombatlogname(unitID)
			if name then
				module.main:COMBAT_LOG_EVENT_UNFILTERED(nil,"SPELL_CAST_SUCCESS",nil,nil,name,nil,nil,nil,nil,nil,nil,spellID)
			end
		end
	end
end

function module.main:UNIT_FLAGS(unitID)
	local name = UnitCombatlogname(unitID)	
	if _db.isResurectDisabled and _db.resurrect_data[name] and _db.isEncounter and not UnitIsDead(unitID) then
		_db.resurrect_data[name] = nil
		for i=1,#_C do
			if _db.spell_battleRes[ _C[i][2][1] ] then
				CLEUstartCD(i)
			end
		end
		_db.resurrect_count = _db.resurrect_count + 1
	end
end

function module.main:UNIT_SPELLCAST_STOP(unitID,_,_,_,spellID)
	local name = UnitCombatlogname(unitID)
	if name and _db.spell_casting_list[spellID] and _db.spell_casting_data[name][spellID] then
		_db.spell_casting_data[name][spellID] = nil
	end
end

do
	local eventsView
	local isSoulStone = {}
	local function castTimerSchedule()
		_db.spell_casting_frame = nil
		module:UnregisterEvents('UNIT_SPELLCAST_STOP')
	end
	local function removeSoulStoneSchedule(name)
		isSoulStone[name] = nil
	end
	function module.main:COMBAT_LOG_EVENT_UNFILTERED(_,event,_,sourceGUID,sourceName,sourceFlags,_,destGUID,destName,destFlags,_,spellId)
		local func = eventsView[event]
		if func then
			func(self,sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellId)
		end
	end
	function module.main:SPELL_AURA_REMOVED(sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellId)
		if sourceName then
			local reduceCdByAuraFade = _db.spell_reduceCdByAuraFade[spellId]
			if reduceCdByAuraFade then
				local reduceCdByAuraFadeSpell = reduceCdByAuraFade[1]
				if type(reduceCdByAuraFadeSpell) ~= "table" then
					local j = _db.cdsNav[sourceName][reduceCdByAuraFadeSpell]
					if j and (GetTime() - _C[j][4] - _C[j][5]) > -0.5 then
						_C[j][3] = _C[j][3] + reduceCdByAuraFade[2]
					end
				else
					if _db.session_gGUIDs[sourceName][ reduceCdByAuraFadeSpell[2] ] then
						local j = _db.cdsNav[sourceName][ reduceCdByAuraFadeSpell[1] ]
						if j and (GetTime() - _C[j][4] - _C[j][5]) > -0.5 then
							_C[j][3] = _C[j][3] + reduceCdByAuraFade[2]
						end
					end
				end
			end
		
			local sID = _db.spell_aura_list[spellId]
			if sID then
				local sid = _db.cdsNav[sourceName][sID]
				if sid then
					_C[sid][5] = 0
				end
			end
			
			if _db.spell_startCDbyAuraFade[spellId] then
				local cdsNav = _db.cdsNav[sourceName][spellId]
				if cdsNav then
					CLEUstartCD(cdsNav)
				end
			end
			
			if destName and spellId == 20707 then
				isSoulStone[destName] = true
				ScheduleTimer(removeSoulStoneSchedule, 2, destName)	
			end
		end
	end
	function module.main:SPELL_CAST_SUCCESS(sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellId)
		if sourceName then
			if _db.spell_isPetAbility[spellId] then
				sourceName = _db.session_PetOwner[sourceGUID] or sourceName
			end
			local isResurect = _db.isResurectDisabled and _db.spell_battleRes[spellId]
		 
			local findspecspell =  _db.findspecspells[spellId]
			if findspecspell and (GetUnitInfoByUnitFlag(sourceFlags,4) % 8) > 0 then
				globalGUIDs[sourceName] = round(findspecspell)
			end
			
			if _db.spell_startCDbyAuraFade[spellId] then
				return
			end
	
			local cdsNav = _db.cdsNav[sourceName][spellId]
			if cdsNav and not isResurect then
				CLEUstartCD(cdsNav)
			end
	
			if _db.spell_isTalent[spellId] then
				_db.session_gGUIDs[sourceName] = spellId
			end
			
			if _db.spell_resetOtherSpells[spellId] then
				for i,resetSpellID in ipairs(_db.spell_resetOtherSpells[spellId]) do
					local j = _db.cdsNav[sourceName][resetSpellID]
					if j then
						_C[j][3] = 0
					end
				end
			end
			
			if _db.spell_sharingCD[spellId] then
				for spell2ID,timeCD in pairs(_db.spell_sharingCD[spellId]) do
					local inPos = _db.cdsNav[sourceName][spell2ID]
					if inPos then
						_C[inPos][3] = timeCD
						_C[inPos][4] = GetTime()
					end
				end
			end
			
			local reduceByCast = _db.spell_reduceCdCast[spellId]
			if reduceByCast then
				for i=1,#reduceByCast,2 do
					local reduceByCastSpell = reduceByCast[i]
					if type(reduceByCastSpell) ~= "table" then
						local j = _db.cdsNav[sourceName][reduceByCastSpell]
						if j then
							_C[j][3] = _C[j][3] + reduceByCast[i+1]
						end
					else
						if _db.session_gGUIDs[sourceName][ reduceByCastSpell[2] ] then
							local j = _db.cdsNav[sourceName][ reduceByCastSpell[1] ]
							if j then
								_C[j][3] = _C[j][3] + reduceByCast[i+1]
							end
						end
					end
				end
			end
			
			local increaseDurationCast = _db.spell_increaseDurationCast[spellId]
			if increaseDurationCast then
				for i=1,#increaseDurationCast,2 do
					local increaseDurationCastSpell = increaseDurationCast[i]
					if type(increaseDurationCastSpell) ~= "table" then
						local j = _db.cdsNav[sourceName][increaseDurationCastSpell]
						if j and (GetTime() - _C[j][4]) < _C[j][5]  then
							_C[j][5] = _C[j][5] + increaseDurationCast[i+1]
						end
					else
						if _db.session_gGUIDs[sourceName][ increaseDurationCastSpell[2] ] then
							local j = _db.cdsNav[sourceName][ increaseDurationCastSpell[1] ]
							if j and (GetTime() - _C[j][4]) < _C[j][5]  then
								_C[j][5] = _C[j][5] + increaseDurationCast[i+1]
							end
						end
					end
				end
			end
		end
	end
	function module.main:SPELL_CAST_START(sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellId)
		local sID = _db.spell_casting_list[spellId]
		if sID and sourceName then
			local ctime_ = GetTime()
			spell_casting_data_set(sourceName,spellId,ctime_,sID/(1+ (UnitSpellHaste(sourceName) or 0) /100))
			module:RegisterEvents('UNIT_SPELLCAST_STOP')
			if _db.spell_casting_frame then
				CancelTimer(_db.spell_casting_frame)
			end
			_db.spell_casting_frame = ScheduleTimer(castTimerSchedule, 3.5)	
		end
	end
	function module.main:SPELL_DISPEL(sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellId)
		if _db.spell_dispellsList[spellId] and sourceName then
			_db.spell_dispellsFix[ sourceName ] = true
		end
	end
	function module.main:SPELL_RESURRECT(sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellId)
		if not destName then
			return
		end
		_db.resurrect_data[destName] = true
	end
	function module.main:UNIT_DIED(sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellId)
		if destName and isSoulStone[destName] then
			_db.resurrect_data[destName] = true
		end
	end
	eventsView = {
		SPELL_AURA_REMOVED=module.main.SPELL_AURA_REMOVED,
		SPELL_CAST_SUCCESS=module.main.SPELL_CAST_SUCCESS,
		SPELL_CAST_START=module.main.SPELL_CAST_START,
		SPELL_RESURRECT=module.main.SPELL_RESURRECT,
		SPELL_DISPEL=module.main.SPELL_DISPEL,
		UNIT_DIED=module.main.UNIT_DIED,
	}
end

function module.options:Load()
	loadstring(module.db.AllClassSpellsInText)()
	module.db.AllClassSpellsInText = nil

	module.options.spellsPerPage = 16

	self.chkEnable = ExRT.lib.CreateCheckBox(self,nil,480,-3,ExRT.L.senable)
	self.chkEnable:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			module:Enable()
		else
			module:Disable()
		end
	end)
	
	self.chkLock = ExRT.lib.CreateCheckBox(self,nil,340,-3,ExRT.L.cd2fix)
	self.chkLock:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.lock = true
			ExRT.mds.LockMove(module.frame,nil,module.frame.texture)
			ExRT.lib.AddShadowComment(module.frame,1)
			if VExRT.ExCD2.SplitOpt then 
				for i=1,module.db.maxColumns do 
					ExRT.mds.LockMove(module.frame.colFrame[i],nil,module.frame.colFrame[i].lockTexture)
					ExRT.lib.AddShadowComment(module.frame.colFrame[i],1)
				end 
			end
		else
			VExRT.ExCD2.lock = nil
			ExRT.mds.LockMove(module.frame,true,module.frame.texture)
			ExRT.lib.AddShadowComment(module.frame,nil,ExRT.L.cd2)
			if VExRT.ExCD2.SplitOpt then 
				for i=1,module.db.maxColumns do 
					ExRT.mds.LockMove(module.frame.colFrame[i],true,module.frame.colFrame[i].lockTexture)
					ExRT.lib.AddShadowComment(module.frame.colFrame[i],nil,ExRT.L.cd2,i,72,"OUTLINE")
				end 
			end
		end
	end)

	self.tab = ExRT.lib.CreateTabFrame(self,613,535,5,-30,3,1,ExRT.L.cd2Spells,ExRT.L.cd2Appearance,ExRT.L.cd2History)
	
	
	local function fastSetupFrameListClick(self)
		for k=1,#self.ids do
			local bool = nil
			for j=1,#module.db.spellDB do
				if module.db.spellDB[j][1] == self.ids[k] then
					bool = true
					break
				end
			end
			if not bool then
				for class,classData in pairs(module.db.allClassSpells) do
					for j=1,#classData do
						if classData[j][1] == self.ids[k] then
							module.options:addNewSpell(class,classData[j],true)
							bool = true
							break
						end
					end
					if bool then
						break
					end
				end
			end
		end
		for j=1,#self.ids do
			VExRT.ExCD2.CDE[self.ids[j]] = true
		end
		UpdateRoster()
		module.options:ReloadSpellsPage()
		module.options.fastSetupFrame.HideByTimer(module.options.fastSetupFrame)
	end
	local function fastSetupFrameListEnter(self)
		local sList = {}
		for j=1,#self.ids do
			local sID,_,sT=GetSpellInfo(self.ids[j])
			if sID then
				table.insert(sList,"|T"..sT..":0|t |cffffffff"..sID.."|r")
			end
		end
		ExRT.lib.TooltipShow(self,"ANCHOR_LEFT",ExRT.L.cd2fastSetupTooltip..":",unpack(sList))
	end
	local function fastSetupFrameListLeave(self)
		ExRT.lib.TooltipHide()
	end
	self.fastSetupFrame = ExRT.lib.CreateListFrame(self.tab.tabs[1],200,6,"RIGHT","TOPRIGHT",-15,-5,ExRT.L.cd2fastSetupTitle..":",fastSetupFrameListClick)
	for i=1,6 do
		self.fastSetupFrame.buttons[i]:SetScript("OnEnter", fastSetupFrameListEnter)
		self.fastSetupFrame.buttons[i]:SetScript("OnLeave", fastSetupFrameListLeave)				
	end
	self.fastSetupFrame.buttons[1].ids = {31821,62618,97462,159916,76577,51052,98008,115310,64843,740,108280,108281,15286,172106}
	self.fastSetupFrame.buttons[1].text:SetText(ExRT.L.cd2fastSetupTitle1)
	self.fastSetupFrame.buttons[2].ids = {47788,33206,6940,102342,114030,116849,1022}
	self.fastSetupFrame.buttons[2].text:SetText(ExRT.L.cd2fastSetupTitle2)
	self.fastSetupFrame.buttons[3].ids = {20484,20707,61999,126393,20608,161642}
	self.fastSetupFrame.buttons[3].text:SetText(ExRT.L.cd2fastSetupTitle3)
	self.fastSetupFrame.buttons[4].ids = {6552,102060,96231,147362,1766,15487,47528,47476,57994,2139,116705,106839,19647,91802,115781,78675,}	--Kicks
	self.fastSetupFrame.buttons[4].text:SetText(ExRT.L.cd2fastSetupTitle4)
	self.fastSetupFrame.buttons[5].ids = {114192,355,62124,56222,49576,115546,6795,}	--Taunts
	self.fastSetupFrame.buttons[5].text:SetText(ExRT.L.cd2fastSetupTitle5)
	self.fastSetupFrame.buttons[6].ids = {4987,32375,527,51886,115450,2782,475,115276,89808}		--Dispels
	self.fastSetupFrame.buttons[6].text:SetText(ExRT.L.cd2fastSetupTitle6)

	
	self.borderList = CreateFrame("Frame",nil,self.tab.tabs[1])
	self.borderList:SetSize(603,self.spellsPerPage*31+3)
	self.borderList:SetPoint("TOPLEFT", 5, -30)
	self.borderList:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",edgeFile = ExRT.mds.defBorder,tile = false,edgeSize = 8})
	self.borderList:SetBackdropColor(0,0,0,0.3)
	self.borderList:SetBackdropBorderColor(0.6,0.6,0.6,0.9)
	
	local function SyncUserDB()
		table.wipe(VExRT.ExCD2.userDB)
		local j = 1
		for i=module.db.dbCountDef+1,#module.db.spellDB do
			VExRT.ExCD2.userDB[j] = module.db.spellDB[i]
			j = j + 1
		end
	end
	
	local function CheckToNil(self)
		self.chk:SetChecked(nil) 
		VExRT.ExCD2.CDE[self.sid] = nil
		UpdateRoster()
	end

	self.ScrollBar = ExRT.lib.CreateScrollBar2(self.borderList,18,self.spellsPerPage*31-2,-1,-3,1,20,"TOPRIGHT")
	function module.options:ReloadSpellsPage()
		local event = ExRT.mds.Round(module.options.ScrollBar:GetValue())
		module.options.butSpellsAdd:Hide()
		module.options.butSpellsFrame:Hide()	
		for i=event,event+module.options.spellsPerPage-1 do
			local j = i - event + 1
			if i <= #module.db.spellDB then
				module.options.spellsList[j].chk:SetChecked(VExRT.ExCD2.CDE[module.db.spellDB[i][1]])
				local SpellName, _, tx = GetSpellInfo(module.db.spellDB[i][1])
				module.options.spellsList[j].sid = module.db.spellDB[i][1]
				module.options.spellsList[j].tid = i
				module.options.spellsList[j].icon:SetTexture(tx or "Interface\\Icons\\INV_MISC_QUESTIONMARK")
				module.options.spellsList[j].spellName:SetFormattedText("|cffffffff|Hspell:%d|h%s|h|r",module.db.spellDB[i][1], SpellName or "?")
				module.options.spellsList[j].class:SetText(ExRT.L.classLocalizate[module.db.spellDB[i][2]] or "?")
				local cR,cG,cB = ExRT.mds.classColorNum(module.db.spellDB[i][2])
				module.options.spellsList[j].class:SetTextColor(cR,cG,cB,1)
				
				module.options.spellsList[j].backClassColorR = cR
				module.options.spellsList[j].backClassColorG = cG
				module.options.spellsList[j].backClassColorB = cB
		
				if not SpellName then
					module.options.spellsList[j].chk:Disable()
					module.options.spellsList[j].chk:SetAlpha(0.5)
				else
					module.options.spellsList[j].chk:Enable()
					module.options.spellsList[j].chk:SetAlpha(1)
				end
	
				module.options.spellsList[j]:Show()
	
				ExRT.lib.ShowOrHide(module.options.spellsList[j].tooltipFrame,not module.db.spellDB[i].user)
				ExRT.lib.ShowOrHide(module.options.spellsList[j].spellName,not module.db.spellDB[i].user)
				ExRT.lib.ShowOrHide(module.options.spellsList[j].class,not module.db.spellDB[i].user)
				ExRT.lib.ShowOrHide(module.options.spellsList[j].userSpellName,module.db.spellDB[i].user)
				ExRT.lib.ShowOrHide(module.options.spellsList[j].userClass,module.db.spellDB[i].user)
				ExRT.lib.ShowOrHide(module.options.spellsList[j].userRemove,module.db.spellDB[i].user)
	
				module.options.spellsList[j].dropDownPriority:SetText(format("%d",VExRT.ExCD2.Priority[module.db.spellDB[i][1]] or 15))
	
				if module.db.spellDB[i].user then
					module.options.spellsList[j].userSpellName:SetText(module.db.spellDB[i][1] or "")
	
					module.options.spellsList[j].userClass:SetText("|c"..ExRT.mds.classColor(module.db.spellDB[i][2])..ExRT.L.classLocalizate[module.db.spellDB[i][2]])
				end
				
				if module.db.spellDB[i][1] == 161642 then
					module.options.spellsList[j].additionalTooltip = ExRT.L.cd2ResurrectTooltip
				else
					module.options.spellsList[j].additionalTooltip = nil
				end
			else
				module.options.butSpellsAdd:Show()
				module.options.butSpellsFrame:Show()
				module.options.spellsList[j]:Hide()
			end
		end
		GameTooltip_Hide()
		ExRT.lib.HideAdditionalTooltips()
		module.options.ScrollBar:reButtonsState()
	end
	self.ScrollBar:SetScript("OnValueChanged", module.options.ReloadSpellsPage)
	
	self:SetScript("OnMouseWheel", function(self, delta)
		delta = -delta
		local current = module.options.ScrollBar:GetValue()
		local min_,max_ = module.options.ScrollBar:GetMinMaxValues()
		current = current + delta
		if current > max_ then
			current = max_
		elseif current < min_ then
			current = min_
		end
		module.options.ScrollBar:SetValue(current)
	end)
	
	local function SpellsListChkOnClick(self)
		if self:GetChecked() then
			VExRT.ExCD2.CDE[module.options.spellsList[self._i].sid] = true
		else
			VExRT.ExCD2.CDE[module.options.spellsList[self._i].sid] = nil
		end
		UpdateRoster()
	end
	local function SpellsListOnUpdate(self)
		if ExRT.mds.IsInFocus(self,nil,nil,true) then
			self.backClassColor:SetGradientAlpha("HORIZONTAL", self.backClassColorR, self.backClassColorG, self.backClassColorB, 0.8, self.backClassColorR, self.backClassColorG, self.backClassColorB, 0)
		else
			self.backClassColor:SetGradientAlpha("HORIZONTAL", self.backClassColorR, self.backClassColorG, self.backClassColorB, 0.4, self.backClassColorR, self.backClassColorG, self.backClassColorB, 0)
		end
	end
	local function SpellsListTooltipFrameOnEnter(self)
		ExRT.lib.OnEnterHyperLinkTooltip(self,module.options.spellsList[self._i].spellName:GetText())
		if module.options.spellsList[self._i].additionalTooltip then
			ExRT.lib.AdditionalTooltip(nil,{module.options.spellsList[self._i].additionalTooltip})
		end
	end
	local function SpellsListTooltipFrameOnLeave()
		GameTooltip_Hide()
		ExRT.lib.HideAdditionalTooltips()
	end
	local SpellsListDropDownPriorityDataList = {}
	local function SpellsListDropDownPrioritySelectFunc(self,arg)
		local list = self:GetParent().parent
		list:SetText(arg)
		VExRT.ExCD2.Priority[module.options.spellsList[list._i].sid] = arg
		ExRT.lib.ScrollDropDown.Close()
		UpdateRoster()
	end
	for i=1,30 do
		SpellsListDropDownPriorityDataList[i] = {text=i,justifyH="CENTER",arg1=i,func=SpellsListDropDownPrioritySelectFunc}
	end
	local function SpellsListDropDownPriorityOnEnter(self)
		ExRT.lib.TooltipShow(self,"ANCHOR_LEFT",ExRT.L.cd2Priority,{ExRT.L.cd2PriorityTooltip,1,1,1,true})
	end
	local function SpellsListButtonModifyOnClick(self)
		module.options.spellsModifyFrame:Hide()
		module.options.spellsModifyFrame.sid = module.options.spellsList[self._i].sid
		module.options.spellsModifyFrame.tid = module.options.spellsList[self._i].tid
		module.options.spellsModifyFrame.class = module.db.spellDB[module.options.spellsList[self._i].tid][2]
		local x, y = GetCursorPosition()
		local s = self:GetEffectiveScale()
		x, y = x/s, y/s
		module.options.spellsModifyFrame:ClearAllPoints()
		module.options.spellsModifyFrame:SetPoint("TOPRIGHT",UIParent,"BOTTOMLEFT",x,y)
		module.options.spellsModifyFrame:Show()
	end
	local function SpellsListUserSpellNameOnTextChanged(self,isUser)
		if not isUser then
			return
		end
		local tmp = nil
		local sid_ = tonumber(self:GetText())
		if sid_ then
			for j=1,#module.db.spellDB do
				if module.db.spellDB[j][1] == sid_ and j ~= module.options.spellsList[self._i].tid then
					module.options.spellsList[self._i].chk:Disable()
					module.options.spellsList[self._i].chk:SetAlpha(0.5)
					return
				end
			end
		end
	
		CheckToNil(module.options.spellsList[self._i])
		if not sid_ then 
			module.options.spellsList[self._i].chk:Disable()
			module.options.spellsList[self._i].chk:SetAlpha(0.5)
			return 
		end
		local SpellName, _, tx = GetSpellInfo(sid_)
		module.options.spellsList[self._i].sid = sid_
		module.options.spellsList[self._i].icon:SetTexture(tx or "Interface\\Icons\\INV_MISC_QUESTIONMARK")
		if not SpellName then
			module.options.spellsList[self._i].chk:Disable()
			module.options.spellsList[self._i].chk:SetAlpha(0.5)
			--return 
		else
			local txt_ = ("|cff71d5ff|Hspell:%d|h%s|h|r"):format(sid_, SpellName or "?")		

			module.options.spellsList[self._i].chk:Enable()
			module.options.spellsList[self._i].chk:SetAlpha(1)
		end
		module.db.spellDB[module.options.spellsList[self._i].tid][1] = sid_
		SyncUserDB()
	end
	local function SpellsListUserSpellNameOnEnter(self)
		local sid = tonumber(self:GetText())
		if sid then
			local spellName = GetSpellInfo(sid)
			if spellName then
				local link = format("|Hspell:%d|hspell|h",sid)
				ExRT.lib.OnEnterHyperLinkTooltip(self,link)
			else
				ExRT.lib.OnEnterTooltip(self)
			end
		else
			ExRT.lib.OnEnterTooltip(self)
		end
	end
	local function SpellsListUserClassDropDownInit(self, level, menuList)
		ExRT.mds.FixDropDown(120)
		local info = UIDropDownMenu_CreateInfo()
		for key,val in pairs(module.db.classNames) do
			info.text,info.notCheckable,info.minWidth,info.justifyH = ExRT.L.classLocalizate[val],1,120,"CENTER"
			info.menuList, info.hasArrow, info.arg1 = key, false, key
			info.colorCode = "|c"..ExRT.mds.classColor(val)
			info.func = function (this,nv)
				CheckToNil(module.options.spellsList[self._i])
				module.options.spellsList[self._i].userClass:SetText("|c"..ExRT.mds.classColor(module.db.classNames[nv])..ExRT.L.classLocalizate[module.db.classNames[nv]])
				CloseDropDownMenus()
				module.db.spellDB[module.options.spellsList[self._i].tid][2] = module.db.classNames[nv]
				local cR,cG,cB = ExRT.mds.classColorNum(module.db.classNames[nv])
				module.options.spellsList[self._i].backClassColorR = cR
				module.options.spellsList[self._i].backClassColorG = cG
				module.options.spellsList[self._i].backClassColorB = cB
				SyncUserDB()
			end
			UIDropDownMenu_AddButton(info)
		end
		do
			info.text,info.notCheckable,info.minWidth,info.justifyH = ExRT.L.classLocalizate["ALL"],1,120,"CENTER"
			info.menuList, info.hasArrow = #module.db.classNames+1, false
			info.colorCode = "|c"..ExRT.mds.classColor("ALL")
			info.func = function (this)
				CheckToNil(module.options.spellsList[self._i])
				module.options.spellsList[self._i].userClass:SetText("|c"..ExRT.mds.classColor("ALL")..ExRT.L.classLocalizate["ALL"])
				CloseDropDownMenus()
				module.db.spellDB[module.options.spellsList[self._i].tid][2] = "ALL"
				local cR,cG,cB = ExRT.mds.classColorNum("ALL")
				module.options.spellsList[self._i].backClassColorR = cR
				module.options.spellsList[self._i].backClassColorG = cG
				module.options.spellsList[self._i].backClassColorB = cB
				SyncUserDB()
			end
			UIDropDownMenu_AddButton(info)
		end
	end
	local function SpellsListUserRemoveOnClick(self)
		VExRT.ExCD2.CDE[module.options.spellsList[self._i].sid] = nil
		
		for j=3,7 do
			if type(module.db.spellDB[module.options.spellsList[self._i].tid][j])=="table" then
				VExRT.ExCD2.CDECol[module.db.spellDB[module.options.spellsList[self._i].tid][j][1]..";"..(j-2)] = nil
			end
		end
		
		for j = module.options.spellsList[self._i].tid + 1,#module.db.spellDB do
			module.db.spellDB[j-1] = module.db.spellDB[j]
		end
		module.db.spellDB[#module.db.spellDB] = nil

		local current = module.options.ScrollBar:GetValue()
		local min_,max_ = module.options.ScrollBar:GetMinMaxValues()
		module.options.ScrollBar:SetMinMaxValues(min_,max_-1)
		
		local newVal = current == max_ and max(current-1,1) or current
		if newVal ~= current then
			module.options.ScrollBar:SetValue(newVal)
		else
			module.options.ReloadSpellsPage()
		end

		SyncUserDB()
		UpdateRoster()
		
		module.options:CleanUPVariables()
	end
	
	self.spellsList = {}
	for i=1,self.spellsPerPage do
		self.spellsList[i] = CreateFrame("Frame",nil,self.borderList)
		self.spellsList[i]:SetPoint("TOPLEFT",5,-1-(i-1)*31)
		self.spellsList[i]:SetSize(577,31)

		self.spellsList[i].chk = ExRT.lib.CreateCheckBox(self.spellsList[i],nil,0,0,"")
		self.spellsList[i].chk._i = i
		self.spellsList[i].chk:SetScript("OnClick", SpellsListChkOnClick)
		
		self.spellsList[i].backClassColor = self.spellsList[i]:CreateTexture(nil, "BACKGROUND")
		self.spellsList[i].backClassColor:SetPoint("TOPLEFT",-3,0)
		self.spellsList[i].backClassColor:SetSize(200,31)
		self.spellsList[i].backClassColor:SetTexture( 1, 1, 1, 1)
		self.spellsList[i].backClassColorR = 0
		self.spellsList[i].backClassColorG = 0
		self.spellsList[i].backClassColorB = 0
		
		self.spellsList[i]:SetScript("OnUpdate",SpellsListOnUpdate)
	
		self.spellsList[i].icon = self.spellsList[i]:CreateTexture(nil, "ARTWORK")
		self.spellsList[i].icon:SetSize(30,30)
		self.spellsList[i].icon:SetPoint("TOPLEFT", 30, -1)
	
		self.spellsList[i].tooltipFrame = CreateFrame("Frame",nil,self.spellsList[i])
		self.spellsList[i].tooltipFrame:SetSize(150,30) 
		self.spellsList[i].tooltipFrame:SetPoint("TOPLEFT", 66, 0)
		self.spellsList[i].tooltipFrame._i = i
		self.spellsList[i].tooltipFrame:SetScript("OnEnter", SpellsListTooltipFrameOnEnter)
		self.spellsList[i].tooltipFrame:SetScript("OnLeave", SpellsListTooltipFrameOnLeave)

		self.spellsList[i].spellName = ExRT.lib.CreateText(self.spellsList[i],155,30,nil,66,0,nil,nil,ExRT.mds.defFont,12,nil,nil,nil,nil,nil,1)
	
		self.spellsList[i].class = ExRT.lib.CreateText(self.spellsList[i],140,30,nil,230,0,nil,nil,ExRT.mds.defFont,14,nil,nil,nil,nil,nil,1)
	
		self.spellsList[i].dropDownPriority = ExRT.lib.CreateScrollDropDown(self.spellsList[i],"TOPLEFT",330,-2,50,60,15)
		self.spellsList[i].dropDownPriority._i = i
		self.spellsList[i].dropDownPriority.List = SpellsListDropDownPriorityDataList
		self.spellsList[i].dropDownPriority:SetScript("OnEnter",SpellsListDropDownPriorityOnEnter)
		self.spellsList[i].dropDownPriority:SetScript("OnLeave",ExRT.lib.TooltipHide)
		
		self.spellsList[i].buttonModify = ExRT.lib.CreateButton(self.spellsList[i],130,27,nil,420,-2,ExRT.L.cd2ButtonModify)
		self.spellsList[i].buttonModify._i = i
		self.spellsList[i].buttonModify:SetScript("OnClick", SpellsListButtonModifyOnClick) 

		self.spellsList[i].userSpellName = ExRT.lib.CreateEditBox(self.spellsList[i],140,24,nil,70,-4,ExRT.L.cd2SpellID,6,true)
		self.spellsList[i].userSpellName._i = i
		self.spellsList[i].userSpellName:SetScript("OnTextChanged",SpellsListUserSpellNameOnTextChanged)
		self.spellsList[i].userSpellName:SetScript("OnEnter",SpellsListUserSpellNameOnEnter)
		self.spellsList[i].userSpellName:SetScript("OnLeave",ExRT.lib.TooltipHide)
		
		self.spellsList[i].userClass = ExRT.lib.CreateDropDown(self.spellsList[i],"TOPLEFT",200,-2,110)
		self.spellsList[i].userClass._i = i
		UIDropDownMenu_Initialize(self.spellsList[i].userClass, SpellsListUserClassDropDownInit)
		self.spellsList[i].userClass.tooltipText = ExRT.L.cd2Class
		self.spellsList[i].userClass:SetScript("OnEnter",ExRT.lib.OnEnterTooltip)
		self.spellsList[i].userClass:SetScript("OnLeave",ExRT.lib.OnLeaveTooltip)
	
		self.spellsList[i].userRemove = CreateFrame("Button",nil,self.spellsList[i],"UIPanelCloseButton") 
		self.spellsList[i].userRemove:SetSize(18,18) 
		self.spellsList[i].userRemove:SetPoint("TOPLEFT",555,-7) 
		self.spellsList[i].userRemove.tooltipText = ExRT.L.cd2RemoveButton
		self.spellsList[i].userRemove._i = i
		self.spellsList[i].userRemove:SetScript("OnClick",SpellsListUserRemoveOnClick) 
		self.spellsList[i].userRemove:SetScript("OnEnter",ExRT.lib.OnEnterTooltip)
		self.spellsList[i].userRemove:SetScript("OnLeave",ExRT.lib.OnLeaveTooltip)

		self.spellsList[i].userClass:Hide()
		self.spellsList[i].userRemove:Hide()
	end

	self.butSpellsAdd = ExRT.lib.CreateButton(self.borderList,280,26,nil,5,-3-(self.spellsPerPage-1)*31,ExRT.L.cd2AddSpell)
	self.butSpellsAdd:SetScript("OnClick", function(self) 
		module.options:addNewSpell(module.db.classNames[math.random(1,#module.db.classNames)])
		module.options:CleanUPVariables()
	end) 
	self.butSpellsAdd:Hide()
	
	self.butSpellsFrame = ExRT.lib.CreateButton(self.borderList,280,26,nil,292,-3-(self.spellsPerPage-1)*31,ExRT.L.cd2AddSpellFromList)
	self.butSpellsFrame:SetScript("OnClick", function(self) 
		module.options.addSpellFrame:Show()
	end) 
	self.butSpellsFrame:Hide()
	
	self.spellsModifyFrame = ExRT.lib.CreatePopupFrame(560,200)	
	self.spellsModifyFrame.title = ExRT.lib.CreateText(self.spellsModifyFrame,400,24,nil,20,-3,"LEFT",nil,nil,nil,"",nil,1,1,1)
	
	self.spellsModifyFrame.isDefaultSpell = nil
	
	self.spellsModifyFrame.OnShow = function(self)
		if not self.class or not self.sid or not self.tid then
			self:Hide()
			return
		end
		self:SetFrameLevel(120)
		
		local titleName,_,titleTexture = GetSpellInfo(self.sid)
		module.options.spellsModifyFrame.title:SetFormattedText("%s%s",titleTexture and "|T"..titleTexture..":16|t " or "",titleName or ExRT.L.cd2TextSpell.." #"..self.sid)

		local specByClassTable = module.db.specByClass[self.class] or {0}
		local specsCount = #specByClassTable
		for i=1,specsCount do
			local specID = specByClassTable[i]
			local icon = ""
			if module.db.specIcons[specID] then
				icon = "|T".. module.db.specIcons[specID] ..":20|t"
			else
				icon = ExRT.mds.classIconInText(self.class,20) or ""
			end
		
			module.options.spellsModifyFrame.el[i].spec:SetText(icon.." |c"..ExRT.mds.classColor(self.class)..ExRT.L.specLocalizate[module.db.specInLocalizate[specID]])
			module.options.spellsModifyFrame.el[i]:Show()
			
			if module.db.spellDB[self.tid][i+2] then
				module.options.spellsModifyFrame.el[i].cd:SetText(module.db.spellDB[self.tid][i+2][2])
				module.options.spellsModifyFrame.el[i].dur:SetText(module.db.spellDB[self.tid][i+2][3])
				module.options.spellsModifyFrame.el[i].spellID:SetText(module.db.spellDB[self.tid][i+2][1])
				
				module.options.spellsModifyFrame.el[i].col:SetText( VExRT.ExCD2.CDECol[module.db.spellDB[self.tid][i+2][1]..";"..i] or module.db.def_col[module.db.spellDB[self.tid][i+2][1]..";"..i] or 1)
				
				module.options.spellsModifyFrame.el[i].add:Hide()
				module.options.spellsModifyFrame.el[i].col:Show()
				module.options.spellsModifyFrame.el[i].dur:Show()
				module.options.spellsModifyFrame.el[i].spellID:Show()
				module.options.spellsModifyFrame.el[i].cd:Show()
				module.options.spellsModifyFrame.el[i].remove:Show()
			else
				module.options.spellsModifyFrame.el[i].add:Show()
				module.options.spellsModifyFrame.el[i].col:Hide()
				module.options.spellsModifyFrame.el[i].dur:Hide()
				module.options.spellsModifyFrame.el[i].spellID:Hide()
				module.options.spellsModifyFrame.el[i].cd:Hide()
				module.options.spellsModifyFrame.el[i].remove:Hide()
			end
			
			if not module.db.spellDB[self.tid].user then
				module.options.spellsModifyFrame.el[i].spellID:Disable()
				--module.options.spellsModifyFrame.el[i].cd:Disable()
				--module.options.spellsModifyFrame.el[i].dur:Disable()
				module.options.spellsModifyFrame.el[i].remove:Disable()
				module.options.spellsModifyFrame.el[i].add:Hide()
			else
				module.options.spellsModifyFrame.el[i].spellID:Enable()
				--module.options.spellsModifyFrame.el[i].cd:Enable()
				--module.options.spellsModifyFrame.el[i].dur:Enable()
				module.options.spellsModifyFrame.el[i].remove:Enable()
				if module.options.spellsModifyFrame.el[i].add:IsShown() then
					module.options.spellsModifyFrame.el[i].add:Show()
				end
			end
		end
		for i=specsCount+1,5 do
			module.options.spellsModifyFrame.el[i]:Hide()
		end
		if not module.db.spellDB[self.tid].user then
			module.options.spellsModifyFrame.isDefaultSpell = true
		else
			module.options.spellsModifyFrame.isDefaultSpell = nil
		end
		module.options.spellsModifyFrame:SetHeight(40+35*specsCount)
	end
	
	self.spellsModifyFrame.el = {}
	for i=1,5 do
		self.spellsModifyFrame.el[i] = CreateFrame("Frame",nil,self.spellsModifyFrame)
		self.spellsModifyFrame.el[i]:SetPoint("TOPLEFT",15,-30-(i-1)*35)
		self.spellsModifyFrame.el[i]:SetSize(1,1)
		
		self.spellsModifyFrame.el[i].spec = ExRT.lib.CreateText(self.spellsModifyFrame.el[i],160,30,nil,0,0,nil,nil,ExRT.mds.defFont,14,nil,nil,nil,nil,nil,1)
	
		self.spellsModifyFrame.el[i].spellID = ExRT.lib.CreateEditBox(self.spellsModifyFrame.el[i],140,24,nil,180,-4,ExRT.L.cd2SpellID,6,true)
		self.spellsModifyFrame.el[i].spellID:SetScript("OnTextChanged",function(self,isUser)
			local sid_ = tonumber(self:GetText())
			if not sid_ or not isUser then
				return
			end
			local spellName = GetSpellInfo(sid_)

			local c = VExRT.ExCD2.CDECol[module.db.spellDB[module.options.spellsModifyFrame.tid][i+2][1]..";"..i]
			local tmp = nil
			for N1=1,#module.db.spellDB do
				for N2=3,7 do
					if module.db.spellDB[N1][N2] and module.db.spellDB[N1][N2] and module.db.spellDB[N1][N2][1] == module.db.spellDB[module.options.spellsModifyFrame.tid][i+2][1] and not (module.options.spellsModifyFrame.tid == N1 and (i+2) == N2) then
						tmp = true
					end
				end
			end
			if not tmp then
				VExRT.ExCD2.CDECol[module.db.spellDB[module.options.spellsModifyFrame.tid][i+2][1]..";"..i] = nil
			end
			module.db.spellDB[module.options.spellsModifyFrame.tid][i+2][1] = sid_
			if not VExRT.ExCD2.CDECol[sid_..";"..i] and not module.db.def_col[sid_..";"..i] then
				VExRT.ExCD2.CDECol[sid_..";"..i] = c
			else
				module.options.spellsModifyFrame.el[i].col:SetText( VExRT.ExCD2.CDECol[sid_..";"..i] or module.db.def_col[sid_..";"..i])
			end
		end)
		
		self.spellsModifyFrame.el[i].spellID:SetScript("OnEnter",function(self)
			local sid = tonumber(self:GetText())
			if sid then
				local spellName = GetSpellInfo(sid)
				if spellName then
					local link = format("|Hspell:%d|hspell|h",sid)
					ExRT.lib.OnEnterHyperLinkTooltip(self,link)
				else
					ExRT.lib.OnEnterTooltip(self)
				end
			else
				ExRT.lib.OnEnterTooltip(self)
			end
		end)
		self.spellsModifyFrame.el[i].spellID:SetScript("OnLeave",function(self)
			ExRT.lib.TooltipHide()
		end)
		
		self.spellsModifyFrame.el[i].col = ExRT.lib.CreateDropDown(self.spellsModifyFrame.el[i],"TOPLEFT",315,-2,50)
		UIDropDownMenu_Initialize(self.spellsModifyFrame.el[i].col, function(self, level, menuList)
			ExRT.mds.FixDropDown(50)
			local info = UIDropDownMenu_CreateInfo()
			for val=1,10 do
				info.text,info.notCheckable,info.minWidth,info.justifyH = val,1,50,"CENTER"
				info.menuList, info.hasArrow, info.arg1 = val, false, val
				info.func = function (slf,nv)
					self:SetText(tostring(nv))
					CloseDropDownMenus()
					VExRT.ExCD2.CDECol[module.db.spellDB[module.options.spellsModifyFrame.tid][i+2][1]..";"..i] = tonumber(nv)
				end
				UIDropDownMenu_AddButton(info)
			end
		end)
	
		self.spellsModifyFrame.el[i].col.tooltipText = ExRT.L.cd2ColNum
		self.spellsModifyFrame.el[i].col:SetScript("OnEnter",function(self) ExRT.lib.OnEnterTooltip(self) end)
		self.spellsModifyFrame.el[i].col:SetScript("OnLeave",function() ExRT.lib.OnLeaveTooltip() end)
		
		self.spellsModifyFrame.el[i].cd = ExRT.lib.CreateEditBox(self.spellsModifyFrame.el[i],50,24,nil,410,-4,ExRT.L.cd2EditBoxCDTooltip,6,true)
		self.spellsModifyFrame.el[i].cd:SetScript("OnTextChanged",function(self)
			local sid_ = tonumber(self:GetText())
			if not sid_ then
				return
			end
			module.db.spellDB[module.options.spellsModifyFrame.tid][i+2][2] = sid_
			if module.options.spellsModifyFrame.isDefaultSpell then
				local spellID = module.db.spellDB[module.options.spellsModifyFrame.tid][1]
				VExRT.ExCD2.default_userCD[spellID] = VExRT.ExCD2.default_userCD[spellID] or {}
				VExRT.ExCD2.default_userCD[spellID][i] = sid_
			end
		end)
		
		self.spellsModifyFrame.el[i].dur = ExRT.lib.CreateEditBox(self.spellsModifyFrame.el[i],50,24,nil,470,-4,ExRT.L.cd2EditBoxDurationTooltip,6,true)
		self.spellsModifyFrame.el[i].dur:SetTextColor(0.5,1,0.5,1)
		self.spellsModifyFrame.el[i].dur:SetScript("OnTextChanged",function(self)
			local sid_ = tonumber(self:GetText())
			if not sid_ then
				return
			end
			module.db.spellDB[module.options.spellsModifyFrame.tid][i+2][3] = sid_
			if module.options.spellsModifyFrame.isDefaultSpell then
				local spellID = module.db.spellDB[module.options.spellsModifyFrame.tid][1]
				VExRT.ExCD2.default_userDuration[spellID] = VExRT.ExCD2.default_userDuration[spellID] or {}
				VExRT.ExCD2.default_userDuration[spellID][i] = sid_
			end
		end)
		
		self.spellsModifyFrame.el[i].remove = CreateFrame("Button",nil,self.spellsModifyFrame.el[i],"UIPanelCloseButton") 
		self.spellsModifyFrame.el[i].remove:SetSize(18,18) 
		self.spellsModifyFrame.el[i].remove:SetPoint("TOPLEFT",520,-7) 
		self.spellsModifyFrame.el[i].remove.tooltipText = ExRT.L.cd2RemoveButton
		self.spellsModifyFrame.el[i].remove:SetScript("OnClick", function(self) 
			module.options.spellsModifyFrame.el[i].add:Show()
			module.options.spellsModifyFrame.el[i].col:Hide()
			module.options.spellsModifyFrame.el[i].dur:Hide()
			module.options.spellsModifyFrame.el[i].spellID:Hide()
			module.options.spellsModifyFrame.el[i].cd:Hide()
			module.options.spellsModifyFrame.el[i].remove:Hide()
			
			module.db.spellDB[module.options.spellsModifyFrame.tid][i+2] = nil
		end) 
		self.spellsModifyFrame.el[i].remove:SetScript("OnEnter",function(self) ExRT.lib.OnEnterTooltip(self) end)
		self.spellsModifyFrame.el[i].remove:SetScript("OnLeave",function() ExRT.lib.OnLeaveTooltip() end)
		
		self.spellsModifyFrame.el[i].add = CreateFrame("Button",nil,self.spellsModifyFrame.el[i])
		self.spellsModifyFrame.el[i].add:SetSize(400,24)
		self.spellsModifyFrame.el[i].add:SetPoint("TOPLEFT", 140, -4)
		self.spellsModifyFrame.el[i].add:SetScript("OnClick", function(self) 
			self:Hide()
			module.options.spellsModifyFrame.el[i].col:Show()
			module.options.spellsModifyFrame.el[i].dur:Show()
			module.options.spellsModifyFrame.el[i].spellID:Show()
			module.options.spellsModifyFrame.el[i].cd:Show()
			module.options.spellsModifyFrame.el[i].remove:Show()
			
			module.options.spellsModifyFrame.el[i].spellID:SetText(module.options.spellsModifyFrame.sid)
			
			module.db.spellDB[module.options.spellsModifyFrame.tid][i+2] = {module.options.spellsModifyFrame.sid,0,0}
			
			module.options.spellsModifyFrame.el[i].cd:SetText(0)
			module.options.spellsModifyFrame.el[i].dur:SetText(0)
			module.options.spellsModifyFrame.el[i].col:SetText(VExRT.ExCD2.CDECol[module.db.spellDB[module.options.spellsModifyFrame.tid][i+2][1]..";"..i] or 1)
		end)
		self.spellsModifyFrame.el[i].add.html = ExRT.lib.CreateText(self.spellsModifyFrame.el[i].add,400,24,nil,0,0,"CENTER",nil,nil,nil,ExRT.L.cd2TextAdd,nil,1,1,1)
		ExRT.lib.CreateHoverHighlight(self.spellsModifyFrame.el[i].add)
		self.spellsModifyFrame.el[i].add.hl:SetVertexColor(1,1,1,0.5)
		self.spellsModifyFrame.el[i].add:SetScript("OnEnter", function(self) self.hl:Show() end)
		self.spellsModifyFrame.el[i].add:SetScript("OnLeave", function(self) self.hl:Hide() end)
	end
	
	self.addSpellFrame = ExRT.lib.CreatePopupFrame(550,422+10,ExRT.L.cd2AddSpellFrameName)
	
	self.addSpellFrame.backClassColor = self.addSpellFrame:CreateTexture(nil, "BORDER",nil,0)
	self.addSpellFrame.backClassColor:SetPoint("TOP",0,-25)
	self.addSpellFrame.backClassColor:SetSize(537,40)
	self.addSpellFrame.backClassColor:SetTexture( 1, 1, 1, 1)
	self.addSpellFrame.backClassColor:Hide()
	
	self.addSpellFrame.backClassColorBottom = self.addSpellFrame:CreateTexture(nil, "BORDER",nil,0)
	self.addSpellFrame.backClassColorBottom:SetPoint("BOTTOM",0,8)
	self.addSpellFrame.backClassColorBottom:SetSize(537,15)
	self.addSpellFrame.backClassColorBottom:SetTexture( 1, 1, 1, 1)
	self.addSpellFrame.backClassColorBottom:Hide()
	
	self.addSpellFrame.sortedClasses = {}
	
	self.addSpellFrame.dropDown = ExRT.lib.CreateDropDown(self.addSpellFrame,"TOPLEFT",320,-30,180)
	function self.addSpellFrame.dropDown:SetValue(newValue)
		module.options.addSpellFrame.dropDown:SetText("|c"..ExRT.mds.classColor(newValue)..ExRT.L.classLocalizate[newValue])
		CloseDropDownMenus()
		if not module.options.addSpellFrame.sortedClasses[newValue] then
			for i=1,#module.db.allClassSpells[newValue] do
				local spellName = GetSpellInfo(module.db.allClassSpells[newValue][i][1])
				module.db.allClassSpells[newValue][i].spellName = spellName or tostring(module.db.allClassSpells[newValue][i][1])
			end
			table_sort(module.db.allClassSpells[newValue],function(a,b) return a.spellName < b.spellName end)
			module.options.addSpellFrame.sortedClasses[newValue] = true
		end
		
		for i=1,#module.db.allClassSpells[newValue] do
			if i <= module.options.addSpellFrame.buttonsMax then
				local spellName, _, spellTexture = GetSpellInfo(module.db.allClassSpells[newValue][i][1])
				module.options.addSpellFrame.buttons[i].icon:SetTexture(spellTexture or "Interface\\Icons\\INV_MISC_QUESTIONMARK")
				module.options.addSpellFrame.buttons[i].text:SetText(spellName or "?")
				module.options.addSpellFrame.buttons[i].spellID = module.db.allClassSpells[newValue][i][1]
				module.options.addSpellFrame.buttons[i].spellLink = GetSpellLink(module.db.allClassSpells[newValue][i][1])
				module.options.addSpellFrame.buttons[i].colNum = module.db.allClassSpells[newValue][i][2]
				
				module.options.addSpellFrame.buttons[i].line = module.db.allClassSpells[newValue][i]
				
				if newValue == "PET" then
					module.options.addSpellFrame.buttons[i].text:SetText("|c"..ExRT.mds.classColor(module.db.allClassSpells[newValue][i][3])..ExRT.L.classLocalizate[module.db.allClassSpells[newValue][i][3]].."|r "..(spellName or "?"))
				end
				
				module.options.addSpellFrame.buttons[i].disabled = nil
				for j=1,#module.db.spellDB do
					if module.db.spellDB[j][1] == module.db.allClassSpells[newValue][i][1] then
							module.options.addSpellFrame.buttons[i].icon:SetDesaturated(true)
							module.options.addSpellFrame.buttons[i].text:SetTextColor(0.5,0.5,0.5,1)
							module.options.addSpellFrame.buttons[i].disabled = true
						break
					end
				end
				if not module.options.addSpellFrame.buttons[i].disabled then
					module.options.addSpellFrame.buttons[i].icon:SetDesaturated(nil)
					module.options.addSpellFrame.buttons[i].text:SetTextColor(1,1,1,1)
				end
	
				module.options.addSpellFrame.buttons[i]:Show()
			end
		end
		for i=#module.db.allClassSpells[newValue]+1,module.options.addSpellFrame.buttonsMax do
			module.options.addSpellFrame.buttons[i]:Hide()
		end
		module.options.addSpellFrame.class = newValue
		
		local cR,cG,cB = ExRT.mds.classColorNum(newValue)
		module.options.addSpellFrame.backClassColor:SetGradientAlpha("VERTICAL", cR,cG,cB, 0, cR,cG,cB, 0.5)
		module.options.addSpellFrame.backClassColor:Show()
		module.options.addSpellFrame.backClassColorBottom:SetGradientAlpha("VERTICAL", cR,cG,cB, 0.5, cR,cG,cB, 0)		
		module.options.addSpellFrame.backClassColorBottom:Show()
	end
	UIDropDownMenu_Initialize(self.addSpellFrame.dropDown, function(self, level, menuList)
		ExRT.mds.FixDropDown(180)
		local info = UIDropDownMenu_CreateInfo()
		for i,className in pairs(module.db.classNames) do
			info.text,info.notCheckable, info.minWidth, info.justifyH, info.menuList, info.hasArrow, info.arg1, info.func, info.colorCode = ExRT.L.classLocalizate[className], 1, 180, "CENTER", i, false, className, self.SetValue, "|c"..ExRT.mds.classColor(className)
			UIDropDownMenu_AddButton(info)
		end
		info.text,info.notCheckable, info.minWidth, info.justifyH, info.menuList, info.hasArrow, info.arg1, info.func, info.colorCode = ExRT.L.classLocalizate["PET"], 1, 180, "CENTER", #module.db.classNames + 1, false, "PET", self.SetValue, "|c"..ExRT.mds.classColor("PET")
		UIDropDownMenu_AddButton(info)
	end)
	
	local function AddSpellFrameButtonsOnEnter(self)
		self:SetBackdropBorderColor(1,1,1,0.5)
		GameTooltip:SetOwner(self, "ANCHOR_LEFT")
		GameTooltip:SetHyperlink(self.spellLink)
		GameTooltip:AddLine(" ")
		if module.options.addSpellFrame.class ~= "PET" then
			for i=1,#module.db.specByClass[module.options.addSpellFrame.class] do
				if self.line[2+i] then
					local icon = ""
					if module.db.specIcons[module.db.specByClass[module.options.addSpellFrame.class][i]] then
						icon = "|T".. module.db.specIcons[module.db.specByClass[module.options.addSpellFrame.class][i]] ..":20|t"
					else
						icon = ExRT.mds.classIconInText(module.options.addSpellFrame.class,20) or ""
					end
					GameTooltip:AddLine(icon.." |c"..ExRT.mds.classColor(module.options.addSpellFrame.class)..ExRT.L.specLocalizate[module.db.specInLocalizate[module.db.specByClass[module.options.addSpellFrame.class][i]]].. ":|r|cffffffff "..ExRT.L.cd2AddSpellFrameCDText.." "..self.line[i+2][2].. (self.line[i+2][3] > 0 and ", "..ExRT.L.cd2AddSpellFrameDurationText.." "..self.line[i+2][3] or ""))
				end
			end
		else
			for petName,petData in pairs(module.db.petsAbilities) do
				for j=2,#petData do
					if petData[j][1] == self.line[1] then
						local petNameInTooltip = petName
						if tonumber(petNameInTooltip) then
							petNameInTooltip = ExRT.L.creatureNames[tonumber(petNameInTooltip)]
						end
						GameTooltip:AddLine((ExRT.mds.classIconInText(self.line[3],20) or "").." |c"..ExRT.mds.classColor(self.line[3])..petNameInTooltip.. ":|r|cffffffff "..ExRT.L.cd2AddSpellFrameCDText.." "..petData[j][2].. (petData[j][3] and ", "..ExRT.L.cd2AddSpellFrameDurationText.." "..petData[j][3] or ""))
						break
					end
				end
			end
		end
		GameTooltip:AddLine("|cffffffff"..ExRT.L.cd2AddSpellFrameColumnText..": ".. self.colNum .."|r")
		if module.db.spell_isTalent[self.line[1]] then
			GameTooltip:AddLine("|cffffffff"..ExRT.L.cd2AddSpellFrameTalent.."|r")
		end
		if module.db.spell_durationByTalent_fix[self.line[1]] then
			GameTooltip:AddLine("|cffaaffaa"..ExRT.L.cd2AddSpellFrameDuration..":|r")
			for j=1,#module.db.spell_durationByTalent_fix[self.line[1]],2 do
				local sname = GetSpellInfo(module.db.spell_durationByTalent_fix[self.line[1]][j]) or "???"
				local cd = module.db.spell_durationByTalent_fix[self.line[1]][j+1]
				if not tonumber(cd) then
					cd = tonumber(string.sub(cd,2))
					if cd < 1 then
						cd = "-"..( (1-cd)*100 ).."%"
					else
						cd = "+"..( (cd-1)*100 ).."%"
					end
				end
				GameTooltip:AddLine("|cffffffff - "..sname .." (".. (tonumber(cd) and cd > 0 and "+" or "").. cd ..")|r")
				
				ExRT.lib.AdditionalTooltip("spell:"..module.db.spell_durationByTalent_fix[self.line[1]][j])
			end
			
		end
		do
			local cdByTalent_fix = nil
			local readiness_lines = {}
			if module.db.spell_cdByTalent_fix[self.line[1]] then
				cdByTalent_fix = true
				for j=1,#module.db.spell_cdByTalent_fix[self.line[1]],2 do
					local sname = GetSpellInfo(module.db.spell_cdByTalent_fix[self.line[1]][j]) or "???"
					local cd = module.db.spell_cdByTalent_fix[self.line[1]][j+1]
					if not tonumber(cd) then
						cd = tonumber(string.sub(cd,2))
						if cd < 1 then
							cd = "-"..( (1-cd)*100 ).."%"
						else
							cd = "+"..( (cd-1)*100 ).."%"
						end
					end
					table_insert(readiness_lines,"|cffffffff - "..sname .." (".. (tonumber(cd) and cd > 0 and "+" or "").. cd ..")|r")
					
					ExRT.lib.AdditionalTooltip("spell:"..module.db.spell_cdByTalent_fix[self.line[1]][j])
				end
			end
			--[[
			if module.options.addSpellFrame.class ~= "PET" then
				if not ExRT.isDraenorContent then
					local frame_class = module.options.addSpellFrame.class
					for j=1,#module.db.specByClass[frame_class] do
						for spellID,_ in pairs(module.db.spell_readiness[ module.db.specByClass[frame_class][j] ]) do
							if spellID == self.line[1] then
								cdByTalent_fix = true
								table_insert(readiness_lines,"|cffffffff - "..ExRT.L.cd2AddSpellFrameRadiness.." ("..ExRT.L.specLocalizate[ module.db.specInLocalizate[ module.db.specByClass[frame_class][j] ] ] ..")|r")
							end
						end
					end
				end
			end
			]]
			if cdByTalent_fix then
				GameTooltip:AddLine("|cffffaaaa"..ExRT.L.cd2AddSpellFrameCDChange..": |r")
				for j=1,#readiness_lines do
					GameTooltip:AddLine(readiness_lines[j])
				end
			end
		end
		if module.db.spell_charge_fix[self.line[1]] then
			if module.db.spell_charge_fix[self.line[1]] == 1 then
				GameTooltip:AddLine("|cffffffaa"..ExRT.L.cd2AddSpellFrameCharge.."|r")
			else
				GameTooltip:AddLine("|cffffffaa"..ExRT.L.cd2AddSpellFrameChargeChange..":|r")
				local sname = GetSpellInfo(module.db.spell_charge_fix[self.line[1]]) or "???"
				GameTooltip:AddLine("|cffffffff - "..sname .."|r")
			end
		end
		if module.db.spell_casting_list[self.line[1]] then
			GameTooltip:AddLine("|cffffffaa"..ExRT.L.cd2AddSpellFrameCast..": ".. module.db.spell_casting_list[self.line[1]] .."|r")
		end
		do
			for auraID,sID in pairs(module.db.spell_aura_list) do
				if sID == self.line[1] then
					local sname = GetSpellInfo(auraID) or "???"
					GameTooltip:AddLine("|cffaaffaa"..ExRT.L.cd2AddSpellFrameDurationLost..":|r")
					GameTooltip:AddLine("|cffffffff - \""..sname.."\"|r")
				end
			end
		end
		if module.db.spell_sharingCD[self.line[1]] then
			GameTooltip:AddLine("|cffffffaa"..ExRT.L.cd2AddSpellFrameSharing..": |r")
			for otherID,otherCD in pairs(module.db.spell_sharingCD[self.line[1]]) do
				local sname = GetSpellInfo(otherID) or "???"
				GameTooltip:AddLine("|cffffffff - "..sname .." (".. otherCD ..")|r")
			end
		end
		if module.db.spell_dispellsList[self.line[1]] then
			GameTooltip:AddLine("|cffffffaa"..ExRT.L.cd2AddSpellFrameDispel.."|r")
		end
		if module.db.spell_talentReplaceOther[self.line[1]] then
			local sname = GetSpellInfo(module.db.spell_talentReplaceOther[self.line[1]]) or "???"
			GameTooltip:AddLine("|cffffaaaa"..ExRT.L.cd2AddSpellFrameReplace .." ".. sname .."|r")
		end
		GameTooltip:Show()
	end
	local function AddSpellFrameButtonsOnLeave(self)
	  	self:SetBackdropBorderColor(1,1,1,0)
	  	GameTooltip_Hide()
	  	ExRT.lib.HideAdditionalTooltips()
	end
	local function AddSpellFrameButtonsOnClick(self)
		if not self.disabled then	
			module.options:addNewSpell(module.options.addSpellFrame.class,self.line)
			module.options.addSpellFrame:Hide()
		end
	end
	
	self.addSpellFrame.buttonsMax = 0
	for classNum=1,#module.db.classNames do
		local now = #module.db.allClassSpells[ module.db.classNames[classNum] ]
		self.addSpellFrame.buttonsMax = max(self.addSpellFrame.buttonsMax,now)
	end
	self.addSpellFrame.buttonsMax = max(self.addSpellFrame.buttonsMax,#module.db.allClassSpells["PET"])
	self.addSpellFrame:SetHeight( 82 + 35 * ceil( self.addSpellFrame.buttonsMax / 4 ) )
	
	self.addSpellFrame.buttons = {}
	for i=1,self.addSpellFrame.buttonsMax do
		self.addSpellFrame.buttons[i] = CreateFrame("Button",nil,self.addSpellFrame)
		self.addSpellFrame.buttons[i]:SetPoint("TOPLEFT",(i-1)%4 * 130 + 15,-floor((i-1)/4) * 35 - 60)
		self.addSpellFrame.buttons[i]:SetSize(130,35)
		self.addSpellFrame.buttons[i]:SetBackdrop({edgeFile = ExRT.mds.defBorder, edgeSize = 8})
		self.addSpellFrame.buttons[i]:SetBackdropBorderColor(1,1,1,0)
		
		self.addSpellFrame.buttons[i]:SetScript("OnEnter",AddSpellFrameButtonsOnEnter)
		self.addSpellFrame.buttons[i]:SetScript("OnLeave",AddSpellFrameButtonsOnLeave)
		
		self.addSpellFrame.buttons[i]:SetScript("OnClick",AddSpellFrameButtonsOnClick)
		
		self.addSpellFrame.buttons[i].icon = self.addSpellFrame.buttons[i]:CreateTexture(nil, "BACKGROUND")
		self.addSpellFrame.buttons[i].icon:SetSize(24,24)
		self.addSpellFrame.buttons[i].icon:SetPoint("TOPLEFT",5,-5)
		
		self.addSpellFrame.buttons[i].text = ExRT.lib.CreateText(self.addSpellFrame.buttons[i],99,31,nil,33,-2,nil,nil,nil,12,"",nil,1,1,1,1)
	end

	function module.options:addNewSpell(class,line,doNotScroll)
		local sbmin,sbmax = module.options.ScrollBar:GetMinMaxValues()
		module.options.ScrollBar:SetMinMaxValues(sbmin,sbmax+1)
		if line then
			if class ~= "PET" then
				module.db.spellDB[#module.db.spellDB+1] = {line[1],class,line[3],line[4],line[5],line[6],line[7],user=true}
				for j=3,7 do
					if line[j] and not VExRT.ExCD2.CDECol[ line[j][1] .. ";" .. (j-2) ] then
						VExRT.ExCD2.CDECol[ line[j][1] .. ";" .. (j-2) ] = line[2]
					end
				end
			else
				local cd,dur = 0,0
				for petName,petData in pairs(module.db.petsAbilities) do
					for j=2,#petData do
						if petData[j][1] == line[1] then
							cd = petData[j][2]
							dur = petData[j][3] or 0
							break
						end
					end
				end
				module.db.spellDB[#module.db.spellDB+1] = {line[1],line[3],{line[1],cd,dur},user=true}
				if not VExRT.ExCD2.CDECol[ line[1] .. ";1" ] then
					VExRT.ExCD2.CDECol[ line[1] .. ";1" ] = line[2]
				end
			end
		else
			module.db.spellDB[#module.db.spellDB+1] = {0,class,user=true}
		end
		if not doNotScroll then
			module.options.ScrollBar:SetValue(sbmax+1)
		end
		SyncUserDB()
		UpdateRoster()
	end
	
	self.addSpellFrame.OnShow = function (self)
		self.dropDown:SetValue(self.class or "WARRIOR")
	end
	
	
	self.tab1tab = ExRT.lib.CreateTabFrame(self.tab.tabs[1],600,100,0,0,2,1,ExRT.L.cd2Spells,ExRT.L.cd2Columns)
	self.tab1tab:SetBackdrop({})
	local function SetFirstTabFrame(self)
		if self._i == 1 then
			module.options.borderList:Show()
			module.options.colsSpells:Hide()
		else
			module.options.borderList:Hide()
			module.options.colsSpells:Show()		
		end
	end
	for i=1,2 do
		local frame = self.tab1tab.tabs[i].button
		frame:ClearAllPoints()
		if i == 1 then
			frame:SetPoint("TOPLEFT",self.tab.tabs[1],"TOPLEFT",10,-4)
		else
			frame:SetPoint("LEFT", self.tab1tab.tabs[1].button, "RIGHT", -16, 0)
		end
		frame._i = i
		frame.additionalFunc = SetFirstTabFrame
	end
	
	self.colsSpells = CreateFrame("ScrollFrame",nil,self.tab.tabs[1])
	self.colsSpells:SetSize(603,self.spellsPerPage*31+3)
	self.colsSpells:SetPoint("TOPLEFT", 5, -30)
	self.colsSpells:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",edgeFile = ExRT.mds.defBorder,tile = true,edgeSize = 8,insets = {left = 3,right = 3,top = 3,bottom = 3}})
	self.colsSpells:SetBackdropColor(0,0,0,0.3)
	self.colsSpells:SetBackdropBorderColor(0.6,0.6,0.6,0.9)
	self.colsSpells:Hide()
	
	self.colsSpells.C = CreateFrame("Frame", nil, self.colsSpells) 
	self.colsSpells.C:SetSize(603-16, self.spellsPerPage*31+100) 
	self.colsSpells:SetScrollChild(self.colsSpells.C)
	
	local function ColsSpellsUpdate()
		local val = self.colsSpells.ScrollBar:GetValue()
		module.options.colsSpells:SetVerticalScroll( (val * 24) % 24 )
		--val = ExRT.mds.Round( self.colsSpells.ScrollBar:GetValue() )
		val = floor( val )
		local line = 0
		local count = 0
		for i=1,#module.db.spellDB do
			local spellData = module.db.spellDB[i]
			local spellID = spellData[1]
			if VExRT_CDE[ spellID ] then
				local class = spellData[2]
				local specsCount = module.db.specByClass[class] and #module.db.specByClass[class] or 1
			
				for j=3,3+specsCount do
					if spellData[j] then
						count = count + 1
						if count >= val then
							line = line + 1
							if line > #self.colsSpells.lines then
								return
							end
							self.colsSpells.lines[line]:Show()
							
							local spellName,_,spellTexture = GetSpellInfo(spellID)
							self.colsSpells.lines[line].icon:SetTexture(spellTexture)
							self.colsSpells.lines[line].spellName:SetText(spellName)
							self.colsSpells.lines[line].link = "spell:"..(spellData[j][1] or spellID)
							
							if j == 3 then
								self.colsSpells.lines[line].iconSpec:Hide()
							else
								self.colsSpells.lines[line].iconSpec:Show()
								self.colsSpells.lines[line].iconSpec:SetTexture( module.db.specIcons[ module.db.specByClass[class][j - 2] ] or "" )
							end
							
							if CLASS_ICON_TCOORDS[class] then
								self.colsSpells.lines[line].iconClass:SetTexture("Interface\\GLUES\\CHARACTERCREATE\\UI-CHARACTERCREATE-CLASSES")
								self.colsSpells.lines[line].iconClass:SetTexCoord(unpack(CLASS_ICON_TCOORDS[class]))
							else
								self.colsSpells.lines[line].iconClass:SetTexture("")
							end
							
							for k=1,10 do
								self.colsSpells.lines[line].chk[k]:SetChecked(false)
							end
							local checked = VExRT.ExCD2.CDECol[spellData[j][1]..";"..(j-2)] or module.db.def_col[spellData[j][1]..";"..(j-2)] or 1
							self.colsSpells.lines[line].chk[checked]:SetChecked(true)
							
							self.colsSpells.lines[line].spellID = spellData[j][1]
							self.colsSpells.lines[line].specNum = j-2
						end
					end
				end
			end
		end
		for i=line+1,#self.colsSpells.lines do
			self.colsSpells.lines[i]:Hide()
		end
	end
	self.colsSpells:SetScript("OnShow",function(self)
		local count = 0
		for i=1,#module.db.spellDB do
			local spellData = module.db.spellDB[i]
			if VExRT_CDE[ spellData[1] ] then
				local class = spellData[2]
				local specsCount = module.db.specByClass[class] and #module.db.specByClass[class] or 1
				for j=3,3+specsCount do
					if spellData[j] then
						count =  count + 1
					end
				end
			end
		end
	
		self.ScrollBar:SetMinMaxValues(1,max(1,count+1-20))
		ColsSpellsUpdate()
	end)
	self.colsSpells:SetScript("OnMouseWheel", function(self, delta)
		delta = -delta
		local current = module.options.colsSpells.ScrollBar:GetValue()
		local min_,max_ = module.options.colsSpells.ScrollBar:GetMinMaxValues()
		current = current + delta
		if current > max_ then
			current = max_
		elseif current < min_ then
			current = min_
		end
		module.options.colsSpells.ScrollBar:SetValue(current)
	end)
	
	self.colsSpells.ScrollBar = ExRT.lib.CreateScrollBar2(self.colsSpells,18,self.spellsPerPage*31-2,-1,-3,1,21,"TOPRIGHT")
	self.colsSpells.ScrollBar:SetScript("OnValueChanged",ColsSpellsUpdate)
	self.colsSpells.ScrollBar:SetObeyStepOnDrag(true)
	
	self.colsSpells.lines = {}
	local function ColsSpellsSpellTooltipOnEnter(self)
		ExRT.lib.OnEnterHyperLinkTooltip(self,self:GetParent().link)
	end
	local function ColsSpellsSpellCheckboxClick(self)
		for j=1,10 do
			if j ~= self._i then
				self.array[j]:SetChecked(false)
			end
		end
		VExRT.ExCD2.CDECol[self.main.spellID..";"..self.main.specNum] = self._i
	end
	for i=1,22 do
		self.colsSpells.lines[i] = CreateFrame("Frame",nil,self.colsSpells.C)
		self.colsSpells.lines[i]:SetPoint("TOPLEFT",5,-3-(i-1)*24)
		self.colsSpells.lines[i]:SetSize(577,24)
		
		self.colsSpells.lines[i].icon = self.colsSpells.lines[i]:CreateTexture(nil, "ARTWORK")
		self.colsSpells.lines[i].icon:SetSize(24,24)
		self.colsSpells.lines[i].icon:SetPoint("TOPLEFT", 4, 0)
		
		self.colsSpells.lines[i].tooltipFrame = CreateFrame("Frame",nil,self.colsSpells.lines[i])
		self.colsSpells.lines[i].tooltipFrame:SetSize(150,24) 
		self.colsSpells.lines[i].tooltipFrame:SetPoint("TOPLEFT", 30, 0)
		self.colsSpells.lines[i].tooltipFrame:SetScript("OnEnter", ColsSpellsSpellTooltipOnEnter)
		self.colsSpells.lines[i].tooltipFrame:SetScript("OnLeave", GameTooltip_Hide)
		
		self.colsSpells.lines[i].spellName = ExRT.lib.CreateText(self.colsSpells.lines[i],155,24,nil,30,0,nil,nil,ExRT.mds.defFont,12,nil,nil,nil,nil,nil,1)
	
		self.colsSpells.lines[i].iconClass = self.colsSpells.lines[i]:CreateTexture(nil, "ARTWORK")
		self.colsSpells.lines[i].iconClass:SetSize(18,18)
		self.colsSpells.lines[i].iconClass:SetPoint("TOPLEFT", 180, -3)
		
		self.colsSpells.lines[i].iconSpec = self.colsSpells.lines[i]:CreateTexture(nil, "ARTWORK")
		self.colsSpells.lines[i].iconSpec:SetSize(18,18)
		self.colsSpells.lines[i].iconSpec:SetPoint("TOPLEFT", 200, -3)
		
		self.colsSpells.lines[i].chk = {}
		for j=1,10 do
			self.colsSpells.lines[i].chk[j] = ExRT.lib.CreateCheckBox(self.colsSpells.lines[i],nil,230 + (j-1) * 25,3,"",nil,j)
			self.colsSpells.lines[i].chk[j].array = self.colsSpells.lines[i].chk
			self.colsSpells.lines[i].chk[j]._i = j
			self.colsSpells.lines[i].chk[j].main = self.colsSpells.lines[i]
			self.colsSpells.lines[i].chk[j]:SetScript("OnClick",ColsSpellsSpellCheckboxClick)
		end
	end
	

	--> OPTIONS TAB2: Customize
	self.optColHeader = ExRT.lib.CreateText(self.tab.tabs[2],560,20,nil,15,-8,nil,nil,nil,nil,ExRT.L.cd2ColSet)
	
	function self:selectColumnTab()
		local i = self and self.colID or module.options.optColTabs.selected
		module.options.optColTabs.selected = i
		module.options.optColTabs:UpdateTabs()
		
		local isGeneralTab = i == (module.db.maxColumns + 1)
		
		if isGeneralTab then
			VExRT.ExCD2.colSet[i].frameGeneral = nil
			VExRT.ExCD2.colSet[i].iconGeneral = nil
			VExRT.ExCD2.colSet[i].textureGeneral = nil
			VExRT.ExCD2.colSet[i].fontGeneral = nil
			VExRT.ExCD2.colSet[i].textGeneral = nil
			VExRT.ExCD2.colSet[i].methodsGeneral = nil
		end

		module.options.optColSet.chkEnable:SetChecked(VExRT.ExCD2.colSet[i].enabled)
		module.options.optColSet.chkGeneral:SetChecked(VExRT.ExCD2.colSet[i].frameGeneral)
		
		module.options.optColSet.sliderLinesNum:SetValue(VExRT.ExCD2.colSet[i].frameLines or module.db.colsDefaults.frameLines)
		module.options.optColSet.sliderAlpha:SetValue(VExRT.ExCD2.colSet[i].frameAlpha or module.db.colsDefaults.frameAlpha)
		module.options.optColSet.sliderScale:SetValue(VExRT.ExCD2.colSet[i].frameScale or module.db.colsDefaults.frameScale)
		module.options.optColSet.sliderWidth:SetValue(VExRT.ExCD2.colSet[i].frameWidth or module.db.colsDefaults.frameWidth)
		module.options.optColSet.sliderColsInCol:SetValue(VExRT.ExCD2.colSet[i].frameColumns or module.db.colsDefaults.frameColumns)
		module.options.optColSet.sliderBetweenLines:SetValue(VExRT.ExCD2.colSet[i].frameBetweenLines or module.db.colsDefaults.frameBetweenLines)
		module.options.optColSet.sliderBlackBack:SetValue(VExRT.ExCD2.colSet[i].frameBlackBack or module.db.colsDefaults.frameBlackBack)
		
		module.options.optColSet.chkGeneral:doAlphas()
		
		module.options.optColSet.sliderHeight:SetValue(VExRT.ExCD2.colSet[i].iconSize or module.db.colsDefaults.iconSize)
		module.options.optColSet.chkGray:SetChecked(VExRT.ExCD2.colSet[i].iconGray)
		module.options.optColSet.chkCooldown:SetChecked(VExRT.ExCD2.colSet[i].methodsCooldown)	
		module.options.optColSet.chkGeneralIcons:SetChecked(VExRT.ExCD2.colSet[i].iconGeneral)
		do
			local defIconPos = VExRT.ExCD2.colSet[i].iconPosition or module.db.colsDefaults.iconPosition
			module.options.optColSet.dropDownIconPos:SetText( module.options.optColSet.dropDownIconPos.PosNames[defIconPos])	
		end
		
		module.options.optColSet.chkGeneralIcons:doAlphas()
		
		do
			local texturePos = nil
			for j=1,#ExRT.mds.textureList do
				if ExRT.mds.textureList[j] == (VExRT.ExCD2.colSet[i].textureFile or ExRT.mds.barImg) then
					texturePos = j
					break
				end
			end
			if not texturePos and VExRT.ExCD2.colSet[i].textureFile then
				texturePos = select(3,string.find(VExRT.ExCD2.colSet[i].textureFile,"\\([^\\]*)$"))
			end
			texturePos = texturePos or "Standart"
			module.options.optColSet.dropDownTexture:SetText(ExRT.L.cd2OtherSetTexture.." ["..texturePos.."]")
		end
		module.options.optColSet.colorPickerBorder.color:SetTexture(VExRT.ExCD2.colSet[i].textureBorderColorR or module.db.colsDefaults.textureBorderColorR,VExRT.ExCD2.colSet[i].textureBorderColorG or module.db.colsDefaults.textureBorderColorG,VExRT.ExCD2.colSet[i].textureBorderColorB or module.db.colsDefaults.textureBorderColorB, VExRT.ExCD2.colSet[i].textureBorderColorA or module.db.colsDefaults.textureBorderColorA)
		module.options.optColSet.sliderBorderSize:SetValue(VExRT.ExCD2.colSet[i].textureBorderSize or module.db.colsDefaults.textureBorderSize)
		module.options.optColSet.chkAnimation:SetChecked(VExRT.ExCD2.colSet[i].textureAnimation)
		module.options.optColSet.chkGeneralColorize:SetChecked(VExRT.ExCD2.colSet[i].textureGeneral)
		
		module.options.optColSet.chkGeneralColorize:doAlphas()
			
		do
			local FontNameForDropDown = select(3,string.find(VExRT.ExCD2.colSet[i].fontName or module.db.colsDefaults.fontName,"\\([^\\]*)$"))
			module.options.optColSet.dropDownFont:SetText( (FontNameForDropDown or VExRT.ExCD2.colSet[i].fontName or module.db.colsDefaults.fontName or "?") )
		end
		module.options.optColSet.sliderFont:SetValue(VExRT.ExCD2.colSet[i].fontSize or module.db.colsDefaults.fontSize)
		module.options.optColSet.chkFontOutline:SetChecked(VExRT.ExCD2.colSet[i].fontOutline)
		module.options.optColSet.chkFontShadow:SetChecked(VExRT.ExCD2.colSet[i].fontShadow)
		do
			module.options.optColSet.chkFontOtherAvailable:SetChecked(VExRT.ExCD2.colSet[i].fontOtherAvailable)
			module.options.fontOtherAvailable(VExRT.ExCD2.colSet[i].fontOtherAvailable)
			if VExRT.ExCD2.colSet[i].fontOtherAvailable then
				module.options.optColSet.nowFont = "fontLeft"
			else
				module.options.optColSet.nowFont = "font"
			end
			module.options.optColSet.fontsTab.selectFunc(module.options.optColSet.fontsTab.tabs[1].button)
		end
		module.options.optColSet.chkGeneralFont:SetChecked(VExRT.ExCD2.colSet[i].fontGeneral)
		
		module.options.optColSet.chkGeneralFont:doAlphas()
		
		module.options.optColSet.textLeftTemEdit:SetText(VExRT.ExCD2.colSet[i].textTemplateLeft or module.db.colsDefaults.textTemplateLeft)
		module.options.optColSet.textRightTemEdit:SetText(VExRT.ExCD2.colSet[i].textTemplateRight or module.db.colsDefaults.textTemplateRight)
		module.options.optColSet.textCenterTemEdit:SetText(VExRT.ExCD2.colSet[i].textTemplateCenter or module.db.colsDefaults.textTemplateCenter)
		module.options.optColSet.chkIconName:SetChecked(VExRT.ExCD2.colSet[i].textIconName)
		module.options.optColSet.chkGeneralText:SetChecked(VExRT.ExCD2.colSet[i].textGeneral)
		
		module.options.optColSet.chkGeneralText:doAlphas()

		module.options.optColSet.chkShowOnlyOnCD:SetChecked(VExRT.ExCD2.colSet[i].methodsShownOnCD)
		module.options.optColSet.chkBotToTop:SetChecked(VExRT.ExCD2.colSet[i].frameAnchorBottom)
		module.options.optColSet.chkGeneralMethods:SetChecked(VExRT.ExCD2.colSet[i].methodsGeneral)
		do
			local defStyleAnimation = VExRT.ExCD2.colSet[i].methodsStyleAnimation or module.db.colsDefaults.methodsStyleAnimation
			module.options.optColSet.dropDownStyleAnimation:SetText( module.options.optColSet.dropDownStyleAnimation.Styles[defStyleAnimation])
			local defTimeLineAnimation = VExRT.ExCD2.colSet[i].methodsTimeLineAnimation or module.db.colsDefaults.methodsTimeLineAnimation
			module.options.optColSet.dropDownTimeLineAnimation:SetText(module.options.optColSet.dropDownTimeLineAnimation.Styles[defTimeLineAnimation])	
		end
		module.options.optColSet.chkIconTooltip:SetChecked(VExRT.ExCD2.colSet[i].methodsIconTooltip)
		module.options.optColSet.chkLineClick:SetChecked(VExRT.ExCD2.colSet[i].methodsLineClick)

		module.options.optColSet.chkGeneralMethods:doAlphas()

		ExRT.lib.ShowOrHide(module.options.optColSet.chkEnable,not isGeneralTab)
		ExRT.lib.ShowOrHide(module.options.optColSet.chkGeneral,not isGeneralTab)

		ExRT.lib.ShowOrHide(module.options.optColSet.chkGeneralIcons,not isGeneralTab)
		ExRT.lib.ShowOrHide(module.options.optColSet.chkGeneralColorize,not isGeneralTab)
		ExRT.lib.ShowOrHide(module.options.optColSet.chkGeneralFont,not isGeneralTab)
		ExRT.lib.ShowOrHide(module.options.optColSet.chkGeneralText,not isGeneralTab)
		ExRT.lib.ShowOrHide(module.options.optColSet.chkGeneralMethods,not isGeneralTab)
		
		module.options.showColorFrame(module.options.colorSetupFrame)
		
		if self then
			module.options.optColSet.templateRestore:Hide()
		end
	end

	self.optColSet = {}
	do
		local tmpArr = {}
		for i=1,module.db.maxColumns do
			tmpArr[i] = tostring(i)
		end
		tmpArr[module.db.maxColumns+1] = ExRT.L.cd2GeneralSet
		self.optColTabs = ExRT.lib.CreateTabFrame(self.tab.tabs[2],603,417,5,-50,module.db.maxColumns+1,module.db.maxColumns+1,unpack(tmpArr))
	end
	for i=1,module.db.maxColumns+1 do
		self.optColTabs.tabs[i].button.colID = i
		self.optColTabs.tabs[i].button:SetScript("OnClick", self.selectColumnTab)
	end

	 
	self.optColSet.superTabFrame = ExRT.lib.CreateScrollTabsFrame(self.optColTabs,"TOP",0,-5,590,410,true,ExRT.L.cd2OtherSetTabNameGeneral,ExRT.L.cd2OtherSetTabNameIcons,ExRT.L.cd2OtherSetTabNameColors,ExRT.L.cd2OtherSetTabNameFont,ExRT.L.cd2OtherSetTabNameText,ExRT.L.cd2OtherSetTabNameOther,ExRT.L.cd2OtherSetTabNameTemplate)
	
	self.optColSet.chkEnable = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[1],nil,5,-5,"|cff00ff00 >>>"..ExRT.L.senable.."<<<")
	self.optColSet.chkEnable:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].enabled = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].enabled = nil
		end
		module:ReloadAllSplits()
	end)
	
	self.optColSet.chkGeneral = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[1],"TOPRIGHT",-5,-5,ExRT.L.cd2ColSetGeneral,nil,nil,true)
	self.optColSet.chkGeneral:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameGeneral = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameGeneral = nil
		end
		module:ReloadAllSplits()
		self:doAlphas()
	end)
	function self.optColSet.chkGeneral:doAlphas()
		ExRT.lib.SetAlphas(VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameGeneral and 0.5 or 1,module.options.optColSet.sliderLinesNum,module.options.optColSet.sliderAlpha,module.options.optColSet.sliderScale,module.options.optColSet.sliderWidth,module.options.optColSet.sliderColsInCol,module.options.optColSet.sliderBetweenLines,module.options.optColSet.sliderBlackBack,module.options.optColSet.butToCenter)	
	end
	
	self.optColSet.sliderLinesNum = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[1],300,15,0,-50,1,module.db.maxLinesInCol,ExRT.L.cd2lines,15,"TOP")
	self.optColSet.sliderLinesNum:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameLines = event
		self.tooltipText = event
		self:tooltipReload(self)
		module:ReloadAllSplits()		
	end)
	
	self.optColSet.sliderAlpha = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[1],300,15,0,-120,0,100,ExRT.L.cd2alpha,nil,"TOP")
	self.optColSet.sliderAlpha:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameAlpha = event
		self.tooltipText = event
		self:tooltipReload(self)
		module:ReloadAllSplits()
	end)
	
	self.optColSet.sliderScale = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[1],300,15,0,-155,5,200,ExRT.L.cd2scale,100,"TOP")
	self.optColSet.sliderScale:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameScale = event
		self.tooltipText = event
		self:tooltipReload(self)
		module:ReloadAllSplits("ScaleFix")
	end)
	
	self.optColSet.sliderWidth = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[1],300,15,0,-85,1,400,ExRT.L.cd2width,130,"TOP")
	self.optColSet.sliderWidth:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameWidth = event
		self.tooltipText = event
		self:tooltipReload(self)
		module:ReloadAllSplits()
	end)
	
	self.optColSet.sliderColsInCol = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[1],300,15,0,-190,1,module.db.maxLinesInCol,ExRT.L.cd2ColSetColsInCol,1,"TOP")
	self.optColSet.sliderColsInCol:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameColumns = event
		self.tooltipText = event
		self:tooltipReload(self)
		module:ReloadAllSplits()
	end)
	
	self.optColSet.sliderBetweenLines = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[1],300,15,0,-225,0,20,ExRT.L.cd2ColSetBetweenLines,0,"TOP")
	self.optColSet.sliderBetweenLines:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameBetweenLines = event
		self.tooltipText = event
		self:tooltipReload(self)
		module:ReloadAllSplits()
	end)
	
	self.optColSet.sliderBlackBack = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[1],300,15,0,-260,0,100,ExRT.L.cd2BlackBack,0,"TOP")
	self.optColSet.sliderBlackBack:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameBlackBack = event
		self.tooltipText = event
		self:tooltipReload(self)
		module:ReloadAllSplits()
	end)

	self.optColSet.butToCenter = ExRT.lib.CreateButton(self.optColSet.superTabFrame.tab[1],200,22,"TOP",0,-295,ExRT.L.cd2ColSetResetPos)
	self.optColSet.butToCenter:SetScript("OnClick", function(self) 
		if (module.db.maxColumns + 1) == module.options.optColTabs.selected then
			module.frame:ClearAllPoints()
			module.frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
		else
			module.frame.colFrame[module.options.optColTabs.selected]:ClearAllPoints()
			module.frame.colFrame[module.options.optColTabs.selected]:SetPoint("CENTER",UIParent,"CENTER",0,0)
		end
	end) 

	--> Icon and height options
	
	self.optColSet.sliderHeight = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[2],300,15,0,-50,6,128,ExRT.L.cd2OtherSetIconSize,nil,"TOP")
	self.optColSet.sliderHeight:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].iconSize = event
		module:ReloadAllSplits()
		self.tooltipText = event
		self:tooltipReload(self)
	end)
	
	self.optColSet.chkGray = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[2],nil,10,-115,ExRT.L.cd2graytooltip)
	self.optColSet.chkGray:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].iconGray = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].iconGray = nil
		end
		module:ReloadAllSplits()
	end)
	
	self.optColSet.textIconPos = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[2],200,20,"TOPLEFT",15,-88,nil,nil,nil,nil,ExRT.L.cd2OtherSetIconPosition..":")
	self.optColSet.dropDownIconPos = ExRT.lib.CreateDropDown(self.optColSet.superTabFrame.tab[2],"TOPLEFT",150,-85,170)
	self.optColSet.dropDownIconPos.PosNames = {ExRT.L.cd2OtherSetIconPositionLeft,ExRT.L.cd2OtherSetIconPositionRight,ExRT.L.cd2OtherSetIconPositionNo}
	UIDropDownMenu_Initialize(self.optColSet.dropDownIconPos, function(self, level, menuList)
		ExRT.mds.FixDropDown(170)
		local info = UIDropDownMenu_CreateInfo()
		for key,val in pairs(self.PosNames) do
			info.text,info.notCheckable,info.minWidth,info.justifyH = val,1,170,"LEFT"
			info.menuList, info.hasArrow, info.arg1 = key, false, key
			info.func = function (slf,nv)
				CloseDropDownMenus()
				VExRT.ExCD2.colSet[module.options.optColTabs.selected].iconPosition = nv
				module:ReloadAllSplits()
				self:SetText(module.options.optColSet.dropDownIconPos.PosNames[nv])
			end
			UIDropDownMenu_AddButton(info)
		end
	end)
	
	self.optColSet.chkCooldown = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[2],nil,10,-140,ExRT.L.cd2ColSetMethodCooldown)
	self.optColSet.chkCooldown:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsCooldown = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsCooldown = nil
		end
		module:ReloadAllSplits()
	end)
	
	self.optColSet.chkGeneralIcons = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[2],"TOPRIGHT",-5,-5,ExRT.L.cd2ColSetGeneral,nil,nil,true)
	self.optColSet.chkGeneralIcons:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].iconGeneral = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].iconGeneral = nil
		end
		module:ReloadAllSplits()
		self:doAlphas()
	end)
	function self.optColSet.chkGeneralIcons:doAlphas()
		ExRT.lib.SetAlphas(VExRT.ExCD2.colSet[module.options.optColTabs.selected].iconGeneral and 0.5 or 1,module.options.optColSet.chkGray,module.options.optColSet.sliderHeight,module.options.optColSet.dropDownIconPos,module.options.optColSet.chkCooldown)
	end
	
	--> Texture and colors Options
	
	local function dropDownTextureButtonClick(self,arg,name)
		ExRT.lib.ScrollDropDown.Close()
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureFile = arg
		module:ReloadAllSplits()
		module.options.optColSet.dropDownTexture:SetText(ExRT.L.cd2OtherSetTexture.." ["..name.."]")
	end
	
	self.optColSet.textDDTexture = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[3],200,20,"TOPLEFT",15,-38,nil,nil,nil,nil,ExRT.L.cd2OtherSetTexture..":")
	self.optColSet.dropDownTexture = ExRT.lib.CreateScrollDropDown(self.optColSet.superTabFrame.tab[3],nil,150,-35,175,nil,15)
	for i=1,#ExRT.mds.textureList do
		self.optColSet.dropDownTexture.List[i] = {}
		local info = self.optColSet.dropDownTexture.List[i]
		info.text = i
		info.arg1 = ExRT.mds.textureList[i]
		info.arg2 = i
		info.func = dropDownTextureButtonClick
		info.texture = ExRT.mds.textureList[i]
		info.justifyH = "CENTER" 
	end
	if LibStub then
		local media = LibStub("LibSharedMedia-3.0")
		if media then
			local barsList = media:HashTable("statusbar")
			if barsList then
				local count = #self.optColSet.dropDownTexture.List
				for key,texture in pairs(barsList) do
					count = count + 1
					self.optColSet.dropDownTexture.List[count] = {}
					local info = self.optColSet.dropDownTexture.List[count]
					
					info.text = key
					info.arg1 = texture
					info.arg2 = key
					info.func = dropDownTextureButtonClick
					info.texture = texture
					info.justifyH = "CENTER" 
				end
			end
		end
	end
	
	self.optColSet.textDDBorder = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[3],200,20,"TOPLEFT",15,-68,nil,nil,nil,nil,ExRT.L.cd2OtherSetBorder..":")
	self.optColSet.sliderBorderSize = ExRT.lib.CreateSlider(self.optColSet.superTabFrame.tab[3],150,15,172,-70,0,20,"",0,"TOPLEFT")
	self.optColSet.sliderBorderSize:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderSize = event
		self.tooltipText = event
		self:tooltipReload(self)
		module:ReloadAllSplits()
	end)
	self.optColSet.colorPickerBorder = ExRT.lib.CreateColorPickButton(self.optColSet.superTabFrame.tab[3],20,20,nil,337,-68)
	self.optColSet.colorPickerBorder:SetScript("OnClick",function (self)
		ColorPickerFrame.previousValues = {VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorR or module.db.colsDefaults.textureBorderColorR,VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorG or module.db.colsDefaults.textureBorderColorG,VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorB or module.db.colsDefaults.textureBorderColorB, VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorA or module.db.colsDefaults.textureBorderColorA}
		ColorPickerFrame.hasOpacity = true
		local nilFunc = ExRT.NULLfunc
		local function changedCallback(restore)
			local newR, newG, newB, newA
			if restore then
				newR, newG, newB, newA = unpack(restore)
			else
				newA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB()
			end
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorR = newR
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorG = newG
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorB = newB
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorA = newA
			module:ReloadAllSplits()
			
			self.color:SetTexture(newR,newG,newB,newA)
		end
		ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = nilFunc, nilFunc, nilFunc
		ColorPickerFrame.opacity = VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorA or module.db.colsDefaults.textureBorderColorA
		ColorPickerFrame:SetColorRGB(VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorR or module.db.colsDefaults.textureBorderColorR,VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorG or module.db.colsDefaults.textureBorderColorG,VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureBorderColorB or module.db.colsDefaults.textureBorderColorB)
		ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = changedCallback, changedCallback, changedCallback
		ColorPickerFrame:Show()
		ExRT.lib.ShitInterfaceLibFix(ColorPickerFrame)
	end)
		
	self.optColSet.chkAnimation = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[3],nil,10,-95,ExRT.L.cd2OtherSetAnimation)
	self.optColSet.chkAnimation:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureAnimation = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureAnimation = nil
		end
		module:ReloadAllSplits()
	end)

	
	self.colorSetupFrame = CreateFrame("Frame",nil,self.optColSet.superTabFrame.tab[3])
	self.colorSetupFrame:SetSize(self.optColSet.superTabFrame.tab[3]:GetWidth(),270)
	self.colorSetupFrame:SetPoint("TOPLEFT",0,-110)
		
	self.colorSetupFrame.backAlpha = ExRT.lib.CreateSlider(self.colorSetupFrame,250,15,0,-163,0,100,ExRT.L.cd2OtherSetColorFrameAlpha,100,"TOP")
	self.colorSetupFrame.backCDAlpha = ExRT.lib.CreateSlider(self.colorSetupFrame,250,15,0,-198,0,100,ExRT.L.cd2OtherSetColorFrameAlphaCD,100,"TOP")
	self.colorSetupFrame.backCooldownAlpha = ExRT.lib.CreateSlider(self.colorSetupFrame,250,15,0,-233,0,100,ExRT.L.cd2OtherSetColorFrameAlphaCooldown,100,"TOP")
	
	self.colorSetupFrame.backAlpha.inOptName = "textureAlphaBackground"
	self.colorSetupFrame.backCDAlpha.inOptName = "textureAlphaTimeLine"
	self.colorSetupFrame.backCooldownAlpha.inOptName = "textureAlphaCooldown"
	
	local function colorPickerButtonClick(self)
		ColorPickerFrame.previousValues = {VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."R"] or module.db.colsDefaults[self.inOptName.."R"],VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."G"] or module.db.colsDefaults[self.inOptName.."G"],VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."B"] or module.db.colsDefaults[self.inOptName.."B"], 1}
		local nilFunc = ExRT.NULLfunc
		local function changedCallback(restore)
			local newR, newG, newB, newA
			if restore then
				newR, newG, newB, newA = unpack(restore)
			else
				newA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB()
			end
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."R"] = newR
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."G"] = newG
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."B"] = newB
			module:ReloadAllSplits()
			
			self.color:SetTexture(newR,newG,newB,1)
		end
		ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = nilFunc, nilFunc, nilFunc
		ColorPickerFrame:SetColorRGB(VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."R"] or module.db.colsDefaults[self.inOptName.."R"],VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."G"] or module.db.colsDefaults[self.inOptName.."G"],VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName.."B"] or module.db.colsDefaults[self.inOptName.."B"])
		ColorPickerFrame.func, ColorPickerFrame.cancelFunc = changedCallback, changedCallback
		ColorPickerFrame:Show()
		ExRT.lib.ShitInterfaceLibFix(ColorPickerFrame)
	end

	local function colorPickerSliderValue(self,newval)
		VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName] = newval / 100
		module:ReloadAllSplits()
		self.tooltipText = ExRT.mds.Round(newval)
		self:tooltipReload(self)
	end

	local function colorPickerCheckBoxClick(self)
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName] = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.inOptName] = nil
		end
		module:ReloadAllSplits()
	end
	
	local colorSetupFrameColorsNames_TopText = {ExRT.L.cd2OtherSetColorFrameTopText,ExRT.L.cd2OtherSetColorFrameTopBack,ExRT.L.cd2OtherSetColorFrameTopTimeLine}
	for i=1,3 do
		self.colorSetupFrame["topText"..i] = ExRT.lib.CreateText(self.colorSetupFrame,50,20,nil,225+(i-1)*40,-15,"CENTER",nil,nil,12,colorSetupFrameColorsNames_TopText[i],nil,1,1,1,1)
	end
	
	local colorSetupFrameColorsNames_Text = {ExRT.L.cd2OtherSetColorFrameText..":",ExRT.L.cd2OtherSetColorFrameActive..":",ExRT.L.cd2OtherSetColorFrameCooldown..":",ExRT.L.cd2OtherSetColorFrameCast..":"}
	for j=1,4 do
		for i=1,3 do
			self.colorSetupFrame["color"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]] = ExRT.lib.CreateColorPickButton(self.colorSetupFrame,20,20,nil,240+(i-1)*40,-35-(j-1)*20)
			self.colorSetupFrame["color"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]].inOptName = "textureColor"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]
			self.colorSetupFrame["color"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]]:SetScript("OnClick",colorPickerButtonClick)
		end
		self.colorSetupFrame["text"..colorSetupFrameColorsNames[j]] = ExRT.lib.CreateText(self.colorSetupFrame,210,20,nil,10,-35-(j-1)*20,"RIGHT",nil,nil,12,colorSetupFrameColorsNames_Text[j],nil,1,1,1,1)
	end
	
	local checksInOptNames = {"textureClassText","textureClassBackground","textureClassTimeLine"}
	for i=1,3 do
		self.colorSetupFrame["colorClass"..colorSetupFrameColorsObjectsNames[i]] = ExRT.lib.CreateCheckBox(self.colorSetupFrame,nil,234+(i-1)*40,-110,"")
		self.colorSetupFrame["colorClass"..colorSetupFrameColorsObjectsNames[i]].inOptName = checksInOptNames[i]
		self.colorSetupFrame["colorClass"..colorSetupFrameColorsObjectsNames[i]]:SetScript("OnClick",colorPickerCheckBoxClick)
	end
	self.colorSetupFrame["textClass"] = ExRT.lib.CreateText(self.colorSetupFrame,210,20,nil,10,-115,"RIGHT",nil,nil,12,ExRT.L.cd2OtherSetColorFrameClass..":",nil,1,1,1,1)
	
	self.colorSetupFrame.backAlpha:SetScript("OnValueChanged",colorPickerSliderValue)
	self.colorSetupFrame.backCDAlpha:SetScript("OnValueChanged",colorPickerSliderValue)
	self.colorSetupFrame.backCooldownAlpha:SetScript("OnValueChanged",colorPickerSliderValue)
	
	self.colorSetupFrame.resetButton = ExRT.lib.CreateButton(self.colorSetupFrame,140,22,"TOP",-71,-257,ExRT.L.cd2OtherSetColorFrameReset)
	self.colorSetupFrame.softenButton = ExRT.lib.CreateButton(self.colorSetupFrame,140,22,"TOP",71,-257,ExRT.L.cd2OtherSetColorFrameSoften)
	
	self.colorSetupFrame.softenButton:SetScript("OnClick",function()
		local tmpColors = {"R","G","B"}
		for j=1,4 do
			for i=1,3 do
				local maxColor = 0
				for n=1,3 do
					local color = VExRT.ExCD2.colSet[module.options.optColTabs.selected]["textureColor"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]..tmpColors[n]] or module.db.colsDefaults["textureColor"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]..tmpColors[n]]
					maxColor = max(maxColor,color)
				end
				for n=1,3 do
					local color = VExRT.ExCD2.colSet[module.options.optColTabs.selected]["textureColor"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]..tmpColors[n]] or module.db.colsDefaults["textureColor"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]..tmpColors[n]]
					if color < maxColor then
						VExRT.ExCD2.colSet[module.options.optColTabs.selected]["textureColor"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]..tmpColors[n]] = color + (maxColor - color) / 2
					end
				end
			end
		end
		module.options.showColorFrame(module.options.colorSetupFrame)
		module:ReloadAllSplits()
	end)
	
	self.colorSetupFrame.resetButton:SetScript("OnClick",function()
		local tmpColors = {"R","G","B"}
		for j=1,4 do
			for i=1,3 do
				for n=1,3 do
					VExRT.ExCD2.colSet[module.options.optColTabs.selected]["textureColor"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]..tmpColors[n]] = nil
				end
			end
		end
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureAlphaBackground = nil
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureAlphaTimeLine = nil
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureAlphaCooldown = nil
		for i=1,3 do
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][ checksInOptNames[i] ] = nil
		end
		module.options.showColorFrame(module.options.colorSetupFrame)
		module:ReloadAllSplits()
	end)
	
	function self:showColorFrame()
		for j=1,4 do
			for i=1,3 do
				local this = module.options.colorSetupFrame["color"..colorSetupFrameColorsObjectsNames[i]..colorSetupFrameColorsNames[j]]
				this.color:SetTexture(VExRT.ExCD2.colSet[module.options.optColTabs.selected][this.inOptName.."R"] or module.db.colsDefaults[this.inOptName.."R"],VExRT.ExCD2.colSet[module.options.optColTabs.selected][this.inOptName.."G"] or module.db.colsDefaults[this.inOptName.."G"],VExRT.ExCD2.colSet[module.options.optColTabs.selected][this.inOptName.."B"] or module.db.colsDefaults[this.inOptName.."B"],1)
			end
		end
		for i=1,3 do
			module.options.colorSetupFrame["colorClass"..colorSetupFrameColorsObjectsNames[i]]:SetChecked( VExRT.ExCD2.colSet[module.options.optColTabs.selected][ checksInOptNames[i] ] )
		end

		self.backAlpha:SetValue((VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.backAlpha.inOptName] or module.db.colsDefaults[self.backAlpha.inOptName])*100)
		self.backCDAlpha:SetValue((VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.backCDAlpha.inOptName] or module.db.colsDefaults[self.backCDAlpha.inOptName])*100)
		self.backCooldownAlpha:SetValue((VExRT.ExCD2.colSet[module.options.optColTabs.selected][self.backCooldownAlpha.inOptName] or module.db.colsDefaults[self.backCooldownAlpha.inOptName])*100)
	end

	self.colorSetupFrame:SetScript("OnShow",self.showColorFrame)

	
	self.optColSet.chkGeneralColorize = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[3],"TOPRIGHT",-5,-5,ExRT.L.cd2ColSetGeneral,nil,nil,true)
	self.optColSet.chkGeneralColorize:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureGeneral = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureGeneral = nil
		end
		module:ReloadAllSplits()
		self:doAlphas()
	end)
	function self.optColSet.chkGeneralColorize:doAlphas()
		ExRT.lib.SetAlphas(VExRT.ExCD2.colSet[module.options.optColTabs.selected].textureGeneral and 0.5 or 1,module.options.optColSet.dropDownTexture,module.options.optColSet.chkAnimation,module.options.colorSetupFrame,module.options.optColSet.colorPickerBorder,module.options.optColSet.sliderBorderSize)
	end	

	--> Font Options
	self.optColSet.nowFont = "font"
	
	self.optColSet.fontsTab = ExRT.lib.CreateTabFrame(self.optColSet.superTabFrame.tab[4],375,160,5,-55,4,1,ExRT.L.cd2ColSetFontPosGeneral,ExRT.L.cd2ColSetFontPosRight,ExRT.L.cd2ColSetFontPosCenter,ExRT.L.cd2ColSetFontPosIcon)
	local function fontsTabButtonClick(self)
		local tabFrame = self.mainFrame
		tabFrame.selected = self.id
		tabFrame.UpdateTabs(tabFrame)
		
		module.options.optColSet.nowFont = self.fontMark
		
		local i = module.options.optColTabs.selected
		do
			local FontNameForDropDown = select(3,string.find(VExRT.ExCD2.colSet[i][self.fontMark.."Name"] or module.db.colsDefaults.fontName,"\\([^\\]*)$"))
			module.options.optColSet.dropDownFont:SetText(  (FontNameForDropDown or VExRT.ExCD2.colSet[i][self.fontMark.."Name"] or module.db.colsDefaults.fontName or "?") )
		end
		module.options.optColSet.sliderFont:SetValue(VExRT.ExCD2.colSet[i][self.fontMark.."Size"] or module.db.colsDefaults.fontSize)
		module.options.optColSet.chkFontOutline:SetChecked(VExRT.ExCD2.colSet[i][self.fontMark.."Outline"])
		module.options.optColSet.chkFontShadow:SetChecked(VExRT.ExCD2.colSet[i][self.fontMark.."Shadow"])
	end
	for i=1,4 do
		self.optColSet.fontsTab.tabs[i].button:SetScript("OnClick",fontsTabButtonClick)
	end
	local fontOtherAvailableTable = {"Left","Right","Center","Icon"}
	function self.fontOtherAvailable(isAvailable)
		if isAvailable then
			for i=2,4 do
				self.optColSet.fontsTab.tabs[i].button:Show()
			end
			self.optColSet.fontsTab.tabs[1].button:SetText(ExRT.L.cd2ColSetFontPosLeft)
			for i=1,4 do
				self.optColSet.fontsTab.tabs[i].button.fontMark = "font"..fontOtherAvailableTable[i]
			end
		else
			for i=2,4 do
				self.optColSet.fontsTab.tabs[i].button:Hide()
			end
			self.optColSet.fontsTab.tabs[1].button:SetText(ExRT.L.cd2ColSetFontPosGeneral)
			self.optColSet.fontsTab.tabs[1].button.fontMark = "font"
		end
		self.optColSet.fontsTab.resizeFunc(self.optColSet.fontsTab.tabs[1].button, 0, nil, nil, self.optColSet.fontsTab.tabs[1].button:GetFontString():GetStringWidth(), self.optColSet.fontsTab.tabs[1].button:GetFontString():GetStringWidth())
		fontsTabButtonClick(module.options.optColSet.fontsTab.tabs[1].button)
	end
	
	self.optColSet.chkFontOtherAvailable = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[4],nil,10,-220,ExRT.L.cd2ColSetFontOtherAvailable)
	self.optColSet.chkFontOtherAvailable:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].fontOtherAvailable = true --fontOtherAvailable
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].fontOtherAvailable = nil
		end
		module:ReloadAllSplits()
		module.options.fontOtherAvailable( self:GetChecked() )
	end)

	self.optColSet.sliderFont = ExRT.lib.CreateSlider(self.optColSet.fontsTab,300,15,0,-70,8,72,ExRT.L.cd2OtherSetFontSize,12,"TOP")
	self.optColSet.sliderFont:SetScript("OnValueChanged", function(self,event) 
		event = event - event%1
		VExRT.ExCD2.colSet[module.options.optColTabs.selected][module.options.optColSet.nowFont.."Size"] = event --fontSize
		module:ReloadAllSplits()
		self.tooltipText = event
		self:tooltipReload(self)
	end)

	self.optColSet.textDDFont = ExRT.lib.CreateText(self.optColSet.fontsTab,200,20,"TOPLEFT",15,-18,nil,nil,nil,nil,ExRT.L.cd2OtherSetFont..":")

	local function dropDownFontButtonClick(self,arg1,arg2)
		ExRT.lib.ScrollDropDown.Close()
		VExRT.ExCD2.colSet[module.options.optColTabs.selected][module.options.optColSet.nowFont.."Name"] = arg1 --fontName
		module:ReloadAllSplits()
		local FontNameForDropDown = select(3,string.find(arg1,"\\([^\\]*)$"))
		if arg2 <= #ExRT.mds.fontList then
			module.options.optColSet.dropDownFont:SetText(FontNameForDropDown or ExRT.mds.fontList[arg2])
		else
			module.options.optColSet.dropDownFont:SetText(FontNameForDropDown or arg2)
		end
	end
	
	self.optColSet.dropDownFont = ExRT.lib.CreateScrollDropDown(self.optColSet.fontsTab,nil,150,-15,175,350,10)
	for i=1,#ExRT.mds.fontList do
		self.optColSet.dropDownFont.List[i] = {}
		local info = self.optColSet.dropDownFont.List[i]
		info.text = ExRT.mds.fontList[i]
		info.arg1 = ExRT.mds.fontList[i]
		info.arg2 = i
		info.func = dropDownFontButtonClick
		info.font = ExRT.mds.fontList[i]
		info.justifyH = "CENTER" 
	end
	if LibStub then
		local media = LibStub("LibSharedMedia-3.0")
		if media then
			local fontList = media:HashTable("font")
			if fontList then
				local count = #self.optColSet.dropDownFont.List
				for key,font in pairs(fontList) do
					count = count + 1
					self.optColSet.dropDownFont.List[count] = {}
					local info = self.optColSet.dropDownFont.List[count]
					
					info.text = font
					info.arg1 = font
					info.arg2 = count
					info.func = dropDownFontButtonClick
					info.font = font
					info.justifyH = "CENTER" 
				end
			end
		end
	end
	

	self.optColSet.chkFontOutline = ExRT.lib.CreateCheckBox(self.optColSet.fontsTab,nil,10,-95,ExRT.L.cd2OtherSetOutline)
	self.optColSet.chkFontOutline:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][module.options.optColSet.nowFont.."Outline"] = true --fontOutline
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][module.options.optColSet.nowFont.."Outline"] = nil
		end
		module:ReloadAllSplits()
	end)
	
	self.optColSet.chkFontShadow = ExRT.lib.CreateCheckBox(self.optColSet.fontsTab,nil,10,-120,ExRT.L.cd2OtherSetFontShadow)
	self.optColSet.chkFontShadow:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][module.options.optColSet.nowFont.."Shadow"] = true -- fontShadow
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][module.options.optColSet.nowFont.."Shadow"] = nil
		end
		module:ReloadAllSplits()
	end)

	
	self.optColSet.chkGeneralFont = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[4],"TOPRIGHT",-5,-5,ExRT.L.cd2ColSetGeneral,nil,nil,true)
	self.optColSet.chkGeneralFont:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].fontGeneral = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].fontGeneral = nil
		end
		module:ReloadAllSplits()
		self:doAlphas()
	end)	
	function self.optColSet.chkGeneralFont:doAlphas()
		ExRT.lib.SetAlphas(VExRT.ExCD2.colSet[module.options.optColTabs.selected].fontGeneral and 0.5 or 1,module.options.optColSet.dropDownFont,module.options.optColSet.sliderFont,module.options.optColSet.chkFontOutline,module.options.optColSet.chkFontShadow)
	end
	
	--> Text options
	
	self.optColSet.textLeftTemText = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[5],200,20,"TOPLEFT",15,-43,nil,nil,nil,nil,ExRT.L.cd2ColSetTextLeft..":")
	self.optColSet.textLeftTemEdit = ExRT.lib.CreateEditBox(self.optColSet.superTabFrame.tab[5],220,24,nil,140,-40)
	self.optColSet.textLeftTemEdit:SetScript("OnTextChanged",function(self,isUser)
		if isUser then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textTemplateLeft = self:GetText()
			module:ReloadAllSplits()
		end
	end)

	self.optColSet.textRightTemText = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[5],200,20,"TOPLEFT",15,-68,nil,nil,nil,nil,ExRT.L.cd2ColSetTextRight..":")
	self.optColSet.textRightTemEdit = ExRT.lib.CreateEditBox(self.optColSet.superTabFrame.tab[5],220,24,nil,140,-65)
	self.optColSet.textRightTemEdit:SetScript("OnTextChanged",function(self,isUser)
		if isUser then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textTemplateRight = self:GetText()
			module:ReloadAllSplits()
		end
	end)
	
	self.optColSet.textCenterTemText = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[5],200,20,"TOPLEFT",15,-93,nil,nil,nil,nil,ExRT.L.cd2ColSetTextCenter..":")
	self.optColSet.textCenterTemEdit = ExRT.lib.CreateEditBox(self.optColSet.superTabFrame.tab[5],220,24,nil,140,-90)
	self.optColSet.textCenterTemEdit:SetScript("OnTextChanged",function(self,isUser)
		if isUser then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textTemplateCenter = self:GetText()
			module:ReloadAllSplits()
		end
	end)
	
	self.optColSet.textAllTemplates = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[5],400,200,"TOPLEFT",15,-115,nil,"TOP",nil,11,ExRT.L.cd2ColSetTextTooltip,nil,1,1,1)

	self.optColSet.textResetButton = ExRT.lib.CreateButton(self.optColSet.superTabFrame.tab[5],340,22,"TOP",0,-210,ExRT.L.cd2ColSetTextReset)
	self.optColSet.textResetButton:SetScript("OnClick", function(self)
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].textTemplateLeft = nil
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].textTemplateRight = nil
		VExRT.ExCD2.colSet[module.options.optColTabs.selected].textTemplateCenter = nil
		module:ReloadAllSplits()
		module.options.optColSet.textLeftTemEdit:SetText(module.db.colsDefaults.textTemplateLeft)
		module.options.optColSet.textRightTemEdit:SetText(module.db.colsDefaults.textTemplateRight)
		module.options.optColSet.textCenterTemEdit:SetText(module.db.colsDefaults.textTemplateCenter)
	end)
	
	self.optColSet.chkIconName = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[5],nil,10,-235,ExRT.L.cd2ColSetTextIconName)
	self.optColSet.chkIconName:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textIconName = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textIconName = nil
		end
		module:ReloadAllSplits()
	end)
	
	self.optColSet.chkGeneralText = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[5],"TOPRIGHT",-5,-5,ExRT.L.cd2ColSetGeneral,nil,nil,true)
	self.optColSet.chkGeneralText:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textGeneral = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].textGeneral = nil
		end
		module:ReloadAllSplits()
		self:doAlphas()
	end)
	function self.optColSet.chkGeneralText:doAlphas()
		ExRT.lib.SetAlphas(VExRT.ExCD2.colSet[module.options.optColTabs.selected].textGeneral and 0.5 or 1,module.options.optColSet.textLeftTemEdit,module.options.optColSet.textRightTemEdit,module.options.optColSet.textCenterTemEdit,module.options.optColSet.chkIconName)
	end

	--> Method options
	
	self.optColSet.chkShowOnlyOnCD = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[6],nil,10,-30,ExRT.L.cd2OtherSetOnlyOnCD)
	self.optColSet.chkShowOnlyOnCD:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsShownOnCD = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsShownOnCD = nil
		end
		module:ReloadAllSplits()
	end)
	
	self.optColSet.chkBotToTop = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[6],nil,10,-55,ExRT.L.cd2ColSetBotToTop)
	self.optColSet.chkBotToTop:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameAnchorBottom = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].frameAnchorBottom = nil
		end
		module:ReloadAllSplits()
	end)
	
	self.optColSet.textStyleAnimation = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[6],200,20,"TOPLEFT",15,-83,nil,nil,nil,nil,ExRT.L.cd2OtherSetStyleAnimation..":")
	self.optColSet.dropDownStyleAnimation = ExRT.lib.CreateDropDown(self.optColSet.superTabFrame.tab[6],"TOPLEFT",150,-80,170)
	self.optColSet.dropDownStyleAnimation.Styles = {ExRT.L.cd2OtherSetStyleAnimation1,ExRT.L.cd2OtherSetStyleAnimation2}
	UIDropDownMenu_Initialize(self.optColSet.dropDownStyleAnimation, function(self, level, menuList)
		ExRT.mds.FixDropDown(170)
		local info = UIDropDownMenu_CreateInfo()
		for key,val in pairs(self.Styles) do
			info.text,info.notCheckable,info.minWidth,info.justifyH = val,1,170,"LEFT"
			info.menuList, info.hasArrow, info.arg1 = key, false, key
			info.func = function (slf,nv)
				CloseDropDownMenus()
				VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsStyleAnimation = nv
				module:ReloadAllSplits()
				self:SetText(module.options.optColSet.dropDownStyleAnimation.Styles[nv])
			end
			UIDropDownMenu_AddButton(info)
		end
	end)
	
	self.optColSet.textTimeLineAnimation = ExRT.lib.CreateText(self.optColSet.superTabFrame.tab[6],200,20,"TOPLEFT",15,-113,nil,nil,nil,nil,ExRT.L.cd2OtherSetTimeLineAnimation..":")
	self.optColSet.dropDownTimeLineAnimation = ExRT.lib.CreateDropDown(self.optColSet.superTabFrame.tab[6],"TOPLEFT",150,-110,170)
	self.optColSet.dropDownTimeLineAnimation.Styles = {ExRT.L.cd2OtherSetTimeLineAnimation1,ExRT.L.cd2OtherSetTimeLineAnimation2}
	UIDropDownMenu_Initialize(self.optColSet.dropDownTimeLineAnimation, function(self, level, menuList)
		ExRT.mds.FixDropDown(170)
		local info = UIDropDownMenu_CreateInfo()
		for key,val in pairs(self.Styles) do
			info.text,info.notCheckable,info.minWidth,info.justifyH = val,1,170,"LEFT"
			info.menuList, info.hasArrow, info.arg1 = key, false, key
			info.func = function (slf,nv)
				CloseDropDownMenus()
				VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsTimeLineAnimation = nv
				module:ReloadAllSplits()
				self:SetText(module.options.optColSet.dropDownTimeLineAnimation.Styles[nv])
			end
			UIDropDownMenu_AddButton(info)
		end
	end)
	
	self.optColSet.chkIconTooltip = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[6],nil,10,-140,ExRT.L.cd2OtherSetIconToolip)
	self.optColSet.chkIconTooltip:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsIconTooltip = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsIconTooltip = nil
		end
		module:ReloadAllSplits()
	end)
		
	self.optColSet.chkLineClick = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[6],nil,10,-165,ExRT.L.cd2OtherSetLineClick)
	self.optColSet.chkLineClick:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsLineClick = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsLineClick = nil
		end
		module:ReloadAllSplits()
	end)
	

	self.optColSet.chkGeneralMethods = ExRT.lib.CreateCheckBox(self.optColSet.superTabFrame.tab[6],"TOPRIGHT",-5,-5,ExRT.L.cd2ColSetGeneral,nil,nil,true)
	self.optColSet.chkGeneralMethods:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsGeneral = true
		else
			VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsGeneral = nil
		end
		module:ReloadAllSplits()
		self:doAlphas()
	end)
	function self.optColSet.chkGeneralMethods:doAlphas()
		ExRT.lib.SetAlphas(VExRT.ExCD2.colSet[module.options.optColTabs.selected].methodsGeneral and 0.5 or 1,module.options.optColSet.chkShowOnlyOnCD,module.options.optColSet.chkBotToTop,module.options.optColSet.dropDownStyleAnimation,module.options.optColSet.dropDownTimeLineAnimation,module.options.optColSet.chkIconTooltip,module.options.optColSet.chkLineClick)
	end
	
	--> Templates Tab
	self.optColSet.templates = {}
	self.optColSet.templateData = {
		spells = {31821,62618,97462,20484,98008},
		spellsCD = {90,0,0,0,0},
		spellsDuration = {0,10,0,0,0},
		spellsDead = {nil,nil,true,nil,nil},
		spellsCast = {nil,nil,nil,6,nil},
		spellsClass = {"PALADIN","PRIEST","WARRIOR","DRUID","SHAMAN"},
		[1] = {
			iconSize = 16,
			optionAnimation = true,
			optionStyleAnimation = 1,
			optionTimeLineAnimation = 1,
			optionIconPosition = 1,
			optionGray = true,
			fontSize = 12,
			fontName = ExRT.mds.defFont,
			fontOutline = true,
			fontShadow = false,
			textureFile = ExRT.mds.barImg,
			colorsText = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsBack = {0,1,0, 0,1,0, 1,0,0, 1,1,0},
			colorsTL = {0,1,0, 0,1,0, 1,0,0, 1,1,0},
			textureAlphaBackground = 0.3,
			textureAlphaTimeLine = 0.8,
			textureAlphaCooldown = 1,
			optionClassColorBackground = false,
			optionClassColorTimeLine = false,
			optionClassColorText = false,
			textTemplateLeft = "%name%",
			textTemplateRight = "%time%",
			textTemplateCenter = "",
		},
		[2] = {
			iconSize = 14,
			optionAnimation = false,
			optionStyleAnimation = 1,
			optionTimeLineAnimation = 1,
			optionIconPosition = 1,
			optionGray = false,
			fontSize = 12,
			fontName = ExRT.mds.defFont,
			fontOutline = true,
			fontShadow = false,
			textureFile = ExRT.mds.barImg,
			colorsText = {1,1,1, 0.5,1,0.5, 1,0.5,0.5, 1,1,0.5,},
			colorsBack = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsTL = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			textureAlphaBackground = 0.3,
			textureAlphaTimeLine = 0.8,
			textureAlphaCooldown = 1,
			optionClassColorBackground = false,
			optionClassColorTimeLine = false,
			optionClassColorText = false,
			textTemplateLeft = "%time% %name%",
			textTemplateRight = "",
			textTemplateCenter = "",
		},
		[3] = {
			iconSize = 14,
			optionAnimation = true,
			optionStyleAnimation = 1,
			optionTimeLineAnimation = 2,
			optionIconPosition = 1,
			optionGray = false,
			fontSize = 12,
			fontName = ExRT.mds.defFont,
			fontOutline = false,
			fontShadow = true,
			textureFile = "Interface\\AddOns\\ExRT\\media\\bar26.tga",
			colorsText = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsBack = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsTL = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			textureAlphaBackground = 0.15,
			textureAlphaTimeLine = 0.8,
			textureAlphaCooldown = 1,
			optionClassColorBackground = false,
			optionClassColorTimeLine = true,
			optionClassColorText = false,
			textTemplateLeft = "",
			textTemplateRight = "%time%",
			textTemplateCenter = "%name%: %spell%",
		},
		[4] = {
			iconSize = 16,
			optionAnimation = true,
			optionStyleAnimation = 2,
			optionTimeLineAnimation = 2,
			optionIconPosition = 1,
			optionGray = false,
			fontSize = 12,
			fontName = ExRT.mds.defFont,
			fontOutline = false,
			fontShadow = true,
			textureFile = "Interface\\AddOns\\ExRT\\media\\bar19.tga",
			colorsText = {1,1,1, 0.5,1,0.5, 1,1,1, 1,1,0.5},
			colorsBack = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsTL = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			textureAlphaBackground = 0.15,
			textureAlphaTimeLine = 1,
			textureAlphaCooldown = 0.85,
			optionClassColorBackground = true,
			optionClassColorTimeLine = true,
			optionClassColorText = false,
			textTemplateLeft = "%name%",
			textTemplateRight = "%time%",
			textTemplateCenter = "",
			
			frameBetweenLines = 1,
		},
		[5] = {
			iconSize = 40,
			optionAnimation = false,
			optionStyleAnimation = 1,
			optionTimeLineAnimation = 1,
			optionIconPosition = 1,
			optionGray = false,
			fontSize = 10,
			fontName = ExRT.mds.defFont,
			fontOutline = true,
			fontShadow = false,
			textureFile = ExRT.mds.barImg,
			colorsText = {1,1,1, 0.5,1,0.5, 1,0.5,0.5, 1,1,0.5,},
			colorsBack = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsTL = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			textureAlphaBackground = 0,
			textureAlphaTimeLine = 0,
			textureAlphaCooldown = 0.7,
			optionClassColorBackground = false,
			optionClassColorTimeLine = false,
			optionClassColorText = false,
			textTemplateLeft = "",
			textTemplateRight = "",
			textTemplateCenter = "",
			textIconName = true,
			methodsCooldown = true,
			
			frameWidth = 40,
			frameColumns = 4,
		},
		[6] = {
			iconSize = 12,
			optionAnimation = false,
			optionStyleAnimation = 1,
			optionTimeLineAnimation = 1,
			optionIconPosition = 1,
			optionGray = false,
			fontSize = 12,
			fontName = ExRT.mds.defFont,
			fontOutline = false,
			fontShadow = false,
			textureFile = ExRT.mds.barImg,
			colorsText = {1,1,1, 0.5,1,0.5, 1,0.5,0.5, 1,1,0.5,},
			colorsBack = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsTL = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			textureAlphaBackground = 0,
			textureAlphaTimeLine = 0,
			textureAlphaCooldown = 1,
			optionClassColorBackground = false,
			optionClassColorTimeLine = false,
			optionClassColorText = false,
			textTemplateLeft = "%time% %name%",
			textTemplateRight = "",
			textTemplateCenter = "",
		},
		[7] = {
			iconSize = 14,
			optionAnimation = true,
			optionStyleAnimation = 1,
			optionTimeLineAnimation = 1,
			optionIconPosition = 1,
			optionGray = false,
			fontSize = 12,
			fontName = ExRT.mds.defFont,
			fontOutline = false,
			fontShadow = true,
			textureFile = "Interface\\AddOns\\ExRT\\media\\bar29.tga",
			colorsText = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsBack = {0,1,0, 0,1,0, 0.8,0,0, 1,1,0},
			colorsTL = {0,1,0, 0,1,0, 0.8,0,0, 1,1,0},
			textureAlphaBackground = 0.3,
			textureAlphaTimeLine = 0.8,
			textureAlphaCooldown = 0.5,
			optionClassColorBackground = false,
			optionClassColorTimeLine = false,
			optionClassColorText = false,
			textTemplateLeft = "%name%",
			textTemplateRight = "%stime%",
			textTemplateCenter = "",
		},
		[8] = {
			iconSize = 16,
			optionAnimation = true,
			optionStyleAnimation = 2,
			optionTimeLineAnimation = 2,
			optionIconPosition = 2,
			optionGray = true,
			fontSize = 13,
			fontName = ExRT.mds.defFont,
			fontOutline = true,
			fontShadow = true,
			textureFile = "Interface\\AddOns\\ExRT\\media\\bar6.tga",
			colorsText = {1,1,1, 0.5,1,0.5, 1,0.5,0.5, 1,1,0.5,},
			colorsBack = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsTL = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			textureAlphaBackground = 0.3,
			textureAlphaTimeLine = 0.8,
			textureAlphaCooldown = 0.5,
			optionClassColorBackground = false,
			optionClassColorTimeLine = false,
			optionClassColorText = true,
			textTemplateLeft = "%name%",
			textTemplateRight = "",
			textTemplateCenter = "",
		},
		[9] = {
			iconSize = 18,
			optionAnimation = true,
			optionStyleAnimation = 1,
			optionTimeLineAnimation = 2,
			optionIconPosition = 1,
			optionGray = false,
			fontSize = 12,
			fontName = ExRT.mds.defFont,
			fontOutline = false,
			fontShadow = true,
			textureFile = "Interface\\AddOns\\ExRT\\media\\bar16.tga",
			colorsText = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsBack = {0,0,0, 0,0,0, 0,0,0, 0,0,0},
			colorsTL = {0.24,0.44,1, 1,0.37,1, 0.24,0.44,1, 1,0.46,0.10},
			textureAlphaBackground = 0.3,
			textureAlphaTimeLine = 0.9,
			textureAlphaCooldown = 1,
			optionClassColorBackground = false,
			optionClassColorTimeLine = false,
			optionClassColorText = false,
			textTemplateLeft = "%name%",
			textTemplateRight = "%stime%",
			textTemplateCenter = "",
			textureBorderSize = 1,
			frameBetweenLines = 3,
			textureBorderColorA = 1,
		},
		[10] = {
			iconSize = 18,
			optionAnimation = true,
			optionStyleAnimation = 1,
			optionTimeLineAnimation = 2,
			optionIconPosition = 1,
			optionGray = false,
			fontSize = 12,
			fontName = ExRT.mds.defFont,
			fontOutline = false,
			fontShadow = true,
			textureFile = "Interface\\AddOns\\ExRT\\media\\bar16.tga",
			colorsText = {1,1,1, 1,1,1, 1,1,1, 1,1,1},
			colorsBack = {0,0,0, 0,0,0, 0,0,0, 0,0,0},
			colorsTL = {0.24,0.44,1, 1,0.37,1, 0.24,0.44,1, 1,0.46,0.10},
			textureAlphaBackground = 0.3,
			textureAlphaTimeLine = 0.9,
			textureAlphaCooldown = 1,
			optionClassColorBackground = false,
			optionClassColorTimeLine = true,
			optionClassColorText = false,
			textTemplateLeft = "%name%",
			textTemplateRight = "%stime%",
			textTemplateCenter = "",
			textureBorderSize = 1,
			frameBetweenLines = 3,
			textureBorderColorA = 1,
		},
		toOptions = {
			iconSize = "iconSize",
			optionAnimation = "textureAnimation",
			optionStyleAnimation = "methodsStyleAnimation",
			optionTimeLineAnimation = "methodsTimeLineAnimation",
			optionIconPosition = "iconPosition",
			optionGray = "iconGray",
			fontSize = "fontSize",
			fontName = "fontName",
			fontOutline = "fontOutline",
			fontShadow = "fontShadow",
			textureFile = "textureFile",
			colorsText = {"textureColorTextDefaultR","textureColorTextDefaultG","textureColorTextDefaultB","textureColorTextActiveR","textureColorTextActiveG","textureColorTextActiveB","textureColorTextCooldownR","textureColorTextCooldownG","textureColorTextCooldownB","textureColorTextCastR","textureColorTextCastG","textureColorTextCastB",},
			colorsBack = {"textureColorBackgroundDefaultR","textureColorBackgroundDefaultG","textureColorBackgroundDefaultB","textureColorBackgroundActiveR","textureColorBackgroundActiveG","textureColorBackgroundActiveB","textureColorBackgroundCooldownR","textureColorBackgroundCooldownG","textureColorBackgroundCooldownB","textureColorBackgroundCastR","textureColorBackgroundCastG","textureColorBackgroundCastB",},
			colorsTL = {"textureColorTimeLineDefaultR","textureColorTimeLineDefaultG","textureColorTimeLineDefaultB","textureColorTimeLineActiveR","textureColorTimeLineActiveG","textureColorTimeLineActiveB","textureColorTimeLineCooldownR","textureColorTimeLineCooldownG","textureColorTimeLineCooldownB","textureColorTimeLineCastR","textureColorTimeLineCastG","textureColorTimeLineCastB",},
			textureAlphaBackground = "textureAlphaBackground",
			textureAlphaTimeLine = "textureAlphaTimeLine",
			textureAlphaCooldown = "textureAlphaCooldown",
			optionClassColorBackground = "textureClassBackground",
			optionClassColorTimeLine = "textureClassTimeLine",
			optionClassColorText = "textureClassText",	
			textTemplateLeft = "textTemplateLeft",
			textTemplateRight = "textTemplateRight",
			textTemplateCenter = "textTemplateCenter",
			methodsCooldown = "methodsCooldown",
			textIconName = "textIconName",
			fontOtherAvailable = "fontOtherAvailable",
			frameBetweenLines = "frameBetweenLines",
			textureBorderSize = "textureBorderSize",
			textureBorderColorR = "textureBorderColorR",
			textureBorderColorG = "textureBorderColorG",
			textureBorderColorB = "textureBorderColorB",
			textureBorderColorA = "textureBorderColorA",
			
			iconGeneral = "iconGeneral",
			textureGeneral = "textureGeneral",
			methodsGeneral = "methodsGeneral",
			fontGeneral = "fontGeneral",

			frameColumns = "frameColumns",
			
			_frameAlpha = "frameAlpha",
			_frameWidth = "frameWidth",
			_frameBlackBack = "frameBlackBack",
		},
	}
	self.optColSet.templateSaveData = nil
	
	self.optColSet.templatesScrollFrame = ExRT.lib.CreateScrollFrame(self.optColSet.superTabFrame.tab[7],366,348,"TOP",0,-50, ceil(#self.optColSet.templateData/2) * 125 + 10 )
	for i=1,#self.optColSet.templateData do
		self.optColSet.templates[i] = CreateFrame("Button",nil,self.optColSet.templatesScrollFrame.C)
		self.optColSet.templates[i]:SetPoint((i-1)%2 == 0 and "TOPRIGHT" or "TOPLEFT",self.optColSet.templatesScrollFrame.C,"TOP",0,-floor((i-1)/2) * 125 - 5)
		self.optColSet.templates[i]:SetSize(170,120)
		self.optColSet.templates[i]:SetBackdrop({edgeFile = ExRT.mds.defBorder, edgeSize = 8})
		self.optColSet.templates[i]:SetBackdropBorderColor(1,1,1,0)
		self.optColSet.templates[i].backgTexture = self.optColSet.templates[i]:CreateTexture(nil, "BACKGROUND")
		self.optColSet.templates[i].backgTexture:SetAllPoints()
		
		self.optColSet.templates[i]:SetScript("OnEnter",function (self)
			self:SetBackdropBorderColor(1,1,1,0.5)
			self.backgTexture:SetTexture(1,1,1,0.3)
		end)
		
		self.optColSet.templates[i]:SetScript("OnLeave",function (self)
		  	self:SetBackdropBorderColor(1,1,1,0)
			self.backgTexture:SetTexture(0,0,0,0)
		end)
		
		self.optColSet.templates[i]:SetScript("OnClick",function (self)
		  	module.options.optColSet.templateRestore:Show()
		  	module.options.optColSet.templateSaveData = {}
		  	ExRT.mds.table_copy(VExRT.ExCD2.colSet[module.options.optColTabs.selected],module.options.optColSet.templateSaveData)
		  	for key,val in pairs(module.options.optColSet.templateData.toOptions) do
		  		if type(val) ~= "table" then
		  			if string.find(key,"^_") then
		  				local key2 = string.sub(key,2)
		  				if module.options.optColSet.templateData[i][key2] then
		  					VExRT.ExCD2.colSet[module.options.optColTabs.selected][val] = module.options.optColSet.templateData[i][key2]
		  				elseif key2 == "frameWidth" then
		  					VExRT.ExCD2.colSet[module.options.optColTabs.selected][val] = max(110,VExRT.ExCD2.colSet[module.options.optColTabs.selected][val] or 110)
		  				end
		  			else
		  				VExRT.ExCD2.colSet[module.options.optColTabs.selected][val] = module.options.optColSet.templateData[i][key]
		  			end
		  		else
		  			for k=1,#val do
		  				VExRT.ExCD2.colSet[module.options.optColTabs.selected][val[k]] = module.options.optColSet.templateData[i][key][k]
		  			end
		  		end
		  	end
		  	module:ReloadAllSplits()
		  	module.options.selectColumnTab()
		end)		
		
		self.optColSet.templates[i].lines = {}
		for j=1,5 do
			self.optColSet.templates[i].lines[j] = module.frameCreateLine(self.optColSet.templates[i])
			local width,height= self.optColSet.templateData[i].frameWidth or 160, self.optColSet.templateData[i].iconSize
			local betweenLines = self.optColSet.templateData[i].frameBetweenLines or 0
			if not self.optColSet.templateData[i].frameColumns then
				self.optColSet.templates[i].lines[j]:SetPoint("TOP",0,-height*(j-1)-10 -betweenLines*(j-1))
			else
				local inLine = (j-1) % self.optColSet.templateData[i].frameColumns
				local line = ExRT.mds.Round( ((j-1) - inLine) / self.optColSet.templateData[i].frameColumns )
				self.optColSet.templates[i].lines[j]:SetPoint("TOP", inLine*width, -line*height -10 -betweenLines*line) 
			end
			
			self.optColSet.templates[i].textTemplateLeft = self.optColSet.templateData[i].textTemplateLeft
			self.optColSet.templates[i].textTemplateRight = self.optColSet.templateData[i].textTemplateRight
			self.optColSet.templates[i].textTemplateCenter = self.optColSet.templateData[i].textTemplateCenter
			self.optColSet.templates[i].optionIconName = self.optColSet.templateData[i].textIconName
			self.optColSet.templates[i].optionCooldown = self.optColSet.templateData[i].methodsCooldown
			
			self.optColSet.templates[i].textureBorderColorR = self.optColSet.templateData[i].textureBorderColorR or 0
			self.optColSet.templates[i].textureBorderColorG = self.optColSet.templateData[i].textureBorderColorG or 0
			self.optColSet.templates[i].textureBorderColorB = self.optColSet.templateData[i].textureBorderColorB or 0
			self.optColSet.templates[i].textureBorderColorA = self.optColSet.templateData[i].textureBorderColorA or 0
			
			local templateDataColorsTablesNames = {"colorsText","colorsBack","colorsTL"}
			for object_c=1,3 do
				for state_c=1,4 do
					self.optColSet.templates[i]["optionColor".. colorSetupFrameColorsObjectsNames[object_c] .. colorSetupFrameColorsNames[state_c] ] = {
						r = self.optColSet.templateData[i][ templateDataColorsTablesNames[object_c] ][ (state_c-1)*3+1 ],
						g = self.optColSet.templateData[i][ templateDataColorsTablesNames[object_c] ][ (state_c-1)*3+2 ],
						b = self.optColSet.templateData[i][ templateDataColorsTablesNames[object_c] ][ (state_c-1)*3+3 ],
					}
				end
			end
		
			module.ReloadLine(self.optColSet.templates[i].lines[j],160,height,self.optColSet.templateData[i].optionAnimation,self.optColSet.templateData[i].optionClassColorBackground,self.optColSet.templateData[i].optionClassColorTimeLine,self.optColSet.templateData[i].optionClassColorText,self.optColSet.templateData[i].optionStyleAnimation,self.optColSet.templateData[i].optionTimeLineAnimation,self.optColSet.templateData[i].optionIconPosition,self.optColSet.templateData[i].optionGray,self.optColSet.templateData[i].fontSize,self.optColSet.templateData[i].fontName,self.optColSet.templateData[i].fontOutline,self.optColSet.templateData[i].fontShadow,self.optColSet.templateData[i].textureFile,self.optColSet.templateData[i].textureBorderSize or 0,self.optColSet.templateData[i].textureAlphaBackground,self.optColSet.templateData[i].textureAlphaTimeLine,self.optColSet.templateData[i].textureAlphaCooldown)
						
			self.optColSet.templates[i].lines[j].data = {
				[1] = UnitName("player"),
				[2] = {self.optColSet.templateData.spells[j],self.optColSet.templateData.spellsClass[j]},
				[3] = self.optColSet.templateData.spellsCD[j],
				[4] = GetTime(),
				[5] = self.optColSet.templateData.spellsDuration[j],
				[6] = self.optColSet.templateData.spellsDead[j],
				[7] = self.optColSet.templateData.spellsCast[j],
			}
			
			self.optColSet.templates[i].lines[j]:SetScript("OnUpdate",function (self)
				local ctime_ = GetTime()
				local t_ = self.data[3] ~= 0 and (self.data[3] - (ctime_ % self.data[3])) or -2
				local _parent = self.data[2]
				local _spellID =  _parent[1]
				local _name = self.data[1]
				
				local timetogo = t_
				local d_ = self.data[5] ~= 0 and (self.data[5] - (ctime_ % self.data[5])) or 0

				local lineStatus = nil

				local spellName,_,spellTexture = GetSpellInfo(_spellID)
				self.icon.t:SetTexture(spellTexture or "Interface\\Icons\\INV_MISC_QUESTIONMARK")

				local name = _name

				if self.data[6] or (t_ > 0 and d_ <= 0) then
					lineStatus = -1
				elseif d_ > 0 then
					timetogo = d_
					lineStatus = 1
				elseif self.data[7] then
					name = "> " .. name
					lineStatus = 2
				else
					lineStatus = nil
				end

				self.isDead = lineStatus == -1
				if self.optionAlphaCooldown < 1 then
					if lineStatus == -1 then
						self:SetAlpha(self.optionAlphaCooldown)
					else
						self:SetAlpha(1)
					end
				end

				local textLeft = self.textTemplateLeft
				local textRight = self.textTemplateRight
				local textCenter = self.textTemplateCenter
				
				local longtime = TimeStr(timetogo)
				local shorttime = TimeStr(timetogo,true)
				local name_time = ((t_ > 0 or d_ > 0) and longtime) or name
				local name_stime = ((t_ > 0 or d_ > 0) and shorttime) or name
				textLeft = string_gsub(textLeft,"%%time%%",longtime)
				textLeft = string_gsub(textLeft,"%%stime%%",shorttime)
				textLeft = string_gsub(textLeft,"%%name%%",name)
				textLeft = string_gsub(textLeft,"%%name_time%%",name_time)
				textLeft = string_gsub(textLeft,"%%name_stime%%",name_stime)
				textLeft = string_gsub(textLeft,"%%spell%%",spellName)
				textRight = string_gsub(textRight,"%%time%%",longtime)
				textRight = string_gsub(textRight,"%%stime%%",shorttime)
				textRight = string_gsub(textRight,"%%name%%",name)
				textRight = string_gsub(textRight,"%%name_time%%",name_time)
				textRight = string_gsub(textRight,"%%name_stime%%",name_stime)
				textRight = string_gsub(textRight,"%%spell%%",spellName)
				
				-- Demonstration Fix
				spellName = string.sub(spellName,1,string.find(spellName,' '))
				
				textCenter = string_gsub(textCenter,"%%time%%",longtime)
				textCenter = string_gsub(textCenter,"%%stime%%",shorttime)
				textCenter = string_gsub(textCenter,"%%name%%",name)
				textCenter = string_gsub(textCenter,"%%name_time%%",name_time)
				textCenter = string_gsub(textCenter,"%%name_stime%%",name_stime)
				textCenter = string_gsub(textCenter,"%%spell%%",spellName)	

				self.unitName:SetText(string_trim(textLeft))
				self.time:SetText(string_trim(textRight))
				self.center:SetText(string_trim(textCenter))
				
				if self.optionIconName then
					self.iconText:SetText(name)
				end
				
				if self.optionCooldown then
					if d_ > 0 then
						self.cooldown:Show()
						self.cooldown:SetReverse(true)
						self.cooldown:SetCooldown(GetTime() + d_ - self.data[5],self.data[5])
					elseif t_ > 0 then
						self.cooldown:Show()
						self.cooldown:SetReverse(false)
						self.cooldown:SetCooldown(GetTime() + t_ - self.data[3],self.data[3])
					elseif self.isDead then
						self.cooldown:Show()
						self.cooldown:SetReverse(false)
						self.cooldown:SetCooldown(GetTime()+1,1)
					else
						self.cooldown:Hide()
					end
				end

				LinesEnableOrDisable(self,lineStatus,self.optionClassColorText)
				
				self.classColor = RAID_CLASS_COLORS[ _parent[2] ] or _db.notAClass

				self:Show()
				local link = self.data

				if self.optionAnimation then
					t_ = 1.01
					local c_ = nil
					local a_ = 1.01
					local cast_ = 1.01
					if link[3]~=0 then 
						t_ = (ctime_ % self.data[3])/self.data[3]
					end
					local _mainSpellID = link[2][1]
					
					if link[5]~=0 then 
						a_ = (ctime_ % self.data[5])/self.data[5]
					end					
					
					if self.data[7] and t_ > 1 then
						cast_ = (ctime_ % self.data[7])/self.data[7]
					end
					AnimationAndSparkLine(self,t_ <= 1 and t_,a_ <= 1 and a_,c_,cast_ <= 1 and cast_,self.isDead)
				else
					self.t:Hide()
					self.spark:Hide()
					
					if self.optionClassColorBackground then
						_line:SetBackdropColor(self.classColor.r,self.classColor.g,self.classColor.b,self.optionAlphaBackground)
					end
					if self.optionTimeLineAnimation == 2 then
						if lineStatus == -1 then
							self.t:Hide()
						else
							self.t:Show()
						end
						if self.optionClassColorTimeLine then
							self:SetBackdropColor(self.classColor.r,self.classColor.g,self.classColor.b,self.optionAlphaTimeLine)
						end
					end
				end

			end)
		end
	end
	
	self.optColSet.templateRestore = CreateFrame("Button",nil,self.optColSet.superTabFrame.tab[7])
	self.optColSet.templateRestore:SetPoint("TOP",0,-10)
	self.optColSet.templateRestore:SetSize(330,30)
	self.optColSet.templateRestore:SetBackdrop({edgeFile = ExRT.mds.defBorder, edgeSize = 8})
	self.optColSet.templateRestore:SetBackdropBorderColor(1,0.5,0.5,1)
	self.optColSet.templateRestore.text = ExRT.lib.CreateText(self.optColSet.templateRestore,0,0,nil,0,0,"CENTER","MIDDLE",nil,12,ExRT.L.cd2OtherSetTemplateRestore,nil,1,1,1,1)
	self.optColSet.templateRestore.text:SetAllPoints()
	self.optColSet.templateRestore:SetScript("OnEnter",function (self)
	  	self.text:SetTextColor(1,1,0,1)
	end)
	self.optColSet.templateRestore:SetScript("OnLeave",function (self)
	  	self.text:SetTextColor(1,1,1,1)	  
	end)
	self.optColSet.templateRestore:SetScript("OnClick",function (self)
		VExRT.ExCD2.colSet[module.options.optColTabs.selected] = {}
		ExRT.mds.table_copy(module.options.optColSet.templateSaveData,VExRT.ExCD2.colSet[module.options.optColTabs.selected])
		module:ReloadAllSplits()
		module.options.selectColumnTab()
		self:Hide()
	end)
	self.optColSet.templateRestore:Hide()
	
	do
		module.options.optColTabs.selected = module.db.maxColumns+1
		module.options.tab.tabs[2]:SetScript("OnShow",function ()
			module.options.selectColumnTab(self.optColTabs.tabs[module.db.maxColumns+1].button)
			module.options.tab.tabs[2]:SetScript("OnShow",nil)
		end)
	end	
	
	--> Other setts
	self.optSetTab = ExRT.lib.CreateOneTab(self.tab.tabs[2],603,50,nil,5,-480,ExRT.L.cd2OtherSet)
	
	self.chkSplit = ExRT.lib.CreateCheckBox(self.optSetTab,nil,5,-10,ExRT.L.cd2split,VExRT.ExCD2.SplitOpt,ExRT.L.cd2splittooltip)
	self.chkSplit:SetScript("OnClick", function(self,event)
		if self:GetChecked() then
			VExRT.ExCD2.SplitOpt = true
		else
			VExRT.ExCD2.SplitOpt = nil
		end
		module:SplitExCD2Window()
		module:ReloadAllSplits()
	end)
	
	self.chkNoRaid = ExRT.lib.CreateCheckBox(self.optSetTab,nil,155,-10,ExRT.L.cd2noraid,VExRT.ExCD2.NoRaid)
	self.chkNoRaid:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			VExRT.ExCD2.NoRaid = true
		else
			VExRT.ExCD2.NoRaid = nil
		end
		UpdateRoster()
	end)
	
	self.testMode = ExRT.lib.CreateCheckBox(self.optSetTab,nil,305,-10,ExRT.L.cd2GeneralSetTestMode,module.db.testMode,ExRT.L.cd2HelpTestButton)
	self.testMode:SetScript("OnClick", function(self,event) 
		if self:GetChecked() then
			module.db.testMode = true
		else
			module.db.testMode = nil
			TestMode(1)
		end
		UpdateRoster()
	end)

	self.butResetToDef = ExRT.lib.CreateButton(self.optSetTab,137,24,nil,455,-13,ExRT.L.cd2OtherSetReset,nil,ExRT.L.cd2HelpButtonDefault)
	self.butResetToDef:SetScript("OnClick",function()
		table_wipe2(VExRT.ExCD2.colSet[module.options.optColTabs.selected])
		for optName,optVal in pairs(module.db.colsInit) do
			VExRT.ExCD2.colSet[module.options.optColTabs.selected][optName] = optVal
		end
		
		module.options.selectColumnTab(self.optColTabs.tabs[module.options.optColTabs.selected].button)
		module:ReloadAllSplits()
	end) 
	
	
	
	--> OPTIONS TAB3: History
	self.butHistoryClear = ExRT.lib.CreateButton(self.tab.tabs[3],180,22,nil,415,-9,ExRT.L.cd2HistoryClear)
	self.butHistoryClear:SetScript("OnClick",function()
		table_wipe2(module.db.historyUsage)
		module.options.historyBox.EditBox:SetText("")
	end)
	
	local historyBoxUpdateTable = {}
	local function historyBoxUpdate(v)
		table_wipe2(historyBoxUpdateTable)
		local count = 0
		for i=1,#module.db.historyUsage do
			if VExRT.ExCD2.CDE[module.db.historyUsage[i][2]] then
				count = count + 1
			end
			if count >= v and VExRT.ExCD2.CDE[module.db.historyUsage[i][2]] then
				local tm = date("%X",module.db.historyUsage[i][1])
				local bosshpstr = module.db.historyUsage[i][4] and format(" (%d:%.2d)",module.db.historyUsage[i][4]/60,module.db.historyUsage[i][4]%60) or ""
				local spellName,_,spellIcon = GetSpellInfo(module.db.historyUsage[i][2])
				historyBoxUpdateTable [#historyBoxUpdateTable + 1] = format("|cffffff00[%s]%s|r %s |Hspell:%d|h|T%s:0|t%s|h",tm,bosshpstr,module.db.historyUsage[i][3] or "?",module.db.historyUsage[i][2] or 0,spellIcon or "Interface\\Icons\\Trade_Engineering",spellName or "?")
			end
			if #historyBoxUpdateTable > 40 then
				break
			end
		end
		module.options.historyBox.EditBox:SetText(strjoin("\n",unpack(historyBoxUpdateTable)))
	end
	
	self.historyBox = ExRT.lib.CreateMultiEditBox2(self.tab.tabs[3],590,485,"TOP",0,-40)
	self.historyBox.EditBox:SetScript("OnShow",function(self)
		historyBoxUpdate(1)
		local count = 0
		for i=1,#module.db.historyUsage do
			if VExRT.ExCD2.CDE[module.db.historyUsage[i][2]] then
				count = count + 1
			end
		end
		module.options.historyBox.ScrollBar:SetMinMaxValues(1,max(count,1))
	end)
	self.historyBox.ScrollBar:SetScript("OnValueChanged",function (self,val)
		val = ExRT.mds.Round(val)
		historyBoxUpdate(val)
	end)
	self.historyBox.EditBox:SetHyperlinksEnabled(true)
	self.historyBox.EditBox:SetScript("OnHyperlinkEnter",ExRT.lib.EditBoxOnEnterHyperLinkTooltip)
	self.historyBox.EditBox:SetScript("OnHyperlinkLeave",ExRT.lib.EditBoxOnLeaveHyperLinkTooltip)
	
	self.HelpPlate = {
		[1] = {
			FramePos = { x = 0, y = 0 },FrameSize = { width = 623, height = 568 },
			[1] = { ButtonPos = { x = 500,	y = -25 },  	HighLightBox = { x = 445, y = -35, width = 166, height = 24 },		ToolTipDir = "LEFT",	ToolTipText = ExRT.L.cd2HelpFastSetup },
			[2] = { ButtonPos = { x = 5,  y = -135 }, 	HighLightBox = { x = 13, y = -62, width = 34, height = 464 },		ToolTipDir = "RIGHT",	ToolTipText = ExRT.L.cd2HelpOnOff },
			[3] = { ButtonPos = { x = 250,  y = -135 }, 	HighLightBox = { x = 235, y = -62, width = 120, height = 464 },		ToolTipDir = "DOWN",	ToolTipText = ExRT.L.cd2HelpCol },
			[4] = { ButtonPos = { x = 375,  y = -135},  	HighLightBox = { x = 360, y = -62, width = 70, height = 464 },		ToolTipDir = "DOWN",	ToolTipText = ExRT.L.cd2HelpPriority },
			[5] = { ButtonPos = { x = 470,  y = -135 },  	HighLightBox = { x = 433, y = -62, width = 138, height = 464 },		ToolTipDir = "LEFT",	ToolTipText = ExRT.L.cd2HelpTime },
			[6] = { ButtonPos = { x = 370,  y = -520 },  	HighLightBox = { x = 10, y = -528, width = 580, height = 30 },		ToolTipDir = "UP",	ToolTipText = ExRT.L.cd2HelpAddButton },
		},
		[2] = {
			FramePos = { x = 0, y = 0 },FrameSize = { width = 623, height = 568 },
			[1] = { ButtonPos = { x = 50,	y = -130 },  	HighLightBox = { x = 10, y = -57, width = 605, height = 440 },		ToolTipDir = "RIGHT",	ToolTipText = ExRT.L.cd2HelpColSetup },
			[2] = { ButtonPos = { x = 310,	y = -512 },  	HighLightBox = { x = 310, y = -520, width = 130, height = 30 },		ToolTipDir = "LEFT",	ToolTipText = ExRT.L.cd2HelpTestButton },
			[3] = { ButtonPos = { x = 460,	y = -512 },  	HighLightBox = { x = 460, y = -520, width = 145, height = 30 },		ToolTipDir = "LEFT",	ToolTipText = ExRT.L.cd2HelpButtonDefault },
		},
		[3] = {
			FramePos = { x = 0, y = 0 },FrameSize = { width = 623, height = 568 },
			[1] = { ButtonPos = { x = 230,	y = -35 },  	HighLightBox = { x = 5, y = -30, width = 613, height = 534 },		ToolTipDir = "DOWN",	ToolTipText = ExRT.L.cd2HelpHistory },		
		}
	}
	self.HELPButton = ExRT.lib.CreateHelpButton(self,self.HelpPlate,self.tab)
	function self.HELPButton:Click2()
		local min,max=module.options.ScrollBar:GetMinMaxValues()
		module.options.ScrollBar:SetValue(max)
	end

	self.ScrollBar:SetMinMaxValues(1,max(#module.db.spellDB-self.spellsPerPage+2,1))
	module.options:ReloadSpellsPage()

	self.chkEnable:SetChecked(VExRT.ExCD2.enabled)
	self.chkLock:SetChecked(VExRT.ExCD2.lock)
end

function module.options:CleanUPVariables()
	local cleanUP = {}
	for sett,col in pairs(VExRT.ExCD2.CDECol) do
		local bool = nil
		for i=1,#module.db.spellDB do
			for j=3,7 do
				if module.db.spellDB[i][j] then
					if tonumber( string.gsub(sett,";%d",""),nil ) == module.db.spellDB[i][j][1] then
						bool = true
					end
				end
			end
		end
		if not bool then
			cleanUP [#cleanUP + 1] = sett
		end
	end
	for i=1,#cleanUP do
		VExRT.ExCD2.CDECol[cleanUP[i]] = nil
	end
	table_wipe2(cleanUP)
	for sid,val in pairs(VExRT.ExCD2.CDE) do
		local bool = nil
		for i=1,#module.db.spellDB do
			if sid == module.db.spellDB[i][1] then
				bool = true
			end
		end
		if not bool then
			cleanUP [#cleanUP + 1] = sid
		end
	end
	for i=1,#cleanUP do
		VExRT.ExCD2.CDE[cleanUP[i]] = nil
	end
	table_wipe2(cleanUP)
	for sid,val in pairs(VExRT.ExCD2.Priority) do
		local bool = nil
		for i=1,#module.db.spellDB do
			if sid == module.db.spellDB[i][1] then
				bool = true
			end
		end
		if not bool then
			cleanUP [#cleanUP + 1] = sid
		end
	end
	for i=1,#cleanUP do
		VExRT.ExCD2.Priority[cleanUP[i]] = nil
	end
end

local function LineIconOnHover(self)
	local parent = self:GetParent()
	if not parent.link then
		return
	end
	GameTooltip:SetOwner(self, "ANCHOR_LEFT")
	GameTooltip:SetHyperlink("spell:"..parent.link[2][1])
	GameTooltip:Show()
end
local function LineIconOnLeave(self)
	GameTooltip_Hide()
end
local function LineIconOnClick(self)
	local parent = self:GetParent()
	if not parent.link then
		return
	end
	local time = parent.link[4] + parent.link[3] - GetTime()
	if time < 0 then
		return
	end
	local text = parent.link[1].." - "..parent.link[10]..": "..TimeStr(time)
	local chat_type = ExRT.mds.chatType(true)
	SendChatMessage(text,chat_type)
end

local function SetBorderSize(self,size,cR,cG,cB,cA)
	if size == 0 then
		self.border.top:Hide()
		self.border.bottom:Hide()
		self.border.left:Hide()
		self.border.right:Hide()
		return
	else
		self.border.top:Show()
		self.border.bottom:Show()
		self.border.left:Show()
		self.border.right:Show()	
	end
	self.border.top:ClearAllPoints()
	self.border.bottom:ClearAllPoints()
	self.border.left:ClearAllPoints()
	self.border.right:ClearAllPoints()
	
	self.border.top:SetPoint("TOPLEFT",self,"TOPLEFT",-size,size)
	self.border.top:SetPoint("BOTTOMRIGHT",self,"TOPRIGHT",size,0)

	self.border.bottom:SetPoint("BOTTOMLEFT",self,"BOTTOMLEFT",-size,-size)
	self.border.bottom:SetPoint("TOPRIGHT",self,"BOTTOMRIGHT",size,0)

	self.border.left:SetPoint("TOPLEFT",self,"TOPLEFT",-size,0)
	self.border.left:SetPoint("BOTTOMRIGHT",self,"BOTTOMLEFT",0,0)

	self.border.right:SetPoint("TOPLEFT",self,"TOPRIGHT",0,0)
	self.border.right:SetPoint("BOTTOMRIGHT",self,"BOTTOMRIGHT",size,0)

	self.border.top:SetTexture(cR,cG,cB,cA)
	self.border.bottom:SetTexture(cR,cG,cB,cA)
	self.border.left:SetTexture(cR,cG,cB,cA)
	self.border.right:SetTexture(cR,cG,cB,cA)
end

local function SetTextFont(self,fontName,fontSize,fontOutline,fontShadow)
	local isValidFont = self:SetFont(fontName,fontSize,fontOutline and "OUTLINE")
	if not isValidFont then
		self:SetFont(module.db.colsDefaults.fontName,fontSize,fontOutline and "OUTLINE")
	end
	local fontOffset = fontShadow and 1 or 0
	self:SetShadowOffset(1*fontOffset,-1*fontOffset)
end

function module.ReloadLine(self,frameWidth,iconSize,optionAnimation,optionClassColorBackground,optionClassColorTimeLine,optionClassColorText,optionStyleAnimation,optionTimeLineAnimation,optionIconPosition,optionGray,fontSize,fontName,fontOutline,fontShadow,textureFile,textureBorderFile,optionAlphaBackground,optionAlphaTimeLine,optionAlphaCooldown, fontOtherAvailable, fontLeftSize, fontLeftName, fontLeftOutline, fontLeftShadow, fontRightSize, fontRightName, fontRightOutline, fontRightShadow, fontCenterSize, fontCenterName, fontCenterOutline, fontCenterShadow, fontIconSize, fontIconName, fontIconOutline, fontIconShadow)
	local parent = self:GetParent()

	self:SetWidth(frameWidth)
	
	self.optionAnimation = optionAnimation
	self.optionStyleAnimation = optionStyleAnimation
	self.optionTimeLineAnimation = optionTimeLineAnimation
	
	self.optionClassColorBackground = optionClassColorBackground
	self.optionClassColorTimeLine = optionClassColorTimeLine
	self.optionClassColorText = optionClassColorText
	self.optionCooldown = parent.optionCooldown
	self.optionIconName = parent.optionIconName
	
	self.textTemplateLeft = parent.textTemplateLeft
	self.textTemplateRight = parent.textTemplateRight
	self.textTemplateCenter = parent.textTemplateCenter
	
	local fontOffset = fontShadow and 1 or 0
	local fontOutlineFix = fontOutline and 3 or 0

	self.unitName:ClearAllPoints()
	self.unitName:SetWidth(0)
	self.time:ClearAllPoints()
	self.time:SetWidth(0)
	self.center:ClearAllPoints()
	self.center:SetWidth(0)
	self.iconText:ClearAllPoints()
	
	self:SetHeight(iconSize)
	self.icon:SetSize(iconSize,iconSize)
	self.unitName:SetHeight(iconSize)
	self.time:SetHeight(iconSize)
	self.center:SetHeight(iconSize)
	
	if not optionAnimation then
		self.t:Hide()
		self.spark:Hide()
	end
	
	local iconLeft = optionIconPosition == 1 and iconSize or 0
	local iconRight = optionIconPosition == 2 and iconSize or 0
	ExRT.lib.ShowOrHide(self.icon,not (optionIconPosition == 3))
	self.icon:ClearAllPoints()
	if optionIconPosition == 1 then
		self.icon:SetPoint("TOPLEFT",0,0)
	elseif optionIconPosition == 2 then
		self.icon:SetPoint("TOPRIGHT",0,0)
	end
	
	self.t:SetPoint("TOPLEFT", iconLeft, 0)
	self.t:SetHeight(iconSize)
	self.spark:SetSize(10,iconSize+10)
		
	self.unitName:SetPoint("TOPLEFT",self,"TOPLEFT",iconLeft+1, 0)
	self.time:SetPoint("TOPRIGHT",self,"TOPRIGHT",-1-iconRight+fontOffset+fontOutlineFix, 0)
	if self.textTemplateLeft == "" then
		self.time:SetPoint("TOPLEFT",self.unitName,"TOPRIGHT",0, 0)
	elseif self.textTemplateRight == "" then
		self.unitName:SetPoint("TOPRIGHT",self.time,"TOPLEFT",0, 0)
	elseif string_match(self.textTemplateLeft,"%%time%%") then 
		self.time:SetPoint("TOPLEFT",self.unitName,"TOPRIGHT",0, 0)
	elseif string_match(self.textTemplateRight,"%%time%%") then 
		self.unitName:SetPoint("TOPRIGHT",self.time,"TOPLEFT",0, 0)
	end
	
	self.center:SetPoint("TOPLEFT",self,"TOPLEFT",iconLeft+1, 0)
	self.center:SetPoint("TOPRIGHT",self,"TOPRIGHT",-1-iconRight, 0)

	self.iconText:SetAllPoints(self.icon)
	self.iconText:SetSize(iconSize,iconSize)
	
	self.t.ln = frameWidth - (optionIconPosition == 3 and 0 or iconSize)
	
	self.optionGray = optionGray

	local isValidTexture = self.t:SetTexture(textureFile)
	if not isValidTexture then
		textureFile = module.db.colsDefaults.textureFile
		self.t:SetTexture(textureFile)
	end
	self.t_special:SetTexture(textureFile)
	
	local backdrop = parent.backdrop
	if not backdrop then
		backdrop = {bgFile = textureFile}
		parent.backdrop = backdrop
	end
	self:SetBackdrop(backdrop)
	
	SetBorderSize(self,textureBorderFile,parent.textureBorderColorR,parent.textureBorderColorG,parent.textureBorderColorB,parent.textureBorderColorA)
	
	SetTextFont(self.unitName,fontOtherAvailable and fontLeftName or fontName,fontOtherAvailable and fontLeftSize or fontSize,(fontOtherAvailable and fontLeftOutline) or (not fontOtherAvailable and fontOutline),(fontOtherAvailable and fontLeftShadow) or (not fontOtherAvailable and fontShadow))
	SetTextFont(self.time,fontOtherAvailable and fontRightName or fontName,fontOtherAvailable and fontRightSize or fontSize,(fontOtherAvailable and fontRightOutline) or (not fontOtherAvailable and fontOutline),(fontOtherAvailable and fontRightShadow) or (not fontOtherAvailable and fontShadow))
	SetTextFont(self.center,fontOtherAvailable and fontCenterName or fontName,fontOtherAvailable and fontCenterSize or fontSize,(fontOtherAvailable and fontCenterOutline) or (not fontOtherAvailable and fontOutline),(fontOtherAvailable and fontCenterShadow) or (not fontOtherAvailable and fontShadow))
	SetTextFont(self.iconText,fontOtherAvailable and fontIconName or fontName,fontOtherAvailable and fontIconSize or fontSize,(fontOtherAvailable and fontIconOutline) or (not fontOtherAvailable and fontOutline),(fontOtherAvailable and fontIconShadow) or (not fontOtherAvailable and fontShadow))
	
	if parent.methodsIconTooltip then
		self.icon:SetScript("OnEnter",LineIconOnHover)
		self.icon:SetScript("OnLeave",LineIconOnLeave)
	else
		self.icon:SetScript("OnEnter",nil)
		self.icon:SetScript("OnLeave",nil)	
	end
	
	if parent.methodsLineClick then
		self.clickFrame:SetScript("OnClick",LineIconOnClick)
		self.clickFrame:Show()
	else
		self.clickFrame:SetScript("OnClick",nil)
		self.clickFrame:Hide()	
	end

	--> Colors
	self.optionAlphaBackground = optionAlphaBackground
	self.optionAlphaTimeLine = optionAlphaTimeLine
	self.optionAlphaCooldown = optionAlphaCooldown
	
	for j=1,3 do
		for n=1,4 do
			local object = colorSetupFrameColorsObjectsNames[j]
			local state = colorSetupFrameColorsNames[n]
			
			self["optionColor"..object..state] = parent["optionColor"..object..state]
		end
	end
	self.classColor = module.db.notAClass
	
	self:SetAlpha(1)
	self.cooldown:Hide()
	self.iconText:SetText("")
	
	self:SetBackdropColor(self.optionColorBackgroundDefault.r,self.optionColorBackgroundDefault.g,self.optionColorBackgroundDefault.b,optionAlphaBackground)
	self.t:SetVertexColor(self.optionColorTimeLineDefault.r,self.optionColorTimeLineDefault.g,self.optionColorTimeLineDefault.b,optionAlphaTimeLine)
	self.t:SetWidth(self.t.ln)
end

module.db.lastSplitsReload = 0
function module:ReloadAllSplits(argScaleFix)
	local _ctime = GetTime()
	if module.db.lastSplitsReload > _ctime then
		return
	end
	module.db.lastSplitsReload = _ctime + 0.05
	local Width = 0
	local maxHeight = 0
	local maxLine = VExRT.ExCD2.colSet[module.db.maxColumns+1].frameLines or module.db.colsDefaults.frameLines
	local maxBetweenLines = 0
	if VExRT.ExCD2.colSet[module.db.maxColumns+1].frameColumns then
		maxLine = ceil(maxLine / VExRT.ExCD2.colSet[module.db.maxColumns+1].frameColumns)
	end	

	for i=1,module.db.maxColumns do
		module.frame.colFrame[i].iconSize = (not VExRT.ExCD2.colSet[i].iconGeneral and VExRT.ExCD2.colSet[i].iconSize) or (VExRT.ExCD2.colSet[i].iconGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].iconSize) or module.db.colsDefaults.iconSize
		if VExRT.ExCD2.colSet[i].enabled then
			maxHeight = max(maxHeight,module.frame.colFrame[i].iconSize)
		end
		
		local frameBetweenLines = (not VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[i].frameBetweenLines) or (VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].frameBetweenLines) or module.db.colsDefaults.frameBetweenLines

		local frameColumns = (not VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[i].frameColumns) or (VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].frameColumns) or module.db.colsDefaults.frameColumns
		local linesShown = (not VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[i].frameLines) or (VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].frameLines) or module.db.colsDefaults.frameLines	
		linesShown = ceil(linesShown / frameColumns)
		if VExRT.ExCD2.SplitOpt then 
			module.frame.colFrame[i]:SetHeight(module.frame.colFrame[i].iconSize*linesShown+frameBetweenLines*(linesShown-1)) 
		else
			module.frame.colFrame[i]:SetHeight(module.frame.colFrame[i].iconSize*linesShown)
			if VExRT.ExCD2.colSet[i].enabled then
				maxLine = max(maxLine,linesShown)
				maxBetweenLines = max(maxBetweenLines, frameBetweenLines*(linesShown-1) ) 
			end
		end

		local frameAlpha = (not VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[i].frameAlpha) or (VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].frameAlpha) or module.db.colsDefaults.frameAlpha
		module.frame.colFrame[i]:SetAlpha(frameAlpha/100) 

		local frameScale = (not VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[i].frameScale) or (VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].frameScale) or module.db.colsDefaults.frameScale
		if VExRT.ExCD2.SplitOpt then 
			if argScaleFix == "ScaleFix" then
				ExRT.mds.SetScaleFix(module.frame.colFrame[i],frameScale/100)
			else
				module.frame.colFrame[i]:SetScale(frameScale/100) 
			end
		else
			module.frame.colFrame[i]:SetScale(1)
		end
		
		local blackBack = (not VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[i].frameBlackBack) or (VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].frameBlackBack) or module.db.colsDefaults.frameBlackBack
		module.frame.colFrame[i].texture:SetTexture(0,0,0,blackBack / 100)

		--> New
		module.frame.colFrame[i].optionClassColorBackground = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureClassBackground) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureClassBackground)
		module.frame.colFrame[i].optionClassColorTimeLine = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureClassTimeLine) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureClassTimeLine)
		module.frame.colFrame[i].optionClassColorText = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureClassText) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureClassText)

		module.frame.colFrame[i].optionAnimation = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureAnimation) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureAnimation)
		module.frame.colFrame[i].optionLinesMax = min(linesShown*frameColumns,module.db.maxLinesInCol)
		module.frame.colFrame[i].optionShownOnCD = (not VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[i].methodsShownOnCD) or (VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].methodsShownOnCD)
		module.frame.colFrame[i].optionIconPosition = (not VExRT.ExCD2.colSet[i].iconGeneral and VExRT.ExCD2.colSet[i].iconPosition) or (VExRT.ExCD2.colSet[i].iconGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].iconPosition) or module.db.colsDefaults.iconPosition
		module.frame.colFrame[i].optionStyleAnimation = (not VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[i].methodsStyleAnimation) or (VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].methodsStyleAnimation) or module.db.colsDefaults.methodsStyleAnimation
		module.frame.colFrame[i].optionTimeLineAnimation = (not VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[i].methodsTimeLineAnimation) or (VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].methodsTimeLineAnimation) or module.db.colsDefaults.methodsTimeLineAnimation
		module.frame.colFrame[i].optionCooldown = (not VExRT.ExCD2.colSet[i].iconGeneral and VExRT.ExCD2.colSet[i].methodsCooldown) or (VExRT.ExCD2.colSet[i].iconGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].methodsCooldown)
		module.frame.colFrame[i].optionIconName = (not VExRT.ExCD2.colSet[i].textGeneral and VExRT.ExCD2.colSet[i].textIconName) or (VExRT.ExCD2.colSet[i].textGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textIconName)
		module.frame.colFrame[i].methodsIconTooltip = (not VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[i].methodsIconTooltip) or (VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].methodsIconTooltip) 
		module.frame.colFrame[i].methodsLineClick = (not VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[i].methodsLineClick) or (VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].methodsLineClick)

		module.frame.colFrame[i].textTemplateLeft = (not VExRT.ExCD2.colSet[i].textGeneral and VExRT.ExCD2.colSet[i].textTemplateLeft) or (VExRT.ExCD2.colSet[i].textGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textTemplateLeft) or module.db.colsDefaults.textTemplateLeft
		module.frame.colFrame[i].textTemplateRight = (not VExRT.ExCD2.colSet[i].textGeneral and VExRT.ExCD2.colSet[i].textTemplateRight) or (VExRT.ExCD2.colSet[i].textGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textTemplateRight) or module.db.colsDefaults.textTemplateRight
		module.frame.colFrame[i].textTemplateCenter = (not VExRT.ExCD2.colSet[i].textGeneral and VExRT.ExCD2.colSet[i].textTemplateCenter) or (VExRT.ExCD2.colSet[i].textGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textTemplateCenter) or module.db.colsDefaults.textTemplateCenter
		
		local frameWidth = (not VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[i].frameWidth) or (VExRT.ExCD2.colSet[i].frameGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].frameWidth) or module.db.colsDefaults.frameWidth
		module.frame.colFrame[i]:SetWidth(frameWidth*frameColumns)
		
		local optionGray = (not VExRT.ExCD2.colSet[i].iconGeneral and VExRT.ExCD2.colSet[i].iconGray) or (VExRT.ExCD2.colSet[i].iconGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].iconGray)
		local fontSize = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontSize) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontSize) or module.db.colsDefaults.fontSize
		local fontName = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontName) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontName) or module.db.colsDefaults.fontName
		local fontOutline = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontOutline) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontOutline)
		local fontShadow = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontShadow) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontShadow)
		local textureFile = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureFile) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureFile) or module.db.colsDefaults.textureFile
		local textureBorderSize = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureBorderSize) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureBorderSize) or module.db.colsDefaults.textureBorderSize
		module.frame.colFrame[i].backdrop = nil

		module.frame.colFrame[i].textureBorderColorR = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureBorderColorR) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureBorderColorR) or module.db.colsDefaults.textureBorderColorR
		module.frame.colFrame[i].textureBorderColorG = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureBorderColorG) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureBorderColorG) or module.db.colsDefaults.textureBorderColorG
		module.frame.colFrame[i].textureBorderColorB = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureBorderColorB) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureBorderColorB) or module.db.colsDefaults.textureBorderColorB
		module.frame.colFrame[i].textureBorderColorA = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureBorderColorA) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureBorderColorA) or module.db.colsDefaults.textureBorderColorA

		local fontOtherAvailable = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontOtherAvailable) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontOtherAvailable)

		local fontLeftSize = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontLeftSize) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontLeftSize) or module.db.colsDefaults.fontSize
		local fontLeftName = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontLeftName) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontLeftName) or module.db.colsDefaults.fontName
		local fontLeftOutline = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontLeftOutline) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontLeftOutline)
		local fontLeftShadow = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontLeftShadow) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontLeftShadow)

		local fontRightSize = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontRightSize) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontRightSize) or module.db.colsDefaults.fontSize
		local fontRightName = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontRightName) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontRightName) or module.db.colsDefaults.fontName
		local fontRightOutline = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontRightOutline) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontRightOutline)
		local fontRightShadow = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontRightShadow) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontRightShadow)

		local fontCenterSize = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontCenterSize) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontCenterSize) or module.db.colsDefaults.fontSize
		local fontCenterName = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontCenterName) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontCenterName) or module.db.colsDefaults.fontName
		local fontCenterOutline = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontCenterOutline) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontCenterOutline)
		local fontCenterShadow = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontCenterShadow) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontCenterShadow)

		local fontIconSize = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontIconSize) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontIconSize) or module.db.colsDefaults.fontSize
		local fontIconName = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontIconName) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontIconName) or module.db.colsDefaults.fontName
		local fontIconOutline = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontIconOutline) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontIconOutline)
		local fontIconShadow = (not VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[i].fontIconShadow) or (VExRT.ExCD2.colSet[i].fontGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].fontIconShadow)

		for j=1,3 do
			for n=1,4 do
				local object = colorSetupFrameColorsObjectsNames[j]
				local state = colorSetupFrameColorsNames[n]
				if not module.frame.colFrame[i]["optionColor"..object..state] then
					module.frame.colFrame[i]["optionColor"..object..state] = {}
				end

				module.frame.colFrame[i]["optionColor"..object..state].r = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i]["textureColor"..object..state.."R"]) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1]["textureColor"..object..state.."R"]) or module.db.colsDefaults["textureColor"..object..state.."R"]
				module.frame.colFrame[i]["optionColor"..object..state].g = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i]["textureColor"..object..state.."G"]) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1]["textureColor"..object..state.."G"]) or module.db.colsDefaults["textureColor"..object..state.."G"]
				module.frame.colFrame[i]["optionColor"..object..state].b = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i]["textureColor"..object..state.."B"]) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1]["textureColor"..object..state.."B"]) or module.db.colsDefaults["textureColor"..object..state.."B"]
			end
		end

		local optionAlphaBackground = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureAlphaBackground) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureAlphaBackground) or module.db.colsDefaults.textureAlphaBackground
		local optionAlphaTimeLine = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureAlphaTimeLine) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureAlphaTimeLine) or module.db.colsDefaults.textureAlphaTimeLine
		local optionAlphaCooldown = (not VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[i].textureAlphaCooldown) or (VExRT.ExCD2.colSet[i].textureGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].textureAlphaCooldown) or module.db.colsDefaults.textureAlphaCooldown

		for n=1,module.db.maxLinesInCol do
			module.ReloadLine(module.frame.colFrame[i].lines[n],frameWidth,module.frame.colFrame[i].iconSize,module.frame.colFrame[i].optionAnimation,module.frame.colFrame[i].optionClassColorBackground,module.frame.colFrame[i].optionClassColorTimeLine,module.frame.colFrame[i].optionClassColorText,module.frame.colFrame[i].optionStyleAnimation,module.frame.colFrame[i].optionTimeLineAnimation,module.frame.colFrame[i].optionIconPosition,optionGray,fontSize,fontName,fontOutline,fontShadow,textureFile,textureBorderSize,
				optionAlphaBackground,optionAlphaTimeLine,optionAlphaCooldown, fontOtherAvailable, fontLeftSize, fontLeftName, fontLeftOutline, fontLeftShadow, fontRightSize, fontRightName, fontRightOutline, fontRightShadow, fontCenterSize, fontCenterName, fontCenterOutline, fontCenterShadow, fontIconSize, fontIconName, fontIconOutline, fontIconShadow)
		end
		
		local frameAnchorBottom = (not VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[i].frameAnchorBottom) or (VExRT.ExCD2.colSet[i].methodsGeneral and VExRT.ExCD2.colSet[module.db.maxColumns+1].frameAnchorBottom)
		if frameAnchorBottom then
			for n=1,module.db.maxLinesInCol do 
				local inLine = (n-1) % frameColumns
				local line = ((n-1) - inLine) / frameColumns
				module.frame.colFrame[i].lines[n]:ClearAllPoints() 
				module.frame.colFrame[i].lines[n]:SetPoint("BOTTOMLEFT", inLine*frameWidth, line*module.frame.colFrame[i].iconSize+line*frameBetweenLines) 
			end
		else
			for n=1,module.db.maxLinesInCol do 
				local inLine = (n-1) % frameColumns
				local line = ExRT.mds.Round( ((n-1) - inLine) / frameColumns )
				module.frame.colFrame[i].lines[n]:ClearAllPoints()
				module.frame.colFrame[i].lines[n]:SetPoint("TOPLEFT", inLine*frameWidth, -line*module.frame.colFrame[i].iconSize-line*frameBetweenLines) 
			end
		end
		
		if VExRT.ExCD2.colSet[i].enabled and VExRT.ExCD2.enabled then
			module.frame.colFrame[i]:Show()
		else
			module.frame.colFrame[i]:Hide()
		end
		if not VExRT.ExCD2.SplitOpt then
			module.frame.colFrame[i]:ClearAllPoints()
			module.frame.colFrame[i]:SetPoint("TOPLEFT",module.frame,Width, 0)
		else
			if VExRT.ExCD2.colSet[i].posX and VExRT.ExCD2.colSet[i].posY then
				module.frame.colFrame[i]:ClearAllPoints()
				module.frame.colFrame[i]:SetPoint("TOPLEFT",UIParent,"BOTTOMLEFT",VExRT.ExCD2.colSet[i].posX,VExRT.ExCD2.colSet[i].posY)
			else
				module.frame.colFrame[i]:ClearAllPoints()
				module.frame.colFrame[i]:SetPoint("CENTER",UIParent,"CENTER",0,0)
			end
		end
		if VExRT.ExCD2.colSet[i].enabled then
			Width = Width + frameWidth*frameColumns
		end
	end
	module.frame:SetWidth(Width)
	module.frame:SetHeight(maxHeight*maxLine + maxBetweenLines)
	module.frame:SetAlpha((VExRT.ExCD2.colSet[module.db.maxColumns+1].frameAlpha or module.db.colsDefaults.frameAlpha)/100)
	if argScaleFix == "ScaleFix" then
		ExRT.mds.SetScaleFix(module.frame,(VExRT.ExCD2.colSet[module.db.maxColumns+1].frameScale or module.db.colsDefaults.frameScale)/100)
	else
		module.frame:SetScale((VExRT.ExCD2.colSet[module.db.maxColumns+1].frameScale or module.db.colsDefaults.frameScale)/100) 
	end
end

function module:SplitExCD2Window()
	if VExRT.ExCD2.SplitOpt then
		for i=1,module.db.maxColumns do 
			module.frame.colFrame[i]:SetParent(UIParent)
			module.frame.colFrame[i]:EnableMouse(false)

			if not VExRT.ExCD2.lock then 
				ExRT.mds.LockMove(module.frame.colFrame[i],true,module.frame.colFrame[i].lockTexture)
				ExRT.lib.AddShadowComment(module.frame.colFrame[i],nil,ExRT.L.cd2,i,72,"OUTLINE")
			end
		end
		module.frame:Hide()
	else
		for i=1,module.db.maxColumns do 
			module.frame.colFrame[i]:SetParent(module.frame)
			ExRT.mds.LockMove(module.frame.colFrame[i],nil,module.frame.colFrame[i].lockTexture)
			ExRT.lib.AddShadowComment(module.frame.colFrame[i],1)
		end
		module.frame:Show()
	end

end

function module:slash(arg1,arg2)
	if string.find(arg1,"runcd ") then
		local sid,name = string_match(arg2,"%a+ (%d+) (.+)")
		if sid and name then
			print("Run CD "..sid.." by "..name)
			module.main:COMBAT_LOG_EVENT_UNFILTERED(nil,"SPELL_CAST_SUCCESS",nil,nil,name,nil,nil,nil,nil,nil,nil,sid)
		end
	elseif string.find(arg1,"resetcd ") then
		local sid,name = string_match(arg2,"%a+ (%d+) (.+)")
		if sid and name then
			print("Reset CD "..sid.." by "..name)
			local j = module.db.cdsNav[name][sid]
			if j then
				module._C[j][3] = 0
			end
		end
	end
end

module.db.AllClassSpellsInText = [[
local module = GExRT.A.ExCD2
module.db.allClassSpells = {
["WARRIOR"] = {
	{107574,3,	{107574,180,	24},	nil,			nil,			nil,			},	--Avatar
	{18499,	3,	{18499,	30,	6},	nil,			nil,			nil,			},	--Berserker Rage
	{46924,	3,	{46924,	60,	6},	nil,			nil,			nil,			},	--Bladestorm
	{12292,	3,	{12292,	60,	12},	nil,			nil,			nil,			},	--Bloodbath
	{100,	3,	{100,	20,	0},	nil,			nil,			nil,			},	--Charge
	{1160,	3,	nil,			nil,			nil,			{1160,	60,	8},	},	--Demoralizing Shout
	{118038,3,	nil,			{118038,120,	8},	{118038,120,	8},	nil,			},	--Die by the Sword
	{118000,3,	{118000,60,	0},	nil,			nil,			nil,			},	--Dragon Roar
	{55694,	4,	{55694,	60,	5},	nil,			nil,			nil,			},	--Enraged Regeneration
	{52174,	3,	{52174,	45,	0},	nil,			nil,			nil,			},	--Heroic Leap
	{103840,4,	{103840,30,	0},	nil,			nil,			nil,			},	--Impending Victory
	{3411,	2,	{3411,	30,	10},	nil,			nil,			nil,			},	--Intervene
	{5246,	3,	{5246,	90,	0},	nil,			nil,			nil,			},	--Intimidating Shout
	{12975,	4,	nil,			nil,			nil,			{12975,	180,	15},	},	--Last Stand
	{114028,1,	{114028,30,	5},	nil,			nil,			nil,			},	--Mass Spell Reflection
	{114192,1,	nil,			nil,			nil,			{114192,180,	30},	},	--Mocking Banner
	{6552,	5,	{6552,	15,	0},	nil,			nil,			nil,			},	--Pummel
	{97462,	1,	nil,			{97462,	180,	10},	{97462,	180,	10},	nil,			},	--Rallying Cry
	{152277,3,	{152277,60,	10},	nil,			nil,			nil,			},	--Ravager
	{1719,	3,	nil,			{1719,	180,	10},	{1719,	180,	10},	nil,			},	--Recklessness
	{114029,2,	{114029,30,	6},	nil,			nil,			nil,			},	--Safeguard
	{64382,	3,	{64382,	300,	0},	nil,			nil,			nil,			},	--Shattering Throw
	{871,	4,	nil,			nil,			nil,			{871,	180,	8},	},	--Shield Wall
	{46968,	3,	{46968,	40,	0},	nil,			nil,			nil,			},	--Shockwave
	{176289,3,	nil,			{176289,45,	0},	{176289,45,	0},	nil,			},	--Siegebreaker
	{23920,	4,	{23920,	25,	5},	nil,			nil,			nil,			},	--Spell Reflection
	{107570,3,	{107570,30,	0},	nil,			nil,			nil,			},	--Storm Bolt
	{12328,	3,	nil,			{12328,	15,	0},	nil,			nil,			},	--Sweeping Strikes
	{355,	5,	{355,	8,	0},	nil,			nil,			nil,			},	--Taunt
	{114030,2,	{114030,120,	12},	nil,			nil,			nil,			},	--Vigilance
},
["PALADIN"] = {
	{31850,	4,	nil,			nil,			{31850,	180,	10},	nil,			},	--Ardent Defender
	{31842,	3,	nil,			{31842,	180,	0},	nil,			nil,			},	--Avenging Wrath
	{31884,	3,	nil,			nil,			nil,			{31884,	120,	0},	},	--Avenging Wrath
	{157007,3,	nil,			{157007,15,	0},	nil,			nil,			},	--Beacon of Insight
	--{115750,3,	{115750,120,	0},	nil,			nil,			nil,			},	--Blinding Light
	{4987,	5,	{4987,	8,	0},	nil,			nil,			nil,			},	--Cleanse
	{31821,	1,	nil,			{31821,	180,	6},	nil,			nil,			},	--Devotion Aura
	{498,	4,	{498,	60,	8},	nil,			nil,			nil,			},	--Divine Protection
	{642,	3,	{642,	300,	10},	nil,			nil,			nil,			},	--Divine Shield
	{114157,3,	{114157,60,	10},	nil,			nil,			nil,			},	--Execution Sentence
	{105593,3,	{105593,30,	0},	nil,			nil,			nil,			},	--Fist of Justice
	{86659,	4,	nil,			nil,			{86659,	180,	8},	nil,			},	--Guardian of Ancient Kings
	{853,	3,	{853,	60,	0},	nil,			nil,			nil,			},	--Hammer of Justice
	{1044,	2,	{1044,	25,	6},	nil,			nil,			nil,			},	--Hand of Freedom
	{1022,	2,	{1022,	300,	10},	nil,			nil,			nil,			},	--Hand of Protection
	{114039,2,	{114039,30,	6},	nil,			nil,			nil,			},	--Hand of Purity
	{6940,	2,	{6940,	120,	12},	nil,			nil,			{6940,	90,	12},	},	--Hand of Sacrifice
	{1038,	2,	nil,			nil,			{1038,	120,	10},	nil,			},	--Hand of Salvation
	{105809,3,	{105809,120,	18},	nil,			nil,			nil,			},	--Holy Avenger
	{114165,3,	{114165,20,	0},	nil,			nil,			nil,			},	--Holy Prism
	{633,	2,	{633,	600,	0},	nil,			nil,			nil,			},	--Lay on Hands
	{114158,3,	{114158,60,	14},	nil,			nil,			nil,			},	--Light's Hammer
	{96231,	5,	{96231,	15,	0},	nil,			nil,			nil,			},	--Rebuke
	{62124,	5,	{62124,	8,	0},	nil,			nil,			nil,			},	--Reckoning
	{20066,	3,	{20066,	15,	0},	nil,			nil,			nil,			},	--Repentance
	{152262,3,	nil,			nil,			{152262,30,	15},	{152262,30,	15},	},	--Seraphim
	{85499,	3,	{85499,	45,	8},	nil,			nil,			nil,			},	--Speed of Light
	{10326,	3,	{10326,	15,	0},	nil,			nil,			nil,			},	--Turn Evil
},
["HUNTER"] = {
	{131894,3,	{131894,60,	0},	nil,			nil,			nil,			},	--A Murder of Crows
	{172106,1,	{172106,180,	6},	nil,			nil,			nil,			},	--Aspect of the Fox
	{120360,3,	{120360,20,	0},	nil,			nil,			nil,			},	--Barrage
	{19574,	3,	nil,			{19574,	60,	10},	nil,			nil,			},	--Bestial Wrath
	{109248,3,	{109248,45,	0},	nil,			nil,			nil,			},	--Binding Shot
	{51753,	4,	{51753,	60,	0},	nil,			nil,			nil,			},	--Camouflage
	{147362,5,	{147362,24,	0},	nil,			nil,			nil,			},	--Counter Shot
	{19263,	4,	{19263,	180,	5},	nil,			nil,			nil,			},	--Deterrence
	{120679,3,	{120679,30,	15},	nil,			nil,			nil,			},	--Dire Beast
	{781,	4,	{781,	20,	0},	nil,			nil,			nil,			},	--Disengage
	{20736,	5,	{20736,	8,	0},	nil,			nil,			nil,			},	--Distracting Shot
	{109304,4,	{109304,120,	0},	nil,			nil,			nil,			},	--Exhilaration
	{13813,	3,	{13813,	30,	0},	nil,			nil,			{13813,	15,	0},	},	--Explosive Trap
	{5384,	4,	{5384,	30,	0},	nil,			nil,			nil,			},	--Feign Death
	{1543,	3,	{1543,	20,	0},	nil,			nil,			nil,			},	--Flare
	{1499,	3,	{1499,	30,	0},	nil,			nil,			{1499,	15,	0},	},	--Freezing Trap
	{117050,3,	{117050,15,	0},	nil,			nil,			nil,			},	--Glaive Toss
	{13809,	3,	{13809,	30,	0},	nil,			nil,			{13809,	15,	0},	},	--Ice Trap
	{19577,	3,	{19577,	60,	0},	nil,			nil,			nil,			},	--Intimidation
	{53271,	2,	{53271,	45,	4},	nil,			nil,			nil,			},	--Master's Call
	{34477,	3,	{34477,	30,	0},	nil,			nil,			nil,			},	--Misdirection
	{109259,3,	{109259,45,	0},	nil,			nil,			nil,			},	--Powershot
	{3045,	3,	nil,			nil,			{3045,	120,	0},	nil,			},	--Rapid Fire
	{121818,3,	{121818,300,	0},	nil,			nil,			nil,			},	--Stampede
	{19386,	3,	{19386,	45,	0},	nil,			nil,			nil,			},	--Wyvern Sting
},
["ROGUE"] = {
	{13750,	3,	nil,			nil,			{13750,	180,	15},	nil,			},	--Adrenaline Rush
	{2094,	3,	{2094,	120,	0},	nil,			nil,			nil,			},	--Blind
	{31224,	4,	{31224,	60,	5},	nil,			nil,			nil,			},	--Cloak of Shadows
	{74001,	4,	{74001,	120,	20},	nil,			nil,			nil,			},	--Combat Readiness
	{152150,3,	{152150,20,	0},	nil,			nil,			nil,			},	--Death from Above
	{1725,	3,	{1725,	30,	0},	nil,			nil,			nil,			},	--Distract
	{5277,	4,	{5277,	120,	10},	nil,			nil,			nil,			},	--Evasion
	{1776,	3,	{1776,	10,	0},	nil,			nil,			nil,			},	--Gouge
	{1766,	5,	{1766,	15,	0},	nil,			nil,			nil,			},	--Kick
	{408,	3,	{408,	20,	0},	nil,			nil,			nil,			},	--Kidney Shot
	{51690,	3,	nil,			nil,			{51690,	120,	3},	nil,			},	--Killing Spree
	{137619,3,	{137619,60,	0},	nil,			nil,			nil,			},	--Marked for Death
	{14183,	3,	nil,			nil,			nil,			{14183,	20,	0},	},	--Premeditation
	{14185,	3,	{14185,	300,	0},	nil,			nil,			nil,			},	--Preparation
	{51713,	3,	nil,			nil,			nil,			{51713,	60,	10},	},	--Shadow Dance
	{152151,3,	{152151,120,	8},	nil,			nil,			nil,			},	--Shadow Reflection
	{36554,	3,	{36554,	20,	0},	nil,			nil,			nil,			},	--Shadowstep
	{5938,	3,	{5938,	10,	0},	nil,			nil,			nil,			},	--Shiv
	{114018,1,	{114018,300,	15},	nil,			nil,			nil,			},	--Shroud of Concealment
	{76577,	1,	{76577,	180,	5},	nil,			nil,			nil,			},	--Smoke Bomb
	{2983,	3,	{2983,	60,	8},	nil,			nil,			nil,			},	--Sprint
	{57934,	3,	{57934,	30,	6},	nil,			nil,			nil,			},	--Tricks of the Trade
	{1856,	4,	{1856,	120,	6},	nil,			nil,			{1856,	90,	6},	},	--Vanish
	{79140,	3,	nil,			{79140,	120,	20},	nil,			nil,			},	--Vendetta
},
["PRIEST"] = {
	{81700,	3,	nil,			{81700,	30,	18},	nil,			nil,			},	--Archangel
	{121135,3,	nil,			{121135,25,	0},	{121135,25,	0},	{127632,25,	0},	},	--Cascade
	{81209,	3,	nil,			nil,			{81209,	10,	0},	nil,			},	--Chakra: Chastise
	{81206,	3,	nil,			nil,			{81206,	10,	0},	nil,			},	--Chakra: Sanctuary
	{81208,	3,	nil,			nil,			{81208,	10,	0},	nil,			},	--Chakra: Serenity
	{34861,	3,	nil,			nil,			{34861,	12,	0},	nil,			},	--Circle of Healing
	{19236,	4,	{19236,	120,	0},	nil,			nil,			nil,			},	--Desperate Prayer
	{47585,	4,	nil,			nil,			nil,			{47585,	120,	6},	},	--Dispersion
	{64843,	1,	nil,			nil,			{64843,	180,	8},	nil,			},	--Divine Hymn
	{110744,3,	nil,			{110744,15,	0},	{110744,15,	0},	{122121,15,	0},	},	--Divine Star
	{586,	4,	{586,	30,	10},	nil,			nil,			nil,			},	--Fade
	{6346,	2,	{6346,	180,	0},	nil,			nil,			nil,			},	--Fear Ward
	{47788,	2,	nil,			nil,			{47788,	180,	10},	nil,			},	--Guardian Spirit
	{120517,1,	nil,			{120517,40,	0},	{120517,40,	0},	{120644,40,	0},	},	--Halo
	{88625,	3,	nil,			nil,			{88625,	30,	0},	nil,			},	--Holy Word: Chastise
	{88684,	3,	{88684,	10,	0},	nil,			nil,			nil,			},	--Holy Word: Serenity
	{73325,	2,	{73325,	90,	0},	nil,			nil,			nil,			},	--Leap of Faith
	{126135,3,	nil,			nil,			{126135,180,	0},	nil,			},	--Lightwell
	{32375,	5,	{32375,	15,	0},	nil,			nil,			nil,			},	--Mass Dispel
	{123040,3,	{123040,60,	15},	nil,			nil,			nil,			},	--Mindbender
	{33206,	2,	nil,			{33206,	180,	8},	nil,			nil,			},	--Pain Suppression
	{10060,	3,	{10060,	120,	20},	nil,			nil,			nil,			},	--Power Infusion
	{62618,	1,	nil,			{62618,	180,	10},	nil,			nil,			},	--Power Word: Barrier
	{64044,	3,	nil,			nil,			nil,			{64044,	45,	0},	},	--Psychic Horror
	{8122,	3,	{8122,	45,	0},	nil,			nil,			nil,			},	--Psychic Scream
	{34433,	1,	{34433,	180,	0},	nil,			nil,			nil,			},	--Shadowfiend
	{15487,	3,	nil,			{15487,	45,	0},	nil,			{15487,	45,	0},	},	--Silence
	{112833,4,	{112833,30,	6},	nil,			nil,			nil,			},	--Spectral Guise
	{109964,1,	nil,			{109964,60,	10},	nil,			nil,			},	--Spirit Shell
	{15286,	1,	nil,			nil,			nil,			{15286,	180,	15},	},	--Vampiric Embrace
	{108920,3,	{108920,30,	0},	nil,			nil,			nil,			},	--Void Tendrils
	{527,	5,	nil,			{527,	8,	0},	{527,	8,	0},	nil,			},	--Очищение
},
["DEATHKNIGHT"] = {
	{48707,	4,	{48707,	45,	5},	nil,			nil,			nil,			},	--Anti-Magic Shell
	{51052,	1,	{51052,	120,	3},	nil,			nil,			nil,			},	--Anti-Magic Zone
	{42650,	3,	{42650,	600,	0},	nil,			nil,			nil,			},	--Army of the Dead
	{108194,3,	{108194,30,	0},	nil,			nil,			nil,			},	--Asphyxiate
	{49222,	4,	nil,			{49222,	60,	0},	nil,			nil,			},	--Bone Shield
	{152279,3,	{152279,120,	0},	nil,			nil,			nil,			},	--Breath of Sindragosa
	{49028,	3,	nil,			{49028,	90,	8},	nil,			nil,			},	--Dancing Rune Weapon
	{56222,	5,	nil,			{56222,	8,	0},	nil,			nil,			},	--Dark Command
	{77606,	3,	{77606,	60,	0},	nil,			nil,			nil,			},	--Dark Simulacrum
	{49576,	3,	{49576,	25,	0},	{49576,	20,	0},	nil,			nil,			},	--Death Grip
	{48743,	4,	{48743,	120,	0},	nil,			nil,			nil,			},	--Death Pact
	{43265,	3,	{43265,	30,	10},	nil,			nil,			nil,			},	--Death and Decay
	{96268,	4,	{96268,	30,	6},	nil,			nil,			nil,			},	--Death's Advance
	{152280,3,	{152280,30,	0},	nil,			nil,			nil,			},	--Defile
	{108201,4,	{108201,120,	10},	nil,			nil,			nil,			},	--Desecrated Ground
	{47568,	3,	{47568,	300,	0},	nil,			nil,			nil,			},	--Empower Rune Weapon
	{108199,1,	{108199,60,	0},	nil,			nil,			nil,			},	--Gorefiend's Grasp
	{48792,	4,	{48792,	180,	8},	nil,			nil,			nil,			},	--Icebound Fortitude
	{49039,	4,	{49039,	120,	10},	nil,			nil,			nil,			},	--Lichborne
	{47528,	5,	{47528,	15,	0},	nil,			nil,			nil,			},	--Mind Freeze
	{77575,	3,	{77575,	60,	0},	nil,			nil,			nil,			},	--Outbreak
	{51271,	3,	nil,			nil,			{51271,	60,	20},	nil,			},	--Pillar of Frost
	{123693,3,	{123693,25,	0},	nil,			nil,			nil,			},	--Plague Leech
	{61999,	3,	{61999,	600,	0},	nil,			nil,			nil,			},	--Raise Ally
	{46584,	3,	nil,			nil,			nil,			{46584,	60,	0},	},	--Raise Dead
	{108200,3,	{108200,60,	0},	nil,			nil,			nil,			},	--Remorseless Winter
	{47476,	3,	{47476,	60,	0},	nil,			nil,			nil,			},	--Strangulate
	{49206,	3,	nil,			nil,			nil,			{49206,	180,	40},	},	--Summon Gargoyle
	{115989,3,	{115989,90,	10},	nil,			nil,			nil,			},	--Unholy Blight
	{55233,	4,	nil,			{55233,	60,	10},	nil,			nil,			},	--Vampiric Blood
},
["SHAMAN"] = {
	{108281,1,	{108281,120,	10},	nil,			nil,			nil,			},	--Ancestral Guidance
	{16188,	3,	{16188,	90,	0},	nil,			nil,			nil,			},	--Ancestral Swiftness
	{114049,3,	{114049,180,	15},	{165339,180,	15},	{165341,180,	15},	{165344,180,	15},	},	--Ascendance
	{108271,4,	{108271,90,	6},	nil,			nil,			nil,			},	--Astral Shift
	{2825,	3,	{2825,	300,	40},	nil,			nil,			nil,			},	--Bloodlust
	{108285,3,	{108285,180,	0},	nil,			nil,			nil,			},	--Call of the Elements
	{108269,3,	{108269,45,	5},	nil,			nil,			nil,			},	--Capacitor Totem
	{51886,	5,	{51886,	8,	0},	nil,			nil,			{77130,	8,	0},	},	--Cleanse Spirit
	{157153,3,	nil,			nil,			nil,			{157153,30,	15},	},	--Cloudburst Totem
	{2062,	3,	{2062,	300,	0},	nil,			nil,			nil,			},	--Earth Elemental Totem
	{2484,	3,	{2484,	30,	20},	nil,			nil,			nil,			},	--Earthbind Totem
	{51485,	3,	{51485,	30,	20},	nil,			nil,			nil,			},	--Earthgrab Totem
	{117014,3,	{117014,12,	0},	nil,			nil,			nil,			},	--Elemental Blast
	{16166,	3,	{16166,	120,	20},	nil,			nil,			nil,			},	--Elemental Mastery
	{51533,	3,	nil,			nil,			{51533,	120,	30},	nil,			},	--Feral Spirit
	{2894,	3,	{2894,	300,	0},	nil,			nil,			nil,			},	--Fire Elemental Totem
	{8177,	1,	{8177,	25,	0},	nil,			nil,			nil,			},	--Grounding Totem
	{5394,	3,	{5394,	30,	15},	nil,			nil,			nil,			},	--Healing Stream Totem
	{108280,1,	nil,			nil,			nil,			{108280,180,	10},	},	--Healing Tide Totem
	{51514,	3,	{51514,	45,	0},	nil,			nil,			nil,			},	--Hex
	{152255,3,	nil,			{152255,45,	0},	{152255,45,	0},	nil,			},	--Liquid Magma
	{20608,	3,	{21169,	1800,	0},	nil,			nil,			nil,			},	--Reincarnation
	{30823,	4,	nil,			{30823,	60,	15},	{30823,	60,	15},	nil,			},	--Shamanistic Rage
	{98008,	1,	nil,			nil,			nil,			{98008,	180,	6},	},	--Spirit Link Totem
	{58875,	3,	nil,			nil,			{58875,	60,	15},	nil,			},	--Spirit Walk
	{79206,	3,	nil,			{79206,	120,	15},	nil,			{79206,	120,	15},	},	--Spiritwalker's Grace
	{108270,4,	{108270,60,	0},	nil,			nil,			nil,			},	--Stone Bulwark Totem
	{152256,3,	{152256,300,	0},	nil,			nil,			nil,			},	--Storm Elemental Totem
	{51490,	3,	nil,			{51490,	45,	0},	nil,			nil,			},	--Thunderstorm
	{108287,3,	{108287,10,	0},	nil,			nil,			nil,			},	--Totemic Projection
	{8143,	1,	{8143,	60,	10},	nil,			nil,			nil,			},	--Tremor Totem
	{73680,	3,	nil,			nil,			{73680,	15,	0},	nil,			},	--Unleash Elements
	{165462,3,	nil,			{165462,15,	0},	nil,			nil,			},	--Unleash Flame
	{57994,	5,	{57994,	12,	0},	nil,			nil,			nil,			},	--Wind Shear
	{108273,1,	{108273,60,	6},	nil,			nil,			nil,			},	--Windwalk Totem
},
["MAGE"] = {
	{108978,4,	{108978,90,	10},	nil,			nil,			nil,			},	--Alter Time
	{159916,1,	{159916,120,	6},	nil,			nil,			nil,			},	--Amplify Magic
	{153626,3,	nil,			{153626,15,	0},	nil,			nil,			},	--Arcane Orb
	{12042,	3,	nil,			{12042,	90,	15},	nil,			nil,			},	--Arcane Power
	{108843,4,	{108843,25,	1.5},	nil,			nil,			nil,			},	--Blazing Speed
	{1953,	4,	{1953,	15,	0},	nil,			nil,			nil,			},	--Blink
	{11958,	4,	{11958,	180,	0},	nil,			nil,			nil,			},	--Cold Snap
	{11129,	3,	nil,			nil,			{11129,	45,	10},	nil,			},	--Combustion
	{153595,3,	nil,			nil,			nil,			{153595,30,	0},	},	--Comet Storm
	{120,	3,	{120,	12,	0},	nil,			nil,			nil,			},	--Cone of Cold
	{2139,	5,	{2139,	24,	0},	nil,			nil,			nil,			},	--Counterspell
	{44572,	3,	nil,			nil,			nil,			{44572,	30,	0},	},	--Deep Freeze
	{31661,	3,	nil,			nil,			{31661,	20,	0},	nil,			},	--Dragon's Breath
	{157913,4,	{157913,45,	3},	nil,			nil,			nil,			},	--Evanesce
	{12051,	3,	nil,			{12051,	90,	6},	nil,			nil,			},	--Evocation
	{122,	3,	{122,	30,	0},	nil,			nil,			nil,			},	--Frost Nova
	{102051,3,	{102051,20,	0},	nil,			nil,			nil,			},	--Frostjaw
	{84714,	3,	nil,			nil,			nil,			{84714,	60,	0},	},	--Frozen Orb
	{110959,4,	{110959,90,	20},	nil,			nil,			nil,			},	--Greater Invisibility
	{11426,	4,	{11426,	25,	0},	nil,			nil,			nil,			},	--Ice Barrier
	{45438,	4,	{45438,	300,	10},	nil,			nil,			nil,			},	--Ice Block
	{111264,2,	{111264,20,	0},	nil,			nil,			nil,			},	--Ice Ward
	{12472,	3,	nil,			nil,			nil,			{12472,	180,	20},	},	--Icy Veins
	{66,	4,	{66,	300,	20},	nil,			nil,			nil,			},	--Invisibility
	{153561,3,	nil,			nil,			{153561,45,	0},	nil,			},	--Meteor
	{55342,	3,	{55342,	120,	0},	nil,			nil,			nil,			},	--Mirror Image
	{12043,	3,	nil,			{12043,	90,	0},	nil,			nil,			},	--Presence of Mind
	{152087,3,	{152087,60,	0},	nil,			nil,			nil,			},	--Prismatic Crystal
	{475,	5,	{475,	8,	0},	nil,			nil,			nil,			},	--Remove Curse
	{113724,3,	{113724,45,	10},	nil,			nil,			nil,			},	--Ring of Frost
	{31687,	3,	nil,			nil,			nil,			{31687,	60,	0},	},	--Summon Water Elemental
	{80353,	3,	{80353,	300,	40},	nil,			nil,			nil,			},	--Time Warp
},
["WARLOCK"] = {
	{111397,4,	{111397,60,	0},	nil,			nil,			nil,			},	--Blood Horror
	{152108,3,	{152108,60,	0},	nil,			nil,			nil,			},	--Cataclysm
	{110913,4,	{110913,180,	8},	nil,			nil,			nil,			},	--Dark Bargain
	{108359,4,	{108359,120,	12},	nil,			nil,			nil,			},	--Dark Regeneration
	{77801,	3,	nil,			{113860,120,	20},	{113861,120,	20},	{113858,120,	20},	},	--Dark Soul: Instability
	{48020,	4,	{48020,	30,	0},	nil,			nil,			nil,			},	--Demonic Circle: Teleport
	{109151,4,	nil,			nil,			{109151,10,	0},	nil,			},	--Demonic Leap
	{120451,3,	nil,			nil,			nil,			{120451,60,	0},	},	--Flames of Xoroth
	{108503,3,	nil,			{108503,30,	0},	nil,			{108503,30,	0},	},	--Grimoire of Sacrifice
	{108501,3,	nil,			nil,			{108501,120,	0},	nil,			},	--Grimoire of Service
	{80240,	3,	nil,			nil,			nil,			{80240,	20,	0},	},	--Havoc
	{5484,	3,	{5484,	40,	0},	nil,			nil,			nil,			},	--Howl of Terror
	{137587,3,	{137587,60,	8},	nil,			nil,			nil,			},	--Kil'jaeden's Cunning
	{108508,3,	{108508,60,	10},	nil,			nil,			nil,			},	--Mannoroth's Fury
	{6789,	4,	{6789,	45,	0},	nil,			nil,			nil,			},	--Mortal Coil
	{108416,4,	{108416,60,	0},	nil,			nil,			nil,			},	--Sacrificial Pact
	{30283,	3,	{30283,	30,	0},	nil,			nil,			nil,			},	--Shadowfury
	{29858,	4,	{29858,	120,	0},	nil,			nil,			nil,			},	--Soulshatter
	{20707,	3,	{20707,	600,	0},	nil,			nil,			nil,			},	--Soulstone
	{18540,	3,	{18540,	600,	0},	nil,			nil,			nil,			},	--Summon Doomguard
	{1122,	3,	{1122,	600,	0},	nil,			nil,			nil,			},	--Summon Infernal
	{108482,4,	{108482,120,	0},	nil,			nil,			nil,			},	--Unbound Will
	{104773,4,	{104773,180,	8},	nil,			nil,			nil,			},	--Unending Resolve
},
["MONK"] = {
	{157535,3,	nil,			nil,			nil,			{157535,90,	10},	},	--Breath of the Serpent
	{119392,3,	{119392,30,	3},	nil,			nil,			nil,			},	--Charging Ox Wave
	{123986,3,	{123986,30,	0},	nil,			nil,			nil,			},	--Chi Burst
	{115098,3,	{115098,15,	0},	nil,			nil,			nil,			},	--Chi Wave
	{122278,4,	{122278,90,	0},	nil,			nil,			nil,			},	--Dampen Harm
	{115460,3,	nil,			nil,			nil,			{115460,10,	0},	},	--Detonate Chi
	{122783,4,	{122783,90,	6},	nil,			nil,			nil,			},	--Diffuse Magic
	{115288,3,	nil,			nil,			{115288,60,	6},	nil,			},	--Energizing Brew
	{115072,3,	{115072,15,	0},	nil,			nil,			nil,			},	--Expel Harm
	{113656,3,	nil,			nil,			{113656,25,	0},	nil,			},	--Fists of Fury
	{101545,3,	nil,			nil,			{101545,25,	0},	nil,			},	--Flying Serpent Kick
	{115203,4,	{115203,180,	15},	nil,			nil,			nil,			},	--Fortifying Brew
	{115295,4,	nil,			{115295,30,	0},	nil,			nil,			},	--Guard
	{152175,3,	nil,			nil,			{152175,45,	0},	nil,			},	--Hurricane Strike
	{123904,3,	{123904,180,	0},	nil,			nil,			nil,			},	--Invoke Xuen, the White Tiger
	{119381,3,	{119381,45,	0},	nil,			nil,			nil,			},	--Leg Sweep
	{116849,2,	nil,			nil,			nil,			{116849,100,	12},	},	--Life Cocoon
	{137562,4,	{137562,120,	6},	nil,			nil,			nil,			},	--Nimble Brew
	{115078,3,	{115078,15,	0},	nil,			nil,			nil,			},	--Paralysis
	{115546,5,	{115546,8,	0},	nil,			nil,			nil,			},	--Provoke
	{115310,1,	nil,			nil,			nil,			{115310,180,	0},	},	--Revival
	{116844,3,	{116844,45,	8},	nil,			nil,			nil,			},	--Ring of Peace
	{152173,3,	nil,			{152173,90,	10},	{152173,90,	10},	nil,			},	--Serenity
	{116705,5,	{116705,15,	0},	nil,			nil,			nil,			},	--Spear Hand Strike
	{116680,3,	nil,			nil,			nil,			{116680,45,	0},	},	--Thunder Focus Tea
	{116841,2,	{116841,30,	6},	nil,			nil,			nil,			},	--Tiger's Lust
	{115080,3,	{115080,90,	0},	nil,			nil,			nil,			},	--Touch of Death
	{122470,4,	nil,			nil,			{122470,90,	10},	nil,			},	--Touch of Karma
	{101643,3,	{101643,10,	0},	nil,			nil,			nil,			},	--Transcendence
	{119996,4,	{119996,25,	0},	nil,			nil,			nil,			},	--Transcendence: Transfer
	{115176,4,	nil,			{115176,180,	8},	{115176,180,	8},	nil,			},	--Zen Meditation
	{115450,5,	{115450,8,	0},	nil,			nil,			nil,			},	--Детоксикация
},
["DRUID"] = {
	{22812,	4,	nil,			{22812,	60,	12},	nil,			{22812,	60,	12},	{22812,	60,	12},	},	--Barkskin
	{106952,3,	nil,			nil,			{106952,180,	10},	{106952,180,	15},	nil,			},	--Berserk
	{155835,4,	nil,			nil,			nil,			{155835,60,	3},	nil,			},	--Bristling Fur
	{112071,3,	nil,			{112071,180,	15},	nil,			nil,			nil,			},	--Celestial Alignment
	{102351,3,	{102351,30,	0},	nil,			nil,			nil,			nil,			},	--Cenarion Ward
	{1850,	3,	{1850,	180,	15},	nil,			nil,			nil,			nil,			},	--Dash
	{102280,3,	{102280,30,	4},	nil,			nil,			nil,			nil,			},	--Displacer Beast
	{6795,	5,	{6795,	8,	0},	nil,			nil,			nil,			nil,			},	--Growl
	{108294,3,	nil,			{108291,360,	40},	{108292,360,	40},	{108293,360,	40},	{108294,360,	40},	},	--Heart of the Wild
	{99,	3,	{99,	30,	0},	nil,			nil,			nil,			nil,			},	--Incapacitating Roar
	{33891,	3,	nil,			nil,			nil,			nil,			{33891,	180,	15},	},	--Incarnation: Tree of Life
	{102342,2,	nil,			nil,			nil,			nil,			{102342,60,	12},	},	--Ironbark
	{102359,3,	{102359,30,	20},	nil,			nil,			nil,			nil,			},	--Mass Entanglement
	{5211,	3,	{5211,	50,	0},	nil,			nil,			nil,			nil,			},	--Mighty Bash
	{132158,3,	nil,			nil,			nil,			nil,			{132158,60,	0},	},	--Nature's Swiftness
	{124974,3,	{124974,90,	30},	nil,			nil,			nil,			nil,			},	--Nature's Vigil
	{20484,	3,	{20484,	600,	0},	nil,			nil,			nil,			nil,			},	--Rebirth
	{2782,	5,	{2782,	8,	0},	nil,			nil,			nil,			{88423,	8,	0},	},	--Remove Corruption
	{108238,4,	{108238,120,	0},	nil,			nil,			nil,			nil,			},	--Renewal
	{106839,5,	nil,			nil,			{106839,15,	0},	{106839,15,	0},	nil,			},	--Skull Bash
	{78675,	5,	nil,			{78675,	60,	8},	nil,			nil,			nil,			},	--Solar Beam
	{106898,1,	{106898,120,	0},	nil,			{77764,	120,	8},	{77761,	120,	8},	nil,			},	--Stampeding Roar
	{61336,	4,	nil,			nil,			{61336,	12,	6},	{61336,	12,	6},	nil,			},	--Survival Instincts
	{5217,	3,	nil,			nil,			{5217,	30,	8},	nil,			nil,			},	--Tiger's Fury
	{740,	1,	nil,			nil,			nil,			nil,			{740,	480,	8},	},	--Tranquility
	{132469,3,	{132469,30,	0},	nil,			nil,			nil,			nil,			},	--Typhoon
	{102793,3,	{102793,60,	10},	nil,			nil,			nil,			nil,			},	--Ursol's Vortex
	{102401,3,	{102401,15,	0},	nil,			nil,			nil,			nil,			},	--Wild Charge
},
["PET"] = {
	{90355,	3,	"HUNTER"},
	{160011,3,	"HUNTER"},
	{159926,3,	"HUNTER"},
	{160063,3,	"HUNTER"},
	{159931,3,	"HUNTER"},
	{26064,	3,	"HUNTER"},
	{159956,3,	"HUNTER"},
	{61684,	3,	"HUNTER"},
	{55709,	3,	"HUNTER"},
	{53490,	3,	"HUNTER"},
	{53480,	2,	"HUNTER"},
	{90339,	3,	"HUNTER"},
	{53478,	3,	"HUNTER"},
	{61685,	3,	"HUNTER"},
	{159953,3,	"HUNTER"},
	{126393,3,	"HUNTER"},
	{137798,3,	"HUNTER"},
	{90361,	3,	"HUNTER"},
	{160044,3,	"HUNTER"},
	{91802,	5,	"DEATHKNIGHT"},
	{91797,	3,	"DEATHKNIGHT"},
	{89751,	3,	"WARLOCK"},
	{89766,	5,	"WARLOCK"},
	{115276,5,	"WARLOCK"},
	{17767,	3,	"WARLOCK"},
	{89808,	5,	"WARLOCK"},
	{119899,4,	"WARLOCK"},
	{89792,	3,	"WARLOCK"},
	{115781,5,	"WARLOCK"},
	{115284,3,	"WARLOCK"},
	{115831,3,	"WARLOCK"},
	{115268,3,	"WARLOCK"},
	{6358,	3,	"WARLOCK"},
	{19647,	5,	"WARLOCK"},
	{19505,	3,	"WARLOCK"},
	{135029,3,	"MAGE"},
	{33395,	3,	"MAGE"},
},
}
]]