local _G = getfenv(0)

function Skinner:Tooltips()
	if not self.db.profile.Tooltips.skin or self.initialized.Tooltips then return end
	self.initialized.Tooltips = true

	-- fix for TinyTip tooltip becoming 'fractured'
	if self.db.profile.Tooltips.style == 3 then
		GameTooltip:SetBackdrop(backdrop)
		ShoppingTooltip1:SetBackdrop(backdrop)
		ShoppingTooltip2:SetBackdrop(backdrop)
		ItemRefTooltip:SetBackdrop(backdrop)
		SmallTextTooltip:SetBackdrop(backdrop)
	end

	self:HookScript(GameTooltip, "OnShow", function(object)
--	   	self:Debug("GameTooltip_OnShow: [%s, %s]", this:GetName(), object:GetName())
		self.hooks[GameTooltip].OnShow(object)
		self:skinTooltip(object)
		if self.db.profile.Tooltips.glazesb then self:glazeStatusBar(GameTooltipStatusBar, 0) end
		end)
	
	self:HookScript(ShoppingTooltip1, "OnShow", function(object)
--	   	self:Debug("ShoppingTooltip1_OnShow: [%s, %s]", this:GetName(), object:GetName())
		self.hooks[ShoppingTooltip1].OnShow(object)
		self:skinTooltip(object)
		end)
	
	self:HookScript(ShoppingTooltip2, "OnShow", function(object)
--	   	self:Debug("ShoppingTooltip2_OnShow: [%s, %s]", this:GetName(), object:GetName())
		self.hooks[ShoppingTooltip2].OnShow(object)
		self:skinTooltip(object)
		end)
	
	self:HookScript(ItemRefTooltip, "OnShow", function(object)
--		self:Debug("ItemRefTooltip_OnShow: [%s, %s]", this:GetName(), object:GetName())
		self.hooks[ItemRefTooltip].OnShow(object)
		self:skinTooltip(object)
		end)
	
	self:HookScript(SmallTextTooltip, "OnShow", function(object)
--		self:Debug("SmallTextTooltip_OnShow: [%s, %s]", this:GetName(), object:GetName())
		self.hooks[SmallTextTooltip].OnShow(object)
		self:skinTooltip(object)
		end)
	
end

function Skinner:MirrorTimers()
	if not self.db.profile.MirrorTimers.skin or self.initialized.MirrorTimers then return end
	self.initialized.MirrorTimers = true
	
	for i = 1, MIRRORTIMER_NUMTIMERS do
		local mTimer = _G["MirrorTimer"..i]
		local mTimerSB = _G["MirrorTimer"..i.."StatusBar"]
		self:keepRegions(mTimer, {2}) -- N.B. region 2 is text
		mTimer:SetHeight(mTimer:GetHeight() * 1.1)
		mTimerSB:SetWidth(mTimerSB:GetWidth() * 0.75)
		self:moveObject(_G[mTimer:GetName().."Text"], nil, nil, "-", 2)
		if self.db.profile.MirrorTimers.glaze then self:glazeStatusBar(mTimerSB, 0)	end
	end
	
end

function Skinner:QuestTimers()
	if not self.db.profile.MirrorTimers or self.initialized.QuestTimers then return end
	self.initialized.QuestTimers = true
	
	self:keepRegions(QuestTimerFrame, {11}) -- N.B. region 11 is text
	QuestTimerFrame:SetWidth(QuestTimerFrame:GetWidth() - 40)
	QuestTimerFrame:SetHeight(QuestTimerFrame:GetHeight() - 20)
	self:moveObject(QuestTimerHeader, nil, nil, "-", 4)
	self:applySkin(QuestTimerFrame)
	
end

function Skinner:CastingBar()
	if not self.db.profile.CastingBar.skin or self.initialized.CastingBar then return end
	self.initialized.CastingBar = true

	self:removeRegions(CastingBarFrame, {1, 3})
	CastingBarFrame:SetWidth(CastingBarFrame:GetWidth() * 0.75)
	CastingBarFrame:SetHeight(CastingBarFrame:GetHeight() * 1.1)
	CastingBarFrameSpark:SetHeight(CastingBarFrameSpark:GetHeight() * 1.5)
	CastingBarFrameFlash:SetWidth(CastingBarFrame:GetWidth())
	CastingBarFrameFlash:SetHeight(CastingBarFrame:GetHeight())
	CastingBarFrameFlash:SetTexture("Interface\\AddOns\\Skinner\\textures\\glaze")
	self:moveObject(CastingBarFrameText, nil, nil, "-", 3)
	self:moveObject(CastingBarFrameFlash, nil, nil, "-", 28)
	if self.db.profile.CastingBar.glaze then 
		self:glazeStatusBar(CastingBarFrame, 0)
	end
	self:SecureHook("CastingBarFrame_OnUpdate", function()
		self:moveObject(CastingBarFrameSpark, "+", 0, "-", 3)
		end)
	
end

function Skinner:StaticPopups()
	if not self.db.profile.StaticPopups or self.initialized.StaticPopups then return end
	self.initialized.StaticPopups = true
	                                           
	for i = 1, STATICPOPUP_NUMDIALOGS do
		self:applySkin(_G["StaticPopup"..i])
		self:skinEditBox(_G["StaticPopup"..i.."WideEditBox"])
		self:skinEditBox(_G["StaticPopup"..i.."EditBox"])
	end
	
end

function Skinner:ChatTabs()
	if not self.db.profile.ChatTabs or self.initialized.ChatTabs then return end
	self.initialized.ChatTabs = true

    if self.db.profile.TexturedTab then 
    	self:SecureHook("FCF_SetTabPosition", function(chatFrame, x)
--  		self:Debug("FCF_SetTabPosition: [%s, %s]", chatFrame:GetName(), x)
    		self:moveObject(_G[chatFrame:GetName().."Tab"], nil, nil, "-", 4)
    		end)
    
    	for i = 1, NUM_CHAT_WINDOWS do
    		local tabName = _G["ChatFrame"..i.."Tab"]
    		self:keepRegions(tabName, {4, 5}) --N.B. region 4 is text, 5 is highlight
    		self:moveObject(tabName, nil, nil, "-", 4)
    		self:moveObject(_G[tabName:GetName().."Flash"], nil, nil, "+", 4)
    		local textObj
    		-- move text and highlight area and resize highlight
			self:moveObject(self:getRegion(tabName, 4), "+", 5, "+", 4)
			textObj = self:getRegion(tabName, 4)
			self:moveObject(self:getRegion(tabName, 5), "+", 5, "+", 5)
			self:getRegion(tabName, 5):SetWidth(textObj:GetWidth()  + 30)
    		self:applySkin(tabName, nil, 0)
    		self:setActiveTab(tabName)
    	end
    else
    	for i=1, NUM_CHAT_WINDOWS do
    		self:removeRegions(_G["ChatFrame"..i.."Tab"], {1, 2, 3})
    		self:createTab(_G["ChatFrame"..i.."Tab"])
    	end
	end
	
end

function Skinner:ChatFrames()
	if not self.db.profile.ChatFrames or self.initialized.ChatFrames then return end
	self.initialized.ChatFrames = true

	self:SecureHook("FCF_StopResize", function()
--		self:Debug("FCF_StopResize: [%s, %s]", this:GetName(), this:GetParent():GetName())
		local frame = _G["Skinner"..this:GetParent():GetName()]
		frame.tfade:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -4, -math.ceil(frame:GetHeight()))
		end)
		
	for i=1, NUM_CHAT_WINDOWS do
		self:createCF(_G["ChatFrame"..i])
	end
	
end

function Skinner:createTab(parent)
--	self:Debug("createTab: [%s]", parent)

	oct = CreateFrame("frame", nil, parent)
	oct:SetFrameStrata("BACKGROUND")
	oct:SetFrameLevel(0)
	oct:ClearAllPoints()
	oct:SetPoint("TOPLEFT", parent, "TOPLEFT", 0, -8)
	oct:SetPoint("TOPRIGHT", parent, "TOPRIGHT", 0, -8)
	oct:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", 0, -5)
	oct:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", 0, -5)
	self:applySkin(oct)
	
end

function Skinner:createCF(parent)
--	self:Debug("createCF: [%s]", parent)

	ocf = CreateFrame("frame", "Skinner"..parent:GetName(), parent)
	ocf:SetFrameStrata("BACKGROUND")
	ocf:SetFrameLevel(0)
	ocf:ClearAllPoints()
	ocf:SetPoint("TOPLEFT", parent, "TOPLEFT", -4, 4)
	ocf:SetPoint("TOPRIGHT", parent, "TOPRIGHT", 4, 4)
	ocf:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", -4, -8)
	ocf:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", 4, -8)
	self:applySkin(ocf)

end

function Skinner:ChatEditBox()
	if not self.db.profile.ChatEditBox.skin then return end 

	if self.db.profile.ChatEditBox.style == 1 then
		self:keepRegions(ChatFrameEditBox, {1, 2, 3, 4, 5})
		self:applySkin(ChatFrameEditBox)
	else
		self:skinEditBox(ChatFrameEditBox, nil, nil, true)
	end
		
end

function Skinner:LootFrame()
	if not self.db.profile.LootFrame or self.initialized.LootFrame then return end
	self.initialized.LootFrame = true

	self:removeRegions(LootFrame, {1, 2})
	
	LootFrame:SetWidth(LootFrame:GetWidth() * 0.66)
	LootFrame:SetHeight(LootFrame:GetHeight() * FyMult)
	self.LFHeight = math.floor(LootFrame:GetHeight())

	self:moveObject(self:getRegion(LootFrame, 3), "+", 15, "-", 10) -- region 3 is the title
	_, _, _, self.LFxOfs, self.LFyOfs = self:getRegion(LootFrame, 3):GetPoint()
	
	self:moveObject(LootCloseButton, "+", 65, "+", 10)
	self:moveObject(LootButton1, "-", 13, "+", 40)
    self:moveObject(LootFramePrev, "-", 15, nil, nil)	
    self:moveObject(LootFrameNext, "-", 0, nil, nil)	
	self:moveObject(LootFrameUpButton, "-", 15, nil, nil)
	self:moveObject(LootFrameDownButton, "-", 0, nil, nil)

	self:applySkin(LootFrame, 1)
	
end

function Skinner:GroupLoot()
	if not self.db.profile.GroupLoot.skin or self.initialized.GroupLoot then return end
	self.initialized.GroupLoot = true

	self:Hook("GroupLootFrame_OnShow", function()
		local texture, name, count, quality, bindOnPickUp = GetLootRollItemInfo(this.rollID)
		_G["GroupLootFrame"..this:GetID().."IconFrameIcon"]:SetTexture(texture)
		_G["GroupLootFrame"..this:GetID().."Name"]:SetText(name)
		local color = ITEM_QUALITY_COLORS[quality]
		_G["GroupLootFrame"..this:GetID().."Name"]:SetVertexColor(color.r, color.g, color.b)
		_G["GroupLootFrame"..this:GetID().."Timer"]:SetStatusBarColor(color.r, color.g, color.b)
		end, true)

	self:keepRegions(GroupLootDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	local f = GameFontNormalSmall:GetFont()

	for i = 1, NUM_GROUP_LOOT_FRAMES do
	
		local glf = "GroupLootFrame"..i
		self:removeRegions(_G[glf], {4, 5}) -- N.B. regions 1-3 are text
	
		if self.db.profile.GroupLoot.size == 1 then 
		
			_G[glf]:SetWidth(_G[glf]:GetWidth() * 0.95)
			_G[glf]:SetHeight(_G[glf]:GetHeight() * FyMult)
	
			self:moveObject(_G[glf.."SlotTexture"], "-", 3, "+", 5)
			self:moveObject(_G[glf.."RollButton"], "+", 6, "+", 6)

		elseif self.db.profile.GroupLoot.size == 2 then
	
			_G[glf]:SetWidth(_G[glf]:GetWidth() * 0.78)
			_G[glf]:SetHeight(_G[glf]:GetHeight() * 0.65)
	
			local xMult, yMult = 0.75, 0.75
			_G[glf.."SlotTexture"]:SetWidth(_G[glf.."SlotTexture"]:GetWidth() * xMult)
			_G[glf.."SlotTexture"]:SetHeight(_G[glf.."SlotTexture"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."SlotTexture"], "-", 2, "+", 4)
			_G[glf.."NameFrame"]:SetWidth(_G[glf.."NameFrame"]:GetWidth() - 15)
			_G[glf.."NameFrame"]:SetHeight(_G[glf.."NameFrame"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."NameFrame"], "+", 2, "+", 2)
			_G[glf.."Name"]:SetFont(f, 7)
			self:moveObject(_G[glf.."Name"], "+", 3, "-", 4)
			_G[glf.."PassButton"]:SetWidth(_G[glf.."PassButton"]:GetWidth() * xMult)
			_G[glf.."PassButton"]:SetHeight(_G[glf.."PassButton"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."PassButton"], nil, nil, "+", 3)
			_G[glf.."RollButton"]:SetWidth(_G[glf.."RollButton"]:GetWidth() * xMult)
			_G[glf.."RollButton"]:SetHeight(_G[glf.."RollButton"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."RollButton"], "+", 13, "+", 7)
			_G[glf.."GreedButton"]:SetWidth(_G[glf.."GreedButton"]:GetWidth() * xMult)
			_G[glf.."GreedButton"]:SetHeight(_G[glf.."GreedButton"]:GetHeight() * yMult)
			_G[glf.."IconFrame"]:SetWidth(_G[glf.."IconFrame"]:GetWidth() * xMult)
			_G[glf.."IconFrame"]:SetHeight(_G[glf.."IconFrame"]:GetHeight() * yMult)
			_G[glf.."IconFrameIcon"]:SetWidth(_G[glf.."IconFrameIcon"]:GetWidth() * 0.8)
			_G[glf.."IconFrameIcon"]:SetHeight(_G[glf.."IconFrameIcon"]:GetHeight() * 0.8)
			_G[glf.."IconFrameIcon"]:SetAlpha(1)
			self:moveObject(_G[glf.."IconFrameIcon"], "-", 5, "+", 5)
			_G[glf.."Timer"]:SetWidth(_G[glf.."Timer"]:GetWidth() * xMult)
			_G[glf.."Timer"]:SetHeight(_G[glf.."Timer"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."Timer"], "-", 2, "-", 3)	
		
		elseif self.db.profile.GroupLoot.size == 3 then
	
			_G[glf]:SetWidth(_G[glf]:GetWidth() * 0.35)
			_G[glf]:SetHeight(_G[glf]:GetHeight() * 0.65)
	
			local xMult, yMult = 0.75, 0.75
			_G[glf.."SlotTexture"]:SetWidth(_G[glf.."SlotTexture"]:GetWidth() * xMult)
			_G[glf.."SlotTexture"]:SetHeight(_G[glf.."SlotTexture"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."SlotTexture"], "-", 5, "+", 5)
			_G[glf.."NameFrame"]:Hide()
			_G[glf.."Name"]:Hide()
			_G[glf.."PassButton"]:SetWidth(_G[glf.."PassButton"]:GetWidth() * xMult)
			_G[glf.."PassButton"]:SetHeight(_G[glf.."PassButton"]:GetHeight() * yMult)
			_G[glf.."RollButton"]:SetWidth(_G[glf.."RollButton"]:GetWidth() * xMult)
			_G[glf.."RollButton"]:SetHeight(_G[glf.."RollButton"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."RollButton"], "+", 15, "+", 10)
			_G[glf.."GreedButton"]:SetWidth(_G[glf.."GreedButton"]:GetWidth() * xMult)
			_G[glf.."GreedButton"]:SetHeight(_G[glf.."GreedButton"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."GreedButton"], nil, nil, "+", 3)
			_G[glf.."IconFrame"]:SetWidth(_G[glf.."IconFrame"]:GetWidth() * xMult)
			_G[glf.."IconFrame"]:SetHeight(_G[glf.."IconFrame"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."IconFrame"], "-", 5, "+", 5)
			_G[glf.."IconFrameIcon"]:SetWidth(_G[glf.."IconFrameIcon"]:GetWidth() * xMult + 2)
			_G[glf.."IconFrameIcon"]:SetHeight(_G[glf.."IconFrameIcon"]:GetHeight() * yMult + 2)
			_G[glf.."IconFrameIcon"]:SetAlpha(1)
			_G[glf.."Timer"]:SetWidth(_G[glf.."Timer"]:GetWidth() * 0.35)
			_G[glf.."Timer"]:SetHeight(_G[glf.."Timer"]:GetHeight() * yMult)
			self:moveObject(_G[glf.."Timer"], "-", 2, "-", 4)	
		
		end

		self:removeRegions(_G[glf.."Timer"], {1})
		self:glazeStatusBar(_G[glf.."Timer"])
	
		self:applySkin(_G[glf])
	end
	
end

function Skinner:ContainerFrames()
	if not self.db.profile.ContainerFrames.skin or self.initialized.ContainerFrames then return end
	self.initialized.ContainerFrames = true

	self:SecureHook("ContainerFrame_GenerateFrame")	

	for i = 1, NUM_CONTAINER_FRAMES do
		self:keepRegions(_G["ContainerFrame"..i], {6}) -- N.B. region 6 is text
		self:moveObject(_G["ContainerFrame"..i.."Name"], "-", 5, nil, nil)
		local CFfh = self.db.profile.ContainerFrames.fheight <= math.ceil(_G["ContainerFrame"..i]:GetHeight()) and self.db.profile.ContainerFrames.fheight or math.ceil(_G["ContainerFrame"..i]:GetHeight())	
		self:applySkin(_G["ContainerFrame"..i], nil, nil, nil, CFfh)
	end

end

function Skinner:ContainerFrame_GenerateFrame(frameObj, size, id)

	frame = frameObj:GetName()
	
	if ( id > NUM_BAG_FRAMES ) then
		_G[frame.."Name"]:SetTextColor(.3, .3, 1)
	elseif ( id == KEYRING_CONTAINER ) then
		_G[frame.."Name"]:SetTextColor(1, .7, 0)
	else
		_G[frame.."Name"]:SetTextColor(1, 1, 1)
	end

	self:shrinkBag(frameObj, true)	

end

function Skinner:StackSplit()
	if not self.db.profile.StackSplit or self.initialized.StackSplit then return end
	self.initialized.StackSplit = true
	
	self:removeRegions(StackSplitFrame, {1}) -- N.B. region 2 is text
	StackSplitFrame:SetWidth(StackSplitFrame:GetWidth() - 12)
	StackSplitFrame:SetHeight(StackSplitFrame:GetHeight() - 28)
	self:moveObject(StackSplitText, nil, nil, "-", 5)	
	self:moveObject(StackSplitLeftButton, "+", 5, "-", 5)	
	self:moveObject(StackSplitRightButton, "-", 5, "-", 5)	
	self:moveObject(StackSplitOkayButton, nil, nil, "-", 13)	
	self:moveObject(StackSplitCancelButton, nil, nil, "-", 13)	

	self:applySkin(StackSplitFrame)

end

function Skinner:ItemText()
	if not self.db.profile.ItemText or self.initialized.ItemText then return end
	self.initialized.ItemText = true
	
	self:SecureHook("ItemTextFrame_OnEvent", function(event)
--		self:Debug("ItemTextFrame_OnEvent: [%s]", event)
		if event == "ITEM_TEXT_BEGIN" then
			ItemTextPageText:SetTextColor(BTr, BTg, BTb)
		end
		end)
	
	self:removeRegions(ItemTextFrame, {1, 2, 3, 4, 5, 6, 7, 8, 9}) -- N.B. region 10 & 11 are text
	ItemTextFrame:SetWidth(ItemTextFrame:GetWidth() - 30)
	ItemTextFrame:SetHeight(ItemTextFrame:GetHeight() - 60)
	self:moveObject(ItemTextTitleText, nil, nil, "-", 24)

	self:removeRegions(ItemTextScrollFrame)
	self:moveObject(ItemTextScrollFrame, "+", 30, "+", 20)
	self:skinScrollBar(ItemTextScrollFrame)
	self:moveObject(ItemTextStatusBar, nil, nil, "-", 115)
	self:glazeStatusBar(ItemTextStatusBar, 0)
	self:moveObject(ItemTextPrevPageButton, "-", 45, "+", 10)
	self:moveObject(ItemTextNextPageButton, "+", 10, "+", 10)
	self:moveObject(ItemTextCloseButton, "+", 28, "+", 8)
	
	self:applySkin(ItemTextFrame)
	
end

function Skinner:ColorPicker()
	if not self.db.profile.Colours or self.initialized.Colours then return end
	self.initialized.Colours = true

	self:applySkin(ColorPickerFrame, 1)
	self:applySkin(OpacityFrame)

end

function Skinner:WorldMap()
	if not self.db.profile.WorldMap or self.initialized.WorldMap then return end
	self.initialized.WorldMap = true

	self:keepRegions(WorldMapFrame, {14}) -- N.B. region 14 is text
	self:keepRegions(WorldMapContinentDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(WorldMapZoneDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	
	if not IsAddOnLoaded("MetaMap") and not IsAddOnLoaded("Cartographer") then
		self:moveObject(WorldMapFrameCloseButton, "+", 98, "-", 4)
		self:applySkin(WorldMapFrame)
	end

	WorldMapTooltip:SetBackdrop(backdrop)
	self:HookScript(WorldMapTooltip, "OnShow", function(object)
--		self:Debug("WorldMapTooltip_OnShow: [%s, %s]", this:GetName(), object:GetName())
		self.hooks[WorldMapTooltip].OnShow(object)
		self:skinTooltip(object)
		end)


end

function Skinner:HelpFrame()
	if not self.db.profile.HelpFrame or self.initialized.HelpFrame then return end
	self.initialized.HelpFrame = true

	self:keepRegions(HelpFrame, {8}) -- N.B. region 8 is text
	HelpFrame:SetWidth(HelpFrame:GetWidth() - 20)
	HelpFrame:SetHeight(HelpFrame:GetHeight() * 0.90)
	self:moveObject(HelpFrameCloseButton, "+", 42, "+", 2)
	self:moveObject(HelpFrameHomeCancel, "+", 42, "-", 12)
	self:applySkin(HelpFrame, 1)
	
	self:moveObject(self:getRegion(HelpFrameGM, 1), nil, nil, "+", 30)
	self:moveObject(HelpFrameButton1, nil, nil, "+", 35)
	self:removeRegions(HelpFrameGMScrollFrame)
	self:skinScrollBar(HelpFrameGMScrollFrame)
	self:moveObject(HelpFrameGMCancel, "+", 42, "-", 12)
	
	self:moveObject(HelpFrameGeneralCancel, "+", 42, "-", 12)
	
	self:moveObject(HelpFrameHarassmentText, nil, nil, "+", 20)
	self:moveObject(HelpFrameVerbalHarassment, nil, nil, "+", 25)
--	self:moveObject(HelpFrameVerbalHarassmentButton, nil, nil, "+", 10)
	HelpFrameHarassmentDivider2:Hide()
	self:moveObject(HelpFramePhysicalHarassment, nil, nil, "+", 25)
--	self:moveObject(HelpFramePhysicalHarassmentButton, nil, nil, "+", 20)
	HelpFrameHarassmentDivider:Hide()
	self:moveObject(HelpFrameHarassmentCancel, "+", 42, "-", 12)
	
	self:moveObject(HelpFrameStuckCancel, "+", 42, "-", 12)
	
-->>-- Open Ticket	
	self:moveObject(HelpFrameOpenTicketLabel, nil, nil, "+", 40)
	HelpFrameOpenTicketDivider:Hide()
	self:removeRegions(HelpFrameOpenTicketScrollFrame)
	self:skinScrollBar(HelpFrameOpenTicketScrollFrame)
	self:moveObject(HelpFrameOpenTicketScrollFrame, "+", 20, "+", 50)
	self:moveObject(HelpFrameOpenTicketCancel, "+", 42, "-", 12)
    self:applySkin(HelpFrameOpenTicket)

end

function Skinner:KnowledgeBase()
	if not self.db.profile.KnowledgeBase or self.initialized.KnowledgeBase then return end
	self.initialized.KnowledgeBase = true

	self:keepRegions(KnowledgeBaseFrame, {8}) -- N.B. region 8 is text
	KnowledgeBaseFrame:SetWidth(KnowledgeBaseFrame:GetWidth() - 20)
	KnowledgeBaseFrame:SetHeight(KnowledgeBaseFrame:GetHeight() * 0.90)
	self:skinEditBox(KnowledgeBaseFrameEditBox)
	self:keepRegions(KnowledgeBaseFrameCategoryDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(KnowledgeBaseFrameSubCategoryDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	KnowledgeBaseFrameDivider:Hide()
	KnowledgeBaseFrameDivider2:Hide()
	self:removeRegions(KnowledgeBaseArticleScrollFrame)
	self:skinScrollBar(KnowledgeBaseArticleScrollFrame)
	self:moveObject(KnowledgeBaseFrameCloseButton, "+", 42, "+", 2)
	self:applySkin(KnowledgeBaseFrame, 1)

end

function Skinner:InspectFrame()
	if not self.db.profile.Inspect or self.initialized.Inspect then return end
	self.initialized.Inspect = true

    if self.db.profile.TexturedTab then 
    	-- hook to handle tabs
    	self:SecureHook("InspectFrameTab_OnClick", function()
--    		self:Debug("InspectFrameTab_OnClick")
    		for i = 1, #INSPECTFRAME_SUBFRAMES do
    			if i == this:GetID() then
    				self:setActiveTab(_G["InspectFrameTab"..i])
    			else
    				self:setInactiveTab(_G["InspectFrameTab"..i])
    			end
    		end
    		end)
	end
		
	self:removeRegions(InspectFrame, {1})
	self:keepRegions(InspectPaperDollFrame, {5, 6, 7}) -- N.B. regions 5-7 are text

	InspectModelRotateLeftButton:Hide()
	InspectModelRotateRightButton:Hide()
	self:makeMFRotatable(InspectModelFrame)

	InspectFrame:SetWidth(InspectFrame:GetWidth() * FxMult)
	InspectFrame:SetHeight(InspectFrame:GetHeight() * FyMult)

	local xOfs, yOfs = 5, 20
	self:moveObject(InspectFrameCloseButton, "+", 28, "+", 8)
	self:moveObject(InspectNameText, nil, nil, "-", 32)
	self:moveObject(InspectModelFrame, nil, nil, "+", yOfs)
	self:moveObject(InspectHeadSlot, nil, nil, "+", yOfs)
	self:moveObject(InspectHandsSlot, "-", 15, "+", yOfs)
	self:moveObject(InspectMainHandSlot, nil, nil, "-", 38)

-->>-- PVP Frame
	self:removeRegions(InspectPVPFrame, {1,2,3,4,5})
	InspectPVPFrameCloseButton:Hide()
	self:moveObject(InspectPVPTeam1Standard, "-", 10, "+", 10)
	self:moveObject(InspectPVPTeam2Standard, "-", 10, "+", 10)
	self:moveObject(InspectPVPTeam3Standard, "-", 10, "+", 10)
	
-->>-- Frame Tabs
	for i = 1, #INSPECTFRAME_SUBFRAMES do
		local tabName = _G["InspectFrameTab"..i]
		self:keepRegions(tabName, {7, 8}) -- N.B. region 7 is text, 8 is highlight
        if self.db.profile.TexturedTab then self:applySkin(tabName, nil, 0)
        else self:applySkin(tabName) end
		if i == 1 then
			self:moveObject(tabName, nil, nil, "-", 70)
			if self.db.profile.TexturedTab then self:setActiveTab(tabName) end
		else
			self:moveObject(tabName, "+", 11, nil, nil)
			if self.db.profile.TexturedTab then self:setInactiveTab(tabName) end
		end
		
	end

	self:applySkin(InspectFrame)

end

function Skinner:BattleScore()
	if not self.db.profile.BattleScore then return end

	self:SecureHook("WorldStateScoreFrame_Resize", function(width)
		WorldStateScoreFrame:SetWidth(WorldStateScoreFrame:GetWidth() * FxMult)
		end)

    self:SecureHook("WorldStateScoreFrameTab_OnClick", function(tab)
		self:setInactiveTab(WorldStateScoreFrameTab1)
		self:setInactiveTab(WorldStateScoreFrameTab2)
		self:setInactiveTab(WorldStateScoreFrameTab3)
		self:setActiveTab(tab)
		end)
		
	WorldStateScoreFrame:SetHeight(WorldStateScoreFrame:GetHeight() * FyMult + 20)
	self:keepRegions(WorldStateScoreFrame, {7,8,9,10,11})
	self:removeRegions(WorldStateScoreScrollFrame)
	self:skinScrollBar(WorldStateScoreScrollFrame)
	self:moveObject(WorldStateScoreScrollFrame, "+", 116, "+", 12)
	self:moveObject(WorldStateScoreFrameCloseButton, "+", 110, "+", 10)
	self:moveObject(WorldStateScoreFrameLeaveButton, "+", 30, "-", 65)
	
	-- Tabs
	for i = 1, 3 do   
		local tabName = _G["WorldStateScoreFrameTab"..i]
		self:keepRegions(tabName, {7, 8}) -- N.B. region 7 is the Text, 8 is the highlight
		self:moveObject(_G[tabName:GetName().."Text"], nil, nil, "-", 8)
		self:moveObject(_G[tabName:GetName().."HighlightTexture"], "-", 5, "-", 9)
        if self.db.profile.TexturedTab then self:applySkin(tabName, nil, 0, 1)
		else self:applySkin(tabName) end
		if i == 1 then
			self:moveObject(tabName, nil, nil, "-", 62)
			self:setActiveTab(tabName)
		else
			self:moveObject(tabName, "+", 11, nil, nil)
			self:setInactiveTab(tabName)
		end
	end       
	self:applySkin(WorldStateScoreFrame)

end

function Skinner:ScriptErrors()
	if not self.db.profile.ScriptErrors then return end

--	Skin the ScriptErrors Frame 
	self:applySkin(ScriptErrors)

end

function Skinner:Tutorial()
	if not self.db.profile.Tutorial then return end

--	Skin the TutorialFrame Frame 
	self:applySkin(TutorialFrame)

end

function Skinner:DropDowns()
	if not self.db.profile.DropDowns or self.initialized.DropDowns then return end
	self.initialized.DropDowns = true
	
	-- hook these to Skin the DropDown frames
	for i = 1, 3 do
		local ddFrame = "DropDownList"..i
		if _G[ddFrame] then
			self:HookScript(_G[ddFrame], "OnShow", function()
				self.hooks[_G[ddFrame]].OnShow()
				self:removeRegions(_G[ddFrame])
				_G[ddFrame.."Backdrop"]:Hide()
				_G[ddFrame.."MenuBackdrop"]:Hide()
				self:applySkin(_G[ddFrame])
				end)
		end
	end
	
end
