----------------------------------------------------------------------
-- 	Leatrix Plus 5.1.01
-- 	Last updated: 28th November 2012
-- 
--	For the latest version, go to www.leatrix.com.
----------------------------------------------------------------------
--[[

	00: Start					You're reading it
	01: Locks					Option panel control locking mechanism
	02: Restarts				Options which require a UI reload
	03: Functions				Various functions used throughout the addon
	04: Load and Save			Handles loading and saving of the settings

	20: Live					Code that runs after ADDON_LOADED and when an option changes
	21: Isolated environment	Code that runs after ADDON_LOADED
	22: Tooltip customisation	Tooltip customisation code (runs under isolated environment)
	23: Variable				Code that runs after VARIABLES_LOADED
	24: Frame customisation		Frame customisation code (runs under variable)
	25: Player					Code that runs after PLAYER_ENTERING_WORLD	
	26: BlizzDep				Code that runs after a required Blizzard addon has loaded
	30: RunOnce					Generic code that runs after the Isolated Environment
	31: Events					Code that runs when a specific event fires
	32: Slash commands			Slash command handler

	40: Panel functions			Functions used for creating options panel elements
	41: Options panel frame		Code that creates the main options panel frame
	42: Options panel pages		Code that creates the individual options panel pages
	50+ Panel pages				Code that populates the individual options panel pages

--]]
----------------------------------------------------------------------
-- 	Addon code
----------------------------------------------------------------------

--  Create global tables if they don't exist
	LeaPlusDB = LeaPlusDB or {}
	LeaPlusDC = LeaPlusDC or {}

-- 	Create local tables to store configuration and frames
	local LeaPlusLC = {}
	local LeaPlusCB = {}
	local LeaDropList = {};
	local void

--	Initialise variables
	LeaPlusLC["ShowErrorsFlag"] = 1
	LeaPlusLC["NumberOfPages"] = 7
	LeaPlusLC["PlayerLocale"] = GetLocale()
	LeaPlusLC["PlayerClass"] = select(2,UnitClass("player"))
	LeaPlusLC["PlayerName"] = UnitName("player")
	LeaPlusLC["GameVer"] = strsub(select(4, GetBuildInfo()),1,1)
	LeaPlusLC["PlusVersion"] = GetAddOnMetadata("Leatrix_Plus", "Version")

--	Create dungeon spam array
	LeaPlusLC["InterruptSpamTable"] = {"gag order", "dispel", "rallying cry", "shield wall", "avenger", "divine protection", "interrupted", "taunt", "activate", "mind freeze", "rebuke", "bash", "pummel", "silence", "counterspell", "wind shear", "spell lock", "salvation", "strangulate", "purge"}
	LeaPlusLC["InterruptSpamTip"] = "\n"
	for k,v in pairs(LeaPlusLC["InterruptSpamTable"]) do
		LeaPlusLC["InterruptSpamTip"] = LeaPlusLC["InterruptSpamTip"] .. "\n" .. LeaPlusLC["InterruptSpamTable"][k]
	end

--	Create event frame
	local LpEvt = CreateFrame("FRAME");
	LpEvt:RegisterEvent("ADDON_LOADED");
	LpEvt:RegisterEvent("VARIABLES_LOADED");
	LpEvt:RegisterEvent("PLAYER_ENTERING_WORLD");
	LpEvt:RegisterEvent("PLAYER_LOGOUT");

----------------------------------------------------------------------
--	L01: Locks
----------------------------------------------------------------------

-- 	Lock and unlock individual items
	function LeaPlusLC:LockItem(item,lock)
		if lock then
			item:Disable()
			item:SetAlpha(0.3)
		else
			item:Enable()
			item:SetAlpha(1.0)
		end
	end

--	Lock and dim invalid options
	function LeaPlusLC:SetDim()

		-- Player chains
		if (LeaPlusLC["ShowElitePlayerChain"] ~= LeaPlusDB["ShowElitePlayerChain"]) or LeaPlusLC["ShowElitePlayerChain"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["ShowRarePlayerChain"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["ShowRarePlayerChain"],false)
		end

		-- Protect privacy (yeah right)
		if (LeaPlusLC["AchieveControl"] ~= LeaPlusDB["AchieveControl"]) or LeaPlusLC["AchieveControl"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["CharOnlyAchieves"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["CharOnlyAchieves"],false)
		end

		-- Tooltip scale slider
		if not (LeaPlusLC["TipModEnable"] == LeaPlusDB["TipModEnable"]) or LeaPlusLC["TipScaleCheck"] == "Off" or LeaPlusLC["TipModEnable"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusTipSize"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusTipSize"],false)
		end

		-- Spell icons
		if (LeaPlusLC["ShowSpellIcons"] ~= LeaPlusDB["ShowSpellIcons"]) or LeaPlusLC["ShowSpellIcons"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["SpellIconsBtn"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["SpellIconsBtn"],false)
		end

		-- Frame options
		if (LeaPlusLC["FrmEnabled"] ~= LeaPlusDB["FrmEnabled"]) or LeaPlusLC["FrmEnabled"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["MoveFramesButton"],true)
		elseif LeaPlusLC["FrmEnabled"] == "On" then
			LeaPlusLC:LockItem(LeaPlusCB["MoveFramesButton"],false)
		end

		-- World map modification button
		if (LeaPlusLC["ShowMapMod"] ~= LeaPlusDB["ShowMapMod"]) or LeaPlusLC["ShowMapMod"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["MapOptBtn"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["MapOptBtn"],false)
		end

		-- Camera zoom level
		if (LeaPlusLC["ManageZoomLevel"] ~= LeaPlusDB["ManageZoomLevel"]) or LeaPlusLC["ManageZoomLevel"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["ZoomOutLevel"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["ZoomOutLevel"],false)
		end

		-- Tooltip options
		if (LeaPlusLC["TipModEnable"] ~= LeaPlusDB["TipModEnable"]) or LeaPlusLC["TipModEnable"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["TipShowTitle"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowRank"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowRace"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowTarget"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowMobType"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowClass"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowRealm"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipBackSimple"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipBackFriend"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipBackHostile"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipScaleCheck"],true)
			LeaPlusLC:LockItem(LeaPlusCB["MoveTooltipButton"],true)
			LeaPlusLC:LockItem(LeaPlusCB["TipAnchorToMouse"],true)
			LeaPlusLC:LockItem(LeaPlusCB["ModTipMouseBtn"],true)

		elseif LeaPlusLC["TipModEnable"] == "On" then

			LeaPlusLC:LockItem(LeaPlusCB["TipShowTitle"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowRank"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowRace"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowTarget"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowMobType"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowClass"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipShowRealm"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipBackSimple"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipBackFriend"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipBackHostile"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipScaleCheck"],false)
			LeaPlusLC:LockItem(LeaPlusCB["MoveTooltipButton"],false)
			LeaPlusLC:LockItem(LeaPlusCB["TipAnchorToMouse"],false)
			LeaPlusLC:LockItem(LeaPlusCB["ModTipMouseBtn"],false)

			-- Anchor to mouse
			if (LeaPlusLC["TipAnchorToMouse"] ~= LeaPlusDB["TipAnchorToMouse"]) or LeaPlusLC["TipAnchorToMouse"] == "Off" then
				LeaPlusLC:LockItem(LeaPlusCB["ModTipMouseBtn"],true)
			else
				LeaPlusLC:LockItem(LeaPlusCB["ModTipMouseBtn"],false)
			end

		end

		-- Quest detail font slider lockout
		if (LeaPlusLC["QuestFontChange"] ~= LeaPlusDB["QuestFontChange"]) or LeaPlusLC["QuestFontChange"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusQuestFontSize"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusQuestFontSize"],false)
		end

		-- Mail font slider lockout
		if (LeaPlusLC["MailFontChange"] ~= LeaPlusDB["MailFontChange"]) or LeaPlusLC["MailFontChange"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusMailFontSize"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusMailFontSize"],false)
		end

		-- Automatically accept quest lockout
		if LeaPlusLC["AutoAcceptQuests"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["AcceptOnlyDailys"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["AcceptOnlyDailys"],false)
		end

		-- Automatically turn-in quest lockout
		if LeaPlusLC["AutoTurnInQuests"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["TurnInOnlyDailys"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["TurnInOnlyDailys"],false)
		end

		-- Block NPC spam resting only filter
		if LeaPlusLC["NoNPCSpam"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["NoNPCSpamRest"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["NoNPCSpamRest"],false)
		end

		-- Automatic resurrection lockout
		if LeaPlusLC["AutoAcceptRes"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["NoAutoResInCombat"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["NoAutoResInCombat"],false)
		end

		-- Error frame quest lockout
		if LeaPlusLC["HideErrorFrameText"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["ShowQuestUpdates"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["ShowQuestUpdates"],false)
		end

		-- Leatrix Plus panel tooltip placement
		if LeaPlusLC["PlusShowTips"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["PanelTipAnchor"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["PanelTipAnchor"],false)
		end

		-- Leatrix Plus scale
		if LeaPlusLC["PlusPanelScaleCheck"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusScaleValue"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusScaleValue"],false)
		end

		-- Leatrix Plus alpha
		if LeaPlusLC["PlusPanelAlphaCheck"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusAlphaValue"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["LeaPlusAlphaValue"],false)
		end

		-- Hide soulbound confirmations
		if (LeaPlusLC["NoConfirmBoP"] ~= LeaPlusDB["NoConfirmBoP"]) or LeaPlusLC["NoConfirmBoP"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["BoPShowWarning"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["BoPShowWarning"],false)
		end

		-- Class coloring lockout
		if (LeaPlusLC["Manageclasscolors"] ~= LeaPlusDB["Manageclasscolors"]) or LeaPlusLC["Manageclasscolors"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["ColorLocalChannels"],true)
			LeaPlusLC:LockItem(LeaPlusCB["ColorGlobalChannels"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["ColorLocalChannels"],false)
			LeaPlusLC:LockItem(LeaPlusCB["ColorGlobalChannels"],false)
		end

		-- Trade and guild block lockout
		if (LeaPlusLC["ManageTradeGuild"] ~= LeaPlusDB["ManageTradeGuild"]) or LeaPlusLC["ManageTradeGuild"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["NoTradeRequests"],true)
			LeaPlusLC:LockItem(LeaPlusCB["NoGuildInvites"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["NoTradeRequests"],false)
			LeaPlusLC:LockItem(LeaPlusCB["NoGuildInvites"],false)
		end

		-- Automated repair with guild
		if LeaPlusLC["AutoRepairOwnFunds"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["AutoRepairGuildFunds"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["AutoRepairGuildFunds"],false)
		end

		-- Viewport
		if (LeaPlusLC["ViewPortEnable"] ~= LeaPlusDB["ViewPortEnable"]) or LeaPlusLC["ViewPortEnable"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["ModViewportBtn"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["ModViewportBtn"],false)
		end

		-- Minimap customisation
		if (LeaPlusLC["MinimapMod"] ~= LeaPlusDB["MinimapMod"]) or LeaPlusLC["MinimapMod"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["ModMinimapBtn"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["ModMinimapBtn"],false)
		end

		-- Static coordinates
		if (LeaPlusLC["StaticCoordsEn"] ~= LeaPlusDB["StaticCoordsEn"]) or LeaPlusLC["StaticCoordsEn"] == "Off" then
			LeaPlusLC:LockItem(LeaPlusCB["ModStaticCoordsBtn"],true)
		else
			LeaPlusLC:LockItem(LeaPlusCB["ModStaticCoordsBtn"],false)
		end

	end

----------------------------------------------------------------------
--	L02: Restarts
----------------------------------------------------------------------

	-- Check to see if any options require a UI reload
	function LeaPlusLC:ReloadCheck()

		if	(LeaPlusLC["NoClassBar"]				~= LeaPlusDB["NoClassBar"])
		or	(LeaPlusLC["NoCharControls"]			~= LeaPlusDB["NoCharControls"])
		or	(LeaPlusLC["ManageTradeGuild"] 			~= LeaPlusDB["ManageTradeGuild"])
		or	(LeaPlusLC["ShowQuestLevels"] 			~= LeaPlusDB["ShowQuestLevels"])
		or	(LeaPlusLC["QuestFontChange"]			~= LeaPlusDB["QuestFontChange"])
		or	(LeaPlusLC["MailFontChange"]			~= LeaPlusDB["MailFontChange"])
		or	(LeaPlusLC["NoStickyChat"]				~= LeaPlusDB["NoStickyChat"])
		or	(LeaPlusLC["UseArrowKeysInChat"]		~= LeaPlusDB["UseArrowKeysInChat"])
		or	(LeaPlusLC["ShowElitePlayerChain"]		~= LeaPlusDB["ShowElitePlayerChain"])
		or	(LeaPlusLC["HideZoneText"]				~= LeaPlusDB["HideZoneText"])
		or	(LeaPlusLC["HideSubzoneText"]			~= LeaPlusDB["HideSubzoneText"])
		or	(LeaPlusLC["UseArrowKeysInChat"]		~= LeaPlusDB["UseArrowKeysInChat"])
		or	(LeaPlusLC["NoGryphons"]				~= LeaPlusDB["NoGryphons"])
		or	(LeaPlusLC["NoRaidRestrictions"]		~= LeaPlusDB["NoRaidRestrictions"])
		or	(LeaPlusLC["NoChatFade"]				~= LeaPlusDB["NoChatFade"])
		or	(LeaPlusLC["NoBagAutomation"]			~= LeaPlusDB["NoBagAutomation"])
		or	(LeaPlusLC["NoSpecSpam"]				~= LeaPlusDB["NoSpecSpam"])
		or	(LeaPlusLC["FrmEnabled"]				~= LeaPlusDB["FrmEnabled"])
		or	(LeaPlusLC["ShowMinimapIcon"]			~= LeaPlusDB["ShowMinimapIcon"])
		or	(LeaPlusLC["Manageclasscolors"]			~= LeaPlusDB["Manageclasscolors"])
		or	(LeaPlusLC["UseEasyChatResizing"]		~= LeaPlusDB["UseEasyChatResizing"])
		or	(LeaPlusLC["NoCombatLogTab"]			~= LeaPlusDB["NoCombatLogTab"])
		or	(LeaPlusLC["MaxChatHstory"] 			~= LeaPlusDB["MaxChatHstory"])
		or	(LeaPlusLC["MoveChatEditBoxToTop"] 		~= LeaPlusDB["MoveChatEditBoxToTop"])
		or	(LeaPlusLC["TipModEnable"] 				~= LeaPlusDB["TipModEnable"])
		or	(LeaPlusLC["HideErrorFrameText"] 		~= LeaPlusDB["HideErrorFrameText"])
		or	(LeaPlusLC["ShowVanityButtons"] 		~= LeaPlusDB["ShowVanityButtons"])
		or	(LeaPlusLC["ShowHonorStat"] 			~= LeaPlusDB["ShowHonorStat"])
		or	(LeaPlusLC["DungeonFinderButtons"] 		~= LeaPlusDB["DungeonFinderButtons"])
		or	(LeaPlusLC["NoChatButtons"]				~= LeaPlusDB["NoChatButtons"])
		or	(LeaPlusLC["ShowVolume"]				~= LeaPlusDB["ShowVolume"])
		or	(LeaPlusLC["ShowDressTab"]				~= LeaPlusDB["ShowDressTab"])
		or	(LeaPlusLC["AhExtras"]					~= LeaPlusDB["AhExtras"])
		or	(LeaPlusLC["NoLootWonAlert"]			~= LeaPlusDB["NoLootWonAlert"])
		or	(LeaPlusLC["AchieveControl"]			~= LeaPlusDB["AchieveControl"])
		or	(LeaPlusLC["RoleSave"]					~= LeaPlusDB["RoleSave"])
		or	(LeaPlusLC["DurabilityStatus"]			~= LeaPlusDB["DurabilityStatus"])
		or	(LeaPlusLC["ViewPortEnable"]			~= LeaPlusDB["ViewPortEnable"])
		or	(LeaPlusLC["TipAnchorToMouse"]			~= LeaPlusDB["TipAnchorToMouse"])
		or	(LeaPlusLC["ShowMapMod"]				~= LeaPlusDB["ShowMapMod"])
		or	(LeaPlusLC["MinimapMod"]				~= LeaPlusDB["MinimapMod"])
		or	(LeaPlusLC["StaticCoordsEn"]			~= LeaPlusDB["StaticCoordsEn"])
		or	(LeaPlusLC["NoConfirmBoP"]				~= LeaPlusDB["NoConfirmBoP"])
		or	(LeaPlusLC["ManageZoomLevel"]			~= LeaPlusDB["ManageZoomLevel"])
		or	(LeaPlusLC["ShowSpellIcons"]			~= LeaPlusDB["ShowSpellIcons"])

		then
			LeaPlusLC:LockItem(LeaPlusCB["ReloadUIButton"],false)
		else
			LeaPlusLC:LockItem(LeaPlusCB["ReloadUIButton"],true)
		end

	end

----------------------------------------------------------------------
--	L03: Functions
----------------------------------------------------------------------

	-- Show memory usage stat
	function LeaPlusLC:ShowMemoryUsage(frame, anchor, x, y, text)
		local memoryusage = frame:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
		memoryusage:SetPoint(anchor, x, y)
		memoryusage:SetText(text)

		memoryusage.stat = frame:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
		memoryusage.stat:SetPoint("LEFT", memoryusage, "RIGHT")
		memoryusage.stat:SetText("(calculating...)")

		local memorytimer = 0
		frame:SetScript("OnUpdate", function(self, elapsed)
			memorytimer = memorytimer + elapsed;
			while (memorytimer > 2) do
				UpdateAddOnMemoryUsage();
				memoryusage.stat:SetText(string.format("%.f", GetAddOnMemoryUsage("Leatrix_Plus")).. " KB");
				memorytimer = 0;
			end
		end)
	end

	-- Does character have duel spec
	function LeaPlusLC:IsDualSpec()
		if GetNumSpecGroups() == 2 then
			return true
		else
			return false
		end
	end

	-- Print currently active talent spec
	function LeaPlusLC:ShowActiveSpec()
		if LeaPlusLC:IsDualSpec() then
			local cspec = GetSpecialization();
			if not cspec then return end
			local specsaver = {"Primary Spec", "Secondary Spec"}
			local void, spectree, void, icon, void, role = GetSpecializationInfo(cspec);
			if icon and spectree and role then
				LeaPlusLC:Print("|T" .. icon .. ":0|t " .. spectree .. " (" .. string.upper(string.sub(role, 1, 1)).. string.lower(string.sub(role, 2, (string.len(role)))).. ", ".. specsaver[GetActiveSpecGroup()].. ")")
			end
		end
	end

	-- Check if player is in LFG queue
	function LeaPlusLC:IsInLFGQueue()
 		if GetLFGMode(LE_LFG_CATEGORY_LFD) or GetLFGMode(LE_LFG_CATEGORY_LFR) or GetLFGMode(LE_LFG_CATEGORY_RF) or GetLFGMode(LE_LFG_CATEGORY_SCENARIO) then
			return true
		end
	end

	-- Hide self
	function LeaPlusLC:HideSelf() self:Hide(); end;

	-- Show self
	function LeaPlusLC:ShowSelf() self:Show(); end;
	
	-- Print text
	function LeaPlusLC:Print(text) DEFAULT_CHAT_FRAME:AddMessage(text, 1.0, 0.85, 0.0); end;

	-- Check if player is in combat
	function LeaPlusLC:PlayerInCombat(status)
		if (UnitAffectingCombat("player")) then
			LeaPlusLC:Print("You cannot do that in combat.")
			return true
		end
	end

	--  Hide pages
	function LeaPlusLC:HideFrames()

		-- Hide option pages
		for i = 0, LeaPlusLC["NumberOfPages"] do
			if LeaPlusLC["Page"..i] then
				LeaPlusLC["Page"..i]:Hide();
			end;
		end

		-- Hide special pages
		LeaPlusLC["PageF"]:Hide(); -- Options panel
		LeaPlusLC["PageS"]:Hide(); -- Settings page

	end

	-- Show button tooltips for Leatrix Plus settings
	function LeaPlusLC:ShowTooltip()
		if LeaPlusLC["PlusShowTips"] == "On" then
			GameTooltip:SetOwner(self, "ANCHOR_NONE")
			if LeaPlusLC["PanelTipAnchor"] == "On" then
				-- Show tips on the right side of the panel
				GameTooltip:SetPoint("TOPRIGHT",LeaPlusLC["PageF"],"TOPLEFT",0,0)
			else
				-- Show tips on the left side of the panel
				GameTooltip:SetPoint("TOPLEFT",LeaPlusLC["PageF"],"TOPRIGHT",0,0)
			end
			GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true)
		end
	end

	-- Show button tooltips for interface settings (top side)
	function LeaPlusLC:ShowFacetip()
		if LeaPlusLC["PlusFaceTips"] == "On" then
			GameTooltip:SetOwner(self, "ANCHOR_TOP")
			GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true)
		end
	end

	function LeaPlusLC:AddLeftTip(control, tip)
		control:SetScript("OnEnter", function()
			if LeaPlusLC["PlusFaceTips"] == "On" then
				GameTooltip:SetOwner(control, "ANCHOR_LEFT", -10, -50)
				GameTooltip:SetText(tip, nil, nil, nil, nil, true)
			end
		end)
	end

	-- Hide button tooltips
	function LeaPlusLC:HideTooltip() 
		GameTooltip:Hide() 
	end

	-- Check if a player is in your friends list
	function LeaPlusLC:FriendCheck(name)
		ShowFriends()
		for i = 1, GetNumFriends() do
			if (name == GetFriendInfo(i)) then
				return true
			end
		end
		return false;
	end

	-- Check if a player is in guild
	function LeaPlusLC:GuildCheck(name)
		if IsInGuild("player") then
			if UnitIsInMyGuild(name) then
				return true
			else
				return false;
			end
		end
	end

	-- Check if a player is in your Real ID friends list
	function LeaPlusLC:RealIDCheck(name)
		ShowFriends() 
		for i = 1, BNGetNumFriends() do
			local presenceID, void, void, void, void, void, client, isOnline = BNGetFriendInfo(i)
			if (client == "WoW" and isOnline) then
				local void, toonname, void, realmname = BNGetToonInfo(presenceID)
				if (name == toonname) or (name == toonname .. "-" .. realmname) then
					return true
				end
			end
		end
		return false;
	end

	-- Block NPC spam filter
	function LeaPlusLC:BlockNPCSpam()
		if LeaPlusLC["NoNPCSpamRest"] == "Off" then
			-- Resting only filter is off so block all NPC say spam
			return true
		else
			-- Resting only filter is on, only block NPC say spam if character is resting
			if IsResting() then 
				return true 
			end
		end
	end

	-- Block interrupt spam
	function LeaPlusLC:LeaPlusInterruptFilter(...)
		local void,msg = ...
		if not (IsInInstance() == nil) and (UnitAffectingCombat("player")) then
			for k,v in pairs(LeaPlusLC["InterruptSpamTable"]) do
				if string.lower(msg):find(v) then
					return true
				end
			end
		end
	end

----------------------------------------------------------------------
--	L04: Load and Save Global Profile
----------------------------------------------------------------------

-- 	Copy globals to locals
	function LeaPlusLC:Load()

		-- Automation
		LeaPlusLC["AcceptPartyFriends"]		= LeaPlusDB["AcceptPartyFriends"] 	or "Off"
		LeaPlusLC["AcceptPartyGuild"]		= LeaPlusDB["AcceptPartyGuild"] 	or "Off"
		LeaPlusLC["AutoConfirmRole"]		= LeaPlusDB["AutoConfirmRole"]		or "Off"
		LeaPlusLC["InviteFromWhisper"]		= LeaPlusDB["InviteFromWhisper"]	or "Off"

		LeaPlusLC["AutoReleaseInBG"] 		= LeaPlusDB["AutoReleaseInBG"] 		or "Off"
		LeaPlusLC["AutoAcceptRes"] 			= LeaPlusDB["AutoAcceptRes"]		or "Off"
		LeaPlusLC["NoAutoResInCombat"]		= LeaPlusDB["NoAutoResInCombat"]	or "Off"

		LeaPlusLC["NoDuelRequests"] 		= LeaPlusDB["NoDuelRequests"]		or "Off"
		LeaPlusLC["NoPartyInvites"] 		= LeaPlusDB["NoPartyInvites"]		or "Off"

		LeaPlusLC["ManageTradeGuild"] 		= LeaPlusDB["ManageTradeGuild"]		or "Off"
		LeaPlusLC["NoTradeRequests"]		= LeaPlusDB["NoTradeRequests"]		or "On"
		LeaPlusLC["NoGuildInvites"]			= LeaPlusDB["NoGuildInvites"]		or "On"

		-- Interaction
		LeaPlusLC["ShowQuestLevels"]		= LeaPlusDB["ShowQuestLevels"]		or "Off"
		LeaPlusLC["AutoAcceptQuests"]		= LeaPlusDB["AutoAcceptQuests"]		or "Off"
		LeaPlusLC["AcceptOnlyDailys"]		= LeaPlusDB["AcceptOnlyDailys"]		or "Off"
		LeaPlusLC["AutoTurnInQuests"]		= LeaPlusDB["AutoTurnInQuests"]		or "Off"
		LeaPlusLC["TurnInOnlyDailys"]		= LeaPlusDB["TurnInOnlyDailys"]		or "Off"

		LeaPlusLC["QuestFontChange"] 		= LeaPlusDB["QuestFontChange"]		or "Off"
		LeaPlusLC["LeaPlusQuestFontSize"] 	= LeaPlusDB["LeaPlusQuestFontSize"]	or "18"

		LeaPlusLC["AutoSellJunk"]			= LeaPlusDB["AutoSellJunk"]			or "Off"
		LeaPlusLC["AutoRepairOwnFunds"]		= LeaPlusDB["AutoRepairOwnFunds"]	or "Off"
		LeaPlusLC["AutoRepairGuildFunds"]	= LeaPlusDB["AutoRepairGuildFunds"]	or "Off"
		LeaPlusLC["NoBagAutomation"] 		= LeaPlusDB["NoBagAutomation"]		or "Off"
		LeaPlusLC["AhExtras"]				= LeaPlusDB["AhExtras"]				or "Off"
		LeaPlusLC["AhBuyoutOnly"]			= LeaPlusDB["AhBuyoutOnly"]			or "Off"
		LeaPlusLC["AhGoldOnly"]				= LeaPlusDB["AhGoldOnly"]			or "Off"

		LeaPlusLC["NoRaidRestrictions"]		= LeaPlusDB["NoRaidRestrictions"]	or "Off"
		LeaPlusLC["NoConfirmLoot"]			= LeaPlusDB["NoConfirmLoot"]		or "Off"
		LeaPlusLC["NoConfirmBoP"]			= LeaPlusDB["NoConfirmBoP"]			or "Off"
		LeaPlusLC["BoPShowWarning"]			= LeaPlusDB["BoPShowWarning"]		or "On"
		LeaPlusLC["NoLootWonAlert"]			= LeaPlusDB["NoLootWonAlert"]		or "Off"
		LeaPlusLC["RoleSave"]				= LeaPlusDB["RoleSave"]				or "Off"

		-- Chat
		LeaPlusLC["UseEasyChatResizing"]	= LeaPlusDB["UseEasyChatResizing"]	or "Off"
		LeaPlusLC["NoCombatLogTab"]			= LeaPlusDB["NoCombatLogTab"]		or "Off"
		LeaPlusLC["NoChatButtons"]			= LeaPlusDB["NoChatButtons"]		or "Off"
		LeaPlusLC["MoveChatEditBoxToTop"]	= LeaPlusDB["MoveChatEditBoxToTop"]	or "Off"

		LeaPlusLC["Manageclasscolors"]		= LeaPlusDB["Manageclasscolors"]	or "Off"
		LeaPlusLC["ColorLocalChannels"]		= LeaPlusDB["ColorLocalChannels"]	or "Off"
		LeaPlusLC["ColorGlobalChannels"]	= LeaPlusDB["ColorGlobalChannels"]	or "Off"

		LeaPlusLC["NoStickyChat"]			= LeaPlusDB["NoStickyChat"]			or "Off"
		LeaPlusLC["UseArrowKeysInChat"]		= LeaPlusDB["UseArrowKeysInChat"]	or "Off"
		LeaPlusLC["NoChatFade"]				= LeaPlusDB["NoChatFade"]			or "Off"
		LeaPlusLC["MaxChatHstory"]			= LeaPlusDB["MaxChatHstory"]		or "Off"

		-- Text
		LeaPlusLC["HideZoneText"] 			= LeaPlusDB["HideZoneText"]			or "Off"
		LeaPlusLC["HideSubzoneText"] 		= LeaPlusDB["HideSubzoneText"]		or "Off"

		LeaPlusLC["HideErrorFrameText"]		= LeaPlusDB["HideErrorFrameText"]	or "Off"
		LeaPlusLC["ShowQuestUpdates"]		= LeaPlusDB["ShowQuestUpdates"]		or "Off"

		LeaPlusLC["NoSpecSpam"] 			= LeaPlusDB["NoSpecSpam"]			or "Off"
		LeaPlusLC["NoNPCSpam"] 				= LeaPlusDB["NoNPCSpam"]			or "Off"
		LeaPlusLC["NoNPCSpamRest"] 			= LeaPlusDB["NoNPCSpamRest"]		or "Off"
		LeaPlusLC["NoInterruptSpam"]		= LeaPlusDB["NoInterruptSpam"]		or "Off"

		LeaPlusLC["MailFontChange"]			= LeaPlusDB["MailFontChange"]		or "Off"
		LeaPlusLC["LeaPlusMailFontSize"]	= LeaPlusDB["LeaPlusMailFontSize"]	or "22"

		-- Tooltip
		LeaPlusLC["TipModEnable"] 			= LeaPlusDB["TipModEnable"]			or "Off"
		LeaPlusLC["TipPosAnchor"] 			= LeaPlusDB["TipPosAnchor"]			or "BOTTOMRIGHT"
		LeaPlusLC["TipPosRelative"] 		= LeaPlusDB["TipPosRelative"]		or "BOTTOMRIGHT"
		LeaPlusLC["TipPosXOffset"] 			= LeaPlusDB["TipPosXOffset"]		or "-13"
		LeaPlusLC["TipPosYOffset"] 			= LeaPlusDB["TipPosYOffset"]		or "94"

		LeaPlusLC["TipShowTitle"] 			= LeaPlusDB["TipShowTitle"]			or "Off"
		LeaPlusLC["TipShowRealm"] 			= LeaPlusDB["TipShowRealm"]			or "On"
		LeaPlusLC["TipShowRace"] 			= LeaPlusDB["TipShowRace"]			or "On"
		LeaPlusLC["TipShowClass"] 			= LeaPlusDB["TipShowClass"]			or "On"
		LeaPlusLC["TipShowRank"] 			= LeaPlusDB["TipShowRank"]			or "On"
		LeaPlusLC["TipShowMobType"] 		= LeaPlusDB["TipShowMobType"]		or "On"
		LeaPlusLC["TipShowTarget"] 			= LeaPlusDB["TipShowTarget"]		or "On"

		LeaPlusLC["TipBackSimple"] 			= LeaPlusDB["TipBackSimple"]		or "On"
		LeaPlusLC["TipBackFriend"] 			= LeaPlusDB["TipBackFriend"]		or "Off"
		LeaPlusLC["TipBackHostile"] 		= LeaPlusDB["TipBackHostile"]		or "Off"

		LeaPlusLC["TipAnchorToMouse"] 		= LeaPlusDB["TipAnchorToMouse"]		or "Off"
		LeaPlusLC["TipMouseOffsetX"] 		= LeaPlusDB["TipMouseOffsetX"]		or 0
		LeaPlusLC["TipMouseOffsetY"] 		= LeaPlusDB["TipMouseOffsetY"]		or 0
		LeaPlusLC["TipMouseAnchor"] 		= LeaPlusDB["TipMouseAnchor"]		or 1
		LeaPlusLC["TipAlpha"] 				= LeaPlusDB["TipAlpha"]				or 1.0
		LeaPlusLC["TipHideCombat"] 			= LeaPlusDB["TipHideCombat"]		or "Off"
		LeaPlusLC["TipScaleCheck"] 			= LeaPlusDB["TipScaleCheck"]		or "Off"
		LeaPlusLC["LeaPlusTipSize"] 		= LeaPlusDB["LeaPlusTipSize"]		or "1.25"

		-- Frames
		LeaPlusLC["FrmEnabled"] 			= LeaPlusDB["FrmEnabled"]			or "Off"

		LeaPlusLC["NoGryphons"]				= LeaPlusDB["NoGryphons"]			or "Off"
		LeaPlusLC["NoClassBar"]				= LeaPlusDB["NoClassBar"]			or "Off"
		LeaPlusLC["NoCharControls"]			= LeaPlusDB["NoCharControls"]		or "Off"

		-- Interface
		LeaPlusLC["ShowMapMod"] 			= LeaPlusDB["ShowMapMod"]			or "Off"
		LeaPlusLC["MapRevealBox"] 			= LeaPlusDB["MapRevealBox"]			or "On"
		LeaPlusLC["MapQuestBox"] 			= LeaPlusDB["MapQuestBox"]			or "On"
		LeaPlusLC["LeaPlusMapScale"] 		= LeaPlusDB["LeaPlusMapScale"]		or "1.0"
		LeaPlusLC["LeaPlusMapOpacity"] 		= LeaPlusDB["LeaPlusMapOpacity"]	or "0.0"
		LeaPlusLC["MapLock"] 				= LeaPlusDB["MapLock"]				or "Off"
		LeaPlusLC["MapQuestLeft"] 			= LeaPlusDB["MapQuestLeft"]			or "Off"
		LeaPlusLC["MapA"] 					= LeaPlusDB["MapA"]					or "TOPLEFT"
		LeaPlusLC["MapX"] 					= LeaPlusDB["MapX"]					or 10
		LeaPlusLC["MapY"] 					= LeaPlusDB["MapY"]					or -118
		LeaPlusLC["CursorCoords"] 			= LeaPlusDB["CursorCoords"]			or "On"

		LeaPlusLC["MinimapMod"] 			= LeaPlusDB["MinimapMod"]			or "Off"
		LeaPlusLC["MergeTrackBtn"] 			= LeaPlusDB["MergeTrackBtn"]		or "Off"
		LeaPlusLC["HideMinimapZone"] 		= LeaPlusDB["HideMinimapZone"]		or "Off"
		LeaPlusLC["HideMinimapTime"] 		= LeaPlusDB["HideMinimapTime"]		or "Off"
		LeaPlusLC["MinimapMouseZoom"] 		= LeaPlusDB["MinimapMouseZoom"]		or "Off"
		LeaPlusLC["MinimapScale"] 			= LeaPlusDB["MinimapScale"]			or 1.00

		LeaPlusLC["ViewPortEnable"]			= LeaPlusDB["ViewPortEnable"]		or "Off"
		LeaPlusLC["ViewportResize"]			= LeaPlusDB["ViewportResize"]		or "Off"
		LeaPlusLC["ViewPortTop"]			= LeaPlusDB["ViewPortTop"]			or 0
		LeaPlusLC["ViewPortBottom"]			= LeaPlusDB["ViewPortBottom"]		or 0
		LeaPlusLC["ViewPortLeft"]			= LeaPlusDB["ViewPortLeft"]			or 0
		LeaPlusLC["ViewPortRight"]			= LeaPlusDB["ViewPortRight"]		or 0

		LeaPlusLC["ShowVanityButtons"]		= LeaPlusDB["ShowVanityButtons"]	or "Off"
		LeaPlusLC["ShowVanityInFrame"]		= LeaPlusDB["ShowVanityInFrame"]	or "Off"
		LeaPlusLC["DungeonFinderButtons"]	= LeaPlusDB["DungeonFinderButtons"]	or "Off"
		LeaPlusLC["ShowSpellIcons"]			= LeaPlusDB["ShowSpellIcons"]		or "Off"
		LeaPlusLC["SpellIDonTip"]			= LeaPlusDB["SpellIDonTip"]			or "On"
		LeaPlusLC["SpellOnPlayer"]			= LeaPlusDB["SpellOnPlayer"]		or "Off"
		LeaPlusLC["ShowVolume"] 			= LeaPlusDB["ShowVolume"]			or "Off"
		LeaPlusLC["ShowVolumeInFrame"] 		= LeaPlusDB["ShowVolumeInFrame"]	or "Off"
		LeaPlusLC["ShowDressTab"] 			= LeaPlusDB["ShowDressTab"]			or "Off"

		LeaPlusLC["ShowHonorStat"]			= LeaPlusDB["ShowHonorStat"]		or "Off"
		LeaPlusLC["DurabilityStatus"] 		= LeaPlusDB["DurabilityStatus"]		or "Off"
		LeaPlusLC["StaticCoords"] 			= LeaPlusDB["StaticCoords"]			or "On"
		LeaPlusLC["CoordsA"] 				= LeaPlusDB["CoordsA"]				or "CENTER"
		LeaPlusLC["CoordsR"] 				= LeaPlusDB["CoordsR"]				or "CENTER"
		LeaPlusLC["CoordsX"] 				= LeaPlusDB["CoordsX"]				or 0
		LeaPlusLC["CoordsY"] 				= LeaPlusDB["CoordsY"]				or 0
		LeaPlusLC["StaticCoordsEn"] 		= LeaPlusDB["StaticCoordsEn"]		or "Off"
		LeaPlusLC["StaticCoordsBack"] 		= LeaPlusDB["StaticCoordsBack"]		or "Off"
		LeaPlusLC["StaticThrottle"] 		= LeaPlusDB["StaticThrottle"]		or "On"
		LeaPlusLC["StaticCoordsScale"] 		= LeaPlusDB["StaticCoordsScale"]	or 2.2
		LeaPlusLC["StaticCoordsLock"] 		= LeaPlusDB["StaticCoordsLock"]		or "Off"
		LeaPlusLC["StaticCoordsMap"] 		= LeaPlusDB["StaticCoordsMap"]		or "Off"
		LeaPlusLC["StaticCoordsTop"] 		= LeaPlusDB["StaticCoordsTop"]		or "Off"

		-- Miscellaneous
		LeaPlusLC["NoDeathEffect"]			= LeaPlusDB["NoDeathEffect"]		or "Off"
		LeaPlusLC["NoSpecialEffects"]		= LeaPlusDB["NoSpecialEffects"]		or "Off"
		LeaPlusLC["NoGlowEffect"]			= LeaPlusDB["NoGlowEffect"]			or "Off"
		LeaPlusLC["ManageZoomLevel"]		= LeaPlusDB["ManageZoomLevel"]		or "Off"
		LeaPlusLC["ZoomOutLevel"]			= LeaPlusDB["ZoomOutLevel"]			or 50
		LeaPlusLC["ShowElitePlayerChain"] 	= LeaPlusDB["ShowElitePlayerChain"]	or "Off"
		LeaPlusLC["ShowRarePlayerChain"] 	= LeaPlusDB["ShowRarePlayerChain"]	or "Off"

		LeaPlusLC["AchieveControl"] 		= LeaPlusDB["AchieveControl"]		or "Off"
		LeaPlusLC["CharOnlyAchieves"] 		= LeaPlusDB["CharOnlyAchieves"]		or "On"

		-- Settings
		LeaPlusLC["ShowMinimapIcon"] 		= LeaPlusDB["ShowMinimapIcon"]		or "On"
		LeaPlusLC["MinimapIconPos"] 		= LeaPlusDB["MinimapIconPos"]		or -65
		LeaPlusLC["PlusShowTips"] 			= LeaPlusDB["PlusShowTips"]			or "On"
		LeaPlusLC["PanelTipAnchor"] 		= LeaPlusDB["PanelTipAnchor"]		or "Off"
		LeaPlusLC["PlusFaceTips"] 			= LeaPlusDB["PlusFaceTips"]			or "On"
		LeaPlusLC["ShowBackground"] 		= LeaPlusDB["ShowBackground"]		or "On"
		LeaPlusLC["ShowStartTag"] 			= LeaPlusDB["ShowStartTag"]			or "On"
		LeaPlusLC["OpenPlusAtHome"]			= LeaPlusDB["OpenPlusAtHome"]		or "Off"
		LeaPlusLC["LeaStartPage"] 			= LeaPlusDB["LeaStartPage"]			or "0"

		LeaPlusLC["PlusPanelAlphaCheck"] 	= LeaPlusDB["PlusPanelAlphaCheck"]	or "Off"
		LeaPlusLC["LeaPlusAlphaValue"] 		= LeaPlusDB["LeaPlusAlphaValue"]	or "1.0"
		LeaPlusLC["PlusPanelScaleCheck"] 	= LeaPlusDB["PlusPanelScaleCheck"]	or "Off"
		LeaPlusLC["LeaPlusScaleValue"] 		= LeaPlusDB["LeaPlusScaleValue"]	or "1.0"

		-- Ensure dropdowns are within valid ranges to prevent corruption
		if tonumber(LeaPlusLC["TipMouseAnchor"]) == nil or LeaPlusLC["TipMouseAnchor"] < 1 or LeaPlusLC["TipMouseAnchor"] > 9 then LeaPlusLC["TipMouseAnchor"] = 1 end

		-- Save all settings now
		LeaPlusLC:Save();

	end

-- 	Save locals to globals
	function LeaPlusLC:Save()

		-- Automation
		LeaPlusDB["AcceptPartyFriends"]		= LeaPlusLC["AcceptPartyFriends"]
		LeaPlusDB["AcceptPartyGuild"]		= LeaPlusLC["AcceptPartyGuild"]
		LeaPlusDB["AutoConfirmRole"]		= LeaPlusLC["AutoConfirmRole"]
		LeaPlusDB["InviteFromWhisper"]		= LeaPlusLC["InviteFromWhisper"]

		LeaPlusDB["AutoReleaseInBG"] 		= LeaPlusLC["AutoReleaseInBG"]
		LeaPlusDB["AutoAcceptRes"] 			= LeaPlusLC["AutoAcceptRes"]
		LeaPlusDB["NoAutoResInCombat"]		= LeaPlusLC["NoAutoResInCombat"]

		LeaPlusDB["NoDuelRequests"] 		= LeaPlusLC["NoDuelRequests"]
		LeaPlusDB["NoPartyInvites"]			= LeaPlusLC["NoPartyInvites"]

		LeaPlusDB["ManageTradeGuild"] 		= LeaPlusLC["ManageTradeGuild"]
		LeaPlusDB["NoTradeRequests"]		= LeaPlusLC["NoTradeRequests"]
		LeaPlusDB["NoGuildInvites"]			= LeaPlusLC["NoGuildInvites"]

		-- Interaction
		LeaPlusDB["ShowQuestLevels"]		= LeaPlusLC["ShowQuestLevels"]
		LeaPlusDB["AutoAcceptQuests"] 		= LeaPlusLC["AutoAcceptQuests"]
		LeaPlusDB["AcceptOnlyDailys"] 		= LeaPlusLC["AcceptOnlyDailys"]
		LeaPlusDB["AutoTurnInQuests"] 		= LeaPlusLC["AutoTurnInQuests"]
		LeaPlusDB["TurnInOnlyDailys"] 		= LeaPlusLC["TurnInOnlyDailys"]

		LeaPlusDB["QuestFontChange"] 		= LeaPlusLC["QuestFontChange"]
		LeaPlusDB["LeaPlusQuestFontSize"]	= LeaPlusLC["LeaPlusQuestFontSize"]

		LeaPlusDB["AutoSellJunk"] 			= LeaPlusLC["AutoSellJunk"]
		LeaPlusDB["AutoRepairOwnFunds"] 	= LeaPlusLC["AutoRepairOwnFunds"]
		LeaPlusDB["AutoRepairGuildFunds"] 	= LeaPlusLC["AutoRepairGuildFunds"]
		LeaPlusDB["NoBagAutomation"] 		= LeaPlusLC["NoBagAutomation"]
		LeaPlusDB["AhExtras"]				= LeaPlusLC["AhExtras"]
		LeaPlusDB["AhBuyoutOnly"]			= LeaPlusLC["AhBuyoutOnly"]
		LeaPlusDB["AhGoldOnly"]				= LeaPlusLC["AhGoldOnly"]

		LeaPlusDB["NoRaidRestrictions"]		= LeaPlusLC["NoRaidRestrictions"]
		LeaPlusDB["NoConfirmLoot"] 			= LeaPlusLC["NoConfirmLoot"]
		LeaPlusDB["NoConfirmBoP"] 			= LeaPlusLC["NoConfirmBoP"]
		LeaPlusDB["BoPShowWarning"] 		= LeaPlusLC["BoPShowWarning"]
		LeaPlusDB["NoLootWonAlert"] 		= LeaPlusLC["NoLootWonAlert"]
		LeaPlusDB["RoleSave"] 				= LeaPlusLC["RoleSave"]

		-- Chat
		LeaPlusDB["UseEasyChatResizing"]	= LeaPlusLC["UseEasyChatResizing"]
		LeaPlusDB["NoCombatLogTab"]			= LeaPlusLC["NoCombatLogTab"]
		LeaPlusDB["NoChatButtons"]			= LeaPlusLC["NoChatButtons"]
		LeaPlusDB["MoveChatEditBoxToTop"]	= LeaPlusLC["MoveChatEditBoxToTop"]

		LeaPlusDB["Manageclasscolors"]		= LeaPlusLC["Manageclasscolors"]
		LeaPlusDB["ColorLocalChannels"]		= LeaPlusLC["ColorLocalChannels"]
		LeaPlusDB["ColorGlobalChannels"]	= LeaPlusLC["ColorGlobalChannels"]

		LeaPlusDB["NoStickyChat"] 			= LeaPlusLC["NoStickyChat"]
		LeaPlusDB["UseArrowKeysInChat"]		= LeaPlusLC["UseArrowKeysInChat"]
		LeaPlusDB["NoChatFade"]				= LeaPlusLC["NoChatFade"]
		LeaPlusDB["MaxChatHstory"]			= LeaPlusLC["MaxChatHstory"]

		-- Text
		LeaPlusDB["HideZoneText"] 			= LeaPlusLC["HideZoneText"]
		LeaPlusDB["HideSubzoneText"] 		= LeaPlusLC["HideSubzoneText"]

		LeaPlusDB["HideErrorFrameText"]		= LeaPlusLC["HideErrorFrameText"]
		LeaPlusDB["ShowQuestUpdates"]		= LeaPlusLC["ShowQuestUpdates"]

		LeaPlusDB["NoSpecSpam"] 			= LeaPlusLC["NoSpecSpam"]
		LeaPlusDB["NoNPCSpam"] 				= LeaPlusLC["NoNPCSpam"]
		LeaPlusDB["NoNPCSpamRest"] 			= LeaPlusLC["NoNPCSpamRest"]
		LeaPlusDB["NoInterruptSpam"]		= LeaPlusLC["NoInterruptSpam"]

		LeaPlusDB["MailFontChange"] 		= LeaPlusLC["MailFontChange"]
		LeaPlusDB["LeaPlusMailFontSize"] 	= LeaPlusLC["LeaPlusMailFontSize"]

		-- Tooltip
		LeaPlusDB["TipModEnable"]			= LeaPlusLC["TipModEnable"]
		LeaPlusDB["TipPosAnchor"]			= LeaPlusLC["TipPosAnchor"]
		LeaPlusDB["TipPosRelative"]			= LeaPlusLC["TipPosRelative"]
		LeaPlusDB["TipPosXOffset"]			= LeaPlusLC["TipPosXOffset"]
		LeaPlusDB["TipPosYOffset"]			= LeaPlusLC["TipPosYOffset"]

		LeaPlusDB["TipShowTitle"]			= LeaPlusLC["TipShowTitle"]
		LeaPlusDB["TipShowRealm"]			= LeaPlusLC["TipShowRealm"]
		LeaPlusDB["TipShowRace"]			= LeaPlusLC["TipShowRace"]
		LeaPlusDB["TipShowClass"]			= LeaPlusLC["TipShowClass"]
		LeaPlusDB["TipShowRank"]			= LeaPlusLC["TipShowRank"]
		LeaPlusDB["TipShowMobType"]			= LeaPlusLC["TipShowMobType"]
		LeaPlusDB["TipShowTarget"]			= LeaPlusLC["TipShowTarget"]

		LeaPlusDB["TipBackSimple"]			= LeaPlusLC["TipBackSimple"]
		LeaPlusDB["TipBackFriend"]			= LeaPlusLC["TipBackFriend"]
		LeaPlusDB["TipBackHostile"]			= LeaPlusLC["TipBackHostile"]

		LeaPlusDB["TipAnchorToMouse"]		= LeaPlusLC["TipAnchorToMouse"]
		LeaPlusDB["TipMouseOffsetX"]		= LeaPlusLC["TipMouseOffsetX"]
		LeaPlusDB["TipMouseOffsetY"]		= LeaPlusLC["TipMouseOffsetY"]
		LeaPlusDB["TipMouseAnchor"]			= LeaPlusLC["TipMouseAnchor"]
		LeaPlusDB["TipAlpha"]				= LeaPlusLC["TipAlpha"]
		LeaPlusDB["TipHideCombat"]			= LeaPlusLC["TipHideCombat"]

		LeaPlusDB["TipScaleCheck"] 			= LeaPlusLC["TipScaleCheck"]
		LeaPlusDB["LeaPlusTipSize"]			= LeaPlusLC["LeaPlusTipSize"]

		-- Frames
		LeaPlusDB["FrmEnabled"]				= LeaPlusLC["FrmEnabled"]

		LeaPlusDB["NoGryphons"]				= LeaPlusLC["NoGryphons"]
		LeaPlusDB["NoClassBar"]				= LeaPlusLC["NoClassBar"]
		LeaPlusDB["NoCharControls"]			= LeaPlusLC["NoCharControls"]

		-- Interface
		LeaPlusDB["ShowMapMod"] 			= LeaPlusLC["ShowMapMod"]
		LeaPlusDB["MapRevealBox"] 			= LeaPlusLC["MapRevealBox"]
		LeaPlusDB["MapQuestBox"] 			= LeaPlusLC["MapQuestBox"]
		LeaPlusDB["LeaPlusMapScale"] 		= LeaPlusLC["LeaPlusMapScale"]
		LeaPlusDB["LeaPlusMapOpacity"] 		= LeaPlusLC["LeaPlusMapOpacity"]
		LeaPlusDB["MapLock"] 				= LeaPlusLC["MapLock"]
		LeaPlusDB["MapQuestLeft"] 			= LeaPlusLC["MapQuestLeft"]
		LeaPlusDB["MapA"] 					= LeaPlusLC["MapA"]
		LeaPlusDB["MapX"] 					= LeaPlusLC["MapX"]
		LeaPlusDB["MapY"] 					= LeaPlusLC["MapY"]
		LeaPlusDB["CursorCoords"] 			= LeaPlusLC["CursorCoords"]

		LeaPlusDB["MinimapMod"]				= LeaPlusLC["MinimapMod"]
		LeaPlusDB["MergeTrackBtn"]			= LeaPlusLC["MergeTrackBtn"]
		LeaPlusDB["HideMinimapZone"]		= LeaPlusLC["HideMinimapZone"]
		LeaPlusDB["HideMinimapTime"]		= LeaPlusLC["HideMinimapTime"]
		LeaPlusDB["MinimapMouseZoom"]		= LeaPlusLC["MinimapMouseZoom"]
		LeaPlusDB["MinimapScale"]			= LeaPlusLC["MinimapScale"]

		LeaPlusDB["ViewPortEnable"]			= LeaPlusLC["ViewPortEnable"]
		LeaPlusDB["ViewportResize"]			= LeaPlusLC["ViewportResize"]
		LeaPlusDB["ViewPortTop"]			= LeaPlusLC["ViewPortTop"]
		LeaPlusDB["ViewPortBottom"]			= LeaPlusLC["ViewPortBottom"]
		LeaPlusDB["ViewPortLeft"]			= LeaPlusLC["ViewPortLeft"]
		LeaPlusDB["ViewPortRight"]			= LeaPlusLC["ViewPortRight"]

		LeaPlusDB["ShowVanityButtons"]		= LeaPlusLC["ShowVanityButtons"]
		LeaPlusDB["ShowVanityInFrame"]		= LeaPlusLC["ShowVanityInFrame"]
		LeaPlusDB["DungeonFinderButtons"]	= LeaPlusLC["DungeonFinderButtons"]
		LeaPlusDB["ShowSpellIcons"]			= LeaPlusLC["ShowSpellIcons"]
		LeaPlusDB["SpellIDonTip"]			= LeaPlusLC["SpellIDonTip"]
		LeaPlusDB["SpellOnPlayer"]			= LeaPlusLC["SpellOnPlayer"]
		LeaPlusDB["ShowVolume"] 			= LeaPlusLC["ShowVolume"]
		LeaPlusDB["ShowVolumeInFrame"] 		= LeaPlusLC["ShowVolumeInFrame"]
		LeaPlusDB["ShowDressTab"] 			= LeaPlusLC["ShowDressTab"]

		LeaPlusDB["ShowHonorStat"]			= LeaPlusLC["ShowHonorStat"]
		LeaPlusDB["DurabilityStatus"]		= LeaPlusLC["DurabilityStatus"]
		LeaPlusDB["StaticCoords"] 			= LeaPlusLC["StaticCoords"]
		LeaPlusDB["CoordsA"] 				= LeaPlusLC["CoordsA"]
		LeaPlusDB["CoordsR"] 				= LeaPlusLC["CoordsR"]
		LeaPlusDB["CoordsX"] 				= LeaPlusLC["CoordsX"]
		LeaPlusDB["CoordsY"] 				= LeaPlusLC["CoordsY"]
		LeaPlusDB["StaticCoordsEn"] 		= LeaPlusLC["StaticCoordsEn"]
		LeaPlusDB["StaticCoordsBack"] 		= LeaPlusLC["StaticCoordsBack"]
		LeaPlusDB["StaticThrottle"] 		= LeaPlusLC["StaticThrottle"]
		LeaPlusDB["StaticCoordsScale"] 		= LeaPlusLC["StaticCoordsScale"]
		LeaPlusDB["StaticCoordsLock"] 		= LeaPlusLC["StaticCoordsLock"]
		LeaPlusDB["StaticCoordsMap"] 		= LeaPlusLC["StaticCoordsMap"]
		LeaPlusDB["StaticCoordsTop"] 		= LeaPlusLC["StaticCoordsTop"]

		-- Miscellaneous
		LeaPlusDB["NoDeathEffect"] 			= LeaPlusLC["NoDeathEffect"]
		LeaPlusDB["NoSpecialEffects"] 		= LeaPlusLC["NoSpecialEffects"]
		LeaPlusDB["NoGlowEffect"] 			= LeaPlusLC["NoGlowEffect"]
		LeaPlusDB["ManageZoomLevel"]		= LeaPlusLC["ManageZoomLevel"]
		LeaPlusDB["ZoomOutLevel"]			= LeaPlusLC["ZoomOutLevel"]
		LeaPlusDB["ShowElitePlayerChain"]	= LeaPlusLC["ShowElitePlayerChain"]
		LeaPlusDB["ShowRarePlayerChain"]	= LeaPlusLC["ShowRarePlayerChain"]

		LeaPlusDB["AchieveControl"]			= LeaPlusLC["AchieveControl"]
		LeaPlusDB["CharOnlyAchieves"]		= LeaPlusLC["CharOnlyAchieves"]

		-- Settings
		LeaPlusDB["ShowMinimapIcon"] 		= LeaPlusLC["ShowMinimapIcon"]
		LeaPlusDB["MinimapIconPos"] 		= LeaPlusLC["MinimapIconPos"]
		LeaPlusDB["PlusShowTips"] 			= LeaPlusLC["PlusShowTips"]
		LeaPlusDB["PanelTipAnchor"] 		= LeaPlusLC["PanelTipAnchor"]
		LeaPlusDB["PlusFaceTips"] 			= LeaPlusLC["PlusFaceTips"]
		LeaPlusDB["ShowBackground"]			= LeaPlusLC["ShowBackground"]
		LeaPlusDB["ShowStartTag"]			= LeaPlusLC["ShowStartTag"]
		LeaPlusDB["OpenPlusAtHome"]			= LeaPlusLC["OpenPlusAtHome"]
		LeaPlusDB["LeaStartPage"]			= LeaPlusLC["LeaStartPage"]

		LeaPlusDB["PlusPanelAlphaCheck"] 	= LeaPlusLC["PlusPanelAlphaCheck"]
		LeaPlusDB["LeaPlusAlphaValue"] 		= LeaPlusLC["LeaPlusAlphaValue"]

		LeaPlusDB["PlusPanelScaleCheck"] 	= LeaPlusLC["PlusPanelScaleCheck"]
		LeaPlusDB["LeaPlusScaleValue"] 		= LeaPlusLC["LeaPlusScaleValue"]

	end

----------------------------------------------------------------------
--	L20: Live
----------------------------------------------------------------------

--	The Live bit
	function LeaPlusLC:Live()

		-- Player chains
		if LeaPlusDB["ShowElitePlayerChain"] == "On" then -- Checks global
			if LeaPlusLC["ShowRarePlayerChain"] == "On" then
				PlayerFrameTexture:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Rare.blp");
			else
				PlayerFrameTexture:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Elite.blp");
			end
		end

		-- Block interrupt messages
		if LeaPlusLC["NoInterruptSpam"] == "On" then
			ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_AddMessageEventFilter("CHAT_MSG_YELL", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY_LEADER", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_AddMessageEventFilter("CHAT_MSG_RAID", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_AddMessageEventFilter("CHAT_MSG_RAID_LEADER", LeaPlusLC.LeaPlusInterruptFilter)
		else
			ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SAY", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_RemoveMessageEventFilter("CHAT_MSG_YELL", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_RemoveMessageEventFilter("CHAT_MSG_PARTY", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_RemoveMessageEventFilter("CHAT_MSG_PARTY_LEADER", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_RemoveMessageEventFilter("CHAT_MSG_RAID", LeaPlusLC.LeaPlusInterruptFilter)
			ChatFrame_RemoveMessageEventFilter("CHAT_MSG_RAID_LEADER", LeaPlusLC.LeaPlusInterruptFilter)
		end

		-- Block NPC spam
		if LeaPlusLC["NoNPCSpam"] == "On" then
			-- Add the filter
			ChatFrame_AddMessageEventFilter("CHAT_MSG_MONSTER_SAY", LeaPlusLC.BlockNPCSpam)
			ChatFrame_AddMessageEventFilter("CHAT_MSG_MONSTER_YELL", LeaPlusLC.BlockNPCSpam)
		else
			-- Remove the filter
			ChatFrame_RemoveMessageEventFilter("CHAT_MSG_MONSTER_SAY", LeaPlusLC.BlockNPCSpam)
			ChatFrame_RemoveMessageEventFilter("CHAT_MSG_MONSTER_YELL", LeaPlusLC.BlockNPCSpam)
		end

		-- Automatically accept Dungeon Finder role confirmations
		if LeaPlusLC["AutoConfirmRole"] == "On" then
			LFDRoleCheckPopupAcceptButton:SetScript("OnShow", function()
				local leader = ""
				for i=1, GetNumSubgroupMembers() do 
					if (UnitIsGroupLeader("party"..i)) then 
						leader = UnitName("party"..i);
						break; 
					end
				end
				if (LeaPlusLC:FriendCheck(leader)) or (LeaPlusLC:RealIDCheck(leader)) or (LeaPlusLC:GuildCheck(leader)) then
					LFDRoleCheckPopupAcceptButton:Click();
				end
			end)
		else
			LFDRoleCheckPopupAcceptButton:SetScript("OnShow", nil)
		end

		-- Class colors in all channels
		if LeaPlusLC["Manageclasscolors"] == "On" then
			for i=1, 18 do
				if _G["ChatConfigChatSettingsLeftCheckBox" .. i .. "Check"] then
					if LeaPlusLC["ColorLocalChannels"] == "On" then
						ToggleChatColorNamesByClassGroup(true, _G["ChatConfigChatSettingsLeftCheckBox" .. i .. "Check"]:GetParent().type);
					else
						ToggleChatColorNamesByClassGroup(false, _G["ChatConfigChatSettingsLeftCheckBox" .. i .. "Check"]:GetParent().type);
					end
				end
			end
			for i=1, 50 do
				if LeaPlusLC["ColorGlobalChannels"] == "On" then
					ToggleChatColorNamesByClassGroup(true, "CHANNEL"..i)
				else
					ToggleChatColorNamesByClassGroup(false, "CHANNEL"..i)
				end
			end
		end

		-- Show Leatrix Plus background image
		if LeaPlusLC["ShowBackground"] == "On" then
			LeaPlusLC["MainTexture"]:SetTexture("Interface\\DressUpFrame\\DressUpBackground-NightElf1");
		else
			LeaPlusLC["MainTexture"]:SetTexture("");
		end

		-- Invite from whispers
		if LeaPlusLC["InviteFromWhisper"] == "On" then
			LpEvt:RegisterEvent("CHAT_MSG_WHISPER");
			LpEvt:RegisterEvent("CHAT_MSG_BN_WHISPER");
		else
			LpEvt:UnregisterEvent("CHAT_MSG_WHISPER");
			LpEvt:UnregisterEvent("CHAT_MSG_BN_WHISPER");
		end

		-- Disable full-screen glow
		if LeaPlusLC["NoGlowEffect"] == "On" then
			SetCVar("ffxGlow", "0")
		else
			SetCVar("ffxGlow", "1")
		end

		-- Disable death effect
		if LeaPlusLC["NoDeathEffect"] == "On" then
			SetCVar("ffxDeath", "0")
		else
			SetCVar("ffxDeath", "1")
		end

		-- Disable special effects
		if LeaPlusLC["NoSpecialEffects"] == "On" then
			SetCVar("ffxSpecial", "0")
			SetCVar("ffxNetherWorld", "0")
		else
			SetCVar("ffxSpecial", "1")
			SetCVar("ffxNetherWorld", "1")
		end

		-- Block duels
		if LeaPlusLC["NoDuelRequests"] == "On" then
			LpEvt:RegisterEvent("DUEL_REQUESTED");
		else
			LpEvt:UnregisterEvent("DUEL_REQUESTED");
		end

		-- Block party invites
		if LeaPlusLC["NoPartyInvites"] == "On" or LeaPlusLC["AcceptPartyFriends"] == "On" or LeaPlusLC["AcceptPartyGuild"] == "On" then
			LpEvt:RegisterEvent("PARTY_INVITE_REQUEST");
		else
			LpEvt:UnregisterEvent("PARTY_INVITE_REQUEST");
		end

		-- Battleground release
		if LeaPlusLC["AutoReleaseInBG"] == "On" then
			LpEvt:RegisterEvent("PLAYER_DEAD");
		else
			LpEvt:UnregisterEvent("PLAYER_DEAD");
		end

		-- Automatic resurrection
		if LeaPlusLC["AutoAcceptRes"] == "On" then
			LpEvt:RegisterEvent("RESURRECT_REQUEST");
		else
			LpEvt:UnregisterEvent("RESURRECT_REQUEST");
		end

		-- Get quests automatically
		if LeaPlusLC["AutoAcceptQuests"] == "On" or (LeaPlusLC["AutoAcceptQuests"] == "On" and LeaPlusLC["AcceptOnlyDailys"] == "On") then
			LpEvt:RegisterEvent("QUEST_DETAIL");
			LpEvt:RegisterEvent("QUEST_ACCEPT_CONFIRM")
		else
			LpEvt:UnregisterEvent("QUEST_DETAIL");
			LpEvt:UnregisterEvent("QUEST_ACCEPT_CONFIRM")
		end

		-- Turn-in quests automatically
		if LeaPlusLC["AutoTurnInQuests"] == "On" then
			LpEvt:RegisterEvent("QUEST_PROGRESS")
			LpEvt:RegisterEvent("QUEST_COMPLETE")
		else
			LpEvt:UnregisterEvent("QUEST_PROGRESS")
			LpEvt:UnregisterEvent("QUEST_COMPLETE")
		end

		-- Sell junk automatically and repair automatically
		if LeaPlusLC["AutoSellJunk"] == "On" or LeaPlusLC["AutoRepairOwnFunds"] == "On" then
			LpEvt:RegisterEvent("MERCHANT_SHOW");
		else
			LpEvt:UnregisterEvent("MERCHANT_SHOW");
		end

		-- Don't confirm loot rolls
		if LeaPlusLC["NoConfirmLoot"] == "On" then
			LpEvt:RegisterEvent("CONFIRM_LOOT_ROLL");
			LpEvt:RegisterEvent("CONFIRM_DISENCHANT_ROLL");
		else
			LpEvt:UnregisterEvent("CONFIRM_LOOT_ROLL");
			LpEvt:UnregisterEvent("CONFIRM_DISENCHANT_ROLL");
		end

	end

----------------------------------------------------------------------
--	L21: Isolated Environment
----------------------------------------------------------------------

	function LeaPlusLC:Isolated()

		-- Disable taint log (due to problems with the taint log, not Leatrix Plus)
		SetCVar("taintLog", "0");

		-- Create secure button to enable a macro to be used to stop targeting a spell
		local LeaPlusClearSpell = CreateFrame("Button", "LeaPlusClearSpell", UIParent, "SecureActionButtonTemplate")
		LeaPlusClearSpell:SetAttribute("type", "stop")

		----------------------------------------------------------------------
		-- Show spell icons
		----------------------------------------------------------------------

		-- Show spell icons
		if LeaPlusLC["ShowSpellIcons"] == "On" then

			-- Disable buffs on top of target frame (otherwise they would conflict)
			TargetFrame_UpdateBuffsOnTop = function() TARGET_FRAME_BUFFS_ON_TOP = false; end

			-- Create local tables to store spell icons and editboxes
			local icon = {}; -- Used to store spell icon frames
			local SpellEB = {}; -- Used to store editbox values
			local iCount = 5; -- Number of spell icons (hope Apple don't sue over the variable name)

			-- Create spell icon frames
			for i = 1, iCount do

				-- Create spell icon frame
				icon[i] = CreateFrame("Frame", nil, UIParent)
				icon[i]:SetFrameStrata("BACKGROUND")
				icon[i]:SetWidth(20)
				icon[i]:SetHeight(20)

				-- Create cooldown icon
				icon[i].c = CreateFrame("Cooldown", nil, icon[i], "CooldownFrameTemplate")
				icon[i].c:SetAllPoints();
				icon[i].c:SetReverse(true)

				-- Create texture (will be overwritten with spell texture later)
				icon[i].t = icon[i]:CreateTexture(nil,"BACKGROUND")
				icon[i].t:SetAllPoints()

			end

			-- Change spell icon scale when player frame scale changes
			PlayerFrame:HookScript("OnSizeChanged", function(self, name, value)
				if LeaPlusLC["SpellOnPlayer"] == "On" then
					for i = 1, iCount do
						icon[i]:SetScale(PlayerFrame:GetScale());
					end
				end
			end)

			-- Change spell icon scale when target frame scale changes
			TargetFrame:HookScript("OnSizeChanged", function(self, name, value)
				if LeaPlusLC["SpellOnPlayer"] == "Off" then
					for i = 1, iCount do
						icon[i]:SetScale(TargetFrame:GetScale());
					end
				end
			end)

			-- Function to set spell cooldowns to the icons
			local function ShowIcon(i, id, owner)

				local void

				-- Get spell information
				local spell, void, path = GetSpellInfo(id)

				if spell and path then

					-- Set icon texture to the spell texture
					icon[i].t:SetTexture(path)

					-- Handle events
					icon[i]:RegisterUnitEvent("UNIT_AURA", owner)
					icon[i]:RegisterUnitEvent("UNIT_PET", "player")
					icon[i]:SetScript("OnEvent", function(self, event, arg1)

						-- If pet was dismissed (or otherwise disappears such as when flying), hide pet spell icons
						if event == "UNIT_PET" then
							if not UnitExists("pet") then
								if LeaPlusDC["Spell"..i.."Pet"] then
									icon[i]:Hide();
								end
							end

						-- Ensure spell belongs to the owner we're watching (player or pet)
						elseif arg1 == owner then

							-- Hide the icon frame (required for icons to disappear after the duration)
							icon[i]:Hide()

							-- If buff matches spell we want, start the cooldown
							local buff, void, void, stack, void, length, expire = UnitBuff(owner, spell)
							if buff then
								local stackval = tonumber(SpellEB[i.."Stack"]:GetText())
								if (stackval and stack >= stackval) or (not stackval) then
									icon[i]:Show();
									local start = expire - length
									CooldownFrame_SetTimer(icon[i].c, start, length, 1)
								end
							end

						end
					end)

				else
					-- Spell does not exist so no point in watching it
					icon[i]:UnregisterEvent("UNIT_AURA")
					icon[i]:SetScript("OnEvent", nil);
					icon[i]:Hide();
				end

			end

			-- Create side panel
			local SpellPanel = LeaPlusLC:CreateSidePanel("Spell Icons", 164, 350)

			-- Function to refresh the tooltip with the spell name
			local function RefSpellTip(self,elapsed)
				local spellinfo, void, icon = GetSpellInfo(self:GetText());
				if spellinfo and icon then
					GameTooltip:SetOwner(self, "ANCHOR_LEFT", -10, -26)
					GameTooltip:SetText("|T" .. icon .. ":0|t " .. spellinfo, nil, nil, nil, nil, true)
				else
					GameTooltip:Hide();
				end
			end

			-- Function to create spell ID editboxes and pet checkboxes
			local function MakeSpellEB(num, x, y, tab, shifttab)

				-- Create editbox for spell ID
				SpellEB[num] = LeaPlusLC:CreateEditBox("SpellEB" .. num, SpellPanel, 70, 6, "TOPLEFT", x, y-20, "SpellEB" .. num .. "Stack", "SpellEB" .. shifttab .. "Stack");
				SpellEB[num]:SetNumeric(true);
				SpellEB[num]:SetBackdropColor(0.3, 0.3, 0, 1.0)

				-- Add border and backdrop to spell ID editbox
				SpellEB[num].f = CreateFrame("FRAME", nil, SpellEB[num]);
				SpellEB[num].f:SetBackdrop(GameTooltip:GetBackdrop())
				SpellEB[num].f:SetPoint("LEFT", -6, 0);
				SpellEB[num].f:SetWidth(SpellEB[num]:GetWidth()+6);
				SpellEB[num].f:SetHeight(SpellEB[num]:GetHeight())
				SpellEB[num].f:SetBackdropColor(1.0, 1.0, 1.0, 0.3)

				-- Refresh tooltip when mouse is hovering over the editbox
				SpellEB[num]:SetScript("OnEnter", function()
					SpellEB[num]:SetScript("OnUpdate", RefSpellTip)

				end)
				SpellEB[num]:SetScript("OnLeave", function()
					SpellEB[num]:SetScript("OnUpdate", nil)
					GameTooltip:Hide();
				end)

				-- Create editbox for stack size
				SpellEB[num.."Stack"] = LeaPlusLC:CreateEditBox("SpellEB" .. num .. "Stack", SpellPanel, 30, 2, "TOPLEFT", x+80, y-20, "SpellEB" .. tab, "SpellEB" .. num);
				SpellEB[num.."Stack"]:SetNumeric(true);
				SpellEB[num.."Stack"]:SetBackdropColor(0.3, 0.3, 0, 1.0)

				-- Add border and backdrop to stack size editbox
				SpellEB[num.."Stack"].f = CreateFrame("FRAME", nil, SpellEB[num.."Stack"]);
				SpellEB[num.."Stack"].f:SetBackdrop(GameTooltip:GetBackdrop())
				SpellEB[num.."Stack"].f:SetPoint("LEFT", -6, 0);
				SpellEB[num.."Stack"].f:SetWidth(SpellEB[num.."Stack"]:GetWidth()+6);
				SpellEB[num.."Stack"].f:SetHeight(SpellEB[num.."Stack"]:GetHeight())
				SpellEB[num.."Stack"].f:SetBackdropColor(1.0, 1.0, 1.0, 0.3)

				-- Create checkbox for pet spell
				LeaPlusLC:MakeCB(SpellPanel, "Spell" .. num .."Pet", "", 130, y-20, "")
				LeaPlusCB["Spell" .. num .."Pet"]:SetHitRectInsets(0, 0, 0, 0);

			end

			-- Add titles
			LeaPlusLC:MakeTx(SpellPanel, "Spell ID", 10, -60)
			LeaPlusLC:MakeTx(SpellPanel, "Stack", 84, -60)
			LeaPlusLC:MakeTx(SpellPanel, "Pet", 130, -60)

			-- Add editboxes and checkboxes
			MakeSpellEB(1, 10, -60, "2", "5")
			MakeSpellEB(2, 10, -90, "3", "1")
			MakeSpellEB(3, 10, -120, "4", "2")
			MakeSpellEB(4, 10, -150, "5", "3")
			MakeSpellEB(5, 10, -180, "1", "4")

			-- Add checkbox option to toggle spell ID in tooltips
			LeaPlusLC:MakeTx(SpellPanel, "Options", 10, -240)
			LeaPlusLC:MakeCB(SpellPanel, "SpellIDonTip", "Show Spell ID in tips", 10, -260, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["SpellIDonTip"], "If checked, spell IDs will be shown in the tooltips for beneficial spell icons situated in either the buff frame or under the target frame.");

			LeaPlusLC:MakeCB(SpellPanel, "SpellOnPlayer", "Anchor to player", 10, -280, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["SpellOnPlayer"], "If checked, spell icons will be shown above the player frame instead of the target frame.\n\nIf unchecked, spell icons will be shown above the target frame.");

			-- Function to save the panel control settings and refresh the spell icons
			local function SaveClassControls()
				for i = 1, iCount do
					-- Show icons above target or player frame
					icon[i]:ClearAllPoints()
					if LeaPlusLC["SpellOnPlayer"] == "On" then
						icon[i]:SetPoint("TOPLEFT", PlayerFrame, "TOPLEFT", 116 + (22 * (i - 1)), 5)
						icon[i]:SetScale(PlayerFrame:GetScale());
					else
						icon[i]:SetPoint("TOPLEFT", TargetFrame, "TOPLEFT", 6 + (22 * (i - 1)), 5)
						icon[i]:SetScale(TargetFrame:GetScale());
					end
					-- Save control states to globals
					LeaPlusDC["SpellEB"..i] = SpellEB[i]:GetText();
					LeaPlusDC["SpellEB"..i.."Stack"] = SpellEB[i.."Stack"]:GetText();
					LeaPlusDC["Spell"..i.."Pet"] = LeaPlusCB["Spell" .. i .."Pet"]:GetChecked();
					-- Set spell icons
					if LeaPlusCB["Spell" .. i .."Pet"]:GetChecked() == 1 then
						ShowIcon(i, SpellEB[i]:GetText(), "pet");
					else
						ShowIcon(i, SpellEB[i]:GetText(), "player");
					end

					-- Show or hide spell icons depending on current buffs
					local newowner
					local newspell = GetSpellInfo(SpellEB[i]:GetText())
					if newspell then
						if LeaPlusDC["Spell"..i.."Pet"] then 
							newowner = "pet" 
						else
							newowner = "player"
						end
						-- Hide spell icon
						icon[i]:Hide()
						-- If buff matches spell we want, show spell icon
						local buff, void, void, stack, void, length, expire = UnitBuff(newowner, newspell)
						if buff then
							local stackval = tonumber(SpellEB[i.."Stack"]:GetText())
							if (stackval and stack >= stackval) or (not stackval) then
								icon[i]:Show()
								-- Set the icon cooldown to the buff cooldown
								CooldownFrame_SetTimer(icon[i].c, expire - length, length, 1)
							end
						end
					end
				end

			end

			-- Update spell icons when checkboxes are clicked
			LeaPlusCB["SpellOnPlayer"]:HookScript("OnClick", SaveClassControls)

			-- Create save button (I don't know why these buttons are called save, they never save anything!)
			LeaPlusLC:CreateButton("SaveClassBtn", SpellPanel, "Save", "BOTTOMLEFT", 10, 10, 70, 25, "")
			LeaPlusCB["SaveClassBtn"]:SetScript("OnClick", function()
				SpellPanel:Hide(); LeaPlusLC["PageF"]:Show(); LeaPlusLC["Page6"]:Show();
				return
			end)

			-- Create reset button
			LeaPlusLC:CreateButton("ResetClassBtn", SpellPanel, "Reset", "BOTTOMLEFT", 80, 10, 70, 25, "")
			LeaPlusCB["ResetClassBtn"]:SetScript("OnClick", function()
				for i = 1, iCount do
					-- Reset the panel controls
					SpellEB[i]:SetText("");
					SpellEB[i.."Stack"]:SetText("");
					LeaPlusDC["Spell" .. i .. "Pet"] = 0;
					LeaPlusLC["SpellIDonTip"] = "On";
					LeaPlusLC["SpellOnPlayer"] = "Off";
					-- Hide spell icons and clear scripts
					icon[i]:Hide();
					icon[i]:UnregisterEvent("UNIT_AURA")
					icon[i]:SetScript("OnEvent", nil);
				end
				SpellPanel:Hide(); SpellPanel:Show();
			end)

			-- Save editboxes when changed
			for i = 1, iCount do
				-- Set initial checkbox states
				LeaPlusCB["Spell" .. i .."Pet"]:SetChecked(LeaPlusDC["Spell"..i.."Pet"])
				-- Set checkbox states when shown
				LeaPlusCB["Spell" .. i .."Pet"]:SetScript("OnShow", function()
					LeaPlusCB["Spell" .. i .."Pet"]:SetChecked(LeaPlusDC["Spell"..i.."Pet"])
				end)
				-- Set states when changed
				SpellEB[i]:SetScript("OnTextChanged", SaveClassControls)
				SpellEB[i.."Stack"]:SetScript("OnTextChanged", SaveClassControls)
				LeaPlusCB["Spell" .. i .."Pet"]:SetScript("OnClick", SaveClassControls);
			end

			-- Show spell icons on startup
			SaveClassControls();

			-- Show panel when options panel button is clicked
			local function ShowSpellPanel()
				if IsShiftKeyDown() and IsControlKeyDown() then

					-- Top secret profile (ssh!)
					if LeaPlusLC["PlayerClass"] == "HUNTER" then
						SpellEB[1]:SetText("136"); 		SpellEB["1Stack"]:SetText(""); 	LeaPlusDC["Spell1Pet"] = 1; -- Mend Pet
						SpellEB[2]:SetText("82692"); 	SpellEB["2Stack"]:SetText(""); 	LeaPlusDC["Spell2Pet"] = 0; -- Focus Fire
						SpellEB[3]:SetText(""); 		SpellEB["3Stack"]:SetText(""); 	LeaPlusDC["Spell3Pet"] = 0;
						SpellEB[4]:SetText(""); 		SpellEB["4Stack"]:SetText(""); 	LeaPlusDC["Spell4Pet"] = 0;
						SpellEB[5]:SetText(""); 		SpellEB["5Stack"]:SetText(""); 	LeaPlusDC["Spell5Pet"] = 0;

					elseif LeaPlusLC["PlayerClass"] == "DRUID" then
						SpellEB[1]:SetText("69369"); 	SpellEB["1Stack"]:SetText(""); 	LeaPlusDC["Spell1Pet"] = 0; -- Predator's Swiftness
						SpellEB[2]:SetText("62606"); 	SpellEB["2Stack"]:SetText(""); 	LeaPlusDC["Spell2Pet"] = 0; -- Savage Defense
						SpellEB[3]:SetText(""); 		SpellEB["3Stack"]:SetText(""); 	LeaPlusDC["Spell3Pet"] = 0;
						SpellEB[4]:SetText(""); 		SpellEB["4Stack"]:SetText(""); 	LeaPlusDC["Spell4Pet"] = 0;
						SpellEB[5]:SetText("33763"); 	SpellEB["5Stack"]:SetText("3"); LeaPlusDC["Spell5Pet"] = 0; -- Lifebloom

					elseif LeaPlusLC["PlayerClass"] == "MAGE" then
						SpellEB[1]:SetText("11426"); 	SpellEB["1Stack"]:SetText("");	LeaPlusDC["Spell1Pet"] = 0; -- Ice Barrier
						SpellEB[2]:SetText("48108"); 	SpellEB["2Stack"]:SetText("");	LeaPlusDC["Spell2Pet"] = 0; -- Pyroblast!
						SpellEB[3]:SetText(""); 		SpellEB["3Stack"]:SetText(""); 	LeaPlusDC["Spell3Pet"] = 0;
						SpellEB[4]:SetText(""); 		SpellEB["4Stack"]:SetText(""); 	LeaPlusDC["Spell4Pet"] = 0;
						SpellEB[5]:SetText(""); 		SpellEB["5Stack"]:SetText(""); 	LeaPlusDC["Spell5Pet"] = 0;

					elseif LeaPlusLC["PlayerClass"] == "WARRIOR" then
						SpellEB[1]:SetText("32216");	SpellEB["1Stack"]:SetText(""); 	LeaPlusDC["Spell1Pet"] = 0; -- Victory Rush
						SpellEB[2]:SetText(""); 		SpellEB["2Stack"]:SetText(""); 	LeaPlusDC["Spell2Pet"] = 0;
						SpellEB[3]:SetText(""); 		SpellEB["3Stack"]:SetText(""); 	LeaPlusDC["Spell3Pet"] = 0;
						SpellEB[4]:SetText(""); 		SpellEB["4Stack"]:SetText(""); 	LeaPlusDC["Spell4Pet"] = 0;
						SpellEB[5]:SetText("6673"); 	SpellEB["5Stack"]:SetText(""); 	LeaPlusDC["Spell5Pet"] = 0; -- Battle Shout

					elseif LeaPlusLC["PlayerClass"] == "PALADIN" then
						SpellEB[1]:SetText("114250"); 	SpellEB["1Stack"]:SetText("3"); LeaPlusDC["Spell1Pet"] = 0; -- Selfless Healer
						SpellEB[2]:SetText(""); 		SpellEB["2Stack"]:SetText(""); 	LeaPlusDC["Spell2Pet"] = 0;
						SpellEB[3]:SetText(""); 		SpellEB["3Stack"]:SetText(""); 	LeaPlusDC["Spell3Pet"] = 0;
						SpellEB[4]:SetText(""); 		SpellEB["4Stack"]:SetText(""); 	LeaPlusDC["Spell4Pet"] = 0;
						SpellEB[5]:SetText("20217"); 	SpellEB["5Stack"]:SetText(""); 	LeaPlusDC["Spell5Pet"] = 0; -- Blessing of Might

					elseif LeaPlusLC["PlayerClass"] == "PRIEST" then
						SpellEB[1]:SetText("17"); 		SpellEB["1Stack"]:SetText(""); 	LeaPlusDC["Spell1Pet"] = 0; -- Power Word: Shield
						SpellEB[2]:SetText(""); 		SpellEB["2Stack"]:SetText(""); 	LeaPlusDC["Spell2Pet"] = 0;
						SpellEB[3]:SetText(""); 		SpellEB["3Stack"]:SetText(""); 	LeaPlusDC["Spell3Pet"] = 0;
						SpellEB[4]:SetText(""); 		SpellEB["4Stack"]:SetText(""); 	LeaPlusDC["Spell4Pet"] = 0;
						SpellEB[5]:SetText("21562"); 	SpellEB["5Stack"]:SetText(""); 	LeaPlusDC["Spell5Pet"] = 0; -- Power Word: Fortitude
		
					elseif LeaPlusLC["PlayerClass"] == "ROGUE" then
						SpellEB[1]:SetText("13877");	SpellEB["1Stack"]:SetText(""); 	LeaPlusDC["Spell1Pet"] = 0; -- Blade Flurry
						SpellEB[2]:SetText("5171"); 	SpellEB["2Stack"]:SetText(""); 	LeaPlusDC["Spell2Pet"] = 0; -- Slice abd Dice
						SpellEB[3]:SetText(""); 		SpellEB["3Stack"]:SetText(""); 	LeaPlusDC["Spell3Pet"] = 0;
						SpellEB[4]:SetText(""); 		SpellEB["4Stack"]:SetText(""); 	LeaPlusDC["Spell4Pet"] = 0;
						SpellEB[5]:SetText("2823"); 	SpellEB["5Stack"]:SetText(""); 	LeaPlusDC["Spell5Pet"] = 0; -- Deadly Poison

				end

					LeaPlusLC["SpellIDonTip"] = "On";
					LeaPlusLC["SpellOnPlayer"] = "Off";
					SpellPanel:Show(); SpellPanel:Hide();
					SaveClassControls();

				else

					-- Show spell panel
					SpellPanel:Show();
					LeaPlusLC:HideFrames();

				end

			end

			LeaPlusCB["SpellIconsBtn"]:SetScript("OnClick", ShowSpellPanel);

			-- Function to show spell ID in tooltips
			local function SpellIDonTip(unit, target, index)
				if LeaPlusLC["SpellIDonTip"] == "On" then
					local spellid = select(11, UnitAura(target, index));
					if spellid then
						GameTooltip:AddLine("Spell ID: " .. spellid)
						GameTooltip:Show();
					end
				end
			end

			-- Add spell ID to tooltip when icons in the buff frame are hovered
			hooksecurefunc(GameTooltip, 'SetUnitAura', SpellIDonTip)   

			-- Add spell ID to tooltip when icons in the target frame are hovered
			hooksecurefunc(GameTooltip, 'SetUnitBuff', SpellIDonTip)

		end
 
		----------------------------------------------------------------------
		-- Hide soulbound confirmations
		----------------------------------------------------------------------

		if LeaPlusLC["NoConfirmBoP"] == "On" then

			-- Ensure loot source flag is empty
			local LootSource = {};
			local Entry = 1;

			-- Function to check if the raid warning needs to be refreshed
			local function CheckSource(loot)
				local match = false
				-- Traverse table containing list of recent GUIDs (table is reset when loot is closed)
				for k, v in pairs(LootSource) do
					local guid, quantity = GetLootSourceInfo(loot)
					if GetLootSourceInfo(loot) .. loot == LootSource[k] then
						match = true
					end
				end
				return match
			end

			-- Create frame to watch events
			local bop = CreateFrame("FRAME")
			bop:RegisterEvent("LOOT_BIND_CONFIRM")
			bop:RegisterEvent("LOOT_CLOSED");
			bop:SetScript("OnEvent", function(self, event, arg1, arg2, ...)

				if event == "LOOT_BIND_CONFIRM" then

					-- Loot and hide the confirmation
					ConfirmLootSlot(arg1, arg2);
					StaticPopup_Hide("LOOT_BIND",...)

					-- Show raid warning
					if LeaPlusLC["BoPShowWarning"] == "On" then

						-- Only continue with raid warning if GUID is different
						if not CheckSource(arg1) then

							-- Quit if loot roll windows are being used
							local inagroup, inaraid = IsInGroup(), IsInRaid();
							if (inagroup and GetLootMethod() ~= "freeforall") or (inaraid and GetLootMethod() ~= "freeforall") then return end

							-- Build loot string
							local lootIcon, lootName, lootQuantity, rarity, locked, isQuestItem, questID, isActive  = GetLootSlotInfo(arg1);

							local lootName = "|T" .. lootIcon .. ":0|t " ..  lootName
							local color = ITEM_QUALITY_COLORS[rarity]
							local lootString = "|cff" .. string.format('%02x%02x%02x',color.r * 255, color.g * 255, color.b * 255) .. lootName

							-- Show the warning
							RaidNotice_AddMessage(RaidBossEmoteFrame, lootString, ChatTypeInfo["RAID_BOSS_EMOTE"], 6);
							PlaySoundFile("Sound\\Interface\\RaidWarning.ogg");

							-- Set loot source flag (will remain until loot is closed)
							LootSource[Entry] = GetLootSourceInfo(arg1) .. arg1
							Entry = Entry + 1;

						end
					end
				elseif event == "LOOT_CLOSED" then
					-- Reset the loot source flag
					LootSource = {};
					Entry = 1;
				end
			end)
		end
				
		----------------------------------------------------------------------
		-- Coordinates
		----------------------------------------------------------------------

		if LeaPlusLC["StaticCoordsEn"] == "On" then

			-- Create movable coordinates frame
			local StaticCoordBox = CreateFrame("Frame", nil, UIParent)
			LeaPlusLC["StaticCoordBox"] = StaticCoordBox
			StaticCoordBox:Hide(); StaticCoordBox:EnableMouse(true);
			StaticCoordBox:SetClampedToScreen(true);
			StaticCoordBox:ClearAllPoints(); StaticCoordBox:SetPoint(LeaPlusLC["CoordsA"], UIParent, LeaPlusLC["CoordsR"], LeaPlusLC["CoordsX"], LeaPlusLC["CoordsY"]);
			StaticCoordBox:SetMovable(true); StaticCoordBox:RegisterForDrag("LeftButton")
			StaticCoordBox:SetScript("OnDragStart", StaticCoordBox.StartMoving)
			StaticCoordBox:SetScript("OnDragStop", function ()
				StaticCoordBox:StopMovingOrSizing();
				StaticCoordBox:SetUserPlaced(false);
				LeaPlusLC["CoordsA"], void, LeaPlusLC["CoordsR"], LeaPlusLC["CoordsX"], LeaPlusLC["CoordsY"] = StaticCoordBox:GetPoint();
			end)
			StaticCoordBox.t = StaticCoordBox:CreateTexture(nil, "BACKGROUND"); StaticCoordBox.t:SetAllPoints(); StaticCoordBox.t:SetTexture(0.05, 0.05, 0.05, 0.8)

			local Splay = CreateFrame("FRAME", nil, StaticCoordBox)
			Splay:SetWidth(38); Splay:SetHeight(16);
			Splay:SetPoint("TOPLEFT", 2, -2)

			Splay.x = Splay:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") 
			Splay.x:SetAllPoints(); Splay.x:SetJustifyH"LEFT";

			Splay.y = Splay:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") 
			Splay.y:SetPoint("LEFT", Splay.x, "RIGHT", 0, 0);
			Splay.y:SetJustifyH"LEFT";

			local stimer = 0; -- Internal timer for OnUpdate
			local updtime = 0.2; -- Configurable timer for OnUpdate (changed when throttle is enabled)

			local function ShowStaticCoordinates(self, elapsed)
				stimer = stimer + elapsed;
				while (stimer > updtime) do
					local vplayx, vplayy = GetPlayerMapPosition("player")
					if vplayx and vplayy and tonumber(vplayx) > 0 and tonumber(vplayy) > 0 then
						Splay.x:SetText(format("%0.1f", (floor(vplayx * 1000 + 0.5)) / 10))
						Splay.y:SetText("   " .. format("%0.1f", (floor(vplayy * 1000 + 0.5)) / 10))
					else
						Splay.x:SetText("00.0");
						Splay.y:SetText("   00.0");
					end
					stimer = 0;
				end
			end

			-- Calculate coordinates (only runs if coordinates are showing)
			StaticCoordBox:SetScript("OnUpdate", ShowStaticCoordinates)

			-- Create side panel
			local StaticPanel = LeaPlusLC:CreateSidePanel("Coordinates", 164, 400)

			LeaPlusLC:MakeTx(StaticPanel, "Coordinates Frame", 10, -60)
			LeaPlusLC:MakeCB(StaticPanel, "StaticCoords", "Enable coordinates", 10, -80, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["StaticCoords"], "If checked, the coordinates frame will be enabled and you will be able to see it based on the settings below.\n\nIf you have the minimap button enabled, you can hold down SHIFT and right-click it to toggle this setting at any time.\n\nIf unchecked, the coordinates frame will be disabled and no CPU power will be allocated to updating them.\n\nNote that while this option is checked, the world map will set itself to your current zone whenever your zone (or subzone) changes.");

			LeaPlusLC:MakeCB(StaticPanel, "StaticCoordsBack", "Show background", 10, -100, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["StaticCoordsBack"], "If checked, the coordinates frame will have a dark background.");

			LeaPlusLC:MakeTx(StaticPanel, "Visibility", 10, -140)

			LeaPlusLC:MakeCB(StaticPanel, "StaticCoordsMap", "Bind to world map", 10, -160, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["StaticCoordsMap"], "If checked, the coordinates frame will be shown only when the smaller world map is shown and hidden when it's not.");

			LeaPlusLC:MakeCB(StaticPanel, "StaticCoordsTop", "Show on top", 10, -180, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["StaticCoordsTop"], "If checked, the coordinates frame will show over the top of most frames (such as the world map frame, bag frames, etc).");

			LeaPlusLC:MakeTx(StaticPanel, "Mechanics", 10, -220)

			LeaPlusLC:MakeCB(StaticPanel, "StaticCoordsLock", "Lock coordinates", 10, -240, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["StaticCoordsLock"], "If checked, the coordinates frame will be locked and you will not be able to move it.\n\nEnabling this option will make the coordinates frame non-interactive, meaning you will be able to click through it as if it wasn't there.\n\nThis is useful if you are showing the coordinates in a space where you would normally click (such as the game world or minimap).");

			LeaPlusLC:MakeCB(StaticPanel, "StaticThrottle", "Throttle updates", 10, -260, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["StaticThrottle"], "If checked, the CPU power allocated to calculating coordinates will be throttled.\n\nThis will help to conserve CPU power, however, the coordinates will not be updated quite so frequently.\n\nIt's recommended that you leave this box checked.");

			LeaPlusLC:MakeTx(StaticPanel, "Scale", 10, -300)
			LeaPlusLC:MakeSL(StaticPanel, "StaticCoordsScale", "", 0.9, 2.2, 0.1, 10, -320, "%.1f")

			-- Function to show coordinates based on options (run by many handlers)
			local function RefreshStaticCoords()
				-- Show or hide coordinates
				if LeaPlusLC["StaticCoords"] == "On" then
					-- Show coordinates and set map to current zone
					StaticCoordBox:Show();
					SetMapToCurrentZone();
				else
					StaticCoordBox:Hide();
				end
				-- Show or hide the background
				if LeaPlusLC["StaticCoordsBack"] == "On" then
					StaticCoordBox.t:Show();
				else
					StaticCoordBox.t:Hide();
				end
				-- Set update timer (lower values update faster but use more CPU power)
				if LeaPlusLC["StaticThrottle"] == "On" then updtime = 0.2 else updtime = 0.05 end;
				-- Set scale of coordinates
				local scale = LeaPlusLC["StaticCoordsScale"]
				StaticCoordBox:SetWidth(94 * scale);
				StaticCoordBox:SetHeight(18 * scale);
				Splay:SetScale(scale);
				-- Set locked status
				if LeaPlusLC["StaticCoordsLock"] == "On" then
					StaticCoordBox:SetScript("OnDragStart", nil);
					StaticCoordBox:EnableMouse(false);
				else
					StaticCoordBox:SetScript("OnDragStart", StaticCoordBox.StartMoving)
					StaticCoordBox:EnableMouse(true);
				end
				-- Show on top
				if LeaPlusLC["StaticCoordsTop"] == "On" then
					StaticCoordBox:SetFrameStrata("HIGH")
				else
					StaticCoordBox:SetFrameStrata("MEDIUM")
				end
				-- Show with map
				if LeaPlusLC["StaticCoords"] == "On" then
					if LeaPlusLC["StaticCoordsMap"] == "On" then
						if WorldMapFrame:IsShown() then
							StaticCoordBox:Show();
						else
							StaticCoordBox:Hide();
						end
					else
						StaticCoordBox:Show();
					end
				else
					StaticCoordBox:Hide();
				end
			end
		
			-- Assign file level scope to local function (so that the minimap button can run it)
			LeaPlusLC.RefreshStaticCoords = RefreshStaticCoords

			-- Refresh map when controls are clicked
			LeaPlusCB["StaticCoords"]:HookScript("OnClick", RefreshStaticCoords)
			LeaPlusCB["StaticCoordsBack"]:HookScript("OnClick", RefreshStaticCoords)
			LeaPlusCB["StaticThrottle"]:HookScript("OnClick", RefreshStaticCoords)
			LeaPlusCB["StaticCoordsScale"]:HookScript("OnValueChanged", RefreshStaticCoords)
			LeaPlusCB["StaticCoordsLock"]:HookScript("OnClick", RefreshStaticCoords)
			LeaPlusCB["StaticCoordsTop"]:HookScript("OnClick", RefreshStaticCoords)
			LeaPlusCB["StaticCoordsMap"]:HookScript("OnClick", RefreshStaticCoords)

			-- Hide coordinates frame when battle pet frame is shown
			hooksecurefunc("PetBattleFrame_Display", function() 
				if LeaPlusLC["StaticCoords"] == "On" then
					LeaPlusLC["StaticCoordBox"]:Hide();
				end
			end)

			-- Refresh coordinates when battle frame is hidden
			hooksecurefunc("PetBattleFrame_Remove", function() 
				if LeaPlusLC["StaticCoords"] == "On" then
					RefreshStaticCoords();
				end
			end)

			-- Show coordinates frame when world map is shown (handled separately to isolate map scripts)
			local function ShowWithMap()
				if LeaPlusLC["StaticCoords"] == "On" then
					if WorldMapFrame:IsShown() then
						if LeaPlusLC["StaticCoordsMap"] == "On" then
							StaticCoordBox:Show();
						end
					else
						if LeaPlusLC["StaticCoordsMap"] == "On" then
							StaticCoordBox:Hide();
						end
					end
				end
			end

			WorldMapFrame:HookScript("OnShow", ShowWithMap);
			WorldMapFrame:HookScript("OnHide", ShowWithMap);

			-- Load settings on startup
			RefreshStaticCoords();

			-- Create save button
			LeaPlusLC:CreateButton("SaveStaticBtn", StaticPanel, "Save", "BOTTOMLEFT", 10, 10, 70, 25, "")
			LeaPlusCB["SaveStaticBtn"]:SetScript("OnClick", function()
				StaticPanel:Hide(); LeaPlusLC["PageF"]:Show(); LeaPlusLC["Page6"]:Show();
				return
			end)

			-- Create reset button
			LeaPlusLC:CreateButton("ResetStaticBtn", StaticPanel, "Reset", "BOTTOMLEFT", 80, 10, 70, 25, "")
			LeaPlusCB["ResetStaticBtn"]:SetScript("OnClick", function()

				-- Reset checkboxes
				LeaPlusLC["StaticCoords"] = "On"
				LeaPlusLC["StaticCoordsBack"] = "Off"
				LeaPlusLC["StaticThrottle"] = "On"
				LeaPlusLC["StaticCoordsScale"] = 2.2;
				LeaPlusLC["StaticCoordsLock"] = "Off";
				LeaPlusLC["StaticCoordsMap"] = "Off";
				LeaPlusLC["StaticCoordsTop"] = "Off";
				RefreshStaticCoords();

				-- Reset coordinates frame location
				LeaPlusLC["CoordsA"], LeaPlusLC["CoordsR"], LeaPlusLC["CoordsX"], LeaPlusLC["CoordsY"] = "CENTER", "CENTER", 0, 0
				StaticCoordBox:ClearAllPoints();
				StaticCoordBox:SetPoint(LeaPlusLC["CoordsA"], UIParent, LeaPlusLC["CoordsR"], LeaPlusLC["CoordsX"], LeaPlusLC["CoordsY"]);

				-- Refresh side panel
				StaticPanel:Hide(); StaticPanel:Show();

			end)

			-- Show side panal when options panel button is clicked
			local function ShowSide()
				StaticPanel:Show();
				LeaPlusLC:HideFrames();
			end

			LeaPlusCB["ModStaticCoordsBtn"]:SetScript("OnClick", ShowSide);

			-- Refresh map when zone changes
			local function UpdateMapZone()
				if LeaPlusLC["StaticCoords"] == "On" then
					SetMapToCurrentZone();
				end
			end

			StaticCoordBox:RegisterEvent("ZONE_CHANGED_NEW_AREA");
			StaticCoordBox:RegisterEvent("ZONE_CHANGED");
			StaticCoordBox:RegisterEvent("ZONE_CHANGED_INDOORS");
			StaticCoordBox:RegisterEvent("NEW_WMO_CHUNK");
			StaticCoordBox:SetScript("OnEvent", UpdateMapZone);	

		end

		----------------------------------------------------------------------
		-- Minimap customisation
		----------------------------------------------------------------------

		-- Enable minimap customisation
		if LeaPlusLC["MinimapMod"] == "On" then

			-- Create minimap modification side panel
			local SideMinimap = LeaPlusLC:CreateSidePanel("Minimap", 164, 270)

			-- Update minimap when slider control changes
			local function RefreshMinimap()
				MinimapCluster:SetScale(LeaPlusLC["MinimapScale"])
			end

			-- Add checkboxes
			LeaPlusLC:MakeTx(SideMinimap, "Features", 10, -60)
			LeaPlusLC:MakeCB(SideMinimap, "MergeTrackBtn", "Merge buttons", 10, -80, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["MergeTrackBtn"], "If checked, the minimap tracking button will be merged with the calendar button to save space.\n\nThe new tracking button will be moved to the space normally occupied by the calendar button.\n\nYou will be able to left-click the tracking button to show the tracking menu and right-click it to show the calendar.");

			LeaPlusLC:MakeCB(SideMinimap, "HideMinimapZone", "Hide zone text", 10, -100, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["HideMinimapZone"], "If checked, the zone information shown above the minimap, as well as the world map button, will be hidden.\n\nThe tooltip for the tracking button will show zone text information instead.");

			LeaPlusLC:MakeCB(SideMinimap, "HideMinimapTime", "Hide clock", 10, -120, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["HideMinimapTime"], "If checked, the clock will be hidden.");

			LeaPlusLC:MakeCB(SideMinimap, "MinimapMouseZoom", "Mousewheel zoom", 10, -140, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["MinimapMouseZoom"], "If checked, you will be able to use the mousewheel to zoom in and out of the minimap.  The zoom in/out buttons will be hidden.");

			-- Create slider control
			LeaPlusLC:MakeTx(SideMinimap, "Scale", 10, -180)
			LeaPlusLC:MakeSL(SideMinimap, "MinimapScale", "", 0.5, 3, 0.1, 10, -200, "%.2f")
			LeaPlusCB["MinimapScale"]:HookScript("OnValueChanged", RefreshMinimap)

			-- Store Blizzard handlers
			local origMiniMapTrackingButtonOnEnter = MiniMapTrackingButton:GetScript('OnEnter')
			local zonta,zontp,zontr,zontx,zonty = MinimapZoneTextButton:GetPoint();

			local function ShowZoneTip()
				if LeaPlusLC["HideMinimapZone"] == "On" then
					-- Show zone information in tooltip
					local zoneName = GetZoneText();
					local subzoneName = GetSubZoneText();
					if ( subzoneName == zoneName ) then
						subzoneName = "";	
					end
					-- Change the owner and position (needed for Minimap_SetTooltip)
					GameTooltip:SetOwner(MinimapZoneTextButton, "ANCHOR_LEFT")
					MinimapZoneTextButton:SetAllPoints(MiniMapTrackingButton)
					-- Show the tooltip
					local pvpType, isSubZonePvP, factionName = GetZonePVPInfo();
					Minimap_SetTooltip( pvpType, factionName )
					GameTooltip:Show();
				else
					MinimapZoneTextButton:ClearAllPoints();
					MinimapZoneTextButton:SetPoint(zonta,zontp,zontr,zontx,zonty)
				end
			end

			-- Merge buttons
			local function UpdateMiniMergeButtons()
				if LeaPlusLC["MergeTrackBtn"] == "On" then
					-- Hide calendar button
					GameTimeFrame:Hide();
					-- Move the tracking button to the calendar button space
					MiniMapTracking:ClearAllPoints();
					MiniMapTracking:SetAllPoints(GameTimeFrame);
					-- Right-clicking the tracking button shows the calendar 
					MiniMapTrackingButton:SetScript("OnMouseDown", function(self, btn)
						if btn == "RightButton" then GameTimeFrame:Click();	end
					end)
				else
					-- Show the calendar button
					GameTimeFrame:Show();
					-- Move the tracking button to its origianl position
					MiniMapTracking:ClearAllPoints();
					MiniMapTracking:SetPoint("TOPLEFT", MinimapBackdrop, "TOPLEFT", 9, -45);
					-- Remove right-click from the tracking button
					MiniMapTrackingButton:SetScript("OnMouseDown", nil);
				end
			end

			-- When the merge buttons option is checked, update the minimap
			LeaPlusCB["MergeTrackBtn"]:HookScript("OnClick", UpdateMiniMergeButtons);

			-- Update the minimap on startup
			UpdateMiniMergeButtons();

			-- Hide minimap zone text
			local function UpdateMiniZoneText()
				if LeaPlusLC["HideMinimapZone"] == "On" then
					-- Hide the minimap zone information and world map button
					MinimapZoneTextButton:Hide(); MiniMapWorldMapButton:Hide();
					MinimapBorderTop:SetTexture("");
					-- Move the minimap up to the top
					MinimapCluster:ClearAllPoints(); MinimapCluster:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 20);
					-- Set the tooltip of the tracking button as the zone name
					MiniMapTrackingButton:SetScript("OnEnter", ShowZoneTip);
				else
					-- Show the minimap zone information and world map button
					MinimapZoneTextButton:Show(); MiniMapWorldMapButton:Show();
					MinimapBorderTop:SetTexture("Interface\\Minimap\\UI-Minimap-Border");
					-- Move the minimap to its original position
					MinimapCluster:ClearAllPoints(); MinimapCluster:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0);
					-- Set the tooltip of the tracking button as the original one
					MiniMapTrackingButton:SetScript("OnEnter", origMiniMapTrackingButtonOnEnter);
				end
			end

			-- Function to show tooltip text
			local function ShowTextAndTip()
				UpdateMiniZoneText(); 
				ShowZoneTip();
			end

			-- When the hide zone text option is checked, update the minimap
			LeaPlusCB["HideMinimapZone"]:HookScript("OnClick", ShowTextAndTip);

			-- Update the minimap on startup
			UpdateMiniZoneText();

			-- Hide the time
			if not IsAddOnLoaded("Blizzard_TimeManager") then
				LoadAddOn("Blizzard_TimeManager")
			end

			local function UpdateClock()
				if LeaPlusLC["HideMinimapTime"] == "On"	then
					TimeManagerClockButton:Hide();
				else
					TimeManagerClockButton:Show();
				end
			end

			-- Update the clock when the checkbox is clicked
			LeaPlusCB["HideMinimapTime"]:HookScript("OnClick", UpdateClock);
		
			-- Update the clock on startup
			UpdateClock();

			-- Use mousewheel to zoom
			local function MiniZoom(self, arg1)
				if arg1 > 0 and self:GetZoom() < 5 then
					self:SetZoom(self:GetZoom() + 1)
				elseif arg1 < 0 and self:GetZoom() > 0 then
					self:SetZoom(self:GetZoom() - 1)
				end
			end

			local function MiniZoomSet()
				if LeaPlusLC["MinimapMouseZoom"] == "On" then
					MinimapZoomIn:Hide()
					MinimapZoomOut:Hide()
					Minimap:EnableMouseWheel(true)
					Minimap:SetScript("OnMouseWheel", MiniZoom);
				else
					MinimapZoomIn:Show()
					MinimapZoomOut:Show()
					Minimap:EnableMouseWheel(false)
					Minimap:SetScript("OnMouseWheel", nil);
				end
			end

			-- Update the zoom setting when checkbox is clicked
			LeaPlusCB["MinimapMouseZoom"]:HookScript("OnClick", MiniZoomSet);
	
			-- Update the zoom setting on startup
			MiniZoomSet();

			-- Create save button
			LeaPlusLC:CreateButton("SaveMinimapBtn", SideMinimap, "Save", "BOTTOMLEFT", 10, 10, 70, 25, "")
			LeaPlusCB["SaveMinimapBtn"]:SetScript("OnClick", function()
				-- Hide the side panel and show the options panel again
				SideMinimap:Hide(); LeaPlusLC["PageF"]:Show(); LeaPlusLC["Page6"]:Show();
				return
			end)

			-- Create reset button
			LeaPlusLC:CreateButton("ResetMinimapBtn", SideMinimap, "Reset", "BOTTOMLEFT", 80, 10, 70, 25, "")
			LeaPlusCB["ResetMinimapBtn"]:SetScript("OnClick", function()
				-- Reset the minimap scale and refresh the side panel
				LeaPlusLC["MergeTrackBtn"] = "Off"
				UpdateMiniMergeButtons();
				LeaPlusLC["HideMinimapZone"] = "Off"
				UpdateMiniZoneText(); ShowTextAndTip();
				LeaPlusLC["HideMinimapTime"] = "Off"
				UpdateClock();
				LeaPlusLC["MinimapMouseZoom"] = "Off"
				MiniZoomSet();
				LeaPlusLC["MinimapScale"] = 1.00;
				RefreshMinimap();
				SideMinimap:Hide();
				SideMinimap:Show();
			end)

			-- Handler for options panel ? button
			LeaPlusCB["ModMinimapBtn"]:SetScript("OnClick", function()
				if IsShiftKeyDown() and IsControlKeyDown() then

					-- Top secret profile (ssh!)
					LeaPlusLC["MergeTrackBtn"] = "On"; UpdateMiniMergeButtons();
					LeaPlusLC["HideMinimapZone"] = "On"
					UpdateMiniZoneText(); ShowTextAndTip();
					LeaPlusLC["HideMinimapTime"] = "Off"
					UpdateClock();
					LeaPlusLC["MinimapMouseZoom"] = "Off"
					MiniZoomSet();
					LeaPlusLC["MinimapScale"] = 1.30;
					RefreshMinimap();

				else

					-- Show side panel
					SideMinimap:Show();
					LeaPlusLC:HideFrames();

				end
			end)

			-- Update minimap during loading time
			RefreshMinimap();

		end

		-- Quest detail font size
		if LeaPlusLC["QuestFontChange"] == "On" then

			-- Function to update the font size
			local function QuestSizeUpdate()
				QuestTitleFont:SetFont(QuestTitleFont:GetFont(), LeaPlusLC["LeaPlusQuestFontSize"]+6, nil);
				QuestFont:SetFont(QuestFont:GetFont(), LeaPlusLC["LeaPlusQuestFontSize"]+1, nil);
				QuestFontNormalSmall:SetFont(QuestFontNormalSmall:GetFont(), LeaPlusLC["LeaPlusQuestFontSize"], nil);
			end

			-- Set text size on startup
			QuestSizeUpdate();

			-- Set text size after changing slider
			LeaPlusCB["LeaPlusQuestFontSize"]:HookScript("OnValueChanged", QuestSizeUpdate);

		end

		-- Mail font size
		if LeaPlusLC["MailFontChange"] == "On" then

			-- Function to update the font size
			local function MailSizeUpdate()
				local MailFont = QuestFont:GetFont();
				OpenMailBodyText:SetFont(MailFont, LeaPlusLC["LeaPlusMailFontSize"])
				SendMailBodyEditBox:SetFont(MailFont, LeaPlusLC["LeaPlusMailFontSize"])
			end

			-- Set text size on startup
			MailSizeUpdate();

			-- Set text size after changing slider
			LeaPlusCB["LeaPlusMailFontSize"]:HookScript("OnValueChanged", MailSizeUpdate);

		end

		if LeaPlusLC["ShowMapMod"] == "On" then

			-- Set world map to mini size if map customisation is enabled (rest is done in variable)
			SetCVar("miniWorldMap", "1")

		end

		if LeaPlusLC["ViewPortEnable"] == "On" then

			-- Create static textures
			local BordTop = WorldFrame:CreateTexture(nil, "ARTWORK");
			local BordBot = WorldFrame:CreateTexture(nil, "ARTWORK");
			local BordLeft = WorldFrame:CreateTexture(nil, "ARTWORK");
			local BordRight = WorldFrame:CreateTexture(nil, "ARTWORK");

			BordTop:SetTexture(0, 0, 0, 1); 
			BordBot:SetTexture(0, 0, 0, 1);
			BordLeft:SetTexture(0, 0, 0, 1);
			BordRight:SetTexture(0, 0, 0, 1);

			BordTop:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0);
			BordTop:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0);
			BordBot:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0);
			BordBot:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0);

			BordLeft:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0);
			BordLeft:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0);
			BordRight:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0);
			BordRight:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0);

			local function RefreshViewport()

				local gwidth, gheight = string.match(GetCVar("gxResolution"),"(%d+).-(%d+)");
				local scale = 768 / gheight;

				if LeaPlusLC["ViewportResize"] == "On" then
					-- Resize is on, remove borders and resize game world
					BordTop:SetHeight(0);
					BordBot:SetHeight(0);
					WorldFrame:SetPoint("TOPLEFT", 0, -(LeaPlusLC["ViewPortTop"] * scale));
					WorldFrame:SetPoint("BOTTOMRIGHT", 0, (LeaPlusLC["ViewPortBottom"] * scale));
				else
					-- Resize is off, set border width and maximise game world
					BordTop:SetHeight(LeaPlusLC["ViewPortTop"]);
					BordBot:SetHeight(LeaPlusLC["ViewPortBottom"]);
					WorldFrame:SetPoint("TOPLEFT", 0, 0);
					WorldFrame:SetPoint("BOTTOMRIGHT", 0, 0);
				end
		
				-- Set left and right border width
				BordLeft:SetWidth(LeaPlusLC["ViewPortLeft"]);
				BordRight:SetWidth(LeaPlusLC["ViewPortRight"]);

				-- Hide the borders if they have no height
				if LeaPlusLC["ViewPortTop"] == 0 then BordTop:Hide(); else BordTop:Show(); end
				if LeaPlusLC["ViewPortBottom"] == 0 then BordBot:Hide(); else BordBot:Show(); end
				if LeaPlusLC["ViewPortLeft"] == 0 then BordLeft:Hide(); else BordLeft:Show(); end
				if LeaPlusLC["ViewPortRight"] == 0 then BordRight:Hide(); else BordRight:Show(); end
					
			end

			-- Create viewport modification side panel
			local SideViewport = LeaPlusLC:CreateSidePanel("Viewport", 164, 330)

			-- Create slider controls
			LeaPlusLC:MakeTx(SideViewport, "Top Border", 10, -60)
			LeaPlusLC:MakeSL(SideViewport, "ViewPortTop", "", 0, 250, 5, 10, -80, "%.0f")
			LeaPlusCB["ViewPortTop"]:HookScript("OnValueChanged", RefreshViewport)

			LeaPlusLC:MakeTx(SideViewport, "Bottom Border", 10, -110)
			LeaPlusLC:MakeSL(SideViewport, "ViewPortBottom", "", 0, 250, 5, 10, -130, "%.0f")
			LeaPlusCB["ViewPortBottom"]:HookScript("OnValueChanged", RefreshViewport)

			LeaPlusLC:MakeTx(SideViewport, "Left Border", 10, -160)
			LeaPlusLC:MakeSL(SideViewport, "ViewPortLeft", "", 0, 250, 5, 10, -180, "%.0f")
			LeaPlusCB["ViewPortLeft"]:HookScript("OnValueChanged", RefreshViewport)

			LeaPlusLC:MakeTx(SideViewport, "Right Border", 10, -210)
			LeaPlusLC:MakeSL(SideViewport, "ViewPortRight", "", 0, 250, 5, 10, -230, "%.0f")
			LeaPlusCB["ViewPortRight"]:HookScript("OnValueChanged", RefreshViewport)

			-- Create resize game world checkbox
			LeaPlusLC:MakeCB(SideViewport, "ViewportResize", "Resize game world", 10, -260, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["ViewportResize"], "If checked, the game world will be resized to fit between the top and bottom borders.\n\nThis ensures that none of the game world is blocked by those borders.\n\nNote that this setting has no effect on the left and right borders.")

			-- Create save button
			LeaPlusLC:CreateButton("SaveViewportBtn", SideViewport, "Save", "BOTTOMLEFT", 10, 10, 70, 25, "")
			LeaPlusCB["SaveViewportBtn"]:SetScript("OnClick", function()
				SideViewport:Hide();
				LeaPlusLC["PageF"]:Show();
				LeaPlusLC["Page7"]:Show();
				return
			end)

			-- Create reset button
			LeaPlusLC:CreateButton("ResetViewportBtn", SideViewport, "Reset", "BOTTOMLEFT", 80, 10, 70, 25, "")
			LeaPlusCB["ResetViewportBtn"]:SetScript("OnClick", function()
				LeaPlusLC["ViewPortTop"] = 0 
				LeaPlusLC["ViewPortBottom"] = 0
				LeaPlusLC["ViewPortLeft"] = 0
				LeaPlusLC["ViewPortRight"] = 0
				LeaPlusLC["ViewportResize"] = "Off"
				SideViewport:Hide(); SideViewport:Show();
				RefreshViewport();
			end)

			-- Handler for options panel ? button
			LeaPlusCB["ModViewportBtn"]:SetScript("OnClick", function()
				SideViewport:Show();
				LeaPlusLC:HideFrames();
			end)

			-- Refresh viewport when resize button is clicked and on startup
			LeaPlusCB["ViewportResize"]:HookScript("OnClick", RefreshViewport)
			RefreshViewport();

		end

		if LeaPlusLC["DurabilityStatus"] == "On" then

			local Slots = {"HeadSlot", "ShoulderSlot", "ChestSlot", "WristSlot", "HandsSlot", "WaistSlot", "LegsSlot", "FeetSlot", "MainHandSlot", "SecondaryHandSlot"}
			local SlotsFriendly = {INVTYPE_HEAD, INVTYPE_SHOULDER, INVTYPE_CHEST, INVTYPE_WRIST, INVTYPE_HAND, INVTYPE_WAIST, INVTYPE_LEGS, INVTYPE_FEET, INVTYPE_WEAPONMAINHAND, INVTYPE_WEAPONOFFHAND}

			-- Show durability status in tooltip or status line (tip or status)
			local function ShowDuraStats(where)

				local duravaltotal, duramaxtotal, durapercent, doitonce = 0, 0, 0, 0
				local valcol

				if where == "tip" then
					-- Creare layout
					_G["GameTooltipTextLeft1"]:SetText("|cffffffff"); _G["GameTooltipTextRight1"]:SetText("|cffffffff")
					_G["GameTooltipTextLeft2"]:SetText("|cffffffff"); _G["GameTooltipTextRight2"]:SetText("|cffffffff")
				end

				-- Traverse equipment slots
				for k, slotName in ipairs(Slots) do
					if GetInventorySlotInfo(slotName) then
						local id = GetInventorySlotInfo(slotName)
						local duraval, duramax = GetInventoryItemDurability(id)
						if duraval ~= nil then

							-- Add to tooltip (hack)
							if where == "tip" then
								local valcol = "|cffffffff"
								local durapercent = tonumber(string.format("%.0f", duraval / duramax * 100))
								if durapercent >= 80 then valcol = "|cff00FF00"	elseif durapercent >= 60 then valcol = "|cff99FF00"	elseif durapercent >= 40 then valcol = "|cffFFFF00"	elseif durapercent >= 20 then valcol = "|cffFF9900"	elseif durapercent >= 0 then valcol = "|cffFF2000" end
								if doitonce == 0 then GameTooltip:AddLine("|cffffffff"); GameTooltip:AddLine("|cffffffff"); doitonce = doitonce + 1; end
								_G["GameTooltipTextLeft1"]:SetText("Durability")
								_G["GameTooltipTextLeft2"]:SetText(_G["GameTooltipTextLeft2"]:GetText() .. SlotsFriendly[k] .. "\n")
								_G["GameTooltipTextRight2"]:SetText(_G["GameTooltipTextRight2"]:GetText() ..  valcol .. durapercent .. "%" .. "\n")
							end

							duravaltotal = duravaltotal + duraval
							duramaxtotal = duramaxtotal + duramax
						end
					end
				end
				durapercent = duravaltotal / duramaxtotal * 100

				if where == "tip" then

					-- Show overall durability in the tooltip
					if durapercent >= 80 then valcol = "|cff00FF00"	elseif durapercent >= 60 then valcol = "|cff99FF00"	elseif durapercent >= 40 then valcol = "|cffFFFF00"	elseif durapercent >= 20 then valcol = "|cffFF9900"	elseif durapercent >= 0 then valcol = "|cffFF2000" else return end
						_G["GameTooltipTextLeft2"]:SetText(_G["GameTooltipTextLeft2"]:GetText() .. "\nOverall " .. valcol)
						_G["GameTooltipTextRight2"]:SetText(_G["GameTooltipTextRight2"]:GetText() .. "\n" .. valcol .. string.format("%.0f", durapercent) .. "%")

						-- Show both lines of the tooltip (yep, just two)
						GameTooltipTextLeft1:Show(); GameTooltipTextRight1:Show();
						GameTooltipTextLeft2:Show(); GameTooltipTextRight2:Show();
						GameTooltipTextRight2:SetJustifyH"RIGHT";
						GameTooltip:Show();

				elseif where == "status" then
					-- Show simple status line instead
					LeaPlusLC:Print("|TInterface\\COMMON\\Indicator-Green.png:0|t You have " .. string.format("%.0f", durapercent) .. "%" .. " durability.")
				end
			end

			-- Hook the tooltip to the expand button on the character frame
			CharacterFrameExpandButton:SetScript("OnEnter", function()
				GameTooltip:SetOwner(CharacterFrameExpandButton, "ANCHOR_RIGHT");
				ShowDuraStats("tip");
			end)

			-- Create frame to watch for characters coming back to life
			local DeathDura = CreateFrame("FRAME")
			DeathDura:RegisterEvent("PLAYER_UNGHOST")
			DeathDura:SetScript("OnEvent", function(self,event)
				if event == "PLAYER_UNGHOST" then
					-- Player has ressed by corpse-running, used spirit healer or accepted a res while corpse running
					ShowDuraStats("status")
				end
			end)

			hooksecurefunc("AcceptResurrect", function()
				-- Player has ressed without releasing
				ShowDuraStats("status")
			end)
			
		end

		-- Fix the quest fading bug (may as well disable it for all here as there's no option to use it in the client)
		QuestInfoDescriptionText.SetAlphaGradient = function() return end

		-- Hide the combat log
		if LeaPlusLC["NoCombatLogTab"] == "On" then

			FCF_DockFrame(ChatFrame2, 2);
			FCF_SetWindowName(ChatFrame2, ".", 1)

			ChatFrame2:Hide();
			ChatFrame2Tab:Hide();
			ChatFrame2.Show = ChatFrame2.Hide;
			ChatFrame2Tab.Show = ChatFrame2Tab.Hide;

		end

		-- Block talent spec spam
		if LeaPlusLC["NoSpecSpam"] == "On" then

			-- Block dual-spec spam
			local function TalentFilter(void, void, msg)
				if (msg:find(format(ERR_LEARN_ABILITY_S, ".+"))) or (msg:find(format(ERR_LEARN_SPELL_S, ".+"))) or (msg:find(format(ERR_LEARN_PASSIVE_S, ".+"))) or (msg:find(format(ERR_SPELL_UNLEARNED_S, ".+"))) then
					return true 
				end
			end

			local TalentSpam = CreateFrame("FRAME")
			TalentSpam:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED");
			TalentSpam:RegisterUnitEvent("UNIT_SPELLCAST_START", "player")
			TalentSpam:RegisterUnitEvent("UNIT_SPELLCAST_INTERRUPTED", "player");
			TalentSpam:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", "player");

			TalentSpam:SetScript("OnEvent", function(self, event, spec, void, void, void, spell)
				if event == "UNIT_SPELLCAST_START" and (spell == 63645 or spell == 63644) then
					ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", TalentFilter)
				elseif (event == "UNIT_SPELLCAST_INTERRUPTED" or event == "UNIT_SPELLCAST_SUCCEEDED") and (spell == 63645 or spell == 63644) then
					ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SYSTEM", TalentFilter)
				elseif event == "ACTIVE_TALENT_GROUP_CHANGED" then
					LeaPlusLC:ShowActiveSpec();
				end
			end)

		end

		-- Move the chat frame editbox to the top (combat log part is done in BlizzDep)
		if LeaPlusLC["MoveChatEditBoxToTop"] == "On" then

			-- Set the chat style to classic and prevent changes
			SetCVar("chatStyle", "classic")
			InterfaceOptionsSocialPanelChatStyle_SetChatStyle("classic")

			InterfaceOptionsSocialPanelChatStyleButton:Disable()
			InterfaceOptionsSocialPanelChatStyleText:SetAlpha(0.0)
			InterfaceOptionsSocialPanelChatStyle.tooltip="Chat style is set to classic and controlled by Leatrix Plus."

			-- Position the editbox
			_G["ChatFrame1EditBox"]:ClearAllPoints();
			_G["ChatFrame1EditBox"]:SetPoint("TOPLEFT", GeneralDockManager, "TOPLEFT", 0, -25);
			_G["ChatFrame1EditBox"]:SetWidth(ChatFrame1:GetWidth());

			-- Ensure editbox width matches chatframe width
			ChatFrame1:HookScript("OnSizeChanged", function()
				ChatFrame1EditBox:SetWidth(ChatFrame1:GetWidth())
			end)

		end

		-- Hide loot won alert
		if LeaPlusLC["NoLootWonAlert"] == "On" then
			local function NoLootAlert()
				LootWonAlertFrame1:Hide()
				BonusRollLootWonFrame:Hide();
			end;
			LootWonAlertFrame1:SetScript("OnShow", NoLootAlert);
			BonusRollLootWonFrame:SetScript("OnShow", NoLootAlert);
		end

		-- Hide character controls
		if LeaPlusLC["NoCharControls"] == "On" then
			CharacterModelFrameControlFrame:HookScript("OnShow", LeaPlusLC.HideSelf);
			DressUpModelControlFrame:HookScript("OnShow", LeaPlusLC.HideSelf);
			SideDressUpModelControlFrame:HookScript("OnShow", LeaPlusLC.HideSelf);
		end

		-- Zone text
		if LeaPlusLC["HideZoneText"] == "On" then
			local function NoZoneText()
				ZoneTextFrame:Hide();
			end
			ZoneTextFrame:SetScript("OnShow", NoZoneText);
		end

		-- Subzone text
		if LeaPlusLC["HideSubzoneText"] == "On" then
			local function NoSubZoneText()
				SubZoneTextFrame:Hide();
			end
			SubZoneTextFrame:SetScript("OnShow", NoSubZoneText);
		end

		-- Classic chat
		if LeaPlusLC["NoStickyChat"] == "On" then
			ChatTypeInfo['WHISPER']['sticky'] = 0
			ChatTypeInfo['BN_WHISPER']['sticky'] = 0
		end

		-- Enable arrow keys in chat
		if LeaPlusLC["UseArrowKeysInChat"] == "On" then
			for i = 1, NUM_CHAT_WINDOWS do
				local eb =  _G[format("%s%d%s", "ChatFrame", i, "EditBox")]
				_G[format("%s%d%s", "ChatFrame", i, "EditBox")]:SetAltArrowKeyMode(false)
			end
		end

		-- Hide class bar
		if LeaPlusLC["NoClassBar"] == "On" then
			StanceBarFrame:Hide();
			RegisterStateDriver(StanceBarFrame, "visibility", "hide")
		end
		
		-- Remove raid restrictions
		if LeaPlusLC["NoRaidRestrictions"] == "On" then
			SetAllowLowLevelRaid(1);
		end

		-- Hide gryphons
		if LeaPlusLC["NoGryphons"] == "On" then
			MainMenuBarLeftEndCap:Hide();
			MainMenuBarRightEndCap:Hide();
		end

		-- Disable chat fade
		if LeaPlusLC["NoChatFade"] == "On" then
			-- Disable fade for normal chat frames
			for i = 1, NUM_CHAT_WINDOWS do
				_G[('ChatFrame'..i)]:SetFading(false)
			end
			-- Disable fade for pet battle frame
			hooksecurefunc("FCF_OpenTemporaryWindow", function(chatType)
				if chatType == "PET_BATTLE_COMBAT_LOG" then
					local cf = FCF_GetCurrentChatFrame():GetName()
					_G[cf]:SetFading(false)
				end
			end)
		end

		-- Bag automation
		if LeaPlusLC["NoBagAutomation"] == "On" then
			local function GoAwayBags() return end
			OpenAllBags = GoAwayBags;
			CloseAllBags = GoAwayBags;
		end

		-- Set tooltip position
		if LeaPlusLC["TipModEnable"] == "On" then
			if (LeaPlusLC["TipAnchorToMouse"] == "On") then

				-- Disable fading for certain UI elements (such as player frame)
				GameTooltip.FadeOut = GameTooltip.Hide;

				-- Variables are scoped out of OnUpdate and given values during SetDefaultAnchor to save CPU power
				local realanc; -- Used to store anchor to cursor offset

				-- Set default anchor (for objects and UI elements)
				hooksecurefunc("GameTooltip_SetDefaultAnchor", function (tooltip, parent)
					realanc = LeaPlusLC["TipMouseAnchorTable"][LeaPlusLC["TipMouseAnchor"]]
					GameTooltip:SetOwner(UIParent, "ANCHOR_NONE");
					GameTooltip:SetPoint(LeaPlusLC["TipPosAnchor"], UIParent, LeaPlusLC["TipPosRelative"], LeaPlusLC["TipPosXOffset"], LeaPlusLC["TipPosYOffset"]);
				end)

				-- Hook tooltip update function to position and hide tooltips
				GameTooltip:HookScript("OnUpdate", function(frame, elapsed)
					if GetMouseFocus() == WorldFrame then
						if LeaPlusLC["TipHideCombat"] == "On" and (UnitAffectingCombat("player")) and not IsShiftKeyDown() then
							GameTooltip:SetAlpha(0);
						else
							GameTooltip:SetAlpha(LeaPlusLC["TipAlpha"]);
						end
						if UnitExists("mouseover") then
							if (frame.default) then
								local x, y = GetCursorPosition()
								local scale = frame:GetEffectiveScale()
								frame:ClearAllPoints() 
								frame:SetPoint(realanc, UIParent, "BOTTOMLEFT", (x/scale + LeaPlusLC["TipMouseOffsetX"]), (y/scale + LeaPlusLC["TipMouseOffsetY"]))
							end
						else
							if (GameTooltip:GetUnit("mouseover")) ~= nil then
								GameTooltip:SetOwner(UIParent, "ANCHOR_NONE");
								GameTooltip:SetPoint(LeaPlusLC["TipPosAnchor"], UIParent, LeaPlusLC["TipPosRelative"], LeaPlusLC["TipPosXOffset"], LeaPlusLC["TipPosYOffset"]);
							end
						end
					else
						local hasUnit, unit = GameTooltip:GetUnit()
						if hasUnit and not unit then
							GameTooltip:Hide();
						end
					end
				end)
			else
				-- Tooltip option without anchor to mouse (handled independently to save CPU power)
				hooksecurefunc("GameTooltip_SetDefaultAnchor", function (tooltip, parent)
					GameTooltip:SetOwner(UIParent, "ANCHOR_NONE");
					GameTooltip:SetPoint(LeaPlusLC["TipPosAnchor"], UIParent, LeaPlusLC["TipPosRelative"], LeaPlusLC["TipPosXOffset"], LeaPlusLC["TipPosYOffset"]);
				end)
			end
			
		end

		-- Use easy resizing
		if LeaPlusLC["UseEasyChatResizing"] == "On" then
			ChatFrame1Tab:HookScript("OnMouseDown", function(self,arg1)
				if arg1 == "LeftButton" then
					if select(8, GetChatWindowInfo(1)) then
						ChatFrame1:StartSizing("TOP")
					end
				end
			end)
			ChatFrame1Tab:SetScript("OnMouseUp", function(self,arg1)
				if arg1 == "LeftButton" then
					ChatFrame1:StopMovingOrSizing()
					FCF_SavePositionAndDimensions(ChatFrame1)
				end
			end)
		end

		-- Chat history size
		if LeaPlusLC["MaxChatHstory"] == "On" then
			for i = 1, NUM_CHAT_WINDOWS, 1 do
				if (_G["ChatFrame" .. i]:GetMaxLines() ~= 4096) then
					_G["ChatFrame" .. i]:SetMaxLines(4096);
				end
			end
		end

		-- Dungeon Finder buttons
		if LeaPlusLC["DungeonFinderButtons"] == "On" then

			-- Dungeon Finder time button
			local TimeBtn = CreateFrame("Button", nil, LFDQueueFrame) 
			TimeBtn:SetWidth(30)
			TimeBtn:SetHeight(30)
			TimeBtn:SetPoint("BOTTOMLEFT", 08, 286)
			TimeBtn:RegisterForClicks("AnyUp") 

			TimeBtn:SetNormalTexture([[Interface/LFGFRAME/BattlenetWorking23]])
			TimeBtn:SetHighlightTexture([[Interface/LFGFRAME/BattlenetWorking23]])
			TimeBtn:SetPushedTexture([[Interface/LFGFRAME/BattlenetWorking23]])

			TimeBtn.tiptext = "Toggles showing your random dungeon cooldown."
			TimeBtn:SetScript("OnEnter", LeaPlusLC.ShowFacetip)
			TimeBtn:SetScript("OnLeave", function(self)
				GameTooltip:Hide()
			end)

			TimeBtn:SetScript("OnClick", function() 
				if LFDQueueFramePartyBackfillNoBackfillButton:IsShown() then
					LFDQueueFramePartyBackfillNoBackfillButton:Click();
				end
				if LFDQueueFrameCooldownFrame:IsShown() then
					LFDQueueFrameCooldownFrame:Hide();
				else
					LFDQueueFrameCooldownFrame:Show();
				end
			end)

			-- Create checkbox for removing target markers
			local harassbox = CreateFrame('CheckButton', nil, LFDQueueFrame, "OptionsCheckButtonTemplate")
			harassbox:SetText("")
			harassbox:SetHitRectInsets(0, 0, 0, 0);
			harassbox:SetSize(24, 24)
			harassbox:SetPoint("BOTTOMLEFT", 46, 288)

			-- Click the checkbox
			harassbox:SetScript('OnClick', function()
				if harassbox:GetChecked() then
					SetRaidTargetIcon("player", 0);
					harassbox:RegisterEvent("RAID_TARGET_UPDATE");
				else
					harassbox:UnregisterEvent("RAID_TARGET_UPDATE");
				end
			end)

			-- Hide target markers
			harassbox:SetScript("OnEvent", function()
				SetRaidTargetIcon("player", 0);
			end)

			-- Show tooltip
			harassbox.tiptext = "If checked, target markers placed on you will be automatically removed.\n\nYou can use this checkbox if someone in your dungeon group is behaving inappropriately.\n\nThe setting of this checkbox is not saved between login sessions."
			harassbox:SetScript("OnEnter", LeaPlusLC.ShowFacetip)
			harassbox:SetScript("OnLeave", function(self)
				GameTooltip:Hide()
			end)

		end

		-- Quest levels
		if LeaPlusLC["ShowQuestLevels"] == "On" then

			-- Create table for tags (only needed if quest type tags are used)
			local QuestTags = {Elite = "+", Group = "G", Dungeon = "D", Raid = "R", PvP = "P", Daily = "!", Heroic = "H", Repeatable = "?"}

			-- Show quest levels
			local function QuestFunc()

				local buttons = QuestLogScrollFrame.buttons
				local QuestButtons = #buttons
				local QuestScrollOffset = HybridScrollFrame_GetOffset(QuestLogScrollFrame)
				local QuestEntries, void = GetNumQuestLogEntries()

				-- Go through quest log
				for i = 1, QuestButtons do
					local QuestIndex = i + QuestScrollOffset
					local QuestTitle = buttons[i]
					if QuestIndex <= QuestEntries then

						local title, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily = GetQuestLogTitle(QuestIndex)

						-- Add quest type
						if not isHeader or title then
							if not suggestedGroup or suggestedGroup == 0 then suggestedGroup = nil end
							title = string.format("[%s%s%s%s] %s", level, questTag and QuestTags[questTag] or "", isDaily and QuestTags.Daily or "",suggestedGroup or "", title), questTag, isDaily, isComplete
						end

						-- Show quest title with level
						if not isHeader then
							QuestTitle:SetText(title)
							QuestLogTitleButton_Resize(QuestTitle)
						end

					end
				end

			end

			hooksecurefunc('QuestLog_Update', QuestFunc)
			QuestLogScrollFrameScrollBar:HookScript('OnValueChanged', QuestFunc)

		end

		-- Error text
		if LeaPlusLC["HideErrorFrameText"] == "On" then
	
			local OrigErrHandler = UIErrorsFrame:GetScript('OnEvent')

			--	Error message events
			UIErrorsFrame:SetScript('OnEvent', function (self, event, err, ...)

				-- Handle error messages
				if event == "UI_ERROR_MESSAGE" then
					if LeaPlusLC["ShowErrorsFlag"] == 1 then
						if 	err == ERR_INV_FULL or
							err == ERR_QUEST_LOG_FULL or
							err == ERR_RAID_GROUP_ONLY	or
							err == ERR_PARTY_LFG_BOOT_LIMIT or
							err == ERR_PARTY_LFG_BOOT_DUNGEON_COMPLETE or
							err == ERR_PARTY_LFG_BOOT_IN_COMBAT or
							err == ERR_PARTY_LFG_BOOT_IN_PROGRESS or
							err == ERR_PARTY_LFG_BOOT_LOOT_ROLLS or
							err == ERR_PARTY_LFG_TELEPORT_IN_COMBAT or
							err == ERR_PET_SPELL_DEAD or
							err == ERR_PLAYER_DEAD or
							err:find(format(ERR_PARTY_LFG_BOOT_NOT_ELIGIBLE_S, ".+")) then
							return OrigErrHandler(self, event, err, ...) 
						end
					else
						return OrigErrHandler(self, event, err, ...) 
					end
				end

				-- Handle information messages
				if event == 'UI_INFO_MESSAGE'  then
					if LeaPlusLC["ShowQuestUpdates"] == "On" then
						return OrigErrHandler(self, event, err, ...)
					end
				end

			end)

		end

		-- Character sheet checkboxes
		if LeaPlusLC["ShowVanityButtons"] == "On" then

			-- Create checkboxs
			local hbox = CreateFrame('CheckButton', nil, CharacterModelFrame, "OptionsCheckButtonTemplate")
			hbox:SetSize(24, 24)
			hbox.f = hbox:CreateFontString(nil, 'OVERLAY', "GameFontNormal")
			hbox.f:SetPoint("LEFT", 24, 0)

			local cbox = CreateFrame('CheckButton', nil, CharacterModelFrame, "OptionsCheckButtonTemplate")
			cbox:SetSize(24, 24)
			cbox.f = cbox:CreateFontString(nil, 'OVERLAY', "GameFontNormal")
			cbox.f:SetPoint("LEFT", 24, 0)

			-- Refresh checkbox state while controls are shown
			local htimer = 0
			hbox:SetScript('OnUpdate', function(self, elapsed)
				htimer = htimer + elapsed;
				while (htimer > 0.05) do
					hbox:SetChecked(ShowingHelm())
					cbox:SetChecked(ShowingCloak())
					htimer = 0;
				end
			end)

			-- Positioning functions for dual layout
			local function SetVanityPlacement()
				if LeaPlusLC["ShowVanityInFrame"] == "On" then
					hbox:ClearAllPoints();
					hbox:SetPoint("TOPLEFT", 166, -326)
					hbox:SetHitRectInsets(0, -10, 0, 0);
					hbox.f:SetText("H");
					cbox:ClearAllPoints();
					cbox:SetPoint("TOPLEFT", 206, -326)
					cbox:SetHitRectInsets(0, -10, 0, 0);
					cbox.f:SetText("C");
				else
					hbox:ClearAllPoints();
					hbox:SetPoint("TOPLEFT", 4, -298)
					hbox:SetHitRectInsets(0, -32, 0, 0);
					hbox.f:SetText("Helm");
					cbox:ClearAllPoints();
					cbox:SetPoint("TOPLEFT", 164, -298)
					cbox:SetHitRectInsets(0, -36, 0, 0);
					cbox.f:SetText("Cloak");
				end
				hbox:SetAlpha(0.7);
				cbox:SetAlpha(0.7);
			end

			-- Click handlers
			hbox:SetScript('OnClick', function(self, btn)
				ShowHelm(hbox:GetChecked())
			end)

			cbox:SetScript('OnClick', function(self, btn)
				ShowCloak(cbox:GetChecked())
			end)

			hbox:SetScript('OnMouseDown', function(self, btn)
				if btn == "RightButton" and IsShiftKeyDown() then
					if LeaPlusLC["ShowVanityInFrame"] == "On" then LeaPlusLC["ShowVanityInFrame"] = "Off" else LeaPlusLC["ShowVanityInFrame"] = "On" end
					SetVanityPlacement();
				end
			end)

			cbox:SetScript('OnMouseDown', function(self, btn)
				if btn == "RightButton" and IsShiftKeyDown() then
					if LeaPlusLC["ShowVanityInFrame"] == "On" then LeaPlusLC["ShowVanityInFrame"] = "Off" else LeaPlusLC["ShowVanityInFrame"] = "On" end
					SetVanityPlacement();
				end
			end)

			-- Unusable while character is dead
			CharacterModelFrame:HookScript("OnShow",function()
				if UnitIsDeadOrGhost("player") then
					LeaPlusLC:LockItem(hbox,true)
					LeaPlusLC:LockItem(cbox,true)
				else
					LeaPlusLC:LockItem(hbox,false)
					LeaPlusLC:LockItem(cbox,false)
					SetVanityPlacement();
				end
			end)

		end

		-- Show hide tabard button on dressup windows
		if LeaPlusLC["ShowDressTab"] == "On" then

			-- Add button to main dressup frame
			LeaPlusLC:CreateButton("DressUpTabBtn", DressUpFrame, "Hide Tabard", "BOTTOMLEFT", 26, 79, 116, 22,"")
			LeaPlusCB["DressUpTabBtn"]:SetScript("OnClick", function()
				DressUpModel:UndressSlot(19)
			end)

			-- Add button to dressup frame
			LeaPlusLC:CreateButton("DressUpSideBtn", SideDressUpFrame, "Hide Tabard", "BOTTOMLEFT", 34, 20, 116, 22,"")
			LeaPlusCB["DressUpSideBtn"]:SetFrameStrata("HIGH");
			LeaPlusCB["DressUpSideBtn"]:SetScript("OnClick", function()
				SideDressUpModel:UndressSlot(19)
			end)

		end

		-- Honor shown in tooltip
		if LeaPlusLC["ShowHonorStat"] == "On" then
			PVPFrameCurrency:HookScript("OnEnter", function()
				GameTooltip:AddLine("Lifetime Honorable Kills: |cffffffff" .. GetStatistic(588))
				GameTooltip:Show();
			end)
		end

		----------------------------------------------------------------------
		--	Minimap button
		----------------------------------------------------------------------

		if LeaPlusLC["ShowMinimapIcon"] == "On" then
	
			-- Create minimap button
			local minibtn = CreateFrame("Button", "LeaPlusMapBtn", Minimap)
			LeaPlusCB["MiniMapButton"] = minibtn
			minibtn:SetSize(32,32)
			minibtn:SetMovable(true)
			minibtn:SetFrameStrata("MEDIUM")
			minibtn:SetNormalTexture("Interface/COMMON/Indicator-Green.png")
			minibtn:SetPushedTexture("Interface/COMMON/Indicator-Green.png")
			minibtn:SetHighlightTexture("Interface/COMMON/Indicator-Green.png")
			minibtn:RegisterForClicks("AnyUp")

			local function UpdateMapBtn()
				local Xpoa, Ypoa = GetCursorPosition()
				local Xmin, Ymin = Minimap:GetLeft(), Minimap:GetBottom()
				Xpoa = Xmin - Xpoa / Minimap:GetEffectiveScale() + 70
				Ypoa = Ypoa / Minimap:GetEffectiveScale() - Ymin - 70
				LeaPlusLC["MinimapIconPos"] = math.deg(math.atan2(Ypoa, Xpoa))
				minibtn:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", 52 - (80 * cos(LeaPlusLC["MinimapIconPos"])), (80 * sin(LeaPlusLC["MinimapIconPos"])) - 52)
			end

			-- Control movement
			minibtn:RegisterForDrag("LeftButton")
			minibtn:SetScript("OnDragStart", function()
				minibtn:StartMoving()
				minibtn:SetScript("OnUpdate", UpdateMapBtn)
			end)

			minibtn:SetScript("OnDragStop", function ()
				minibtn:StopMovingOrSizing();
				minibtn:SetUserPlaced(false);
				minibtn:SetScript("OnUpdate", nil)
				UpdateMapBtn();
			end)

			-- Ensure position is a valid number
			if type(LeaPlusLC["MinimapIconPos"]) ~= "number" then
				LeaPlusLC["MinimapIconPos"] = -65
			end

			if LeaPlusLC["MinimapIconPos"] < -180 or LeaPlusLC["MinimapIconPos"] > 180 then 
				LeaPlusLC["MinimapIconPos"] = -65
			end

			-- Set position
			minibtn:ClearAllPoints();
			minibtn:SetPoint("TOPLEFT","Minimap","TOPLEFT",52-(80*cos(LeaPlusLC["MinimapIconPos"])),(80*sin(LeaPlusLC["MinimapIconPos"]))-52)

			-- Control clicks
			minibtn:SetScript("OnClick", function(self,arg1)
				if InterfaceOptionsFrame:IsShown() or VideoOptionsFrame:IsShown() then return end

				-- Left button down
				if arg1 == "LeftButton" then

					-- Shift key modifier toggles the music
					if IsShiftKeyDown() then
						Sound_ToggleMusic();
						if GetCVar("Sound_EnableMusic") == "1" then
							LeaPlusLC:Print("Music enabled.")
						else
							LeaPlusLC:Print("Music disabled.")
						end
						return
					end

					-- No modifier key toggles the options panel
					if LeaPlusLC["PageF"]:IsShown() then
						LeaPlusLC:HideFrames();
					else
						LeaPlusLC:HideFrames();
						LeaPlusLC["PageF"]:Show();
					end
					if LeaPlusLC["Page"..LeaPlusLC["LeaStartPage"]] and LeaPlusLC["OpenPlusAtHome"] == "Off" then
						 LeaPlusLC["Page"..LeaPlusLC["LeaStartPage"]]:Show()
					else
						LeaPlusLC["Page0"]:Show();
					end
				end

				-- Right button down
				if arg1 == "RightButton" then

					-- Shift key modifier toggles coordinates
					if IsShiftKeyDown() then
						if LeaPlusLC["StaticCoordsEn"] == "On" then
							if LeaPlusLC["StaticCoords"] == "On" then
								LeaPlusLC["StaticCoords"] = "Off";
							else
								LeaPlusLC["StaticCoords"] = "On";
								SetMapToCurrentZone();
							end
							-- Run the coordinates refresh function
							LeaPlusLC:RefreshStaticCoords();
							-- Update side panel checkbox if it's showning
							if LeaPlusCB["StaticCoords"]:IsShown() then
								LeaPlusCB["StaticCoords"]:Hide();
								LeaPlusCB["StaticCoords"]:Show();
							end
						end
						return
					end

					-- No modifier key toggles error text
					if LeaPlusLC["HideErrorFrameText"] == "On" then
						if LeaPlusLC["ShowErrorsFlag"] == 1 then 
							LeaPlusLC["ShowErrorsFlag"] = 0
							minibtn:SetNormalTexture("Interface/COMMON/Indicator-Red.png")
							minibtn:SetPushedTexture("Interface/COMMON/Indicator-Red.png")
							minibtn:SetHighlightTexture("Interface/COMMON/Indicator-Red.png")
						else
							LeaPlusLC["ShowErrorsFlag"] = 1
							minibtn:SetNormalTexture("Interface/COMMON/Indicator-Green.png")
							minibtn:SetPushedTexture("Interface/COMMON/Indicator-Green.png")
							minibtn:SetHighlightTexture("Interface/COMMON/Indicator-Green.png")
						end
					end
				end

				-- Middle button modifier
				if arg1 == "MiddleButton" then

					-- No modifier key toggles Recount
					if (IsAddOnLoaded("Recount")) then
						if Recount_MainWindow:IsShown() then
							Recount.MainWindow:Hide();
						else
							Recount.MainWindow:Show();
							Recount:RefreshMainWindow();
						end
					end
				end
			end)

		end

		----------------------------------------------------------------------
		-- L22: Tooltip customisation
		----------------------------------------------------------------------

		if LeaPlusLC["TipModEnable"] == "On" then

			local LeaPlusTT = {}

			-- Create local versions of globals
			local tiplevelglobal = strtrim(strtrim(string.gsub(TOOLTIP_UNIT_LEVEL, "%%s", "")))

			-- Tooltip
			LeaPlusTT["LpTipColorBlind"] = GetCVar("colorblindMode")

			-- 	Create drag frame
			local TipDrag = CreateFrame("Frame", nil, UIParent)
			TipDrag:SetMovable(true)
			TipDrag:EnableMouse(true)
			TipDrag:RegisterForDrag("LeftButton")
			TipDrag:SetToplevel(true);
			TipDrag:SetClampedToScreen();
			TipDrag:SetSize(130, 64);
			TipDrag:Hide();
			TipDrag:SetFrameStrata("TOOLTIP")
			TipDrag:SetBackdropColor(0.0, 0.5, 1.0);
			TipDrag:SetBackdrop({ 
				edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
				tile = false, tileSize = 0, edgeSize = 16,
				insets = { left = 0, right = 0, top = 0, bottom = 0 }});

			-- Show text in drag frame
			TipDrag.f = TipDrag:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
			TipDrag.f:SetPoint('TOPLEFT', 16, -16)
			TipDrag.f:SetText("Tooltip")

			-- Create texture
			TipDrag.t = TipDrag:CreateTexture();
			TipDrag.t:SetAllPoints();
			TipDrag.t:SetTexture(0.0, 0.5, 1.0, 0.5);
			TipDrag.t:SetAlpha(0.5);

			---------------------------------------------------------------------------------------------------------
			-- Tooltip movement settings
			---------------------------------------------------------------------------------------------------------

			-- Create tooltip customisation side panel
			local SideTip = LeaPlusLC:CreateSidePanel("Tooltip", 164, 100)

			-- Create save button
			LeaPlusLC:CreateButton("SaveTipBtn", SideTip, "Save", "BOTTOMLEFT", 10, 10, 70, 25, "")
			LeaPlusCB["SaveTipBtn"]:SetScript("OnClick", function()
				SideTip:Hide();
				if TipDrag:IsShown() then
					TipDrag:Hide();
				end
				LeaPlusLC["PageF"]:Show();
				LeaPlusLC["Page5"]:Show();
				return
			end)

			-- Create reset button
			LeaPlusLC:CreateButton("ResetTipBtn", SideTip, "Reset", "BOTTOMLEFT", 80, 10, 70, 25, "")
			LeaPlusCB["ResetTipBtn"]:SetScript("OnClick", function()
				LeaPlusLC["TipPosXOffset"] = "-13";
				LeaPlusLC["TipPosYOffset"] = "94";
				LeaPlusLC["TipPosAnchor"] = "BOTTOMRIGHT";
				LeaPlusLC["TipPosRelative"] = "BOTTOMRIGHT";	
				TipDrag:ClearAllPoints();
				TipDrag:SetPoint(LeaPlusLC["TipPosAnchor"], UIParent, LeaPlusLC["TipPosRelative"], LeaPlusLC["TipPosXOffset"], LeaPlusLC["TipPosYOffset"]);
			end)

			-- Control movement functions
			TipDrag:SetScript("OnDragStart", TipDrag.StartMoving)
			TipDrag:SetScript("OnDragStop", function ()
				TipDrag:StopMovingOrSizing();
				LeaPlusLC["TipPosAnchor"], LeaPlusLC["LpTipRelaAnchor"], LeaPlusLC["TipPosRelative"], LeaPlusLC["TipPosXOffset"], LeaPlusLC["TipPosYOffset"] = TipDrag:GetPoint()
			end)

			--	Move the tooltip
			LeaPlusCB["MoveTooltipButton"]:SetScript("OnClick", function()
				LeaPlusLC:HideFrames();
				SideTip:Show();
				if TipDrag:IsShown() then
					SideTip:Hide();
					TipDrag:Hide();
					return
				else
					TipDrag:Show();
				end

				-- Set scale
				if LeaPlusLC["TipScaleCheck"] == "On" then
					TipDrag:SetScale(LeaPlusLC["LeaPlusTipSize"])
				else
					TipDrag:SetScale(1.00)
				end

				-- Set position of the drag frame
				TipDrag:ClearAllPoints();
				TipDrag:SetPoint(LeaPlusLC["TipPosAnchor"], UIParent, LeaPlusLC["TipPosRelative"], LeaPlusLC["TipPosXOffset"], LeaPlusLC["TipPosYOffset"]);
			end)
					
			---------------------------------------------------------------------------------------------------------
			-- Tooltip scale settings
			---------------------------------------------------------------------------------------------------------

			-- Function to set the tooltip scale
			local function SetTipScale()
				-- Only runs if tooltip customisation is enabled (after reload)
				if LeaPlusLC["TipModEnable"] == LeaPlusDB["TipModEnable"] then
					if LeaPlusLC["TipScaleCheck"] == "On" and LeaPlusLC["TipModEnable"] == "On" then
						GameTooltip:SetScale(LeaPlusLC["LeaPlusTipSize"])
					elseif LeaPlusLC["TipScaleCheck"] == "Off" or LeaPlusLC["TipModEnable"] == "Off" then 
						GameTooltip:SetScale("1.00")
					end
					return
				else
					GameTooltip:SetScale("1.00")
				end
			end

			-- Set tooltip scale on startp
			SetTipScale();

			-- Set tooltip scale when slider or checkbox changes
			LeaPlusCB["LeaPlusTipSize"]:HookScript("OnValueChanged", SetTipScale);
			LeaPlusCB["TipScaleCheck"]:HookScript("OnClick", SetTipScale);

			---------------------------------------------------------------------------------------------------------
			-- Anchor to Mouse Settings
			---------------------------------------------------------------------------------------------------------

			-- Create anchor to mouse pointer settings frame
			local SideAnchor = LeaPlusLC:CreateSidePanel("Anchor to Mouse", 164, 360)

			-- Create save button
			LeaPlusLC:CreateButton("SaveTipMouseBtn", SideAnchor, "Save", "BOTTOMLEFT", 10, 10, 70, 25, "")
			LeaPlusCB["SaveTipMouseBtn"]:SetScript("OnClick", function()
				SideAnchor:Hide();
				LeaPlusLC["PageF"]:Show();
				LeaPlusLC["Page5"]:Show();
				return
			end)

			-- Create reset button
			LeaPlusLC:CreateButton("ResetTipMouseBtn", SideAnchor, "Reset", "BOTTOMLEFT", 80, 10, 70, 25, "")
			LeaPlusCB["ResetTipMouseBtn"]:SetScript("OnClick", function()
				LeaPlusLC["TipMouseAnchor"] = 1;
				LeaPlusLC["TipMouseOffsetX"] = "0";
				LeaPlusLC["TipMouseOffsetY"] = "0";
				LeaPlusLC["TipAlpha"] = 1.0;
				LeaPlusLC["TipHideCombat"] = "Off";
				SideAnchor:Hide(); SideAnchor:Show();
			end)

			LeaPlusLC:CreateDropDown("TipMouseAnchor", "Anchor", SideAnchor, 146, "TOPLEFT", 10, -100, {"BOTTOMLEFT", "LEFT", "TOPLEFT", "TOP", "TOPRIGHT", "RIGHT", "BOTTOMRIGHT", "BOTTOM", "CENTER"}, "")

			-- Create slider controls
			LeaPlusLC:MakeTx(SideAnchor, "X Offset", 10, -120)
			LeaPlusLC:MakeSL(SideAnchor, "TipMouseOffsetX", "", -400, 400, 5, 10, -140, "%.0f")
			LeaPlusLC:MakeTx(SideAnchor, "Y Offset", 10, -170)
			LeaPlusLC:MakeSL(SideAnchor, "TipMouseOffsetY", "", -400, 400, 5, 10, -190, "%.0f")
			LeaPlusLC:MakeTx(SideAnchor, "Alpha", 10, -220)
			LeaPlusLC:MakeSL(SideAnchor, "TipAlpha", "", 0, 1, 0.1, 10, -240, "%.1f")
			LeaPlusLC:MakeCB(SideAnchor, "TipHideCombat", "Hide tips in combat", 10, -280, "")

			-- Modify the anchor to mouse pointer settings
			LeaPlusCB["ModTipMouseBtn"]:SetScript("OnClick", function()
				LeaPlusLC:HideFrames();
				SideAnchor:Show();
			end)

			---------------------------------------------------------------------------------------------------------
			-- Other tooltip code
			---------------------------------------------------------------------------------------------------------

			-- Colorblind setting change
			TipDrag:RegisterEvent("CVAR_UPDATE");
			TipDrag:SetScript("OnEvent", function(self,event,arg1,arg2)
				if (arg1 == "USE_COLORBLIND_MODE") then
					LeaPlusTT["LpTipColorBlind"] = arg2;
				end
			end)

			-- 	Replace line in the tooltip
			local function repline(line,text)
				_G["GameTooltipTextLeft"..line]:SetText(text)
			end

			--	Show tooltip
			local function ShowTip(update)

				-- Get unit information
				if GetMouseFocus() == WorldFrame then
					LeaPlusTT["LpTipUnitTarget"] = "mouseover"
				else
					LeaPlusTT["LpTipNameHelper"], LeaPlusTT["LpTipUnitTarget"] = GameTooltip:GetUnit()
					if not (LeaPlusTT["LpTipUnitTarget"]) then return end
				end

				-- If something is wrong, get the hell out of here!
				if (UnitReaction(LeaPlusTT["LpTipUnitTarget"],"player")) == nil then return end

				-- Setup variables
				local TipUnitName, TipUnitRealm = UnitName(LeaPlusTT["LpTipUnitTarget"])
				local TipIsPlayer = UnitIsPlayer(LeaPlusTT["LpTipUnitTarget"])
				local TipUnitLevel = UnitLevel(LeaPlusTT["LpTipUnitTarget"])
				local void,TipUnitClass = UnitClassBase(LeaPlusTT["LpTipUnitTarget"])

				-- Get guild information
				if (TipIsPlayer) then
					if (GetGuildInfo(LeaPlusTT["LpTipUnitTarget"])) then
						if LeaPlusTT["LpTipColorBlind"] == "1" then
							LeaPlusTT["LpTipGuildLines"], LeaPlusTT["LpTipInfomation"] = 2, 4
						else
							LeaPlusTT["LpTipGuildLines"], LeaPlusTT["LpTipInfomation"] = 2, 3
						end
						LeaPlusTT["LpTipGuildNames"], LeaPlusTT["LpTipGuildsRank"] = GetGuildInfo(LeaPlusTT["LpTipUnitTarget"])
						LeaPlusTT["LpTipMyOwnGuild"], void = GetGuildInfo("player")
					else
						LeaPlusTT["LpTipGuildNames"] = nil
						if LeaPlusTT["LpTipColorBlind"] == "1" then
							LeaPlusTT["LpTipGuildLines"], LeaPlusTT["LpTipInfomation"] = 0,3
						else
							LeaPlusTT["LpTipGuildLines"], LeaPlusTT["LpTipInfomation"] = 0,2
						end
					end
				end

				-- Sort out the class color
				if (TipUnitClass) then
					LeaPlusTT["LpTipPlayGender"] = (UnitSex(LeaPlusTT["LpTipUnitTarget"]))
					if LeaPlusTT["LpTipPlayGender"] == 2 then
						LeaPlusTT["LpTipUnitsClass"] = LOCALIZED_CLASS_NAMES_MALE[TipUnitClass]
					else
						LeaPlusTT["LpTipUnitsClass"] = LOCALIZED_CLASS_NAMES_FEMALE[TipUnitClass]
					end
					LeaPlusTT["LpTipPureClassC"] = RAID_CLASS_COLORS[TipUnitClass]
					LeaPlusTT["LpTipClassColor"] = "|cff" .. string.format('%02x%02x%02x',LeaPlusTT["LpTipPureClassC"].r * 255, LeaPlusTT["LpTipPureClassC"].g * 255, LeaPlusTT["LpTipPureClassC"].b * 255)
				end
				----------------------------------------------------------------------
				-- Name line (name and realm for friendly or higher players, pets and npcs)
				if ((TipIsPlayer) or (UnitPlayerControlled(LeaPlusTT["LpTipUnitTarget"]))) or (UnitReaction(LeaPlusTT["LpTipUnitTarget"],"player")) > 4 then

					-- If it's a player show name in class color
					if (TipIsPlayer) then
						LeaPlusTT["TipNameColor"] = LeaPlusTT["LpTipClassColor"]
					else
						-- If not, set to green or blue depending on PvP status
						if (UnitIsPVP(LeaPlusTT["LpTipUnitTarget"])) then
							LeaPlusTT["TipNameColor"] = "|cff00ff00"
						else
							LeaPlusTT["TipNameColor"] = "|cff00aaff"
						end
					end

					-- Show title
					if LeaPlusLC["TipShowTitle"] == "On" then
						LeaPlusTT["TipNameData"] = UnitPVPName(LeaPlusTT["LpTipUnitTarget"])
					else
						LeaPlusTT["TipNameData"] = TipUnitName
					end

					-- Show realm
					if not (TipUnitRealm == nil) and LeaPlusLC["TipShowRealm"] == "On" then
						LeaPlusTT["TipNameData"] = LeaPlusTT["TipNameData"] .. " - " .. TipUnitRealm
					end

					-- Show dead units in grey
					if UnitIsDeadOrGhost(LeaPlusTT["LpTipUnitTarget"]) then
						LeaPlusTT["TipNameColor"] = "|c88888888"
					end

					-- Show name line in color (alive) or grey (dead)
					repline(1, LeaPlusTT["TipNameColor"] .. LeaPlusTT["TipNameData"] .. "|cffffffff|r")
					
				elseif UnitIsDeadOrGhost(LeaPlusTT["LpTipUnitTarget"]) then

					-- Show grey name for other dead units
					repline(1,"|c88888888" .. _G["GameTooltipTextLeft1"]:GetText() .. "|cffffffff|r")

				return end
				----------------------------------------------------------------------
				-- Guild line
				if (TipIsPlayer) and not (LeaPlusTT["LpTipGuildNames"] == nil) then
					
					-- Show guild line (with rank if enabled)
					if LeaPlusLC["TipShowRank"] == "On" then
						if UnitIsInMyGuild(LeaPlusTT["LpTipUnitTarget"]) then
							repline (LeaPlusTT["LpTipGuildLines"], "|c00aaaaff" .. LeaPlusTT["LpTipGuildNames"] .. " - " .. LeaPlusTT["LpTipGuildsRank"] .. "|r")
						else
							repline (LeaPlusTT["LpTipGuildLines"], "|c00aaaaff" .. LeaPlusTT["LpTipGuildNames"] .. "|cffffffff|r")
						end
					else
						repline (LeaPlusTT["LpTipGuildLines"], "|c00aaaaff" .. LeaPlusTT["LpTipGuildNames"] .. "|cffffffff|r")
					end
				end
				----------------------------------------------------------------------
				-- Information line (level, class, race)
				if (TipIsPlayer) then

					-- Show level
					if (UnitReaction(LeaPlusTT["LpTipUnitTarget"],"player")) < 5 then
						if TipUnitLevel == -1 then
							LeaPlusTT["LpTipInfomaData"] = ("|cffff3333Level ??|cffffffff")
						else
							LeaPlusTT["LpTipLevelColor"] = (GetQuestDifficultyColor(UnitLevel(LeaPlusTT["LpTipUnitTarget"])))
							LeaPlusTT["LpTipLevelColor"] = string.format('%02x%02x%02x', LeaPlusTT["LpTipLevelColor"].r * 255, LeaPlusTT["LpTipLevelColor"].g * 255, LeaPlusTT["LpTipLevelColor"].b * 255)
							LeaPlusTT["LpTipInfomaData"] = ("|cff" .. LeaPlusTT["LpTipLevelColor"] .. tiplevelglobal .. " " .. TipUnitLevel .. "|cffffffff")
						end
					else
						LeaPlusTT["LpTipInfomaData"] = tiplevelglobal .. " " .. TipUnitLevel
					end

					-- Show race
					if (LeaPlusLC["TipShowRace"] == "On") then
						LeaPlusTT["LpTipInfomaData"] = LeaPlusTT["LpTipInfomaData"] .. " " .. UnitRace(LeaPlusTT["LpTipUnitTarget"])
					end

					-- Show class
					if (LeaPlusLC["TipShowClass"] == "On") then
						LeaPlusTT["LpTipInfomaData"] = LeaPlusTT["LpTipInfomaData"] .. " " .. LeaPlusTT["LpTipClassColor"] .. LeaPlusTT["LpTipUnitsClass"]
					end

					-- Show information line
					repline (LeaPlusTT["LpTipInfomation"], LeaPlusTT["LpTipInfomaData"] .. "|cffffffff|r")

				end
				----------------------------------------------------------------------
				-- Mob name in brighter red (alive) and steel blue (tapped)
				if not (TipIsPlayer) and (UnitReaction(LeaPlusTT["LpTipUnitTarget"],"player")) < 4 and not (UnitPlayerControlled(LeaPlusTT["LpTipUnitTarget"])) then
					if (UnitIsTapped(LeaPlusTT["LpTipUnitTarget"]) and not (UnitIsTappedByPlayer(LeaPlusTT["LpTipUnitTarget"]))) then
						LeaPlusTT["TipNameData"] = "|c8888bbbb" .. TipUnitName .. "|r"
					else
						LeaPlusTT["TipNameData"] = "|cffff3333" .. TipUnitName .. "|r"
					end
					repline(1,LeaPlusTT["TipNameData"])
				end
				----------------------------------------------------------------------
				-- Mob level in color (neutral or lower)
				if not (TipIsPlayer) and (UnitReaction(LeaPlusTT["LpTipUnitTarget"],"player")) < 5 and not (UnitPlayerControlled(LeaPlusTT["LpTipUnitTarget"])) then

					-- Level ?? mob
					if TipUnitLevel == -1 then
						LeaPlusTT["LpTipInfomaData"] = "|cffff3333Level ??|cffffffff "

					-- Mobs within level range
					else
						LeaPlusTT["LpTipMyMobColor"] = (GetQuestDifficultyColor(UnitLevel(LeaPlusTT["LpTipUnitTarget"])))
						LeaPlusTT["LpTipMyMobColor"] = string.format('%02x%02x%02x', LeaPlusTT["LpTipMyMobColor"].r * 255, LeaPlusTT["LpTipMyMobColor"].g * 255, LeaPlusTT["LpTipMyMobColor"].b * 255)
						LeaPlusTT["LpTipInfomaData"] = "|cff" .. LeaPlusTT["LpTipMyMobColor"] .. tiplevelglobal .. " " .. TipUnitLevel .. "|cffffffff "
					end

					-- Find the line with level information on it
					if (_G["GameTooltipTextLeft2"]:GetText()) == nil then
						LeaPlusTT["LpTipMobInfLine"] = 2 
					else
						if not (strsplit(" ", (_G["GameTooltipTextLeft2"]:GetText()),2) == tiplevelglobal) then LeaPlusTT["LpTipMobInfLine"] = 3 else LeaPlusTT["LpTipMobInfLine"] = 2 end
					end

					-- Show creature type and classification (find a happy place!)
					local LeaLeaTipOptMobType = UnitCreatureType(LeaPlusTT["LpTipUnitTarget"])
					if LeaPlusLC["TipShowMobType"] == "On" and (LeaLeaTipOptMobType) and not (LeaLeaTipOptMobType == "Not specified") then
						LeaPlusTT["LpTipInfomaData"] = LeaPlusTT["LpTipInfomaData"] .. "|cffffffff" .. LeaLeaTipOptMobType .. "|cffffffff "
					end

					-- Sort out the special mobs
					local LeaPlusTipElite = UnitClassification(LeaPlusTT["LpTipUnitTarget"])
					if (LeaPlusTipElite) then
						if LeaPlusTipElite == "elite" then LeaPlusTipElite = "(Elite)"
						elseif LeaPlusTipElite == "rare" then LeaPlusTipElite = "|c00e066ff(Rare)"
						elseif LeaPlusTipElite == "rareelite" then LeaPlusTipElite = "|c00e066ff(Rare Elite)"
						elseif LeaPlusTipElite == "worldboss" then LeaPlusTipElite = "(Boss)"
						else LeaPlusTipElite = nil end
						if (LeaPlusTipElite) then
							LeaPlusTT["LpTipInfomaData"] = LeaPlusTT["LpTipInfomaData"] .. LeaPlusTipElite
						end
					end
					repline(LeaPlusTT["LpTipMobInfLine"], LeaPlusTT["LpTipInfomaData"])
				end
				----------------------------------------------------------------------
				-- Backdrops
				local LeaPlusTipFaction = UnitFactionGroup(LeaPlusTT["LpTipUnitTarget"])
				if UnitCanAttack("player",LeaPlusTT["LpTipUnitTarget"]) and not (UnitIsDeadOrGhost(LeaPlusTT["LpTipUnitTarget"])) and not (LeaPlusTipFaction == nil) and not (LeaPlusTipFaction == UnitFactionGroup("player")) then
					if (TipIsPlayer) and LeaPlusLC["TipBackHostile"] == "On" then
						GameTooltip:SetBackdropColor(LeaPlusTT["LpTipPureClassC"].r, LeaPlusTT["LpTipPureClassC"].g, LeaPlusTT["LpTipPureClassC"].b);
					else
						if LeaPlusLC["TipBackSimple"] == "On" then
							GameTooltip:SetBackdropColor(0.5, 0.0, 0.0);
						else
							GameTooltip:SetBackdropColor(0.0, 0.0, 0.0);
						end
					end
				else
					if (TipIsPlayer) and LeaPlusLC["TipBackFriend"] == "On" then
						GameTooltip:SetBackdropColor(LeaPlusTT["LpTipPureClassC"].r, LeaPlusTT["LpTipPureClassC"].g, LeaPlusTT["LpTipPureClassC"].b);
					else
						if LeaPlusLC["TipBackSimple"] == "On" then
							GameTooltip:SetBackdropColor(0.0, 0.0, 0.5);
						else
							GameTooltip:SetBackdropColor(0.0, 0.0, 0.0);
						end
					end
				end
				----------------------------------------------------------------------
				--	Show target
				if LeaPlusLC["TipShowTarget"] == "On" then
					local target = UnitName(LeaPlusTT["LpTipUnitTarget"].."target");
					if target == nil or target == "" then return end
					if (UnitIsUnit(target, "player")) then target = ("|c12ff4400YOU") end

					-- Show target in class color
					if not (UnitIsUnit(target, "player")) and (UnitIsPlayer(LeaPlusTT["LpTipUnitTarget"].."target")) then
						local void,tar_g = UnitClassBase(LeaPlusTT["LpTipUnitTarget"].."target");
						local LeaPlusTipTcolr = RAID_CLASS_COLORS[tar_g]
						local LeaPlusTipTcolr = "|cff" .. string.format('%02x%02x%02x',LeaPlusTipTcolr.r * 255, LeaPlusTipTcolr.g * 255, LeaPlusTipTcolr.b * 255)
						target = (LeaPlusTipTcolr .. target)
					end
					
					GameTooltip:AddLine("Target: " .. target)
				end
				----------------------------------------------------------------------
			end
			GameTooltip:HookScript("OnTooltipSetUnit", function(self) ShowTip(true) end)
			
		end

	end

----------------------------------------------------------------------
--	L23: Variable
----------------------------------------------------------------------

	function LeaPlusLC:Variable()

		-- Map customisation
		if LeaPlusLC["ShowMapMod"] == "On" then

			----------------------------------------------------------------------
			-- Basic modification
			----------------------------------------------------------------------

			-- Function to toggle the world map safely without tainting
			local function ToggleMapSafe()
				local sfx = GetCVar("Sound_EnableSFX");
				SetCVar("Sound_EnableSFX", 0);
				MiniMapWorldMapButton:Click(); MiniMapWorldMapButton:Click();
				SetCVar("Sound_EnableSFX", sfx);
			end

			-- Enable mousewheel for traversing map floors
			WorldMapButton:SetScript("OnMouseWheel", function(self, delta)
				local newLevel = GetCurrentMapDungeonLevel() - delta
				if newLevel >= 1 and newLevel <= GetNumDungeonMapLevels() then
					SetDungeonMapLevel(newLevel)
					PlaySound("UChatScrollButton")
				end
			end)

			-- Refresh map if digsites are toggled while in microdungeons
			WorldMapShowDigSites:HookScript("OnClick", function(self)
				local filename, texheight, void, void, sub = GetMapInfo()
				if sub or not filename then
					ToggleMapSafe();
				end
			end)

			----------------------------------------------------------------------
			-- Map reveal (why isn't there a CVAR for this?)
			----------------------------------------------------------------------

			--local mapcrawler = 423582990616; print(mapcrawler % 1024, floor(mapcrawler / 1024) % 1024, floor(mapcrawler / 1048576) % 1024, floor(mapcrawler / 1073741824))

			local LeaPlusMapData = {

				-- Eastern Kingdoms
				["Arathi"] = {"CirecleofOuterBinding:215:188:332:273", "CircleofWestBinding:220:287:85:24", "NorthfoldManor:227:268:132:105", "Bouldergor:249:278:171:123", "StromgardeKeep:284:306:21:269", "FaldirsCove:273:268:77:400", "CircleofInnerBinding:228:227:201:312", "ThandolSpan:237:252:261:416", "BoulderfistHall:252:258:327:367", "RefugePoint:196:270:293:145", "WitherbarkVillage:260:220:476:359", "GoShekFarm:306:248:430:249", "DabyriesFarmstead:210:227:404:144", "CircleofEastBinding:183:238:506:126", "Hammerfall:270:271:581:118", "GalensFall:212:305:0:144"},
				["Badlands"] = {"AgmondsEnd:342:353:230:315", "AngorFortress:285:223:230:68", "ApocryphansRest:252:353:0:66", "CampBoff:274:448:407:220", "CampCagg:339:347:0:281", "CampKosh:236:260:504:19", "DeathwingScar:328:313:175:178", "HammertoesDigsite:209:196:411:116", "LethlorRavine:469:613:533:55", "TheDustbowl:214:285:144:99", "Uldaman:266:210:336:0",},
				["BlastedLands"] = {"AltarofStorms:238:195:225:110", "DreadmaulHold:272:206:258:0", "DreadmaulPost:235:188:327:182", "NethergardeKeep:295:205:530:6", "NethergardeSupplyCamps:195:199:436:0", "RiseoftheDefiler:168:170:375:102", "SerpentsCoil:218:183:459:97", "Shattershore:240:270:578:91", "SunveilExcursion:233:266:386:374", "Surwich:199:191:333:474", "TheDarkPortal:370:298:368:179", "TheRedReaches:268:354:533:268", "TheTaintedForest:348:357:132:311", "TheTaintedScar:308:226:144:175",},
				["BurningSteppes"] = {"AltarofStorms:182:360:0:0", "BlackrockMountain:281:388:79:0", "BlackrockPass:298:410:419:258", "BlackrockStronghold:320:385:235:0", "Dracodar:362:431:0:237", "DreadmaulRock:274:263:568:151", "MorgansVigil:383:413:615:255", "PillarofAsh:274:413:253:255", "RuinsofThaurissan:324:354:421:0", "TerrorWingPath:350:341:646:7",},
				["Darkshore"] = {"AmethAran:326:145:294:330", "EyeoftheVortex:330:192:300:239", "Lordanel:277:281:391:54", "Nazjvel:244:201:207:467", "RuinsofAuberdine:203:194:280:182", "RuinsofMathystra:200:263:517:28", "ShatterspearVale:250:241:596:16", "ShatterspearWarcamp:245:147:565:0", "TheMastersGlaive:303:185:277:483", "WildbendRiver:314:193:280:378", "WitheringThicket:328:250:305:118",},
				["DeadwindPass"] = {"DeadmansCrossing:617:522:83:0", "Karazhan:513:358:92:310", "TheVice:350:449:433:208",},
				["DunMorogh"] = {"AmberstillRanch:249:183:595:225", "ColdridgePass:225:276:360:340", "ColdridgeValley:398:302:100:366", "FrostmaneFront:226:335:469:256", "FrostmaneHold:437:249:50:227", "Gnomeregan:409:318:0:27", "GolBolarQuarry:198:251:663:288", "HelmsBedLake:218:234:760:268", "IceFlowLake:236:358:263:0", "Ironforge:376:347:398:0", "IronforgeAirfield:308:335:630:0", "Kharanos:184:188:449:220", "NorthGateOutpost:237:366:765:43", "TheGrizzledDen:211:160:374:287", "TheShimmeringDeep:171:234:397:132", "TheTundridHills:174:249:579:306",},
				["Duskwood"] = {"AddlesStead:299:296:32:348", "BrightwoodGrove:279:399:497:112", "Darkshire:329:314:640:128", "ManorMistmantle:219:182:661:122", "RacenHill:205:157:96:292", "RavenHillCemetary:323:309:91:132", "TheDarkenedBank:931:235:71:26", "TheHushedBank:189:307:0:152", "TheRottingOrchard:291:263:539:368", "TheTranquilGardensCemetary:291:244:627:344", "TheTwilightGrove:320:388:314:101", "TheYorgenFarmstead:233:248:401:396", "VulGolOgreMound:268:282:228:355",},
				["EasternPlaguelands"] = {"Acherus:228:273:774:102", "BlackwoodLake:238:231:382:151", "CorinsCrossing:186:213:493:289", "CrownGuardTower:202:191:258:351", "Darrowshire:248:206:211:462", "EastwallTower:181:176:541:184", "LakeMereldar:266:241:462:427", "LightsHopeChapel:196:220:687:271", "LightsShieldTower:243:162:391:271", "Northdale:265:232:570:61", "NorthpassTower:250:192:401:69", "Plaguewood:328:253:144:40", "QuelLithienLodge:277:175:351:0", "RuinsOfTheScarletEnclave:264:373:738:295", "Stratholme:310:178:118:0", "Terrordale:258:320:0:10", "TheFungalVale:274:216:183:211", "TheInfectisScar:177:266:595:263", "TheMarrisStead:202:202:133:335", "TheNoxiousGlade:297:299:650:55", "ThePestilentScar:182:320:383:348", "TheUndercroft:280:211:56:457", "ThondorilRiver:262:526:0:100", "Tyrshand:214:254:651:414", "ZulMashar:286:176:528:0",},
				["Elwynn"] = {"BrackwellPumpkinPatch:287:216:532:424", "CrystalLake:220:207:417:327", "EastvaleLoggingCamp:294:243:703:292", "FargodeepMine:269:248:240:420", "Goldshire:276:231:247:294", "JerodsLanding:230:206:396:430", "NorthshireValley:295:296:355:138", "RidgepointTower:285:194:708:442", "StonecairnLake:340:272:552:186", "Stromwind:512:422:0:0", "TowerofAzora:270:241:529:287", "WestbrookGarrison:269:313:116:355",},
				["Ghostlands"] = {"AmaniPass:404:436:598:232", "BleedingZiggurat:256:256:184:238", "DawnstarSpire:427:256:575:0", "Deatholme:512:293:95:375", "ElrendarCrossing:512:256:326:0", "FarstriderEnclave:429:256:573:136", "GoldenmistVillage:512:512:44:0", "HowlingZiggurat:256:449:340:219", "IsleofTribulations:256:256:585:0", "SanctumoftheMoon:256:256:210:126", "SanctumoftheSun:256:512:448:150", "SuncrownVillage:512:256:460:0", "ThalassiaPass:256:262:364:406", "Tranquillien:256:512:365:2", "WindrunnerSpire:256:256:40:287", "WindrunnerVillage:256:512:60:117", "ZebNowa:512:431:466:237",},
				["HillsbradFoothills"] = {"AzurelodeMine:180:182:287:399", "ChillwindPoint:447:263:555:68", "CorrahnsDagger:135:160:426:224", "CrushridgeHold:134:124:463:101", "DalaranCrater:316:238:102:137", "DandredsFold:258:113:341:0", "DarrowHill:147:160:425:279", "DunGarok:269:258:542:410", "DurnholdeKeep:437:451:565:217", "GallowsCorner:155:147:451:140", "GavinsNaze:116:129:344:254", "GrowlessCave:171:136:359:191", "HillsbradFields:302:175:191:302", "LordamereInternmentCamp:250:167:194:216", "MistyShore:158:169:321:42", "NethanderSteed:204:244:502:373", "PurgationIsle:144:139:200:505", "RuinsOfAlterac:189:181:347:85", "SlaughterHollow:148:120:413:55", "SoferasNaze:148:146:484:166", "SouthpointTower:312:254:59:310", "Southshore:229:219:383:352", "Strahnbrad:275:193:505:44", "TarrenMill:165:203:494:226", "TheHeadland:105:148:390:255", "TheUplands:212:160:441:0",},
				["Hinterlands"] = {"AeriePeak:238:267:0:236", "Agolwatha:208:204:367:159", "JinthaAlor:287:289:487:334", "PlaguemistRavine:191:278:133:105", "QuelDanilLodge:241:211:220:181", "Seradane:303:311:475:5", "ShadraAlor:240:196:220:379", "Shaolwatha:281:261:565:208", "SkulkRock:176:235:490:195", "TheAltarofZul:225:196:357:343", "TheCreepingRuin:199:199:390:252", "TheOverlookCliffs:244:401:677:267", "ValorwindLake:199:212:286:269", "Zunwatha:226:225:152:284",},
				["LochModan"] = {"GrizzlepawRidge:273:230:245:324", "IronbandsExcavationSite:397:291:481:296", "MogroshStronghold:294:249:549:52", "NorthgatePass:319:289:16:0", "SilverStreamMine:225:252:221:0", "StonesplinterValley:273:294:177:345", "StronewroughtDam:333:200:339:0", "TheFarstriderLodge:349:292:570:209", "TheLoch:330:474:340:81", "Thelsamar:455:295:0:146", "ValleyofKings:310:345:0:311",},
				["Redridge"] = {"AlthersMill:228:247:350:139", "CampEverstill:189:193:445:286", "GalardellValley:428:463:574:0", "LakeEverstill:464:250:81:214", "LakeridgeHighway:392:352:148:316", "Lakeshire:410:256:0:110", "RedridgeCanyons:413:292:37:0", "RendersCamp:357:246:214:0", "RendersValley:427:291:451:377", "ShalewindCanyon:306:324:688:283", "StonewatchFalls:316:182:525:302", "StonewatchKeep:228:420:480:0", "ThreeCorners:323:406:0:256",},
				["RuinsofGilneas"] = {"GilneasPuzzle:1002:668:0:0",},
				["Gilneas"] = {"NorthgateWoods:282:298:482:14", "GilneasCity:282:263:483:210", "StormglenVillage:321:203:516:465", "HammondFarmstead:194:236:167:352", "HaywardFishery:177:219:293:449", "TempestsReach:350:345:652:290", "TheHeadlands:328:336:160:0", "Duskhaven:286:178:272:333", "NorthernHeadlands:267:314:387:0", "Keelharbor:280:342:298:95", "CrowleyOrchard:210:166:261:427", "EmberstoneMine:281:351:639:43", "Greymanemanor:244:241:141:202", "KorothsDen:222:268:393:386", "TheBlackwald:280:224:504:394",},
				["Gilneas_terrain1"] = {"NorthgateWoods:282:298:482:14", "GilneasCity:282:263:483:210", "StormglenVillage:321:203:516:465", "HammondFarmstead:194:236:167:352", "HaywardFishery:177:219:293:449", "TempestsReach:350:345:652:290", "TheHeadlands:328:336:160:0", "Duskhaven:286:178:272:333", "NorthernHeadlands:267:314:387:0", "Keelharbor:280:342:298:95", "CrowleyOrchard:210:166:261:427", "EmberstoneMine:281:351:639:43", "Greymanemanor:244:241:141:202", "KorothsDen:222:268:393:386", "TheBlackwald:280:224:504:394",},
				["Gilneas_terrain2"] = {"NorthgateWoods:282:298:482:14", "GilneasCity:282:263:483:210", "StormglenVillage:321:203:516:465", "HammondFarmstead:194:236:167:352", "HaywardFishery:177:219:293:449", "TempestsReach:350:345:652:290", "TheHeadlands:328:336:160:0", "Duskhaven:286:178:272:333", "NorthernHeadlands:267:314:387:0", "Keelharbor:280:342:298:95", "CrowleyOrchard:210:166:261:427", "EmberstoneMine:281:351:639:43", "Greymanemanor:244:241:141:202", "KorothsDen:222:268:393:386", "TheBlackwald:280:224:504:394",},
				["SearingGorge"] = {"BlackcharCave:375:307:0:361", "BlackrockMountain:304:244:243:424", "DustfireValley:392:355:588:0", "FirewatchRidge:365:393:0:75", "GrimsiltWorksite:441:266:531:241", "TannerCamp:571:308:413:360", "TheCauldron:481:360:232:171", "ThoriumPoint:429:301:255:38",},
				["Silverpine"] = {"Ambermill:283:243:509:250", "BerensPeril:318:263:505:405", "DeepElemMine:217:198:483:212", "FenrisIsle:352:302:581:15", "ForsakenHighCommand:361:175:445:0", "ForsakenRearGuard:186:238:369:0", "NorthTidesBeachhead:174:199:323:68", "NorthTidesRun:281:345:147:0", "OlsensFarthing:251:167:312:249", "ShadowfangKeep:179:165:337:337", "TheBattlefront:255:180:349:429", "TheDecrepitFields:176:152:471:156", "TheForsakenFront:152:189:433:327", "TheGreymaneWall:409:162:318:506", "TheSepulcher:218:200:341:157", "TheSkitteringDark:227:172:236:0", "ValgansField:162:172:461:77",},
				["StranglethornJungle"] = {"BalAlRuins:159:137:267:168", "BaliaMahRuins:239:205:397:243", "Bambala:190:176:566:164", "FortLivingston:230:170:398:375", "GromGolBaseCamp:167:179:298:228", "KalAiRuins:139:150:354:184", "KurzensCompound:244:238:499:0", "LakeNazferiti:240:228:413:95", "Mazthoril:350:259:488:364", "MizjahRuins:157:173:387:246", "MoshOggOgreMound:234:206:543:253", "NesingwarysExpedition:227:190:306:63", "RebelCamp:302:166:306:0", "RuinsOfZulKunda:228:265:158:0", "TheVileReef:236:224:140:208", "ZulGurub:376:560:626:0", "ZuuldalaRuins:324:263:9:22",},
				["Sunwell"] = {"SunsReachHarbor:512:416:252:252", "SunsReachSanctum:512:512:251:4",},
				["SwampOfSorrows"] = {"Bogpaddle:262:193:600:0", "IthariusCave:268:316:7:242", "MarshtideWatch:330:342:478:0", "MistyreedStrand:402:668:600:0", "MistyValley:268:285:0:80", "PoolOfTears:257:229:575:238", "Sorrowmurk:229:418:703:80", "SplinterspearJunction:238:343:194:236", "Stagalbog:347:303:540:360", "Stonard:357:308:297:258", "TheHarborage:266:284:161:79", "TheShiftingMire:292:360:331:24",},
				["TheCapeOfStranglethorn"] = {"BootyBay:225:255:289:341", "CrystalveinMine:271:204:528:73", "GurubashiArena:238:260:345:0", "HardwrenchHideaway:356:221:208:116", "JagueroIsle:240:264:471:404", "MistvaleValley:253:242:408:248", "NekmaniWellspring:246:221:292:213", "RuinsofAboraz:184:176:533:181", "RuinsofJubuwal:155:221:468:119", "TheSundering:244:209:452:0", "WildShore:236:276:340:392",},
				["Tirisfal"] = {"AgamandMills:285:260:324:90", "BalnirFarmstead:242:179:594:324", "BrightwaterLake:210:292:573:122", "Brill:199:182:480:252", "CalstonEstate:179:169:389:255", "ColdHearthManor:212:177:418:317", "CrusaderOutpost:175:210:686:232", "Deathknell:431:407:9:207", "GarrensHaunt:190:214:477:129", "NightmareVale:225:281:347:325", "RuinsofLorderon:390:267:423:359", "ScarletMonastery:262:262:740:47", "ScarletWatchPost:161:234:692:99", "SollidenFarmstead:286:225:201:192", "TheBulwark:293:338:709:330", "VenomwebVale:250:279:752:150",},
				["TwilightHighlands"] = {"Bloodgulch:215:157:416:205", "CrucibleOfCarnage:203:208:387:268", "Crushblow:182:195:370:447", "DragonmawPass:283:206:76:120", "DragonmawPort:251:207:631:245", "DunwaldRuins:197:218:395:367", "FirebeardsPatrol:215:181:499:265", "GlopgutsHollow:174:190:291:89", "GorshakWarCamp:194:170:543:220", "GrimBatol:230:276:83:223", "Highbank:220:227:697:403", "HighlandForest:239:232:482:330", "HumboldtConflaguration:143:141:344:89", "Kirthaven:308:267:482:0", "ObsidianForest:342:288:436:380", "RuinsOfDrakgor:206:182:296:0", "SlitheringCove:198:201:622:169", "TheBlackBreach:211:210:498:121", "TheGullet:175:180:269:179", "TheKrazzworks:226:232:654:0", "TheTwilightBreach:199:212:312:192", "TheTwilightCitadel:361:354:151:314", "TheTwilightGate:165:199:327:356", "Thundermar:238:229:374:93", "TwilightShore:260:202:610:345", "VermillionRedoubt:324:264:71:16", "VictoryPoint:177:159:302:306", "WeepingWound:214:190:358:0", "WyrmsBend:191:198:205:232",},
				["TwilightHighlands_terrain1"] = {"Bloodgulch:215:157:416:205", "CrucibleOfCarnage:203:208:387:268", "Crushblow:182:195:370:447", "DragonmawPass:283:206:76:120", "DragonmawPort:251:207:631:245", "DunwaldRuins:197:218:395:367", "FirebeardsPatrol:215:181:499:265", "GlopgutsHollow:174:190:291:89", "GorshakWarCamp:194:170:543:220", "GrimBatol:230:276:83:223", "Highbank:220:227:697:403", "HighlandForest:239:232:482:330", "HumboldtConflaguration:143:141:344:89", "Kirthaven:308:267:482:0", "ObsidianForest:342:288:436:380", "RuinsOfDrakgor:206:182:296:0", "SlitheringCove:198:201:622:169", "TheBlackBreach:211:210:498:121", "TheGullet:175:180:269:179", "TheKrazzworks:226:232:654:0", "TheTwilightBreach:199:212:312:192", "TheTwilightCitadel:361:354:151:314", "TheTwilightGate:165:199:327:356", "Thundermar:238:229:374:93", "TwilightShore:260:202:610:345", "VermillionRedoubt:324:264:71:16", "VictoryPoint:177:159:302:306", "WeepingWound:214:190:358:0", "WyrmsBend:191:198:205:232",},
				["WesternPlaguelands"] = {"Andorhal:464:325:96:343", "CaerDarrow:194:208:601:390", "DalsonsFarm:325:192:300:232", "DarrowmereLake:492:314:510:354", "FelstoneField:241:212:229:228", "GahrronsWithering:241:252:495:213", "Hearthglen:432:271:235:0", "NorthridgeLumberCamp:359:182:231:123", "RedpineDell:290:133:286:211", "SorrowHill:368:220:261:448", "TheBulwark:316:316:48:235", "TheWeepingCave:185:230:551:151", "TheWrithingHaunt:169:195:472:332", "ThondrorilRiver:311:436:533:0",},
				["Westfall"] = {"AlexstonFarmstead:346:222:167:263", "DemontsPlace:201:195:203:376", "FurlbrowsPumpkinFarm:197:213:394:0", "GoldCoastQuarry:235:306:199:79", "JangoloadMine:196:229:311:0", "Moonbrook:232:213:308:325", "SaldeansFarm:244:237:451:81", "SentinelHill:229:265:404:226", "TheDaggerHills:292:273:303:395", "TheDeadAcre:193:273:531:200", "TheDustPlains:317:261:480:378", "TheGapingChasm:184:217:294:168", "TheJansenStead:202:179:474:0", "TheMolsenFarm:202:224:348:118", "WestfallLighthouse:211:167:221:477",},
				["Wetlands"] = {"AngerfangEncampment:236:256:359:201", "BlackChannelMarsh:301:232:37:240", "BluegillMarsh:321:248:31:102", "DireforgeHills:329:228:506:34", "DunAlgaz:298:215:346:419", "DunModr:257:185:356:7", "GreenwardensGrove:250:269:460:102", "IronbeardsTomb:185:224:372:76", "MenethilHarbor:325:363:0:297", "MosshideFen:369:235:506:232", "RaptorRidge:256:245:599:123", "Satlspray:250:282:218:0", "SlabchiselsSurvey:300:316:532:352", "SundownMarsh:276:243:121:63", "ThelganRock:258:207:371:335", "WhelgarsExcavationSite:298:447:185:195",},

				-- Kalimdor
				["AhnQirajTheFallenKingdom"] = {"AQKingdom:887:668:115:0",},
				["Ashenvale"] = {"Astranaar:251:271:255:164", "BoughShadow:166:211:836:148", "FallenSkyLake:287:276:529:385", "FelfireHill:277:333:714:317", "LakeFalathim:184:232:112:148", "MaelstrasPost:246:361:188:0", "NightRun:221:257:595:253", "OrendilsRetreat:244:251:143:0", "RaynewoodRetreat:231:256:481:221", "Satyrnaar:235:236:696:154", "SilverwindRefuge:347:308:338:335", "TheHowlingVale:325:239:473:97", "TheRuinsofStardust:236:271:210:331", "TheShrineofAssenia:306:283:40:275", "TheZoramStrand:262:390:0:0", "ThistlefurVillage:314:241:255:78", "ThunderPeak:203:310:377:121", "WarsongLumberCamp:231:223:771:265",},
				["Aszhara"] = {"BearsHead:256:224:113:141", "BilgewaterHarbor:587:381:395:127", "BitterReaches:321:247:477:0", "BlackmawHold:260:267:204:53", "DarnassianBaseCamp:243:262:343:3", "GallywixPleasurePalace:250:230:70:222", "LakeMennar:210:232:245:377", "OrgimmarRearGate:352:274:22:344", "RavencrestMonument:295:267:476:401", "RuinsofArkkoran:219:193:575:121", "RuinsofEldarath:218:237:228:229", "StormCliffs:207:232:407:403", "TheSecretLab:184:213:353:396", "TheShatteredStrand:206:329:316:168", "TowerofEldara:306:337:684:22",},
				["AzuremystIsle"] = {"AmmenFord:256:256:515:279", "AmmenVale:475:512:527:104", "AzureWatch:256:256:383:249", "BristlelimbVillage:256:256:174:363", "Emberglade:256:256:488:24", "FairbridgeStrand:256:128:356:0", "GreezlesCamp:256:256:507:350", "MoongrazeWoods:256:256:449:183", "OdesyusLanding:256:256:352:378", "PodCluster:256:256:281:305", "PodWreckage:128:256:462:349", "SiltingShore:256:256:291:3", "SilvermystIsle:256:222:23:446", "StillpineHold:256:256:365:49", "TheExodar:512:512:74:85", "ValaarsBerth:256:256:176:303", "WrathscalePoint:256:247:220:421",},
				["Barrens"] = {"BoulderLodeMine:278:209:511:7", "DreadmistPeak:241:195:290:104", "FarWatchPost:207:332:555:129", "GroldomFarm:243:217:448:127", "MorshanRampart:261:216:258:6", "Ratchet:219:175:547:379", "TheCrossroads:233:193:362:275", "TheDryHills:283:270:116:57", "TheForgottenPools:446:256:100:208", "TheMerchantCoast:315:212:556:456", "TheSludgeFen:257:249:403:6", "TheStagnantOasis:336:289:344:379", "TheWailingCaverns:377:325:152:318", "ThornHill:239:231:481:254",},
				["BloodmystIsle"] = {"AmberwebPass:256:512:44:62", "Axxarien:256:256:297:136", "BlacksiltShore:512:242:177:426", "Bladewood:256:256:367:209", "BloodscaleIsle:239:256:763:256", "BloodWatch:256:256:437:258", "BristlelimbEnclave:256:256:546:410", "KesselsCrossing:485:141:517:527", "Middenvale:256:256:414:406", "Mystwood:256:185:309:483", "Nazzivian:256:256:250:404", "RagefeatherRidge:256:256:481:117", "RuinsofLorethAran:256:256:556:216", "TalonStand:256:256:657:78", "TelathionsCamp:128:128:180:216", "TheBloodcursedReef:256:256:729:54", "TheBloodwash:256:256:302:27", "TheCrimsonReach:256:256:555:87", "TheCryoCore:256:256:293:285", "TheFoulPool:256:256:221:136", "TheHiddenReef:256:256:205:39", "TheLostFold:256:198:503:470", "TheVectorCoil:512:430:43:238", "TheWarpPiston:256:256:451:29", "VeridianPoint:256:256:637:0", "VindicatorsRest:256:256:232:242", "WrathscaleLair:256:256:598:338", "WyrmscarIsland:256:256:613:82",},
				["Desolace"] = {"CenarionWildlands:312:285:415:156", "GelkisVillage:274:196:207:472", "KodoGraveyard:250:215:360:273", "MagramTerritory:289:244:613:170", "MannorocCoven:326:311:381:357", "NijelsPoint:231:257:573:0", "RanzjarIsle:161:141:210:0", "Sargeron:317:293:655:0", "ShadowbreakRavine:292:266:637:402", "ShadowpreyVillage:222:299:142:369", "ShokThokar:309:349:589:319", "SlitherbladeShore:338:342:208:24", "TethrisAran:274:145:399:0", "ThargadsCamp:212:186:275:376", "ThunderAxeFortress:220:205:440:49", "ValleyofSpears:321:275:170:196",},
				["Durotar"] = {"DrygulchRavine:236:196:415:60", "EchoIsles:330:255:429:413", "NorthwatchFoothold:162:157:399:440", "Orgrimmar:259:165:309:0", "RazorHill:224:227:431:157", "RazormaneGrounds:248:158:302:264", "SenjinVillage:192:184:457:406", "SkullRock:208:157:438:0", "SouthfuryWatershed:244:222:282:174", "ThunderRidge:220:218:295:48", "TiragardeKeep:210:200:462:298", "ValleyOfTrials:254:258:304:312",},
				["Dustwallow"] = {"AlcazIsland:206:200:656:21", "BlackhoofVillage:344:183:199:0", "BrackenwllVillage:384:249:133:59", "DirehornPost:279:301:358:169", "Mudsprocket:433:351:109:313", "ShadyRestInn:317:230:137:188", "TheramoreIsle:305:247:542:223", "TheWyrmbog:436:299:359:369", "WitchHill:270:353:428:0",},
				["EversongWoods"] = {"AzurebreezeCoast:256:256:669:228", "DuskwitherGrounds:256:256:605:253", "EastSanctum:256:256:460:373", "ElrendarFalls:128:256:580:399", "FairbreezeVilliage:256:256:386:386", "FarstriderRetreat:256:128:524:359", "GoldenboughPass:256:128:243:469", "LakeElrendar:128:197:584:471", "NorthSanctum:256:256:361:298", "RuinsofSilvermoon:256:256:307:136", "RunestoneFalithas:256:172:378:496", "RunestoneShandor:256:174:464:494", "SatherilsHaven:256:256:324:384", "SilvermoonCity:512:512:440:87", "StillwhisperPond:256:256:474:314", "SunsailAnchorage:256:128:231:404", "SunstriderIsle:512:512:195:5", "TheGoldenStrand:128:253:183:415", "TheLivingWood:128:248:511:420", "TheScortchedGrove:256:128:255:507", "ThuronsLivery:256:128:539:305", "TorWatha:256:353:648:315", "TranquilShore:256:256:215:298", "WestSanctum:128:256:292:319", "Zebwatha:128:193:554:475",},
				["Felwood"] = {"BloodvenomFalls:345:192:220:231", "DeadwoodVillage:173:163:410:505", "EmeraldSanctuary:274:212:394:382", "FelpawVillage:307:161:471:0", "IrontreeWoods:261:273:406:55", "JadefireGlen:229:210:288:458", "JadefireRun:263:199:303:9", "Jaedenar:319:176:234:317", "MorlosAran:187:176:476:484", "RuinsofConstellas:268:214:278:359", "ShatterScarVale:343:250:243:107", "TalonbranchGlade:209:226:531:57",},
				["Feralas"] = {"CampMojache:174:220:671:181", "DarkmistRuins:172:198:568:287", "DireMaul:265:284:485:101", "FeathermoonStronghold:217:192:362:237", "FeralScar:191:179:457:281", "GordunniOutpost:192:157:663:116", "GrimtotemCompund:159:218:607:170", "LowerWilds:207:209:756:191", "RuinsofFeathermoon:208:204:186:229", "RuinsofIsildien:206:237:467:354", "TheForgottenCoast:194:304:375:343", "TheTwinColossals:350:334:271:0", "WrithingDeep:232:206:652:298",},
				["Hyjal_terrain1"] = {"ArchimondesVengeance:270:300:320:5", "AshenLake:282:418:6:78", "DarkwhisperGorge:320:471:682:128", "DireforgeHill:270:173:303:197", "GatesOfSothann:272:334:622:320", "Nordrassil:537:323:392:0", "SethriasRoost:277:232:139:436", "ShrineOfGoldrinn:291:321:116:17", "TheRegrowth:441:319:52:253", "TheScorchedPlain:365:264:411:216", "TheThroneOfFlame:419:290:318:378",},
				["Hyjal"] = {"ArchimondesVengeance:270:300:320:5", "AshenLake:282:418:6:78", "DarkwhisperGorge:320:471:682:128", "DireforgeHill:270:173:303:197", "GatesOfSothann:272:334:622:320", "Nordrassil:537:323:392:0", "SethriasRoost:277:232:139:436", "ShrineOfGoldrinn:291:321:116:17", "TheRegrowth:441:319:52:253", "TheScorchedPlain:365:264:411:216", "TheThroneOfFlame:419:290:318:378",},
				["Moonglade"] = {"LakeEluneara:431:319:219:273", "Nighthaven:346:244:370:135", "ShrineofRemulos:271:296:209:91", "StormrageBarrowDens:275:346:542:210",},
				["Mulgore"] = {"BaeldunDigsite:218:192:226:220", "BloodhoofVillage:302:223:319:273", "PalemaneRock:172:205:248:321", "RavagedCaravan:187:165:435:224", "RedCloudMesa:446:264:286:401", "RedRocks:186:185:514:43", "StonetalonPass:237:184:201:0", "TheGoldenPlains:186:216:448:101", "TheRollingPlains:260:243:527:291", "TheVentureCoMine:208:300:530:138", "ThunderBluff:373:259:208:62", "ThunderhornWaterWell:201:167:333:202", "WildmaneWaterWell:190:172:331:0", "WindfuryRidge:222:202:400:0", "WinterhoofWaterWell:174:185:449:340",},
				["Silithus"] = {"CenarionHold:292:260:427:143", "HiveAshi:405:267:345:4", "HiveRegal:489:358:380:310", "HiveZora:542:367:0:206", "SouthwindVillage:309:243:550:181", "TheCrystalVale:329:246:126:0", "TheScarabWall:580:213:0:455", "TwilightBaseCamp:434:231:100:151", "ValorsRest:315:285:614:0",},
				["SouthernBarrens"] = {"BaelModan:269:211:398:457", "Battlescar:384:248:274:307", "ForwardCommand:216:172:423:251", "FrazzlecrazMotherload:242:195:269:436", "HonorsStand:315:170:201:0", "HuntersHill:218:178:300:64", "NorthwatchHold:280:279:548:147", "RazorfenKraul:214:140:273:528", "RuinsofTaurajo:285:171:244:286", "TheOvergrowth:355:226:289:117", "VendettaPoint:254:214:267:196",},
				["StonetalonMountains"] = {"BattlescarValley:290:297:220:189", "BoulderslideRavine:194:156:532:512", "CliffwalkerPost:241:192:366:95", "GreatwoodVale:322:220:602:448", "KromgarFortress:183:196:588:341", "Malakajin:211:131:618:537", "MirkfallonLake:244:247:417:143", "RuinsofEldrethar:221:235:367:411", "StonetalonPeak:305:244:265:0", "SunRockRetreat:222:222:353:285", "ThaldarahOverlook:210:189:252:121", "TheCharredVale:277:274:199:368", "UnearthedGrounds:265:206:654:369", "WebwinderHollow:164:258:479:401", "WebwinderPath:267:352:468:263", "WindshearCrag:374:287:533:179", "WindshearHold:176:189:516:289",},
				["Tanaris"] = {"AbyssalSands:255:194:297:148", "BrokenPillar:195:163:413:211", "CavernsofTime:213:173:507:238", "DunemaulCompound:231:177:305:257", "EastmoonRuins:173:163:380:341", "Gadgetzan:189:180:412:92", "GadgetzanBay:254:341:479:9", "LandsEndBeach:224:216:431:452", "LostRiggerCover:178:243:615:201", "SandsorrowWatch:214:149:293:99", "SouthbreakShore:274:186:437:289", "SouthmoonRuins:232:211:301:349", "TheGapingChasm:225:187:448:364", "TheNoxiousLair:179:190:258:211", "ThistleshrubValley:221:293:185:280", "ValleryoftheWatchers:269:190:255:431", "ZulFarrak:315:190:184:0",},
				["Teldrassil"] = {"BanethilHollow:175:235:374:221", "Darnassus:298:337:149:181", "GalardellValley:178:186:466:237", "GnarlpineHold:198:181:347:355", "LakeAlameth:289:202:422:310", "PoolsofArlithrien:140:210:345:243", "RutheranVillage:317:220:329:448", "Shadowglen:241:217:481:104", "StarbreezeVillage:187:196:544:217", "TheCleft:144:226:432:109", "TheOracleGlade:194:244:276:90", "WellspringLake:165:249:382:83",},
				["ThousandNeedles"] = {"DarkcloudPinnacle:317:252:169:116", "FreewindPost:436:271:276:186", "Highperch:246:380:0:134", "RazorfenDowns:361:314:298:0", "RustmaulDiveSite:234:203:527:465", "SouthseaHoldfast:246:256:756:412", "SplithoofHeights:431:410:571:49", "TheGreatLift:272:232:136:0", "TheShimmeringDeep:411:411:591:257", "TheTwilightWithering:374:339:347:329", "TwilightBulwark:358:418:125:241", "WestreachSummit:280:325:0:0",},
				["Uldum"] = {"AkhenetFields:164:185:471:277", "CradelOfTheAncient:202:169:341:402", "HallsOfOrigination:269:242:599:184", "KhartutsTomb:203:215:542:0", "LostCityOfTheTolVir:233:321:527:291", "Marat:160:193:406:174", "Nahom:237:194:583:162", "Neferset:209:254:407:384", "ObeliskOfTheMoon:400:224:110:0", "ObeliskOfTheStars:196:170:551:121", "ObeliskOfTheSun:269:203:340:282", "Orsis:249:243:264:136", "Ramkahen:228:227:411:67", "RuinsOfAhmtul:278:173:365:0", "RuinsOfAmmon:203:249:217:289", "Schnottzslanding:312:289:28:221", "TahretGrounds:150:159:545:193", "TempleofUldum:296:209:132:127", "TheCursedlanding:237:316:752:170", "TheGateofUnendingCycles:161:236:647:15", "TheTrailOfDevestation:206:204:657:349", "TheVortexPinnacle:213:195:656:473", "ThroneOfTheFourWinds:270:229:229:433", "VirnaalDam:151:144:479:215",},
				["Uldum_terrain1"] = {"AkhenetFields:164:185:471:277", "CradelOfTheAncient:202:169:341:402", "HallsOfOrigination:269:242:599:184", "KhartutsTomb:203:215:542:0", "LostCityOfTheTolVir:233:321:527:291", "Marat:160:193:406:174", "Nahom:237:194:583:162", "Neferset:209:254:407:384", "ObeliskOfTheMoon:400:224:110:0", "ObeliskOfTheStars:196:170:551:121", "ObeliskOfTheSun:269:203:340:282", "Orsis:249:243:264:136", "Ramkahen:228:227:411:67", "RuinsOfAhmtul:278:173:365:0", "RuinsOfAmmon:203:249:217:289", "Schnottzslanding:312:289:28:221", "TahretGrounds:150:159:545:193", "TempleofUldum:296:209:132:127", "TheCursedlanding:237:316:752:170", "TheGateofUnendingCycles:161:236:647:15", "TheTrailOfDevestation:206:204:657:349", "TheVortexPinnacle:213:195:656:473", "ThroneOfTheFourWinds:270:229:229:433", "VirnaalDam:151:144:479:215",},
				["UngoroCrater"] = {"FirePlumeRidge:321:288:356:192", "FungalRock:224:191:557:0", "GolakkaHotSprings:309:277:145:226", "IronstonePlateau:197:222:706:201", "LakkariTarPits:432:294:305:0", "MarshalsStand:204:170:462:330", "MossyPile:186:185:328:179", "TerrorRun:316:293:162:357", "TheMarshlands:263:412:573:256", "TheRollingGarden:337:321:565:39", "TheScreamingReaches:332:332:157:0", "TheSlitheringScar:381:274:335:384",},
				["Winterspring"] = {"Everlook:194:229:482:195", "FrostfireHotSprings:376:289:93:118", "FrostsaberRock:332:268:304:0", "FrostwhisperGorge:317:183:424:474", "IceThistleHills:249:217:581:314", "LakeKeltheril:271:258:372:268", "Mazthoril:257:238:399:340", "OwlWingThicket:254:150:556:439", "StarfallVillage:367:340:229:33", "TheHiddenGrove:333:255:500:17", "TimbermawPost:362:252:92:302", "WinterfallVillage:221:209:588:181",},

				-- Outland
				["BladesEdgeMountains"] = {"BashirLanding:256:256:422:0", "BladedGulch:256:256:623:147", "BladesipreHold:256:507:314:161", "BloodmaulCamp:256:256:412:95", "BloodmaulOutpost:256:297:342:371", "BrokenWilds:256:256:733:109", "CircleofWrath:256:256:439:210", "DeathsDoor:256:419:512:249", "ForgeCampAnger:416:256:586:147", "ForgeCampTerror:512:252:144:416", "ForgeCampWrath:256:256:254:176", "Grishnath:256:256:286:28", "GruulsLayer:256:256:527:81", "JaggedRidge:256:254:446:414", "MokNathalVillage:256:256:658:297", "RavensWood:512:256:214:55", "RazorRidge:256:336:533:332", "RidgeofMadness:256:410:554:258", "RuuanWeald:256:512:479:98", "Skald:256:256:673:71", "Sylvanaar:256:318:289:350", "TheCrystalpine:256:256:585:0", "ThunderlordStronghold:256:396:405:272", "VeilLashh:256:240:271:428", "VeilRuuan:256:128:563:151", "VekhaarStand:256:256:629:406", "VortexPinnacle:256:462:166:206",},
				["Hellfire"] = {"DenofHaalesh:256:256:182:412", "ExpeditionArmory:512:255:261:413", "FalconWatch:512:342:183:326", "FallenSkyRidge:256:256:34:142", "ForgeCampRage:512:512:478:25", "HellfireCitadel:256:458:338:210", "HonorHold:256:256:469:298", "MagharPost:256:256:206:110", "PoolsofAggonar:256:512:326:45", "RuinsofShanaar:256:378:25:290", "TempleofTelhamat:512:512:38:152", "TheLegionFront:256:512:579:128", "TheStairofDestiny:256:512:737:156", "Thrallmar:256:256:467:154", "ThroneofKiljaeden:512:256:477:6", "VoidRidge:256:256:705:368", "WarpFields:256:260:308:408", "ZethGor:422:238:580:430",},
				["Nagrand"] = {"BurningBladeRUins:256:334:660:334", "ClanWatch:256:256:532:363", "ForgeCampFear:512:420:36:248", "ForgeCampHate:256:256:162:154", "Garadar:256:256:431:143", "Halaa:256:256:335:193", "KilsorrowFortress:256:241:558:427", "LaughingSkullRuins:256:256:351:52", "OshuGun:512:334:168:334", "RingofTrials:256:256:533:267", "SouthwindCleft:256:256:391:258", "SunspringPost:256:256:219:199", "Telaar:256:256:387:390", "ThroneoftheElements:256:256:504:53", "TwilightRidge:256:512:10:107", "WarmaulHill:256:256:157:32", "WindyreedPass:256:256:598:79", "WindyreedVillage:256:256:666:233", "ZangarRidge:256:256:277:54",},
				["Netherstorm"] = {"Area52:256:128:241:388", "ArklonRuins:256:256:328:397", "CelestialRidge:256:256:644:173", "EcoDomeFarfield:256:256:396:10", "EtheriumStagingGrounds:256:256:481:208", "ForgeBaseOG:256:256:237:22", "KirinVarVillage:256:145:490:523", "ManaforgeBanar:256:387:147:281", "ManaforgeCoruu:256:179:357:489", "ManaforgeDuro:256:256:465:336", "ManafrogeAra:256:256:171:155", "Netherstone:256:256:411:20", "NetherstormBridge:256:256:132:294", "RuinedManaforge:256:256:513:138", "RuinsofEnkaat:256:256:253:301", "RuinsofFarahlon:512:256:354:49", "SocretharsSeat:256:256:229:38", "SunfuryHold:256:217:454:451", "TempestKeep:409:384:593:284", "TheHeap:256:213:239:455", "TheScrapField:256:256:356:261", "TheStormspire:256:256:298:134",},
				["ShadowmoonValley"] = {"AltarofShatar:256:256:520:93", "CoilskarPoint:512:512:348:8", "EclipsePoint:512:358:343:310", "IlladarPoint:256:256:143:256", "LegionHold:512:512:104:155", "NetherwingCliffs:256:256:554:308", "NetherwingLedge:492:223:510:445", "ShadowmoonVilliage:512:512:116:35", "TheBlackTemple:396:512:606:126", "TheDeathForge:256:512:290:129", "TheHandofGuldan:512:512:394:90", "TheWardensCage:512:410:469:258", "WildhammerStronghold:512:439:168:229",}, 
				["TerokkarForest"] = {"AllerianStronghold:256:256:480:277", "AuchenaiGrounds:256:234:247:434", "BleedingHollowClanRuins:256:367:103:301", "BonechewerRuins:256:256:521:275", "CarrionHill:256:256:377:272", "CenarionThicket:256:256:314:0", "FirewingPoint:385:512:617:149", "GrangolvarVilliage:512:256:143:171", "RaastokGlade:256:256:505:154", "RazorthornShelf:256:256:478:19", "RefugeCaravan:128:256:316:268", "RingofObservance:256:256:310:345", "SethekkTomb:256:256:245:289", "ShattrathCity:512:512:104:4", "SkethylMountains:512:320:449:348", "SmolderingCaravan:256:208:321:460", "StonebreakerHold:256:256:397:165", "TheBarrierHills:256:256:116:4", "Tuurem:256:512:455:34", "VeilRhaze:256:256:222:362", "WrithingMound:256:256:417:327",},
				["Zangarmarsh"] = {"AngoroshGrounds:256:256:88:50", "AngoroshStronghold:256:128:124:0", "BloodscaleEnclave:256:256:596:412", "CenarionRefuge:308:256:694:321", "CoilfangReservoir:256:512:462:90", "FeralfenVillage:512:336:314:332", "MarshlightLake:256:256:81:152", "OreborHarborage:256:512:329:25", "QuaggRidge:256:343:141:325", "Sporeggar:512:256:20:202", "Telredor:256:512:569:112", "TheDeadMire:286:512:716:128", "TheHewnBog:256:512:219:51", "TheLagoon:256:256:512:303", "TheSpawningGlen:256:256:31:339", "TwinspireRuins:256:256:342:249", "UmbrafenVillage:256:207:720:461", "ZabraJin:256:256:175:232",},

				-- Northrend
				["BoreanTundra"] = {"AmberLedge:244:214:325:140", "BorGorokOutpost:396:203:314:0", "Coldarra:460:381:50:0", "DeathsStand:289:279:707:181", "GarroshsLanding:267:378:153:238", "Kaskala:385:316:509:214", "RiplashStrand:382:258:293:383", "SteeljawsCaravan:244:319:397:66", "TempleCityOfEnKilah:290:292:712:15", "TheDensOfDying:203:209:662:11", "TheGeyserFields:375:342:480:0", "TorpsFarm:186:276:272:237", "ValianceKeep:259:302:457:264", "WarsongStronghold:260:278:329:237",},
				["CrystalsongForest"] = {"ForlornWoods:544:668:129:0", "SunreaversCommand:446:369:536:40", "TheAzureFront:416:424:0:244", "TheDecrepitFlow:288:222:0:0", "TheGreatTree:252:260:0:91", "TheUnboundThicket:502:477:500:105", "VioletStand:264:303:0:176", "WindrunnersOverlook:558:285:444:383",},
				["Dragonblight"] = {"AgmarsHammer:236:218:258:203", "Angrathar:306:242:210:0", "ColdwindHeights:213:219:403:0", "EmeraldDragonshrine:196:218:543:362", "GalakrondsRest:258:225:433:118", "IcemistVillage:235:337:134:165", "LakeIndule:356:300:217:313", "LightsRest:299:278:703:7", "Naxxramas:311:272:691:160", "NewHearthglen:214:261:614:358", "ObsidianDragonshrine:304:203:256:104", "RubyDragonshrine:188:211:374:208", "ScarletPoint:235:354:569:7", "TheCrystalVice:229:259:487:0", "TheForgottenShore:301:286:698:332", "VenomSpite:226:212:661:264", "WestwindRefugeeCamp:229:299:42:187", "WyrmrestTemple:317:353:453:219",},
				["GrizzlyHills"] = {"AmberpineLodge:278:290:217:244", "BlueSkyLoggingGrounds:249:235:232:129", "CampOneqwah:324:265:548:137", "ConquestHold:332:294:17:307", "DrakilJinRuins:351:284:607:41", "DrakTheronKeep:382:285:0:46", "DunArgol:455:400:547:257", "GraniteSprings:356:224:7:207", "GrizzleMaw:294:227:358:187", "RageFangShrine:475:362:312:294", "ThorModan:329:246:509:0", "UrsocsDen:328:260:331:32", "VentureBay:274:207:18:461", "Voldrune:283:247:176:421",},
				["HowlingFjord"] = {"AncientLift:177:191:342:351", "ApothecaryCamp:263:265:99:37", "BaelgunsExcavationSite:244:305:621:327", "Baleheim:174:173:576:170", "CampWinterHoof:223:209:354:0", "CauldrosIsle:181:178:490:161", "EmberClutch:213:256:283:203", "ExplorersLeagueOutpost:232:216:585:336", "FortWildervar:251:192:490:0", "GiantsRun:298:306:572:0", "Gjalerbron:242:189:225:0", "Halgrind:187:263:397:208", "IvaldsRuin:193:201:668:223", "Kamagua:333:265:99:278", "NewAgamand:284:308:415:360", "Nifflevar:178:208:595:240", "ScalawagPoint:350:258:168:410", "Skorn:238:232:343:108", "SteelGate:222:168:222:100", "TheTwistedGlade:266:210:420:57", "UtgardeKeep:248:382:477:216", "VengeanceLanding:223:338:664:25", "WestguardKeep:347:220:90:180",},
				["IcecrownGlacier"] = {"Aldurthar:373:375:355:37", "ArgentTournamentGround:314:224:616:30", "Corprethar:308:212:342:392", "IcecrownCitadel:308:202:392:466", "Jotunheim:393:474:22:122", "OnslaughtHarbor:204:268:0:167", "Scourgeholme:245:239:690:267", "SindragosasFall:300:343:626:31", "TheBombardment:248:243:538:181", "TheBrokenFront:283:231:558:329", "TheConflagration:227:210:327:305", "TheFleshwerks:219:283:218:291", "TheShadowVault:223:399:321:15", "Valhalas:238:240:217:50", "ValleyofEchoes:269:217:715:390", "Ymirheim:223:207:444:276",},
				["SholazarBasin"] = {"KartaksHold:329:293:76:375", "RainspeakerCanopy:207:235:427:244", "RiversHeart:468:329:359:339", "TheAvalanche:322:265:596:92", "TheGlimmeringPillar:294:327:308:34", "TheLifebloodPillar:312:369:501:134", "TheMakersOverlook:233:286:705:236", "TheMakersPerch:249:248:172:135", "TheMosslightPillar:239:313:265:355", "TheSavageThicket:293:229:396:51", "TheStormwrightsShelf:268:288:138:58", "TheSuntouchedPillar:455:316:82:186",},
				["TheStormPeaks"] = {"BorsBreath:322:195:109:375", "BrunnhildarVillage:305:298:339:370", "DunNiffelem:309:383:481:285", "EngineoftheMakers:210:179:316:296", "Frosthold:244:220:134:429", "GarmsBane:184:191:395:470", "NarvirsCradle:180:239:214:144", "Nidavelir:221:200:108:206", "SnowdriftPlains:205:232:162:143", "SparksocketMinefield:251:200:242:468", "TempleofLife:182:270:570:113", "TempleofStorms:169:164:239:301", "TerraceoftheMakers:363:341:292:122", "Thunderfall:306:484:627:179", "Ulduar:369:265:218:0", "Valkyrion:228:158:98:318",},
				["ZulDrak"] = {"AltarOfHarKoa:265:257:533:345", "AltarOfMamToth:311:317:575:88", "AltarOfQuetzLun:261:288:607:251", "AltarOfRhunok:247:304:431:127", "AltarOfSseratus:237:248:288:168", "AmphitheaterOfAnguish:266:254:289:287", "DrakSotraFields:286:265:326:358", "GunDrak:336:297:629:0", "Kolramas:302:231:380:437", "LightsBreach:321:305:181:363", "ThrymsEnd:272:268:0:247", "Voltarus:218:291:174:191", "Zeramas:307:256:7:412", "ZimTorga:249:258:479:241",},

				-- Cataclysm
				["Deepholm"] = {"CrimsonExpanse:462:400:540:12", "DeathwingsFall:454:343:549:297", "NeedlerockChasm:378:359:20:0", "NeedlerockSlag:370:285:0:146", "ScouredReach:516:287:448:0", "StoneHearth:371:354:0:314", "StormsFuryWreckage:292:285:458:383", "TempleOfEarth:355:345:287:177", "ThePaleRoost:467:273:85:0", "TherazanesThrone:274:156:434:0", "TheShatteredField:430:230:141:438", "TwilightOverlook:411:248:570:420", "TwilightTerrace:237:198:297:384",},
				["Kezan"] = {"BilgewaterPort:694:290:163:148", "Drudgetown:351:301:180:367", "FirstbankofKezan:376:343:98:325", "GallywixsVilla:303:452:0:41", "Kajamine:354:360:586:308", "KajaroField:250:307:383:260", "KezanMap:1002:664:0:4", "SwindleStreet:168:213:317:232",},
				["TheLostIsles"] = {"Alliancebeachhead:177:172:129:348", "BilgewaterLumberyard:248:209:462:43", "GallywixDocks:173:180:351:21", "HordeBaseCamp:222:190:244:458", "KTCOilPlatform:156:142:433:11", "landingSite:142:133:377:359", "Lostpeak:350:517:581:21", "OoomlotVillage:221:211:508:345", "Oostan:210:258:492:161", "RaptorRise:168:205:416:368", "RuinsOfVashelan:212:216:440:452", "ScorchedGully:305:288:323:185", "ShipwreckShore:172:175:189:408", "SkyFalls:190:186:416:131", "TheSavageGlen:231:216:213:325", "TheSlavePits:212:193:279:68", "WarchiefsLookout:159:230:264:144",},
				["VashjirDepths"] = {"AbandonedReef:371:394:50:263", "AbyssalBreach:491:470:497:0", "ColdlightChasm:267:374:266:280", "DeepfinRidge:363:262:275:32", "FireplumeTrench:298:251:315:110", "KorthunsEnd:370:385:412:283", "LGhorek:306:293:162:210", "Seabrush:225:250:415:183",},
				["VashjirKelpForest"] = {"DarkwhisperGorge:220:189:528:228", "GnawsBoneyard:311:217:451:325", "GubogglesLedge:227:207:399:280", "HoldingPens:316:267:456:401", "HonorsTomb:291:206:380:43", "LegionsFate:278:315:210:35", "TheAccursedReef:340:225:365:162",},
				["VashjirRuins"] = {"BethMoraRidge:335:223:407:445", "GlimmeringdeepGorge:272:180:270:222", "Nespirah:286:269:460:261", "RuinsOfTherseral:197:223:554:175", "RuinsOfVashjir:349:361:217:268", "ShimmeringGrotto:339:278:400:0", "SilverTideHollow:480:319:150:32",},

				-- Pandaria
				["DreadWastes"] = {"KLAXXIVESS:236:206:458:110", "ZANVESS:290:283:162:385", "BREWGARDEN:250:218:351:0", "DREADWATERLAKE:322:211:437:313", "CLUTCHESOFSHEKZEER:209:318:341:125", "HORRIDMARCH:323:194:441:224", "BRINYMUCK:325:270:214:311", "SOGGYSGAMBLE:268:241:450:406", "TERRACEOFGURTHAN:209:234:593:92", "RIKKITUNVILLAGE:218:186:236:32", "HEARTOFFEAR:262:293:191:122", "KYPARIVOR:325:190:485:0",},
				["Krasarang"] = {"RedwingRefuge:212:265:317:63", "AnglersOutpost:265:194:545:205", "TempleOfTheRedCrane:219:259:300:215", "DojaniRiver:190:282:513:3", "krasarangCove:286:268:701:19", "TheDeepwild:188:412:397:59", "LostDynasty:217:279:589:27", "FallsongRiver:214:393:218:77", "TheSouthernIsles:252:313:23:267", "ZhusBastion:306:204:612:0", "RuinsOfDojan:204:383:444:44", "TheForbiddenJungle:257:300:0:79", "RuinsOfKorja:211:395:125:88", "CradleOfChiJi:272:250:176:376", "UngaIngoo:258:170:330:498", "NayeliLagoon:246:240:343:373",},
				["KunLaiSummit"] = {"BinanVillage:240:198:607:470", "Mogujia:253:208:462:411", "MuskpawRanch:229:262:603:313", "MountNeverset:313:208:228:264", "ZouchinVillage:298:219:502:64", "TempleoftheWhitetiger:250:260:587:170", "GateoftheAugust:261:162:449:506", "ShadoPanMonastery:385:385:88:92", "TheBurlapTrail:310:276:398:310", "PeakOfSerenity:287:277:333:63", "ValleyOfEmperors:224:241:453:191", "Kotapeak:252:257:233:360", "Iseoflostsouls:259:233:602:4", "FireboughNook:224:172:322:496", "TEMPLEOFTHEWHITETIGER:250:260:587:170",},
				["TheHiddenPass"] = {"TheHiddenCliffs:294:220:433:0", "TheBlackMarket:479:493:371:175", "TheHiddenSteps:290:191:412:477",},
				["TheJadeForest"] = {"GlassfinVillage:278:310:525:358", "RuinsOfGanShi:196:158:316:0", "TheArboretum:242:210:481:215", "WindlessIsle:251:348:539:43", "DawnsBlossom:234:210:325:178", "TempleOfTheJadeSerpent:264:211:468:295", "DreamersPavillion:218:148:474:520", "NectarbreezeOrchard:219:256:290:330", "HellscreamsHope:196:166:181:75", "SlingtailPits:179:180:428:416", "SerpentsSpine:191:216:388:299", "ChunTianMonastery:227:198:300:56", "JadeMines:236:142:400:146", "EmperorsOmen:202:204:430:21", "GrookinMound:253:229:182:214", "WreckOfTheSkyShark:210:158:202:0", "Waywardlanding:219:186:346:482", "NookaNooka:219:205:189:151",},
				["TheWanderingIsle"] = {"TheDawningValley:677:668:325:0", "TempleofFiveDawns:607:461:395:182", "MandoriVillage:610:374:392:294", "RidgeofLaughingWinds:313:321:183:198", "Pei-WuForest:651:262:351:406", "PoolofthePaw:220:188:297:324", "SkyfireCrash-Site:346:263:124:405", "TheRows:385:373:504:295", "TheSingingPools:372:475:545:12", "MorningBreezeVillage:261:315:203:36", "Fe-FangVillage:234:286:134:9", "TheWoodofStaves:989:466:13:202",},
				["TownlongWastes"] = {"NiuzaoTemple:296:359:213:241", "ShanzeDao:300:246:125:0", "TheSumprushes:271:205:545:369", "Sikvess:261:235:306:433", "GaoRanBlockade:353:200:546:468", "MingChiCrossroads:247:221:417:447", "palewindVillage:282:306:692:362", "OsulMesa:238:296:560:185", "ShadoPanGarrison:213:170:413:385", "KriVess:255:269:420:209", "SriVess:294:283:92:192",},
				["ValeofEternalBlossoms"] = {"GuoLaiRuins:337:349:87:3", "WhiteMoonShrine:298:262:482:10", "MistfallVillage:310:305:200:363", "SettingSunTraining:350:429:0:234", "TuShenBurialGround:267:308:349:316", "TheStairsAscent:446:359:556:267", "WinterboughGlade:361:333:4:107", "TheGoldenStair:242:254:328:16", "WhitepetalLake:267:281:278:170", "TheTwinMonoliths:272:522:444:97", "MoguShanPalace:373:385:629:22",},
				["ValleyoftheFourWinds"] = {"ThunderfootFields:380:317:622:0", "PoolsofPurity:213:246:513:58", "RumblingTerrace:277:245:582:301", "PaoquanHollow:273:246:12:105", "StormsoutBrewery:257:288:227:380", "DustbackGorge:209:308:0:343", "CliffsofDispair:510:264:215:404", "Theheartland:286:392:253:75", "SilkenFields:254:259:530:253", "HarvestHome:260:251:5:239", "GildedFan:208:292:438:41", "GrandGranery:314:212:334:325", "SingingMarshes:175:291:170:130", "ZhusDecent:303:323:699:114", "Halfhill:206:245:438:177", "NesingwarySafari:249:342:104:326", "MudmugsPlace:230:217:561:161", "KuzenVillage:199:304:224:74",},
			
			}

			-- Initialise counters
			local createdtex = 0
			local texcount = 0

			-- Create local texture table
			local MapTex = {}

			-- Map refresh function
			local function RefMap()

				if texcount > 0 then
					for i = 1, texcount do
						MapTex[i]:Hide()
					end
					texcount = 0; 
				end

				-- Get current map
				local filename, texheight, void, void, sub = GetMapInfo()
				if sub then return end
				if not filename then return end

				local texpath = format([[Interface\WorldMap\%s\]], filename)
				local zone = LeaPlusMapData[filename] or {}

				-- Create new textures for current map
				for travnum, num in next, zone do
					local tname, texwidth, texheight, offsetx, offsety = strsplit(":", num)
					local texturename = texpath .. tname
					--if filename == "Gilneas" then aa,bb,cc,dd,ee,ff,gg = GetMapOverlayInfo(travnum); print(aa,bb,cc,dd,ee,ff,gg); end
					local numtexwide, numtextall = math.ceil(texwidth / 256), math.ceil(texheight / 256)

					-- Work out how many textures are needed to fill the map
					local neededtex = texcount + numtextall * numtexwide

					-- Create the textures
					if neededtex > createdtex then
						for j = createdtex + 1, neededtex do
							MapTex[j] = WorldMapDetailFrame:CreateTexture(nil, "ARTWORK")
						end
						createdtex = neededtex
					end

					-- Process textures
					for j = 1, numtextall do
						local texturepxheight, texturefileheight
						if j < numtextall then
							texturepxheight = 256
							texturefileheight = 256
						else
							texturepxheight = texheight % 256
							if texturepxheight == 0 then
								texturepxheight = 256
							end
							texturefileheight = 16
							while texturefileheight < texturepxheight do
								texturefileheight = texturefileheight * 2
							end
						end

						for k = 1, numtexwide do
							if texcount > createdtex then return end
							texcount = texcount + 1
							local texture = MapTex[texcount]
							local texturepxwidth
							local texturefilewidth
							if k < numtexwide then
								texturepxwidth = 256
								texturefilewidth = 256
							else
								texturepxwidth = texwidth % 256
								if texturepxwidth == 0 then
									texturepxwidth = 256
								end
								texturefilewidth = 16
								while texturefilewidth < texturepxwidth do
									texturefilewidth = texturefilewidth * 2
								end
							end 
							texture:SetWidth(texturepxwidth)
							texture:SetHeight(texturepxheight)
							texture:SetTexCoord(0, texturepxwidth/texturefilewidth, 0, texturepxheight/texturefileheight)
							texture:ClearAllPoints()						  
							texture:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", offsetx + (256 * (k-1)), -(offsety + (256 * (j - 1))))
							texture:SetTexture(texturename..(((j - 1) * numtexwide) + k))
							texture:Show()
						end
					end 
				end
			end

			-- Create reveal checkbox
			LeaPlusCB["MapRevealBox"] = CreateFrame('CheckButton', nil, WorldMapPositioningGuide, "OptionsCheckButtonTemplate")
			LeaPlusCB["MapRevealBox"]:SetHitRectInsets(0, -42, 0, 0);
			LeaPlusCB["MapRevealBox"]:SetSize(24, 24)
			LeaPlusCB["MapRevealBox"]:SetPoint("BOTTOMLEFT", WorldMapPositioningGuide, "BOTTOMLEFT", 100, 4)

			LeaPlusCB["MapRevealBox.f"] = LeaPlusCB["MapRevealBox"]:CreateFontString(nil, 'OVERLAY', "GameFontNormal")
			LeaPlusCB["MapRevealBox.f"]:SetPoint("LEFT", 24, 0)
			LeaPlusCB["MapRevealBox.f"]:SetText("Reveal")
			LeaPlusCB["MapRevealBox.f"]:Show();

			LeaPlusCB["MapRevealBox"].tiptext = "If checked, unexplored areas of the map will be shown."
			LeaPlusCB["MapRevealBox"]:SetScript("OnEnter", LeaPlusLC.ShowFacetip)

			-- Handle clicks
			LeaPlusCB["MapRevealBox"]:SetScript("OnClick", function()
				if LeaPlusCB["MapRevealBox"]:GetChecked() == 1 then
					LeaPlusLC["MapRevealBox"] = "On"
					if WorldMapFrame:IsShown() then
						RefMap()
					end
				else
					LeaPlusLC["MapRevealBox"] = "Off"
					if texcount > 0 then
						for i = 1, texcount do MapTex[i]:Hide()	end
						texcount = 0
					end
				end
			end)

			-- Set checkbox state
			LeaPlusCB["MapRevealBox"]:SetScript("OnShow", function()
				if LeaPlusLC["MapRevealBox"] == "On" then LeaPlusCB["MapRevealBox"]:SetChecked(true) else LeaPlusCB["MapRevealBox"]:SetChecked(false) end
			end)

			-- Update map
			hooksecurefunc("WorldMapFrame_Update", function()
				if WorldMapFrame:IsShown() and LeaPlusLC["MapRevealBox"] == "On" then
					RefMap();
				end
			end)

			----------------------------------------------------------------------
			-- Quest details
			----------------------------------------------------------------------

			local function ShowQuestDetails()
				QuestLogDetailFrame:ClearAllPoints()
				if LeaPlusLC["MapQuestLeft"] == "On" then
					QuestLogDetailFrame:SetPoint("TOPRIGHT", WorldMapFrame, "TOPLEFT", -10, 0)
				else
					QuestLogDetailFrame:SetPoint("TOPLEFT", WorldMapFrame, "TOPRIGHT", 10, 0)
				end
				QuestLogDetailFrame:Show()
			end

			-- Hook POI clicking function to show quest detail frame
			hooksecurefunc("WorldMapQuestPOI_OnClick", function(self)
				if IsControlKeyDown() or LeaPlusLC["MapQuestBox"] == "On" then
					if not IsShiftKeyDown() then
						-- Get the quest log index position of the button that was clicked
						local cquest = self.quest.questLogIndex
						--local cid = self.quest.questId
						if cquest then
							-- Hide detail frame if quest hasn't changed (toggle)
							if cquest == GetQuestLogSelection() then
								if QuestLogDetailFrame:IsShown() then
									QuestLogDetailFrame:Hide();
									return
								end
							end
							-- Select the entry in the log
							SelectQuestLogEntry(cquest);
							-- Show and hide the quest log (forced update)
							if not QuestLogFrame:IsShown() then QuestLogFrame:Show();QuestLogFrame:Hide(); end
							-- Show the detail frame
							ShowQuestDetails();
						end
					end
				end
			end)

			-- Create quest detail checkbox
			LeaPlusCB["MapQuestBox"] = CreateFrame('CheckButton', nil, WorldMapPositioningGuide, "OptionsCheckButtonTemplate")
			LeaPlusCB["MapQuestBox"]:SetHitRectInsets(0, -42, 0, 0);
			LeaPlusCB["MapQuestBox"]:SetSize(24, 24)
			LeaPlusCB["MapQuestBox"]:SetPoint("BOTTOMLEFT", WorldMapPositioningGuide, "BOTTOMLEFT", 210, 4)

			LeaPlusCB["MapQuestBox.f"] = LeaPlusCB["MapQuestBox"]:CreateFontString(nil, 'OVERLAY', "GameFontNormal")
			LeaPlusCB["MapQuestBox.f"]:SetPoint("LEFT", 24, 0)
			LeaPlusCB["MapQuestBox.f"]:SetText("Details")
			LeaPlusCB["MapQuestBox.f"]:Show();

			-- When the map is closed, the quest detail should close too
			LeaPlusCB["MapQuestBox"]:SetScript("OnHide", function() 
				QuestLogDetailFrame:Hide(); 
			end)

			-- Handle clicks
			LeaPlusCB["MapQuestBox"]:SetScript("OnClick", function()
				if LeaPlusCB["MapQuestBox"]:GetChecked() == 1 then
					LeaPlusLC["MapQuestBox"] = "On"
				else
					LeaPlusLC["MapQuestBox"] = "Off"
				end
			end)

			-- Set checkbox state
			LeaPlusCB["MapQuestBox"]:SetScript("OnShow", function()
				if LeaPlusLC["MapQuestBox"] == "On" then
					LeaPlusCB["MapQuestBox"]:SetChecked(true)
				else
					LeaPlusCB["MapQuestBox"]:SetChecked(false)
				end
			end)

			LeaPlusCB["MapQuestBox"].tiptext = "If checked, clicking on quest objectives will automatically show the quest details.\n\nIf unchecked, the quest details can be shown individually by holding down CTRL while clicking a quest objective."
			LeaPlusCB["MapQuestBox"]:SetScript("OnEnter", LeaPlusLC.ShowFacetip)

			----------------------------------------------------------------------
			-- Cursor coordinates
			----------------------------------------------------------------------

			-- Create cursor coordinates frame (map)
			local Cmap = CreateFrame("FRAME", nil, WorldMapFrame)
			Cmap:SetWidth(38);	Cmap:SetHeight(16);
			Cmap:SetPoint("TOPLEFT", 16, -3)

			Cmap.x = Cmap:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall") 
			Cmap.x:SetAllPoints(); Cmap.x:SetJustifyH"LEFT";

			Cmap.y = Cmap:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall") 
			Cmap.y:SetPoint("LEFT", Cmap.x, "RIGHT", -16, 0);
			Cmap.y:SetJustifyH"LEFT";

			-- Initialise variables
			local vmapx, vmapy = 0, 0
			local mtimer = 0

			-- Cursor coordinates update function
			local function UpdateCursorCoords(self, elapsed)

				mtimer = mtimer + elapsed;

				while (mtimer > 0.1) do

					-- Show cursor coordinates
					local scale = WorldMapDetailFrame:GetEffectiveScale()
					local width = WorldMapDetailFrame:GetWidth()
					local height = WorldMapDetailFrame:GetHeight()
					local cenx, ceny = WorldMapDetailFrame:GetCenter()
					local x, y = GetCursorPosition()
					local vmapx = (x / scale - (cenx - (width/2))) / width
					local vmapy = (ceny + (height/2) - y / scale) / height		

					if (vmapx >= 0  and vmapy >= 0 and vmapx <=1 and vmapy <=1) then
						Cmap.x:SetText(format("%0.1f", (floor(vmapx * 1000 + 0.5)) / 10))
						Cmap.y:SetText("   " .. format("%0.1f", (floor(vmapy * 1000 + 0.5)) / 10))
					end

					mtimer = 0;

				end

			end

			-- Function to toggle cursor coordinates (run on startup and when option is clicked)
			local function RefreshCursorCoords()
				if LeaPlusLC["CursorCoords"] == "On" then
					Cmap:Show();
					Cmap:SetScript("OnUpdate", UpdateCursorCoords)
				else
					Cmap:Hide();
					Cmap:SetScript("OnUpdate", nil)
				end
			end

			----------------------------------------------------------------------
			-- Map modification functions (scale, opacity, position)
			----------------------------------------------------------------------

			-- Set map position
			local function RefreshMapPos()
				WorldMapFrame:ClearAllPoints();
				WorldMapFrame:SetPoint(LeaPlusLC["MapA"], LeaPlusLC["MapX"], LeaPlusLC["MapY"])
				WorldMapScreenAnchor:ClearAllPoints()
				WorldMapScreenAnchor:StartMoving();
				WorldMapScreenAnchor:SetPoint("TOPLEFT", WorldMapFrame);
				WorldMapScreenAnchor:StopMovingOrSizing();
				WorldMapFrame:SetUserPlaced(false)
				WorldMapScreenAnchor:SetUserPlaced(false)
			end
	
			-- Refresh the map with changes
			local function RefreshMapMod()
				WorldMapFrame:SetScale(tostring(LeaPlusLC["LeaPlusMapScale"]))
				WorldMapFrame_SetOpacity(LeaPlusLC["LeaPlusMapOpacity"])
				WORLDMAP_SETTINGS.opacity = LeaPlusLC["LeaPlusMapOpacity"];
				SetCVar("worldMapOpacity", LeaPlusLC["LeaPlusMapOpacity"]);
				if LeaPlusLC["MapLock"] == "On" then
					WORLDMAP_SETTINGS.locked = true
					SetCVar("lockedWorldMap", 1);
				else
					WORLDMAP_SETTINGS.locked = false
					SetCVar("lockedWorldMap", 0);
				end
			end

			-- Save map position after dragging it
			WorldMapTitleButton:HookScript("OnDragStop", function()
				LeaPlusLC["MapA"], void, void, LeaPlusLC["MapX"], LeaPlusLC["MapY"] = WorldMapFrame:GetPoint()
				WorldMapFrame:SetUserPlaced(false)
				WorldMapScreenAnchor:SetUserPlaced(false)
			end)

			-- Remove existing context menu (else it gets confusing)
			WorldMapTitleButton:RegisterForClicks("LeftButton")

			----------------------------------------------------------------------
			-- Map Panel
			----------------------------------------------------------------------

			-- Create map panel
			local SideMap = LeaPlusLC:CreateSidePanel("World Map", 164, 270)

			-- Add scale slider
			LeaPlusLC:MakeTx(SideMap, "Map Scale", 10, -60)
			LeaPlusLC:MakeSL(SideMap, "LeaPlusMapScale", "", 0.5, 2.0, 0.05, 10, -80, "%.2f")
			LeaPlusCB["LeaPlusMapScale"]:HookScript("OnValueChanged", RefreshMapMod)
			LeaPlusCB["LeaPlusMapScale"]:HookScript("OnMouseUp", ToggleMapSafe)
			LeaPlusCB["LeaPlusMapScale"]:HookScript("OnMouseWheel", ToggleMapSafe)

			-- Add opacity slider
			LeaPlusLC:MakeTx(SideMap, "Map Opacity", 10, -110)
			LeaPlusLC:MakeSL(SideMap, "LeaPlusMapOpacity", "", 0.0, 1.0, 0.1, 10, -130, "%.1f")
			LeaPlusCB["LeaPlusMapOpacity"]:HookScript("OnValueChanged", RefreshMapMod)

			-- Add cursor coordinates checkbox
			LeaPlusLC:MakeCB(SideMap, "CursorCoords", "Show cursor coords", 10, -160, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["CursorCoords"], "If checked, cursor coordinates will be shown at the topleft of the world map.")
			LeaPlusCB["CursorCoords"]:HookScript("OnClick", RefreshCursorCoords)

			-- Add lock checkbox
			LeaPlusLC:MakeCB(SideMap, "MapLock", "Lock map position", 10, -180, "")
			LeaPlusCB["MapLock"]:HookScript("OnClick", RefreshMapMod)
			LeaPlusLC:AddLeftTip(LeaPlusCB["MapLock"], "If checked, the world map frame position will be locked and you will not be able to move it.\n\nIf unchecked, you will be able to move the map by dragging the title bar.  The map cannot be moved during combat.")

			-- Add quest details left side checkbox
			LeaPlusLC:MakeCB(SideMap, "MapQuestLeft", "Quests on left", 10, -200, "")
			LeaPlusLC:AddLeftTip(LeaPlusCB["MapQuestLeft"], "If checked, quest details will be shown on the left side of the map instead of the right.")
			LeaPlusCB["MapQuestLeft"]:HookScript("OnClick", function()
				RefreshMapMod();
				if QuestLogDetailFrame:IsShown() then ShowQuestDetails() end
			end)

			-- Create save button
			LeaPlusLC:CreateButton("SaveMapBtn", SideMap, "Save", "BOTTOMLEFT", 10, 10, 70, 25, "")
			LeaPlusCB["SaveMapBtn"]:SetScript("OnClick", function()
				SideMap:Hide();
				if WorldMapFrame:IsShown() then MiniMapWorldMapButton:Click(); end
				LeaPlusLC["PageF"]:Show(); LeaPlusLC["Page6"]:Show();
			end)

			-- Create reset button
			LeaPlusLC:CreateButton("ResetMapBtn", SideMap, "Reset", "BOTTOMLEFT", 80, 10, 70, 25, "")
			LeaPlusCB["ResetMapBtn"]:SetScript("OnClick", function()
				LeaPlusLC["LeaPlusMapScale"] = "1.0"
				LeaPlusLC["LeaPlusMapOpacity"] = "0.0"
				LeaPlusLC["MapLock"] = "Off"
				LeaPlusLC["MapA"] = "TOPLEFT"
				LeaPlusLC["MapX"] = 10
				LeaPlusLC["MapY"] = -118
				LeaPlusLC["MapQuestLeft"] = "Off"
				LeaPlusLC["CursorCoords"] = "On"
				RefreshMapMod();
				RefreshMapPos();
				ToggleMapSafe();
				RefreshCursorCoords();
				SideMap:Hide(); SideMap:Show();
			end)

			-- Hide controls during combat
			SideMap:RegisterEvent("PLAYER_REGEN_DISABLED")
			SideMap:SetScript("OnEvent", SideMap.Hide)
						
			----------------------------------------------------------------------
			-- World map modification
			----------------------------------------------------------------------

			-- Create modify button on world map
			LeaPlusCB["MapOptBtn"]:HookScript("OnClick", function()
				if LeaPlusLC:PlayerInCombat() then
					return
				else
					if IsShiftKeyDown() and IsControlKeyDown() then

						-- Top secret profile (ssh!)
						LeaPlusLC["LeaPlusMapScale"] = "1.75"
						LeaPlusLC["LeaPlusMapOpacity"] = "0.0"
						LeaPlusLC["MapLock"] = "Off"
						LeaPlusLC["MapA"] = "TOPLEFT"
						LeaPlusLC["MapX"] = 0
						LeaPlusLC["MapY"] = 0
						LeaPlusLC["CursorCoords"] = "On"
						LeaPlusLC["MapQuestLeft"] = "Off"
						RefreshMapMod();
						RefreshMapPos();
						RefreshCursorCoords();
						ToggleMapSafe();

					else

						LeaPlusLC:HideFrames();
						SideMap:Show();
						if not WorldMapFrame:IsShown() then MiniMapWorldMapButton:Click(); end

					end
				end
			end)
			WorldMapFrameSizeUpButton:Disable(); -- WorldMapFrameSizeUpButton:Hide(); -- Hide the sizing button

			-- Prevent map movement during combat
			local LeaPlusIsMapLocked
			LeaPlusCB["MapRevealBox"]:RegisterEvent("PLAYER_REGEN_DISABLED")
			LeaPlusCB["MapRevealBox"]:RegisterEvent("PLAYER_REGEN_ENABLED")
			LeaPlusCB["MapRevealBox"]:SetScript("OnEvent", function(self,event)
				if event == "PLAYER_REGEN_DISABLED" then
					WorldMapFrame:StopMovingOrSizing();
					LeaPlusIsMapLocked = WORLDMAP_SETTINGS.locked
					WORLDMAP_SETTINGS.locked = true
				else
					if LeaPlusIsMapLocked == false then
						WORLDMAP_SETTINGS.locked = LeaPlusIsMapLocked
					end
				end
			end)

			-- Preshow the map box to set initial values
			SideMap:Show(); SideMap:Hide();

			-- Set map position on startup
			RefreshMapPos();

			-- Set the map scale
			RefreshMapMod();

			-- Set cursor coordinates
			RefreshCursorCoords();

			----------------------------------------------------------------------
			-- World map checkboxes
			----------------------------------------------------------------------

			-- Set checkbox layout (set position and remove tooltips)
			WorldMapTrackQuest:ClearAllPoints();
			WorldMapTrackQuest:SetPoint("BOTTOMLEFT", WorldMapPositioningGuide, "BOTTOMLEFT", 10, 4)
			WorldMapTrackQuest:SetHitRectInsets(0, -34, 0, 0);
			WorldMapTrackQuest.tiptext = "If checked, the currently selected quest will be tracked and added to the watch list."
			WorldMapTrackQuest:SetScript("OnEnter", LeaPlusLC.ShowFacetip)
			WorldMapTrackQuest:SetScript("OnLeave", LeaPlusLC.HideTooltip)
			WorldMapTrackQuestText:SetText("Track")

			WorldMapShowDigSites:ClearAllPoints();
			WorldMapShowDigSites:SetPoint("BOTTOMLEFT", WorldMapPositioningGuide, "BOTTOMLEFT", 320, 4)
			WorldMapShowDigSites.tiptext = "If checked, archaeological digsites will be shown on the map."
			WorldMapShowDigSites:SetScript("OnEnter", LeaPlusLC.ShowFacetip)
			WorldMapShowDigSites:SetScript("OnLeave", LeaPlusLC.HideTooltip)
			WorldMapShowDigSites:SetHitRectInsets(0, -50, 0, 0);
			WorldMapShowDigSitesText:SetText("Digsites")

			WorldMapQuestShowObjectives:ClearAllPoints();
			WorldMapQuestShowObjectives:SetPoint("BOTTOMLEFT", WorldMapPositioningGuide, "BOTTOMLEFT", 440, 4)
			WorldMapQuestShowObjectives.tiptext = "If checked, quest objectives will be shown on the map."
			WorldMapQuestShowObjectives:SetScript("OnEnter", LeaPlusLC.ShowFacetip)
			WorldMapQuestShowObjectives:SetScript("OnLeave", LeaPlusLC.HideTooltip)
			WorldMapQuestShowObjectives:SetHitRectInsets(0, -66, 0, 0);
			WorldMapQuestShowObjectivesText:SetText("Objectives")

			-- Prevent Blizzard from moving the objectives checkbox (oh dear...)
			function WorldMapQuestShowObjectives_AdjustPosition() return end

			WorldMapZoneMinimapDropDown:SetScript("OnEnter", nil);

		end

		-- Show volume control on character sheet
		if LeaPlusLC["ShowVolume"] == "On" then

			-- Function to update master volume
			local function MasterVolUpdate()
				if LeaPlusLC["ShowVolume"] == "On" then
					-- Set the volume
					SetCVar("Sound_MasterVolume", LeaPlusLC["LeaPlusMaxVol"]);
					-- Format the slider text
					LeaPlusCB["LeaPlusMaxVol"].f:SetText(format("%.0f", LeaPlusLC["LeaPlusMaxVol"]*10))
				end
			end

			-- Create slider control
			LeaPlusLC["LeaPlusMaxVol"] = tonumber(GetCVar("Sound_MasterVolume"));
			LeaPlusLC:MakeSL(CharacterModelFrame, "LeaPlusMaxVol", "",	0, 1, 0.05, -34, -328, "%.2f")
			LeaPlusCB["LeaPlusMaxVol"]:SetWidth(64);

			-- Set slider control value when shown
			LeaPlusCB["LeaPlusMaxVol"]:SetScript("OnShow", function()
				LeaPlusCB["LeaPlusMaxVol"]:SetValue(GetCVar("Sound_MasterVolume"))
			end)

			-- Update volume when slider control is changed
			LeaPlusCB["LeaPlusMaxVol"]:HookScript("OnValueChanged", MasterVolUpdate);

			-- Dual layout
			local function SetVolumePlacement()
				if LeaPlusLC["ShowVolumeInFrame"] == "On" then
					LeaPlusCB["LeaPlusMaxVol"]:ClearAllPoints();
					LeaPlusCB["LeaPlusMaxVol"]:SetPoint("TOPLEFT", 72, -276)
				else
					LeaPlusCB["LeaPlusMaxVol"]:ClearAllPoints();
					LeaPlusCB["LeaPlusMaxVol"]:SetPoint("TOPLEFT", -34, -328)
				end
			end

			LeaPlusCB["LeaPlusMaxVol"]:SetScript('OnMouseDown', function(self, btn)
				if btn == "RightButton" and IsShiftKeyDown() then
					if LeaPlusLC["ShowVolumeInFrame"] == "On" then LeaPlusLC["ShowVolumeInFrame"] = "Off" else LeaPlusLC["ShowVolumeInFrame"] = "On" end
					SetVolumePlacement();
				end
			end)

			CharacterModelFrame:HookScript("OnShow",function()
				SetVolumePlacement();
			end)

		end

		-- Hide chat buttons
		if LeaPlusLC["NoChatButtons"] == "On" then

			-- Function to add CTRL key and SHIFT key modifiers mousescroll functionality
			local function AddChatModKeys(chtfrm)
				_G[chtfrm]:HookScript("OnMouseWheel", function(self, direction)
					if IsControlKeyDown() then
						if direction == 1 then self:ScrollToTop() else self:ScrollToBottom() end
					elseif IsShiftKeyDown() then 
						if direction == 1 then self:PageUp() else self:PageDown() end
					end
				end)
			end

			-- Function to hide chat buttons
			local function HideButtons(chtfrm)
				_G[chtfrm .. "ButtonFrameUpButton"].Show = function() return nil; end;
				_G[chtfrm .. "ButtonFrameDownButton"].Show = function() return nil; end;
				_G[chtfrm .. "ButtonFrameMinimizeButton"].Show = function() return nil; end;
				_G[chtfrm .. "ButtonFrameUpButton"]:Hide();
				_G[chtfrm .. "ButtonFrameDownButton"]:Hide();
				_G[chtfrm .. "ButtonFrameMinimizeButton"]:Hide();
				_G[chtfrm .. "ButtonFrame"]:SetSize(0.1,0.1)
			end

			-- Function to highlight chat tabs, unclamp chat frame, click to scroll to bottom
			local function HighlightTabs(chtfrm)
				-- Set position of bottom button
				_G[chtfrm .. "ButtonFrameBottomButtonFlash"]:SetTexture("Interface/BUTTONS/GRADBLUE.png")
				_G[chtfrm .. "ButtonFrameBottomButton"]:ClearAllPoints()
				_G[chtfrm .. "ButtonFrameBottomButton"]:SetPoint("BOTTOM",_G[chtfrm .. "Tab"],0,-6)
				_G[chtfrm .. "ButtonFrameBottomButton"]:Show()
				_G[chtfrm .. "ButtonFrameBottomButtonFlash"]:SetAlpha(0.5)
				_G[chtfrm .. "ButtonFrameBottomButton"]:SetWidth(_G[chtfrm .. "Tab"]:GetWidth()-10)
				_G[chtfrm .. "ButtonFrameBottomButton"]:SetHeight(24)

				-- Resize bottom button according to tab size
				_G[chtfrm .. "Tab"]:SetScript("OnSizeChanged", function()
					for j = 1, NUM_CHAT_WINDOWS, 1 do
						_G["ChatFrame" .. j .. "ButtonFrameBottomButton"]:SetWidth(_G["ChatFrame" .. j .. "Tab"]:GetWidth()-10)
					end
				end)

				-- Remove click from the bottom button
				_G[chtfrm .. "ButtonFrameBottomButton"]:SetScript("OnClick", nil)

				-- Remove textures
				_G[chtfrm .. "ButtonFrameBottomButton"]:SetNormalTexture("")
				_G[chtfrm .. "ButtonFrameBottomButton"]:SetHighlightTexture("")
				_G[chtfrm .. "ButtonFrameBottomButton"]:SetPushedTexture("")

				-- Unclamp chat frame
				_G[chtfrm]:SetClampedToScreen(false);

				-- Always scroll to bottom when clicking a tab
				_G[chtfrm .. "Tab"]:HookScript("OnClick", function(self,arg1)
					if arg1 == "LeftButton" then
						_G[chtfrm]:ScrollToBottom();
					end
				end)

			end

			-- Enable mouse scrolling and prevent changes
			SetCVar("chatMouseScroll", "1")
			InterfaceOptionsSocialPanelChatMouseScroll:Disable()
			InterfaceOptionsSocialPanelChatMouseScrollText:SetAlpha(0.3)
			InterfaceOptionsSocialPanelChatMouseScroll_SetScrolling("1")

			-- Set whisper mode to inline and lock Blizzard options
			SetCVar("whisperMode", "inline")
			InterfaceOptionsSocialPanelWhisperModeButton:Disable()
			InterfaceOptionsSocialPanelWhisperModeText:SetAlpha(0.0)
			InterfaceOptionsSocialPanelWhisperMode.tooltip = "Whispers are set to inline and are controlled by Leatrix Plus."

			-- Set Real ID mode to inline and lock Blizzard options
			SetCVar("bnWhisperMode", "inline")
			InterfaceOptionsSocialPanelBnWhisperModeButton:Disable()
			InterfaceOptionsSocialPanelBnWhisperModeText:SetAlpha(0.0)
			InterfaceOptionsSocialPanelBnWhisperMode.tooltip = "Real ID whispers are set to inline and are controlled by Leatrix Plus."

			-- Set Real ID conversation mode and lock Blizzard options
			SetCVar("conversationMode", "inline")
			InterfaceOptionsSocialPanelConversationModeButton:Disable()
			InterfaceOptionsSocialPanelConversationModeText:SetAlpha(0.0)
			InterfaceOptionsSocialPanelConversationMode.tooltip = "Real ID conversation mode is set to inline and are controlled by Leatrix Plus."

			-- Hide outer chat frame buttons
			ChatFrameMenuButton.Show = function() return nil; end;
			ChatFrameMenuButton:Hide();
			FriendsMicroButton.Show = function() return nil; end;
			FriendsMicroButton:Hide();

			-- Add chat menu to the middle mouse button
			ChatMenu:ClearAllPoints()
			ChatMenu:SetPoint("TOP", ChatFrame1Tab, "BOTTOM", 0, 0)
			ChatMenu.ClearAllPoints = function() end
			ChatMenu.SetPoint = function() end
			ChatFrame1Tab:HookScript("OnMouseDown", function(self, arg1)
				if arg1 == "MiddleButton" then
					if ChatMenu:IsShown() then
						ChatMenu:Hide();
					else
						ChatMenu:Show();
					end
				end
			end)

			-- Set options for normal chat frames
			for i = 1, NUM_CHAT_WINDOWS, 1 do
				AddChatModKeys("ChatFrame" .. i);
				HideButtons("ChatFrame" .. i);
				HighlightTabs("ChatFrame" .. i)
			end

			-- Do the functions above for the pet battle chat frame too
			hooksecurefunc("FCF_OpenTemporaryWindow", function(chatType)
				if chatType == "PET_BATTLE_COMBAT_LOG" then
					local cf = FCF_GetCurrentChatFrame():GetName()
					-- Set options for pet battle chat frame
					AddChatModKeys(cf);
					HideButtons(cf)
					HighlightTabs(cf)
					-- Resize pet battle flashing alert to match tab width
					_G[cf .. "Tab"]:SetScript("OnSizeChanged", function()
						_G[cf .. "ButtonFrameBottomButton"]:SetWidth(_G[cf .. "Tab"]:GetWidth()-10)
					end)
				end
			end)

		end

		----------------------------------------------------------------------
		-- L24: Frame Customisation
		----------------------------------------------------------------------

		-- Frame Movement
		if LeaPlusLC["FrmEnabled"] == "On" then

			-- Lock the player and target frames
			PlayerFrame_SetLocked(true)
			TargetFrame_SetLocked(true)

			-- Remove integrated movement functions to avoid conflicts
			PlayerFrame_ResetUserPlacedPosition = function() LeaPlusLC:Print("Please use Leatrix Plus to reset the player frame.") end
			TargetFrame_ResetUserPlacedPosition = function() LeaPlusLC:Print("Please use Leatrix Plus to reset the target frame.") end
			PlayerFrame_SetLocked = function() LeaPlusLC:Print("Please use Leatrix Plus to move the player frame.") end
			TargetFrame_SetLocked = function() LeaPlusLC:Print("Please use Leatrix Plus to move the target frame.") end

			-- Create frame table (used for local traversal)
			local FrameTable = {DragPlayerFrame = PlayerFrame, DragTargetFrame = TargetFrame, DragWorldStateAlwaysUpFrame = WorldStateAlwaysUpFrame, DragGhostFrame = GhostFrame, DragMirrorTimer1 = MirrorTimer1};

			-- Create main table structure in saved variables if it doesn't exist
			if (LeaPlusDB["Frames"]) == nil then
				LeaPlusDB["Frames"] = {}
			end

			-- Create frame based table structure in saved variables if it doesn't exist and set initial scales
			for k,v in pairs(FrameTable) do
				local vf = v:GetName();
				-- Create frame table structure if it doesn't exist
				if not LeaPlusDB["Frames"][vf] then
					LeaPlusDB["Frames"][vf] = {}
				end
				-- Set saved scale value to default if it doesn't exist
				if not LeaPlusDB["Frames"][vf]["Scale"] then
					LeaPlusDB["Frames"][vf]["Scale"] = 1.00;
				end
				-- Set frame scale to saved value
				_G[vf]:SetScale(LeaPlusDB["Frames"][vf]["Scale"])
			end

			-- Set cached status
			local function LeaPlusFramesSaveCache(frame)
				if frame == "PlayerFrame" or frame == "TargetFrame" then
					_G[frame]:SetUserPlaced(true);
				else
					_G[frame]:SetUserPlaced(false);
				end
			end

			-- Set frames to manual values
			local function LeaFramesSetPos(frame, point, parent, relative, xoff, yoff)
				frame:SetMovable(true);
				frame:ClearAllPoints();
				frame:SetPoint(point, parent, relative, xoff, yoff)
			end

			-- Set frames to default values
			local function LeaPlusFramesDefaults()
				LeaFramesSetPos(PlayerFrame				, "TOPLEFT"	, UIParent, "TOPLEFT"	, -19, -4)
				LeaFramesSetPos(TargetFrame				, "TOPLEFT"	, UIParent, "TOPLEFT"	, 250, -4)
				LeaFramesSetPos(WorldStateAlwaysUpFrame	, "TOP"		, UIParent, "TOP"		, -5, -15)
				LeaFramesSetPos(GhostFrame				, "TOP"		, UIParent, "TOP"		, -5, -29)
				LeaFramesSetPos(MirrorTimer1			, "TOP"		, UIParent, "TOP"		, -5, -96)
			end

			-- Create frame customisation side panel
			local SideFrames = LeaPlusLC:CreateSidePanel("Frames", 164, 270)

			-- Create frame checkboxes
			local function LeaPlusFramesCB(name, x, y, frame, text)
				LeaPlusCB[name] = CreateFrame('CheckButton', nil, SideFrames, 'ChatConfigCheckButtonTemplate')
				LeaPlusCB[name]:SetPoint("TOPLEFT", x, y)
				LeaPlusCB[name]:SetHitRectInsets(0, -70, 0, 0);

				-- Checkbox labels
				LeaPlusCB[name].t = LeaPlusCB[name]:CreateFontString(nil, "BACKGROUND", "GameTooltipText") 
					LeaPlusCB[name].t:SetPoint("LEFT",30,0) 
					LeaPlusCB[name].t:SetText(text)

				-- Process clicks
				LeaPlusCB[name]:SetScript('OnClick', function(self)
					if LeaPlusCB[name]:GetChecked() == nil then LeaPlusLC[frame]:Hide(); end
					if LeaPlusCB[name]:GetChecked() == 1 then LeaPlusLC[frame]:Show(); end					
				end)

				-- Set default checkbox state
				SideFrames:HookScript("OnShow", function() 
					LeaPlusCB[name]:SetChecked(true)
				end)
			end

			-- Create checkboxes
			LeaPlusFramesCB("ChkPlayerFrame"			, 10, -60, 	"DragPlayerFrame"				, "Player frame")
			LeaPlusLC:AddLeftTip(LeaPlusCB["ChkPlayerFrame"], "Click to toggle the player frame overlay.\n\nToggling the overlay frames is useful if you wish to access frames that are underneath.")

			LeaPlusFramesCB("ChkTargetFrame"			, 10, -80,  "DragTargetFrame"				, "Target frame")
			LeaPlusLC:AddLeftTip(LeaPlusCB["ChkTargetFrame"], "Click to toggle the target frame overlay.\n\nToggling the overlay frames is useful if you wish to access frames that are underneath.")

			LeaPlusFramesCB("ChkWorldStateAlwaysUpFrame", 10, -100, "DragWorldStateAlwaysUpFrame"	, "World state")
			LeaPlusLC:AddLeftTip(LeaPlusCB["ChkWorldStateAlwaysUpFrame"], "Click to toggle the world state frame overlay.\n\nThe world state frame is most commonly used for keeping score (such as in battlegrounds).\n\nToggling the overlay frames is useful if you wish to access frames that are underneath.")

			LeaPlusFramesCB("ChkGhostFrame"				, 10, -120,	"DragGhostFrame"				, "Ghost frame")
			LeaPlusLC:AddLeftTip(LeaPlusCB["ChkGhostFrame"], "Click to toggle the ghost frame overlay.\n\nThe ghost frame appears when your character is a ghost.  It allows you to return to the spirit healer.\n\nToggling the overlay frames is useful if you wish to access frames that are underneath.")

			LeaPlusFramesCB("ChkMirrorTimer1"			, 10, -140,	"DragMirrorTimer1"				, "Timer bar")
			LeaPlusLC:AddLeftTip(LeaPlusCB["ChkMirrorTimer1"], "Click to toggle the mirror timer bar overlay.\n\nThe mirror timer bar is used for various activities such as underwater breathing.\n\nNote that not all timer bars use this frame.\n\nToggling the overlay frames is useful if you wish to access frames that are underneath.")

			-- Variable used to store currently selected frame
			local currentframe

			-- Create scale title
			LeaPlusLC:MakeTx(SideFrames, "Selected Frame Scale", 10, -180)
			
			-- Set initial slider value (will be changed when drag frames are selected)
			LeaPlusLC["FrameScale"] = 1.00;

			-- Create scale slider
			LeaPlusLC:MakeSL(SideFrames, "FrameScale", "", 0.5, 3.0, 0.05, 10, -200, "%.2f")
			LeaPlusCB["FrameScale"]:HookScript("OnValueChanged", function(self, value)
				if currentframe then -- If a frame is selected
					-- Set real and drag frame scale
					LeaPlusDB["Frames"][currentframe]["Scale"] = value;
					_G[currentframe]:SetScale(LeaPlusDB["Frames"][currentframe]["Scale"]);
					LeaPlusLC["Drag" .. currentframe]:SetScale(LeaPlusDB["Frames"][currentframe]["Scale"]);
					-- If target frame scale is changed, also change combo point frame
					if currentframe == "TargetFrame" then
						ComboFrame:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"]);
					end
				end
			end)

			-- Set initial scale slider state and value
			LeaPlusCB["FrameScale"]:HookScript("OnShow", function()
				if not currentframe then
					-- No frame selected so select the player frame
					currentframe = PlayerFrame:GetName()
					LeaPlusLC["DragPlayerFrame"].t:SetTexture(0.0, 1.0, 0.0,0.5)
				end
				-- Set the scale slider value to the selected frame
				LeaPlusCB["FrameScale"]:SetValue(LeaPlusDB["Frames"][currentframe]["Scale"]);
			end)

			-- Create save button
			LeaPlusLC:CreateButton("SaveFramesBtn", SideFrames, "Save", "BOTTOMLEFT", 10, 10, 70, 25, "")
			LeaPlusCB["SaveFramesBtn"]:SetScript("OnClick", function()
				-- Hide outer control frame
				SideFrames:Hide();
				-- Hide drag frames
				for k, void in pairs(FrameTable) do
					LeaPlusLC[k]:Hide();
				end
				-- Show options panel at frame section
				LeaPlusLC["PageF"]:Show();
				LeaPlusLC["Page6"]:Show();
			end)

			-- Create reset button
			LeaPlusLC:CreateButton("ResetFramesBtn", SideFrames, "Reset", "BOTTOMLEFT", 80, 10, 70, 25, "")
			LeaPlusCB["ResetFramesBtn"]:SetScript("OnClick", function()
				if LeaPlusLC:PlayerInCombat() then
					-- If player is in combat, print error and stop
					return
				else
					-- Set frames to default positions (presets)
					LeaPlusFramesDefaults();
					for k,v in pairs(FrameTable) do
						local vf = v:GetName()
						-- Store frame locations
						LeaPlusDB["Frames"][vf]["Point"], void, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"] = _G[vf]:GetPoint();
						-- Reset real frame scales and save them
						LeaPlusDB["Frames"][vf]["Scale"] = 1.00;
						_G[vf]:SetScale(LeaPlusDB["Frames"][vf]["Scale"]);
						-- Reset drag frame scales
						LeaPlusLC[k]:SetScale(LeaPlusDB["Frames"][vf]["Scale"]);
					end
					-- Set combo frame scale to match target frame scale
					ComboFrame:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"]);
					-- Set the scale slider value to the selected frame scale
					LeaPlusCB["FrameScale"]:SetValue(LeaPlusDB["Frames"][currentframe]["Scale"]);
				end
			end)

			-- Save frame positions
			local function SaveAllFrames()
				for k, v in pairs(FrameTable) do
					local vf = v:GetName();
					-- Stop real frames from moving
					v:StopMovingOrSizing();
					-- Save frame positions
					LeaPlusDB["Frames"][vf]["Point"], void, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"] = v:GetPoint();
					LeaPlusFramesSaveCache(vf)
				end
			end

			-- Prevent changes during combat (we don't want taint from rescaling protected frames during combat, do we?)
			SideFrames:RegisterEvent("PLAYER_REGEN_DISABLED")
			SideFrames:SetScript("OnEvent", function()
				-- Hide controls frame
				SideFrames:Hide();
				-- Hide drag frames
				for k,void in pairs(FrameTable) do
					LeaPlusLC[k]:Hide();
				end
				-- Save frame positions
				SaveAllFrames();
			end)

			-- Create drag frames
			local function LeaPlusMakeDrag(dragframe,realframe)

				local dragframe = CreateFrame("Frame", nil);
				LeaPlusLC[dragframe] = dragframe
				dragframe:SetSize(realframe:GetSize())
				dragframe:SetPoint("TOP", realframe, "TOP", 0, 2.5)

				dragframe:SetBackdropColor(0.0, 0.5, 1.0);
				dragframe:SetBackdrop({ 
					edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
					tile = false, tileSize = 0, edgeSize = 16,
					insets = { left = 0, right = 0, top = 0, bottom = 0 }});
				dragframe:SetToplevel(true)

				-- Clamp frame to screen (except player frame)
				if realframe:GetName() ~= "PlayerFrame" then
					realframe:SetClampedToScreen(true)
				end

				dragframe:Hide()
				realframe:SetMovable(true);

				-- Click handler
				dragframe:SetScript("OnMouseDown", function(self, btn)

					-- Start dragging if left clicked
					if btn == "LeftButton" then
						realframe:StartMoving()
					end

					-- Set all drag frames to blue then tint the selected frame to green
					for k,v in pairs(FrameTable) do
						LeaPlusLC[k].t:SetTexture(0.0, 0.5, 1.0,0.5)
					end
					dragframe.t:SetTexture(0.0, 1.0, 0.0,0.5)

					-- Set currentframe variable to selected frame and set the scale slider value
					currentframe = realframe:GetName();
					LeaPlusCB["FrameScale"]:SetValue(LeaPlusDB["Frames"][currentframe]["Scale"]);

				end)

				dragframe:SetScript("OnMouseUp", function()
					-- Save frame positions
					SaveAllFrames();
				end)
	
				dragframe.t = dragframe:CreateTexture()
				dragframe.t:SetAllPoints()
				dragframe.t:SetTexture(0.0, 0.5, 1.0,0.5)
				dragframe.t:SetAlpha(0.5)

				dragframe.f = dragframe:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
				dragframe.f:SetPoint('CENTER', 0, 0)

				-- Add titles
				if realframe:GetName() == "PlayerFrame" 			then dragframe.f:SetText("Player") end
				if realframe:GetName() == "TargetFrame" 			then dragframe.f:SetText("Target") end
				if realframe:GetName() == "WorldStateAlwaysUpFrame" then dragframe.f:SetText("World State") end
				if realframe:GetName() == "MirrorTimer1" 			then dragframe.f:SetText("Timer") end
				if realframe:GetName() == "GhostFrame" 				then dragframe.f:SetText("Ghost") end
				return LeaPlusLC[dragframe]

			end
			
			for k,v in pairs(FrameTable) do
				LeaPlusLC[k] = LeaPlusMakeDrag(k,v)
			end

			-- Set frame scales
			for k,v in pairs(FrameTable) do
				local vf = v:GetName();
				_G[vf]:SetScale(LeaPlusDB["Frames"][vf]["Scale"]);
				LeaPlusLC[k]:SetScale(LeaPlusDB["Frames"][vf]["Scale"]);
			end
			ComboFrame:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"]);

			-- Load defaults first then overwrite with saved values if they exist
			LeaPlusFramesDefaults();
			if LeaPlusDB["Frames"] then
				for k,v in pairs(FrameTable) do
					local vf = v:GetName()
					if LeaPlusDB["Frames"][vf] then
						if LeaPlusDB["Frames"][vf]["Point"] and LeaPlusDB["Frames"][vf]["Relative"] and LeaPlusDB["Frames"][vf]["XOffset"] and LeaPlusDB["Frames"][vf]["YOffset"] then
							LeaPlusFramesSaveCache(vf)
							_G[vf]:ClearAllPoints();
							_G[vf]:SetPoint(LeaPlusDB["Frames"][vf]["Point"], UIParent, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"])
						end
					end
				end
			end

			-- Add move button
			LeaPlusCB["MoveFramesButton"]:SetScript("OnClick", function()
				if LeaPlusLC:PlayerInCombat() then
					return
				else
					-- Top secret frame profile (ssh!)
					if (IsShiftKeyDown()) and (IsControlKeyDown()) then
						-- Manual profile
						LeaFramesSetPos(PlayerFrame				, "TOPLEFT"	, UIParent, "TOPLEFT"	,	"-35"	, "-14")
						LeaFramesSetPos(TargetFrame				, "TOPLEFT"	, UIParent, "TOPLEFT"	,	"190"	, "-14")
						LeaFramesSetPos(GhostFrame				, "CENTER"	, UIParent, "CENTER"	,	"3"		, "-142")
						LeaFramesSetPos(WorldStateAlwaysUpFrame	, "TOP"		, UIParent, "TOP"		,	"-40"	, "-530")
						LeaFramesSetPos(MirrorTimer1			, "TOP"		, UIParent, "TOP"		,	"0"		, "-120")
						LeaPlusDB["Frames"]["PlayerFrame"]["Scale"] = 1.20;
						PlayerFrame:SetScale(LeaPlusDB["Frames"]["PlayerFrame"]["Scale"]);
						LeaPlusLC["DragPlayerFrame"]:SetScale(LeaPlusDB["Frames"]["PlayerFrame"]["Scale"]);
						LeaPlusDB["Frames"]["TargetFrame"]["Scale"] = 1.20;
						TargetFrame:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"]);
						LeaPlusLC["DragTargetFrame"]:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"]);
						-- Save locations
						for k,v in pairs(FrameTable) do
							local vf = v:GetName();
							LeaPlusDB["Frames"][vf]["Point"], void, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"] = _G[vf]:GetPoint();
							LeaPlusFramesSaveCache(vf);
						end
					else
						-- Show mover frame
						SideFrames:Show();
						LeaPlusLC:HideFrames();

						-- Find out if the UI has a non-standard scale
						if GetCVar("useuiscale") == "1" then
							LeaPlusLC["gscale"] = GetCVar("uiscale")
						else
							LeaPlusLC["gscale"] = 1
						end

						-- Set all scaled sizes and show drag frames
						for k,v in pairs(FrameTable) do
							LeaPlusLC[k]:SetWidth(v:GetWidth() * LeaPlusLC["gscale"])
							LeaPlusLC[k]:SetHeight(v:GetHeight() * LeaPlusLC["gscale"])
							LeaPlusLC[k]:Show();
						end

						-- Set specific scaled sizes for stubborn frames
						LeaPlusLC["DragWorldStateAlwaysUpFrame"]:SetSize(300 * LeaPlusLC["gscale"], 50 * LeaPlusLC["gscale"]);
						LeaPlusLC["DragMirrorTimer1"]:SetSize(206 * LeaPlusLC["gscale"], 50 * LeaPlusLC["gscale"]);
						LeaPlusLC["DragGhostFrame"]:SetSize(130 * LeaPlusLC["gscale"], 46 * LeaPlusLC["gscale"]);
					end
				end
			end)
		end
	end

----------------------------------------------------------------------
--	L25: Player (only runs once)
----------------------------------------------------------------------

	function LeaPlusLC:Player()

		-- Privacy options (achievement points)
		if LeaPlusDB["AchieveControl"] == "On" then -- Checks global
			local function DoPrivacy()
				if LeaPlusLC["CharOnlyAchieves"] == "On" then
					ShowAccountAchievements(true);
				else
					ShowAccountAchievements(false);
				end
				InterfaceOptionsPanel_CheckButton_Update(InterfaceOptionsDisplayPanelShowAccountAchievments);
				InterfaceOptionsDisplayPanelShowAccountAchievments.text:SetText("Privacy controlled by Leatrix Plus")
				LeaPlusLC:LockItem(InterfaceOptionsDisplayPanelShowAccountAchievments, true);
			end
			DoPrivacy(); -- Set privacy checkbox on startup if privacy control is enabled
			LeaPlusCB["CharOnlyAchieves"]:HookScript("OnClick", DoPrivacy); -- Set when option is changed
		end

		-- Manage camera zoom level
		if LeaPlusDB["ManageZoomLevel"] == "On" then -- Checks global
			-- Update the saved CVAR when the slider value changes
			LeaPlusCB["ZoomOutLevel"]:HookScript("OnValueChanged", function()
				SetCVar("CameraDistanceMax", LeaPlusLC["ZoomOutLevel"])
				CameraZoomOut(0)
			end)
			-- Set the zoom setting on startup
			SetCVar("CameraDistanceMax", LeaPlusLC["ZoomOutLevel"])
			SetCVar("cameraDistanceMaxFactor", "1")
			InterfaceOptionsCameraPanelMaxDistanceSlider:Disable();
			-- Hook reset and wipe buttons
			LeaPlusCB["WipeAllButton"]:HookScript("OnClick", function()
				SetCVar("CameraDistanceMax", "15");
			end)
			LeaPlusCB["SetDefaultsButton"]:HookScript("OnClick", function()
				SetCVar("CameraDistanceMax", "15");
			end)

		end

		-- Save group roles per spec
		if LeaPlusLC["RoleSave"] == "On" then

			-- Create global tables if needed
			LeaPlusDC["RoleSave"] = LeaPlusDC["RoleSave"] or {};
			LeaPlusDC["RoleSave"]["Spec1"] = LeaPlusDC["RoleSave"]["Spec1"] or {};
			LeaPlusDC["RoleSave"]["Spec2"] = LeaPlusDC["RoleSave"]["Spec2"] or {};
			local LFGset = {LEADER, TANK, HEALER, DAMAGER}
			local specsaver = {"primary spec", "secondary spec"}

			-- Print currently selected roles
			local function ShowActiveRoles()
				if LeaPlusLC:IsDualSpec() then
					local newrole = " "
					for k,v in pairs(LFGset) do 
						if select(k, GetLFGRoles()) == true then newrole = newrole .. LFGset[k] .. ", "	end
					end
					if newrole == " " then newrole = " No roles selected" else newrole = strsub(newrole,1,-3) end
					LeaPlusLC:Print("|TInterface\\ICONS\\LEVELUPICON-LFD:0|t Roles:" .. newrole);
				end
			end

			-- Set button state
			local function UpdateSaveRolesButton()
				local CurrentSpec = "Spec" .. GetActiveSpecGroup();
				local LeadRole, TankRole, HealerRole, DamagerRole = GetLFGRoles()
				if LeaPlusDC["RoleSave"][CurrentSpec]["Leader"] == LeadRole and LeaPlusDC["RoleSave"][CurrentSpec]["Tank"] == TankRole and LeaPlusDC["RoleSave"][CurrentSpec]["Healer"] == HealerRole and LeaPlusDC["RoleSave"][CurrentSpec]["Damager"] == DamagerRole then
					LeaPlusCB["SaveLFGRole"]:SetEnabled(false);
				else
					LeaPlusCB["SaveLFGRole"]:SetEnabled(true);
				end
			end

			-- Create button and handler scripts
			LeaPlusLC:CreateButton("SaveLFGRole", GroupFinderFrame, "Save Roles", "BOTTOMLEFT", 60, 10, 100, 25, "")
			LeaPlusCB["SaveLFGRole"]:SetScript("OnClick", function()
				-- You click the save button, so save the selected roles
				local CurrentSpec = "Spec" .. GetActiveSpecGroup();
				LeaPlusDC["RoleSave"][CurrentSpec]["Leader"], LeaPlusDC["RoleSave"][CurrentSpec]["Tank"], LeaPlusDC["RoleSave"][CurrentSpec]["Healer"], LeaPlusDC["RoleSave"][CurrentSpec]["Damager"] = GetLFGRoles();
				UpdateSaveRolesButton();
				LeaPlusLC:Print("Your selected roles have been saved to your " .. specsaver[GetActiveSpecGroup()] .. ".")
			end)

			LeaPlusCB["SaveLFGRole"].tiptext = "Click to save your selected group roles to your current talent spec.\n\nYour saved roles will be selected automatically when you switch specs."
			LeaPlusCB["SaveLFGRole"]:SetScript("OnEnter", LeaPlusLC.ShowFacetip)

			LeaPlusCB["SaveLFGRole"]:SetScript("OnShow", function()
				-- Update the save button whenever it's shown
				UpdateSaveRolesButton();
			end)

			LeaPlusCB["SaveLFGRole"]:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
			LeaPlusCB["SaveLFGRole"]:RegisterEvent("LFG_ROLE_UPDATE")
			LeaPlusCB["SaveLFGRole"]:SetScript("OnEvent", function(self,event)
				if event == "LFG_ROLE_UPDATE" then
					-- Your role has changed, update the save button
					UpdateSaveRolesButton();
				elseif event == "ACTIVE_TALENT_GROUP_CHANGED" then
					-- Your talent spec has changed, set roles to saved values
					local CurrentSpec = "Spec" .. GetActiveSpecGroup();
					SetLFGRoles(LeaPlusDC["RoleSave"][CurrentSpec]["Leader"],LeaPlusDC["RoleSave"][CurrentSpec]["Tank"],LeaPlusDC["RoleSave"][CurrentSpec]["Healer"],LeaPlusDC["RoleSave"][CurrentSpec]["Damager"])
					ShowActiveRoles();
				end
			end)

			-- Set spec and show information on login
			if LeaPlusLC:IsDualSpec() then
				local CurrentSpec = "Spec" .. GetActiveSpecGroup();
				SetLFGRoles(LeaPlusDC["RoleSave"][CurrentSpec]["Leader"],LeaPlusDC["RoleSave"][CurrentSpec]["Tank"],LeaPlusDC["RoleSave"][CurrentSpec]["Healer"],LeaPlusDC["RoleSave"][CurrentSpec]["Damager"])
				LeaPlusLC:ShowActiveSpec();
				ShowActiveRoles();
			end
		end

		-- Set trade and guild locks
		if LeaPlusLC["ManageTradeGuild"] == "On" then

			-- Function to check or uncheck trade and guild options in Blizzard options panel
			local function TradeGuild()
				if LeaPlusLC["ManageTradeGuild"] == "On" then
					if LeaPlusLC["NoTradeRequests"] == "On" then
						InterfaceOptionsControlsPanelBlockTrades:SetValue("1");
					else
						InterfaceOptionsControlsPanelBlockTrades:SetValue("0");
					end
					if LeaPlusLC["NoGuildInvites"] == "On" then
						InterfaceOptionsControlsPanelBlockGuildInvites:SetValue("1");
					else
						InterfaceOptionsControlsPanelBlockGuildInvites:SetValue("0");
					end
				end
			end

			-- Set trade and guild checkboxes on startup and lock them to prevent confusion
			TradeGuild();
			InterfaceOptionsControlsPanelBlockTrades:Disable();
			InterfaceOptionsControlsPanelBlockGuildInvites:Disable();
			_G[InterfaceOptionsControlsPanelBlockTrades:GetName() .. 'Text']:SetText("Trade blocking is controlled by Leatrix Plus.")
			_G[InterfaceOptionsControlsPanelBlockTrades:GetName() .. 'Text']:SetAlpha(0.6)
			_G[InterfaceOptionsControlsPanelBlockGuildInvites:GetName() .. 'Text']:SetText("Guild invitation blocking is controlled by Leatrix Plus.")
			_G[InterfaceOptionsControlsPanelBlockGuildInvites:GetName() .. 'Text']:SetAlpha(0.3)

			-- Set trade and guild checkboxes when options are clicked in Leatrix Plus
			LeaPlusCB["NoTradeRequests"]:HookScript("OnClick", TradeGuild);
			LeaPlusCB["NoGuildInvites"]:HookScript("OnClick", TradeGuild);

		end

		-- Lock class color checkboxes in Blizzard options if manage class colors is enabled
		if LeaPlusLC["Manageclasscolors"] == "On" then
			for i=1, 18 do
				if _G["ChatConfigChatSettingsLeftCheckBox" .. i .. "Check"] then
					LeaPlusLC:LockItem(_G["ChatConfigChatSettingsLeftCheckBox" .. i .. "ColorClasses"],true)
				end
			end
		end

		-- Unregister the player section (since it only needs to be run once)
		LpEvt:UnregisterEvent("PLAYER_ENTERING_WORLD")

	end

----------------------------------------------------------------------
-- 	L26: BlizzDep (options which require Blizzard modules)
----------------------------------------------------------------------

	function LeaPlusLC:BlizzDep(module)

		if module == "Blizzard_AuctionUI" then

			----------------------------------------------------------------------
			-- Auction House Extras
			----------------------------------------------------------------------

			-- Auction House buyout only
			if LeaPlusLC["AhExtras"] == "On" then

				-- Change size of maximise buttons to make room for find button
				AuctionsStackSizeMaxButton:SetWidth(50); AuctionsStackSizeMaxButton:SetText("Max")
				AuctionsNumStacksMaxButton:SetWidth(50); AuctionsNumStacksMaxButton:SetText("Max")

				-- Functions
				local function CreateAuctionCB(name, anchor, x, y, text)
					LeaPlusCB[name] = CreateFrame("CheckButton", nil, AuctionFrameAuctions, "OptionsCheckButtonTemplate")
					LeaPlusCB[name]:SetFrameStrata("HIGH")
					LeaPlusCB[name]:SetHitRectInsets(0, 0, 0, 0);
					LeaPlusCB[name]:SetSize(20, 20)
					LeaPlusCB[name]:SetPoint(anchor, x, y)
					LeaPlusCB[name].f = LeaPlusCB[name]:CreateFontString(nil, 'OVERLAY', "GameFontNormal")
					LeaPlusCB[name].f:SetPoint("LEFT", 20, 0)
					LeaPlusCB[name].f:SetText(text)
					LeaPlusCB[name].f:Show();
					LeaPlusCB[name]:SetScript('OnClick', function()
						if LeaPlusCB[name]:GetChecked() == nil then
							LeaPlusLC[name] = "Off"
						elseif LeaPlusCB[name]:GetChecked() == 1 then
							LeaPlusLC[name] = "On"
						end
					end)
					LeaPlusCB[name]:SetScript('OnShow', function(self)
						self:SetChecked(LeaPlusLC[name])
					end)
				end

				-- Show the correct fields in the AH frame and match prices
				local function SetupAh()
					if LeaPlusLC["AhBuyoutOnly"] == "On" then
						-- Hide the start price
						StartPrice:SetAlpha(0);
						-- Set start price to buyout price 
						StartPriceGold:SetText(BuyoutPriceGold:GetText());
						StartPriceSilver:SetText(BuyoutPriceSilver:GetText());
						StartPriceCopper:SetText(BuyoutPriceCopper:GetText());
					else
						-- Show the start price
						StartPrice:SetAlpha(1);
					end
					-- If gold only is on, set copper and silver to 99
					if LeaPlusLC["AhGoldOnly"] == "On" then
						StartPriceCopper:SetText("99"); StartPriceCopper:Disable();
						StartPriceSilver:SetText("99"); StartPriceSilver:Disable();
						BuyoutPriceCopper:SetText("99"); BuyoutPriceCopper:Disable();
						BuyoutPriceSilver:SetText("99"); BuyoutPriceSilver:Disable();
					else
						StartPriceCopper:Enable();
						StartPriceSilver:Enable();
						BuyoutPriceCopper:Enable();
						BuyoutPriceSilver:Enable();
					end
					-- Validate the auction (mainly for the create auction button status)
					AuctionsFrameAuctions_ValidateAuction();
				end

				-- Create checkboxes
				CreateAuctionCB("AhBuyoutOnly", "BOTTOMLEFT", 200, 16, "Buyout Only")
				CreateAuctionCB("AhGoldOnly", "BOTTOMLEFT", 320, 16, "Gold Only")
				
				LeaPlusCB["AhBuyoutOnly"]:HookScript('OnClick', SetupAh);
				LeaPlusCB["AhBuyoutOnly"]:HookScript('OnShow', SetupAh);
	
				AuctionFrameAuctions:HookScript("OnShow", SetupAh)
				BuyoutPriceGold:HookScript("OnTextChanged", SetupAh)
				BuyoutPriceSilver:HookScript("OnTextChanged", SetupAh)
				BuyoutPriceCopper:HookScript("OnTextChanged", SetupAh)
				StartPriceGold:HookScript("OnTextChanged", SetupAh)
				StartPriceSilver:HookScript("OnTextChanged", SetupAh)
				StartPriceCopper:HookScript("OnTextChanged", SetupAh)
	
				-- Lock the create auction button if buyout gold box is empty (when using buyout only and gold only)
				AuctionsCreateAuctionButton:HookScript("OnEnable", function()
					if LeaPlusLC["AhGoldOnly"] == "On" and LeaPlusLC["AhBuyoutOnly"] == "On" then
						if BuyoutPriceGold:GetText() == "" then
							AuctionsCreateAuctionButton:Disable();
						end
					end
				end)
				
				-- Clear copper and silver prices if gold only box is unchecked
				LeaPlusCB["AhGoldOnly"]:HookScript('OnClick', function()
					if LeaPlusCB["AhGoldOnly"]:GetChecked() == nil then
						BuyoutPriceCopper:SetText("")
						BuyoutPriceSilver:SetText("")
						StartPriceCopper:SetText("")
						StartPriceSilver:SetText("")
					end
					SetupAh();
				end)

				-- Create find button
				LeaPlusLC:CreateButton("FindAuctionButton", AuctionFrameAuctions, "Find", "BOTTOMLEFT", 146, 246, 50, 21, "")
				LeaPlusCB["FindAuctionButton"]:SetFrameStrata("HIGH")
				LeaPlusCB["FindAuctionButton"]:SetScript("OnClick", function()
					if GetAuctionSellItemInfo() then
						local name = GetAuctionSellItemInfo()
						BrowseName:SetText(name)
						QueryAuctionItems(name)
						AuctionFrameTab1:Click();
					end
				end)

				-- Show find button when required (new item added or window shown)
				local function SetFindButton()
					if GetAuctionSellItemInfo() then 
						LeaPlusCB["FindAuctionButton"]:SetEnabled(true); 
					else 
						LeaPlusCB["FindAuctionButton"]:SetEnabled(false); 
					end; 
				end;

				AuctionFrameAuctions:HookScript("OnShow", function() 
					SetFindButton(); 
				end)
				AuctionsItemButton:HookScript("OnEvent", function(self,event)
					if event == "NEW_AUCTION_UPDATE" then
						SetFindButton(); 
					end
				end)

				-- Hide find button when Blizzard block frame is shown (respecting the Blizzard UI)
				AuctionsBlockFrame:HookScript("OnShow", function() LeaPlusCB["FindAuctionButton"]:Hide(); end)
				AuctionsBlockFrame:HookScript("OnHide", function() LeaPlusCB["FindAuctionButton"]:Show(); end)

				-- Clear the cursor and reset editboxes when a new item replaces an existing one
				hooksecurefunc("AuctionsFrameAuctions_ValidateAuction", function()
					if GetAuctionSellItemInfo() then
						-- Return anything you might be holding
						ClearCursor();
						-- Set copper and silver prices to 99 if gold mode is on
						if LeaPlusLC["AhGoldOnly"] == "On" then
							StartPriceCopper:SetText("99")
							StartPriceSilver:SetText("99")
							BuyoutPriceCopper:SetText("99")
							BuyoutPriceSilver:SetText("99")
						end
						-- Only clear the gold if its zero (otherwise it's a buyout price repeater)
						if tonumber(BuyoutPriceGold:GetText()) == 0 then
							StartPriceGold:SetText("")
							BuyoutPriceGold:SetText("")
						end
					end
				end)

			end

		elseif module == "Blizzard_CombatLog" then

			----------------------------------------------------------------------
			-- Move chat editbox to top (the combat log part)
			----------------------------------------------------------------------

			-- Move chat editbox to top
			if LeaPlusLC["MoveChatEditBoxToTop"] == "On" then

				-- Move the combat log quick button bar if combat log is showing
				if LeaPlusLC["NoCombatLogTab"] == "Off" then

					if ChatFrame2.isDocked then
						CombatLogQuickButtonFrame_Custom:ClearAllPoints()
						CombatLogQuickButtonFrame_Custom:SetPoint("TOPLEFT",  "ChatFrame2", "TOPLEFT", 0, 00)
						CombatLogQuickButtonFrame_Custom:SetPoint("TOPRIGHT", "ChatFrame2", "TOPRIGHT")
						CombatLogQuickButtonFrame_Custom:Hide();
					else
						CombatLogQuickButtonFrame_Custom:ClearAllPoints()
						CombatLogQuickButtonFrame_Custom:SetPoint("TOPLEFT",  "ChatFrame2", "TOPLEFT", 0, 25)
						CombatLogQuickButtonFrame_Custom:SetPoint("BOTTOMRIGHT", "ChatFrame2", "TOPRIGHT")
					end

					-- Reposition the quick button bar if combat log is docked/undocked
					hooksecurefunc("FCF_UnDockFrame", function(frame)
						if frame == COMBATLOG then 
							CombatLogQuickButtonFrame_Custom:ClearAllPoints()
							CombatLogQuickButtonFrame_Custom:SetPoint("TOPLEFT",  "ChatFrame2", "TOPLEFT", 0, 25)
							CombatLogQuickButtonFrame_Custom:SetPoint("BOTTOMRIGHT", "ChatFrame2", "TOPRIGHT")
						end
					end)

					hooksecurefunc("FCF_DockFrame", function(frame)
						if frame == COMBATLOG then 
							CombatLogQuickButtonFrame_Custom:ClearAllPoints()
							CombatLogQuickButtonFrame_Custom:SetPoint("TOPLEFT",  "ChatFrame2", "TOPLEFT", 0, 00)
							CombatLogQuickButtonFrame_Custom:SetPoint("TOPRIGHT", "ChatFrame2", "TOPRIGHT")
						end
					end)
		
				end

			end
	
		end

	end
	
----------------------------------------------------------------------
-- 	L30: RunOnce
----------------------------------------------------------------------

	function LeaPlusLC:RunOnce()

		-- Hide Leatrix Plus if Blizzard options are shown (else it gets confusing)
		InterfaceOptionsFrame:HookScript("OnShow", LeaPlusLC.HideFrames);
		VideoOptionsFrame:HookScript("OnShow", LeaPlusLC.HideFrames);

		-- Lock channel colors after channel table is shown
		if LeaPlusLC["Manageclasscolors"] == "On" then
			hooksecurefunc("ChatConfig_CreateCheckboxes", function(self, checkBoxTable, checkBoxTemplate, title)
				if ( ChatConfigChannelSettingsLeft.checkBoxTable ) then
					for i=1,50 do
						if _G["ChatConfigChannelSettingsLeftCheckBox" .. i .. "ColorClasses"] then
							LeaPlusLC:LockItem(_G["ChatConfigChannelSettingsLeftCheckBox" .. i .. "ColorClasses"],true)
						end
					end
				end
			end)
		end

		-- Set default button handler
		LeaPlusCB["SetDefaultsButton"]:SetScript("OnClick", function()
			if IsShiftKeyDown() and IsControlKeyDown() then
				for k,v in pairs(LeaPlusDB) do
					-- Don't reset tooltip settings
					if (string.sub(k, 0, 3) ~= "Tip")
					-- Don't reset frames settings
					and (string.sub(k, 0, 3) ~= "Frm") and k ~= "Frames" 
					-- Don't reset map modification settings
					and k ~= "ShowMapMod" and k ~= "LeaPlusMapScale" and k ~= "LeaPlusMapOpacity" and k ~= "MapQuestLeft" and k ~= "MapLock" and k ~= "MapA" and k ~= "MapX" and k ~= "MapY" and k ~= "CursorCoords"
					-- Don't reset viewport settings
					and k ~= "ViewPortEnable" and k ~= "ViewportResize" and k ~= "ViewPortTop" and k ~= "ViewPortBottom" and k ~= "ViewPortLeft" and k ~= "ViewPortRight"
					-- Don't reset privacy controls
					and k ~= "AchieveControl" and k ~= "CharOnlyAchieves"
					-- Don't reset static coordinates settings
					and k ~= "StaticCoordsEn" and k ~= "StaticCoords" and k ~= "StaticCoordsBack" and k ~= "StaticThrottle" and k ~= "StaticCoordsScale" and k ~= "StaticCoordsLock" and k ~= "StaticCoordsMap" and k ~= "StaticCoordsTop"
					-- Don't reset static coordinates location
					and k ~= "CoordsA" and k ~= "CoordsR" and k ~= "CoordsX" and k ~= "CoordsY"
					-- Don't reset minimap customisation
					and k ~= "MinimapMod" and k ~= "MergeTrackBtn" and k ~= "HideMinimapZone" and k ~= "HideMinimapTime" and k ~= "MinimapMouseZoom" and k ~= "MinimapScale"
					-- Reset everything else
					then
						if LeaPlusLC[k] then LeaPlusLC[k] = nil end
						if LeaPlusDB[k] then LeaPlusDB[k] = nil end
					end
				end
				ReloadUI();
			else
				LeaPlusLC:Print("You need to hold down CTRL and SHIFT while clicking this button.")
			end
		end)

		-- Wipe button handler
		LeaPlusCB["WipeAllButton"]:SetScript("OnClick", function()
			if (IsShiftKeyDown() and IsControlKeyDown()) then
				PlayerFrame:SetUserPlaced(false);
				TargetFrame:SetUserPlaced(false);
				wipe(LeaPlusDB)
				wipe(LeaPlusDC)
				LpEvt:UnregisterAllEvents(); -- Prevent PLAYER_LOGOUT from saving settings
				ReloadUI();
			else
				LeaPlusLC:Print("You need to hold down CTRL and SHIFT while clicking this button.")
			end
		end)

		----------------------------------------------------------------------
		-- Options panel scale
		----------------------------------------------------------------------

		-- Leatrix Plus options panel scale
		local function SetPlusScale()
			LeaPlusLC.PageF:ClearAllPoints()
			LeaPlusLC.PageF:SetPoint("CENTER",0,0)
			if LeaPlusLC["PlusPanelScaleCheck"] == "On" then
				LeaPlusLC["PageF"]:SetScale(LeaPlusLC.LeaPlusScaleValue)
			else
				LeaPlusLC["PageF"]:SetScale(1.00)
			end
		end

		-- Set scale on startup
		SetPlusScale();

		-- Set scale after changing slider or checkbox
		LeaPlusCB["LeaPlusScaleValue"]:HookScript("OnMouseUp", SetPlusScale);
		LeaPlusCB["LeaPlusScaleValue"]:HookScript("OnMouseWheel", SetPlusScale);
		LeaPlusCB["PlusPanelScaleCheck"]:HookScript("OnClick", SetPlusScale);

		----------------------------------------------------------------------
		-- Options panel alpha
		----------------------------------------------------------------------

		-- Leatrix Plus options panel alpha
		local function SetPlusAlpha()
			if LeaPlusLC["PlusPanelAlphaCheck"] == "On" then
				LeaPlusLC["PageF"].t:SetAlpha(LeaPlusLC["LeaPlusAlphaValue"])
			else
				LeaPlusLC["PageF"].t:SetAlpha(1.0)
			end
		end

		-- Set alpha on startup
		SetPlusAlpha();

		-- Set alpha after changing slider or checkbox
		LeaPlusCB["LeaPlusAlphaValue"]:HookScript("OnValueChanged", SetPlusAlpha);
		LeaPlusCB["PlusPanelAlphaCheck"]:HookScript("OnClick", SetPlusAlpha);

	end

----------------------------------------------------------------------
-- 	L31: Default Events
----------------------------------------------------------------------

	local function eventHandler(self, event, arg1, arg2, ...)

		-- Invite from whisper
		if event == "CHAT_MSG_WHISPER" or event == "CHAT_MSG_BN_WHISPER" then
			if (not UnitExists("party1") or UnitIsGroupLeader("player")) and strlower(arg1) == ("plusinvite") then
				if not LeaPlusLC:IsInLFGQueue() then
					if event == "CHAT_MSG_WHISPER" then
						InviteUnit(arg2)
					elseif event == "CHAT_MSG_BN_WHISPER" then
						local void, toonname, void, realmname = BNGetToonInfo(select(11, ...))
						InviteUnit(toonname .. "-" .. realmname)
					end
				end
			end
		end

		-- Block duels
		if event == "DUEL_REQUESTED" and not LeaPlusLC:RealIDCheck(arg1) and not LeaPlusLC:FriendCheck(arg1) and not LeaPlusLC:GuildCheck(arg1) then
			CancelDuel();
			StaticPopup_Hide("DUEL_REQUESTED");
		end

		-- Automatic resurrection
		if event == "RESURRECT_REQUEST" then
			if (GetCorpseRecoveryDelay() == 0) then
				if ((UnitAffectingCombat(arg1)) and LeaPlusLC["NoAutoResInCombat"] == "Off") or not (UnitAffectingCombat(arg1)) then
					AcceptResurrect();
					StaticPopup_Hide("RESURRECT_NO_TIMER");
					DoEmote("thank", arg1)
				end
			end
		end

		-- Block party invites
		if event == "PARTY_INVITE_REQUEST" then

			-- If a friend, accept if you're accepting friends and not in Dungeon Finder
			if (LeaPlusLC["AcceptPartyGuild"] == "On" and LeaPlusLC:GuildCheck(arg1)) or
			(LeaPlusLC["AcceptPartyFriends"] == "On" and (LeaPlusLC:FriendCheck(arg1)) or LeaPlusLC:RealIDCheck(arg1)) then
				if not LeaPlusLC:IsInLFGQueue() then
					AcceptGroup();
					for i=1, STATICPOPUP_NUMDIALOGS do
						if _G["StaticPopup"..i].which == "PARTY_INVITE" then
							_G["StaticPopup"..i].inviteAccepted = 1
							StaticPopup_Hide("PARTY_INVITE");
							break
						elseif _G["StaticPopup"..i].which == "PARTY_INVITE_XREALM" then
							_G["StaticPopup"..i].inviteAccepted = 1
							StaticPopup_Hide("PARTY_INVITE_XREALM");
							break
						end
					end
					return
				end
			end

			-- If neither friend or guild and you're blocking invites, decline
			if LeaPlusLC["NoPartyInvites"] == "On" then
				if LeaPlusLC:FriendCheck(arg1) or LeaPlusLC:RealIDCheck(arg1) or LeaPlusLC:GuildCheck(arg1) then
					return
				else
					DeclineGroup(); 
					StaticPopup_Hide("PARTY_INVITE");
					return
				end
			end	

		end

		-- Don't confirm loot rolls
		if event == "CONFIRM_LOOT_ROLL" or event == "CONFIRM_DISENCHANT_ROLL" then
			ConfirmLootRoll(arg1, arg2)
			StaticPopup_Hide("CONFIRM_LOOT_ROLL")
		end

		-- Sell junk automatically
		if event == "MERCHANT_SHOW" and LeaPlusLC["AutoSellJunk"] == "On" then

			local Total = 0
			local SoldCount = 0
			local Rarity = 0
			local ItemPrice = 0
			local ItemCount = 0
			local CurrentItemLink

			for BagID = 0,4 do
				for BagSlot = 1, GetContainerNumSlots(BagID) do
					CurrentItemLink = GetContainerItemLink(BagID, BagSlot)
					if CurrentItemLink then
						void, void, Rarity, void, void, void, void, void, void, void, ItemPrice = GetItemInfo(CurrentItemLink)
						void, ItemCount = GetContainerItemInfo(BagID, BagSlot)
						if Rarity == 0 and ItemPrice ~= 0 then
							Total = Total + (ItemPrice * ItemCount)
							SoldCount = SoldCount + 1
							UseContainerItem(BagID, BagSlot)
						end
					end
				end
			end
			if Total ~= 0 then
				LeaPlusLC:Print("Sold " .. SoldCount .. " grey items for " .. GetCoinTextureString(Total) .. ".")
			end
		end

		-- Automatically accept quests
		if ((LeaPlusLC["AutoAcceptQuests"] == "On" and LeaPlusLC["AcceptOnlyDailys"] == "Off") or (LeaPlusLC["AutoAcceptQuests"] == "On" and LeaPlusLC["AcceptOnlyDailys"] == "On" and QuestIsDaily() == 1)) then

			-- Automatically accept all quests or daily quests with daily check on
			if event == "QUEST_DETAIL" then
				if not IsShiftKeyDown() then
					if not QuestGetAutoAccept() then
						-- If quest requires an accept click
						AcceptQuest()
					else
						-- If it's automatically accepted, just close the window
						CloseQuest()
					end
				end
			end

			-- Quests requiring confirmation
			if event == "QUEST_ACCEPT_CONFIRM" then
				if not IsShiftKeyDown() then
					ConfirmAcceptQuest()
					StaticPopup_Hide("QUEST_ACCEPT_CONFIRM")
				end
			end
		end
		
		-- Automatically turn-in quests
		if ((LeaPlusLC["AutoTurnInQuests"] == "On" and LeaPlusLC["TurnInOnlyDailys"] == "Off") or (LeaPlusLC["AutoTurnInQuests"] == "On" and LeaPlusLC["TurnInOnlyDailys"] == "On" and QuestIsDaily() == 1)) then

			-- Active quest turn-ins
			if event == "QUEST_PROGRESS" then
				if not IsShiftKeyDown() then
					if IsQuestCompletable() then
						CompleteQuest()
					end
				end
			end

			-- Turn-in completed quest
			if event == "QUEST_COMPLETE" then
				if not IsShiftKeyDown() then
					if GetNumQuestChoices() <= 1 then
						-- If there is only one reward item offered, grab it
						GetQuestReward(GetNumQuestChoices())
					end
				end
			end

		end

		-- Battleground release
		if event == "PLAYER_DEAD" then
			local InstStat, InstType = IsInInstance();
			if InstStat == 1 and InstType == "pvp" then
				-- Check for soulstone
				if not (HasSoulstone()) then
					RepopMe();
				end
			end
		end

		-- Repair automatically
		if event == "MERCHANT_SHOW" and LeaPlusLC["AutoRepairOwnFunds"] == "On" then
			if CanMerchantRepair() then
				local PlayerMoney = GetMoney()
				local RepairCost, CanRepair = GetRepairAllCost()

				local function RepairOwnFunds()
					-- Guild repair option is off or player isn't guilded
					if PlayerMoney == nil then PlayerMoney = 0 end
					if (RepairCost <= PlayerMoney) then
						RepairAllItems()
						LeaPlusLC:Print("Repaired for " .. GetCoinTextureString(RepairCost) .. ".")
					else
						LeaPlusLC:Print("The repair cost is " .. GetCoinTextureString(RepairCost) ..".")
						LeaPlusLC:Print("You do not have enough money to automatically repair.")
					end
				end

				local function RepairGuildFunds()
					-- Guild repair
					RepairAllItems(1)
					LeaPlusLC:Print("Repaired for " .. GetCoinTextureString(RepairCost) .. " (guild).")
				end

				if (CanRepair) then -- if the repair option is available at the merchant

					-- Guild repair first (eek!) if guild option is on and player is in guild
					if LeaPlusLC["AutoRepairGuildFunds"] == "On" and IsInGuild() then
						if CanGuildBankRepair() then -- If you have permission to use guilf funds
							local withdrawLimit = GetGuildBankWithdrawMoney()
							local guildBankMoney = GetGuildBankMoney()
							if guildBankMoney == 0 then 
								-- Guild funds not cached due to Blizzards bugged API
								LeaPlusLC:Print("The repair cost is " .. GetCoinTextureString(RepairCost) ..".")
								LeaPlusLC:Print("A blind repair was attempted.")
								RepairAllItems(1)
								RepairAllItems()
								return
							else
								-- Unlimited funds (guild leader)
								if (withdrawLimit == -1) then withdrawLimit = guildBankMoney else withdrawLimit = min(withdrawLimit, guildBankMoney) end
								if (RepairCost <= withdrawLimit) then
									-- Character is guilded, has permission to guild repair and has guild funds
									RepairGuildFunds();
								else
									-- Character is guilded, has permission to repair but not enough guild funds
									RepairOwnFunds();
								end
							end
						else
							-- Character is guilded but cannot use guild funds so use personal funds
							RepairOwnFunds();
						end
					else
						-- Character is unguilded or guild repair option is disabled
						RepairOwnFunds();
					end
				end
			end
		end

		-- Run modules
		if event == "ADDON_LOADED" then

			if arg1 == "Leatrix_Plus" then
				LeaPlusLC:Load(); -- Load global settings
				LeaPlusLC:Live(); -- Run code from the live environment
				LeaPlusLC:Isolated(); -- Run code inside the isolated environment
				LeaPlusLC:RunOnce(); -- Run code designed to be run once with no qualifying options
				LeaPlusLC:SetDim(); -- Lock invalid options
			elseif arg1 == "Blizzard_CombatLog" or arg1 == "Blizzard_AuctionUI" then
				LeaPlusLC:BlizzDep(arg1); -- Load code which requires Blizzard addons
			end
		end

		if (event == "VARIABLES_LOADED") then
			LeaPlusLC:Variable()
			if LeaPlusLC["ShowStartTag"] == "On" then
				LeaPlusLC:Print("|TInterface\\COMMON\\Indicator-Green.png:0|t Leatrix Plus " .. LeaPlusLC["PlusVersion"] .. ".");
			end
		end

		if (event == "PLAYER_ENTERING_WORLD") then
			LeaPlusLC:Player();
			CameraZoomOut(0);
		end

		-- Save locals back to globals on logout
		if (event == "PLAYER_LOGOUT") then

			-- Set zoom level to default of 15 if checkbox has been unchecked during this session (to force client to cache default value)
			if LeaPlusDB["ManageZoomLevel"] == "On" and LeaPlusLC["ManageZoomLevel"] == "Off" then
				SetCVar("CameraDistanceMax", "15")
			end

			-- Prevent Blizzard from caching frames if frame customisation is enabled (else it confuses things)
			if LeaPlusLC["FrmEnabled"] == "On" then
				PlayerFrame:SetUserPlaced(false)
				TargetFrame:SetUserPlaced(false)
			end

			-- Save global options
			LeaPlusLC:Save();

		end

	end

--	Register event handler
	LpEvt:SetScript("OnEvent", eventHandler);

----------------------------------------------------------------------
--	L32: Slash commands
----------------------------------------------------------------------

--	Slash command handler
	function LeaPlusLC:Slash(str)

		-- Prevent slash commands if Blizzard options are showing (else it gets confusing)
		if InterfaceOptionsFrame:IsShown() or VideoOptionsFrame:IsShown() then return end

		-- Parse command string
		if str == "" then
			if LeaPlusLC["PageF"]:IsShown() then
				LeaPlusLC:HideFrames();
			else
				LeaPlusLC:HideFrames();
				LeaPlusLC["PageF"]:Show();
			end
			if LeaPlusLC["Page"..LeaPlusLC["LeaStartPage"]] and LeaPlusLC["OpenPlusAtHome"] == "Off" then
				 LeaPlusLC["Page"..LeaPlusLC["LeaStartPage"]]:Show()
			else
				LeaPlusLC["Page0"]:Show();
			end
		elseif str == "help" then LeaPlusLC:Print("Leatrix Plus\n/ltp - Toggle the options panel\n/ltp frame - Toggle frame Information\n/ltp restart - Restart graphics subsystem")
		elseif str == "frame" then
			if not (IsAddOnLoaded("Blizzard_DebugTools")) then
				UIParentLoadAddOn("Blizzard_DebugTools")
			end
			FrameStackTooltip_Toggle();
		elseif str == "restart" then
			RestartGx();
		elseif str == "toggle" then
			if LeaPlusLC["ShowErrorsFlag"] == 1 then LeaPlusLC["ShowErrorsFlag"] = 0 else LeaPlusLC["ShowErrorsFlag"] = 1 end
		else
			LeaPlusLC:Print("Invalid command.  Type '/ltp help' for help.")
		end

	end

--	Slash command support
	SLASH_Leatrix_Plus1 = '/ltp'
	SLASH_Leatrix_Plus2 = '/leaplus'
	SlashCmdList["Leatrix_Plus"] = function(str) LeaPlusLC:Slash(string.lower(str)) end
	
----------------------------------------------------------------------
-- 	L40: Options panel functions
----------------------------------------------------------------------

	-- Create a side panel (used for additional configuration)
	function LeaPlusLC:CreateSidePanel(title, width, height)

		-- Create side panel
		local Side = CreateFrame("Frame")
		Side:Hide(); Side:SetSize(width, height); Side:SetToplevel(true)
		Side:ClearAllPoints(); Side:SetPoint("RIGHT", 0, 0)
		Side:SetClampedToScreen(true); Side:EnableMouse(true); Side:SetFrameStrata("FULLSCREEN_DIALOG")

		-- Add background color
		Side.t = Side:CreateTexture(nil, "BACKGROUND")
		Side.t:SetAllPoints()
		Side.t:SetTexture(0.05, 0.05, 0.05, 0.9)

		-- Add title
		Side.f = Side:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
		Side.f:SetPoint('TOPLEFT', 10, -10);
		Side.f:SetText(title)

		-- Add description
		LeaPlusLC:MakeWD(Side, "Configuration Panel", 10, -30)
	
		-- Prevent options panel from showing while side panel is showing
		LeaPlusLC["PageF"]:HookScript("OnShow", function()
			if Side:IsShown() then LeaPlusLC["PageF"]:Hide(); end
		end)

		-- Return the frame
		return Side

	end

	-- Define subheadings
	function LeaPlusLC:MakeTx(frame, title, x, y)
		local text = frame:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
		text:SetPoint("TOPLEFT", x, y)
		text:SetText(title)
	end

	-- Define text
	function LeaPlusLC:MakeWD(frame, title, x, y)
		local text = frame:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight')
		text:SetPoint("TOPLEFT", x, y)
		text:SetText(title)
		text:SetJustifyH"LEFT";
	end

	-- Create a slider control (uses the Blizzard slider template)
	function LeaPlusLC:MakeSL(frame, field, caption, low, high, step, x, y, form)

		-- Create slider control
		local Slider = CreateFrame("Slider", "LeaPlusGlobalSlider" .. field, frame, "OptionssliderTemplate")
		LeaPlusCB[field] = Slider;
		Slider:SetMinMaxValues(low, high)
		Slider:SetValueStep(step)
		Slider:EnableMouseWheel(true)
		Slider:SetPoint('TOPLEFT', x,y)
		Slider:SetWidth(100)
		Slider:SetHeight(20)
		Slider:SetHitRectInsets(0, 0, 0, 0);

		_G[Slider:GetName().."Low"]:SetText('');
		_G[Slider:GetName().."High"]:SetText('');

		-- Create slider label
		Slider.f = Slider:CreateFontString(nil, 'BACKGROUND')
		Slider.f:SetFontObject('GameFontHighlight')
		Slider.f:SetPoint('LEFT', Slider, 'RIGHT', 12, 0)
		Slider.f:SetText(string.format("%.2f", Slider:GetValue()))

		-- Process mousewheel scrolling
		Slider:SetScript('OnMouseWheel', function(self, arg1)
			local step = self:GetValueStep() * arg1
			local value = self:GetValue()
			local minVal, maxVal = self:GetMinMaxValues()
			if step > 0 then
				self:SetValue(min(value+step, maxVal))
			else
				self:SetValue(max(value+step, minVal))
			end
		end)

		-- Process value changed
		Slider:SetScript('OnValueChanged', function(self, value)
			Slider.f:SetText(format(form, value))
			LeaPlusLC[field] = value
		end)

		-- Set default state
		Slider:SetScript('OnShow', function(self)
			self.onShow = true
			self:SetValue(LeaPlusLC[field])
			self.onShow = nil
		end)
	end

	-- Create a checkbox control (uses the Blizzard checkbox template)
	function LeaPlusLC:MakeCB(parent, field, caption, x, y, tip)

		-- Create the checkbox
		local Cbox = CreateFrame('CheckButton', nil, parent, "ChatConfigCheckButtonTemplate")
		LeaPlusCB[field] = Cbox
		Cbox:SetPoint("TOPLEFT",x, y)
		Cbox:SetHitRectInsets(0,-100,0,0)

		-- Add tooltip
		Cbox.tiptext = tip
		Cbox:SetScript("OnEnter", LeaPlusLC.ShowTooltip)		
		Cbox:SetScript("OnLeave", LeaPlusLC.HideTooltip)

		-- Add label
		Cbox.f = Cbox:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight')
		Cbox.f:SetPoint('LEFT', 20, 0)
		Cbox.f:SetText(caption)

		-- Set default checkbox state
		Cbox:SetScript('OnShow', function(self)
			self:SetChecked(LeaPlusLC[field])
		end)

		-- Process clicks
		Cbox:SetScript('OnClick', function()
			if Cbox:GetChecked() == nil then
				LeaPlusLC[field] = "Off"
			elseif Cbox:GetChecked() == 1 then
				LeaPlusLC[field] = "On"
			end
			LeaPlusLC:SetDim(); -- Lock invalid options
			LeaPlusLC:ReloadCheck(); -- Show reload button if needed
			LeaPlusLC:Live(); -- Run live code

			-- Frame movement
			if field == "FrmEnabled" and LeaPlusLC["FrmEnabled"] == "Off" then
				PlayerFrame:SetUserPlaced(false)
				TargetFrame:SetUserPlaced(false)
			elseif field == "FrmEnabled" and LeaPlusLC["FrmEnabled"] == "On" then
				PlayerFrame:SetUserPlaced(true)
				TargetFrame:SetUserPlaced(true)
			end
		end)
	end

	-- Create an editbox (uses the Blizzard input box template)
	function LeaPlusLC:CreateEditBox(frame, parent, width, maxchars, anchor, x, y, tab, shifttab)

		local eb = CreateFrame("EditBox", nil, parent, "InputBoxTemplate");
		LeaPlusCB[frame] = eb;
		eb:SetPoint(anchor, x, y);
		eb:SetWidth(width);
		eb:SetHeight(24);
		eb:SetFontObject("GameFontNormal");
		eb:SetTextColor(1.0, 1.0, 1.0)
		eb:SetAutoFocus(false) 
		eb:SetMaxLetters(maxchars) 
		eb:SetScript("OnEscapePressed", eb.ClearFocus);
		eb:SetScript("OnEnterPressed", eb.ClearFocus);

		-- Move onto next editbox when tab key is pressed
		eb:SetScript("OnTabPressed", function(self)
			LeaPlusLC[frame] = eb:GetText();
			LeaPlusDC[frame] = LeaPlusLC[frame];
			self:ClearFocus();
			if IsShiftKeyDown() then
				LeaPlusCB[shifttab]:SetFocus();
			else
				LeaPlusCB[tab]:SetFocus();
			end
		end)

		-- Load initial values
		if LeaPlusDC[frame] then
			eb:SetText(LeaPlusDC[frame]);
		end

		return eb

	end

	-- Create a dropdown menu (custom design because the Blizzard one produces taint hell)
	function LeaPlusLC:CreateDropDown(ddname, label, parent, width, anchor, x, y, items, tip)

		-- Add the dropdown name to a table
		tinsert(LeaDropList, ddname)

		-- Populate variable with item list
		LeaPlusLC[ddname.."Table"] = items

		-- Create outer frame
		local frame = CreateFrame("FRAME", nil, parent); frame:SetWidth(width); frame:SetHeight(42); frame:SetPoint("BOTTOMLEFT", parent, anchor, x, y);

		-- Create dropdown inside outer frame
		local dd = CreateFrame("Frame", nil, frame); dd:SetPoint("BOTTOMLEFT", -16, -8); dd:SetPoint("BOTTOMRIGHT", 15, -4); dd:SetHeight(32);

		-- Create dropdown textures
		local lt = dd:CreateTexture(nil, "ARTWORK"); lt:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame"); lt:SetTexCoord(0, 0.1953125, 0, 1); lt:SetPoint("TOPLEFT", dd, 0, 17); lt:SetWidth(25); lt:SetHeight(64); 
		local rt = dd:CreateTexture(nil, "BORDER"); rt:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame"); rt:SetTexCoord(0.8046875, 1, 0, 1); rt:SetPoint("TOPRIGHT", dd, 0, 17); rt:SetWidth(25); rt:SetHeight(64); 
		local mt = dd:CreateTexture(nil, "BORDER"); mt:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame"); mt:SetTexCoord(0.1953125, 0.8046875, 0, 1); mt:SetPoint("LEFT", lt, "RIGHT"); mt:SetPoint("RIGHT", rt, "LEFT"); mt:SetHeight(64);

		-- Create dropdown label
		local lf = dd:CreateFontString(nil, "OVERLAY", "GameFontNormal"); lf:SetPoint("TOPLEFT", frame, 5, 0); lf:SetPoint("TOPRIGHT", frame, -5, 0); lf:SetJustifyH("LEFT"); lf:SetText(label)
	
		-- Create dropdown placeholder for value (set it using OnShow)
		local value = dd:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
		value:SetPoint("LEFT", lt, 26, 2); value:SetPoint("RIGHT", rt, -43, 0); value:SetJustifyH("LEFT")
		dd:SetScript("OnShow", function() value:SetText(LeaPlusLC[ddname.."Table"][LeaPlusLC[ddname]]) end)

		-- Create dropdown button (clicking it opens the dropdown list)
		local dbtn = CreateFrame("Button", nil, dd)
		dbtn:SetPoint("TOPRIGHT", rt, -16, -18); dbtn:SetWidth(24); dbtn:SetHeight(24)
		dbtn:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up"); dbtn:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down"); dbtn:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled"); dbtn:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight"); dbtn:GetHighlightTexture():SetBlendMode("ADD")
		dbtn.tiptext = tip; dbtn:SetScript("OnEnter", LeaPlusLC.ShowTooltip); 
		dbtn:SetScript("OnLeave", LeaPlusLC.HideTooltip)

		-- Create dropdown list
		local ddlist =  CreateFrame("Frame",nil,frame);
		LeaPlusCB["ListFrame"..ddname] = ddlist;
		ddlist:SetPoint("TOP",0,-42);
		ddlist:SetWidth(frame:GetWidth());
		ddlist:SetHeight((#items * 17) + 17 + 17);
		ddlist:SetFrameStrata("FULLSCREEN_DIALOG");
		ddlist:SetFrameLevel(12);
		ddlist:SetBackdrop({bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 32, insets = { left = 4, right = 4, top = 4, bottom = 4 }});
		ddlist:Hide();

		-- Create checkmark (it marks the currently selected item)
		local ddlistchk = CreateFrame("FRAME", nil, ddlist)
		ddlistchk:SetHeight(16); ddlistchk:SetWidth(16);
		ddlistchk.t = ddlistchk:CreateTexture(nil, "ARTWORK"); ddlistchk.t:SetAllPoints(); ddlistchk.t:SetTexture("Interface\\Common\\UI-DropDownRadioChecks"); ddlistchk.t:SetTexCoord(0, 0.5, 0.5, 1.0);

		-- Create dropdown list items
		for k, v in pairs(items) do

			local dditem = CreateFrame("Button", nil, LeaPlusCB["ListFrame"..ddname])
			LeaPlusCB["Drop"..ddname..k] = dditem;
			dditem:Show();
			dditem:SetWidth(ddlist:GetWidth()-22)
			dditem:SetHeight(20)
			dditem:SetPoint("TOPLEFT", 12, -k*16)

			dditem.f = dditem:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight'); 
			dditem.f:SetPoint('LEFT', 16, 0)
			dditem.f:SetText(items[k])

			dditem.t = dditem:CreateTexture(nil, "BACKGROUND")
			dditem.t:SetAllPoints()
			dditem.t:SetTexture(0.3, 0.3, 0.00, 0.8)
			dditem.t:Hide();

			dditem:SetScript("OnEnter", function() UIFrameFadeIn(dditem.t, 0.1, 0.0, 1)	end)
			dditem:SetScript("OnLeave", function() UIFrameFadeOut(dditem.t, 0.1, 1, 0.0) end)
			dditem:SetScript("OnClick", function()
				ddlist:Hide();
				LeaPlusLC[ddname] = k
				value:SetText(LeaPlusLC[ddname.."Table"][k])
			end)

			-- Show list when button is clicked
			dbtn:SetScript("OnClick", function()
				-- Show the dropdown
				if ddlist:IsShown() then ddlist:Hide() else 
					ddlist:Show();
					ddlistchk:SetPoint("TOPLEFT",10,select(5,LeaPlusCB["Drop"..ddname..LeaPlusLC[ddname]]:GetPoint()))
					ddlistchk:Show();
				end;
				-- Hide all other dropdowns except the one we're dealing with
				for void,v in pairs(LeaDropList) do
					if v ~= ddname then
						LeaPlusCB["ListFrame"..v]:Hide();
					end
				end
			end)
		end

		return frame
		
	end

	-- Create a standard button
	function LeaPlusLC:CreateButton(name, frame, label, anchor, x, y, width, height, tip)
		local mbtn = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
		LeaPlusCB[name] = mbtn
		mbtn:SetWidth(width)
		mbtn:SetHeight(height) 
		mbtn:SetAlpha(1.0)
		mbtn:SetPoint(anchor, x, y)
		mbtn:SetText(label) 
		mbtn:RegisterForClicks("AnyUp") 
		mbtn:SetHitRectInsets(0, 0, 0, 0);
		mbtn:SetFrameStrata("FULLSCREEN_DIALOG");
		mbtn:SetScript("OnEnter", LeaPlusLC.ShowTooltip)		
		mbtn:SetScript("OnLeave", LeaPlusLC.HideTooltip)
		mbtn.tiptext = tip
		return mbtn
	end
	
----------------------------------------------------------------------
-- 	L41: Create main options panel frame
----------------------------------------------------------------------

	function LeaPlusLC:CreateMainPanel()

		-- Create the options panel frame
		local PageF = CreateFrame("Frame", nil, UIParent); 
		LeaPlusLC["PageF"] = PageF
		PageF:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
		PageF:SetSize(570,370)
		PageF:Hide();
		PageF:SetFrameStrata("FULLSCREEN_DIALOG")
		PageF:SetClampedToScreen(true);
		PageF:EnableMouse(true)
		PageF:SetMovable(true)
		PageF:RegisterForDrag("LeftButton")
		PageF:SetScript("OnDragStart", PageF.StartMoving)
		PageF:SetScript("OnDragStop", function ()
			PageF:StopMovingOrSizing();
			PageF:SetUserPlaced(true);
			for i = 0,LeaPlusLC["NumberOfPages"] do
				LeaPlusLC["Page"..i]:SetAllPoints(PageF)
			end
		end)

		-- Add background color
		PageF.t = PageF:CreateTexture(nil, "BACKGROUND")
		PageF.t:SetAllPoints()
		PageF.t:SetTexture(0.05, 0.05, 0.05, 0.9)

		-- Add textures
		local function CreateBar(name, parent, width, height, anchor, r, g, b, alpha, texture)
			local ft = parent:CreateTexture(nil, "BORDER")
			LeaPlusLC[name] = ft; -- Needed for toggling the panel background
			ft:SetTexture(texture)
			ft:SetSize(width, height)  
			ft:SetPoint(anchor)
			ft:SetVertexColor(r ,g, b, alpha)
		end
		CreateBar("FootTexture", PageF, 570, 42, "BOTTOM", 0.3, 0.3, 1.0, 0.4, "Interface\\GLUES\\MODELS\\UI_MAINMENU\\GRADIENT")
		CreateBar("MainTexture", PageF, 440, 348, "TOPRIGHT", 0.8, 0.8, 0.8, 0.4, "Interface\\DressUpFrame\\DressUpBackground-NightElf1")
		CreateBar("MenuTexture", PageF, 130, 348, "TOPLEFT", 0.6, 0.6, 0.6, 0.4, "Interface\\GLUES\\MODELS\\UI_MAINMENU\\GRADIENT")

		-- Add main title (shown above menu in the corner)
		PageF.mt = PageF:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
		PageF.mt:SetPoint('TOPLEFT', 16, -16);
		PageF.mt:SetText("Leatrix Plus")

		-- Add version text (shown underneath main title)
		PageF.v = PageF:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall')
		PageF.v:SetHeight(32);
		PageF.v:SetPoint('TOPLEFT', PageF.mt, 'BOTTOMLEFT', 0, -8); 
		PageF.v:SetPoint('RIGHT', PageF, -32, 0)
		PageF.v:SetJustifyH('LEFT'); PageF.v:SetJustifyV('TOP');
		PageF.v:SetNonSpaceWrap(true); PageF.v:SetText("Version " .. LeaPlusLC["PlusVersion"])

		-- Add menu title
		LeaPlusLC:MakeTx(PageF, "Menu", 16, -72);

		-- Add home Button
		local homeb = LeaPlusLC:CreateButton("HomePageButton", PageF, "Home", "BOTTOMLEFT", 10, 10, 70, 25, "")
		homeb:SetScript("OnClick", function() 
			LeaPlusLC:HideFrames();
			LeaPlusLC["Page0"]:Show();
			LeaPlusLC["PageF"]:Show();
			LeaPlusLC["LeaStartPage"] = "0";
		end)

		-- Add reload UI Button
		local reloadb = LeaPlusLC:CreateButton("ReloadUIButton", PageF, "Reload", "BOTTOMLEFT", 330, 10, 70, 25,"Your UI needs to be reloaded for some of the changes to take effect.\n\nYou don't have to click the reload button immediately but you do need to click it when you are done making changes and you want the changes to take effect.")
		reloadb:Show();
		LeaPlusLC:LockItem(reloadb,true)
		reloadb:SetScript("OnClick", function()
			ReloadUI();
		end)

		-- Add page back Button
		local navb = LeaPlusLC:CreateButton("PageBackButton", PageF, "<<", "BOTTOMLEFT",410, 10, 70, 25, "")
		navb:SetScript("OnClick", function()
			for i = 0, LeaPlusLC["NumberOfPages"] do
				if LeaPlusLC["Page"..i]:IsShown() then
					-- Numbered options page is being shown
					LeaPlusLC:HideFrames();
					if i > 1 then
						-- Page is not the first page so show previous page
						LeaPlusLC["Page"..i - 1]:Show();
						PageF:Show();
						LeaPlusLC["LeaStartPage"] = i - 1
						return
					else
						-- Page being shown is first page so show last page
						LeaPlusLC["Page"..LeaPlusLC["NumberOfPages"]]:Show();
						PageF:Show();
						LeaPlusLC["LeaStartPage"] = LeaPlusLC["NumberOfPages"]
						return
					end
				end
			end
			-- Numbered page is not being shown so show last page
			LeaPlusLC:HideFrames();
			LeaPlusLC["PageF"]:Show();
			LeaPlusLC["Page"..LeaPlusLC["NumberOfPages"]]:Show();
			LeaPlusLC["LeaStartPage"] = LeaPlusLC["NumberOfPages"]
			return
		end)

		-- Add page forward Button
		local navf = LeaPlusLC:CreateButton("navf", PageF, ">>", "BOTTOMLEFT", 490, 10, 70, 25, "")
		navf:SetScript("OnClick", function()
			for i = 0, LeaPlusLC["NumberOfPages"] do
				if	LeaPlusLC["Page"..i]:IsShown() then
					-- Numbered options page is being shown
					LeaPlusLC:HideFrames();
					if i < LeaPlusLC["NumberOfPages"] then
						-- Page is not the last page so show next page
						LeaPlusLC["Page"..i + 1]:Show();
						PageF:Show();
						LeaPlusLC["LeaStartPage"] = i + 1
						return
					else
						-- Page being shown is last page so show first page
						LeaPlusLC["Page1"]:Show();
						PageF:Show();
						LeaPlusLC["LeaStartPage"] = 1
						return
					end
				end
			end
			-- Numbered page is not shown so show first page
			LeaPlusLC:HideFrames();
			LeaPlusLC["PageF"]:Show();
			LeaPlusLC["Page1"]:Show();
			LeaPlusLC["LeaStartPage"] = 1
			return
		end)

		-- Add close Button
		local CloseB = CreateFrame("Button", nil, PageF, "UIPanelCloseButton") 
		CloseB:SetSize(30, 30)
		CloseB:SetPoint("TOPRIGHT", 0, 0)
		CloseB:SetScript("OnClick", function() 
			LeaPlusLC:HideFrames();
		end)

	end

	LeaPlusLC:CreateMainPanel();

----------------------------------------------------------------------
-- 	L42: Create options panel pages (no content yet)
----------------------------------------------------------------------

	-- Function to add menu button
	function LeaPlusLC:MakeMN(name, text, parent, anchor, x, y, width, height)

		local mbtn = CreateFrame("Button", nil, parent)
		LeaPlusLC[name] = mbtn
		mbtn:Show();
		mbtn:SetSize(width, height)
		mbtn:SetAlpha(1.0)
		mbtn:SetPoint(anchor, x, y)

		mbtn.t = mbtn:CreateTexture(nil, "BACKGROUND")
		mbtn.t:SetAllPoints()
		mbtn.t:SetTexture(0.3, 0.3, 0.00, 0.8)
		mbtn.t:Hide();

		mbtn.s = mbtn:CreateTexture(nil, "BACKGROUND")
		mbtn.s:SetAllPoints()
		mbtn.s:SetTexture(0.3, 0.3, 0.00, 0.8)
		mbtn.s:Hide();

		mbtn.f = mbtn:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
		mbtn.f:SetPoint('LEFT', 16, 0)
		mbtn.f:SetText(text)
	
		mbtn:SetScript("OnEnter", function()
			UIFrameFadeIn(mbtn.t, 0.1, 0.0, 1)
		end)

		mbtn:SetScript("OnLeave", function()
			UIFrameFadeOut(mbtn.t, 0.1, 1, 0.0)
		end)

		return mbtn, mbtn.s

	end

	-- Function to create individual options panel pages
	function LeaPlusLC:MakePage(name, title, menu, menuname, menuparent, menuanchor, menux, menuy, menuwidth, menuheight)

		-- Create frame
		local oPage = CreateFrame("Frame", nil, LeaPlusLC["PageF"]); 
		LeaPlusLC[name] = oPage
		oPage:SetAllPoints(LeaPlusLC["PageF"])
		oPage:Hide();

		-- Add page title
		oPage.s = oPage:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
		oPage.s:SetPoint('TOPLEFT', 146, -16)
		oPage.s:SetText(title)

		-- Add menu item if needed
		if menu then
			LeaPlusLC[menu], LeaPlusLC[menu .. ".s"] = LeaPlusLC:MakeMN(menu, menuname, menuparent, menuanchor, menux, menuy, menuwidth, menuheight)
			LeaPlusLC[name]:SetScript("OnShow", function() LeaPlusLC[menu .. ".s"]:Show(); end)
			LeaPlusLC[name]:SetScript("OnHide", function() LeaPlusLC[menu .. ".s"]:Hide(); end)
		end

		return oPage;
	
	end

	-- Create options pages
	LeaPlusLC["Page0"] = LeaPlusLC:MakePage("Page0", "Welcome, " .. LeaPlusLC["PlayerName"])
	LeaPlusLC["Page1"] = LeaPlusLC:MakePage("Page1", "Automation"	, "LeaPlusNav1", "- Automation"	, LeaPlusLC["PageF"], "TOPLEFT", 16, -92, 112, 20)
	LeaPlusLC["Page2"] = LeaPlusLC:MakePage("Page2", "Interaction"	, "LeaPlusNav2", "- Interaction", LeaPlusLC["PageF"], "TOPLEFT", 16, -112, 112, 20)
	LeaPlusLC["Page3"] = LeaPlusLC:MakePage("Page3", "Chat"			, "LeaPlusNav3", "- Chat"		, LeaPlusLC["PageF"], "TOPLEFT", 16, -132, 112, 20)
	LeaPlusLC["Page4"] = LeaPlusLC:MakePage("Page4", "Text"			, "LeaPlusNav4", "- Text"		, LeaPlusLC["PageF"], "TOPLEFT", 16, -152, 112, 20)
	LeaPlusLC["Page5"] = LeaPlusLC:MakePage("Page5", "Tooltip"		, "LeaPlusNav5", "- Tooltip"	, LeaPlusLC["PageF"], "TOPLEFT", 16, -172, 112, 20)
	LeaPlusLC["Page6"] = LeaPlusLC:MakePage("Page6", "Interface"	, "LeaPlusNav6", "- Interface"	, LeaPlusLC["PageF"], "TOPLEFT", 16, -192, 112, 20)
	LeaPlusLC["Page7"] = LeaPlusLC:MakePage("Page7", "Miscellaneous", "LeaPlusNav7", "- Misc"		, LeaPlusLC["PageF"], "TOPLEFT", 16, -212, 112, 20)

	-- Create special pages
	LeaPlusLC["PageS"] = LeaPlusLC:MakePage("PageS", "Settings"		, nil, nil, nil, nil, nil, nil, nil, nil)

	-- Page navigation mechanism
	for i = 1, LeaPlusLC["NumberOfPages"] do
		LeaPlusLC["LeaPlusNav"..i]:SetScript("OnClick", function()
			LeaPlusLC:HideFrames()
			LeaPlusLC["PageF"]:Show();
			LeaPlusLC["Page"..i]:Show();
			LeaPlusLC["LeaStartPage"] = i
		end)
	end

	-- Use a variable to contain the page (makes it easier to move options around)
	local pg;

----------------------------------------------------------------------
-- 	L50: Page 0 - Welcome
----------------------------------------------------------------------

	pg = "Page0";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Welcome to Leatrix Plus.", 146, -72);
	LeaPlusLC:MakeWD(LeaPlusLC[pg], "To begin, choose an options page.", 146, -92);

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Support", 146, -132);
	LeaPlusLC:MakeWD(LeaPlusLC[pg], "www.leatrix.com", 146, -152);

----------------------------------------------------------------------
-- 	L51: Page 1: Automation
----------------------------------------------------------------------

	pg = "Page1";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Party Automation"			, 	146, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AcceptPartyFriends"		, 	"Party from friends"			, 	146, -92, 	"If checked, party invitations from friends will be automatically accepted unless you are queued in Dungeon Finder.\n\nThis includes Real ID friends.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AcceptPartyGuild"			, 	"Party from guild"				, 	146, -112, 	"If checked, party invitations from guild members will be automatically accepted unless you are queued in Dungeon Finder.\n\nIf the guild member that is inviting you has only recently joined the guild, you may need to reload your UI to update the internal roster.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoConfirmRole"			, 	"Dungeon groups"				,	146, -132, 	"If checked, role checks for dungeon groups will be accepted automatically if the party leader is in your friends list or guild.  This includes Real ID friends.\n\nEnabling this option does not port you into the dungeon automatically.\n\nThis option requires that you select a role for your character in the Dungeon Finder window.\n\nIt is recommended that you enable the 'Save role per spec' option in the interaction menu if you enable this setting.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "InviteFromWhisper"			, 	"Invite from whispers"			, 	146, -152, 	"If checked, when someone whispers 'plusinvite' to you they will be automatically invited to a group with you.\n\nYou need to be either ungrouped or party leader in your own group for this to work.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Death Automation"			, 	146, -192);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoReleaseInBG"			,	"Release in battlegrounds"		, 	146, -212, 	"If checked, you will release automatically after you die in a battleground unless you are protected by a soulstone.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoAcceptRes"				,	"Accept resurrect"				, 	146, -232, 	"If checked, resurrection attempts cast on you will be automatically accepted.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoAutoResInCombat"			,	"Exclude combat res"			, 	166, -252, 	"If checked, resurrection attempts cast on you will not be automatically accepted if the player resurrecting you is in combat.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Blockers"					, 	340, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoDuelRequests"			, 	"Block duels"					,	340, -92, 	"If checked, duel requests will be blocked unless the player requesting the duel is in your friends list or guild.\n\nThis includes Real ID friends.\n\nIf the guild member that is requesting the duel has only recently joined the guild, you may need to reload your UI to update the internal roster.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoPartyInvites"			, 	"Block party invites"			, 	340, -112, 	"If checked, party invitations will be blocked unless the player inviting you is in your friends list or guild.\n\nThis includes Real ID friends.\n\nIf the guild member that is inviting you has only recently joined the guild, you may need to reload your UI to update the internal roster.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Blizzard Blockers"			, 	340, -152);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ManageTradeGuild"			, 	"Manage blockers*"				, 	340, -172, 	"If checked, you will be able to enable or disable trade request and guild invitation and petition blocking using the two settings below.\n\nThese are replacements for the Blizzard options panel settings to make them account-wide.\n\nEnabling this option will prevent you from changing the trade request and guild invitation checkboxes in the Blizzard options panel.\n\n* Requires UI reload.  After the reload, the checkbox controls below will be available.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoTradeRequests"			, 	"Block trades"					, 	360, -192, 	"If checked, trade requests will be blocked.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoGuildInvites"			,	"Block guild invites"			,	360, -212, 	"If checked, guild invitations and petitions will be blocked.\n\nIf you are in the process of making your own guild, you need to uncheck this box to see your own petition.")

----------------------------------------------------------------------
-- 	L52: Page 2: Interaction
----------------------------------------------------------------------

	pg = "Page2";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Vendors"					, 	146, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoSellJunk"				,	"Sell junk automatically"		,	146, -92, 	"If checked, all grey items in your bags will be automatically sold when you visit a merchant.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoRepairOwnFunds"		, 	"Automatically repair"			,	146, -112, 	"If checked, your armor will be automatically repaired when you visit a suitable merchant.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoRepairGuildFunds"		, 	"Use guild funds"				,	166, -132, 	"If checked, repair costs will be taken from guild funds for characters that are guilded and have permission to repair.\n\nIf available guild funds have not been cached by the client yet, a blind repair will be attempted but no confirmation will be shown (this is a limitation of the Blizzard API).\n\nIf the guilded character does not have permission to repair or not enough guild funds are available, the character's own funds will be used.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoBagAutomation"			, 	"Prevent bag automation*"		,	146, -152, 	"If checked, bags will not be opened and closed automatically when using a vendor or mailbox, allowing you to open and close them freely at your command.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AhExtras"					, 	"Auction house extras*"			, 	146, -172, 	"If checked, additional functionality will be added to the auction house frame.\n\nBuyout only - enables you to create buyout auctions without having to fill in the starting price boxes.\n\nGold only - Enables you to permanently set the copper and silver prices at 99 to speed up new auctions.\n\nFind - Enables easy search of the auction house for the item you are selling.\n\nAs a precaution, when both the buyout only and gold only options are checked, you won't be able to create auctions if the buyout gold price box is empty (put a zero in it if needed).\n\n* Requires UI reload.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Quests"					, 	146, -212);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowQuestLevels"			,	"Show quest levels*"			,	146, -232, 	"If checked, quest levels will be shown in the quest log.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoAcceptQuests"			, 	"Accept quests"					,	146, -252, 	"If checked, all quests will be accepted automatically.\n\nYou can hold the shift key down when you talk to a quest giver to over-ride this setting.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AcceptOnlyDailys"			, 	"Restrict to dailies"			, 	166, -272, 	"If checked, only daily quests will be accepted automatically.\n\nYou can hold the shift key down when you talk to a quest giver to over-ride this setting.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoTurnInQuests"			,	"Turn-in quests"				,	146, -292, 	"If checked, quests will be turned-in automatically.\n\nYou can hold the shift key down when you talk to a quest giver to over-ride this setting.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TurnInOnlyDailys"			,	"Restrict to dailies"			,	166, -312, 	"If checked, only daily quests will be turned-in automatically.\n\nYou can hold the shift key down when you talk to a quest giver to over-ride this setting.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Groups"					, 	340, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoRaidRestrictions"		, 	"Remove raid restrictions*"		,	340, -92, 	"If checked, your low level characters will be allowed to join raid groups.\n\nNote that you cannot join a raid group directly with a low level character.  You have to join a party group first then the party leader should convert the party group to a raid group.\n\nReload your UI if the group leader is unable to convert the party group to a raid group.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoConfirmLoot"				, 	"Hide loot warnings"			,	340, -112, 	"If checked, confirmations which appear when you choose a loot roll option (need, greed or disenchant) will not be shown.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoConfirmBoP"				, 	"Hide soulbound warnings*"		,	340, -132, 	"If checked, the soulbound confirmation which appears when attempting to loot a bind-on-pickup item will be automatically accepted.\n\nNote that if you are not in a group, or you are in a group with free for all loot selected, you will need to manually click bind-on-pickup items in the loot frame to loot them (even if you have autoloot enabled).\n\nIf you wish to be sure that you don't miss loot, check the warning box below.\n\n* Requires UI reload.  After the reload, the checkbox control below will be available.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "BoPShowWarning"			, 	"Show loot warning"				,	360, -152, 	"If checked, a raid warning will be shown whenever Leatrix Plus blocks a soulbound confirmation.\n\nThe raid warning will show the bind-on-pickup item name(s).\n\nThe warning will only show when you are not in a group or when you are in a group using free for all loot.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoLootWonAlert"			, 	"Hide loot won alerts*"			,	340, -172, 	"If checked, the loot won alert will not show when you win loot while in a group.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "RoleSave"					, 	"Save roles per spec*"			,	340, -192, 	"If checked, a button will be added to the Dungeon Finder window which will allow you to save your currently selected group roles to your talent spec.\n\nThese roles will then be selected automatically when you switch specs.\n\nIf unchecked, the Blizzard default setting will be used which only saves your role for your entire character regardless of spec.\n\n* Requires UI reload.")

----------------------------------------------------------------------
-- 	L53: Page 3: Chat
----------------------------------------------------------------------

	pg = "Page3";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Chat Frame"				, 	146, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "UseEasyChatResizing"		, 	"Use easy resizing*"			, 	146, -92, 	"If checked, dragging the General chat tab while the chat frame is locked will expand the chat frame upwards.  The general chat frame doesn't need to be showing to do this.\n\n\If the chat frame is unlocked, dragging the General chat tab will move the frame as normal.\n\nThis is a very useful option that enables you to quickly see more of the recent chat text when required (such as damage meters, loot rolls, etc).\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoCombatLogTab" 			, 	"Hide the combat log*"			, 	146, -112, 	"If checked, the combat log will be hidden.\n\nThis is useful if you never wish to use the combat log.\n\nNote that this option won't disable combat log functionality (since that's impossible) so damage meters and the like will still function correctly.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoChatButtons" 			, 	"Hide chat buttons*"			, 	146, -132, 	"If checked, chat frame buttons will be hidden and the chat frame will no longer be clamped to the screen.\n\nClicking chat tabs will automatically show the latest messages.\n\nYou can middle-click the General chat tab to show the hidden chat menu.\n\nYou can use the mouse wheel to scroll through the chat history.\n\nWhile scrolling, you can hold down SHIFT to scroll a page at a time or CTRL to jump to the top or bottom of your chat history.\n\nEnabling this option prevents you from changing the mouse wheel scroll setting, the whisper mode setting and the conversation mode setting in the Blizzard options.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "MoveChatEditBoxToTop" 		, 	"Move editbox to top*"			,	146, -152, 	"If checked, the editbox will be moved to the top of the chat frame.\n\nEnabling this option will set the Blizzard chat style to classic and prevent you from changing it.\n\n* Requires UI reload.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Spam"						, 	146, -192);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoInterruptSpam"			, 	"Hide interrupt messages"		, 	146, -212, 	"If checked, messages will be blocked in party, raid, say and yell chat if they contain any of the words below" .. LeaPlusLC["InterruptSpamTip"] .. "\n\nThis only applies while you are inside an instance (of any type) and only while you are in combat.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoSpecSpam"				, 	"Block dual-spec spam*"			, 	146, -232, 	"If checked, spell spam caused by switching specs will be blocked.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoNPCSpam"					, 	"Block NPC spam"				, 	146, -252, 	"If checked, all NPC spam (in say or yell) will be blocked.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoNPCSpamRest"				, 	"Only while resting"			, 	166, -272, 	"If checked, NPC spam will only be blocked while your character is resting.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Mechanics"					, 	340, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoStickyChat"				, 	"Use classic chat*"				,	340, -92,	"If checked, you can press enter to talk in group chat using whatever method you used last (say, party, guild, etc).\n\nTo reply to whispers, press r as normal.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "UseArrowKeysInChat"		, 	"Use arrow keys in chat*"		, 	340, -112, 	"If checked, you can press the arrow keys to move the insertion point left and right in the chat frame.\n\nIf unchecked, the arrow keys will use the default keybind setting.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoChatFade"				, 	"Disable chat fade*"			, 	340, -132, 	"If checked, chat text will not fade out after a time period.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "MaxChatHstory"				,	"Increase chat history*"		, 	340, -152, 	"If checked, your chat history will increase to 4096 lines.  If unchecked, the default will be used (128 lines).\n\nEnabling this option may prevent some chat text from showing during login.\n\n* Requires UI reload.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Class Colors"				, 	340, -192);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "Manageclasscolors"			, 	"Manage class colors*"			, 	340, -212, 	"If checked, you will be able to enable or disable class-coloring in the chat frame using the two settings below.  This is a replacement for the Blizzard options panel to make it simpler and account-wide.\n\nEnabling this option will prevent you from changing the class coloring options in the Blizzard chat options.\n\n* Requires UI reload.  After the reload, the checkbox controls below will be available.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ColorLocalChannels"		, 	"Local channel colors"			, 	360, -232, 	"If checked, names will be shown in class color in local channels (such as say, party, raid, etc).\n\nIf unchecked, names will be shown in normal chat color.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ColorGlobalChannels"		, 	"Global channel colors"			,	360, -252, 	"If checked, names will be shown in class color in global channels (such as general, trade, etc).\n\nIf unchecked, names will be shown in normal chat color.")

----------------------------------------------------------------------
-- 	L54: Page 4: Text
----------------------------------------------------------------------

	pg = "Page4";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Zone Text"					, 	146, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "HideZoneText"				,	"Hide zone text*"				,	146, -92, 	"If checked, zone text will not be shown (eg. 'Ironforge').\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "HideSubzoneText"			, 	"Hide subzone text*"			,	146, -112, 	"If checked, subzone text will not be shown (eg. 'Mystic Quarter').\n\n* Requires UI reload.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Error Frame"				, 	146, -152);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "HideErrorFrameText"		, 	"Hide error messages*"			,	146, -172, 	"If checked, error messages (eg. 'Not enough rage') will not be shown in the error frame.\n\nCertain important errors (such as Inventory full, quest log full and votekick errors) will be shown regardless of this setting.\n\nIf you have the minimap button enabled, you can right-click it to toggle error messages without affecting this setting.\n\n* Requires UI reload.  After the reload, the checkbox control below will be available.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowQuestUpdates"			, 	"Show quest updates"			, 	166, -192, 	"If checked, quest updates will be shown in the error frame.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Mail Text Size"			, 	340, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "MailFontChange"			,	"Resize mail text*"				, 	340, -92, 	"If checked, the font used for standard mail will be resized according to the value set by the slider.\n\nIn addition, the text itself will be easier to read.\n\nThis does not affect mail created using templates (such as auction house invoices).\n\n* Requires UI reload.  After the reload, the slider control below will be available.")
	LeaPlusLC:MakeSL(LeaPlusLC[pg], "LeaPlusMailFontSize"		, 	"",	10, 36, 1, 364, -122, "%.0f")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Quest Detail Text Size"	, 	340, -162);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "QuestFontChange"			,	"Resize quest detail text*"		, 	340, -182, 	"If checked, quest detail text will be resized according to the value set by the slider.\n\nEnabling this option will also change the text size on other frames which inherit the same font (such as the Dungeon Finder frame).\n\n* Requires UI reload.  After the reload, the slider control below will be available.")
	LeaPlusLC:MakeSL(LeaPlusLC[pg], "LeaPlusQuestFontSize"		, 	"",	10, 36, 1, 364, -212, "%.0f")

----------------------------------------------------------------------
-- 	L55: Page 5: Tooltip
----------------------------------------------------------------------

	pg = "Page5";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Tooltip Customisation"		, 	146, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipModEnable"				,	"Enable customisation*"			,	146, -92, 	"If checked, Leatrix Plus will manage the tooltip and you will be able to modify it using the checkboxes on this page.\n\nIf you use another addon for tooltip customisation, enabling this option may cause conflicts.\n\n* Requires UI reload.  After the reload, a configuration button will be available to the right and the controls on this page will be available.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Tooltip Details"			, 	146, -132);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipShowTitle"				, 	"Show title"					, 	146, -152, 	"If checked, the unit's title will be shown (if it's a player).")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipShowRealm"				, 	"Show realm"					,	146, -172, 	"If checked, the unit's realm will be shown (if it's different from your own).")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipShowRace"				, 	"Show race"						, 	146, -192, 	"If checked, the unit's race will be shown (if it's a player).")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipShowClass"				, 	"Show class"					, 	146, -212, 	"If checked, the unit's class will be shown (if it's a player).")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipShowRank"				, 	"Show guild rank"				, 	146, -232, 	"If checked, the unit's guild rank will be shown (if it's a player from your own guild).")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipShowMobType"			, 	"Show creature type"			, 	146, -252, 	"If checked, the unit's creature type will be shown (such as 'Humanoid' or 'Beast').")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipShowTarget"				, 	"Show target of target"			, 	146, -272, 	"If checked, the target of the unit will be shown (in class color).")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Backdrops"					, 	340, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipBackSimple"				, 	"Show color backdrops"			,	340, -92, 	"If checked, backdrops will be tinted blue (to indicate a friendly faction) or red (to indicate a hostile faction).")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipBackFriend"				, 	"Friendly class backdrop"		, 	340, -112, 	"If checked, friendly unit backdrops will be tinted with the target's class color.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipBackHostile"			,	 "Enemy class backdrop"			, 	340, -132, 	"If checked, hostile unit backdrops will be tinted with the target's class color.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Tooltip Layout"			, 	340, -172);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipAnchorToMouse"			, 	"Anchor tooltip to mouse*"		,	340, -192, 	"If checked, tooltips will be anchored to the mouse pointer.\n\nYou will be able to specify the anchor, offsets and alpha setting.\n\nIn addition, you will be able to hide tooltips during combat.\n\nNote that if you enable this option, Leatrix Plus will use additional resources in order to control the tooltip.\n\nThe tooltip will be anchored to the pointer for units in the game world, however, tooltips for UI elements (such as spell buttons) will still be shown in a fixed position to prevent cluttering the UI.\n\nTo change the fixed tooltip position, click the move button next to the tooltip customisation option at the top of this page.\n\n* Requires UI reload.  After the reload, a configuration button will be available to the right.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipScaleCheck"				, 	"Rescale the tooltip"			, 	340, -212, 	"If checked, tooltips will be rescaled to the value set by the slider.\n\nIf unchecked, the default value (1.00) will be used.")
	LeaPlusLC:MakeSL(LeaPlusLC[pg], "LeaPlusTipSize", "", 0.50, 3.00, 0.05, 364, -242, "%.2f")

	LeaPlusLC:CreateButton("MoveTooltipButton", LeaPlusLC[pg], "?", "BOTTOMLEFT", 0, 0, 20, 20, "Click to move the tooltip.")
	LeaPlusCB["MoveTooltipButton"]:ClearAllPoints()
	LeaPlusCB["MoveTooltipButton"]:SetPoint("LEFT", LeaPlusCB["TipModEnable"].f, "RIGHT", 0, 0)

	LeaPlusLC:CreateButton("ModTipMouseBtn", LeaPlusLC[pg], "?", "BOTTOMLEFT", 0, 0, 20, 20, "Click to change the anchor to mouse pointer settings.\n\nYou can change the tooltip anchor (this is the fixed part of the tooltip), the offsets (distance from the pointer) and the alpha setting (transparency).\n\nIn addition, you can hide tooltips during combat.  If you enable this option, you can show tooltips temporarily by holding down the SHIFT key.\n\nNote that anchor to mouse settings apply only to tooltips in the game world and not to the UI.")
	LeaPlusCB["ModTipMouseBtn"]:ClearAllPoints()
	LeaPlusCB["ModTipMouseBtn"]:SetPoint("LEFT", LeaPlusCB["TipAnchorToMouse"].f, "RIGHT", 0, 0)

----------------------------------------------------------------------
-- 	L56: Page 6: Interface
----------------------------------------------------------------------

	pg = "Page6";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "World Map"					, 	146, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowMapMod"				, 	"Enable customisation*"			, 	146, -92, 	"If checked, you will be able to customise the world map.\n\nYou will be able to change the scale, opacity and position of the map and these settings will be saved account-wide.\n\nIn addition, checkboxes will be added to the bottom of the map allowing you to reveal unexplored areas and show quest details when clicking quest objectives.\n\nFinally, you will be able to show cursor coordinates and use the mousewheel to traverse maps with multiple floors (such as Karazhan).\n\nNote that if you enable this option, you will not be able to switch to the fullscreen map.\n\nYou can zoom in by left-clicking a location and zoom out by right-clicking any area of the map.\n\nIf you use another addon for map modification, enabling this option may cause conflicts.\n\n* Requires UI reload.  After the reload, a configuration button will be available to the right.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Minimap"					, 	146, -132);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "MinimapMod"				,	"Enable customisation*"			, 	146, -152, 	"If checked, you will be able to change the scale of the minimap.\n\nIf you use another addon to modify the minimap, enabling this option may cause conflicts.\n\n* Requires UI reload.  After the reload, a configuration button will be available to the right.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Frames"					, 	146, -192);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "FrmEnabled"				,	"Enable customisation*"			, 	146, -212, 	"If checked, Leatrix Plus will manage the positions of the player frame, target frame, world state, ghost frame and timer bar.\n\nYou will be able to move these frames to your desired locations and your layout will be saved account-wide.\n\nIn addition, you will be able to change the frame scale.\n\nIf you use another addon for frame movement, enabling this option may cause conflicts.\n\n* Requires UI reload.  After the reload, a configuration button will be available to the right.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Controls"					, 	340, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowVanityButtons"			,	"Show vanity controls*"			, 	340, -92, 	"If checked, two buttons will be added to the character sheet to allow you to toggle your helm and cloak easily.\n\nThese checkboxes are not clickable while your character is dead.\n\nThe boxes can be placed in either of two locations on the character sheet.  To toggle between them, hold down SHIFT and right-click one of the boxes.\n\nNote that there is a small delay after clicking a checkbox before it takes effect.\n\nif you toggle these checkboxes too quickly, they may seem to stop working.  If that happens, just wait a few seconds.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowVolume"				, 	"Show volume control*"			, 	340, -112, 	"If checked, a master volume slider will be shown in the character sheet.\n\nThe volume control can be placed in either of two locations on the character sheet.  To toggle between them, hold down SHIFT and right-click it.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "DungeonFinderButtons"		, 	"Show dungeon buttons*"			,	340, -132, 	"If checked, a time button will be shown in the Dungeon Finder frame which will toggle your random dungeon cooldown.\n\nA checkbox will also be available next to it.  If checked, target markers placed on your character will be automatically removed.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowDressTab"				, 	"Show dressup button*"			, 	340, -152, 	"If checked, a button will be added to the dressup frame which will allow you to hide your tabard.\n\n* Requires UI reload.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Information"				, 	340, -192);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "StaticCoordsEn"			, 	"Show coordinates*"				, 	340, -212, 	"If checked, coordinates representing your character's location will be shown in a movable frame.  You will be able to drag the frame to your preferred location.\n\n* Requires UI reload.  After the reload, a configuration button will be available to the right.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowSpellIcons"			, 	"Show spell icons*"				, 	340, -232, 	"If checked, spell icons will be shown above the target or player frame.\n\nThis option is designed for watching spells where it's useful to know how long a spell has left to run before it expires (such as a hunter's Mend Pet spell or a mage's Ice Barrier spell).\n\nOnly beneficial spells that are placed on you or your pet can be used with this option.\n\nEnabling this option will prevent you from using the Blizzard option to place buffs above the target frame.\n\n* Requires UI reload.  After the reload, a configuration button will be available to the right.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowHonorStat"				,	"Show honorable kills*"			, 	340, -252, 	"If checked, the total number of lifetime honorable kills for your character will be shown in the tooltip for the honor points icon (shown at the top of the honor window).\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "DurabilityStatus"			, 	"Show durability status*"		, 	340, -272, 	"If checked, your equipped item durability status will be shown when you hover over the expand button on the character sheet (bottom-right corner).\n\nIn addition, an overall percentage will be shown in the chat frame after you come back to life following death.\n\n* Requires UI reload.")

	LeaPlusLC:CreateButton("MapOptBtn", LeaPlusLC[pg], "?", "BOTTOMLEFT", 0, 0, 20, 20, "Click to modify the world map settings.")
	LeaPlusCB["MapOptBtn"]:ClearAllPoints()
	LeaPlusCB["MapOptBtn"]:SetPoint("LEFT", LeaPlusCB["ShowMapMod"].f, "RIGHT", 0, 0)

	LeaPlusLC:CreateButton("ModMinimapBtn", LeaPlusLC[pg], "?", "BOTTOMLEFT", 0, 0, 20, 20, "Click to modify the minimap settings.")
	LeaPlusCB["ModMinimapBtn"]:ClearAllPoints()
	LeaPlusCB["ModMinimapBtn"]:SetPoint("LEFT", LeaPlusCB["MinimapMod"].f, "RIGHT", 0, 0)

	LeaPlusLC:CreateButton("MoveFramesButton", LeaPlusLC[pg], "?", "TOPLEFT", 0, 0, 20, 20,"Click to modify the frame settings.\n\nTo move a frame, simply drag it to a new location.\n\nTo change the scale of a frame, click to highlight it (green tint) then drag the scale slider.\n\nThe player frame is not clamped to the screen (unlike the other frames) so take care when modifying the scale of it.\n\nClicking the reset button will reset all frame positions and scales.")
	LeaPlusCB["MoveFramesButton"]:ClearAllPoints()
	LeaPlusCB["MoveFramesButton"]:SetPoint("LEFT", LeaPlusCB["FrmEnabled"].f, "RIGHT", 0, 0)

	LeaPlusLC:CreateButton("SpellIconsBtn", LeaPlusLC[pg], "?", "BOTTOMLEFT", 0, 0, 20, 20, "Click to modify the spell icons.\n\nEnter the spell ID for each of the spell icons that you want to see.  Spell IDs are shown in the tooltips of beneficial spell icons in the buff frame and under the target frame.\n\nIf you want the spell icon to show only when the spell is stacked, enter the minimum number of stacks required (otherwise leave it blank).\n\nIf the spell icon normally appears under the pet frame, check the pet checkbox.\n\nHover your pointer over the spell ID editbox to see the spell name for the ID that you have entered.")
	LeaPlusCB["SpellIconsBtn"]:ClearAllPoints()
	LeaPlusCB["SpellIconsBtn"]:SetPoint("LEFT", LeaPlusCB["ShowSpellIcons"].f, "RIGHT", 0, 0)

	LeaPlusLC:CreateButton("ModStaticCoordsBtn", LeaPlusLC[pg], "?", "BOTTOMLEFT", 0, 0, 20, 20, "Click to modify the coordinates settings.")
	LeaPlusCB["ModStaticCoordsBtn"]:ClearAllPoints()
	LeaPlusCB["ModStaticCoordsBtn"]:SetPoint("LEFT", LeaPlusCB["StaticCoordsEn"].f, "RIGHT", 0, 0)

----------------------------------------------------------------------
-- 	L57: Page 7: Miscellaneous
----------------------------------------------------------------------

	pg = "Page7";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Graphics"					, 	146, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoDeathEffect"				, 	"Hide death effect"				, 	146, -92, 	"If checked, the death effect will not be shown.\n\nThis is the grey screen glow that appears while your character is a ghost.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoSpecialEffects"			, 	"Hide special effects"			, 	146, -112, 	"If checked, the netherworld effect (such as mage Invisibility) and special effects (such as the mist in Borean Tundra) will not be shown.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoGlowEffect"				, 	"Remove screen glow"			, 	146, -132, 	"If checked, the screen glow will not be shown.\n\nThis is useful if you find the screen to be too bright.\n\nIt also has a handy side effect in that it blocks the blurry haze effect while your character is drunk.\n\nEnabling this option may increase your overall graphics performance.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowElitePlayerChain"		, 	"Show player chain*"			,	146, -152, 	"If checked, your player portrait will have an elite gold chain around it.\n\n* Requires UI reload.  After the reload, the checkbox control below will be available.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowRarePlayerChain"		, 	"Make it silver"				,	166, -172, 	"If checked, the player chain will be silver instead of gold.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ManageZoomLevel"			, 	"Manage zoom distance*"			,	146, -192, 	"If checked, you will be able to increase the camera's maximum zoom distance using the slider below.\n\nIncreasing the zoom distance can help with lots of encounters where you need to see more of the area around you.\n\nIf you enable this option, the camera distance setting in the Blizzard options panel will be unavailable (since this option will override it).\n\n* Requires UI reload.  After the reload, the slider control below will be available.")
	LeaPlusLC:MakeSL(LeaPlusLC[pg], "ZoomOutLevel", "", 15, 50, 1, 170, -222, "%.0f")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Viewport"					, 	340, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ViewPortEnable"			,	"Enable viewport*"				,	340, -92, 	"If checked, you will be able to create a viewport.  A viewport adds adjustable black borders around the game world.\n\nThe borders are placed on top of the game world but under the UI so you can place UI elements over them.\n\nIn addition, you will be able to resize the game world to fit between the top and bottom borders if you wish.\n\n* Requires UI reload.  After the reload, a configuration button will be available to the right.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Frame Visibility"			, 	340, -132);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoGryphons"				,	"Hide gryphons*"				, 	340, -152, 	"If checked, the Blizzard gryphons will not be shown either side of the main bar.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoClassBar"				,	"Hide stance bar*"				, 	340, -172, 	"If checked, the stance bar will not be shown.\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoCharControls"			,	"Hide character controls*"		,	340, -192, 	"If checked, control buttons (such as zoom) will not be shown at the top of the character frame and dressup frame.\n\n* Requires UI reload.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Privacy"					, 	340, -232);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "AchieveControl"			, 	"Manage privacy*"				,	340, -252, 	"If checked, you will be able to select whether to show character based or account based achievement points when people inspect your character.\n\nIf unchecked, you will need to use the Blizzard setting (in the Display menu) on a per character basis.\n\nThis is a replacement for the Blizzard options panel setting to make it account-wide.\n\n* Requires UI reload.  After the reload, the checkbox control below will be available.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "CharOnlyAchieves"			, 	"Protect privacy"				,	366, -272, 	"If checked, only your character's achievement points will be shown to players inspecting you.\n\nIf unchecked, the totals shown will include all characters on your Battle.net account.\n\n* Requires UI reload.")

	LeaPlusLC:CreateButton("ModViewportBtn", LeaPlusLC[pg], "?", "BOTTOMLEFT", 0, 0, 20, 20, "Click to modify the viewport settings.")
	LeaPlusCB["ModViewportBtn"]:ClearAllPoints()
	LeaPlusCB["ModViewportBtn"]:SetPoint("LEFT", LeaPlusCB["ViewPortEnable"].f, "RIGHT", 0, 0)
	LeaPlusCB["ViewPortEnable"]:SetHitRectInsets(0,-80,0,0); -- Reduce click area of checkbox to avoid conflicts

----------------------------------------------------------------------
-- 	L58: Settings
----------------------------------------------------------------------

	pg = "PageS";

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Settings"					, 146, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowMinimapIcon"			, "Show minimap button*"			, 146, -92, 	"If checked, a minimap button will be available.\n\nLeft-clicking it will launch the options panel.\n\nRight-clicking it will toggle error messages (if the option to hide error messages is enabled).  The button color will change to red while error messages are showing.\n\nMiddle-clicking it will toggle the Recount window (if you have Recount installed).\n\nHolding down SHIFT and left-clicking it will toggle the in-game music setting.\n\nHolding down SHIFT and right-clicking it will toggle showing coordinates (if the coordinates option is enabled).\n\n* Requires UI reload.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowBackground"			, "Show background"					, 146, -112, 	"If checked, the options panel background image will be shown.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowStartTag"				, "Show startup message"			, 146, -132, 	"If checked, the addon name and version will be shown in chat when you login or reload your UI.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "OpenPlusAtHome"			, "Show home on startup"			, 146, -152, 	"If checked, the home page will always be shown when you open Leatrix Plus.\n\nIf unchecked, Leatrix Plus will open with the page that you were on when you last closed it.")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Tooltips"					, 146, -192);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "PlusShowTips"				, "Show option tooltips"			, 146, -212, 	"If checked, tooltips will be shown for all of the checkboxes and buttons in the Leatrix Plus options panel.\n\nThe tooltips will be placed on the right side of the options panel.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "PanelTipAnchor"			, "On the left side"				, 166, -232, 	"If checked, tooltips will be placed on the left side of the options panel instead of the right.")
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "PlusFaceTips"				, "Show interface tips"				, 146, -252, 	"If checked, tooltips will be shown for the checkboxes and buttons which Leatrix Plus creates in the Blizzard interface panels (such as the world map checkboxes if map customisation is enabled).")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Panel Alpha"				, 340, -72);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "PlusPanelAlphaCheck"		, "Modify panel alpha"				, 340, -92, 	"If checked, you will be able to change the alpha (transparency) of the options panel.  If unchecked, the normal alpha will be used.")
	LeaPlusLC:MakeSL(LeaPlusLC[pg], "LeaPlusAlphaValue"		, "", 0.0, 1.0, 0.1, 364, -122, "%.1f")

	LeaPlusLC:MakeTx(LeaPlusLC[pg], "Panel Scale"				, 340, -162);
	LeaPlusLC:MakeCB(LeaPlusLC[pg], "PlusPanelScaleCheck"		, "Modify panel scale"				, 340, -182, 	"If checked, you will be able to change the scale of the options panel.  If unchecked, the normal scale will be used.")
	LeaPlusLC:MakeSL(LeaPlusLC[pg], "LeaPlusScaleValue"		, "", 0.5, 1.7, 0.1, 364, -212, "%.1f")

	LeaPlusLC:ShowMemoryUsage(LeaPlusLC[pg], "TOPLEFT", 340, -286, "Memory Usage: ")

	LeaPlusLC:CreateButton("SettingsButton", LeaPlusLC["PageF"], "Settings", "BOTTOMLEFT", 90, 10, 70, 25, "Click to change the options panel settings (such as whether tooltips are shown, whether the minimap button is shown and the layout of the panel itself).\n\nYou will also be able to see the memory usage of the addon.")
	LeaPlusLC:CreateButton("SetDefaultsButton", LeaPlusLC[pg], "Reset", "BOTTOMLEFT", 170, 10, 70, 25, "This button will set most of the options in Leatrix Plus back to the default settings.  Your UI will be reloaded.\n\nThis does not reset options which offer additional configuration (dungeon roles, tooltip customisation, frame customisation, map customisation, minimap customisation, viewport settings, spell icon profiles and coordinates).  In addition, privacy settings will not be reset.\n\nAs a precaution, you need to hold down CTRL and SHIFT while clicking this button in order for it to work.")
	LeaPlusLC:CreateButton("WipeAllButton", LeaPlusLC[pg], "Wipe", "BOTTOMLEFT", 250, 10, 70, 25, "This button will wipe ALL your Leatrix Plus settings.  Your UI will be reloaded.\n\nEverything will be wiped including the options which offer additional configuration and privacy settings.\n\nAs a precaution, you need to hold down CTRL and SHIFT while clicking this button in order for it to work.")

	LeaPlusCB["SettingsButton"]:SetScript("OnClick", function()
		LeaPlusLC:HideFrames();
		LeaPlusLC["PageF"]:Show();
		LeaPlusLC["PageS"]:Show();
		LeaPlusLC["LeaStartPage"] = "S";
	end)
