-----------
-- Database
-----------
UItatDB = {};
UItatDB["HasBeenRun"] = 0;

-----------------
-- slash commands
-----------------
SLASH_UITAT1 = "/uitat"
SlashCmdList["UITAT"] = function()
	UItat_Main:Show();
end

----------
--bindings
----------
BINDING_HEADER_UITAT = "UItat";
BINDING_NAME_UITATSHOW = "Configuration options";

---------------------------------------------------------------
-- OnLoad and Event declarations, automatic until first config.
---------------------------------------------------------------
function UItat_Main_OnLoad()
	UItat_Main:RegisterEvent("PLAYER_ENTERING_WORLD");
end

function UItat_Main_OnEvent()
	if 	UItatDB.HasBeenRun == 0 then
	   	UItat_Main:Show();
	end
end

-----------------------------------------------------------
-- Functions that are run when main window is opened/closed
-----------------------------------------------------------
function UItat_Main_OnShow()
	UItat_Outline:Show();
end

function UItat_Main_OnHide()
	UItat_Outline:Hide();
end


--[[
-- Primary functions that are run OnClick:
-- 1) Load settings common to all classes
-- 2) Load Class-specific settings
-- 3) Add savedvariable so it no longer auto-opens on login
-- 4) Reload the UI
]]--

function DEATHKNIGHT_OnClick()
	Generic_Setup();
	DeathKnight_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function MONK_OnClick()
	Generic_Setup();
	Monk_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function DRUID_OnClick()
	Generic_Setup();
	Druid_Setup();
 	UItatDB.HasBeenRun = 1;
 	ReloadUI();
end

function HUNTER_OnClick()
	Generic_Setup();
	Hunter_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function MAGE_OnClick()
	Generic_Setup();
	Mage_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function PALADIN_OnClick()
	Generic_Setup();
	Paladin_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function PRIEST_OnClick()
	Generic_Setup();
	Priest_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function ROGUE_OnClick()
	Generic_Setup();
	Rogue_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function SHAMAN_OnClick()
	Generic_Setup();
	Shaman_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function WARLOCK_OnClick()
	Generic_Setup();
	Warlock_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end

function WARRIOR_OnClick()
	Generic_Setup();
	Warrior_Setup();
	UItatDB.HasBeenRun = 1;
	ReloadUI();
end


--[[
-- Generic settings common to all classes
-- (checks first if addon is loaded)
]]--

function Generic_Setup()
	SetCVar("useuiScale", 1);
--	SetCVar("uiScale", 0.6);
--	SetCVar("enableCombatText", 0);
--	SetCVar("CombatDamage", 0);
--	SetCVar("CombatHealing", 0);
--	SetCVar("fctSpellMechanics", 0);
	SetCVar("displaySpellActivationOverlays", 0);
--	SetCVar("consolidateBuffs", 0);
	if IsAddOnLoaded("Broker2FuBar") then
		Broker2FuBar = LibStub("AceAddon-3.0"):GetAddon("Broker2FuBar",true);
		Broker2FuBar.db:CopyProfile("UItat - Server");
	end
	if IsAddOnLoaded("Outfitter") then
		Outfitter.Settings.Options.HideMinimapButton = 1;
		Outfitter.Settings.Options.DisableItemComparisons = 1;
	end
	if IsAddOnLoaded("AtlasLoot") then
--		AtlasLootLoader.db.MiniMapButton.hide = true;
	end
	if IsAddOnLoaded("Castbars") then
		Castbars = LibStub("AceAddon-3.0"):GetAddon("Castbars",true);
		Castbars.db:CopyProfile("Default");
	end
	if IsAddOnLoaded("Proximo") then
		Proximo.db:CopyProfile("UItat");
	end
	if IsAddOnLoaded("Broker_Auditor") then
		AuditorBroker.db.profile.hideTotalInBar = true;
		AuditorBroker.db.global.LibDBIcon.hide = true;
	end
	if IsAddOnLoaded("Auditor2") then
		Auditor.db.profile.autoRepair = true;
		Auditor.db.realm.sellGreys = true;
	end
	if IsAddOnLoaded("InlineAura") then
		InlineAura = LibStub("AceAddon-3.0"):GetAddon("InlineAura",true);
		InlineAura.db.profile.hideCountdown = true;	
	end
	if IsAddOnLoaded("Recount") then
		Recount.db:CopyProfile("UItat");
		Recount.MainWindow:Hide();
	end
	if IsAddOnLoaded("Raven") then
		Raven.db:SetProfile("Default");
	end
	if IsAddOnLoaded("Dominos") then
		Dominos:CopyProfile("UItat");
	end
	if IsAddOnLoaded("Omen") then
		Omen.db:CopyProfile("UItat - Server");
	end
	 if IsAddOnLoaded("SLDataText") then
		SLDataText.db:CopyProfile("Uitat - Hakkar");
	end 
	
end


---------------------------------------------
-- Class-specific settings (currently unused)
---------------------------------------------

function DeathKnight_Setup()
end

function Monk_Setup()
end

function Druid_Setup()
end

function Hunter_Setup()
end

function Mage_Setup()
end

function Paladin_Setup()
end

function Priest_Setup()
end

function Rogue_Setup()
end

function Shaman_Setup()
end

function Warlock_Setup()
end

function Warrior_Setup()
end

