--=============================================
---
--- GoldCounter (Options.lua) by Hexiatröhm
---
--=============================================

local split   = strsplit

function GC_SetAddonOptions()

	-----------------------------
	--- Init Addon Basic Options
	if ( not My_GC_Settings_Local.ShowGoldOnly_SW ) then
		My_GC_Settings_Local.ShowGoldOnly = false
		My_GC_Settings_Local.ShowGoldOnly_SW = true
	end
	if ( not My_GC_Settings_Local.UseShiftToDrag_SW ) then
		My_GC_Settings_Local.UseShiftToDrag = false
		My_GC_Settings_Local.UseShiftToDrag_SW = true
	end
	if ( not My_GC_Settings_Local.DailyReset_SW ) then
		My_GC_Settings_Local.DailyReset = false
		My_GC_Settings_Local.DailyReset_SW = true
	end
	if ( not My_GC_Settings_Local.TransView_SW ) then
		My_GC_Settings_Local.TransView = false
		My_GC_Settings_Local.TransView_SW = true
	end
	if ( not My_GC_Settings_Local.HideInCombat_SW ) then
		My_GC_Settings_Local.HideInCombat = false
		My_GC_Settings_Local.HideInCombat_SW = true
	end
	if ( not My_GC_Settings_Local.MinimapButtonUse_SW ) then
		My_GC_Settings_Local.MinimapButtonUse = true
		My_GC_Settings_Local.MinimapButtonUse_SW = true
	end
	if ( not My_GC_Settings_Local.IconsFlash_SW ) then
		My_GC_Settings_Local.IconsFlash = true
		My_GC_Settings_Local.IconsFlash_SW = true
	end
	if ( not My_GC_Settings_Local.CheckBank_SW ) then
		My_GC_Settings_Local.CheckBank = false
		My_GC_Settings_Local.CheckBank_SW = true
	end
	if ( not My_GC_Settings_Local.HideHistory_SW ) then
		My_GC_Settings_Local.HideHistory = false
		My_GC_Settings_Local.HideHistory_SW = true
	end

	--- Char Panel
	if ( not My_GC_Settings_Local.SortServerOnTop_SW ) then
		My_GC_Settings_Local.SortServerOnTop	= true
		My_GC_Settings_Local.SortServerOnTop_SW	= true
	end

	--- Init Special Options
	if ( not My_GC_Settings_Local.Scale )         then My_GC_Settings_Local.Scale = 1
	elseif My_GC_Settings_Local.Scale < 0.5 	  then My_GC_Settings_Local.Scale = 0.5
	elseif My_GC_Settings_Local.Scale > 4	 	  then My_GC_Settings_Local.Scale = 4
	end
	if ( not My_GC_Settings_Local.Font )          then My_GC_Settings_Local.Font          = GC_CounterFonts_List[1]
	end
	if ( not My_GC_Settings_Local.LastResetDate ) then My_GC_Settings_Local.LastResetDate = tonumber( date("%y%m%d") )
	end
	if ( not My_GC_Settings_Local.Thousand_Delimiter ) then My_GC_Settings_Local.Thousand_Delimiter = ","
	end
	if ( not My_GC_Settings_Local.UserDateFormat ) then My_GC_Settings_Local.UserDateFormat = "YY/MM/DD"
	end
	if not My_GC_Settings_Local.GC_Version then My_GC_Settings_Local.GC_Version = GC_Version
	end

	--- Init Login time if never recorded
	if not My_GC_Settings_Local.LastLoginDate or not My_GC_Settings_Local.LastLoginTime then
		My_GC_Settings_Local.LastLoginDate = tonumber( date("%y%m%d") )
		My_GC_Settings_Local.LastLoginTime = date("%H:%M:%S")
	end

	--- Init Logout time if never recorded
	if not My_GC_Settings_Local.LastLogoutDate or not My_GC_Settings_Local.LastLogoutTime then
		My_GC_Settings_Local.LastLogoutDate = tonumber( date("%y%m%d") )
		My_GC_Settings_Local.LastLogoutTime = date("%H:%M:%S")
	end

	--- Check Reset History Length
	if not My_GC_Settings_Local.MaxHistoryRec then My_GC_Settings_Local.MaxHistoryRec = GC_DefaultHistoryRec
	elseif My_GC_Settings_Local.MaxHistoryRec < GC_MinHistoryRec then
		My_GC_Settings_Local.MaxHistoryRec = GC_MinHistoryRec
	elseif My_GC_Settings_Local.MaxHistoryRec > GC_MaxHistoryRec then
		My_GC_Settings_Local.MaxHistoryRec = GC_MaxHistoryRec
	end

	--- Set History Length in EditBox
	GC_HistListRec_Len:SetNumber( My_GC_Settings_Local.MaxHistoryRec )
	GC_HistListRec_Len:SetCursorPosition(0)

	--- Create or Reset History Table
	GC_BuildHistoryTable()
	-----------------------------

	--- Init GC_MyDailyData
	if not GC_MyDailyData.DailyCount then GC_MyDailyData.DailyCount = 0 end
	if not GC_MyDailyData.Instance_MoneyLoot then GC_MyDailyData.Instance_MoneyLoot = 0 end
	if not GC_MyDailyData.Money_Loot then GC_MyDailyData.Money_Loot = 0 end
	if not GC_MyDailyData.Merchant_Money then GC_MyDailyData.Merchant_Money = 0 end
	if not GC_MyDailyData.Auctioneer then GC_MyDailyData.Auctioneer = 0 end
	if not GC_MyDailyData.MailBoxIncome then GC_MyDailyData.MailBoxIncome = 0 end
	if not GC_MyDailyData.QuestXP then GC_MyDailyData.QuestXP = 0 end
	if not GC_MyDailyData.Merchant_Transmo then GC_MyDailyData.Merchant_Transmo = 0 end
	if not GC_MyDailyData.TaxiCost then GC_MyDailyData.TaxiCost = 0 end
	if not GC_MyDailyData.Craftsmanship then GC_MyDailyData.Craftsmanship = 0 end
	
	--- Set up Addon and Options Panel UI and texts
	
	--- Frame Scaling and Slider Position
		GC_Options_ScalingSlider:SetValue( My_GC_Settings_Local.Scale )
		GC_Scale_CurrentValue:SetText( My_GC_Settings_Local.Scale ) --- Set Value number
		GoldCounter_MainFrame:SetScale( My_GC_Settings_Local.Scale ) --- Set Frame Scale
	--- Frame Mode or Translucent Mode
		GC_Options_CheckButton1:SetChecked( My_GC_Settings_Local.TransView ) --- Check or uncheck button
		GC_ChangeViewMode( My_GC_Settings_Local.TransView )
		GC_ResetFrame() --- Reset Frame basic color if Shown
	--- Only Showing Gold setting
		GC_Options_CheckButton2:SetChecked( My_GC_Settings_Local.ShowGoldOnly ) --- Check or uncheck button
		GC_ShowOnlyGold( My_GC_Settings_Local.ShowGoldOnly )
	--- Use Shift To Drag Option
		GC_Options_CheckButton3:SetChecked( My_GC_Settings_Local.UseShiftToDrag ) --- Check or uncheck button
	--- Daily Reset Set button
		GC_Options_CheckButton4:SetChecked( My_GC_Settings_Local.DailyReset ) --- Check or uncheck button
	--- Hide In Combat Set button
		GC_Options_CheckButton5:SetChecked( My_GC_Settings_Local.HideInCombat ) --- Check or uncheck button
	--- Set Button for Bank Check
		GC_Options_CheckBank:SetChecked( My_GC_Settings_Local.CheckBank ) --- Check or uncheck button
	--- Set Button for Lights Effects
		GC_Options_ButtonsFlash:SetChecked( My_GC_Settings_Local.IconsFlash) --- Check or uncheck button


	--- Set button to for hide history
		GC_Options_CheckHideHistoryButton:SetChecked( My_GC_Settings_Local.HideHistory )
	--- Char Panel: Set Button for Sorting Servers
		GC_SortFilterServerTop:SetChecked( My_GC_Settings_Local.SortServerOnTop ) --- Check or uncheck button


	--- Minimap Button Hide or Show
		GC_Options_MinimapButton:SetChecked( My_GC_Settings_Local.MinimapButtonUse ) --- Check or uncheck button
		
		--- Minimap Button Hide or Show
		if ( My_GC_Settings_Local.MinimapButtonUse == false ) then
			GC_Icon:Hide("GOLDCOUNTER")
		else
			GC_Icon:Show("GOLDCOUNTER")
		end

	--- Lights Effects will Stop/Start if allowed
		if ( My_GC_Settings_Local.IconsFlash == false ) then

			StopLoop1()
			StopLoop2()
		else --- Testing if at login is resting or fighting
			GC_CheckResting()
			GC_CheckFighting()
		end

	--- Set Profile Names on option panel
	for i = 1, 6, 1 do
		if ( My_GC_Profile[i] ) then

			local name = GC_GetClassColor( My_GC_Profile[i].Name, My_GC_Profile[i].Class )
			_G["GC_Profile"..i.."_ButtonDefText"]:SetText( name )

		else
			_G["GC_Profile"..i.."_ButtonDefText"]:SetText( GC_Locale_Text.OPTIONSPANEL_PROFILE_TEXT.." "..i )
		end
	end

	--- If not retail hide some stuff
	if not GC_WOW_isRetail then
	GC_SortFilterServerTop:Hide()
	GC_CharPanelSortServerText:Hide()
	end

end

function XML_Actions( Option )

	if not Option or Option == 0 then return end

	--- 1  = Frame Right-Click Menu

	if Option == 1 then

		--- Frame Right-Click Menu
		GCLibDD:ToggleDropDownMenu(1, nil, GC_OptionsMenuFrame, "cursor", 3, -3)
		PlaySound( SOUNDKIT.IG_MAINMENU_OPTION )

	elseif Option == 2 then
		--- Undefined
	end

end

function GC_ChangeViewMode( switch )

	if switch == true then --- Transparent

		StopLoop1() --- Stop All Anim
		StopLoop2()

		GoldCounter_MainFrame:SetBackdrop( {
                    bgFile = "",
                    edgeFile = "",
                    tile = true,
                    tileSize = 16,
                    edgeSize = 16,
                    insets = { left=2, right=2, top=2, bottom=2 } } )

                GoldCounter_MainFrame:SetBackdropColor(0,0,0,0)
                GoldCounter_MainFrame:SetBackdropBorderColor(0,0,0,0)

		GC_InfoCardButton:SetPoint( "LEFT", "GoldCounter_MainFrame", "RIGHT", "-9", "0" )

	else --- Non Transparent

		GC_ResetFrame()

		GC_InfoCardButton:SetPoint( "LEFT", "GoldCounter_MainFrame", "LEFT", "1", "0" )

		GC_CheckResting()
		GC_CheckFighting()

	end

end

function GC_ShowOnlyGold( switch )

	if ( switch == true ) then

		GC_CopperButton:Hide()
		GC_ShowCoppers:Hide()

		GC_SilverButton:Hide()
		GC_ShowSilvers:Hide()

		GC_GoldButton:SetPoint( "RIGHT", "GC_CopperButton", "LEFT", "14", "0" )

	else
		GC_CopperButton:Show()
		GC_ShowCoppers:Show()

		GC_SilverButton:Show()
		GC_ShowSilvers:Show()

		GC_GoldButton:SetPoint( "RIGHT", "GC_SilverButton", "LEFT", "-24", "0" )

	end

end

function GC_GetClassColor( Name, Class )

	if ( Class == "WARRIOR" ) then         Name = "|cffC69B6D"..Name.."|r"
	elseif ( Class == "WARLOCK" ) then     Name = "|cff8788EE"..Name.."|r"
	elseif ( Class == "SHAMAN" ) then      Name = "|cff0070DD"..Name.."|r"
	elseif ( Class == "ROGUE" ) then       Name = "|cffFFF468"..Name.."|r"
	elseif ( Class == "PRIEST" ) then      Name = "|cffFFFFFF"..Name.."|r"
	elseif ( Class == "PALADIN" ) then     Name = "|cffF48CBA"..Name.."|r"
	elseif ( Class == "MONK" ) then        Name = "|cff00FF98"..Name.."|r"
	elseif ( Class == "MAGE" ) then        Name = "|cff3FC7EB"..Name.."|r"
	elseif ( Class == "HUNTER" ) then      Name = "|cffAAD372"..Name.."|r"
	elseif ( Class == "EVOKER" ) then      Name = "|cff33937F"..Name.."|r"
	elseif ( Class == "DRUID" ) then       Name = "|cffFF7C0A"..Name.."|r"
	elseif ( Class == "DEMONHUNTER" ) then Name = "|cffA330C9"..Name.."|r"
	elseif ( Class == "DEATHKNIGHT" ) then Name = "|cffC41E3A"..Name.."|r"
	end

	return Name
end

function GC_CheckNewVersion( OldVer, NewVer ) --- return nil if same or lower version

	if ( not NewVer ) then return nil end

	local VerMaj1, VerMin1, VerSubMin1 = split( ".", OldVer, 3 )
	VerMaj1, VerMin1, VerSubMin1 = tonumber(VerMaj1), tonumber(VerMin1), tonumber(VerSubMin1)

	local VerMaj2, VerMin2, VerSubMin2 = split( ".", NewVer, 3 )
	VerMaj2, VerMin2, VerSubMin2 = tonumber(VerMaj2), tonumber(VerMin2), tonumber(VerSubMin2)

	local Version

	if VerMaj1 < VerMaj2 then
	Version = true

	elseif VerMaj1 == VerMaj2 and VerMin1 < VerMin2 then
	Version = true
	
	elseif VerMaj1 == VerMaj2 and VerMin1 == VerMin2 and VerSubMin1 < VerSubMin2 then
	Version = true

	else

		Version = nil

	end

	return Version
end

function GC_OptionsMenuFrame_OnClick( self, arg1, arg2, checked )

	if ( arg1 == 2 ) then

		My_GC_Settings_Local.TransView = checked

	elseif ( arg1 == 3 ) then

		My_GC_Settings_Local.ShowGoldOnly = checked

	elseif ( arg1 == 4 ) then

		My_GC_Settings_Local.UseShiftToDrag = checked

	elseif ( arg1 == 5 ) then

		My_GC_Settings_Local.CheckBank = checked

	elseif ( arg1 == 6 ) then

		My_GC_Settings_Local.HideHistory = checked

	elseif ( arg1 == 10 ) then

		if GoldCounterOptionsPanel:IsShown() then
			GoldCounterOptionsPanel:Hide()
		else
			GoldCounterOptionsPanel:Show()
		end

	elseif ( arg1 == 11 ) then

		GC_LoadProfile( arg2 )
		GCLibDD:ToggleDropDownMenu(1, nil, GC_OptionsMenuFrame )
	end

	GC_SetAddonOptions()

end

function GC_SetOptionsPanelText()

		-------------------------
		-- Configuration Panel --
		-------------------------

		GC_OptionsNameTitle:SetText( "GoldCounter "..GC_Version )

		GC_Option_ScaleText:SetText( GC_Locale_Text.OPTIONSPANELTXT_SCALE )
		GC_Option_FontText:SetText( GC_Locale_Text.OPTIONSPANELTXT_FONT )

		GC_Options_CheckButton1DefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_TRANSVIEW )
		GC_Options_CheckButton2DefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_SHOWONLYGOLD )
		GC_Options_CheckButton3DefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_USESHIFTDRAG )
		GC_Options_CheckButton4DefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_DAILYRESET )
		GC_Options_CheckButton5DefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_HIDEINCOMBAT )

		GC_Option_HistoryText:SetText( GC_Locale_Text.OPTIONSPANELTXT_HISTORY )

		GC_Options_MinimapButtonDefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_MINIBUTTON )
		GC_Options_ButtonsFlashDefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_FLASHICONS )
		GC_Options_CheckBankDefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_CHECKBANK )
		GC_Options_ClearHistoryButton:SetText( GC_Locale_Text.OPTIONSPANEL_BUTTON1_TEXT )
		GC_Option_ClearDatabaseText:SetText( GC_Locale_Text.OPTIONSPANELTXT_CLEARDB )
		GC_Options_ClearDB_Button:SetText( GC_Locale_Text.OPTIONSPANEL_BUTTON1_TEXT )

		GC_HistListRec_LenDefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_HISTLEN )
		GC_HistListRec_LenDefText2:SetText( "( " .. GC_MinHistoryRec .." - ".. GC_MaxHistoryRec .. " )" )
		
		GC_Option_ThouSeparatorText:SetText( GC_Locale_Text.OPTIONSPANELTXT_THOUSEPARATOR )
		GC_Option_DateFormatText:SetText( GC_Locale_Text.OPTIONSPANELTXT_DATEFORMAT )

		GC_Option_ProfileText:SetText( GC_Locale_Text.OPTIONSPANELTXT_PROFILE )
		GC_Options_ProfileSave_Button:SetText( GC_Locale_Text.OPTIONSPANEL_BUTTON2_TEXT )
		GC_Options_ProfileLoad_Button:SetText( GC_Locale_Text.OPTIONSPANEL_BUTTON3_TEXT )
		GC_Options_ProfileDelete_Button:SetText( GC_Locale_Text.OPTIONSPANEL_BUTTON1_TEXT )

		GC_Options_CloseButton1:SetText( GC_Locale_Text.OPTIONSMENU_CLOSE )
		
		GC_Options_ResetDefaultsButton1:SetText( GC_Locale_Text.OPTIONSPANELTXT_RESET )
		
		-- Data Error Dialog
		GC_Error_DialogText:SetText( GC_Locale_Text.ERROR_MSG1 )
		GC_ErrorDialogReloadButton:SetText( GC_Locale_Text.DIALOG_ERROR_RELOAD_BUTTON )
		GC_ErrorDialogDisableButton:SetText( GC_Locale_Text.DIALOG_ERROR_DISABLE_BUTTON )
		--

		-- Reset Addon Dialog
		GC_WarnDialogCancelButton:SetText( GC_Locale_Text.OPTIONSPANEL_BUTTON4_TEXT )
		GC_Warn_DialogText:SetText( GC_Locale_Text.DIALOG_WARNING_DEFAULTS )
		GC_Reset_EraseDB_Text:SetText( GC_Locale_Text.INIT_ADDON_RESETDATA )
		GC_Reset_EraseAllProfiles_Text:SetText( GC_Locale_Text.INIT_ADDON_RESETPROFILES	 )
		--

		GC_CharPanelSortServerText:SetText( GC_Locale_Text.OPTIONSPANELTXT_SORTSERVERS )
		GC_Options_CheckHideHistoryButtonDefText:SetText( GC_Locale_Text.OPTIONSPANELTXT_HIDEHISTORY )
		-------------------------
		
		-----------------------------------------
		-- Information Panel Headers Text      --
		-- Cannot set text before addon loaded --
		-----------------------------------------
		GC_CharPanelTitle:SetText( GC_Locale_Text.INFOPANELTITLE )

		GC_CharPanel_Warband:SetText( GC_Locale_Text.TOOLTIP_WARBAND_BANK )
		GC_CharPanel_Total:SetText( GC_Locale_Text.TOOLTIP_INFOS_TOTAL )
		GoldCounterCharPanel_CloseButton1:SetText( GC_Locale_Text.OPTIONSMENU_CLOSE )
		
		GC_ColFrame_Name_String:SetText( GC_Locale_Text.COL_NAME )
		GC_ColFrame_LvL_String:SetText( GC_Locale_Text.COL_LEVEL )
		GC_ColFrame_iLvL_String:SetText( GC_Locale_Text.COL_ILVL )
		GC_ColFrame_FACTION_String:SetText( GC_Locale_Text.COL_FACTION )
		GC_ColFrame_REALM_String:SetText( GC_Locale_Text.COL_REALM )
		GC_ColFrame_COUNTER_String:SetText( GC_Locale_Text.COL_COUNTER )
		GC_ColFrame_FUNDS_String:SetText( GC_Locale_Text.COL_FUNDS )

		-----------------------------------------
end

function GC_CheckHistLen( num, UpOrDown )

	if UpOrDown == 0 then
	
		if num > GC_MaxHistoryRec then
			num = GC_MaxHistoryRec
		elseif num < GC_MinHistoryRec then
			num = GC_MinHistoryRec
		end

		My_GC_Settings_Local.MaxHistoryRec = num
		GC_BuildHistoryTable()

	else
	
		if UpOrDown == 1 then num = num + 1
		elseif UpOrDown == -1 then num = num - 1
		end

		if num > GC_MaxHistoryRec then
			num = GC_MaxHistoryRec
		elseif num < GC_MinHistoryRec then
			num = GC_MinHistoryRec
		end
	
	end

	return num
end

function GC_BuildHistoryTable()

	local HistSize		= #MySavedMoneyHistory
	local MaxSize 		= My_GC_Settings_Local.MaxHistoryRec

	------------------------
	-- If new table then Build it or reset
	if HistSize == 0 or not MySavedMoneyHistory[1].date then

		for i = 1, MaxSize, 1 do
			MySavedMoneyHistory[i] = { }
			MySavedMoneyHistory[i].date = "*"
			MySavedMoneyHistory[i].amount = "*"
			MySavedMoneyHistory[i].sign = "*"
		end

	-- Increase to new MaxSize
	elseif HistSize < MaxSize then
	
		for i = HistSize+1, MaxSize, 1 do
			MySavedMoneyHistory[i] = { }
			MySavedMoneyHistory[i].date = "*"
			MySavedMoneyHistory[i].amount = "*"
			MySavedMoneyHistory[i].sign = "*"
		end
	
	-- Decrease to new MaxSize
	elseif HistSize > MaxSize then
	
		for i = HistSize, MaxSize+1, -1 do
			MySavedMoneyHistory[i] = nil
		end

	end

	-- Cleaning rest of the table
	for i = MaxSize+1, 99, 1 do
		MySavedMoneyHistory[i] = nil
	end
	------------------------
end
function GC_ClearHistory()

    MySavedMoneyHistory = { }
	GC_BuildHistoryTable()
	GC_MyDailyData.DailyCount = 0

	DEFAULT_CHAT_FRAME:AddMessage( "|cffffff00GoldCounter|r "..GC_Locale_Text.CHAT_HISTORY_ERASED )
	GC_PlaySFX( 3 )
	
end

function GC_GetJobsData()

	GC_Job1, GC_Job1Icon, GC_Job1SkillLevel, GC_Job1MaxSkillLevel = nil, nil, 0, 0
	GC_Job2, GC_Job2Icon, GC_Job2SkillLevel, GC_Job2MaxSkillLevel = nil, nil, 0, 0

	if GC_WOW_isRetail then
	
		local Job1, Job2 = GetProfessions()
	
		if Job1 then GC_Job1, GC_Job1Icon, GC_Job1SkillLevel, GC_Job1MaxSkillLevel = GetProfessionInfo( Job1 ) end
		if Job2 then GC_Job2, GC_Job2Icon, GC_Job2SkillLevel, GC_Job2MaxSkillLevel = GetProfessionInfo( Job2 ) end

	elseif GC_WOW_isPandaria then

		local Job1, Job2 = GetProfessions()
	
		if Job1 then
			GC_Job1, GC_Job1Icon, GC_Job1SkillLevel, GC_Job1MaxSkillLevel = GetProfessionInfo(Job1)
			GC_Job1Icon = GC_CLASSIC_PROFESSION_ICONS[GC_Job1]
		end

		if Job2 then
			GC_Job2, GC_Job2Icon, GC_Job2SkillLevel, GC_Job2MaxSkillLevel = GetProfessionInfo(Job2)
			GC_Job2Icon = GC_CLASSIC_PROFESSION_ICONS[GC_Job2]
		end

	else

	GC_Job1 = nil
	GC_Job1Icon = nil
	GC_Job1SkillLevel = nil
	GC_Job1MaxSkillLevel = nil

	GC_Job2 = nil
	GC_Job2Icon = nil
	GC_Job2SkillLevel = nil
	GC_Job2MaxSkillLevel = nil
	
	for i = 1, GetNumSkillLines() do

		local skillName, _, _, skillRank, _, _, skillMaxRank = GetSkillLineInfo(i)

		if skillName and GC_CLASSIC_PROFESSION_ICONS[skillName] then

			if not GC_Job1 then
				GC_Job1 = skillName
				GC_Job1Icon = GC_CLASSIC_PROFESSION_ICONS[skillName]
				GC_Job1SkillLevel = skillRank
				GC_Job1MaxSkillLevel = skillMaxRank
			else
				GC_Job2 = skillName
				GC_Job2Icon = GC_CLASSIC_PROFESSION_ICONS[skillName]
				GC_Job2SkillLevel = skillRank
				GC_Job2MaxSkillLevel = skillMaxRank
				break
			end

		end

	end

	end

end

function GC_CheckResting()

	local FrameBackdrop = GoldCounter_MainFrame:GetBackdrop()

	--- Border Color
	if IsResting() then --- Si en repos et Frame visible

		if My_GC_Settings_Local.IconsFlash == true 		--- Options animations activée
		and GoldCounter_MainFrame:IsShown() 			--- La frame n'est pas cachée
		and My_GC_Settings_Local.TransView == false		--- Mode non transparent 
		and GC_ToggleSwitch == false					--- Non cachée manuellement
		and FrameBackdrop.bgFile						--- La frame est activée
		and not UnitAffectingCombat("player") then		--- Hors Combat

		StartLoop2() --- Start Blue color border animation
		end

	else

		--- Stop Animation
		StopLoop2()
	end

end

function GC_CheckFighting()

	local FrameBackdrop = GoldCounter_MainFrame:GetBackdrop()

	--- Border Color
	if UnitAffectingCombat("player") then --- Si en combat

		if My_GC_Settings_Local.IconsFlash == true 		--- Options animations activée
		and GoldCounter_MainFrame:IsShown() 			--- La frame n'est pas cachée
		and My_GC_Settings_Local.TransView == false		--- Mode non transparent 
		and GC_ToggleSwitch == false					--- Non cachée manuellement
		and FrameBackdrop.bgFile then					--- La frame est activée

		StopLoop2()  --- Stop Resting color
		StartLoop1() --- Start Red color border animation
		end

	else

		--- Stop Animation
		StopLoop1()

	end

end

function GC_FirstStart()
end
