local _G = getfenv(0)

function Skinner:GMail()
	if not self.db.profile.MailFrame then return end
	
	if self.db.profile.TexturedTab then
    	self:Hook(GMail, "MailFrameTab_OnClick", function(gmail, tab)
--   		self:Debug("GMail - MailFrameTab_OnClick: [%s]", tab)
   	    	self.hooks[GMail].MailFrameTab_OnClick(gmail, tab)
--		    self:Debug("GMail - 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:keepRegions(MailFrameTab3, {7, 8}) -- N.B. region 7 is text, 8 is highlight
--	self:moveObject(MailFrameTab3, "+", 4, nil, nil)
	if self.db.profile.TexturedTab then self:applySkin(MailFrameTab3, nil, 0)
	else self:applySkin(MailFrameTab3) end
	
	self:moveObject(GMailInboxOpenSelected, "-", 20, "+", 5)
	self:moveObject(GMailInboxOpenAllButton, "-", 20, "+", 5)

	--	reset MailItem1 position
	self:moveObject(MailItem1, "-", 5, "-", 5)
	
	-- skin the frame
	self:removeRegions(GMailFrame, {4, 5}) -- N.B. regions 1, 2 & 3 are text
	GMailFrame:SetWidth(GMailFrame:GetWidth() * FxMult)
	GMailFrame:SetHeight(GMailFrame:GetHeight() * FyMult)
	
	self:moveObject(GMailTitleText, "+", 5, "-", 35)
	self:moveObject(GMailNameEditBox, "-", 20, "+", 10)
	self:skinEditBox(GMailNameEditBox, {6})
	self:skinEditBox(GMailSubjectEditBox, {6})
	self:moveObject(GMailCostMoneyFrame, "+", 40, "+", 10)
	self:moveObject(GMailMoneyFrame, "-", 5, "-", 72)
	self:moveObject(GMailCancelButton, "+", 34, "-", 72)
	self:applySkin(GMailFrame)

	-- skin the accept send frame
	self:keepRegions(GMailAcceptSendFrame, {11, 12, 13, 14})-- N.B. regions 11 - 14 are text
	self:applySkin(GMailAcceptSendFrame, 1)

	self:moveObject(GMailStatusText, nil, nil, "-", 65)
	self:moveObject(GMailAbortButton, nil, nil, "-", 70)
	
	self:moveObject(GMailButton1, "-", 10, "+", 20)
	
	-- skin the OpenAll frame
	self:keepRegions(GMailInboxOpenAll, {11, 12, 13, 14})-- N.B. regions 11 - 14 are text
	self:applySkin(GMailInboxOpenAll, 1)
	
end
