local _G = getfenv(0)

function Skinner:Auctioneer()
    if not self.db.profile.AuctionFrame or self.initialized.Auctioneer then return end
--	 self:Debug("Auctioneer Loaded: [%s]", AuctionFrame.numTabs)

    if AuctionFrame.numTabs < 5  then
		self:ScheduleEvent(self.Auctioneer, 0.1, self)
		return
	end
	
	self.initialized.Auctioneer= true
	    
    for k, tabName in pairs({ AuctionFrameTabSearch, AuctionFrameTabPost }) do
		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)
            self:setInactiveTab(tabName)
        else 
            self:applySkin(tabName)
        end
		-- self:moveObject(tabName, "+", 3, nil, nil)
    end
    
-->>-- Search Frame
    for k, v in pairs({ "SavedSearch", "Search", "BidTimeLeft", "BidCategory", "BidMinQuality", "BuyoutCategory", "BuyoutMinQuality", "PlainCategory", "PlainMinQuality", "ListColumn1", "ListColumn2", "ListColumn3", "ListColumn4", "ListColumn5", "ListColumn6" }) do
        self:keepRegions(_G["AuctionFrameSearch"..v.."DropDown"], {4,5}) -- N.B. regions 4 & 5 are text
    end

	self:moveObject(AuctionFrameSearchSavedSearchDropDownButton, "+", 2, nil, nil)
    
    for i = 1, 6 do
        self:keepRegions(_G["AuctionFrameSearchListColumn"..i.."Sort"], {4, 5, 6}) -- N.B. region 4 is text, 5 is the arrow, 6 is the highlight
        self:applySkin(_G["AuctionFrameSearchListColumn"..i.."Sort"])
    end
    
    self:removeRegions(AuctionFrameSearchListScrollFrame)
    self:skinScrollBar(AuctionFrameSearchListScrollFrame) 

	self:skinMoneyFrame(AuctionFrameSearchBidMinProfit, true)
	self:skinMoneyFrame(AuctionFrameSearchBuyoutMinProfit, true)
	self:skinMoneyFrame(AuctionFrameSearchCompeteUndercut, true)
	self:skinMoneyFrame(AuctionFrameSearchPlainMaxPrice, true)
	
	self:skinEditBox(AuctionFrameSearchSaveSearchEdit)
	self:moveObject(AuctionFrameSearchBidMinPercentLessEdit, nil, nil, "+", 4)
	self:skinEditBox(AuctionFrameSearchBidMinPercentLessEdit)
	self:moveObject(AuctionFrameSearchBidSearchEdit, "-", 5, "+", 4)
	self:skinEditBox(AuctionFrameSearchBidSearchEdit)
	self:moveObject(AuctionFrameSearchBuyoutMinPercentLessEdit, nil, nil, "+", 4)
	self:skinEditBox(AuctionFrameSearchBuyoutMinPercentLessEdit)
	self:moveObject(AuctionFrameSearchBuyoutSearchEdit, "-", 5, "+", 4)
	self:skinEditBox(AuctionFrameSearchBuyoutSearchEdit)
	self:moveObject(AuctionFrameSearchPlainSearchEdit, "-", 5, "+", 4)
	self:skinEditBox(AuctionFrameSearchPlainSearchEdit)
        
-->>-- Post Frame
    self:removeRegions(AuctionFramePostAuctionItem, {1}) -- N.B. all other regions are text or icon texture
    self:applySkin(AuctionFramePostAuctionItem)
        
    for k, v in pairs({ "PriceModel", "ListColumn1", "ListColumn2", "ListColumn3", "ListColumn4", "ListColumn5", "ListColumn6" }) do
        self:keepRegions(_G["AuctionFramePost"..v.."DropDown"], {4,5}) -- N.B. regions 4 & 5 are text
    end

    for i = 1, 6 do
        self:keepRegions(_G["AuctionFramePostListColumn"..i.."Sort"], {4, 5, 6}) -- N.B. region 4 is text, 5 is the arrow, 6 is the highlight
        self:applySkin(_G["AuctionFramePostListColumn"..i.."Sort"])
    end
    
    self:removeRegions(AuctionFramePostListScrollFrame)
    self:skinScrollBar(AuctionFramePostListScrollFrame) 

	self:moveObject(AuctionFramePostStartPrice, "-", 5, "+", 5)
	self:skinMoneyFrame(AuctionFramePostStartPrice, true)
	self:moveObject(AuctionFramePostBuyoutPrice, "-", 5, "+", 5)
	self:skinMoneyFrame(AuctionFramePostBuyoutPrice, true)

	self:moveObject(AuctionFramePostStackSize, "-", 5, "+", 5)
	self:skinEditBox(AuctionFramePostStackSize)
	self:skinEditBox(AuctionFramePostStackCount)

end
                      
function Skinner:BeanCounter()
	if not self.db.profile.AuctionFrame then return end
--	self:Debug("BeanCounter Loaded: [%s]", AuctionFrame.numTabs)
	                           
	self:removeRegions(AuctionFrameTransactionsListScrollFrame)
	self:skinScrollBar(AuctionFrameTransactionsListScrollFrame)
	self:skinEditBox(AuctionFrameTransactionsSearchSearchEdit)
	self:moveObject(AuctionFrameTransactionsSearchSearchEdit, "-", 6, "+", 4)
	
    self:keepRegions(AuctionFrameTabTransactions, {7, 8}) -- N.B. region 7 is the Text, 8 is the highlight
	if self.db.profile.TexturedTab then 
        self:applySkin(AuctionFrameTabTransactions, nil, 0)
        self:setInactiveTab(AuctionFrameTabTransactions)
    else 
        self:applySkin(AuctionFrameTabTransactions)
    end

end
    
function Skinner:BtmScan()
	if not self.db.profile.AuctionFrame then return end
--	self:Debug("BtmScan Loaded: [%s]", AuctionFrame.numTabs)
	
	-- loop until tab button created
	if not AuctionFrameTabBtmScan then
		self:ScheduleEvent(self.BtmScan, 0.1, self)
		return
	end
    
    self:HookScript(AuctionFrameTabBtmScan, "OnClick", function()
--		self:Debug("AuctionFrameTabBtmScan-OnClick")
		self.hooks[AuctionFrameTabBtmScan].OnClick()
		self:moveObject(BtmScanLogFrame:GetParent(), "-", 10, nil, nil)
		end)
		
	self:removeRegions(BtmScanInputScroll)
	self:skinScrollBar(BtmScanInputScroll)
	self:skinEditBox(BtmScanEditBox)
	self:removeRegions(BtmScanLogFrame)
	self:skinScrollBar(BtmScanLogFrame)
	BtmScanLogFrame:GetParent():SetWidth(BtmScanLogFrame:GetParent():GetWidth() + 10)
	self:applySkin(BtmScanLogFrame:GetParent())
	
    self:keepRegions(AuctionFrameTabBtmScan, {7, 8}) -- N.B. region 7 is the Text, 8 is the highlight
	self:moveObject(AuctionFrameTabBtmScan, "+", 3, nil, nil)
	if AuctionFrameTabTransactions then self:moveObject(AuctionFrameTabTransactions, "+", 3, nil, nil) end
	if self.db.profile.TexturedTab then 
        self:applySkin(AuctionFrameTabBtmScan, nil, 0)
        self:setInactiveTab(AuctionFrameTabBtmScan)
    else 
        self:applySkin(AuctionFrameTabBtmScan)
    end

end
