local _G = getfenv(0)

function Skinner:MenuFrames()
	if not self.db.profile.MenuFrames or self.initialized.MenuFrames then return end
	self.initialized.MenuFrames = true
	
	self:applySkin(GameMenuFrame, 1, nil, nil, 100)

--	Video Options
    self:applySkin(OptionsFrame, 1, nil, nil, 300)

	self:keepRegions(OptionsFrameResolutionDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(OptionsFrameRefreshDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(OptionsFrameMultiSampleDropDown, {4,5}) -- N.B. regions 4 & 5 are text
    
    self:applySkin(OptionsFrameDisplay)
	self:applySkin(OptionsFrameWorldAppearance)
	self:applySkin(OptionsFrameBrightness)
	self:applySkin(OptionsFramePixelShaders)
	self:applySkin(OptionsFrameMiscellaneous)

--	Sound
    self:applySkin(SoundOptionsFrame, 1, nil, nil, 100)

--	Interface
	self:HookScript(UIOptionsFrameTab1, "OnClick", function()
--		self:Debug("UIOFT1_OnClick")
		self.hooks[UIOptionsFrameTab1].OnClick()
		self:moveObject(UIOptionsFrameTab2, nil, nil, "+", 1)
		end)
	self:HookScript(UIOptionsFrameTab2, "OnClick", function()
--		self:Debug("UIOFT2_OnClick")
		self.hooks[UIOptionsFrameTab2].OnClick()
		self:moveObject(UIOptionsFrameTab2, nil, nil, "-", 1)
		end)    
	self:keepRegions(UIOptionsFrame, {1}) -- N.B. region 1 is text
	-- change this to allow Frames to be resized
	UIOptionsFrame:SetParent(GameMenuFrame:GetParent())
	self:moveObject(UIPanelCloseButton, "-", 4, "-", 4)

	-- change these to allow the buttons to work
	UIOptionsFrameDefaults:SetFrameStrata(GameMenuFrame:GetFrameStrata())
	UIOptionsFrameOkay:SetFrameStrata(GameMenuFrame:GetFrameStrata())
	UIOptionsFrameCancel:SetFrameStrata(GameMenuFrame:GetFrameStrata())

--	BasicOptions
	BasicOptions:SetWidth(BasicOptions:GetWidth() * 0.95)
	BasicOptions:SetHeight(BasicOptions:GetHeight() * FyMult + 45)
	self:keepRegions(UIOptionsFrameClickCameraDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(UIOptionsFrameCameraDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(UIOptionsFrameAutoSelfCastKeyDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(UIOptionsFrameAutoLootKeyDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(UIOptionsFrameLocaleDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(UIOptionsWorldPVPObjectiveDisplay, {4,5}) -- N.B. regions 4 & 5 are text
	self:moveObject(UIOptionsFrameLocaleDropDown, "-", 34, "+", 10, "UIOptionsWorldPVPObjectiveDisplay")
	self:applySkin(BasicOptionsGeneral)
	self:applySkin(BasicOptionsDisplay)
	self:applySkin(BasicOptionsCamera)
	self:applySkin(BasicOptionsHelp)
	self:applySkin(BasicOptions)
	
--	AdvancedOptions
	AdvancedOptions:SetWidth(AdvancedOptions:GetWidth() * 0.95)
	AdvancedOptions:SetHeight(AdvancedOptions:GetHeight() * FyMult + 45)
	self:keepRegions(UIOptionsFrameTargetofTargetDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:keepRegions(UIOptionsFrameCombatTextDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:applySkin(AdvancedOptionsActionBars)
	self:applySkin(AdvancedOptionsChat)
	self:applySkin(AdvancedOptionsRaid)
	self:applySkin(AdvancedOptionsCombatText)
	self:applySkin(AdvancedOptions)
	
	for i = 1, 2 do
		local tabName = _G["UIOptionsFrameTab"..i]
   		self:keepRegions(tabName, {7, 8}) -- N.B. region 7 is text, 8 is highlight
		tabName:SetFrameStrata(GameMenuFrame:GetFrameStrata())
		tabName:SetHeight(tabName:GetHeight() * FTyMult)
		if i == 2 then 
			self:moveObject(tabName, nil, nil, "+", 1)
		end
		self:moveObject(_G[tabName:GetName().."Text"], nil, nil, "+", 5)
		self:moveObject(_G[tabName:GetName().."HighlightTexture"], nil, nil, "+", 8)
  		self:applySkin(tabName)
  	end

	if IsAddOnLoaded("Blizzard_MacroUI") then self:MacroFrame() end
	if IsAddOnLoaded("Blizzard_BindingUI") then self:KeyBindingFrame() end
	
end

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

	self:keepRegions(MacroFrame, {6, 9, 10, 11 ,12}) -- N.B. regions 6, 9-12 are text
	MacroFrame:SetWidth(MacroFrame:GetWidth() * FxMult)
	MacroFrame:SetHeight(MacroFrame:GetHeight() * FyMult)

	for i = 1, 2 do
		local tabName = _G["MacroFrameTab"..i]
		self:keepRegions(tabName, {7, 8}) -- N.B. region 7 is text, 8 is highlight
		self:moveObject(_G[tabName:GetName().."Text"], nil, nil, "+", 5)
		self:moveObject(_G[tabName:GetName().."HighlightTexture"], nil, nil, "+", 8)
		self:applySkin(tabName)
	end
		

	self:moveObject(MacroFrameCloseButton, "+", 28, "+", 8)
	self:moveObject(MacroButton1, "-", 10, nil, nil)
	self:moveObject(MacroFrameSelectedMacroBackground, nil, nil, "+", 10)
	self:moveObject(MacroFrameTextBackground, nil, nil, "+", 10)
	self:moveObject(MacroDeleteButton, "-", 10, "-", 72)
	self:moveObject(MacroNewButton, "-", 4, "+", 10)
	self:moveObject(MacroExitButton, "-", 4, "+", 10)
	self:moveObject(MacroFrameCharLimitText, nil, nil, "-", 75)
	
	self:skinScrollBar(MacroFrameScrollFrame)
	self:skinEditBox(MacroFrameText, nil, true)
	self:applySkin(MacroFrameTextBackground)
	self:applySkin(MacroFrame)
	
	-- Macro Popup Frame
	self:keepRegions(MacroPopupFrame, {5, 6}) -- N.B. regions 5 & 6 are text
	MacroPopupFrame:SetWidth(MacroPopupFrame:GetWidth() * FxMult)
	MacroPopupFrame:SetHeight(MacroPopupFrame:GetHeight() - 20) -- N.B. must be absolute not multiple
	self:moveObject(MacroPopupFrame, "+", 40, nil, nil)

	local xOfs, yOfs = 5, 15
	self:moveObject(MacroPopupEditBox, "-", xOfs, "+", yOfs)
	self:moveObject(MacroPopupScrollFrame, "+", 10, "+", yOfs)
	self:moveObject(MacroPopupButton1, "-", xOfs, "+", yOfs)
	self:moveObject(MacroPopupCancelButton, nil, nil, "-", 4)
	self:skinEditBox(MacroPopupEditBox)
	-- regions 5 & 6 are text
	self:moveObject(self:getRegion(MacroPopupFrame, 5), "-", xOfs, "+", yOfs)
	self:moveObject(self:getRegion(MacroPopupFrame, 6), "-", xOfs, "+", yOfs)
	self:removeRegions(MacroPopupScrollFrame)
	self:skinScrollBar(MacroPopupScrollFrame)
	self:applySkin(MacroPopupFrame)
	
end

function Skinner:KeyBindingFrame()
	if not self.db.profile.MenuFrames or self.initialized.KeyBindingFrame then return end
	self.initialized.KeyBindingFrame = true
	
	self:keepRegions(KeyBindingFrame, {7, 8, 9, 10, 12}) -- N.B. regions 7-10 & 12 are text
	KeyBindingFrame:SetWidth(KeyBindingFrame:GetWidth() * 0.95)
	-- N.B. Don't change Height
	
	self:moveObject(KeyBindingFrameHeaderText, nil, nil, "-", 8)
	self:moveObject(KeyBindingFrameCharacterButton, "+", 30, "+", 5)
	self:moveObject(KeyBindingFrameOutputText, nil, nil, "-", 10)
	self:moveObject(KeyBindingFrameDefaultButton, nil, nil, "-", 14)
	self:moveObject(KeyBindingFrameCancelButton, "+", 40, "-", 14)
	
	self:removeRegions(KeyBindingFrameScrollFrame)
	self:skinScrollBar(KeyBindingFrameScrollFrame)
	
	self:applySkin(KeyBindingFrame)

end

function Skinner:makeModelFramesRotatable()
--[[
[12:55:21] <dreyruugr> http://ace.pastey.net/551
[12:55:42] <dreyruugr> That should do framerate independant rotation of the model, based on how much the mouse moves
[13:12:43] <dreyruugr> Gngsk: http://ace.pastey.net/552 - This doesn't work quite right, but if you work on it you'll be able to zoom in on the character's face using the y offset of the mouse

This does the trick, but it might be worth stealing chester's code from SuperInspect

]]

-- Click to drag Modelframes

	self:SecureHook("Model_RotateLeft", function(model, rotationIncrement)
		if ( not rotationIncrement ) then
			rotationIncrement = 0.03
		end
		model.rotation = model.rotation - rotationIncrement
		model:SetRotation(model.rotation)
		end)
	self:SecureHook("Model_RotateRight", function(model, rotationIncrement)
		if ( not rotationIncrement ) then
			rotationIncrement = 0.03
		end
		model.rotation = model.rotation + rotationIncrement
		model:SetRotation(model.rotation)
		end)
		
end

function Skinner:makeMFRotatable(frame)
	--frame:EnableMouseWheel(true)
	frame:EnableMouse(true)
	frame.draggingDirection = nil
	frame.cursorPosition = { }

	if not self:IsHooked(frame, "OnUpdate") then 
		self:HookScript(frame, "OnUpdate", function()
			self.hooks[frame].OnUpdate()
			if this.dragging then
				local x,y = GetCursorPosition()
				if this.cursorPosition.x > x then
					Model_RotateLeft(frame, (this.cursorPosition.x - x) * arg1)
				elseif this.cursorPosition.x < x then
					Model_RotateRight(frame, (x - this.cursorPosition.x) * arg1)
				end

				this.cursorPosition.x, this.cursorPosition.y = GetCursorPosition()
			end
		end)
		self:HookScript(frame, "OnMouseDown", function()
		self.hooks[frame].OnMouseDown()
			if arg1 == "LeftButton" then
				this.dragging = true
				this.cursorPosition.x, this.cursorPosition.y = GetCursorPosition()
			end
		end)
		self:HookScript(frame, "OnMouseUp", function()
		self.hooks[frame].OnMouseUp()
			if this.dragging then
				this.dragging = false
				this.cursorPosition.x, this.cursorPosition.y = nil
			end
		end)
	end
	
	--[[ MouseWheel to zoom Modelframe - in/out works, but needs to be fleshed out
	frame:SetScript("OnMouseWheel", function()
		local xPos, yPos, zPos = frame:GetPosition() 
		if arg1 == 1 then 
			frame:SetPosition(xPos+00.1, 0, 0)
		else
			frame:SetPosition(xPos-00.1, 0, 0)
		end 
	end) ]]
end

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

	self:removeRegions(BankFrame, {1, 2}) -- N.B. regions 3-5 are text

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

	self:moveObject(BankFrameTitleText, nil, nil, "-", 35)
	self:moveObject(BankCloseButton, "+", 20, "+", 6)
	self:moveObject(BankFrameItem1, "-", 10, nil, nil)
	-- regions 4 and 5 hold the slot text
	self:moveObject(self:getRegion(BankFrame, 4), "+", 10, "-", 40)
	self:moveObject(self:getRegion(BankFrame, 5), "+", 10, "-", 40)
	self:moveObject(BankFramePurchaseInfo, nil, nil, "-", 40)
	self:moveObject(BankFrameMoneyFrame, nil, nil, "_", 90)

	self:applySkin(BankFrame)
	
end

function Skinner:MailFrame()
	if not self.db.profile.MailFrame or self.initialized.MailFrame then return end
	self.initialized.MailFrame = true
	
    if self.db.profile.TexturedTab then 
    	self:SecureHook("MailFrameTab_OnClick", function(tab)
--    		self:Debug("MailFrameTab_OnClick: [%s]", tab)
--    		self:Debug("MailFrameTab_OnClick#2: [%s]", PanelTemplates_GetSelectedTab(MailFrame))
    		for i = 1, MailFrame.numTabs do
    			local tabName = _G["MailFrameTab"..i]
    			if i == MailFrame.selectedTab then
    				self:setActiveTab(tabName)
    			else
    				self:setInactiveTab(tabName)
    			end
    		end
    		end)
    end
    
	self:SecureHook("OpenMail_Update", function()
--		self:Debug("OpenMail_Update")
		self:moveObject(OpenMailAttachmentText, nil, nil, "-", 70)
		end)
		
	self:removeRegions(MailFrame)
	MailFrame:SetWidth(MailFrame:GetWidth() * FxMult)
	MailFrame:SetHeight(MailFrame:GetHeight() * FyMult)
	
	self:moveObject(InboxCloseButton, "+", 28, "+", 8)
	
-->>--	Inbox Frame	
	self:moveObject(InboxTitleText, "-", 15, "+", 6)
	self:moveObject(InboxCurrentPage, nil, nil, "+", 12)
	
	for i = 1, 7 do
		self:removeRegions(_G["MailItem"..i], {2, 3}) -- N.B. regions 1, 4 & 5 are text
	end
	
	local xOfs, yOfs = 5, 20	
	self:moveObject(MailItem1, "-", xOfs, "+", yOfs)
	self:moveObject(InboxPrevPageButton, "-", xOfs, "+", yOfs / 2)
	self:moveObject(InboxNextPageButton, "-", xOfs, "+", yOfs / 2)
		
-->>--	Send Mail Frame
	self:removeRegions(SendMailFrame, {4, 5}) -- N.B. regions 1, 2 & 3 are text
	self:moveObject(SendMailTitleText, "-", 15, "+", 6)	
	self:keepRegions(SendMailScrollFrame)
	self:moveObject(SendMailScrollFrame, "-", 5, nil, nil)	
	self:skinScrollBar(SendMailScrollFrame)

	local xOfs, yOfs = 5, 10	
	for k, v in pairs({ SendMailCostMoneyFrame, SendMailPackageButton, SendMailMoneyFrame, SendMailCancelButton }) do
		self:moveObject(v, "-", xOfs, "+", yOfs)
	end

	self:moveObject(SendMailNameEditBox, "-", 20, "+", 10)
	self:skinEditBox(SendMailNameEditBox, {6}) -- N.B. region 6 is text
	self:skinEditBox(SendMailSubjectEditBox, {6}) -- N.B. region 6 is text
	self:skinEditBox(SendMailBodyEditBox, nil, true)
	SendMailBodyEditBox:SetTextColor(self.db.profile.BodyText.r, self.db.profile.BodyText.g, self.db.profile.BodyText.b)
	
	self:skinMoneyFrame(SendMailMoney)
	self:moveObject(SendMailMoneyGold, "-", 10, nil, nil)
	self:moveObject(SendMailMoneySilver, "-", 10, nil, nil)

-->>--	Open Mail Frame
	self:keepRegions(OpenMailFrame, {6, 7, 8, 9, 10, 11}) -- N.B. regions 6 - 11 are text
	OpenMailFrame:SetWidth(OpenMailFrame:GetWidth() * FxMult)
	OpenMailFrame:SetHeight(OpenMailFrame:GetHeight() * FyMult)
	
	self:moveObject(OpenMailCloseButton, "+", 28, "+", 8)
	
	self:moveObject(OpenMailTitleText, nil, nil, "-", 30)	
	self:moveObject(OpenMailSenderLabel, "-", 5, "+", 10)
	self:moveObject(OpenMailSubjectLabel, "-", 5, "+", 10)
	self:moveObject(OpenMailScrollFrame, "-", 5, "+", 10)	
	self:removeRegions(OpenMailScrollFrame, {1, 2}) -- N.B. regions 3 & 4 are the background
	self:skinScrollBar(OpenMailScrollFrame)

	self:moveObject(OpenMailCancelButton, "+", 30, "-", 72)

	self:applySkin(OpenMailFrame)
	
-->>--	FrameTabs
	for i = 1, MailFrame.numTabs do
		local tabName = _G["MailFrameTab"..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, "-", 69)
			if self.db.profile.TexturedTab then self:setActiveTab(tabName) end
		else
			self:moveObject(tabName, "+", 4, nil, nil)
			if self.db.profile.TexturedTab then self:setInactiveTab(tabName) end
		end
	end
	
	self:applySkin(MailFrame)
	
end

function Skinner:AuctionFrame()
	if not self.db.profile.AuctionFrame or self.initialized.AuctionFrame then return end
	self.initialized.AuctionFrame = true
	
    if self.db.profile.TexturedTab then 
    	self:SecureHook("AuctionFrameTab_OnClick", function(index)
--    		self:Debug("AuctionFrameTab_OnClick: [%s]", index)
    		for i = 1, AuctionFrame.numTabs do
    			local tabName = _G["AuctionFrameTab"..i]
    			if i == AuctionFrame.selectedTab then
    				self:setActiveTab(tabName)
    			else
    				self:setInactiveTab(tabName)
    			end
    		end
    		end)
	end
	
	self:SecureHook("FilterButton_SetType", function(button, type, text, isLast)
		_G[button:GetName().."NormalTexture"]:SetAlpha(0.0)
		end)
	self:removeRegions(AuctionFrame)
	AuctionFrame:SetHeight(AuctionFrame:GetHeight() - 6)
	
	self:moveObject(AuctionFrameCloseButton, "-", 4, "+", 8)

-->>--	All Tabs	
	for i = 1, AuctionFrame.numTabs do
		local tabName = _G["AuctionFrameTab"..i]
		self:keepRegions(tabName, {7, 8}) -- N.B. region 7 is the Text, 8 is the 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, "-", 4)
			if self.db.profile.TexturedTab then self:setActiveTab(tabName) end
		else
			self:moveObject(tabName, "+", 3, nil, nil)
			if self.db.profile.TexturedTab then self:setInactiveTab(tabName) end
		end		 
	end
	
	self:moveObject(AuctionFrameMoneyFrame, nil, nil, "-", 6)
   
-->>--	Browse Frame
	self:moveObject(BrowseTitle, nil, nil, "+", 6)

	self:removeRegions(BrowseFilterScrollFrame)
	self:skinScrollBar(BrowseFilterScrollFrame)
	self:removeRegions(BrowseScrollFrame)
	self:skinScrollBar(BrowseScrollFrame)
	
	for i = 1, NUM_FILTERS_TO_DISPLAY do
		self:keepRegions(_G["AuctionFilterButton"..i], {3, 4})
		self:applySkin(_G["AuctionFilterButton"..i])
	end
   
	self:keepRegions(BrowseDropDown, {4,5}) -- N.B. regions 4 & 5 are text
	self:moveObject(BrowseDropDownName, "+", 40, nil, nil)

	for k, v in pairs({ BrowseQualitySort, BrowseLevelSort, BrowseDurationSort,
				BrowseHighBidderSort, BrowseCurrentBidSort }) do
		self:removeRegions(v, {1, 2, 3})
		self:applySkin(v)
	end
	
	for k, v in pairs({ "BrowseName", "BrowseMinLevel", "BrowseMaxLevel" }) do
		self:skinEditBox(_G[v], {9})
		self:moveObject(_G[v], "-", 5, "+", (k ~= 3 and 3 or 0))
	end

	self:skinMoneyFrame(BrowseBidPrice)
	
-->>--	Bid Frame
	self:moveObject(BidTitle, nil, nil, "+", 6)
	
	self:removeRegions(BidScrollFrame)
	self:skinScrollBar(BidScrollFrame)
		
	for k, v in pairs({ _G["BidQualitySort"], BidLevelSort, BidDurationSort, BidBuyoutSort, BidStatusSort, BidBidSort }) do
		self:removeRegions(v, {1, 2, 3})
		self:applySkin(v)
	end

	self:skinMoneyFrame(BidBidPrice)

-->>--	Auctions Frame
	self:moveObject(AuctionsTitle, nil, nil, "+", 6)		
	self:applySkin(AuctionsItemButton)
	self:removeRegions(AuctionsScrollFrame)
	self:skinScrollBar(AuctionsScrollFrame)
	
	for k, v in pairs({ AuctionsQualitySort, AuctionsDurationSort, AuctionsHighBidderSort, AuctionsBidSort }) do
		self:removeRegions(v, {1, 2, 3})
		self:applySkin(v)
	end
	
	self:skinMoneyFrame(StartPrice)
	self:skinMoneyFrame(BuyoutPrice)
	
	self:applySkin(AuctionFrame)
	
-->>--	AuctionDressUp Frame
	self:removeRegions(AuctionDressUpFrame, {1, 2}) --N.B. regions 3 & 4 are the background
	AuctionDressUpFrame:SetWidth(AuctionDressUpFrame:GetWidth() - 6)
	AuctionDressUpFrame:SetHeight(AuctionDressUpFrame:GetHeight() - 13)
	self:moveObject(AuctionDressUpBackgroundTop, nil, nil, "+", 8)

	AuctionDressUpModelRotateLeftButton:Hide()
	AuctionDressUpModelRotateRightButton:Hide()
	self:makeMFRotatable(AuctionDressUpModel)
	
	self:removeRegions(AuctionDressUpFrameCloseButton, {2, 3, 4}) -- N.B. region 1 is the button artwork
	self:applySkin(AuctionDressUpFrame)

end

function Skinner:AH_FilterButton_SetType(button, type, text, isLast)

	local normalText = getglobal(button:GetName().."NormalText")
	local normalTexture = getglobal(button:GetName().."NormalTexture")
	local line = getglobal(button:GetName().."Lines")

	if ( type == "class" ) then
		button:SetText(text)
		normalText:SetPoint("LEFT", button, "LEFT", 4, 0)
		--normalTexture:SetAlpha(1.0)
		line:Hide()
	elseif ( type == "subclass" ) then
		button:SetText(HIGHLIGHT_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE)
		--button:SetText("|cff007FFF"..text.."|r")
		normalText:SetPoint("LEFT", button, "LEFT", 12, 0)
		--normalTexture:SetAlpha(0.4)
		line:Hide()
	elseif ( type == "invtype" ) then
		button:SetText(HIGHLIGHT_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE)
		normalText:SetPoint("LEFT", button, "LEFT", 20, 0)
		normalTexture:SetAlpha(0.0)
		if ( isLast ) then
			line:SetTexCoord(0.4375, 0.875, 0, 0.625)
		else
			line:SetTexCoord(0, 0.4375, 0, 0.625)
		end
		line:Show()
	end

	button.type = type

end

function Skinner:MainMenuBar()
	if not self.db.profile.MainMenuBar.skin or self.initialized.MainMenuBar then return end
	self.initialized.MainMenuBar = true
	
	-- hook this to move the PerformanceBar
	self:SecureHook("MainMenuBar_UpdateKeyRing", function()
		if SHOW_KEYRING == 1 then self:moveObject(MainMenuBarPerformanceBarFrame, nil, nil, "+", 4) end
		end)

	self:removeRegions(MainMenuBar)
	if  not MainMenuBarMaxLevelBar:IsShown() then 
		MainMenuBar:SetHeight(MainMenuBar:GetHeight() * 1.15)
		self:moveObject(ActionBarUpButton, nil, nil, "-", 4)
		self:moveObject(ActionBarDownButton, nil, nil, "-", 4)
	else
		self:moveObject(ActionBarUpButton, nil, nil, "+", 4)
		self:moveObject(ActionBarDownButton, nil, nil, "+", 4)
		self:moveObject(MainMenuBarPageNumber, nil, nil, "+", 4)
	end
	self:moveObject(MainMenuBar, nil, nil, "-", 4)
	self:applySkin(MainMenuBar, nil, 0)
	LowerFrameLevel(MainMenuBar)

	self:keepRegions(MainMenuExpBar, {1, 7}) -- N.B. region 1 is rested XP, 7 is the normal XP
	MainMenuExpBar:SetWidth(MainMenuExpBar:GetWidth() - 8)
	MainMenuExpBar:SetHeight(MainMenuExpBar:GetHeight() * FyMult)
	ExhaustionLevelFillBar:SetHeight(ExhaustionLevelFillBar:GetHeight() * FyMult)
	self:moveObject(MainMenuExpBar, nil, nil, "-", 4)
	self:moveObject(MainMenuBarExpText, nil, nil, "-", 2)
	if self.db.profile.MainMenuBar.glazesb then self:glazeStatusBar(MainMenuExpBar) end
--	MainMenuBarOverlayFrame
	self:removeRegions(MainMenuBarMaxLevelBar)
	self:keepRegions(MainMenuBarArtFrame, {7}) -- N.B. region 7 is text
	self:moveObject(MainMenuBarPerformanceBarFrame, nil, nil, "+", 4)
	MainMenuBarPerformanceBarFrame:SetFrameStrata("MEDIUM")
--	MainMenuBarPerformanceBarFrameButton
	ExhaustionTick:SetAlpha(0)

	-- move Action Buttons, Micro buttons etc
	self:moveObject(ActionButton1, nil, nil, "+", 3)
	self:moveObject(CharacterMicroButton, nil, nil, "+", 4)
	self:moveObject(MainMenuBarBackpackButton, nil, nil, "+", 4)

-->>-- BonusActionBar Frame
	self:keepRegions(BonusActionBarFrame, {})
	self:moveObject(BonusActionButton1, nil, nil, "+", 3)
		
-->>-- ShapeshiftBar Frame
	self:keepRegions(ShapeshiftBarFrame, {})
		
end

function Skinner:CoinPickup()
	if not self.db.profile.CoinPickup or self.initialized.CoinPickup then return end
	self.initialized.CoinPickup = true
	
	self:removeRegions(CoinPickupFrame, {1}) -- N.B. other regions are required
	CoinPickupFrame:SetWidth(CoinPickupFrame:GetWidth() * 0.8)
	CoinPickupFrame:SetHeight(CoinPickupFrame:GetHeight() * 0.65)
	self:moveObject(CoinPickupGoldIcon, "+", 5, "-", 5)
	self:moveObject(CoinPickupSilverIcon, "+", 5, "-", 5)
	self:moveObject(CoinPickupCopperIcon, "+", 5, "-", 5)
	self:moveObject(CoinPickupText, "+", 5, "-", 5)
	self:moveObject(CoinPickupLeftButton, "+", 10, "-", 5)
	self:moveObject(CoinPickupRightButton, "-", 10, "-", 5)
	self:moveObject(CoinPickupOkayButton, "+", 3, "-", 13)
	self:moveObject(CoinPickupCancelButton, "-", 5, "-", 13)
	self:applySkin(CoinPickupFrame)

end

function Skinner:GMSurveyUI()
	if not self.db.profile.GMSurveyUI or self.initialized.GMSurveyUI then return end
	self.initialized.CoinPickup = true
	
	self:keepRegions(GMSurveyFrame, {13}) -- N.B. region 13 is text
	self:keepRegions(GMSurveyHeader, {4}) -- N.B. region 13 is text
	
	for i = 1, MAX_SURVEY_QUESTIONS do
		self:applySkin(_G["GMSurveyQuestion"..i])
	end
	self:applySkin(GMSurveyCommentFrame)
	self:moveObject(GMSurveyHeaderText, "-", 0, "-", 6)
	self:moveObject(GMSurveyCloseButton, "+", 40, nil, nil)
	self:moveObject(GMSurveyCancelButton, "-", 0, "-", 10)
	self:moveObject(GMSurveySubmitButton, "+", 40, "-", 10)
	
	self:removeRegions(GMSurveyScrollFrame)
	self:skinScrollBar(GMSurveyScrollFrame)
	self:removeRegions(GMSurveyCommentScrollFrame)
	self:skinScrollBar(GMSurveyCommentScrollFrame)
	
	self:applySkin(GMSurveyFrame, true)

end

function Skinner:LFGFrame()
	if not self.db.profile.LFGFrame or self.initialized.LFGFrame then return end
	self.initialized.LFGFrame = true
	
	if self.db.profile.TexturedTab then
		self:SecureHook("LFGParentFrameTab1_OnClick", function()
--			self:Debug("LFGParentFrameTab1_OnClick")
			self:setActiveTab(LFGParentFrameTab1)
			self:setInactiveTab(LFGParentFrameTab2)
			end)
		self:SecureHook("LFGParentFrameTab2_OnClick", function()
--			self:Debug("LFGParentFrameTab2_OnClick")
			self:setActiveTab(LFGParentFrameTab2)
			self:setInactiveTab(LFGParentFrameTab1)
			end)
    end
    
	-- hook these to move the comment
	self:SecureHook("LFMFrame_OnShow", function()
		self:moveObject(LFGComment, nil, nil, "-", 80)
		end)
	self:SecureHook("LFGFrame_OnShow", function()
		self:moveObject(LFGComment, nil, nil, "-", 80)
		end)
		
	LFGParentFrame:SetWidth(LFGParentFrame:GetWidth() * FxMult)
	LFGParentFrame:SetHeight(LFGParentFrame:GetHeight() * FyMult)
	-- move the close button
	self:moveObject(self:getChild(LFGParentFrame, 4), "+", 28, "+", 8)
	self:skinEditBox(LFGComment, {})
	
-->>-- LFG Frame
	self:keepRegions(AutoJoinBackground, {})
	self:keepRegions(LFGFrameNameDropDown1, {4,5})
	self:keepRegions(LFGFrameNameDropDown2, {4,5})
	self:keepRegions(LFGFrameNameDropDown3, {4,5})
	self:keepRegions(LFGFrameTypeDropDown1, {4,5})
	self:keepRegions(LFGFrameTypeDropDown2, {4,5})
	self:keepRegions(LFGFrameTypeDropDown3, {4,5})
	self:moveObject(LFGSearchBg1, "+", 30, nil, nil)
	self:keepRegions(LFGEye, {})
	self:applySkin(LFGEye)
	self:moveObject(LFGFrameDoneButton, "+", 25, "-", 76)

-->>-- LFM Frame
	self:keepRegions(AddMemberBackground, {})
	self:moveObject(LFMFrameTotals, nil, nil, "-", 76)
	self:keepRegions(LFMFrameTypeDropDown, {4,5})
	self:keepRegions(LFMFrameNameDropDown, {4,5})
	self:moveObject(LFMFrameTypeDropDown, "-", 10, nil, nil)
	self:skinFFColHeads("LFMFrameColumnHeader") --N.B. Prefix string
	self:moveObject(LFMFrameColumnHeader1, "-", 10, nil, nil)
	self:keepRegions(LFMListScrollFrame, {})
	self:skinScrollBar(LFMListScrollFrame)
	self:keepRegions(LFMEye, {})
	self:applySkin(LFMEye)
	self:keepRegions(LFMFrame, {1})
	self:moveObject(LFMFrameGroupInviteButton, "+", 25, "-", 76)

-->>-- Tabs
	self:keepRegions(LFGParentFrameTab1, {7,8})
	self:keepRegions(LFGParentFrameTab2, {7,8})
	self:moveObject(LFGParentFrameTab1, nil, nil, "-", 70)
	self:moveObject(LFGParentFrameTab2, "+", 10, nil, nil)
	if self.db.profile.TexturedTab then self:applySkin(LFGParentFrameTab1, nil, 0)
	else self:applySkin(LFGParentFrameTab1) end
	if self.db.profile.TexturedTab then self:applySkin(LFGParentFrameTab2, nil, 0)
	else self:applySkin(LFGParentFrameTab2) end
	
	self:keepRegions(LFGParentFrame, {3})
	self:applySkin(LFGParentFrame)
	
end

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

	self:removeRegions(ItemSocketingScrollFrame)
	self:skinScrollBar(ItemSocketingScrollFrame)
	self:keepRegions(ItemSocketingFrame, {3}) -- N.B. these regions are text
	self:applySkin(ItemSocketingFrame)
	
end
