local HealBot_Options_ComboButtons_Button=1;
local HealBot_Options_Opened=false;
local HealBot_Options_SoftReset_flag=false;
local HealBot_buffbarcolr = {};
local HealBot_buffbarcolg = {};
local HealBot_buffbarcolb = {};
local HealBot_Skins = {};
local HealBot_DebuffWatchTarget={}
local HealBot_DebuffPriority="none"
local HealBot_BuffWatchTarget={}
local BuffTextClass=nil
local strtrim=strtrim
local strsub=strsub
local tonumber=tonumber
local floor=floor
local HealBot_Action_SetAllAttribs_flag=false
local class=nil
local mins,secs=0,0
local DoInitTab1=true
local DoInitTab2=true
local DoInitTab3=true
local DoInitTab4=true
local DoInitTab5=true
local DoInitTab6=true
local DoInitTab9=true
local DoInitTab10=true
local bar=nil
local sName=nil
local sRank=nil
local dName=nil
local id=nil
local sID=nil
local val=nil
local text=nil
local unique=nil
local x,y,z,k,j=nil,nil,nil,nil,nil
local textures=nil
local texturesIndex={}
local fonts=nil
local fontsIndex={}
local sounds=nil
local soundsIndex={}
local updatingMedia=false
local LSM = LibStub("LibSharedMedia-3.0")
local uGUID=nil
local xGUID=nil
local BuffWatchName=nil
local ClickedBuffGroupDD=nil
local tGUID=nil
local tName=nil
local hbCurSkin=""
local t=nil
local t2={}

local HealBot_Options_BuffTxt_List = {
    HEALBOT_WORDS_NONE,
    HEALBOT_OPTIONS_BUFFSELF,
    HEALBOT_OPTIONS_BUFFPARTY,
    HEALBOT_OPTIONS_BUFFRAID,
    HEALBOT_DRUID,
    HEALBOT_HUNTER,
    HEALBOT_MAGE,
    HEALBOT_PALADIN,
    HEALBOT_PRIEST,
    HEALBOT_ROGUE,
    HEALBOT_SHAMAN,
    HEALBOT_WARLOCK,
    HEALBOT_WARRIOR,
    HEALBOT_DEATHKNIGHT,
    HEALBOT_CLASSES_MELEE,
    HEALBOT_CLASSES_RANGES,
    HEALBOT_CLASSES_HEALERS,
    HEALBOT_CLASSES_CUSTOM,
    HEALBOT_SELF_PVP,
    HEALBOT_OPTIONS_TANKHEALS,
    HEALBOT_OPTIONS_MYTARGET,
    HEALBOT_FOCUS,
	HEALBOT_SORTBY_NAME,
}

local HealBot_Buff_Spells_Total_List = {
    ["DRUI"] = {
        HEALBOT_MARK_OF_THE_WILD,
        HEALBOT_GIFT_OF_THE_WILD,
        HEALBOT_THORNS,
        HEALBOT_OMEN_OF_CLARITY,
    },
    ["HUNT"] = {
        HEALBOT_A_MONKEY,
        HEALBOT_A_HAWK,
        HEALBOT_A_CHEETAH,
        HEALBOT_A_BEAST,
        HEALBOT_A_PACK,
        HEALBOT_A_WILD,
        HEALBOT_A_VIPER,
        HEALBOT_A_DRAGONHAWK,
    },
    ["MAGE"] = {
        HEALBOT_ARCANE_INTELLECT,
        HEALBOT_ARCANE_BRILLIANCE,
        HEALBOT_DALARAN_INTELLECT,
        HEALBOT_DALARAN_BRILLIANCE,
        HEALBOT_FROST_ARMOR,
        HEALBOT_ICE_ARMOR,
        HEALBOT_MAGE_ARMOR,
        HEALBOT_MOLTEN_ARMOR,
        HEALBOT_DAMPEN_MAGIC,
        HEALBOT_AMPLIFY_MAGIC,
        HEALBOT_FOCUS_MAGIC,
    },
    ["PALA"] = {
        HEALBOT_BLESSING_OF_MIGHT,
        HEALBOT_BLESSING_OF_WISDOM,
        HEALBOT_BLESSING_OF_SALVATION,
        HEALBOT_BLESSING_OF_SANCTUARY,
        HEALBOT_BLESSING_OF_LIGHT,
        HEALBOT_BLESSING_OF_PROTECTION,
        HEALBOT_BLESSING_OF_FREEDOM,
        HEALBOT_BLESSING_OF_SACRIFICE,
        HEALBOT_BLESSING_OF_KINGS,
        HEALBOT_GREATER_BLESSING_OF_MIGHT,
        HEALBOT_GREATER_BLESSING_OF_WISDOM,
        HEALBOT_GREATER_BLESSING_OF_KINGS,
        HEALBOT_GREATER_BLESSING_OF_LIGHT,
        HEALBOT_GREATER_BLESSING_OF_SALVATION,
        HEALBOT_GREATER_BLESSING_OF_SANCTUARY,
        HEALBOT_HAND_OF_FREEDOM,
        HEALBOT_HAND_OF_PROTECTION,
        HEALBOT_HAND_OF_SACRIFICE,
        HEALBOT_HAND_OF_SALVATION,
        HEALBOT_RIGHTEOUS_FURY,
        HEALBOT_DEVOTION_AURA,
        HEALBOT_RETRIBUTION_AURA,
        HEALBOT_CONCENTRATION_AURA,
        HEALBOT_SHR_AURA,
        HEALBOT_FRR_AURA,
        HEALBOT_FIR_AURA,
        HEALBOT_CRUSADER_AURA,
        HEALBOT_SANCTITY_AURA,
        HEALBOT_BEACON_OF_LIGHT,
        HEALBOT_SACRED_SHIELD,
        HEALBOT_SHEATH_OF_LIGHT,
        HEALBOT_SEAL_OF_RIGHTEOUSNESS,
        HEALBOT_SEAL_OF_BLOOD,
        HEALBOT_SEAL_OF_CORRUPTION,
        HEALBOT_SEAL_OF_JUSTICE,
        HEALBOT_SEAL_OF_LIGHT,
        HEALBOT_SEAL_OF_VENGEANCE,
        HEALBOT_SEAL_OF_WISDOM,
        HEALBOT_SEAL_OF_COMMAND,
        HEALBOT_SEAL_OF_THE_MARTYR,
    },
    ["PRIE"] = {
        HEALBOT_POWER_WORD_FORTITUDE,
        HEALBOT_PRAYER_OF_FORTITUDE,
        HEALBOT_ANCESTRAL_FORTITUDE,
        HEALBOT_INNER_FIRE,
        HEALBOT_TOUCH_OF_WEAKNESS,
        HEALBOT_FEAR_WARD,
        HEALBOT_PAIN_SUPPRESSION,
        HEALBOT_POWER_INFUSION,
        HEALBOT_DIVINE_SPIRIT,
        HEALBOT_LEVITATE,
        HEALBOT_PRAYER_OF_SPIRIT,
        HEALBOT_SHADOW_PROTECTION,
        HEALBOT_PRAYER_OF_SHADOW_PROTECTION,
        HEALBOT_SHADOWFORM,
        HEALBOT_VAMPIRIC_EMBRACE,
        HEALBOT_SHADOW_GUARD,
    },
    ["ROGU"] = {
    },
    ["SHAM"] = {
        HEALBOT_LIGHTNING_SHIELD,
        HEALBOT_ROCKBITER_WEAPON,
        HEALBOT_FLAMETONGUE_WEAPON,
        HEALBOT_EARTHLIVING_WEAPON,
        HEALBOT_WINDFURY_WEAPON,
        HEALBOT_FROSTBRAND_WEAPON,
        HEALBOT_EARTH_SHIELD,
        HEALBOT_WATER_SHIELD,
        HEALBOT_WIND_FURY,
        HEALBOT_WATER_BREATHING,
        HEALBOT_WATER_WALKING, 
    },
    ["WARL"] = {
        HEALBOT_DEMON_ARMOR,
        HEALBOT_DEMON_SKIN,
        HEALBOT_FEL_ARMOR,
        HEALBOT_SOUL_LINK,
        HEALBOT_DETECT_INV,
        HEALBOT_UNENDING_BREATH,
    },
    ["WARR"] = {
        HEALBOT_BATTLE_SHOUT,
        HEALBOT_COMMANDING_SHOUT,
        HEALBOT_VIGILANCE,
    },
    ["DEAT"] = {
        HEALBOT_HORN_OF_WINTER,
        HEALBOT_BONE_SHIELD,
    },
}

local HealBot_Buff_Spells_Class_List={}
local HealBot_Buff_Spells_List ={}

function HealBot_Options_InitBuffClassList()
    HealBot_Buff_Spells_Class_List = HealBot_Buff_Spells_Total_List[strsub(HealBot_PlayerClassEN,1,4)]
    table.sort (HealBot_Buff_Spells_Class_List)
end

function HealBot_Options_InitBuffList()
    HealBot_Buff_Spells_List ={}
    for j=1, getn(HealBot_Buff_Spells_Class_List), 1 do
        sID=HealBot_GetSpellId(HealBot_Buff_Spells_Class_List[j]);
        if sID then
            table.insert(HealBot_Buff_Spells_List,HealBot_Buff_Spells_Class_List[j])
            if not HealBot_Spells[HealBot_Buff_Spells_Class_List[j]] then
                if not HealBot_OtherSpells[HealBot_Buff_Spells_Class_List[j]] then
                    id = HealBot_GetSpellId(HealBot_Buff_Spells_Class_List[j]);
                    if id then
                        HealBot_FindSpellRangeCast(id);
                    end
                end
            end
        end
    end
end

local HealBot_Debuff_Spells = {
  ["PALA"] = {
    HEALBOT_PURIFY,
    HEALBOT_CLEANSE,
    HEALBOT_BLESSING_OF_FREEDOM,
                      },
  ["DRUI"] = {
    HEALBOT_CURE_POISON,
    HEALBOT_REMOVE_CURSE,
    HEALBOT_ABOLISH_POISON,
                    },
  ["PRIE"] = {
    HEALBOT_CURE_DISEASE,
    HEALBOT_DISPEL_MAGIC,
    HEALBOT_ABOLISH_DISEASE,
                     },
  ["SHAM"] = {
    HEALBOT_CURE_TOXINS,
    HEALBOT_CLEANSE_SPIRIT,
                       },
  ["HUNT"] = {},
  ["MAGE"] = {HEALBOT_REMOVE_CURSE,},
  ["ROGU"] = {},
  ["WARL"] = {},
  ["WARR"] = {},
  ["DEAT"] = {},
}

local HealBot_Racial_Debuff_Spells = {
  ["Hum"] = {},
  ["Dwa"] = {HEALBOT_STONEFORM,},
  ["Nig"] = {},
  ["Gno"] = {},
  ["Dra"] = {},
  ["Orc"] = {},
  ["Sco"] = {}, -- Undead
  ["Tau"] = {},
  ["Tro"] = {}, 
  ["Blo"] = {},
}

local HealBot_Debuff_Types = {
  [HEALBOT_PURIFY] = {HEALBOT_DISEASE_en, HEALBOT_POISON_en},
  [HEALBOT_CLEANSE] = {HEALBOT_DISEASE_en, HEALBOT_POISON_en, HEALBOT_MAGIC_en},
  [HEALBOT_CURE_POISON] = {HEALBOT_POISON_en},
  [HEALBOT_REMOVE_CURSE] = {HEALBOT_CURSE_en},
  [HEALBOT_ABOLISH_POISON] = {HEALBOT_POISON_en},
  [HEALBOT_CURE_DISEASE] = {HEALBOT_DISEASE_en},
  [HEALBOT_ABOLISH_DISEASE] = {HEALBOT_DISEASE_en},
  [HEALBOT_DISPEL_MAGIC] = {HEALBOT_MAGIC_en},
  [HEALBOT_PURIFICATION_POTION] = {HEALBOT_CURSE_en, HEALBOT_DISEASE_en, HEALBOT_POISON_en},
  [HEALBOT_ANTI_VENOM] = {HEALBOT_POISON_en},
  [HEALBOT_POWERFUL_ANTI_VENOM] = {HEALBOT_POISON_en},
  [HEALBOT_ELIXIR_OF_POISON_RES] = {HEALBOT_POISON_en},
  [HEALBOT_BLESSING_OF_FREEDOM] = {HEALBOT_MAGIC_en},
  [HEALBOT_STONEFORM] = {HEALBOT_DISEASE_en, HEALBOT_POISON_en},
  [HEALBOT_CLEANSE_SPIRIT] = {HEALBOT_DISEASE_en, HEALBOT_POISON_en, HEALBOT_CURSE_en},
  [HEALBOT_CURE_TOXINS] = {HEALBOT_DISEASE_en, HEALBOT_POISON_en},
}

local CPUProfiler=0
StaticPopupDialogs["HEALBOT_OPTIONS_RELOADUI"] = {
    text = HEALBOT_OPTIONS_RELOADUIMSG,
    button1 = HEALBOT_WORDS_YES,
    button2 = HEALBOT_WORDS_NO,
    OnAccept = function()
        ReloadUI();
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1
};

local hbOptGetSkinFrom=" "
local hbOptGetSkinName=" "
StaticPopupDialogs["HEALBOT_OPTIONS_ACCEPTSKIN"] = {
    text = HEALBOT_OPTIONS_ACCEPTSKINMSG.."%s",
    button1 = HEALBOT_WORDS_YES,
    button2 = HEALBOT_WORDS_NO,
    OnAccept = function()
        HealBot_Options_ShareSkinAccept();
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1
};

function HealBot_Options_retDebuffWatchTarget(debuffType, hbGUID)
    if HealBot_DebuffSpell[debuffType] and HealBot_Config.HealBot_BuffWatchGUID[HealBot_DebuffSpell[debuffType]] then
        return HealBot_DebuffWatchTarget[debuffType], HealBot_Config.HealBot_BuffWatchGUID[HealBot_DebuffSpell[debuffType]][hbGUID]
    else
        return HealBot_DebuffWatchTarget[debuffType], nil
    end
end

function HealBot_Options_retBuffWatchTarget(buffName, hbGUID)
    if HealBot_Config.HealBot_BuffWatchGUID[buffName] then
        return HealBot_BuffWatchTarget[buffName], HealBot_Config.HealBot_BuffWatchGUID[buffName][hbGUID]
    else
        return HealBot_BuffWatchTarget[buffName], nil
    end
end

function HealBot_Options_retDebuffPriority()
    return HealBot_DebuffPriority
end

function HealBot_Options_Pct_OnLoad(self,vText)
    self.text = vText;
    getglobal(self:GetName().."Text"):SetText(vText);
    getglobal(self:GetName().."Low"):SetText("0%");
    getglobal(self:GetName().."High"):SetText("100%");
    self:SetMinMaxValues(0.00,1.00);
    self:SetValueStep(0.01);
end

function HealBot_Options_Pct_OnLoad_MinMax(self,vText,Min,Max)
    self.text = vText;

    i=(Min*100).."%";
    j=(Max*100).."%";

    getglobal(self:GetName().."Text"):SetText(vText);
    getglobal(self:GetName().."Low"):SetText(i);
    getglobal(self:GetName().."High"):SetText(j);
    self:SetMinMaxValues(Min,Max);
    self:SetValueStep(0.01);
end

function HealBot_Options_val_OnLoad(self,vText,Min,Max)
    self.text = vText;

    getglobal(self:GetName().."Text"):SetText(vText);
    getglobal(self:GetName().."Low"):SetText(Min);
    getglobal(self:GetName().."High"):SetText(Max);
    self:SetMinMaxValues(Min,Max);
    self:SetValueStep(1);
end

function HealBot_Options_valNoCols_OnLoad(self,Min,Max)
    getglobal(self:GetName().."Text"):SetText(HealBot_Options_SetNoColsText);
    getglobal(self:GetName().."Low"):SetText(Min);
    getglobal(self:GetName().."High"):SetText(Max);
    self:SetMinMaxValues(Min,Max);
    self:SetValueStep(1);
end

function HealBot_Options_val2_OnLoad(self,vText,Min,Max,Step)
    self.text = vText;

    getglobal(self:GetName().."Text"):SetText(vText);
    getglobal(self:GetName().."Low"):SetText(Min/10);
    getglobal(self:GetName().."High"):SetText(Max/10);
    self:SetMinMaxValues(Min,Max);
    self:SetValueStep(Step);
end

function HealBot_Options_valtime_OnLoad(self,vText,Min,Max,Step,secsOnly)
    self.text = vText;

    getglobal(self:GetName().."Text"):SetText(vText);
    if secsOnly then
        getglobal(self:GetName().."Low"):SetText(Min);
        getglobal(self:GetName().."High"):SetText(Max);
    else
        getglobal(self:GetName().."Low"):SetText(Min/60);
        getglobal(self:GetName().."High"):SetText(Max/60);
    end
    self:SetMinMaxValues(Min,Max);
    self:SetValueStep(Step);
end

function HealBot_Options_SetText(self,vText)
    getglobal(self:GetName().."Text"):SetText(vText);
end

function HealBot_Options_NotifyHealMsg_OnTextChanged(self)
    Healbot_Config_Skins.NotifyHealMsg[Healbot_Config_Skins.Current_Skin] = self:GetText()
end

function HealBot_Options_NotifyOtherMsg_OnTextChanged(self)
    Healbot_Config_Skins.NotifyOtherMsg[Healbot_Config_Skins.Current_Skin] = self:GetText()
end

function HealBot_Options_SetNoColsText()
    if Healbot_Config_Skins.ShowHeader[Healbot_Config_Skins.Current_Skin]==1 then
        HealBot_Options_BarNumGroupPerCol:Hide()
        return HEALBOT_OPTIONS_SKINNUMHCOLS;
    else
        HealBot_Options_BarNumGroupPerCol:Show()
        if Healbot_Config_Skins.GroupsPerCol[Healbot_Config_Skins.Current_Skin]==1 then
            return HEALBOT_OPTIONS_SKINNUMHCOLS;
        else
            return HEALBOT_OPTIONS_SKINNUMCOLS;
        end
    end
end

local pct=nil
function HealBot_Options_Pct_OnValueChanged(self)
    pct = floor(self:GetValue()*100+0.5);
    getglobal(self:GetName().."Text"):SetText(self.text .. " (" .. pct .. "%)");
    return self:GetValue();
end


function HealBot_Options_NewSkin_OnTextChanged(self)
    text= self:GetText()
    if strlen(text)>0 then
        HealBot_Options_NewSkinb:Enable();
    else
        HealBot_Options_NewSkinb:Disable();
    end
end

local NewSkinTxt=nil
function HealBot_Options_NewSkinb_OnClick(self)
    NewSkinTxt=HealBot_Options_NewSkin:GetText()
    Healbot_Config_Skins.numcols[NewSkinTxt] = Healbot_Config_Skins.numcols[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btexture[NewSkinTxt] = Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.bcspace[NewSkinTxt] = Healbot_Config_Skins.bcspace[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.brspace[NewSkinTxt] = Healbot_Config_Skins.brspace[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.bwidth[NewSkinTxt] = Healbot_Config_Skins.bwidth[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.bheight[NewSkinTxt] = Healbot_Config_Skins.bheight[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextenabledcolr[NewSkinTxt] = Healbot_Config_Skins.btextenabledcolr[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextenabledcolg[NewSkinTxt] = Healbot_Config_Skins.btextenabledcolg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextenabledcolb[NewSkinTxt] = Healbot_Config_Skins.btextenabledcolb[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextenabledcola[NewSkinTxt] = Healbot_Config_Skins.btextenabledcola[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextdisbledcolr[NewSkinTxt] = Healbot_Config_Skins.btextdisbledcolr[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextdisbledcolg[NewSkinTxt] = Healbot_Config_Skins.btextdisbledcolg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextdisbledcolb[NewSkinTxt] = Healbot_Config_Skins.btextdisbledcolb[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextdisbledcola[NewSkinTxt] = Healbot_Config_Skins.btextdisbledcola[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextcursecolr[NewSkinTxt] = Healbot_Config_Skins.btextcursecolr[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextcursecolg[NewSkinTxt] = Healbot_Config_Skins.btextcursecolg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextcursecolb[NewSkinTxt] = Healbot_Config_Skins.btextcursecolb[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextcursecola[NewSkinTxt] = Healbot_Config_Skins.btextcursecola[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.backcola[NewSkinTxt] = Healbot_Config_Skins.backcola[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.Barcola[NewSkinTxt] = Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.BarcolaInHeal[NewSkinTxt] = Healbot_Config_Skins.BarcolaInHeal[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.backcolr[NewSkinTxt] = Healbot_Config_Skins.backcolr[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.backcolg[NewSkinTxt] = Healbot_Config_Skins.backcolg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.backcolb[NewSkinTxt] = Healbot_Config_Skins.backcolb[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.borcolr[NewSkinTxt] = Healbot_Config_Skins.borcolr[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.borcolg[NewSkinTxt] = Healbot_Config_Skins.borcolg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.borcolb[NewSkinTxt] = Healbot_Config_Skins.borcolb[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.borcola[NewSkinTxt] = Healbot_Config_Skins.borcola[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextheight[NewSkinTxt] = Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.bardisa[NewSkinTxt] = Healbot_Config_Skins.bardisa[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.bareora[NewSkinTxt] = Healbot_Config_Skins.bareora[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.bar2size[NewSkinTxt] = Healbot_Config_Skins.bar2size[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowHeader[NewSkinTxt] = Healbot_Config_Skins.ShowHeader[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headbarcolr[NewSkinTxt] = Healbot_Config_Skins.headbarcolr[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headbarcolg[NewSkinTxt] = Healbot_Config_Skins.headbarcolg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headbarcolb[NewSkinTxt] = Healbot_Config_Skins.headbarcolb[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headbarcola[NewSkinTxt] = Healbot_Config_Skins.headbarcola[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headtxtcolr[NewSkinTxt] = Healbot_Config_Skins.headtxtcolr[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headtxtcolg[NewSkinTxt] = Healbot_Config_Skins.headtxtcolg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headtxtcolb[NewSkinTxt] = Healbot_Config_Skins.headtxtcolb[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headtxtcola[NewSkinTxt] = Healbot_Config_Skins.headtxtcola[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headtexture[NewSkinTxt] = Healbot_Config_Skins.headtexture[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headwidth[NewSkinTxt] = Healbot_Config_Skins.headwidth[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headhight[NewSkinTxt] = Healbot_Config_Skins.headhight[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowAggro[NewSkinTxt] = Healbot_Config_Skins.ShowAggro[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowAggroBars[NewSkinTxt] = Healbot_Config_Skins.ShowAggroBars[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowAggroText[NewSkinTxt] = Healbot_Config_Skins.ShowAggroText[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.HighLightActiveBar[NewSkinTxt] = Healbot_Config_Skins.HighLightActiveBar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.UseFluidBars[NewSkinTxt] = Healbot_Config_Skins.UseFluidBars[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.BarFreq[NewSkinTxt] = Healbot_Config_Skins.BarFreq[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowHoTicons[NewSkinTxt] = Healbot_Config_Skins.ShowHoTicons[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIcon[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIcon[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIconStar[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIconStar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIconCircle[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIconCircle[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIconDiamond[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIconDiamond[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIconTriangle[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIconTriangle[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIconMoon[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIconMoon[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIconSquare[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIconSquare[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIconCross[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIconCross[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowRaidIconSkull[NewSkinTxt] = Healbot_Config_Skins.ShowRaidIconSkull[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.HoTonBar[NewSkinTxt] = Healbot_Config_Skins.HoTonBar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.HoTposBar[NewSkinTxt] = Healbot_Config_Skins.HoTposBar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.HoTx2Bar[NewSkinTxt] = Healbot_Config_Skins.HoTx2Bar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowClassOnBar[NewSkinTxt] = Healbot_Config_Skins.ShowClassOnBar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowClassType[NewSkinTxt] = Healbot_Config_Skins.ShowClassType[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowNameOnBar[NewSkinTxt] = Healbot_Config_Skins.ShowNameOnBar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowHealthOnBar[NewSkinTxt] = Healbot_Config_Skins.ShowHealthOnBar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.BarHealthIncHeals[NewSkinTxt] = Healbot_Config_Skins.BarHealthIncHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.BarHealthSepHeals[NewSkinTxt] = Healbot_Config_Skins.BarHealthSepHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.BarHealthType[NewSkinTxt] = Healbot_Config_Skins.BarHealthType[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SetClassColourText[NewSkinTxt] = Healbot_Config_Skins.SetClassColourText[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SetBarClassColour[NewSkinTxt] = Healbot_Config_Skins.SetBarClassColour[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SetBarCustomColour[NewSkinTxt] = Healbot_Config_Skins.SetBarCustomColour[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowDebuffIcon[NewSkinTxt] = Healbot_Config_Skins.ShowDebuffIcon[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowIconTextCount[NewSkinTxt] = Healbot_Config_Skins.ShowIconTextCount[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowIconTextCountSelfCast[NewSkinTxt] = Healbot_Config_Skins.ShowIconTextCountSelfCast[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowIconTextDuration[NewSkinTxt] = Healbot_Config_Skins.ShowIconTextDuration[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowIconTextDurationSelfCast[NewSkinTxt] = Healbot_Config_Skins.ShowIconTextDurationSelfCast[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.IconScale[NewSkinTxt] = Healbot_Config_Skins.IconScale[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.IconTextScale[NewSkinTxt] = Healbot_Config_Skins.IconTextScale[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.btextfont[NewSkinTxt] = Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headtextfont[NewSkinTxt] = Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.headtextheight[NewSkinTxt] = Healbot_Config_Skins.headtextheight[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.AggroBarSize[NewSkinTxt] = Healbot_Config_Skins.AggroBarSize[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.PanelAnchorY[NewSkinTxt] = Healbot_Config_Skins.PanelAnchorY[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.highcolr[NewSkinTxt] = Healbot_Config_Skins.highcolr[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.highcolg[NewSkinTxt] = Healbot_Config_Skins.highcolg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.highcolb[NewSkinTxt] = Healbot_Config_Skins.highcolb[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.PanelAnchorX[NewSkinTxt] = Healbot_Config_Skins.PanelAnchorX[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.TextAlignment[NewSkinTxt] = Healbot_Config_Skins.TextAlignment[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.DoubleText[NewSkinTxt] = Healbot_Config_Skins.DoubleText[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.GroupsPerCol[NewSkinTxt] = Healbot_Config_Skins.GroupsPerCol[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SelfHeals[NewSkinTxt] = Healbot_Config_Skins.SelfHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.PetHeals[NewSkinTxt] = Healbot_Config_Skins.PetHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.GroupHeals[NewSkinTxt] = Healbot_Config_Skins.GroupHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.TankHeals[NewSkinTxt] = Healbot_Config_Skins.TankHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SelfPet[NewSkinTxt] = Healbot_Config_Skins.SelfPet[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.EmergencyHeals[NewSkinTxt] = Healbot_Config_Skins.EmergencyHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SetFocusBar[NewSkinTxt] = Healbot_Config_Skins.SetFocusBar[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.VehicleHeals[NewSkinTxt] = Healbot_Config_Skins.VehicleHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ShowMyTargetsList[NewSkinTxt] = Healbot_Config_Skins.ShowMyTargetsList[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.TargetHeals[NewSkinTxt] = Healbot_Config_Skins.TargetHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.TargetIncSelf[NewSkinTxt] = Healbot_Config_Skins.TargetIncSelf[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.TargetIncGroup[NewSkinTxt] = Healbot_Config_Skins.TargetIncGroup[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.TargetIncRaid[NewSkinTxt] = Healbot_Config_Skins.TargetIncRaid[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.TargetIncPet[NewSkinTxt] = Healbot_Config_Skins.TargetIncPet[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.TargetBarNormalMode[NewSkinTxt] = Healbot_Config_Skins.TargetBarNormalMode[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.AlertLevel[NewSkinTxt] = Healbot_Config_Skins.AlertLevel[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.NotVisibleDisable[NewSkinTxt] = Healbot_Config_Skins.NotVisibleDisable[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.EmergIncMonitor[NewSkinTxt] = Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ExtraOrder[NewSkinTxt] = Healbot_Config_Skins.ExtraOrder[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.ExtraSubOrder[NewSkinTxt] = Healbot_Config_Skins.ExtraSubOrder[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.HidePartyFrames[NewSkinTxt] = Healbot_Config_Skins.HidePartyFrames[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.HidePlayerTarget[NewSkinTxt] = Healbot_Config_Skins.HidePlayerTarget[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.CastNotify[NewSkinTxt] = Healbot_Config_Skins.CastNotify[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.NotifyChan[NewSkinTxt] = Healbot_Config_Skins.NotifyChan[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.NotifyHealMsg[NewSkinTxt] = Healbot_Config_Skins.NotifyHealMsg[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.NotifyOtherMsg[NewSkinTxt] = Healbot_Config_Skins.NotifyOtherMsg[Healbot_Config_Skins.Current_Skin]   
    Healbot_Config_Skins.CastNotifyResOnly[NewSkinTxt] = Healbot_Config_Skins.CastNotifyResOnly[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.Panel_Anchor[NewSkinTxt] = Healbot_Config_Skins.Panel_Anchor[Healbot_Config_Skins.Current_Skin]
    HealBot_Config.SkinDefault[NewSkinTxt] = 1
    Healbot_Config_Skins.ShowIncHeals[NewSkinTxt] = Healbot_Config_Skins.ShowIncHeals[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.incHealDur[NewSkinTxt] = { D = 5, H = 3, C = 3 }
    Healbot_Config_Skins.ExtraIncGroup[NewSkinTxt] = {[1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = true}
    Healbot_Config_Skins.ActionLocked[NewSkinTxt] = Healbot_Config_Skins.ActionLocked[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.AutoClose[NewSkinTxt] = Healbot_Config_Skins.AutoClose[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.PanelSounds[NewSkinTxt] = Healbot_Config_Skins.PanelSounds[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SubSortIncGroup[NewSkinTxt] = Healbot_Config_Skins.SubSortIncGroup[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SubSortIncPet[NewSkinTxt] = Healbot_Config_Skins.SubSortIncPet[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SubSortIncVehicle[NewSkinTxt] = Healbot_Config_Skins.SubSortIncVehicle[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SubSortIncTanks[NewSkinTxt] = Healbot_Config_Skins.SubSortIncTanks[Healbot_Config_Skins.Current_Skin]
    Healbot_Config_Skins.SubSortIncMyTargets[NewSkinTxt] = Healbot_Config_Skins.SubSortIncMyTargets[Healbot_Config_Skins.Current_Skin]
        
    unique=true;
    table.foreach(HealBot_Skins, function (index,skin)
        if skin==HealBot_Options_NewSkin:GetText() then unique=false; end
    end)
    if unique then
        table.insert(HealBot_Skins,2,NewSkinTxt)
        Healbot_Config_Skins.Skin_ID = 2;
        Healbot_Config_Skins.Skins = HealBot_Skins
        Healbot_Config_Skins.Current_Skin = NewSkinTxt
    end
    HealBot_Options_SetSkins();
    HealBot_Options_NewSkin:SetText("")
end

local hbDelSkinName=nil
function HealBot_Options_DeleteSkin_OnClick(self)
    if Healbot_Config_Skins.Current_Skin~=HEALBOT_SKINS_STD then
        hbDelSkinName=HealBot_Options_SkinsText:GetText()
        Healbot_Config_Skins.numcols[hbDelSkinName] = nil
        Healbot_Config_Skins.btexture[hbDelSkinName] = nil
        Healbot_Config_Skins.bcspace[hbDelSkinName] = nil
        Healbot_Config_Skins.brspace[hbDelSkinName] = nil
        Healbot_Config_Skins.bwidth[hbDelSkinName] = nil
        Healbot_Config_Skins.bheight[hbDelSkinName] = nil
        Healbot_Config_Skins.btextenabledcolr[hbDelSkinName] = nil
        Healbot_Config_Skins.btextenabledcolg[hbDelSkinName] = nil
        Healbot_Config_Skins.btextenabledcolb[hbDelSkinName] = nil
        Healbot_Config_Skins.btextenabledcola[hbDelSkinName] = nil
        Healbot_Config_Skins.btextdisbledcolr[hbDelSkinName] = nil
        Healbot_Config_Skins.btextdisbledcolg[hbDelSkinName] = nil
        Healbot_Config_Skins.btextdisbledcolb[hbDelSkinName] = nil
        Healbot_Config_Skins.btextdisbledcola[hbDelSkinName] = nil
        Healbot_Config_Skins.btextcursecolr[hbDelSkinName] = nil
        Healbot_Config_Skins.btextcursecolg[hbDelSkinName] = nil
        Healbot_Config_Skins.btextcursecolb[hbDelSkinName] = nil
        Healbot_Config_Skins.btextcursecola[hbDelSkinName] = nil
        Healbot_Config_Skins.backcola[hbDelSkinName] = nil
        Healbot_Config_Skins.Barcola[hbDelSkinName] = nil
        Healbot_Config_Skins.BarcolaInHeal[hbDelSkinName] = nil
        Healbot_Config_Skins.backcolr[hbDelSkinName] = nil
        Healbot_Config_Skins.backcolg[hbDelSkinName] = nil
        Healbot_Config_Skins.backcolb[hbDelSkinName] = nil
        Healbot_Config_Skins.borcolr[hbDelSkinName] = nil
        Healbot_Config_Skins.borcolg[hbDelSkinName] = nil
        Healbot_Config_Skins.borcolb[hbDelSkinName] = nil
        Healbot_Config_Skins.borcola[hbDelSkinName] = nil
        Healbot_Config_Skins.btextheight[hbDelSkinName] = nil
        Healbot_Config_Skins.bardisa[hbDelSkinName] = nil
        Healbot_Config_Skins.bareora[hbDelSkinName] = nil
        Healbot_Config_Skins.bar2size[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowHeader[hbDelSkinName] = nil
        Healbot_Config_Skins.headbarcolr[hbDelSkinName] = nil
        Healbot_Config_Skins.headbarcolg[hbDelSkinName] = nil
        Healbot_Config_Skins.headbarcolb[hbDelSkinName] = nil
        Healbot_Config_Skins.headbarcola[hbDelSkinName] = nil
        Healbot_Config_Skins.headtxtcolr[hbDelSkinName] = nil
        Healbot_Config_Skins.headtxtcolg[hbDelSkinName] = nil
        Healbot_Config_Skins.headtxtcolb[hbDelSkinName] = nil
        Healbot_Config_Skins.headtxtcola[hbDelSkinName] = nil
        Healbot_Config_Skins.headtexture[hbDelSkinName] = nil
        Healbot_Config_Skins.headwidth[hbDelSkinName] = nil
        Healbot_Config_Skins.headhight[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowAggro[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowAggroBars[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowAggroText[hbDelSkinName] = nil
        Healbot_Config_Skins.HighLightActiveBar[hbDelSkinName] = nil
        Healbot_Config_Skins.UseFluidBars[hbDelSkinName] = nil
        Healbot_Config_Skins.BarFreq[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowHoTicons[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIcon[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIconStar[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIconCircle[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIconDiamond[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIconTriangle[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIconMoon[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIconSquare[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIconCross[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowRaidIconSkull[hbDelSkinName] = nil
        Healbot_Config_Skins.HoTonBar[hbDelSkinName] = nil
        Healbot_Config_Skins.HoTposBar[hbDelSkinName] = nil
        Healbot_Config_Skins.HoTx2Bar[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowClassOnBar[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowClassType[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowNameOnBar[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowHealthOnBar[hbDelSkinName] = nil
        Healbot_Config_Skins.BarHealthIncHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.BarHealthSepHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.BarHealthType[hbDelSkinName] = nil
        Healbot_Config_Skins.SetClassColourText[hbDelSkinName] = nil
        Healbot_Config_Skins.SetBarClassColour[hbDelSkinName] = nil
        Healbot_Config_Skins.SetBarCustomColour[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowDebuffIcon[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowIconTextCount[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowIconTextCountSelfCast[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowIconTextDuration[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowIconTextDurationSelfCast[hbDelSkinName] = nil
        Healbot_Config_Skins.IconScale[hbDelSkinName] = nil
        Healbot_Config_Skins.IconTextScale[hbDelSkinName] = nil
        Healbot_Config_Skins.btextfont[hbDelSkinName] = nil
        Healbot_Config_Skins.headtextfont[hbDelSkinName] = nil
        Healbot_Config_Skins.headtextheight[hbDelSkinName] = nil
        Healbot_Config_Skins.AggroBarSize[hbDelSkinName] = nil
        Healbot_Config_Skins.PanelAnchorY[hbDelSkinName] = nil
        Healbot_Config_Skins.highcolr[hbDelSkinName] = nil
        Healbot_Config_Skins.highcolg[hbDelSkinName] = nil
        Healbot_Config_Skins.highcolb[hbDelSkinName] = nil
        Healbot_Config_Skins.PanelAnchorX[hbDelSkinName] = nil
        Healbot_Config_Skins.TextAlignment[hbDelSkinName] = nil
        Healbot_Config_Skins.DoubleText[hbDelSkinName] = nil
        Healbot_Config_Skins.GroupsPerCol[hbDelSkinName] = nil
        Healbot_Config_Skins.SelfHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.PetHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.GroupHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.TankHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.SelfPet[hbDelSkinName] = nil
        Healbot_Config_Skins.EmergencyHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.SetFocusBar[hbDelSkinName] = nil
        Healbot_Config_Skins.VehicleHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowMyTargetsList[hbDelSkinName] = nil
        Healbot_Config_Skins.TargetHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.TargetIncSelf[hbDelSkinName] = nil
        Healbot_Config_Skins.TargetIncGroup[hbDelSkinName] = nil
        Healbot_Config_Skins.TargetIncRaid[hbDelSkinName] = nil
        Healbot_Config_Skins.TargetIncPet[hbDelSkinName] = nil
        Healbot_Config_Skins.TargetBarNormalMode[hbDelSkinName] = nil
        Healbot_Config_Skins.AlertLevel[hbDelSkinName] = nil
        Healbot_Config_Skins.NotVisibleDisable[hbDelSkinName] = nil
        Healbot_Config_Skins.EmergIncMonitor[hbDelSkinName] = nil
        Healbot_Config_Skins.ExtraOrder[hbDelSkinName] = nil
        Healbot_Config_Skins.ExtraSubOrder[hbDelSkinName] = nil
        Healbot_Config_Skins.HidePartyFrames[hbDelSkinName] = nil
        Healbot_Config_Skins.HidePlayerTarget[hbDelSkinName] = nil
        Healbot_Config_Skins.CastNotify[hbDelSkinName] = nil
        Healbot_Config_Skins.NotifyChan[hbDelSkinName] = nil
        Healbot_Config_Skins.NotifyHealMsg[hbDelSkinName] = nil
        Healbot_Config_Skins.NotifyOtherMsg[hbDelSkinName] = nil
        Healbot_Config_Skins.CastNotifyResOnly[hbDelSkinName] = nil
        Healbot_Config_Skins.Panel_Anchor[hbDelSkinName] = nil
        HealBot_Config.SkinDefault[hbDelSkinName] = nil
        Healbot_Config_Skins.ShowIncHeals[hbDelSkinName] = nil
        Healbot_Config_Skins.incHealDur[hbDelSkinName] = nil
        Healbot_Config_Skins.ExtraIncGroup[hbDelSkinName] = nil
        Healbot_Config_Skins.ActionLocked[hbDelSkinName] = nil
        Healbot_Config_Skins.SubSortIncGroup[hbDelSkinName] = nil
        Healbot_Config_Skins.SubSortIncPet[hbDelSkinName] = nil
        Healbot_Config_Skins.SubSortIncVehicle[hbDelSkinName] = nil
        Healbot_Config_Skins.SubSortIncTanks[hbDelSkinName] = nil
        Healbot_Config_Skins.SubSortIncMyTargets[hbDelSkinName] = nil
        Healbot_Config_Skins.AutoClose[hbDelSkinName] = nil
        Healbot_Config_Skins.PanelSounds[hbDelSkinName] = nil
        table.remove(HealBot_Skins,Healbot_Config_Skins.Skin_ID)
        Healbot_Config_Skins.Skin_ID = 1;
        Healbot_Config_Skins.Skins = HealBot_Skins;  
        Healbot_Config_Skins.Current_Skin = HEALBOT_SKINS_STD;
        HealBot_Options_SetSkins();
    end
end
        
function HealBot_Options_ShowHeaders_OnClick(self)
    Healbot_Config_Skins.ShowHeader[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_BarNumColsSText:SetText(HealBot_Options_SetNoColsText() .. ": " .. Healbot_Config_Skins.numcols[Healbot_Config_Skins.Current_Skin]);
    HealBot_setOptions_Timer(150)
end
 
function HealBot_Options_PlaySound_OnClick(self)
    PlaySoundFile(LSM:Fetch('sound',sounds[HealBot_Options_WarningSound:GetValue()]));    
end
    
function HealBot_Options_WarningSound_OnValueChanged(self)
    if self:GetValue() > 0 and sounds then
        HealBot_Config.SoundDebuffPlay = sounds[self:GetValue()];
        getglobal(self:GetName().."Text"):SetText(self.text .. " ".. self:GetValue()..": " ..sounds[self:GetValue()]);
    else
        getglobal(self:GetName().."Text"):SetText(self.text);
    end
    if not DoInitTab4 and not updatingMedia then
        PlaySoundFile(LSM:Fetch('sound',HealBot_Config.SoundDebuffPlay));
    end
    updatingMedia=false;
end

function HealBot_Options_BarTextureS_OnValueChanged(self)
    if self:GetValue() > 0 and textures then
        Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin] = textures[self:GetValue()];
        getglobal(self:GetName().."Text"):SetText(self.text .. " "..self:GetValue()..": " .. textures[self:GetValue()]);
    else
        getglobal(self:GetName().."Text"):SetText(self.text);
    end    
    if not updatingMedia then
        HealBot_setOptions_Timer(150)
        HealBot_setOptions_Timer(160)
    end
    updatingMedia=false;
end

function HealBot_BarButtonIconScale_OnValueChanged(self)
    val=self:GetValue();
    val=val/10;
    Healbot_Config_Skins.IconScale[Healbot_Config_Skins.Current_Skin] = val;
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. val);
    HealBot_setOptions_Timer(150)
end

function HealBot_BarButtonIconTextScale_OnValueChanged(self)
    val=self:GetValue();
    val=val/10;
    Healbot_Config_Skins.IconTextScale[Healbot_Config_Skins.Current_Skin] = val;
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. val);
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_HeadTextureS_OnValueChanged(self)
    if self:GetValue() > 0 and textures then
        Healbot_Config_Skins.headtexture[Healbot_Config_Skins.Current_Skin] = textures[self:GetValue()];
        getglobal(self:GetName().."Text"):SetText(self.text .. " " .. self:GetValue()..": " .. textures[self:GetValue()]);
    else
        getglobal(self:GetName().."Text"):SetText(self.text);
    end  
    if not updatingMedia then
        if Healbot_Config_Skins.ShowHeader[Healbot_Config_Skins.Current_Skin]==1 then
            HealBot_setOptions_Timer(150)
        end
        HealBot_setOptions_Timer(160)
    end
    updatingMedia=false;
end

function HealBot_Options_HeadFontNameS_OnValueChanged(self)
    if self:GetValue() > 0 and fonts then
        Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin] = fonts[self:GetValue()];
        getglobal(self:GetName().."Text"):SetText(self.text .. " ".. self:GetValue()..": " ..fonts[self:GetValue()]);
    else
        getglobal(self:GetName().."Text"):SetText(self.text);
    end   
    if not updatingMedia and  self:GetValue() > 0 then
        HealBot_setOptions_Timer(150)
    end
    updatingMedia=false;
    HealBot_setOptions_Timer(160)
end

function HealBot_Options_HeadFontHeightS_OnValueChanged(self)
    Healbot_Config_Skins.headtextheight[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_setOptions_Timer(150)
    HealBot_setOptions_Timer(160)
end

function HealBot_Options_BarHeightS_OnValueChanged(self)
    Healbot_Config_Skins.bheight[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_BarWidthS_OnValueChanged(self)
    Healbot_Config_Skins.bwidth[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_BarNumColsS_OnValueChanged(self)
    Healbot_Config_Skins.numcols[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(HealBot_Options_SetNoColsText() .. ": " .. self:GetValue());
    Delay_RecalcParty=2
end

function HealBot_Options_BarBRSpaceS_OnValueChanged(self)
    Healbot_Config_Skins.brspace[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_BarBCSpaceS_OnValueChanged(self)
    Healbot_Config_Skins.bcspace[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_incHealsDur_OnValueChanged(self, healType)
    Healbot_Config_Skins.incHealDur[Healbot_Config_Skins.Current_Skin][healType] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
end

function HealBot_Options_FontName_OnValueChanged(self)
    if self:GetValue() > 0 and fonts then
        Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin] = fonts[self:GetValue()];
        getglobal(self:GetName().."Text"):SetText(self.text .. " ".. self:GetValue()..": " ..fonts[self:GetValue()]);
    else
        getglobal(self:GetName().."Text"):SetText(self.text);
    end       
    if not updatingMedia and  self:GetValue() > 0 then
        HealBot_setOptions_Timer(150)
    end
    updatingMedia=false;
    HealBot_setOptions_Timer(160)
end

function HealBot_Options_FontHeight_OnValueChanged(self)
    Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_setOptions_Timer(150)
    HealBot_setOptions_Timer(160)
end

function HealBot_Options_AggroBarSize_OnValueChanged(self)
    Healbot_Config_Skins.AggroBarSize[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_Bar2Size_OnValueChanged(self)
    Healbot_Config_Skins.bar2size[Healbot_Config_Skins.Current_Skin] = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_setOptions_Timer(150)
    if Healbot_Config_Skins.bar2size[Healbot_Config_Skins.Current_Skin]==0 then
        HealBot_UnRegister_Mana()
    else
        HealBot_Register_Mana()
    end
end

local HealBot_Alignment = { [1]=HEALBOT_OPTIONS_BUTTONLEFT, [2]=HEALBOT_OPTIONS_BUTTONMIDDLE, [3]=HEALBOT_OPTIONS_BUTTONRIGHT }
function HealBot_Options_TextAlign_OnValueChanged(self)
    getglobal(self:GetName().."Text"):SetText(self.text .. " ".. self:GetValue()..": " ..HealBot_Alignment[self:GetValue()]);
    if Healbot_Config_Skins.TextAlignment[Healbot_Config_Skins.Current_Skin] ~= self:GetValue() then
        Healbot_Config_Skins.TextAlignment[Healbot_Config_Skins.Current_Skin] = self:GetValue();
        StaticPopup_Show ("HEALBOT_OPTIONS_RELOADUI");
    end
end

function HealBot_Options_ActionAlpha_OnValueChanged(self)
    Healbot_Config_Skins.backcola[Healbot_Config_Skins.Current_Skin] = HealBot_Options_Pct_OnValueChanged(self);
end

function HealBot_Options_BarAlpha_OnValueChanged(self)
    Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin] = HealBot_Options_Pct_OnValueChanged(self);
    HealBot_setOptions_Timer(80)
end

function HealBot_Options_HeadWidthS_OnValueChanged(self)
    Healbot_Config_Skins.headwidth[Healbot_Config_Skins.Current_Skin] = HealBot_Options_Pct_OnValueChanged(self);
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_HeadHightS_OnValueChanged(self)
    Healbot_Config_Skins.headhight[Healbot_Config_Skins.Current_Skin] = HealBot_Options_Pct_OnValueChanged(self);
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_BarAlphaInHeal_OnValueChanged(self)
    Healbot_Config_Skins.BarcolaInHeal[Healbot_Config_Skins.Current_Skin] = HealBot_Options_Pct_OnValueChanged(self);
    HealBot_setOptions_Timer(80)
end

function HealBot_Options_BarAlphaDis_OnValueChanged(self)
    Healbot_Config_Skins.bardisa[Healbot_Config_Skins.Current_Skin] = HealBot_Options_Pct_OnValueChanged(self);
    HealBot_setOptions_Timer(80)
end

function HealBot_Options_BarAlphaEor_OnValueChanged(self)
    Healbot_Config_Skins.bareora[Healbot_Config_Skins.Current_Skin] = HealBot_Options_Pct_OnValueChanged(self);
    HealBot_setOptions_Timer(80)
end

function HealBot_Options_TTAlpha_OnValueChanged(self)
    HealBot_Config.ttalpha = HealBot_Options_Pct_OnValueChanged(self);
    HealBot_Tooltip:SetBackdropColor(0,0,0,HealBot_Config.ttalpha)
end

local HealBot_ColourObjWaiting=nil
function HealBot_SkinColorpick_OnClick(SkinType)
    HealBot_ColourObjWaiting=SkinType;

    if SkinType=="En" then
        HealBot_UseColourPick(Healbot_Config_Skins.btextenabledcolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextenabledcolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextenabledcolb[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextenabledcola[Healbot_Config_Skins.Current_Skin]);
    elseif SkinType=="Dis" then
        HealBot_UseColourPick(Healbot_Config_Skins.btextdisbledcolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextdisbledcolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextdisbledcolb[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextdisbledcola[Healbot_Config_Skins.Current_Skin])
    elseif SkinType=="Debuff" then
        HealBot_UseColourPick(Healbot_Config_Skins.btextcursecolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextcursecolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextcursecolb[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.btextcursecola[Healbot_Config_Skins.Current_Skin])
    elseif SkinType=="Back" then
        HealBot_UseColourPick(Healbot_Config_Skins.backcolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.backcolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.backcolb[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.backcola[Healbot_Config_Skins.Current_Skin])
    elseif SkinType=="Bor" then
        HealBot_UseColourPick(Healbot_Config_Skins.borcolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.borcolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.borcolb[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.borcola[Healbot_Config_Skins.Current_Skin])
    elseif SkinType=="HeadB" then
        HealBot_UseColourPick(Healbot_Config_Skins.headbarcolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.headbarcolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.headbarcolb[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.headbarcola[Healbot_Config_Skins.Current_Skin])
    elseif SkinType=="HeadT" then
        HealBot_UseColourPick(Healbot_Config_Skins.headtxtcolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.headtxtcolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.headtxtcolb[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.headtxtcola[Healbot_Config_Skins.Current_Skin])
    elseif SkinType=="CustomBar" then
        HealBot_UseColourPick(Healbot_Config_Skins.barcolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.barcolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.barcolb[Healbot_Config_Skins.Current_Skin])
    elseif SkinType=="HighlightBar" then
        HealBot_UseColourPick(Healbot_Config_Skins.highcolr[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.highcolg[Healbot_Config_Skins.Current_Skin],
                              Healbot_Config_Skins.highcolb[Healbot_Config_Skins.Current_Skin])
    end
end

local buffbarcolrClass=nil
local buffbarcolgClass=nil
local buffbarcolbClass=nil
function HealBot_BuffColorpick_OnClick(BuffID,id)
    HealBot_ColourObjWaiting=BuffID;
    buffbarcolrClass = HealBot_Config.HealBotBuffColR
    buffbarcolgClass = HealBot_Config.HealBotBuffColG
    buffbarcolbClass = HealBot_Config.HealBotBuffColB
    HealBot_UseColourPick(buffbarcolrClass[id],
                          buffbarcolgClass[id],
                          buffbarcolbClass[id]);
end

local btextheight=nil
local barScale=nil
function HealBot_SetSkinColours()
    btextheight=Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin] or 10;
  
    HealBot_EnTextColorpick:SetStatusBarColor(0,1,0,Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_EnTextColorpickin:SetStatusBarColor(0,1,0,Healbot_Config_Skins.BarcolaInHeal[Healbot_Config_Skins.Current_Skin]);
    HealBot_DisTextColorpick:SetStatusBarColor(0,1,0,Healbot_Config_Skins.bardisa[Healbot_Config_Skins.Current_Skin]); 
    HealBot_Options_SetBarsTextColour()
    HealBot_HeadTextColorpickt:SetTextColor(
        Healbot_Config_Skins.headtxtcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headtxtcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headtxtcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headtxtcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_BackgroundColorpick:SetStatusBarColor(
        Healbot_Config_Skins.backcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.backcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.backcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.backcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_BorderColorpick:SetStatusBarColor(
        Healbot_Config_Skins.borcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_HeadBarColorpick:SetStatusBarColor(
        Healbot_Config_Skins.headbarcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcola[Healbot_Config_Skins.Current_Skin])
    HealBot_HeadTextColorpick:SetStatusBarColor(
        Healbot_Config_Skins.headbarcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcola[Healbot_Config_Skins.Current_Skin])
    HealBot_BarCustomColour:SetStatusBarColor(
        Healbot_Config_Skins.barcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.barcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.barcolb[Healbot_Config_Skins.Current_Skin]);
    HealBot_HighlightActiveBarColour:SetStatusBarColor(
        Healbot_Config_Skins.highcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.highcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.highcolb[Healbot_Config_Skins.Current_Skin]);
    HealBot_Action:SetBackdropColor(
        Healbot_Config_Skins.backcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.backcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.backcolb[Healbot_Config_Skins.Current_Skin], 
        Healbot_Config_Skins.backcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_Action:SetBackdropBorderColor(
        Healbot_Config_Skins.borcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcola[Healbot_Config_Skins.Current_Skin]);
    

   
end

local sbR, sbG, sbB = nil, nil, nil
function HealBot_Options_SetBarsTextColour()
    if Healbot_Config_Skins.SetClassColourText[Healbot_Config_Skins.Current_Skin]==0 then
        HealBot_EnTextColorpickt:SetTextColor(
            Healbot_Config_Skins.btextenabledcolr[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextenabledcolg[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextenabledcolb[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextenabledcola[Healbot_Config_Skins.Current_Skin]);
        HealBot_DisTextColorpickt:SetTextColor(
            Healbot_Config_Skins.btextdisbledcolr[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextdisbledcolg[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextdisbledcolb[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextdisbledcola[Healbot_Config_Skins.Current_Skin]);
        HealBot_DebTextColorpickt:SetTextColor(
            Healbot_Config_Skins.btextcursecolr[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextcursecolg[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextcursecolb[Healbot_Config_Skins.Current_Skin],
            Healbot_Config_Skins.btextcursecola[Healbot_Config_Skins.Current_Skin]);
    else
        sbR, sbG, sbB = HealBot_Action_ClassColour(HealBot_PlayerGUID)
        HealBot_EnTextColorpickt:SetTextColor(
            sbR,
            sbG,
            sbB,
            Healbot_Config_Skins.btextenabledcola[Healbot_Config_Skins.Current_Skin]);
        HealBot_DisTextColorpickt:SetTextColor(
            sbR,
            sbG,
            sbB,
            Healbot_Config_Skins.btextdisbledcola[Healbot_Config_Skins.Current_Skin]);
        HealBot_DebTextColorpickt:SetTextColor(
            sbR,
            sbG,
            sbB,
            Healbot_Config_Skins.btextcursecola[Healbot_Config_Skins.Current_Skin]);
    end
end

function HealBot_Options_AlertLevel_OnValueChanged(self)
    Healbot_Config_Skins.AlertLevel[Healbot_Config_Skins.Current_Skin] = HealBot_Options_Pct_OnValueChanged(self);
    HealBot_setOptions_Timer(80)
end

function HealBot_Options_RangeCheckFreq_OnValueChanged(self)
    val=self:GetValue();
    val=val/10;
    HealBot_Config.RangeCheckFreq = val;
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. val .." sec");
end

function HealBot_Options_BuffTimer_OnValueChanged(self,bufftype)
    val=self:GetValue();
    if bufftype=="SHORT" then
        HealBot_Config.ShortBuffTimer = val;
    else
        HealBot_Config.LongBuffTimer = val;
    end
    mins,secs=HealBot_Tooltip_ReturnMinsSecs(val)
    if mins==0 then
        getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. secs .." secs");
    else
        val=val/60;
        getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. mins ..":".. secs .." mins");
    end
    HealBot_setOptions_Timer(10)
end

function HealBot_Options_BarFreq_OnValueChanged(self)
    val=self:GetValue();
    val=val/10;
    Healbot_Config_Skins.BarFreq[Healbot_Config_Skins.Current_Skin] = val;
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. val);
end

function HealBot_Options_NumTestBars_OnValueChanged(self)
    HealBot_Config.noTestBars = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    HealBot_Panel_SetNumBars(HealBot_Config.noTestBars)
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_NumTestTanks_OnValueChanged(self)
    HealBot_Config.noTestTanks = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_NumTestMyTargets_OnValueChanged(self)
    HealBot_Config.noTestTargets = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_NumTestPets_OnValueChanged(self)
    HealBot_Config.noTestPets = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_AutoShow_OnClick(self)
    Healbot_Config_Skins.AutoClose[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(80)
    if Healbot_Config_Skins.AutoClose[Healbot_Config_Skins.Current_Skin]==0 and HealBot_Config.DisableHealBot==0 then
        ShowUIPanel(HealBot_Action)
    else
        HealBot_Action_Refresh(HealBot_PlayerGUID)
    end
end

function HealBot_Options_IgnoreDebuffsClass_OnClick(self)
    HealBot_Config.IgnoreClassDebuffs = self:GetChecked() or 0;
end

function HealBot_Options_IgnoreDebuffsNoHarm_OnClick(self)
    HealBot_Config.IgnoreNonHarmfulDebuffs = self:GetChecked() or 0;
end

function HealBot_Options_IgnoreDebuffsDuration_OnClick(self)
    HealBot_Config.IgnoreFastDurDebuffs = self:GetChecked() or 0;
end

function HealBot_Options_IgnoreDebuffsDurationSecs_OnValueChanged(self)
    HealBot_Config.IgnoreFastDurDebuffsSecs = self:GetValue();
    getglobal(self:GetName().."Text"):SetText(self.text .. ": " .. self:GetValue());
end

function HealBot_Options_IgnoreDebuffsMovement_OnClick(self)
    HealBot_Config.IgnoreMovementDebuffs = self:GetChecked() or 0;
end

function HealBot_Options_CastNotifyResOnly_OnClick(self)
    Healbot_Config_Skins.CastNotifyResOnly[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_Options_BarNumGroupPerCol_OnClick(self)
    Healbot_Config_Skins.GroupsPerCol[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_BarNumColsSText:SetText(HealBot_Options_SetNoColsText() .. ": " .. Healbot_Config_Skins.numcols[Healbot_Config_Skins.Current_Skin]);
    Delay_RecalcParty=2
end

function HealBot_Options_ShowTooltipMyBuffs_OnClick(self)
    HealBot_Config.Tooltip_ShowMyBuffs = self:GetChecked() or 0;
end

function HealBot_Options_ShowClassOnBar_OnClick(self)
    if Healbot_Config_Skins.ShowRaidIcon[Healbot_Config_Skins.Current_Skin]==1 then HealBot_RaidTargetToggle(nil) end
    Healbot_Config_Skins.ShowClassOnBar[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(150)
    if Healbot_Config_Skins.ShowClassOnBar[Healbot_Config_Skins.Current_Skin]==0 then
        HealBot_Options_ShowClassOnBarType1:Disable();
        HealBot_Options_ShowClassOnBarType2:Disable();
    else
        HealBot_Options_ShowClassOnBarType1:Enable();
        HealBot_Options_ShowClassOnBarType2:Enable();
    end
end

function HealBot_Options_ShowNameOnBar_OnClick(self)
    Healbot_Config_Skins.ShowNameOnBar[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(80)
end

function HealBot_BarHealthIncHeal_OnClick(self)
    Healbot_Config_Skins.BarHealthIncHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(80)
end

function HealBot_BarHealthSepHeal_OnClick(self)
    Healbot_Config_Skins.BarHealthSepHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(80)
end

function HealBot_Options_PartyFrames_OnClick(self)
    Healbot_Config_Skins.HidePartyFrames[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(180)
end

function HealBot_Options_AggroTrack_OnClick(self)
    Healbot_Config_Skins.ShowAggro[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Healbot_Config_Skins.ShowAggro[Healbot_Config_Skins.Current_Skin]==0 then
        HealBot_UnRegister_Aggro()
        HealBot_ClearAggro()
    else
        HealBot_Register_Aggro()
    end
    HealBot_setOptions_Timer(150)
    HealBot_setOptions_Timer(80)
    HealBot_Action_Set_Timers()
end

function HealBot_Options_HighlightActiveBar_OnClick(self)
    Healbot_Config_Skins.HighLightActiveBar[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(150)
end

function HealBot_Options_UseFluidBars_OnClick(self)
    Healbot_Config_Skins.UseFluidBars[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(80)
    HealBot_Action_Set_Timers()
end

function HealBot_Options_AggroBar_OnClick(self)
    Healbot_Config_Skins.ShowAggroBars[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(150)
    HealBot_setOptions_Timer(80)
    HealBot_Action_Set_Timers()
end

function HealBot_Options_AggroTxt_OnClick(self)
    Healbot_Config_Skins.ShowAggroText[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(80)
end

function HealBot_Options_EnableLibQuickHealth_OnClick(self)
    HealBot_Config.EnLibQuickHealth = self:GetChecked() or 0;
    StaticPopup_Show ("HEALBOT_OPTIONS_RELOADUI");
end

function HealBot_Options_CPUProfiler_OnClick(self)
    CPUProfiler = self:GetChecked() or 0;
    SetCVar("scriptProfile", CPUProfiler)
    StaticPopup_Show ("HEALBOT_OPTIONS_RELOADUI");
end

function HealBot_Options_PlayerTargetFrames_OnClick(self)
    Healbot_Config_Skins.HidePlayerTarget[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(180)
end

function HealBot_Options_MonitorBuffs_OnClick(self)
    HealBot_Config.BuffWatch = self:GetChecked() or 0;
    if HealBot_Config.BuffWatch==0 then
        HealBot_Options_MonitorBuffsInCombat:Disable();
        HealBot_ClearAllBuffs()
        for x,_ in pairs(HealBot_UnitBuff) do
            HealBot_UnitBuff[x]=nil;
        end
    else
        HealBot_Options_MonitorBuffsInCombat:Enable();
        HealBot_setOptions_Timer(40)
    end
end

function HealBot_Options_MonitorDebuffs_OnClick(self)
    HealBot_Config.DebuffWatch = self:GetChecked() or 0;
    if HealBot_Config.DebuffWatch==0 then
        HealBot_Options_MonitorDebuffsInCombat:Disable();
        HealBot_ClearAllDebuffs()
        for x,_ in pairs(HealBot_UnitDebuff) do
            HealBot_UnitDebuff[x]=nil;
        end
    else
        HealBot_Options_MonitorDebuffsInCombat:Enable();
        HealBot_setOptions_Timer(50)
    end
end

function HealBot_Options_MonitorBuffsInCombat_OnClick(self)
    HealBot_Config.BuffWatchInCombat = self:GetChecked() or 0;
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_MonitorDebuffsInCombat_OnClick(self)
    HealBot_Config.DebuffWatchInCombat = self:GetChecked() or 0;
    HealBot_setOptions_Timer(50)
end

function HealBot_Options_CDCCol_ShowOnHealthBar_OnClick(self)
    HealBot_Config.CDCshownHB = self:GetChecked() or 0;
end

function HealBot_Options_CDCCol_ShowOnAggroBar_OnClick(self)
    HealBot_Config.CDCshownAB = self:GetChecked() or 0;
    if HealBot_Config.CDCshownAB==0 then
        HealBot_Action_ClearUnitDebuffStatus()
    end
end

function HealBot_Options_PanelSounds_OnClick(self)
    Healbot_Config_Skins.PanelSounds[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_Options_ActionLocked_OnClick(self)
    Healbot_Config_Skins.ActionLocked[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_Options_VisibleRange_OnClick(self)
    Healbot_Config_Skins.NotVisibleDisable[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Action_ResetUnitStatus()
end

local curval = 0
function HealBot_Options_DisableHealBot_OnClick(self)
    curval = self:GetChecked() or 0;
    HealBot_Options_ToggleHealBot(curval)
end

function HealBot_Options_ToggleHealBot(checkval)
    HealBot_Config.DisableHealBot=checkval
    HealBot_Options_Timer1 = 0.1
    HealBot_setOptions_Timer(500+checkval)
end

function HealBot_Options_GroupHeals_OnClick(self)
    Healbot_Config_Skins.GroupHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_TankHeals_OnClick(self)
    Healbot_Config_Skins.TankHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_SelfPet_OnClick(self)
    Healbot_Config_Skins.SelfPet[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_EmergencyHeals_OnClick(self)
    Healbot_Config_Skins.EmergencyHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_SelfHeals_OnClick(self)
    Healbot_Config_Skins.SelfHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_PetHeals_OnClick(self)
    Healbot_Config_Skins.PetHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_FocusBar_OnClick(self)
    Healbot_Config_Skins.SetFocusBar[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_MyTargetsList_OnClick(self)
    Healbot_Config_Skins.ShowMyTargetsList[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_VehicleHeals_OnClick(self)
    Healbot_Config_Skins.VehicleHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_TargetBar_OnClick(self)
    Healbot_Config_Skins.TargetHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty<2 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_TargetIncSelf_OnClick(self)
    Healbot_Config_Skins.TargetIncSelf[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_TargetIncGroup_OnClick(self)
    Healbot_Config_Skins.TargetIncGroup[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_TargetIncRaid_OnClick(self)
    Healbot_Config_Skins.TargetIncRaid[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_TargetIncPet_OnClick(self)
    Healbot_Config_Skins.TargetIncPet[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_SubSortIncGroup_OnClick(self)
    Healbot_Config_Skins.SubSortIncGroup[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_SubSortIncPet_OnClick(self)
    Healbot_Config_Skins.SubSortIncPet[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_SubSortIncVehicle_OnClick(self)
    Healbot_Config_Skins.SubSortIncVehicle[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_SubSortIncTanks_OnClick(self)
    Healbot_Config_Skins.SubSortIncTanks[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_SubSortIncMyTargets_OnClick(self)
    Healbot_Config_Skins.SubSortIncMyTargets[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_TargetMode_OnClick(self)
    Healbot_Config_Skins.TargetBarNormalMode[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_SetResetFlag("SOFT")
end

function HealBot_Options_EFGroup_OnClick(self,id)
    if self:GetChecked() then
        Healbot_Config_Skins.ExtraIncGroup[Healbot_Config_Skins.Current_Skin][id] = true;
    else
        Healbot_Config_Skins.ExtraIncGroup[Healbot_Config_Skins.Current_Skin][id] = false;
    end
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_EFClass_OnClick(self)
    if HealBot_Config.EmergencyFClass==1 then
        HealBot_Config.EmergIncMelee[HEALBOT_DRUID] = HealBot_Options_EFClassDruid:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_HUNTER] = HealBot_Options_EFClassHunter:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_MAGE] = HealBot_Options_EFClassMage:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_PALADIN] = HealBot_Options_EFClassPaladin:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_PRIEST] = HealBot_Options_EFClassPriest:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_ROGUE] = HealBot_Options_EFClassRogue:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_SHAMAN] = HealBot_Options_EFClassShaman:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_WARLOCK] = HealBot_Options_EFClassWarlock:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_WARRIOR] = HealBot_Options_EFClassWarrior:GetChecked() or 0;
        HealBot_Config.EmergIncMelee[HEALBOT_DEATHKNIGHT] = HealBot_Options_EFClassDeathKnight:GetChecked() or 0;
    elseif HealBot_Config.EmergencyFClass==2 then
        HealBot_Config.EmergIncRange[HEALBOT_DRUID] = HealBot_Options_EFClassDruid:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_HUNTER] = HealBot_Options_EFClassHunter:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_MAGE] = HealBot_Options_EFClassMage:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_PALADIN] = HealBot_Options_EFClassPaladin:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_PRIEST] = HealBot_Options_EFClassPriest:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_ROGUE] = HealBot_Options_EFClassRogue:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_SHAMAN] = HealBot_Options_EFClassShaman:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_WARLOCK] = HealBot_Options_EFClassWarlock:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_WARRIOR] = HealBot_Options_EFClassWarrior:GetChecked() or 0;
        HealBot_Config.EmergIncRange[HEALBOT_DEATHKNIGHT] = HealBot_Options_EFClassDeathKnight:GetChecked() or 0;
    elseif HealBot_Config.EmergencyFClass==3 then
        HealBot_Config.EmergIncHealers[HEALBOT_DRUID] = HealBot_Options_EFClassDruid:GetChecked() or 0;
        HealBot_Config.EmergIncHealers[HEALBOT_HUNTER] = HealBot_Options_EFClassHunter:GetChecked() or 0;
        HealBot_Config.EmergIncHealers[HEALBOT_MAGE] = HealBot_Options_EFClassMage:GetChecked() or 0;
        HealBot_Config.EmergIncHealers[HEALBOT_PALADIN] = HealBot_Options_EFClassPaladin:GetChecked() or 0;
        HealBot_Config.EmergIncHealers[HEALBOT_PRIEST] = HealBot_Options_EFClassPriest:GetChecked() or 0;
        HealBot_Config.EmergIncHealers[HEALBOT_ROGUE] = HealBot_Options_EFClassRogue:GetChecked() or 0;
        HealBot_Config.EmergIncHealers[HEALBOT_SHAMAN] = HealBot_Options_EFClassShaman:GetChecked() or 0;
        HealBot_Config.EmergIncHealers[HEALBOT_WARLOCK] = HealBot_Options_EFClassWarlock:GetChecked() or 0;
        HealBot_Config.EmergIncHealers[HEALBOT_WARRIOR] = HealBot_Options_EFClassWarrior:GetChecked() or 0
        HealBot_Config.EmergIncHealers[HEALBOT_DEATHKNIGHT] = HealBot_Options_EFClassDeathKnight:GetChecked() or 0;
    elseif HealBot_Config.EmergencyFClass==4 then
        HealBot_Config.EmergIncCustom[HEALBOT_DRUID] = HealBot_Options_EFClassDruid:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_HUNTER] = HealBot_Options_EFClassHunter:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_MAGE] = HealBot_Options_EFClassMage:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_PALADIN] = HealBot_Options_EFClassPaladin:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_PRIEST] = HealBot_Options_EFClassPriest:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_ROGUE] = HealBot_Options_EFClassRogue:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_SHAMAN] = HealBot_Options_EFClassShaman:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_WARLOCK] = HealBot_Options_EFClassWarlock:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_WARRIOR] = HealBot_Options_EFClassWarrior:GetChecked() or 0;
        HealBot_Config.EmergIncCustom[HEALBOT_DEATHKNIGHT] = HealBot_Options_EFClassDeathKnight:GetChecked() or 0;
    end
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

local hbCastNotifyPrev=1
function HealBot_Options_CastNotify_OnClick(self,id)
    if id>0 and id~=hbCastNotifyPrev then
        getglobal("HealBot_Options_CastNotify"..hbCastNotifyPrev):SetChecked(nil);
        hbCastNotifyPrev=id
    end
    Healbot_Config_Skins.CastNotify[Healbot_Config_Skins.Current_Skin] = id;
    if Healbot_Config_Skins.CastNotify[Healbot_Config_Skins.Current_Skin]>0 then
        getglobal("HealBot_Options_CastNotify"..Healbot_Config_Skins.CastNotify[Healbot_Config_Skins.Current_Skin]):SetChecked(1);
    end
end

function HealBot_Options_HideOptions_OnClick(self)
    HealBot_Config.HideOptions = self:GetChecked() or 0;
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

function HealBot_Options_RightButtonOptions_OnClick(self)
    HealBot_Config.RightButtonOptions = self:GetChecked() or 0;
end

function HealBot_Options_ShowMinimapButton_OnClick(self)
    HealBot_Config.ButtonShown = self:GetChecked() or 0;
    HealBot_MMButton_Init();   
end

function HealBot_Options_ShowTooltip_OnClick(self)
    HealBot_Config.ShowTooltip = self:GetChecked() or 0;
end

function HealBot_Options_ShowTooltipUpdate_OnClick(self)
    HealBot_Config.TooltipUpdate = self:GetChecked() or 0;
end

function HealBot_Options_HideTooltipInCombat_OnClick(self)
    HealBot_Config.DisableToolTipInCombat = self:GetChecked() or 0;
end

function HealBot_Options_ShowTooltipTarget_OnClick(self)
    HealBot_Config.Tooltip_ShowTarget = self:GetChecked() or 0;
end

function HealBot_Options_ShowTooltipSpellDetail_OnClick(self)
    HealBot_Config.Tooltip_ShowSpellDetail = self:GetChecked() or 0;
end

function HealBot_Options_ShowTooltipInstant_OnClick(self)
    HealBot_Config.Tooltip_Recommend = self:GetChecked() or 0;
end

function HealBot_Options_ShowTooltipPreDefined_OnClick(self)
    HealBot_Config.Tooltip_PreDefined = self:GetChecked() or 0;
end

function HealBot_Options_ShowIncomingHeals_OnClick(self)
    Healbot_Config_Skins.ShowIncHeals[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_Options_ShowDebuffWarning_OnClick(self)
    HealBot_Config.ShowDebuffWarning = self:GetChecked() or 0;
end

function HealBot_Options_ShowDebuffIcon_OnClick(self)
    Healbot_Config_Skins.ShowDebuffIcon[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_Options_SoundDebuffWarning_OnClick(self)
    HealBot_Config.SoundDebuffWarning = self:GetChecked() or 0;
    if HealBot_Config.SoundDebuffWarning==0 then
        HealBot_Options_WarningSound:Disable();
        HealBot_Options_PlaySound:Disable();
    else
        HealBot_Options_WarningSound:Enable();
        HealBot_Options_PlaySound:Enable();
      end
end

function HealBot_Options_BarInClassColour_OnClick(self)
    Healbot_Config_Skins.SetBarClassColour[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Healbot_Config_Skins.SetBarClassColour[Healbot_Config_Skins.Current_Skin]==0 then
        HealBot_Options_BarClassCustomColour1:Disable();
        HealBot_Options_BarClassCustomColour2:Disable();
    else
        HealBot_Options_BarClassCustomColour1:Enable();
        HealBot_Options_BarClassCustomColour2:Enable();
    end
    HealBot_Panel_resetTestCols()
    HealBot_Action_ResetUnitStatus()
end

local ClassCustomPrev=-1
function HealBot_Options_BarClassCustom_OnClick(self,id)
    if ClassCustomPrev==-1 then
        if Healbot_Config_Skins.SetBarCustomColour[Healbot_Config_Skins.Current_Skin]==1 then
            ClassCustomPrev=1
        else
            ClassCustomPrev=2
        end
    end
    getglobal("HealBot_Options_BarClassCustomColour"..ClassCustomPrev):SetChecked(nil);
    Healbot_Config_Skins.SetBarCustomColour[Healbot_Config_Skins.Current_Skin] = id;
    if Healbot_Config_Skins.SetBarCustomColour[Healbot_Config_Skins.Current_Skin]>0 then
        getglobal("HealBot_Options_BarClassCustomColour"..Healbot_Config_Skins.SetBarCustomColour[Healbot_Config_Skins.Current_Skin]):SetChecked(1);
        ClassCustomPrev=id
    end
    HealBot_Action_ResetUnitStatus()
end

function HealBot_Options_NumberTextLines_OnClick(self)
    Healbot_Config_Skins.DoubleText[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(80)
end

function HealBot_Options_BarTextInClassColour_OnClick(self)
    Healbot_Config_Skins.SetClassColourText[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Action_ResetUnitStatus()
    HealBot_Options_SetBarsTextColour()
    HealBot_Panel_resetTestCols()
end

function HealBot_Options_BarButtonShowHoT_OnClick(self)
    Healbot_Config_Skins.ShowHoTicons[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_Options_BarButtonShowRaidIcon_OnClick(self)
    Healbot_Config_Skins.ShowRaidIcon[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_BarButtonShowRaidIconStar_OnClick(self)
    Healbot_Config_Skins.ShowRaidIconStar[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_BarButtonShowRaidIconCircle_OnClick(self)
    Healbot_Config_Skins.ShowRaidIconCircle[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_BarButtonShowRaidIconDiamond_OnClick(self)
    Healbot_Config_Skins.ShowRaidIconDiamond[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_BarButtonShowRaidIconTriangle_OnClick(self)
    Healbot_Config_Skins.ShowRaidIconTriangle[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_BarButtonShowRaidIconMoon_OnClick(self)
    Healbot_Config_Skins.ShowRaidIconMoon[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_BarButtonShowRaidIconSquare_OnClick(self)
    Healbot_Config_Skins.ShowRaidIconSquare[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_BarButtonShowRaidIconCross_OnClick(self)
    Healbot_Config_Skins.ShowRaidIconCross[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_BarButtonShowRaidIconSkull_OnClick(self)
    Healbot_Config_Skins.ShowRaidIconSkull[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_Options_RaidTargetUpdate()
end

function HealBot_Options_RaidTargetUpdate()
    if Healbot_Config_Skins.ShowRaidIcon[Healbot_Config_Skins.Current_Skin]==1 then 
        HealBot_RaidTargetToggle(true) 
    else
        HealBot_RaidTargetToggle(nil) 
    end
end

function HealBot_BarButtonShowHoTTextCount_OnClick(self)
    Healbot_Config_Skins.ShowIconTextCount[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_BarButtonShowHoTTextCountSelfCast_OnClick(self)
    Healbot_Config_Skins.ShowIconTextCountSelfCast[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_BarButtonShowHoTTextDuration_OnClick(self)
    Healbot_Config_Skins.ShowIconTextDuration[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_BarButtonShowHoTTextDurationSelfCast_OnClick(self)
    Healbot_Config_Skins.ShowIconTextDurationSelfCast[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
end

function HealBot_Options_ShowHealthOnBar_OnClick(self)
    Healbot_Config_Skins.ShowHealthOnBar[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    if Healbot_Config_Skins.ShowHealthOnBar[Healbot_Config_Skins.Current_Skin]==0 then
        HealBot_BarHealthType1:Disable();
        HealBot_BarHealthType2:Disable();
        HealBot_BarHealthIncHeal:Disable();
        HealBot_BarHealthSepHeal:Disable();
    else
        HealBot_BarHealthType1:Enable();
        HealBot_BarHealthType2:Enable();
        HealBot_BarHealthIncHeal:Enable();
        HealBot_BarHealthSepHeal:Enable();
    end
    HealBot_setOptions_Timer(80)
end

local BarHealthTypePrev=-1
function HealBot_BarHealthType_OnClick(self,id)
    if BarHealthTypePrev==-1 then
        if Healbot_Config_Skins.BarHealthType[Healbot_Config_Skins.Current_Skin]==1 then
            BarHealthTypePrev=1
        else
            BarHealthTypePrev=2
        end
    end
    getglobal("HealBot_BarHealthType"..BarHealthTypePrev):SetChecked(nil);
    Healbot_Config_Skins.BarHealthType[Healbot_Config_Skins.Current_Skin] = id;
    if Healbot_Config_Skins.BarHealthType[Healbot_Config_Skins.Current_Skin]>0 then
        getglobal("HealBot_BarHealthType"..Healbot_Config_Skins.BarHealthType[Healbot_Config_Skins.Current_Skin]):SetChecked(1);
        BarHealthTypePrev=id
    end
    HealBot_setOptions_Timer(80)
end

local HoTonBarPrev=-1
function HealBot_HoTonBar_OnClick(self,id)
    if HoTonBarPrev==-1 then
        HoTonBarPrev=Healbot_Config_Skins.HoTonBar[Healbot_Config_Skins.Current_Skin] or 1
    end
    getglobal("HealBot_BarButtonShowHoTonBar"..HoTonBarPrev):SetChecked(nil);
    Healbot_Config_Skins.HoTonBar[Healbot_Config_Skins.Current_Skin] = id;
    if Healbot_Config_Skins.HoTonBar[Healbot_Config_Skins.Current_Skin]>0 then
        getglobal("HealBot_BarButtonShowHoTonBar"..Healbot_Config_Skins.HoTonBar[Healbot_Config_Skins.Current_Skin]):SetChecked(1);
        HoTonBarPrev=id
        HealBot_setOptions_Timer(150)
    end
end

local HoTposBarPrev=-1
function HealBot_HoTposBar_OnClick(self,id)
    if HoTposBarPrev==-1 then
        if Healbot_Config_Skins.HoTposBar[Healbot_Config_Skins.Current_Skin]==1 then
            HoTposBarPrev=1
        else
            HoTposBarPrev=2
        end
    end
    getglobal("HealBot_BarButtonShowHoTposBar"..HoTposBarPrev):SetChecked(nil);
    Healbot_Config_Skins.HoTposBar[Healbot_Config_Skins.Current_Skin] = id;
    if Healbot_Config_Skins.HoTposBar[Healbot_Config_Skins.Current_Skin]>0 then
        getglobal("HealBot_BarButtonShowHoTposBar"..Healbot_Config_Skins.HoTposBar[Healbot_Config_Skins.Current_Skin]):SetChecked(1);
        HoTposBarPrev=id
        HealBot_setOptions_Timer(150)
    end
end

function HealBot_HoTx2Bar_OnClick(self)
    Healbot_Config_Skins.HoTx2Bar[Healbot_Config_Skins.Current_Skin] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(150)
end

local ShowClassOnBarTypePrev=-1
function HealBot_Options_ShowClassOnBarType_OnClick(self,id)
    if Healbot_Config_Skins.ShowRaidIcon[Healbot_Config_Skins.Current_Skin]==1 then HealBot_RaidTargetToggle(nil) end
    if ShowClassOnBarTypePrev==-1 then
        if Healbot_Config_Skins.ShowClassType[Healbot_Config_Skins.Current_Skin]==1 then
            ShowClassOnBarTypePrev=1
        else
            ShowClassOnBarTypePrev=2
        end
    end
    getglobal("HealBot_Options_ShowClassOnBarType"..ShowClassOnBarTypePrev):SetChecked(nil);
    Healbot_Config_Skins.ShowClassType[Healbot_Config_Skins.Current_Skin] = id;
    if Healbot_Config_Skins.ShowClassType[Healbot_Config_Skins.Current_Skin]>0 then
        getglobal("HealBot_Options_ShowClassOnBarType"..Healbot_Config_Skins.ShowClassType[Healbot_Config_Skins.Current_Skin]):SetChecked(1);
        ShowClassOnBarTypePrev=id
        HealBot_setOptions_Timer(150)
    end
end

function HealBot_Options_ProtectPvP_OnClick(self)
    HealBot_Config.ProtectPvP = self:GetChecked() or 0;
end

--------------------------------------------------------------------------------

local HealComm = LibStub and LibStub("LibHealComm-4.0", true)
if not HealComm then HEALBOT_OPTIONS_HEALCOMMUSELHC=HEALBOT_OPTIONS_HEALCOMMLHCNOTFOUND end

local HealBot_Options_HealCommMethod_List = {
    HEALBOT_OPTIONS_HEALCOMMUSELHC,
    HEALBOT_OPTIONS_HEALCOMMINTERNAL1,
    HEALBOT_OPTIONS_HEALCOMMINTERNAL2,
    HEALBOT_OPTIONS_HEALCOMMINTERNAL3,
    HEALBOT_OPTIONS_HEALCOMMINTERNAL4,
}

local info={}
function HealBot_Options_HealCommMethod_DropDown()
    for j=1, getn(HealBot_Options_HealCommMethod_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_HealCommMethod_List[j];
        info.func = HealBot_Options_HealCommMethod_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_HealCommMethod_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_HealCommMethod,HealBot_Options_HealCommMethod_DropDown)
end

function HealBot_Options_HealCommMethod_Refresh(onselect)
    if not onselect then HealBot_Options_HealCommMethod_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_HealCommMethod,HealBot_Config.HealCommMethod)
end

function HealBot_Options_HealCommMethod_OnLoad(self)
  --  HealBot_Options_HealCommMethod_Initialize()
    UIDropDownMenu_SetWidth(self,205)
end

function HealBot_Options_HealCommMethod_OnSelect()
    x=HealBot_Config.HealCommMethod
    HealBot_Config.HealCommMethod = this:GetID()
    HealBot_Options_HealCommMethod_Refresh(true)
    HealBot_Options_HealCommMethod_SetWarning()
    if (x>3 and HealBot_Config.HealCommMethod<4) or (x<4 and HealBot_Config.HealCommMethod>3) then
        HealBot_IncHeals_statusChanged()
    end
end

function HealBot_Options_HealCommMethod_SetWarning()
    if HealComm then
        if HealBot_Config.HealCommMethod>1 then
            HealBot_NoLHC_Warning2:Show()
        else
            HealBot_NoLHC_Warning2:Hide()
        end
        HealBot_NoLHC_Warning:Hide()
        HealBot_Options_incHealsDirectDur:Enable()
        HealBot_Options_incHealsChanDur:Enable()
    else
        HealBot_NoLHC_Warning:Show()
        HealBot_NoLHC_Warning2:Hide()
        HealBot_Options_incHealsDirectDur:Disable()
        HealBot_Options_incHealsChanDur:Disable()
    end
end

--------------------------------------------------------------------------------

local HealBot_Options_CastButton_List = {
    HEALBOT_OPTIONS_BUTTONLEFT,
    HEALBOT_OPTIONS_BUTTONMIDDLE,
    HEALBOT_OPTIONS_BUTTONRIGHT,
    HEALBOT_OPTIONS_BUTTON4,
    HEALBOT_OPTIONS_BUTTON5,
    HEALBOT_OPTIONS_BUTTON6,
    HEALBOT_OPTIONS_BUTTON7,
    HEALBOT_OPTIONS_BUTTON8,
    HEALBOT_OPTIONS_BUTTON9,
    HEALBOT_OPTIONS_BUTTON10,
}

function HealBot_Options_CastButton_DropDown()
    for j=1, getn(HealBot_Options_CastButton_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_CastButton_List[j];
        info.func = HealBot_Options_CastButton_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_CastButton_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_CastButton,HealBot_Options_CastButton_DropDown)
end

function HealBot_Options_CastButton_Refresh(onselect)
    if not onselect then HealBot_Options_CastButton_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_CastButton,HealBot_Options_ComboButtons_Button)
end

function HealBot_Options_CastButton_OnLoad(self)
 --   HealBot_Options_CastButton_Initialize()
    UIDropDownMenu_SetWidth(self,128)
end

function HealBot_Options_CastButton_OnSelect()
    HealBot_Options_ComboButtons_Button = this:GetID()
    HealBot_Options_CastButton_Refresh(true)
    HealBot_Options_ComboClass_Text()
end

--------------------------------------------------------------------------------

local HealBot_Options_ButtonCastMethod_List = {
    HEALBOT_OPTIONS_BUTTONCASTPRESSED,
    HEALBOT_OPTIONS_BUTTONCASTRELEASED,
}

function HealBot_Options_ButtonCastMethod_DropDown()
    for j=1, getn(HealBot_Options_ButtonCastMethod_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_ButtonCastMethod_List[j];
        info.func = HealBot_Options_ButtonCastMethod_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_ButtonCastMethod_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_ButtonCastMethod,HealBot_Options_ButtonCastMethod_DropDown)
end

function HealBot_Options_ButtonCastMethod_Refresh(onselect)
    if not onselect then HealBot_Options_ButtonCastMethod_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_ButtonCastMethod,HealBot_Config.ButtonCastMethod)
end

function HealBot_Options_ButtonCastMethod_OnLoad(self)
 --   HealBot_Options_ButtonCastMethod_Initialize()
    UIDropDownMenu_SetWidth(self,145)
end

function HealBot_Options_ButtonCastMethod_OnSelect()
    x=HealBot_Config.ButtonCastMethod
    HealBot_Config.ButtonCastMethod = this:GetID()
    HealBot_Options_ButtonCastMethod_Refresh(true)
    if x~=HealBot_Config.ButtonCastMethod then 
        HealBot_setOptions_Timer(110)
    end
end

--------------------------------------------------------------------------------

local HealBot_Options_EmergencyFClass_List = {
    HEALBOT_CLASSES_MELEE,
    HEALBOT_CLASSES_RANGES,
    HEALBOT_CLASSES_HEALERS,
    HEALBOT_CLASSES_CUSTOM,
}

function HealBot_Options_EmergencyFClass_DropDown()
    for j=1, getn(HealBot_Options_EmergencyFClass_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_EmergencyFClass_List[j];
        info.func = HealBot_Options_EmergencyFClass_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_EmergencyFClass_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_EmergencyFClass,HealBot_Options_EmergencyFClass_DropDown)
end

function HealBot_Options_EmergencyFClass_Refresh(onselect)
    if not onselect then HealBot_Options_EmergencyFClass_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_EmergencyFClass,HealBot_Config.EmergencyFClass)
end

function HealBot_Options_EmergencyFClass_OnLoad(self)
 --   HealBot_Options_EmergencyFClass_Initialize()
    UIDropDownMenu_SetWidth(self,145)
end

function HealBot_Options_EmergencyFClass_OnSelect()
    HealBot_Config.EmergencyFClass = this:GetID()
    HealBot_Options_EmergencyFClass_Refresh(true)
    HealBot_Options_EFClass_Reset()
end

function HealBot_Options_EFClass_Reset()
    if HealBot_Config.EmergencyFClass==1 then
        HealBot_Options_EFClassDruid:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_DRUID]);
        HealBot_Options_EFClassHunter:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_HUNTER]);
        HealBot_Options_EFClassMage:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_MAGE]);
        HealBot_Options_EFClassPaladin:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_PALADIN]);
        HealBot_Options_EFClassPriest:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_PRIEST]);
        HealBot_Options_EFClassRogue:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_ROGUE]);
        HealBot_Options_EFClassShaman:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_SHAMAN]);
        HealBot_Options_EFClassWarlock:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_WARLOCK]);
        HealBot_Options_EFClassWarrior:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_WARRIOR]);
        HealBot_Options_EFClassDeathKnight:SetChecked(HealBot_Config.EmergIncMelee[HEALBOT_DEATHKNIGHT]);
    elseif HealBot_Config.EmergencyFClass==2 then
        HealBot_Options_EFClassDruid:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_DRUID]);
        HealBot_Options_EFClassHunter:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_HUNTER]);
        HealBot_Options_EFClassMage:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_MAGE]);
        HealBot_Options_EFClassPaladin:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_PALADIN]);
        HealBot_Options_EFClassPriest:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_PRIEST]);
        HealBot_Options_EFClassRogue:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_ROGUE]);
        HealBot_Options_EFClassShaman:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_SHAMAN]);
        HealBot_Options_EFClassWarlock:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_WARLOCK]);
        HealBot_Options_EFClassWarrior:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_WARRIOR]);
        HealBot_Options_EFClassDeathKnight:SetChecked(HealBot_Config.EmergIncRange[HEALBOT_DEATHKNIGHT]);
    elseif HealBot_Config.EmergencyFClass==3 then
        HealBot_Options_EFClassDruid:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_DRUID]);
        HealBot_Options_EFClassHunter:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_HUNTER]);
        HealBot_Options_EFClassMage:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_MAGE]);
        HealBot_Options_EFClassPaladin:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_PALADIN]);
        HealBot_Options_EFClassPriest:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_PRIEST]);
        HealBot_Options_EFClassRogue:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_ROGUE]);
        HealBot_Options_EFClassShaman:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_SHAMAN]);
        HealBot_Options_EFClassWarlock:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_WARLOCK]);
        HealBot_Options_EFClassWarrior:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_WARRIOR]);
        HealBot_Options_EFClassDeathKnight:SetChecked(HealBot_Config.EmergIncHealers[HEALBOT_DEATHKNIGHT]);
    elseif HealBot_Config.EmergencyFClass==4 then
        HealBot_Options_EFClassDruid:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_DRUID]);
        HealBot_Options_EFClassHunter:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_HUNTER]);
        HealBot_Options_EFClassMage:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_MAGE]);
        HealBot_Options_EFClassPaladin:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_PALADIN]);
        HealBot_Options_EFClassPriest:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_PRIEST]);
        HealBot_Options_EFClassRogue:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_ROGUE]);
        HealBot_Options_EFClassShaman:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_SHAMAN]);
        HealBot_Options_EFClassWarlock:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_WARLOCK]);
        HealBot_Options_EFClassWarrior:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_WARRIOR]);
        HealBot_Options_EFClassDeathKnight:SetChecked(HealBot_Config.EmergIncCustom[HEALBOT_DEATHKNIGHT]);
    end
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

--------------------------------------------------------------------------------

local HealBot_Options_ExtraSort_List = {
    HEALBOT_SORTBY_NAME,
    HEALBOT_SORTBY_CLASS,
    HEALBOT_SORTBY_GROUP,
    HEALBOT_SORTBY_MAXHEALTH,
    HEALBOT_WORDS_NONE,
}

function HealBot_Options_ExtraSort_DropDown()
    for j=1, getn(HealBot_Options_ExtraSort_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_ExtraSort_List[j];
        info.func = HealBot_Options_ExtraSort_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_ExtraSubSort_DropDown()
    for j=1, getn(HealBot_Options_ExtraSort_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_ExtraSort_List[j];
        info.func = HealBot_Options_ExtraSubSort_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_ExtraSort_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_ExtraSort,HealBot_Options_ExtraSort_DropDown)
end

function HealBot_Options_ExtraSubSort_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_ExtraSubSort,HealBot_Options_ExtraSubSort_DropDown)
end

function HealBot_Options_ExtraSort_Refresh(onselect)
    if not Healbot_Config_Skins.ExtraOrder[Healbot_Config_Skins.Current_Skin] then return end
    if not onselect then HealBot_Options_ExtraSort_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_ExtraSort,Healbot_Config_Skins.ExtraOrder[Healbot_Config_Skins.Current_Skin])
end

function HealBot_Options_ExtraSubSort_Refresh(onselect)
    if not Healbot_Config_Skins.ExtraSubOrder[Healbot_Config_Skins.Current_Skin] then return end
    if not onselect then HealBot_Options_ExtraSubSort_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_ExtraSubSort,Healbot_Config_Skins.ExtraSubOrder[Healbot_Config_Skins.Current_Skin])
end

function HealBot_Options_ExtraSort_OnLoad(self)
 --   HealBot_Options_ExtraSort_Initialize()
    UIDropDownMenu_SetWidth(self,105)
end

function HealBot_Options_ExtraSubSort_OnLoad(self)
--    HealBot_Options_ExtraSort_Initialize()
    UIDropDownMenu_SetWidth(self,105)
end

function HealBot_Options_ExtraSort_OnSelect()
    Healbot_Config_Skins.ExtraOrder[Healbot_Config_Skins.Current_Skin] = this:GetID();
    HealBot_Options_ExtraSort_Refresh(true)
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=2; 
    end
end

function HealBot_Options_ExtraSubSort_OnSelect()
    Healbot_Config_Skins.ExtraSubOrder[Healbot_Config_Skins.Current_Skin] = this:GetID();
    HealBot_Options_ExtraSubSort_Refresh(true)
    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=2; 
    end
end

--------------------------------------------------------------------------------
local HealBot_ActionBarsCombo=1;

local HealBot_Options_ActionBarsCombo_List = {
    HEALBOT_OPTIONS_ENABLEDBARS,
    HEALBOT_OPTIONS_DISABLEDBARS,
}

function HealBot_Options_ActionBarsCombo_DropDown()
    for j=1, getn(HealBot_Options_ActionBarsCombo_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_ActionBarsCombo_List[j];
        info.func = HealBot_Options_ActionBarsCombo_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_ActionBarsCombo_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_ActionBarsCombo,HealBot_Options_ActionBarsCombo_DropDown)
end

function HealBot_Options_ActionBarsCombo_Refresh(onselect)
    if not onselect then HealBot_Options_ActionBarsCombo_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_ActionBarsCombo,HealBot_ActionBarsCombo)
end

function HealBot_Options_ActionBarsCombo_OnLoad(self)
 --   HealBot_Options_ActionBarsCombo_Initialize()
    UIDropDownMenu_SetWidth(self,240)
end

function HealBot_Options_ActionBarsCombo_OnSelect()
    HealBot_ActionBarsCombo = this:GetID()
    HealBot_Options_ActionBarsCombo_Refresh(true)
    HealBot_Options_ComboClass_Text();
end

--------------------------------------------------------------------------------

local HealBot_SelectHealSpellsCombo=1;
local HealBot_Options_SelectHealSpellsCombo_List = {
    HEALBOT_BINDING_HEAL,
    HEALBOT_CIRCLE_OF_HEALING,
    HEALBOT_CHAIN_HEAL,
    HEALBOT_FLASH_HEAL,
    HEALBOT_FLASH_OF_LIGHT,
    HEALBOT_GREATER_HEAL,
    HEALBOT_HEALING_TOUCH,
    HEALBOT_HEAL,
    HEALBOT_HEALING_WAVE,
    HEALBOT_HEALING_WAY,
    HEALBOT_HOLY_LIGHT,
    HEALBOT_LAY_ON_HANDS,
    HEALBOT_LESSER_HEAL,
    HEALBOT_LIFEBLOOM,
    HEALBOT_LESSER_HEALING_WAVE,
    HEALBOT_NOURISH,
    HEALBOT_PENANCE,
    HEALBOT_PRAYER_OF_HEALING,
    HEALBOT_PRAYER_OF_MENDING,
    HEALBOT_RIPTIDE,
    HEALBOT_REGROWTH,
    HEALBOT_RENEW,
    HEALBOT_REJUVENATION,
    HEALBOT_WILD_GROWTH,
    HEALBOT_SWIFTMEND,
    HEALBOT_TRANQUILITY,
    HEALBOT_GIFT_OF_THE_NAARU,
    HEALBOT_MENDPET,
}
local hbHelpHealSelect=nil
local hbHealDDlist=nil
function HealBot_Options_SelectHealSpellsCombo_DropDown()
    if getn(hbHealDDlist)>0 then
        for j=1, getn(hbHealDDlist), 1 do
            for x,_ in pairs(info) do
                info[x]=nil;
            end
            info.text = hbHealDDlist[j];
            info.func = HealBot_Options_SelectHealSpellsCombo_OnSelect;
            UIDropDownMenu_AddButton(info);
            if not hbHelpHealSelect then hbHelpHealSelect=hbHealDDlist[j] end
        end
    else
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HEALBOT_TOOLTIP_NONE
        info.func = HealBot_Options_SelectHealSpellsCombo_OnSelect;
        UIDropDownMenu_AddButton(info);
        hbHelpHealSelect=HEALBOT_TOOLTIP_NONE
    end
end

function HealBot_Options_SelectHealSpellsCombo_DDlist()
    hbHealDDlist={}
    for j=1, getn(HealBot_Options_SelectHealSpellsCombo_List), 1 do
        if HealBot_GetSpellId(HealBot_Options_SelectHealSpellsCombo_List[j]) then
            table.insert(hbHealDDlist, HealBot_Options_SelectHealSpellsCombo_List[j])
        end
    end
    table.sort(hbHealDDlist)
end

function HealBot_Options_SelectHealSpellsCombo_Initialize()
    if not hbHealDDlist then HealBot_Options_SelectHealSpellsCombo_DDlist() end
    UIDropDownMenu_Initialize(HealBot_Options_SelectHealSpellsCombo,HealBot_Options_SelectHealSpellsCombo_DropDown)
end

function HealBot_Options_SelectHealSpellsCombo_Refresh(onselect)
    if not onselect then HealBot_Options_SelectHealSpellsCombo_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_SelectHealSpellsCombo,HealBot_SelectHealSpellsCombo)
end

function HealBot_Options_SelectHealSpellsCombo_OnLoad(self)
 --   HealBot_Options_SelectHealSpellsCombo_Initialize()
    UIDropDownMenu_SetWidth(self,245)
end

function HealBot_Options_SelectHealSpellsCombo_OnSelect()
    hbHelpHealSelect = this:GetText()
    HealBot_SelectHealSpellsCombo = this:GetID()
    HealBot_Options_SelectHealSpellsCombo_Refresh(true)
end

--------------------------------------------------------------------------------

local HealBot_SelectOtherSpellsCombo=1;

local HealBot_Options_SelectOtherSpellsCombo_List = {
    HEALBOT_STONEFORM,
    HEALBOT_INSPIRATION,
    HEALBOT_POWER_WORD_SHIELD,
    HEALBOT_REVIVE,
    HEALBOT_GUARDIAN_SPIRIT,
    HEALBOT_PURIFICATION,
    HEALBOT_INTERVENE,
    HEALBOT_RESURRECTION,
    HEALBOT_REDEMPTION,
    HEALBOT_REBIRTH,
    HEALBOT_ANCESTRALSPIRIT,
    HEALBOT_PURIFY,
    HEALBOT_CLEANSE,
    HEALBOT_CURE_POISON,
    HEALBOT_REMOVE_CURSE,
    HEALBOT_ABOLISH_POISON,
    HEALBOT_CURE_DISEASE,
    HEALBOT_ABOLISH_DISEASE,
    HEALBOT_DISPEL_MAGIC,
    HEALBOT_CLEANSE_SPIRIT,
    HEALBOT_CURE_TOXINS,
}
local hbHelpOtherSelect=nil
local hbOtherDDlist=nil

function HealBot_Options_SelectOtherSpellsCombo_DropDown()
    if getn(hbOtherDDlist)>0 then
        for j=1, getn(hbOtherDDlist), 1 do
            for x,_ in pairs(info) do
                info[x]=nil;
            end
            info.text = hbOtherDDlist[j];
            info.func = HealBot_Options_SelectOtherSpellsCombo_OnSelect;
            UIDropDownMenu_AddButton(info);
            if not hbHelpOtherSelect then hbHelpOtherSelect=hbOtherDDlist[j] end
        end
    else
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HEALBOT_TOOLTIP_NONE
        info.func = HealBot_Options_SelectOtherSpellsCombo_OnSelect;
        UIDropDownMenu_AddButton(info);
        hbHelpOtherSelect=HEALBOT_TOOLTIP_NONE
    end
end

function HealBot_Options_SelectOtherSpellsCombo_DDlist()
    hbOtherDDlist={}
    for j=1, getn(HealBot_Options_SelectOtherSpellsCombo_List), 1 do
        if HealBot_GetSpellId(HealBot_Options_SelectOtherSpellsCombo_List[j]) then
            table.insert(hbOtherDDlist,HealBot_Options_SelectOtherSpellsCombo_List[j])
        end
    end
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        table.insert(hbOtherDDlist,HealBot_Buff_Spells_List[j])
    end
    table.sort(hbOtherDDlist)
end

function HealBot_Options_SelectOtherSpellsCombo_Initialize()
if not hbOtherDDlist then HealBot_Options_SelectOtherSpellsCombo_DDlist() end
    UIDropDownMenu_Initialize(HealBot_Options_SelectOtherSpellsCombo,HealBot_Options_SelectOtherSpellsCombo_DropDown)
end

function HealBot_Options_SelectOtherSpellsCombo_Refresh(onselect)
    if not onselect then HealBot_Options_SelectOtherSpellsCombo_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_SelectOtherSpellsCombo,HealBot_SelectOtherSpellsCombo)
end

function HealBot_Options_SelectOtherSpellsCombo_OnLoad(self)
 --   HealBot_Options_SelectOtherSpellsCombo_Initialize()
    UIDropDownMenu_SetWidth(self,245)
end

function HealBot_Options_SelectOtherSpellsCombo_OnSelect()
    HealBot_SelectOtherSpellsCombo = this:GetID()
    hbHelpOtherSelect=this:GetText()
    HealBot_Options_SelectOtherSpellsCombo_Refresh(true)
end

--------------------------------------------------------------------------------

local HealBot_SelectMacrosCombo=1;
local hbMacroName=nil
local hbHelpMacroSelect=nil

function HealBot_Options_SelectMacrosCombo_DropDown()
    local numglobal,numperchar = GetNumMacros();
    local totalMacros=numglobal+numperchar
    if totalMacros>0 then
        for j=1, totalMacros, 1 do
            hbMacroName=GetMacroInfo(j)
            if hbMacroName then
                for x,_ in pairs(info) do
                    info[x]=nil;
                end
                info.text = hbMacroName
                info.func = HealBot_Options_SelectMacrosCombo_OnSelect;
                UIDropDownMenu_AddButton(info);
                if not hbHelpMacroSelect then hbHelpMacroSelect=hbMacroName end
            end
        end
    else
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HEALBOT_TOOLTIP_NONE
        info.func = HealBot_Options_SelectMacrosCombo_OnSelect;
        UIDropDownMenu_AddButton(info);
        hbHelpMacroSelect=HEALBOT_TOOLTIP_NONE
    end
end

function HealBot_Options_SelectMacrosCombo_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_SelectMacrosCombo,HealBot_Options_SelectMacrosCombo_DropDown)
end

function HealBot_Options_SelectMacrosCombo_Refresh(onselect)
    if not onselect then HealBot_Options_SelectMacrosCombo_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_SelectMacrosCombo,HealBot_SelectMacrosCombo)
end

function HealBot_Options_SelectMacrosCombo_OnLoad(self)
 --   HealBot_Options_SelectMacrosCombo_Initialize()
    UIDropDownMenu_SetWidth(self,245)
end

function HealBot_Options_SelectMacrosCombo_OnSelect()
    HealBot_SelectMacrosCombo = this:GetID()
    hbHelpMacroSelect=this:GetText()
    HealBot_Options_SelectMacrosCombo_Refresh(true)
end

--------------------------------------------------------------------------------

local hbTmpText1=nil
local hbItemsByLevel={}
local hbLevel = UnitLevel("player")
function HealBot_Options_itemsByLevel(level)
    hbItemsByLevel={}
    if level <= 20 then
        hbTmpText1 = GetItemInfo(19004) or "Minor Healthstone"
        table.insert(hbItemsByLevel,hbTmpText1)
    elseif level <= 30 then
        hbTmpText1 = GetItemInfo(19007) or "Lesser Healthstone"
        table.insert(hbItemsByLevel,hbTmpText1)
    elseif level <= 40 then
        hbTmpText1 = GetItemInfo(19009) or "Healthstone"
        table.insert(hbItemsByLevel,hbTmpText1)
    elseif level <= 50 then
        hbTmpText1 = GetItemInfo(19011) or "Greater Healthstone"
        table.insert(hbItemsByLevel,hbTmpText1)
    elseif level <= 60 then
        hbTmpText1 = GetItemInfo(9421) or "Major Healthstone"
        table.insert(hbItemsByLevel,hbTmpText1)
    elseif level <= 70 then
        hbTmpText1 = GetItemInfo(19008) or "Master Healthstone"
        table.insert(hbItemsByLevel,hbTmpText1)
    elseif level <= 75 then
        hbTmpText1 = GetItemInfo(36892) or "Fel Healthstone"
        table.insert(hbItemsByLevel,hbTmpText1)
    else
        hbTmpText1 = GetItemInfo(36892) or "Fel Healthstone"
        table.insert(hbItemsByLevel,hbTmpText1)
    end
    return hbItemsByLevel
end
local hbItemsIfExists = {
    [1] = GetItemInfo(6450) or "Silk Bandage",
    [2] = GetItemInfo(6451) or "Heavy Silk Bandage",
    [3] = GetItemInfo(8544) or "Mageweave Bandage",
    [4] = GetItemInfo(8545) or "Heavy Mageweave Bandage",
    [5] = GetItemInfo(14529) or "Runecloth Bandage",
    [6] = GetItemInfo(14530) or "Heavy Runecloth Bandage",
    [7] = GetItemInfo(21990) or "Netherweave Bandage",
    [8] = GetItemInfo(21991) or "Heavy Netherweave Bandage",
    [9] = GetItemInfo(34721) or "Frostweave Bandage",
    [10] = GetItemInfo(34722) or "Heavy Frostweave Bandage",
    [11] = GetItemInfo(13446) or "Major Healing Potion",
    [12] = GetItemInfo(22829) or "Super Healing Potion",
    [13] = GetItemInfo(31838) or "Major Combat Healing Potion",
    [14] = GetItemInfo(33447) or "Runic Healing Potion",
    [15] = GetItemInfo(43569) or "Endless Healing Potion",    
    [16] = GetItemInfo(13444) or "Major Mana Potion",
    [17] = GetItemInfo(22832) or "Super Mana Potion",
    [18] = GetItemInfo(31840) or "Major Combat Mana Potion",
    [19] = GetItemInfo(33448) or "Runic Mana Potion",
    [20] = GetItemInfo(43570) or "Endless Mana Potion",
    [21] = HEALBOT_PURIFICATION_POTION,
    [22] = HEALBOT_ANTI_VENOM,
    [23] = HEALBOT_POWERFUL_ANTI_VENOM,
    [24] = HEALBOT_ELIXIR_OF_POISON_RES,
    }
local HealBot_SelectItemsCombo=1;
local HealBot_Options_SelectItemsCombo_List = {}
local hbHelpItemSelect=nil

function HealBot_Options_SelectItemsCombo_DropDown()
    HealBot_Options_SelectItemsCombo_List=HealBot_Options_itemsByLevel(hbLevel)
    for j=1, getn(hbItemsIfExists), 1 do
        if IsUsableItem(hbItemsIfExists[j]) then
            table.insert(HealBot_Options_SelectItemsCombo_List, hbItemsIfExists[j])
        end
    end
    table.sort(HealBot_Options_SelectItemsCombo_List)
    for j=1, getn(HealBot_Options_SelectItemsCombo_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_SelectItemsCombo_List[j];
        info.func = HealBot_Options_SelectItemsCombo_OnSelect;
        UIDropDownMenu_AddButton(info);
        if not hbHelpItemSelect then hbHelpItemSelect=HealBot_Options_SelectItemsCombo_List[j] end
    end
end

function HealBot_Options_SelectItemsCombo_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_SelectItemsCombo,HealBot_Options_SelectItemsCombo_DropDown)
end

function HealBot_Options_SelectItemsCombo_Refresh(onselect)
    if not onselect then HealBot_Options_SelectItemsCombo_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_SelectItemsCombo,HealBot_SelectItemsCombo)
end

function HealBot_Options_SelectItemsCombo_OnLoad(self)
--    HealBot_Options_SelectItemsCombo_Initialize()
    UIDropDownMenu_SetWidth(self,245)
end

function HealBot_Options_SelectItemsCombo_OnSelect()
    HealBot_SelectItemsCombo = this:GetID()
    hbHelpItemSelect=this:GetText()
    HealBot_Options_SelectItemsCombo_Refresh(true)
end

--------------------------------------------------------------------------------

local HealBot_SelectCmdsCombo=1;
local HealBot_Options_SelectCmdsCombo_List = {
    HEALBOT_DISABLED_TARGET,
    HEALBOT_ASSIST,
    HEALBOT_FOCUS,
    HEALBOT_MENU,
    HEALBOT_MAINTANK,
    HEALBOT_MAINASSIST,
    HEALBOT_STOP,
    HEALBOT_TELL.." ...",
}

local hbHelpCmdsSelect=nil
function HealBot_Options_SelectCmdsCombo_DropDown()
    for j=1, getn(HealBot_Options_SelectCmdsCombo_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_SelectCmdsCombo_List[j];
        info.func = HealBot_Options_SelectCmdsCombo_OnSelect;
        UIDropDownMenu_AddButton(info);
        if not hbHelpCmdsSelect then hbHelpCmdsSelect=HealBot_Options_SelectCmdsCombo_List[j] end
    end
end

function HealBot_Options_SelectCmdsCombo_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_SelectCmdsCombo,HealBot_Options_SelectCmdsCombo_DropDown)
end

function HealBot_Options_SelectCmdsCombo_Refresh(onselect)
    if not onselect then HealBot_Options_SelectCmdsCombo_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_SelectCmdsCombo,HealBot_SelectCmdsCombo)
end

function HealBot_Options_SelectCmdsCombo_OnLoad(self)
 --   HealBot_Options_SelectCmdsCombo_Initialize()
    UIDropDownMenu_SetWidth(self,245)
end

function HealBot_Options_SelectCmdsCombo_OnSelect()
    HealBot_SelectCmdsCombo = this:GetID()
    hbHelpCmdsSelect=this:GetText()
    HealBot_Options_SelectCmdsCombo_Refresh(true)
end

--------------------------------------------------------------------------------

local HealBot_Options_sLoc=nil
local hbOptionText=nil
local hbTmpText1=nil
function HealBot_Options_SpellsSelect_OnClick(self, sType)
    if sType~="Cancel" then
        if sType=="Heal" then
            hbTmpText1=hbHelpHealSelect or ""
        elseif sType=="Other" then
            hbTmpText1=hbHelpOtherSelect or ""
        elseif sType=="Macro" then
            hbTmpText1=hbHelpMacroSelect or ""
        elseif sType=="Item" then
            hbTmpText1=hbHelpItemSelect or ""
        else
            hbTmpText1=hbHelpCmdsSelect or ""
        end
        if hbTmpText1~=HEALBOT_TOOLTIP_NONE then
            if HealBot_Options_sLoc=="Click" then
                HealBot_Options_Click:SetText(hbTmpText1)
            elseif HealBot_Options_sLoc=="Shift" then
                HealBot_Options_Shift:SetText(hbTmpText1)
            elseif HealBot_Options_sLoc=="Ctrl" then
                HealBot_Options_Ctrl:SetText(hbTmpText1)
            elseif HealBot_Options_sLoc=="Alt" then
                HealBot_Options_Alt:SetText(hbTmpText1)
            elseif HealBot_Options_sLoc=="CtrlShift" then
                HealBot_Options_CtrlShift:SetText(hbTmpText1)
            else -- "AltShift"
                HealBot_Options_AltShift:SetText(hbTmpText1)
            end
        end
    end
    HealBot_Options_SelectSpellsFrame:Hide()
    HealBot_Options_KeysFrame:Show()
end

function HealBot_Options_HelpSpellsSelect_OnClick(self, sLoc)
    HealBot_Options_Init(10)
    HealBot_Options_sLoc=sLoc
    if HealBot_ActionBarsCombo==1 then
        hbOptionText=HEALBOT_OPTIONS_SETSPELLS.." "..HEALBOT_OPTIONS_ENABLEDBARS
    else
        hbOptionText=HEALBOT_OPTIONS_SETSPELLS.." "..HEALBOT_OPTIONS_DISABLEDBARS
    end
    HealBot_Options_SelectSpellsFrame_TextH1:SetText(hbOptionText)
    hbTmpText1=HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button).." "..HEALBOT_OPTIONS_CLICK
    if sLoc=="Click" then
        hbOptionText=HEALBOT_OPTIONS_COMBOCLASS..":  "..hbTmpText1
    elseif sLoc=="Shift" then
        hbOptionText=HEALBOT_OPTIONS_COMBOCLASS..":  "..HEALBOT_OPTIONS_SHIFT.."+"..hbTmpText1
    elseif sLoc=="Ctrl" then
        hbOptionText=HEALBOT_OPTIONS_COMBOCLASS..":  "..HEALBOT_OPTIONS_CTRL.."+"..hbTmpText1
    elseif sLoc=="Alt" then
        hbOptionText=HEALBOT_OPTIONS_COMBOCLASS..":  "..HEALBOT_OPTIONS_ALT.."+"..hbTmpText1
    elseif sLoc=="CtrlShift" then
        hbOptionText=HEALBOT_OPTIONS_COMBOCLASS..":  "..HEALBOT_OPTIONS_CTRL.."+"..HEALBOT_OPTIONS_SHIFT.."+"..hbTmpText1
    else -- "AltShift"
        hbOptionText=HEALBOT_OPTIONS_COMBOCLASS..":  "..HEALBOT_OPTIONS_ALT.."+"..HEALBOT_OPTIONS_SHIFT.."+"..hbTmpText1
    end
    HealBot_Options_SelectSpellsFrame_TextH2:SetText(hbOptionText)
    HealBot_Options_KeysFrame:Hide()
    HealBot_Options_SelectSpellsFrame:Show()
end

--------------------------------------------------------------------------------

local HealBot_Options_ActionAnchor_List = {
    HEALBOT_OPTIONS_TOPLEFT,
    HEALBOT_OPTIONS_BOTTOMLEFT,
    HEALBOT_OPTIONS_TOPRIGHT,
    HEALBOT_OPTIONS_BOTTOMRIGHT,
    HEALBOT_OPTIONS_TOP,
    HEALBOT_OPTIONS_BUTTONLEFT,
    HEALBOT_OPTIONS_BUTTONRIGHT,
    HEALBOT_OPTIONS_BOTTOM,
}

function HealBot_Options_ActionAnchor_DropDown()
    for j=1, getn(HealBot_Options_ActionAnchor_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_ActionAnchor_List[j];
        info.func = HealBot_Options_ActionAnchor_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_ActionAnchor_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_ActionAnchor,HealBot_Options_ActionAnchor_DropDown)
end

function HealBot_Options_ActionAnchor_Refresh(onselect)
    if not onselect then HealBot_Options_ActionAnchor_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_ActionAnchor,Healbot_Config_Skins.Panel_Anchor[Healbot_Config_Skins.Current_Skin])
end

function HealBot_Options_ActionAnchor_OnLoad(self)
--    HealBot_Options_ActionAnchor_Initialize()
    UIDropDownMenu_SetWidth(self,120)
end

function HealBot_Options_ActionAnchor_OnSelect()
    Healbot_Config_Skins.Panel_Anchor[Healbot_Config_Skins.Current_Skin] = this:GetID()
    HealBot_CheckActionFrame()
    HealBot_Options_ActionAnchor_Refresh(true)
    HealBot_SetResetFlag("SOFT")
end

--------------------------------------------------------------------------------

local HealBot_Options_Class_HoTctlName_List = {
    HEALBOT_GIFT_OF_THE_NAARU,
    HEALBOT_LIFEBLOOM,
    HEALBOT_MENDPET,
    HEALBOT_PRAYER_OF_MENDING,
    HEALBOT_REGROWTH,
    HEALBOT_REJUVENATION,
    HEALBOT_RENEW,
    HEALBOT_RIPTIDE,
    HEALBOT_TRANQUILITY,
    HEALBOT_WILD_GROWTH,
    HEALBOT_ABOLISH_DISEASE,
    HEALBOT_ABOLISH_POISON,
    HEALBOT_GUARDIAN_SPIRIT,
    HEALBOT_PAIN_SUPPRESSION,
    HEALBOT_POWER_INFUSION,
    HEALBOT_POWER_WORD_SHIELD,
    HEALBOT_VIGILANCE,
    HEALBOT_BEACON_OF_LIGHT,
    HEALBOT_HANDOFPROTECTION,
    HEALBOT_FLASH_OF_LIGHT,
    HEALBOT_LIGHT_BEACON,
    HEALBOT_SACRED_SHIELD,
    HEALBOT_DIVINE_AEGIS,
    HEALBOT_GRACE,
    HEALBOT_SURGE_OF_LIGHT,
    HEALBOT_HEALING_WAY,
    HEALBOT_INSPIRATION,
    HEALBOT_PROTANCIENTKINGS,
    HEALBOT_ANCESTRAL_FORTITUDE,
    HEALBOT_EARTHLIVING_WEAPON,
    HEALBOT_EARTH_SHIELD,
    HEALBOT_LIGHTNING_SHIELD,
    HEALBOT_WATER_SHIELD,
}

function HealBot_Options_Class_HoTctlName_DropDown()
    table.sort(HealBot_Options_Class_HoTctlName_List)
    for j=1, getn(HealBot_Options_Class_HoTctlName_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_Class_HoTctlName_List[j];
        info.func = HealBot_Options_Class_HoTctlName_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_Class_HoTctlName_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_Class_HoTctlName,HealBot_Options_Class_HoTctlName_DropDown)
end

function HealBot_Options_Class_HoTctlName_Refresh(onselect)
    if not onselect then HealBot_Options_Class_HoTctlName_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_Class_HoTctlName,HealBot_Globals.HoTindex)
end

function HealBot_Options_Class_HoTctlName_OnLoad(self)
 --   HealBot_Options_Class_HoTctlName_Initialize()
    UIDropDownMenu_SetWidth(self,158)
end

function HealBot_Options_Class_HoTctlName_OnSelect()
    HealBot_Globals.HoTindex = this:GetID()
    HealBot_Globals.HoTname = this:GetText()
    HealBot_Options_Class_HoTctlName_Refresh(true)
    HealBot_Options_Class_HoTctlAction_Refresh()
end

--------------------------------------------------------------------------------

local HealBot_Options_Class_HoTctlAction_List = {
    HEALBOT_WORD_NEVER,
    HEALBOT_OPTIONS_SELFCASTS,
    HEALBOT_WORD_ALWAYS,
}

function HealBot_Options_Class_HoTctlAction_DropDown()
    for j=1, getn(HealBot_Options_Class_HoTctlAction_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_Class_HoTctlAction_List[j];
        info.func = HealBot_Options_Class_HoTctlAction_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_Class_HoTctlAction_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_Class_HoTctlAction,HealBot_Options_Class_HoTctlAction_DropDown)
end

function HealBot_Options_Class_HoTctlAction_Refresh(onselect)
    if not onselect then HealBot_Options_Class_HoTctlAction_Initialize() end  -- or wrong menu may be used !
    local hbClass=strsub(HealBot_PlayerClassEN,1,4)
    UIDropDownMenu_SetSelectedID(HealBot_Options_Class_HoTctlAction,HealBot_Globals.WatchHoT[hbClass][HealBot_Globals.HoTname])
end

function HealBot_Options_Class_HoTctlAction_OnLoad(self)
 --   HealBot_Options_Class_HoTctlAction_Initialize()
    UIDropDownMenu_SetWidth(self,105)
end

function HealBot_Options_Class_HoTctlAction_OnSelect()
    local hbClass=strsub(HealBot_PlayerClassEN,1,4)
    HealBot_Globals.WatchHoT[hbClass][HealBot_Globals.HoTname]=this:GetID()
    HealBot_Options_Class_HoTctlAction_Refresh(true)
    HealBot_setOptions_Timer(170)
end

--------------------------------------------------------------------------------

local HealBot_Options_SkinDefault_List = {
    HEALBOT_WORDS_NONE,
    HEALBOT_WORD_SOLO,
    HEALBOT_WORD_PARTY,
    HEALBOT_OPTIONS_EMERGENCYHEALS.." 10",
    HEALBOT_OPTIONS_EMERGENCYHEALS.." 25",
    HEALBOT_OPTIONS_EMERGENCYHEALS.." 40",
    HEALBOT_WORD_ARENA,
    HEALBOT_WORD_BATTLEGROUND.." 10",
    HEALBOT_WORD_BATTLEGROUND.." 15",
    HEALBOT_WORD_BATTLEGROUND.." 40",
}

function HealBot_Options_SkinDefault_DropDown()
    for j=1, getn(HealBot_Options_SkinDefault_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_SkinDefault_List[j];
        info.func = HealBot_Options_SkinDefault_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_SkinDefault_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_SkinPartyRaidDefault,HealBot_Options_SkinDefault_DropDown)
end

function HealBot_Options_SkinDefault_Refresh(onselect)
    if not onselect then HealBot_Options_SkinDefault_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_SkinPartyRaidDefault,HealBot_Config.SkinDefault[Healbot_Config_Skins.Current_Skin])
end

function HealBot_Options_SkinDefault_OnLoad(self)
 --   HealBot_Options_SkinDefault_Initialize()
    UIDropDownMenu_SetWidth(self,120)
end

local hbSkinDefaultID=1
function HealBot_Options_SkinDefault_OnSelect()
    hbSkinDefaultID = this:GetID()
    if hbSkinDefaultID>1 then
        for x in pairs (Healbot_Config_Skins.Skins) do
            if HealBot_Config.SkinDefault[Healbot_Config_Skins.Skins[x]]==hbSkinDefaultID then HealBot_Config.SkinDefault[Healbot_Config_Skins.Skins[x]]=1 end
        end
    end
    HealBot_Config.SkinDefault[Healbot_Config_Skins.Current_Skin]=hbSkinDefaultID
    HealBot_Options_SkinDefault_Refresh(true)
  --  HealBot_SetResetFlag("SOFT")
end

--------------------------------------------------------------------------------

local HealBot_Options_EmergencyFilter_List = {
    HEALBOT_CLASSES_ALL,
    HEALBOT_DRUID,
    HEALBOT_HUNTER,
    HEALBOT_MAGE,
    HEALBOT_PALADIN,
    HEALBOT_PRIEST,
    HEALBOT_ROGUE,
    HEALBOT_SHAMAN,
    HEALBOT_WARLOCK,
    HEALBOT_WARRIOR,
    HEALBOT_DEATHKNIGHT,
    HEALBOT_CLASSES_MELEE,
    HEALBOT_CLASSES_RANGES,
    HEALBOT_CLASSES_HEALERS,
    HEALBOT_CLASSES_CUSTOM,
}

function HealBot_Options_EmergencyFilter_DropDown()
    for j=1, getn(HealBot_Options_EmergencyFilter_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_EmergencyFilter_List[j];
        info.func = HealBot_Options_EmergencyFilter_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_EmergencyFilter_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_EmergencyFilter,HealBot_Options_EmergencyFilter_DropDown)
end

function HealBot_Options_EmergencyFilter_Refresh(onselect)
    if not Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin] then return end
    if not onselect then HealBot_Options_EmergencyFilter_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_EmergencyFilter,Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin])
end

function HealBot_Options_EmergencyFilter_OnLoad(self)
--    HealBot_Options_EmergencyFilter_Initialize()
    UIDropDownMenu_SetWidth(self,145)
end

function HealBot_Options_EmergencyFilter_OnSelect()
    Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin] = this:GetID()
    HealBot_Options_EmergencyFilter_Refresh(true)
    HealBot_setOptions_Timer(60)
end

function HealBot_Options_EmergencyFilter_Reset()
  
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_DRUID]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_HUNTER]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_MAGE]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_PALADIN]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_PRIEST]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_ROGUE]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_SHAMAN]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARLOCK]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARRIOR]] = 0;
    HealBot_EmergInc[HealBot_Class_En[HEALBOT_DEATHKNIGHT]] = 0;
    if Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==1 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DRUID]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_HUNTER]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_MAGE]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PALADIN]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PRIEST]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_ROGUE]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_SHAMAN]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARLOCK]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARRIOR]] = 1;
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DEATHKNIGHT]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==2 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DRUID]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==3 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_HUNTER]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==4 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_MAGE]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==5 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PALADIN]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==6 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PRIEST]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==7 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_ROGUE]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==8 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_SHAMAN]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==9 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARLOCK]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==10 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARRIOR]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==11 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DEATHKNIGHT]] = 1;
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==12 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DRUID]] = HealBot_Config.EmergIncMelee[HEALBOT_DRUID];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_HUNTER]] = HealBot_Config.EmergIncMelee[HEALBOT_HUNTER];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_MAGE]] = HealBot_Config.EmergIncMelee[HEALBOT_MAGE];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PALADIN]] = HealBot_Config.EmergIncMelee[HEALBOT_PALADIN];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PRIEST]] = HealBot_Config.EmergIncMelee[HEALBOT_PRIEST];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_ROGUE]] = HealBot_Config.EmergIncMelee[HEALBOT_ROGUE];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_SHAMAN]] = HealBot_Config.EmergIncMelee[HEALBOT_SHAMAN];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARLOCK]] = HealBot_Config.EmergIncMelee[HEALBOT_WARLOCK];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARRIOR]] = HealBot_Config.EmergIncMelee[HEALBOT_WARRIOR];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DEATHKNIGHT]] = HealBot_Config.EmergIncMelee[HEALBOT_DEATHKNIGHT];
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==13 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DRUID]] = HealBot_Config.EmergIncRange[HEALBOT_DRUID];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_HUNTER]] = HealBot_Config.EmergIncRange[HEALBOT_HUNTER];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_MAGE]] = HealBot_Config.EmergIncRange[HEALBOT_MAGE];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PALADIN]] = HealBot_Config.EmergIncRange[HEALBOT_PALADIN];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PRIEST]] = HealBot_Config.EmergIncRange[HEALBOT_PRIEST];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_ROGUE]] = HealBot_Config.EmergIncRange[HEALBOT_ROGUE];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_SHAMAN]] = HealBot_Config.EmergIncRange[HEALBOT_SHAMAN];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARLOCK]] = HealBot_Config.EmergIncRange[HEALBOT_WARLOCK];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARRIOR]] = HealBot_Config.EmergIncRange[HEALBOT_WARRIOR];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DEATHKNIGHT]] = HealBot_Config.EmergIncRange[HEALBOT_DEATHKNIGHT];
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==14 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DRUID]] = HealBot_Config.EmergIncHealers[HEALBOT_DRUID];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_HUNTER]] = HealBot_Config.EmergIncHealers[HEALBOT_HUNTER];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_MAGE]] = HealBot_Config.EmergIncHealers[HEALBOT_MAGE];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PALADIN]] = HealBot_Config.EmergIncHealers[HEALBOT_PALADIN];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PRIEST]] = HealBot_Config.EmergIncHealers[HEALBOT_PRIEST];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_ROGUE]] = HealBot_Config.EmergIncHealers[HEALBOT_ROGUE];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_SHAMAN]] = HealBot_Config.EmergIncHealers[HEALBOT_SHAMAN];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARLOCK]] = HealBot_Config.EmergIncHealers[HEALBOT_WARLOCK];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARRIOR]] = HealBot_Config.EmergIncHealers[HEALBOT_WARRIOR];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DEATHKNIGHT]] = HealBot_Config.EmergIncHealers[HEALBOT_DEATHKNIGHT];
    elseif Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]==15 then
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DRUID]] = HealBot_Config.EmergIncCustom[HEALBOT_DRUID];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_HUNTER]] = HealBot_Config.EmergIncCustom[HEALBOT_HUNTER];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_MAGE]] = HealBot_Config.EmergIncCustom[HEALBOT_MAGE];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PALADIN]] = HealBot_Config.EmergIncCustom[HEALBOT_PALADIN];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_PRIEST]] = HealBot_Config.EmergIncCustom[HEALBOT_PRIEST];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_ROGUE]] = HealBot_Config.EmergIncCustom[HEALBOT_ROGUE];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_SHAMAN]] = HealBot_Config.EmergIncCustom[HEALBOT_SHAMAN];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARLOCK]] = HealBot_Config.EmergIncCustom[HEALBOT_WARLOCK];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_WARRIOR]] = HealBot_Config.EmergIncCustom[HEALBOT_WARRIOR];
        HealBot_EmergInc[HealBot_Class_En[HEALBOT_DEATHKNIGHT]] = HealBot_Config.EmergIncCustom[HEALBOT_DEATHKNIGHT];
    end

    if Delay_RecalcParty==0 then 
        Delay_RecalcParty=1; 
    end
end

--------------------------------------------------------------------------------

function HealBot_Options_Skins_DropDown()
    for j=1, getn(HealBot_Skins), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Skins[j];
        info.func = HealBot_Options_Skins_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_Skins_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_Skins,HealBot_Options_Skins_DropDown)
end

function HealBot_Options_Skins_Refresh(onselect)
    if not Healbot_Config_Skins.Skin_ID then return end
    if not onselect then HealBot_Options_Skins_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_Skins,Healbot_Config_Skins.Skin_ID)
end

function HealBot_Options_Skins_OnLoad(self)
 --   HealBot_setOptions_Timer(9000)
    UIDropDownMenu_SetWidth(self,110)
end

function HealBot_Options_Skins_OnSelect()
    Healbot_Config_Skins.Skin_ID = this:GetID()
    HealBot_Options_Skins_Refresh(true)
    if this:GetID()>=1 then
        HealBot_Options_Set_Current_Skin(this:GetText())
    end
end


local HealBot_Options_notSet_Current_Skin = true
function HealBot_Options_Set_Current_Skin(newSkin)
    if HealBot_Options_notSet_Current_Skin or newSkin then
        if HealBot_Options_notSet_Current_Skin then 
            HealBot_Skins = Healbot_Config_Skins.Skins
            HealBot_Options_notSet_Current_Skin=nil
        end
        if newSkin then
            local hbFoundSkin=nil
            local hbValidSkins=nil
            for j=1, getn(HealBot_Skins), 1 do
                if newSkin==HealBot_Skins[j] then
                    hbFoundSkin=true
                    HealBot_RaidTargetToggle(nil) 
                    Healbot_Config_Skins.Skin_ID = j
                    Healbot_Config_Skins.Current_Skin = HealBot_Skins[j]
                    HealBot_Options_SetSkins();
                    --HealBot_SetResetFlag("SOFT")
                    HealBot_Action_clearResetBarSkinDone()
                    HealBot_Panel_clearResetHeaderSkinDone()
                    Delay_RecalcParty=3
                    if Healbot_Config_Skins.ShowRaidIcon[Healbot_Config_Skins.Current_Skin]==1 then 
                        HealBot_RaidTargetToggle(true) 
                    end
                end
                if hbValidSkins then
                    hbValidSkins=hbValidSkins.."  +  "..HealBot_Skins[j]
                else
                    hbValidSkins=HealBot_Skins[j]
                end
            end
            if not hbFoundSkin then
                HealBot_AddChat(HEALBOT_CHAT_ADDONID..HEALBOT_CHAT_CHANGESKINERR1..newSkin)
                HealBot_AddChat(HEALBOT_CHAT_ADDONID..HEALBOT_CHAT_CHANGESKINERR2..hbValidSkins)
            elseif Healbot_Config_Skins.AutoClose[Healbot_Config_Skins.Current_Skin]==0 and HealBot_Config.DisableHealBot==0 then
                ShowUIPanel(HealBot_Action)
            else
                HealBot_Action_Refresh(HealBot_PlayerGUID)
            end
            HealBot_setOptions_Timer(180)
        elseif HealBot_Config.Skin_ID>0 and HealBot_Config.Current_Skin and Healbot_Config_Skins.bheight[HealBot_Config.Current_Skin] then 
            Healbot_Config_Skins.Current_Skin = HealBot_Config.Current_Skin
            Healbot_Config_Skins.Skin_ID = HealBot_Config.Skin_ID
        else
            HealBot_Config.Current_Skin = Healbot_Config_Skins.Current_Skin
            HealBot_Config.Skin_ID = Healbot_Config_Skins.Skin_ID
        end
        HealBot_Options_Skins_Refresh()
        HealBot_Action_SetHightlightAggroCols()
    end
end

--------------------------------------------------------------------------------
local hbOptUsers={}
local hbDisableShare=true
local hbShareSkin=1

function HealBot_Options_ShareSkin_DropDown()
    z=0
    hbDisableShare=true
    if HealBot_PlayerName then
        hbOptUsers=HealBot_GetInfo()
        for x,y in pairs(hbOptUsers) do
            if x~=HealBot_PlayerName then
                z=z+1
            end
        end
    end
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = strlower(HEALBOT_WORDS_NONE);
    info.func = HealBot_Options_ShareSkin_OnSelect;
    UIDropDownMenu_AddButton(info);
    if z>0 then
        hbDisableShare=false
        for x,y in pairs(hbOptUsers) do
            if x~=HealBot_PlayerName then
                for x,_ in pairs(info) do
                    info[x]=nil;
                end
                info.text = x;
                info.func = HealBot_Options_ShareSkin_OnSelect;
                UIDropDownMenu_AddButton(info);
            end
        end
    end
    if hbDisableShare then
        hbShareSkin=1
        HealBot_Options_ShareSkinb:Disable()
    else
        HealBot_Options_ShareSkinb:Enable()
    end
end

function HealBot_Options_ShareSkin_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_ShareSkin,HealBot_Options_ShareSkin_DropDown)
end

function HealBot_Options_ShareSkin_Refresh(onselect)
    if not onselect then HealBot_Options_ShareSkin_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_ShareSkin,hbShareSkin)
end

function HealBot_Options_ShareSkin_OnLoad(self)
 --   HealBot_Options_ShareSkin_Initialize()
    UIDropDownMenu_SetWidth(self,125)
end

local hbCurUnitName=nil
function HealBot_Options_ShareSkin_OnSelect()
    hbShareSkin = this:GetID()
    hbCurUnitName = this:GetText()
    HealBot_Options_ShareSkin_Refresh(true)
end

function HealBot_Options_ShareSkinb_OnClick()
    if hbCurUnitName and hbCurUnitName~=strlower(HEALBOT_WORDS_NONE) then
        HealBot_Options_ShareSkinSend("A", Healbot_Config_Skins.Current_Skin, hbCurUnitName)
    end
end

local hbOptCompatUsers={}
function HealBot_Options_sethbOptCompatUsers(unitName, version)
    hbOptCompatUsers[unitName]=version
end

function HealBot_Options_ShareSkinSend(status,skinName,unitName)
    if hbOptCompatUsers[unitName] then
        local hbFoundSkin=HealBot_Options_checkSkinName(skinName)
        if hbFoundSkin then
            if status=="A" then
                HealBot_Comms_SendAddonMsg("HealBot", "X:"..skinName, 4, unitName)
            else
                local hbMsg=nil
                hbMsg=HealBot_Options_BuildSkinSendMsg(skinName,1)
                HealBot_Comms_SendAddonMsg("HealBot", "Z:1:"..hbMsg, 4, unitName)
                hbMsg=HealBot_Options_BuildSkinSendMsg(skinName,2)
                HealBot_Comms_SendAddonMsg("HealBot", "Z:2:"..hbMsg, 4, unitName)
                hbMsg=HealBot_Options_BuildSkinSendMsg(skinName,3)
                HealBot_Comms_SendAddonMsg("HealBot", "Z:3:"..hbMsg, 4, unitName)
                hbMsg=HealBot_Options_BuildSkinSendMsg(skinName,4)
                HealBot_Comms_SendAddonMsg("HealBot", "Z:4:"..hbMsg, 4, unitName)
                hbMsg=HealBot_Options_BuildSkinSendMsg(skinName,5)
                HealBot_Comms_SendAddonMsg("HealBot", "Z:5:"..hbMsg, 4, unitName)
                hbMsg=HealBot_Options_BuildSkinSendMsg(skinName,6)
                HealBot_Comms_SendAddonMsg("HealBot", "Z:6:"..hbMsg, 4, unitName)
            end
        else
            HealBot_AddChat(HEALBOT_CHAT_ADDONID..skinName..HEALBOT_CHAT_SHARESKINERR1);
        end
    else
        hbOptUsers=HealBot_GetInfo()
        if hbOptUsers[unitName] then
            HealBot_AddChat(HEALBOT_CHAT_ADDONID..unitName..HEALBOT_CHAT_SHARESKINERR2);
        else
            HealBot_AddChat(HEALBOT_CHAT_ADDONID..unitName..HEALBOT_CHAT_SHARESKINERR3);
        end
    end
end

local hbSkinRecAll={}
local hbAccpetedSkin="none"
local hbWarnSharedMedia=false
function HealBot_Options_ShareSkinRec(status, msg, partID)
    if status=="X" then
        hbOptGetSkinFrom, hbOptGetSkinName = string.split("!", msg)
        if hbOptGetSkinFrom and hbOptGetSkinName then
            StaticPopup_Show ("HEALBOT_OPTIONS_ACCEPTSKIN", " "..hbOptGetSkinName..HEALBOT_OPTIONS_ACCEPTSKINMSGFROM..hbOptGetSkinFrom);
        end
    elseif hbOptGetSkinName and hbAccpetedSkin==hbOptGetSkinFrom then
        HealBot_Options_BuildSkinRecMsg(hbOptGetSkinName, tonumber(partID), msg)
        hbSkinRecAll[partID]=true
        if hbSkinRecAll["1"] and hbSkinRecAll["2"] and hbSkinRecAll["3"] and hbSkinRecAll["4"] and hbSkinRecAll["5"] and hbSkinRecAll["6"] then
            unique=true;
            table.foreach(HealBot_Skins, function (index,skin)
                if skin==hbOptGetSkinName then unique=false; end
            end)
            if unique then
                table.insert(HealBot_Skins,2,hbOptGetSkinName)
                Healbot_Config_Skins.Skin_ID = 2;
                Healbot_Config_Skins.Skins = HealBot_Skins
                Healbot_Config_Skins.Current_Skin = hbOptGetSkinName
                HealBot_Update_Skins()
            end
            HealBot_Options_SetSkins();
            HealBot_Options_NewSkin:SetText("")
            hbSkinRecAll={}
            hbAccpetedSkin="none"
            hbWarnSharedMedia=false
        end
    end
end

function HealBot_Options_checkSkinName(skinName)
    local hbFoundSkin=nil
    for j=1, getn(HealBot_Skins), 1 do
        if skinName==HealBot_Skins[j] then
            hbFoundSkin=true
            do break end
        end
    end
    return hbFoundSkin
end

function HealBot_Options_ShareSkinAccept()
    hbSkinRecAll={}
    HealBot_Comms_SendAddonMsg("HealBot", "Y:"..hbOptGetSkinName, 4, hbOptGetSkinFrom)
    hbAccpetedSkin=hbOptGetSkinFrom
end

function HealBot_Options_BuildSkinSendMsg(skinName, partID)
    local ssMsg=nil
    
    if partID==1 then
        ssMsg=Healbot_Config_Skins.numcols[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.btexture[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.bcspace[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.brspace[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.bwidth[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.bheight[skinName]
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextenabledcolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextenabledcolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextenabledcolb[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextenabledcola[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextdisbledcolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextdisbledcolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextdisbledcolb[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextdisbledcola[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextcursecolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextcursecolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextcursecolb[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.btextcursecola[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.backcola[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.Barcola[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.BarcolaInHeal[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.backcolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.backcolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.backcolb[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.borcolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.borcolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.borcolb[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.borcola[skinName],1,4)
    elseif partID==2 then
        ssMsg=Healbot_Config_Skins.btextfont[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.btextheight[skinName]
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.bardisa[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.bareora[skinName],1,4)
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.bar2size[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowHeader[skinName]
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headbarcolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headbarcolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headbarcolb[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headbarcola[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headtxtcolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headtxtcolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headtxtcolb[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headtxtcola[skinName],1,4)
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.headtexture[skinName]
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headwidth[skinName],1,4)
    elseif partID==3 then
        ssMsg=Healbot_Config_Skins.headtextfont[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.headtextheight[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowAggro[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowAggroBars[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowAggroText[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.UseFluidBars[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.BarFreq[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowHoTicons[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIcon[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowDebuffIcon[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.HoTonBar[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.HoTposBar[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowClassOnBar[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowClassType[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowNameOnBar[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowHealthOnBar[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.BarHealthIncHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.BarHealthSepHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.BarHealthType[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SetClassColourText[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SetBarClassColour[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SetBarCustomColour[skinName]
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.barcolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.barcolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.barcolb[skinName],1,4)
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowIconTextCount[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowIconTextDuration[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.IconScale[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.IconTextScale[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.AggroBarSize[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.DoubleText[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.TextAlignment[skinName]
    elseif partID==4 then
        ssMsg=Healbot_Config_Skins.HighLightActiveBar[skinName]
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.highcolr[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.highcolg[skinName],1,4)
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.highcolb[skinName],1,4)
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.GroupsPerCol[skinName]
        ssMsg=ssMsg.."!"..strsub(Healbot_Config_Skins.headhight[skinName],1,4)
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SelfHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.PetHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.GroupHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.TankHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SelfPet[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.EmergencyHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SetFocusBar[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.VehicleHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowMyTargetsList[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.TargetHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.TargetIncSelf[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.TargetIncGroup[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.TargetIncRaid[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.TargetIncPet[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.TargetBarNormalMode[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.AlertLevel[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.NotVisibleDisable[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.HidePartyFrames[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.HidePlayerTarget[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.CastNotify[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.NotifyChan[skinName]
    elseif partID==5 then
        ssMsg=Healbot_Config_Skins.NotifyHealMsg[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.NotifyOtherMsg[skinName]
    elseif partID==6 then
        ssMsg=Healbot_Config_Skins.CastNotifyResOnly[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowIncHeals[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.incHealDur[skinName]["D"]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.incHealDur[skinName]["H"]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.incHealDur[skinName]["C"]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.EmergIncMonitor[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ExtraOrder[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ExtraSubOrder[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SubSortIncGroup[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SubSortIncPet[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SubSortIncVehicle[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SubSortIncTanks[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.SubSortIncMyTargets[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.Panel_Anchor[skinName]
        for x=1,8 do
            if Healbot_Config_Skins.ExtraIncGroup[skinName][x] then
                ssMsg=ssMsg.."!1"
            else
                ssMsg=ssMsg.."!0"
            end
        end
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ActionLocked[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.AutoClose[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.PanelSounds[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIconStar[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIconCircle[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIconDiamond[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIconTriangle[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIconMoon[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIconSquare[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIconCross[skinName]
        ssMsg=ssMsg.."!"..Healbot_Config_Skins.ShowRaidIconSkull[skinName]
    end
    return ssMsg
end

function HealBot_Options_BuildSkinRecMsg(skinName, partID, msg)
    local tmpMsg={}
    if partID==1 then
        tmpMsg[1],   tmpMsg[2],  tmpMsg[3],  tmpMsg[4],  tmpMsg[5],  tmpMsg[6],  tmpMsg[7],  tmpMsg[8],  tmpMsg[9], tmpMsg[10],
        tmpMsg[11], tmpMsg[12], tmpMsg[13], tmpMsg[14], tmpMsg[15], tmpMsg[16], tmpMsg[17], tmpMsg[18], tmpMsg[19], tmpMsg[20],
        tmpMsg[21], tmpMsg[22], tmpMsg[23], tmpMsg[24], tmpMsg[25], tmpMsg[26], tmpMsg[27], tmpMsg[28] = string.split("!", msg)
        Healbot_Config_Skins.numcols[skinName] = tonumber(tmpMsg[1])
        if texturesIndex[tmpMsg[2]] then
            Healbot_Config_Skins.btexture[skinName] = tmpMsg[2]
        elseif not Healbot_Config_Skins.btexture[skinName] then
            Healbot_Config_Skins.btexture[skinName] = "Smooth"
        end
        Healbot_Config_Skins.bcspace[skinName] = tonumber(tmpMsg[3])
        Healbot_Config_Skins.brspace[skinName] = tonumber(tmpMsg[4])
        Healbot_Config_Skins.bwidth[skinName] = tonumber(tmpMsg[5])
        Healbot_Config_Skins.bheight[skinName] = tonumber(tmpMsg[6])
        Healbot_Config_Skins.btextenabledcolr[skinName] = tonumber(tmpMsg[7])
        Healbot_Config_Skins.btextenabledcolg[skinName] = tonumber(tmpMsg[8])
        Healbot_Config_Skins.btextenabledcolb[skinName] = tonumber(tmpMsg[9])
        Healbot_Config_Skins.btextenabledcola[skinName] = tonumber(tmpMsg[10])
        Healbot_Config_Skins.btextdisbledcolr[skinName] = tonumber(tmpMsg[11])
        Healbot_Config_Skins.btextdisbledcolg[skinName] = tonumber(tmpMsg[12])
        Healbot_Config_Skins.btextdisbledcolb[skinName] = tonumber(tmpMsg[13])
        Healbot_Config_Skins.btextdisbledcola[skinName] = tonumber(tmpMsg[14])
        Healbot_Config_Skins.btextcursecolr[skinName] = tonumber(tmpMsg[15])
        Healbot_Config_Skins.btextcursecolg[skinName] = tonumber(tmpMsg[16])
        Healbot_Config_Skins.btextcursecolb[skinName] = tonumber(tmpMsg[17])
        Healbot_Config_Skins.btextcursecola[skinName] = tonumber(tmpMsg[18])
        Healbot_Config_Skins.backcola[skinName] = tonumber(tmpMsg[19])
        Healbot_Config_Skins.Barcola[skinName] = tonumber(tmpMsg[20])
        Healbot_Config_Skins.BarcolaInHeal[skinName] = tonumber(tmpMsg[21])
        Healbot_Config_Skins.backcolr[skinName] = tonumber(tmpMsg[22])
        Healbot_Config_Skins.backcolg[skinName] = tonumber(tmpMsg[23])
        Healbot_Config_Skins.backcolb[skinName] = tonumber(tmpMsg[24])
        Healbot_Config_Skins.borcolr[skinName] = tonumber(tmpMsg[25])
        Healbot_Config_Skins.borcolg[skinName] = tonumber(tmpMsg[26])
        Healbot_Config_Skins.borcolb[skinName] = tonumber(tmpMsg[27])
        Healbot_Config_Skins.borcola[skinName] = tonumber(tmpMsg[28])
    elseif partID==2 then
        tmpMsg[1],   tmpMsg[2],  tmpMsg[3],  tmpMsg[4],  tmpMsg[5],  tmpMsg[6],  tmpMsg[7],  tmpMsg[8],  tmpMsg[9], tmpMsg[10],
        tmpMsg[11], tmpMsg[12], tmpMsg[13], tmpMsg[14], tmpMsg[15], tmpMsg[16] = string.split("!", msg)
        if fontsIndex[tmpMsg[1]] then
            Healbot_Config_Skins.btextfont[skinName] = tmpMsg[1]
        elseif not Healbot_Config_Skins.btextfont[skinName] then
            Healbot_Config_Skins.btextfont[skinName] = "Friz Quadrata TT"
        end
        Healbot_Config_Skins.btextheight[skinName] = tonumber(tmpMsg[2])
        Healbot_Config_Skins.bardisa[skinName] = tonumber(tmpMsg[3])
        Healbot_Config_Skins.bareora[skinName] = tonumber(tmpMsg[4])
        Healbot_Config_Skins.bar2size[skinName] = tonumber(tmpMsg[5])
        Healbot_Config_Skins.ShowHeader[skinName] = tonumber(tmpMsg[6])
        Healbot_Config_Skins.headbarcolr[skinName] = tonumber(tmpMsg[7])
        Healbot_Config_Skins.headbarcolg[skinName] = tonumber(tmpMsg[8])
        Healbot_Config_Skins.headbarcolb[skinName] = tonumber(tmpMsg[9])
        Healbot_Config_Skins.headbarcola[skinName] = tonumber(tmpMsg[10])
        Healbot_Config_Skins.headtxtcolr[skinName] = tonumber(tmpMsg[11])
        Healbot_Config_Skins.headtxtcolg[skinName] = tonumber(tmpMsg[12])
        Healbot_Config_Skins.headtxtcolb[skinName] = tonumber(tmpMsg[13])
        Healbot_Config_Skins.headtxtcola[skinName] = tonumber(tmpMsg[14])
        if texturesIndex[tmpMsg[15]] then
            Healbot_Config_Skins.headtexture[skinName] = tmpMsg[15]
        elseif not Healbot_Config_Skins.headtexture[skinName] then
            Healbot_Config_Skins.headtexture[skinName] = "Smooth"
        end
        Healbot_Config_Skins.headwidth[skinName] = tonumber(tmpMsg[16])
    elseif partID==3 then
        tmpMsg[1],   tmpMsg[2],  tmpMsg[3],  tmpMsg[4],  tmpMsg[5],  tmpMsg[6],  tmpMsg[7],  tmpMsg[8],  tmpMsg[9], tmpMsg[10],
        tmpMsg[11], tmpMsg[12], tmpMsg[13], tmpMsg[14], tmpMsg[15], tmpMsg[16], tmpMsg[17], tmpMsg[18], tmpMsg[19], tmpMsg[20],
        tmpMsg[21], tmpMsg[22], tmpMsg[23], tmpMsg[24], tmpMsg[25], tmpMsg[26], tmpMsg[27], tmpMsg[28], tmpMsg[29], tmpMsg[30],
        tmpMsg[31], tmpMsg[32] = string.split("!", msg)
        if fontsIndex[tmpMsg[1]] then
            Healbot_Config_Skins.headtextfont[skinName] = tmpMsg[1]
        elseif not Healbot_Config_Skins.headtextfont[skinName] then
            Healbot_Config_Skins.headtextfont[skinName] = "Friz Quadrata TT"
        end        
        Healbot_Config_Skins.headtextheight[skinName] = tonumber(tmpMsg[2])
        Healbot_Config_Skins.ShowAggro[skinName] = tonumber(tmpMsg[3])
        Healbot_Config_Skins.ShowAggroBars[skinName] = tonumber(tmpMsg[4])
        Healbot_Config_Skins.ShowAggroText[skinName] = tonumber(tmpMsg[5])
        Healbot_Config_Skins.UseFluidBars[skinName] = tonumber(tmpMsg[6])
        Healbot_Config_Skins.BarFreq[skinName] = tonumber(tmpMsg[7])
        Healbot_Config_Skins.ShowHoTicons[skinName] = tonumber(tmpMsg[8])
        Healbot_Config_Skins.ShowRaidIcon[skinName] = tonumber(tmpMsg[9])
        Healbot_Config_Skins.ShowDebuffIcon[skinName] = tonumber(tmpMsg[10])
        Healbot_Config_Skins.HoTonBar[skinName] = tonumber(tmpMsg[11])
        Healbot_Config_Skins.HoTposBar[skinName] = tonumber(tmpMsg[12])
        Healbot_Config_Skins.HoTx2Bar[skinName] = 0
        Healbot_Config_Skins.ShowClassOnBar[skinName] = tonumber(tmpMsg[13])
        Healbot_Config_Skins.ShowClassType[skinName] = tonumber(tmpMsg[14])
        Healbot_Config_Skins.ShowNameOnBar[skinName] = tonumber(tmpMsg[15])
        Healbot_Config_Skins.ShowHealthOnBar[skinName] = tonumber(tmpMsg[16])
        Healbot_Config_Skins.BarHealthIncHeals[skinName] = tonumber(tmpMsg[17])
        Healbot_Config_Skins.BarHealthSepHeals[skinName] = tonumber(tmpMsg[18])
        Healbot_Config_Skins.BarHealthType[skinName] = tonumber(tmpMsg[19])
        Healbot_Config_Skins.SetClassColourText[skinName] = tonumber(tmpMsg[20])
        Healbot_Config_Skins.SetBarClassColour[skinName] = tonumber(tmpMsg[21])
        Healbot_Config_Skins.SetBarCustomColour[skinName] = tonumber(tmpMsg[22])
        Healbot_Config_Skins.barcolr[skinName] = tonumber(tmpMsg[23])
        Healbot_Config_Skins.barcolg[skinName] = tonumber(tmpMsg[24])
        Healbot_Config_Skins.barcolb[skinName] = tonumber(tmpMsg[25])
        Healbot_Config_Skins.ShowIconTextCount[skinName] = tonumber(tmpMsg[26])
        Healbot_Config_Skins.ShowIconTextCountSelfCast[skinName] = 0
        Healbot_Config_Skins.ShowIconTextDuration[skinName] = tonumber(tmpMsg[27])
        Healbot_Config_Skins.ShowIconTextDurationSelfCast[skinName] = 1
        Healbot_Config_Skins.IconScale[skinName] = tonumber(tmpMsg[28])
        Healbot_Config_Skins.IconTextScale[skinName] = tonumber(tmpMsg[29])
        Healbot_Config_Skins.AggroBarSize[skinName] = tonumber(tmpMsg[30])
        Healbot_Config_Skins.DoubleText[skinName] = tonumber(tmpMsg[31])
        Healbot_Config_Skins.TextAlignment[skinName] = tonumber(tmpMsg[32])
    elseif partID==4 then
        tmpMsg[1],   tmpMsg[2],  tmpMsg[3],  tmpMsg[4],  tmpMsg[5],  tmpMsg[6],  tmpMsg[7],  tmpMsg[8],  tmpMsg[9], tmpMsg[10],
        tmpMsg[11], tmpMsg[12], tmpMsg[13], tmpMsg[14], tmpMsg[15], tmpMsg[16], tmpMsg[17], tmpMsg[18], tmpMsg[19], tmpMsg[20],
        tmpMsg[21], tmpMsg[22], tmpMsg[23], tmpMsg[24], tmpMsg[25], tmpMsg[26], tmpMsg[27] = string.split("!", msg)
        Healbot_Config_Skins.HighLightActiveBar[skinName] = tonumber(tmpMsg[1])
        Healbot_Config_Skins.highcolr[skinName] = tonumber(tmpMsg[2])
        Healbot_Config_Skins.highcolg[skinName] = tonumber(tmpMsg[3])
        Healbot_Config_Skins.highcolb[skinName] = tonumber(tmpMsg[4])
        Healbot_Config_Skins.GroupsPerCol[skinName] = tonumber(tmpMsg[5])
        Healbot_Config_Skins.headhight[skinName] = tonumber(tmpMsg[6])
        Healbot_Config_Skins.SelfHeals[skinName] = tonumber(tmpMsg[7])
        Healbot_Config_Skins.PetHeals[skinName] = tonumber(tmpMsg[8])
        Healbot_Config_Skins.GroupHeals[skinName] = tonumber(tmpMsg[9])
        Healbot_Config_Skins.TankHeals[skinName] = tonumber(tmpMsg[10])
        Healbot_Config_Skins.SelfPet[skinName] = tonumber(tmpMsg[11])
        Healbot_Config_Skins.EmergencyHeals[skinName] = tonumber(tmpMsg[12])
        Healbot_Config_Skins.SetFocusBar[skinName] = tonumber(tmpMsg[13])
        Healbot_Config_Skins.VehicleHeals[skinName] = tonumber(tmpMsg[14])
        Healbot_Config_Skins.ShowMyTargetsList[skinName] = tonumber(tmpMsg[15])
        Healbot_Config_Skins.TargetHeals[skinName] = tonumber(tmpMsg[16])
        Healbot_Config_Skins.TargetIncSelf[skinName] = tonumber(tmpMsg[17])
        Healbot_Config_Skins.TargetIncGroup[skinName] = tonumber(tmpMsg[18])
        Healbot_Config_Skins.TargetIncRaid[skinName] = tonumber(tmpMsg[19])
        Healbot_Config_Skins.TargetIncPet[skinName] = tonumber(tmpMsg[20])
        Healbot_Config_Skins.TargetBarNormalMode[skinName] = tonumber(tmpMsg[21])
        Healbot_Config_Skins.AlertLevel[skinName] = tonumber(tmpMsg[22])
        Healbot_Config_Skins.NotVisibleDisable[skinName] = tonumber(tmpMsg[23])
        Healbot_Config_Skins.HidePartyFrames[skinName] = tonumber(tmpMsg[24])
        Healbot_Config_Skins.HidePlayerTarget[skinName] = tonumber(tmpMsg[25])
        Healbot_Config_Skins.CastNotify[skinName] = tonumber(tmpMsg[26])
        Healbot_Config_Skins.NotifyChan[skinName] = tmpMsg[27]
    elseif partID==5 then
        Healbot_Config_Skins.NotifyHealMsg[skinName],
        Healbot_Config_Skins.NotifyOtherMsg[skinName] = string.split("!", msg)
    elseif partID==6 then
        tmpMsg[1],   tmpMsg[2],  tmpMsg[3],  tmpMsg[4],  tmpMsg[5],  tmpMsg[6],  tmpMsg[7],  tmpMsg[8],  tmpMsg[9], tmpMsg[10],
        tmpMsg[11], tmpMsg[12], tmpMsg[13], tmpMsg[14], tmpMsg[15], tmpMsg[16], tmpMsg[17], tmpMsg[18], tmpMsg[19], tmpMsg[20],
        tmpMsg[21], tmpMsg[22], tmpMsg[23], tmpMsg[24], tmpMsg[25], tmpMsg[26], tmpMsg[27], tmpMsg[28], tmpMsg[29], tmpMsg[30],
        tmpMsg[31], tmpMsg[32], tmpMsg[33] = string.split("!", msg)
        Healbot_Config_Skins.CastNotifyResOnly[skinName] = tonumber(tmpMsg[1])
        Healbot_Config_Skins.ShowIncHeals[skinName] = tonumber(tmpMsg[2])
        Healbot_Config_Skins.incHealDur[skinName] = { D = tonumber(tmpMsg[3]), H = tonumber(tmpMsg[4]), C = tonumber(tmpMsg[5]) }
        Healbot_Config_Skins.EmergIncMonitor[skinName] = tonumber(tmpMsg[6])
        Healbot_Config_Skins.ExtraOrder[skinName] = tonumber(tmpMsg[7])
        Healbot_Config_Skins.ExtraSubOrder[skinName] = tonumber(tmpMsg[8])
        Healbot_Config_Skins.SubSortIncGroup[skinName] = tonumber(tmpMsg[9])
        Healbot_Config_Skins.SubSortIncPet[skinName] = tonumber(tmpMsg[10])
        Healbot_Config_Skins.SubSortIncVehicle[skinName] = tonumber(tmpMsg[11])
        Healbot_Config_Skins.SubSortIncTanks[skinName] = tonumber(tmpMsg[12])
        Healbot_Config_Skins.SubSortIncMyTargets[skinName] = tonumber(tmpMsg[13])
        Healbot_Config_Skins.Panel_Anchor[skinName] = tonumber(tmpMsg[14])
        Healbot_Config_Skins.ExtraIncGroup[skinName] = {}
        for x=1,8 do
            z=x+14
            if tmpMsg[z]=="0" then
                Healbot_Config_Skins.ExtraIncGroup[skinName][x] = false
            else
                Healbot_Config_Skins.ExtraIncGroup[skinName][x] = true
            end
        end
        Healbot_Config_Skins.ActionLocked[skinName] = tonumber(tmpMsg[23])
        Healbot_Config_Skins.AutoClose[skinName] = tonumber(tmpMsg[24])
        Healbot_Config_Skins.PanelSounds[skinName] = tonumber(tmpMsg[25])
        Healbot_Config_Skins.ShowRaidIconStar[skinName] = tonumber(tmpMsg[26])
        Healbot_Config_Skins.ShowRaidIconCircle[skinName] = tonumber(tmpMsg[27])
        Healbot_Config_Skins.ShowRaidIconDiamond[skinName] = tonumber(tmpMsg[28])
        Healbot_Config_Skins.ShowRaidIconTriangle[skinName] = tonumber(tmpMsg[29])
        Healbot_Config_Skins.ShowRaidIconMoon[skinName] = tonumber(tmpMsg[30])
        Healbot_Config_Skins.ShowRaidIconSquare[skinName] = tonumber(tmpMsg[31])
        Healbot_Config_Skins.ShowRaidIconCross[skinName] = tonumber(tmpMsg[32])
        Healbot_Config_Skins.ShowRaidIconSkull[skinName] = tonumber(tmpMsg[33])
    end
end

function HealBot_Option_WarnPossibleNoSharedMedia()
    if not hbWarnSharedMedia then
        HealBot_AddChat(HEALBOT_CHAT_ADDONID..HEALBOT_CHAT_POSSIBLEMISSINGMEDIA)
        hbWarnSharedMedia=true
    end
end

--------------------------------------------------------------------------------

local HealBot_Options_TooltipPos_List = {
    HEALBOT_TOOLTIP_POSDEFAULT,
    HEALBOT_TOOLTIP_POSLEFT,
    HEALBOT_TOOLTIP_POSRIGHT,
    HEALBOT_TOOLTIP_POSABOVE,
    HEALBOT_TOOLTIP_POSBELOW,
    HEALBOT_TOOLTIP_POSCURSOR,
}

function HealBot_Options_TooltipPos_DropDown()
    for j=1, getn(HealBot_Options_TooltipPos_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_TooltipPos_List[j];
        info.func = HealBot_Options_TooltipPos_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_TooltipPos_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_TooltipPos,HealBot_Options_TooltipPos_DropDown)
end

function HealBot_Options_TooltipPos_Refresh(onselect)
    if not HealBot_Config.TooltipPos then return end
    if not onselect then HealBot_Options_TooltipPos_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_TooltipPos,HealBot_Config.TooltipPos)
end

function HealBot_Options_TooltipPos_OnLoad(self)
 --   HealBot_Options_TooltipPos_Initialize()
    UIDropDownMenu_SetWidth(self,128)
end

function HealBot_Options_TooltipPos_OnSelect()
    HealBot_Config.TooltipPos = this:GetID()
    HealBot_Options_TooltipPos_Refresh(true)
end

--------------------------------------------------------------------------------

local specDdId = nil
function HealBot_Options_BuffTxt1_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt1_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt1_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt2_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt2_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt2_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt3_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt3_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt3_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt4_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt4_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt4_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt5_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt5_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt5_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt6_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt6_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt6_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt7_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt7_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt7_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt8_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt8_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt8_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt9_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt9_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt9_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt10_DropDown()
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_BuffTxt10_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(HealBot_Buff_Spells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Buff_Spells_List[j];
        info.func = HealBot_Options_BuffTxt10_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups1_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups1_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups2_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups2_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups3_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups3_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups4_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups4_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups5_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups5_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups6_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups6_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups7_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups7_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups8_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups8_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups9_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups9_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffGroups10_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_BuffGroups10_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_BuffTxt1_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt1,HealBot_Options_BuffTxt1_DropDown)
end

function HealBot_Options_BuffTxt2_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt2,HealBot_Options_BuffTxt2_DropDown)
end

function HealBot_Options_BuffTxt3_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt3,HealBot_Options_BuffTxt3_DropDown)
end

function HealBot_Options_BuffTxt4_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt4,HealBot_Options_BuffTxt4_DropDown)
end

function HealBot_Options_BuffTxt5_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt5,HealBot_Options_BuffTxt5_DropDown)
end

function HealBot_Options_BuffTxt6_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt6,HealBot_Options_BuffTxt6_DropDown)
end

function HealBot_Options_BuffTxt7_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt7,HealBot_Options_BuffTxt7_DropDown)
end

function HealBot_Options_BuffTxt8_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt8,HealBot_Options_BuffTxt8_DropDown)
end

function HealBot_Options_BuffTxt9_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt9,HealBot_Options_BuffTxt9_DropDown)
end

function HealBot_Options_BuffTxt10_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffTxt10,HealBot_Options_BuffTxt10_DropDown)
end

function HealBot_Options_BuffGroups1_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups1,HealBot_Options_BuffGroups1_DropDown)
end

function HealBot_Options_BuffGroups2_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups2,HealBot_Options_BuffGroups2_DropDown)
end

function HealBot_Options_BuffGroups3_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups3,HealBot_Options_BuffGroups3_DropDown)
end

function HealBot_Options_BuffGroups4_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups4,HealBot_Options_BuffGroups4_DropDown)
end

function HealBot_Options_BuffGroups5_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups5,HealBot_Options_BuffGroups5_DropDown)
end

function HealBot_Options_BuffGroups6_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups6,HealBot_Options_BuffGroups6_DropDown)
end

function HealBot_Options_BuffGroups7_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups7,HealBot_Options_BuffGroups7_DropDown)
end

function HealBot_Options_BuffGroups8_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups8,HealBot_Options_BuffGroups8_DropDown)
end

function HealBot_Options_BuffGroups9_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups9,HealBot_Options_BuffGroups9_DropDown)
end

function HealBot_Options_BuffGroups10_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_BuffGroups10,HealBot_Options_BuffGroups10_DropDown)
end

local BuffSpellDropDownClass=nil
function HealBot_Options_BuffTxt1_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(1)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(1)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt1_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt1,BuffTextClass[HealBot_Options_getDropDownId_bySpec(1)])
end

function HealBot_Options_BuffTxt2_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(2)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(2)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt2_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt2,BuffTextClass[HealBot_Options_getDropDownId_bySpec(2)])
end

function HealBot_Options_BuffTxt3_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(3)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(3)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt3_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt3,BuffTextClass[HealBot_Options_getDropDownId_bySpec(3)])
end

function HealBot_Options_BuffTxt4_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(4)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(4)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt4_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt4,BuffTextClass[HealBot_Options_getDropDownId_bySpec(4)])
end

function HealBot_Options_BuffTxt5_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(5)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(5)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt5_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt5,BuffTextClass[HealBot_Options_getDropDownId_bySpec(5)])
end

function HealBot_Options_BuffTxt6_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(6)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(6)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt6_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt6,BuffTextClass[HealBot_Options_getDropDownId_bySpec(6)])
end

function HealBot_Options_BuffTxt7_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(7)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(7)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt7_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt7,BuffTextClass[HealBot_Options_getDropDownId_bySpec(7)])
end

function HealBot_Options_BuffTxt8_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(8)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(8)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt8_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt8,BuffTextClass[HealBot_Options_getDropDownId_bySpec(8)])
end

function HealBot_Options_BuffTxt9_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(9)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(9)]=HEALBOT_WORDS_NONE end;
    if not onselect then HealBot_Options_BuffTxt9_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt9,BuffTextClass[HealBot_Options_getDropDownId_bySpec(9)])
end

function HealBot_Options_BuffTxt10_Refresh(onselect)
    BuffTextClass = HealBot_Config.HealBotBuffText
    if not BuffTextClass[HealBot_Options_getDropDownId_bySpec(10)] then BuffTextClass[HealBot_Options_getDropDownId_bySpec(10)]=HEALBOT_WORDS_NONE  end;
    if not onselect then HealBot_Options_BuffTxt10_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedValue(HealBot_Options_BuffTxt10,BuffTextClass[HealBot_Options_getDropDownId_bySpec(10)])
end

local BuffDropDownClass=nil
function HealBot_Options_BuffGroups1_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(1)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(1)]=4 end;
    if not onselect then HealBot_Options_BuffGroups1_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups1,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(1)])
end

function HealBot_Options_BuffGroups2_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(2)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(2)]=4 end;
    if not onselect then HealBot_Options_BuffGroups2_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups2,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(2)])
end

function HealBot_Options_BuffGroups3_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(3)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(3)]=4 end;
    if not onselect then HealBot_Options_BuffGroups3_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups3,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(3)])
end

function HealBot_Options_BuffGroups4_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(4)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(4)]=4 end;
    if not onselect then HealBot_Options_BuffGroups4_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups4,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(4)])
end

function HealBot_Options_BuffGroups5_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(5)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(5)]=4 end;
    if not onselect then HealBot_Options_BuffGroups5_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups5,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(5)])
end

function HealBot_Options_BuffGroups6_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(6)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(6)]=4 end;
    if not onselect then HealBot_Options_BuffGroups6_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups6,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(6)])
end

function HealBot_Options_BuffGroups7_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(7)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(7)]=4 end;
    if not onselect then HealBot_Options_BuffGroups7_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups7,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(7)])
end

function HealBot_Options_BuffGroups8_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(8)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(8)]=4 end;
    if not onselect then HealBot_Options_BuffGroups8_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups8,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(8)])
end

function HealBot_Options_BuffGroups9_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(9)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(9)]=4 end;
    if not onselect then HealBot_Options_BuffGroups9_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups9,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(9)])
end

function HealBot_Options_BuffGroups10_Refresh(onselect)
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    if not BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(10)] then BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(10)]=4 end;
    if not onselect then HealBot_Options_BuffGroups10_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_BuffGroups10,BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(10)])
end

function HealBot_Options_BuffTxt1_OnLoad(self)
 --   HealBot_Options_BuffTxt1_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt2_OnLoad(self)
 --   HealBot_Options_BuffTxt2_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt3_OnLoad(self)
--    HealBot_Options_BuffTxt3_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt4_OnLoad(self)
 --   HealBot_Options_BuffTxt4_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt5_OnLoad(self)
 --   HealBot_Options_BuffTxt5_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt6_OnLoad(self)
 --   HealBot_Options_BuffTxt6_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt7_OnLoad(self)
 --   HealBot_Options_BuffTxt7_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt8_OnLoad(self)
 --   HealBot_Options_BuffTxt8_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt9_OnLoad(self)
 --   HealBot_Options_BuffTxt9_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffTxt10_OnLoad(self)
 --   HealBot_Options_BuffTxt10_Initialize()
    UIDropDownMenu_SetWidth(self,175)
end

function HealBot_Options_BuffGroups1_OnLoad(self)
 --   HealBot_Options_BuffGroups1_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups2_OnLoad(self)
 --   HealBot_Options_BuffGroups2_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups3_OnLoad(self)
 --   HealBot_Options_BuffGroups3_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups4_OnLoad(self)
  --  HealBot_Options_BuffGroups4_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups5_OnLoad(self)
 --   HealBot_Options_BuffGroups5_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups6_OnLoad(self)
 --   HealBot_Options_BuffGroups6_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups7_OnLoad(self)
 --   HealBot_Options_BuffGroups7_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups8_OnLoad(self)
 --  HealBot_Options_BuffGroups8_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups9_OnLoad(self)
 --   HealBot_Options_BuffGroups9_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffGroups10_OnLoad(self)
 --   HealBot_Options_BuffGroups10_Initialize()
    UIDropDownMenu_SetWidth(self,95)
end

function HealBot_Options_BuffTxt1_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(1)] = this:GetText()
    HealBot_Options_BuffTxt1_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt2_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(2)] = this:GetText()
    HealBot_Options_BuffTxt2_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt3_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(3)] = this:GetText()
    HealBot_Options_BuffTxt3_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt4_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(4)] = this:GetText()
    HealBot_Options_BuffTxt4_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt5_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(5)] = this:GetText()
    HealBot_Options_BuffTxt5_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt6_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(6)] = this:GetText()
    HealBot_Options_BuffTxt6_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt7_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(7)] = this:GetText()
    HealBot_Options_BuffTxt7_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt8_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(8)] = this:GetText()
    HealBot_Options_BuffTxt8_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt9_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(9)] = this:GetText()
    HealBot_Options_BuffTxt9_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffTxt10_OnSelect()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffTextClass[HealBot_Options_getDropDownId_bySpec(10)] = this:GetText()
    HealBot_Options_BuffTxt10_Refresh(true)
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups1_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(1)] = this:GetID()
    HealBot_Options_BuffGroups1_Refresh(true)
    ClickedBuffGroupDD=1
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups2_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(2)] = this:GetID()
    HealBot_Options_BuffGroups2_Refresh(true)
    ClickedBuffGroupDD=2
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups3_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(3)] = this:GetID()
    HealBot_Options_BuffGroups3_Refresh(true)
    ClickedBuffGroupDD=3
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups4_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(4)] = this:GetID()
    HealBot_Options_BuffGroups4_Refresh(true)
    ClickedBuffGroupDD=4
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups5_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(5)] = this:GetID()
    HealBot_Options_BuffGroups5_Refresh(true)
    ClickedBuffGroupDD=5
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups6_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(6)] = this:GetID()
    HealBot_Options_BuffGroups6_Refresh(true)
    ClickedBuffGroupDD=6
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups7_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(7)] = this:GetID()
    HealBot_Options_BuffGroups7_Refresh(true)
    ClickedBuffGroupDD=7
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups8_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(8)] = this:GetID()
    HealBot_Options_BuffGroups8_Refresh(true)
    ClickedBuffGroupDD=8
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups9_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(9)] = this:GetID()
    HealBot_Options_BuffGroups9_Refresh(true)
    ClickedBuffGroupDD=9
    HealBot_setOptions_Timer(40)
end

function HealBot_Options_BuffGroups10_OnSelect()
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(10)] = this:GetID()
    HealBot_Options_BuffGroups10_Refresh(true)
    ClickedBuffGroupDD=10
    HealBot_setOptions_Timer(40)
end
--------------------------------------------------------------------------------

local HealBot_Options_ComboClass_List = {
    HEALBOT_DRUID,
    HEALBOT_PALADIN,
    HEALBOT_PRIEST,
    HEALBOT_SHAMAN,
}

local HealBot_Debuff_Item_List = {
    HEALBOT_PURIFICATION_POTION,
    HEALBOT_ELIXIR_OF_POISON_RES,
    HEALBOT_ANTI_VENOM,
    HEALBOT_POWERFUL_ANTI_VENOM,
}

function HealBot_Options_GetDebuffSpells_List(class)
    return HealBot_Debuff_Spells[class]
end

function HealBot_Options_GetRacialDebuffSpells_List(race)
    return HealBot_Racial_Debuff_Spells[race]
end

local DebuffSpells_List=nil
local RacialDebuffSpells_List=nil
function HealBot_Options_CDCTxt1_DropDown()
    DebuffSpells_List = HealBot_Options_GetDebuffSpells_List(strsub(HealBot_PlayerClassEN,1,4))
    RacialDebuffSpells_List = HealBot_Options_GetRacialDebuffSpells_List(strsub(HealBot_PlayerRaceEN,1,3))
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_CDCTxt1_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(DebuffSpells_List), 1 do
        sName, _=HealBot_GetSpellName(HealBot_GetSpellId(DebuffSpells_List[j]));
        if sName then
            for x,_ in pairs(info) do
                info[x]=nil;
            end
            info.text = sName;
            info.func = HealBot_Options_CDCTxt1_OnSelect;
            UIDropDownMenu_AddButton(info);
        end
    end
    for j=1, getn(RacialDebuffSpells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = RacialDebuffSpells_List[j];
        info.func = HealBot_Options_CDCTxt1_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
    for j=1, getn(HealBot_Debuff_Item_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Debuff_Item_List[j];
        info.func = HealBot_Options_CDCTxt1_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_CDCTxt2_DropDown()
    DebuffSpells_List = HealBot_Options_GetDebuffSpells_List(strsub(HealBot_PlayerClassEN,1,4))
    RacialDebuffSpells_List = HealBot_Options_GetRacialDebuffSpells_List(strsub(HealBot_PlayerRaceEN,1,3))
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_CDCTxt2_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(DebuffSpells_List), 1 do
        sName, _=HealBot_GetSpellName(HealBot_GetSpellId(DebuffSpells_List[j]));
        if sName then
            for x,_ in pairs(info) do
                info[x]=nil;
            end
            info.text = sName;
            info.func = HealBot_Options_CDCTxt2_OnSelect;
            UIDropDownMenu_AddButton(info);
        end
    end
    for j=1, getn(RacialDebuffSpells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = RacialDebuffSpells_List[j];
        info.func = HealBot_Options_CDCTxt2_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
    for j=1, getn(HealBot_Debuff_Item_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Debuff_Item_List[j];
        info.func = HealBot_Options_CDCTxt2_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_CDCTxt3_DropDown()
    DebuffSpells_List = HealBot_Options_GetDebuffSpells_List(strsub(HealBot_PlayerClassEN,1,4))
    RacialDebuffSpells_List = HealBot_Options_GetRacialDebuffSpells_List(strsub(HealBot_PlayerRaceEN,1,3))
    for x,_ in pairs(info) do
        info[x]=nil;
    end
    info.text = HEALBOT_WORDS_NONE;
    info.func = HealBot_Options_CDCTxt3_OnSelect;
    UIDropDownMenu_AddButton(info);
    for j=1, getn(DebuffSpells_List), 1 do
        sName, _=HealBot_GetSpellName(HealBot_GetSpellId(DebuffSpells_List[j]));
        if sName then
            for x,_ in pairs(info) do
                info[x]=nil;
            end
            info.text = sName;
            info.func = HealBot_Options_CDCTxt3_OnSelect;
            UIDropDownMenu_AddButton(info);
        end
    end
    for j=1, getn(RacialDebuffSpells_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = RacialDebuffSpells_List[j];
        info.func = HealBot_Options_CDCTxt3_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
    for j=1, getn(HealBot_Debuff_Item_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Debuff_Item_List[j];
        info.func = HealBot_Options_CDCTxt3_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_CDCGroups1_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_CDCGroups1_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_CDCGroups2_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_CDCGroups2_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_CDCGroups3_DropDown()
    for j=1, getn(HealBot_Options_BuffTxt_List), 1 do
        for x,_ in pairs(info) do
            info[x]=nil;
        end   
        info.text = HealBot_Options_BuffTxt_List[j];
        info.func = HealBot_Options_CDCGroups3_OnSelect;
        UIDropDownMenu_AddButton(info);
    end
end

function HealBot_Options_CDCTxt1_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_CDCTxt1,HealBot_Options_CDCTxt1_DropDown)
end

function HealBot_Options_CDCTxt2_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_CDCTxt2,HealBot_Options_CDCTxt2_DropDown)
end

function HealBot_Options_CDCTxt3_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_CDCTxt3,HealBot_Options_CDCTxt3_DropDown)
end

function HealBot_Options_CDCGroups1_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_CDCGroups1,HealBot_Options_CDCGroups1_DropDown)
end

function HealBot_Options_CDCGroups2_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_CDCGroups2,HealBot_Options_CDCGroups2_DropDown)
end

function HealBot_Options_CDCGroups3_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_CDCGroups3,HealBot_Options_CDCGroups3_DropDown)
end

local DebuffSpellDropDownClass=nil
function HealBot_Options_CDCTxt1_Refresh(onselect)
    DebuffTextClass = HealBot_Config.HealBotDebuffText
    if not DebuffTextClass[HealBot_Options_getDropDownId_bySpec(1)] then return; end
    if not onselect then HealBot_Options_CDCTxt1_Initialize() end 
    UIDropDownMenu_SetSelectedValue(HealBot_Options_CDCTxt1,DebuffTextClass[HealBot_Options_getDropDownId_bySpec(1)])
end

function HealBot_Options_CDCTxt2_Refresh(onselect)
    DebuffTextClass = HealBot_Config.HealBotDebuffText
    if not DebuffTextClass[HealBot_Options_getDropDownId_bySpec(2)] then return; end
    if not onselect then HealBot_Options_CDCTxt2_Initialize() end 
    UIDropDownMenu_SetSelectedValue(HealBot_Options_CDCTxt2,DebuffTextClass[HealBot_Options_getDropDownId_bySpec(2)])
end

function HealBot_Options_CDCTxt3_Refresh(onselect)
    DebuffTextClass = HealBot_Config.HealBotDebuffText
    if not DebuffTextClass[HealBot_Options_getDropDownId_bySpec(3)] then return; end
    if not onselect then HealBot_Options_CDCTxt3_Initialize() end 
    UIDropDownMenu_SetSelectedValue(HealBot_Options_CDCTxt3,DebuffTextClass[HealBot_Options_getDropDownId_bySpec(3)])
end

local DebuffDropDownClass=nil
function HealBot_Options_CDCGroups1_Refresh(onselect)
    DebuffDropDownClass = HealBot_Config.HealBotDebuffDropDown
    if not DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(1)] then return end;
    if not onselect then HealBot_Options_CDCGroups1_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_CDCGroups1,DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(1)])
end

function HealBot_Options_CDCGroups2_Refresh(onselect)
    DebuffDropDownClass = HealBot_Config.HealBotDebuffDropDown
    if not DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(2)] then return end;
    if not onselect then HealBot_Options_CDCGroups2_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_CDCGroups2,DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(2)])
end

function HealBot_Options_CDCGroups3_Refresh(onselect)
    DebuffDropDownClass = HealBot_Config.HealBotDebuffDropDown
    if not DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(3)] then return end;
    if not onselect then HealBot_Options_CDCGroups3_Initialize() end  -- or wrong menu may be used !
    UIDropDownMenu_SetSelectedID(HealBot_Options_CDCGroups3,DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(3)])
end

local combo=nil
local button=nil
function HealBot_Options_ComboClass_Text()
    button = HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button)
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledKeyCombo;
    else
        combo = HealBot_Config.DisabledKeyCombo;
    end
    if combo then
        HealBot_Options_Click:SetText(combo[button..HealBot_Config.CurrentSpec] or "")
        HealBot_Options_Shift:SetText(combo["Shift"..button..HealBot_Config.CurrentSpec] or "")
        HealBot_Options_Ctrl:SetText(combo["Ctrl"..button..HealBot_Config.CurrentSpec] or "")
        HealBot_Options_Alt:SetText(combo["Alt"..button..HealBot_Config.CurrentSpec] or "")
        HealBot_Options_AltShift:SetText(combo["Alt-Shift"..button..HealBot_Config.CurrentSpec] or "")
        HealBot_Options_CtrlShift:SetText(combo["Ctrl-Shift"..button..HealBot_Config.CurrentSpec] or "")
    end
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledSpellTarget;
    else
        combo = HealBot_Config.DisabledSpellTarget;
    end
    if combo then
        HealBot_SpellAutoTarget:SetChecked(combo[button..HealBot_Config.CurrentSpec] or 0)
        HealBot_ShiftSpellAutoTarget:SetChecked(combo["Shift"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_CtrlSpellAutoTarget:SetChecked(combo["Ctrl"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_AltSpellAutoTarget:SetChecked(combo["Alt"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_AltShiftSpellAutoTarget:SetChecked(combo["Alt-Shift"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_CtrlShiftSpellAutoTarget:SetChecked(combo["Ctrl-Shift"..button..HealBot_Config.CurrentSpec] or 0)
    end
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledSpellTrinket1;
    else
        combo = HealBot_Config.DisabledSpellTrinket1;
    end
    if combo then
        HealBot_SpellAutoTrinket1:SetChecked(combo[button..HealBot_Config.CurrentSpec] or 0)
        HealBot_ShiftSpellAutoTrinket1:SetChecked(combo["Shift"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_CtrlSpellAutoTrinket1:SetChecked(combo["Ctrl"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_AltSpellAutoTrinket1:SetChecked(combo["Alt"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_AltShiftSpellAutoTrinket1:SetChecked(combo["Alt-Shift"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_CtrlShiftSpellAutoTrinket1:SetChecked(combo["Ctrl-Shift"..button..HealBot_Config.CurrentSpec] or 0)
    end
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledSpellTrinket2;
    else
        combo = HealBot_Config.DisabledSpellTrinket2;
    end
    if combo then
        HealBot_SpellAutoTrinket2:SetChecked(combo[button..HealBot_Config.CurrentSpec] or 0)
        HealBot_ShiftSpellAutoTrinket2:SetChecked(combo["Shift"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_CtrlSpellAutoTrinket2:SetChecked(combo["Ctrl"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_AltSpellAutoTrinket2:SetChecked(combo["Alt"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_AltShiftSpellAutoTrinket2:SetChecked(combo["Alt-Shift"..button..HealBot_Config.CurrentSpec] or 0)
        HealBot_CtrlShiftSpellAutoTrinket2:SetChecked(combo["Ctrl-Shift"..button..HealBot_Config.CurrentSpec] or 0)
    end
end

function HealBot_Options_CDCTxt1_OnLoad(self)
    UIDropDownMenu_SetWidth(self,180)
 --   HealBot_Options_CDCTxt1_Initialize()
end

function HealBot_Options_CDCTxt2_OnLoad(self)
    UIDropDownMenu_SetWidth(self,180)
  --  HealBot_Options_CDCTxt2_Initialize()
end

function HealBot_Options_CDCTxt3_OnLoad(self)
    UIDropDownMenu_SetWidth(self,180)
   -- HealBot_Options_CDCTxt3_Initialize()
end

function HealBot_Options_CDCGroups1_OnLoad(self)
    UIDropDownMenu_SetWidth(self,110)
  --  HealBot_Options_CDCGroups1_Initialize()
end

function HealBot_Options_CDCGroups2_OnLoad(self)
    UIDropDownMenu_SetWidth(self,110)
  --  HealBot_Options_CDCGroups2_Initialize()
end

function HealBot_Options_CDCGroups3_OnLoad(self)
    UIDropDownMenu_SetWidth(self,110)
  --  HealBot_Options_CDCGroups3_Initialize()
end

local DebuffTextClass=nil
function HealBot_Options_CDCTxt1_OnSelect()
    DebuffTextClass = HealBot_Config.HealBotDebuffText
    DebuffTextClass[HealBot_Options_getDropDownId_bySpec(1)] = this:GetText()
    HealBot_Options_CDCTxt1_Refresh(true)
    HealBot_setOptions_Timer(50)
end

function HealBot_Options_CDCTxt2_OnSelect()
    DebuffTextClass = HealBot_Config.HealBotDebuffText
    DebuffTextClass[HealBot_Options_getDropDownId_bySpec(2)] = this:GetText()
    HealBot_Options_CDCTxt2_Refresh(true)
    HealBot_setOptions_Timer(50)
end

function HealBot_Options_CDCTxt3_OnSelect()
    DebuffTextClass = HealBot_Config.HealBotDebuffText
    DebuffTextClass[HealBot_Options_getDropDownId_bySpec(3)] = this:GetText()
    HealBot_Options_CDCTxt3_Refresh(true)
    HealBot_setOptions_Timer(50)
end

function HealBot_Options_CDCGroups1_OnSelect()
    DebuffDropDownClass = HealBot_Config.HealBotDebuffDropDown
    DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(1)] = this:GetID()
    HealBot_Options_CDCGroups1_Refresh(true)
    ClickedBuffGroupDD=1
    HealBot_setOptions_Timer(50)
end

function HealBot_Options_CDCGroups2_OnSelect()
    DebuffDropDownClass = HealBot_Config.HealBotDebuffDropDown
    DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(2)] = this:GetID()
    HealBot_Options_CDCGroups2_Refresh(true)
    ClickedBuffGroupDD=2
    HealBot_setOptions_Timer(50)
end

function HealBot_Options_CDCGroups3_OnSelect()
    DebuffDropDownClass = HealBot_Config.HealBotDebuffDropDown
    DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(3)] = this:GetID()
    HealBot_Options_CDCGroups3_Refresh(true)
    ClickedBuffGroupDD=3
    HealBot_setOptions_Timer(50)
end

function HealBot_Options_CDebuffTxt1_DropDown() -- added by Diacono
    t = HealBot_Config.HealBot_Custom_Debuffs
    if t then
        for x,_ in pairs(t2) do
            t2[x]=nil;
        end
        table.foreach (t, function (k) table.insert (t2, k) end )
        table.sort (t2)
  
        for x,_ in pairs(info) do
            info[x]=nil;
        end

        for j=1, getn(t2), 1 do
            for x,_ in pairs(info) do
                info[x]=nil;
            end
            info.text = t2[j];
            info.func = HealBot_Options_CDebuffTxt1_OnSelect;
            UIDropDownMenu_AddButton(info);
        end
    end
end

function HealBot_Options_CDebuffTxt1_OnSelect()
    UIDropDownMenu_SetSelectedValue(HealBot_Options_CDebuffTxt1, this.value);
    HealBot_Options_DeleteCDebuffBtn:Enable();
end

function HealBot_Options_CDebuffTxt1_Initialize()
    UIDropDownMenu_Initialize(HealBot_Options_CDebuffTxt1,HealBot_Options_CDebuffTxt1_DropDown)
end

function HealBot_Options_CDebuffTxt1_OnLoad(self)
  --  HealBot_Options_CDebuffTxt1_Initialize()
    UIDropDownMenu_SetWidth(self,140)
end

function HealBot_Options_NewCDebuff_OnTextChanged(self)
    text = strtrim(self:GetText())
    if strlen(text)>0 then
        HealBot_Options_NewCDebuffBtn:Enable();
    else
        HealBot_Options_NewCDebuffBtn:Disable();
    end
end

function HealBot_Options_GetSpellInfo_OnEnterPressed(self)
    text = strtrim(self:GetText())
    if tonumber(text) then
        text = GetSpellInfo(text)
    end
    self:SetText(text or "")
end

StaticPopupDialogs["HEALBOT_OPTIONS_ERROR"] = {
    text = HEALBOT_WORDS_ERROR..": %s",
    button1 = OKAY,
    showAlert = 1,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1
};

StaticPopupDialogs["HEALBOT_OPTIONS_NEWCDEBUFF"] = {
    text = HEALBOT_OPTIONS_SAVESKIN..": %s",
    button1 = HEALBOT_WORDS_YES,
    button2 = HEALBOT_WORDS_NO,
    OnAccept = function()
        HealBot_Options_NewCDebuffBtn_OnClick(HealBot_Options_NewCDebuffBtn)
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1
};

local NewCDebuffTxt=nil
function HealBot_Options_NewCDebuffBtn_OnClick(self)
    NewCDebuffTxt=HealBot_Options_NewCDebuff:GetText()
    unique=true;
    for k, _ in pairs(HealBot_Config.HealBot_Custom_Debuffs) do
        if k==NewCDebuffTxt then unique=false; end
    end
    if unique then
        HealBot_Config.HealBot_Custom_Debuffs[NewCDebuffTxt]=true;
    end
    HealBot_Options_NewCDebuff:SetText("")
    HealBot_Options_CDebuffTxt1_Initialize()
    UIDropDownMenu_SetSelectedValue(HealBot_Options_CDebuffTxt1, NewCDebuffTxt);
end

function HealBot_Options_ConfirmNewCDebuff()
    NewCDebuffTxt=strtrim(HealBot_Options_NewCDebuff:GetText())
    HealBot_Options_NewCDebuff:SetText(NewCDebuffTxt)
    if tonumber(NewCDebuffTxt) then
        NewCDebuffTxt = GetSpellInfo(NewCDebuffTxt)
        if not NewCDebuffTxt then 
            StaticPopup_Show ("HEALBOT_OPTIONS_ERROR", HEALBOT_SPELL_NOT_FOUND);
        else
            HealBot_Options_NewCDebuff:SetText(NewCDebuffTxt)
        end
    end
    if NewCDebuffTxt and NewCDebuffTxt ~= "" then
        StaticPopup_Show ("HEALBOT_OPTIONS_NEWCDEBUFF", NewCDebuffTxt);
    end
end

function HealBot_Options_DeleteCDebuffBtn_OnClick(self)
    HealBot_Config.HealBot_Custom_Debuffs[HealBot_Options_CDebuffTxt1.selectedValue]=nil;
    UIDropDownMenu_ClearAll(HealBot_Options_CDebuffTxt1);
    HealBot_Options_DeleteCDebuffBtn:Disable();
    HealBot_Options_CDebuffTxt1_Initialize()
end

----------------------------------------------------------------------------------

function HealBot_Options_getDropDownId_bySpec(ddId)
    return HealBot_Config.CurrentSpec..ddId
end

function HealBot_Options_ComboClass_Button(bNo)
    if bNo==2 then 
        button = "Middle"
    elseif bNo==3 then 
        button = "Right"
    elseif bNo==4 then 
        button = "Button4"
    elseif bNo==5 then 
        button = "Button5"
    elseif bNo==6 then 
        button = "Button6"
    elseif bNo==7 then 
        button = "Button7"
    elseif bNo==8 then 
        button = "Button8"
    elseif bNo==9 then 
        button = "Button9"
    elseif bNo==10 then 
        button = "Button10"
    else 
        button = "Left"
    end
    return button;
end

local usable=nil
local HealBot_DebuffWatchTargetSpell=nil
local FirstDebuffLoad=true
function HealBot_Options_Debuff_Reset()
    HealBot_DebuffWatchTarget[HEALBOT_DISEASE_en] = {HEALBOT_DISEASE_en = {}};
    HealBot_DebuffWatchTarget[HEALBOT_POISON_en] = {HEALBOT_POISON_en = {}};
    HealBot_DebuffWatchTarget[HEALBOT_MAGIC_en] = {HEALBOT_MAGIC_en = {}};
    HealBot_DebuffWatchTarget[HEALBOT_CURSE_en] = {HEALBOT_CURSE_en = {}};
    HealBot_DebuffWatchTarget[HEALBOT_CUSTOM_en] = {HEALBOT_CUSTOM_en = {}}; -- added by Diacono
    for x,_ in pairs(HealBot_DebuffSpell) do
        HealBot_DebuffSpell[x]=nil;
    end
    HealBot_DebuffPriority = nil;
    DebuffTextClass = HealBot_Config.HealBotDebuffText
    DebuffDropDownClass = HealBot_Config.HealBotDebuffDropDown
    
    for k=1,3 do
        if DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)] and DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]>1 then
            id=HealBot_GetSpellId(DebuffTextClass[HealBot_Options_getDropDownId_bySpec(k)]);
            sName,spellrank = HealBot_GetSpellName(id);
            if not sName then
                usable, _ = IsUsableItem(DebuffTextClass[HealBot_Options_getDropDownId_bySpec(k)]);
                if usable then
                    sName=DebuffTextClass[HealBot_Options_getDropDownId_bySpec(k)];
                end
            end
            if HealBot_Debuff_Types[sName] then
                table.foreach(HealBot_Debuff_Types[sName], function (i,dName)
                    
                    if not HealBot_DebuffSpell[dName] then
                        HealBot_DebuffSpell[dName]=sName;
                    end
                    HealBot_DebuffWatchTargetSpell=HealBot_DebuffWatchTarget[dName];

                    if not HealBot_DebuffPriority then
                        HealBot_DebuffPriority=dName;
                    end
                    if DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==2 then
                        HealBot_DebuffWatchTargetSpell["Self"]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==3 then
                        HealBot_DebuffWatchTargetSpell["Party"]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==4 then
                        HealBot_DebuffWatchTargetSpell["Raid"]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==5 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==6 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==7 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==8 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==9 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==10 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==11 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==12 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==13 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==14 then
                        HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==15 then
                        if HealBot_Config.EmergIncMelee[HEALBOT_DRUID]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_HUNTER]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_MAGE]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_PALADIN]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_PRIEST]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_ROGUE]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_SHAMAN]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_WARLOCK]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_WARRIOR]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                        end
                        if HealBot_Config.EmergIncMelee[HEALBOT_DEATHKNIGHT]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                        end
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==16 then
                        if HealBot_Config.EmergIncRange[HEALBOT_DRUID]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_HUNTER]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_MAGE]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_PALADIN]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_PRIEST]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_ROGUE]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_SHAMAN]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_WARLOCK]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_WARRIOR]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                        end
                        if HealBot_Config.EmergIncRange[HEALBOT_DEATHKNIGHT]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                        end
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==17 then
                        if HealBot_Config.EmergIncHealers[HEALBOT_DRUID]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_HUNTER]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_MAGE]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_PALADIN]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_PRIEST]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_ROGUE]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_SHAMAN]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_WARLOCK]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_WARRIOR]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                        end
                        if HealBot_Config.EmergIncHealers[HEALBOT_DEATHKNIGHT]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                        end
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==18 then
                        if HealBot_Config.EmergIncCustom[HEALBOT_DRUID]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_HUNTER]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_MAGE]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_PALADIN]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_PRIEST]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_ROGUE]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_SHAMAN]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_WARLOCK]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_WARRIOR]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                        end
                        if HealBot_Config.EmergIncCustom[HEALBOT_DEATHKNIGHT]==1 then
                            HealBot_DebuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                        end
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==19 then
                        HealBot_DebuffWatchTargetSpell["PvP"]=true
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==20 then
                        HealBot_DebuffWatchTargetSpell["MainTanks"]=true
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==21 then
                        HealBot_DebuffWatchTargetSpell["MyTargets"]=true
                    elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==22 then
                        HealBot_DebuffWatchTargetSpell["Focus"]=true
					elseif DebuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==23 then
						HealBot_DebuffWatchTargetSpell["Name"]=true
                        if not FirstDebuffLoad then HealBot_Options_Get_deBuffWatchGUID(sName, "Debuff", k) end
                    end        
                end)
            end
        end
        HealBot_setOptions_Timer(20)
    end
    FirstDebuffLoad=nil
end


local spells={}
local Monitor_Buffs=nil
local HealBot_BuffWatchTargetSpell=nil
local FirstBuffLoad=true
function HealBot_Options_Buff_Reset()
    BuffTextClass = HealBot_Config.HealBotBuffText
    BuffDropDownClass = HealBot_Config.HealBotBuffDropDown
    buffbarcolrClass = HealBot_Config.HealBotBuffColR
    buffbarcolgClass = HealBot_Config.HealBotBuffColG
    buffbarcolbClass = HealBot_Config.HealBotBuffColB
    Monitor_Buffs=false;
    for x,_ in pairs(spells) do
        spells[x]=nil;
    end
    HealBot_Clear_BuffWatch()
    for x,_ in pairs(HealBot_BuffWatchTarget) do
        HealBot_BuffWatchTarget[x]=nil;
    end
    for x,_ in pairs(HealBot_buffbarcolr) do
        HealBot_buffbarcolr[x]=nil;
    end
    for x,_ in pairs(HealBot_buffbarcolg) do
        HealBot_buffbarcolg[x]=nil;
    end
    for x,_ in pairs(HealBot_buffbarcolb) do
        HealBot_buffbarcolb[x]=nil;
    end
    HealBot_Tooltip_Clear_CheckBuffs()
    
    for k=1,10 do
        if BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)] and BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]>1 then
            id=HealBot_GetSpellId(BuffTextClass[HealBot_Options_getDropDownId_bySpec(k)]);
            sName,_ = HealBot_GetSpellName(id);

            if sName then
                if not spells[sName] then
                    spells[sName]=sName;
                    HealBot_Set_BuffWatch(sName)
                    HealBot_BuffWatchTarget[sName] = {sName = {}};
                    Monitor_Buffs=true;
                end

                HealBot_BuffWatchTargetSpell=HealBot_BuffWatchTarget[sName];
                HealBot_Tooltip_CheckBuffs(sName)
        
                if BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==2 then
                    HealBot_BuffWatchTargetSpell["Self"]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==3 then
                    HealBot_BuffWatchTargetSpell["Party"]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==4 then
                    HealBot_BuffWatchTargetSpell["Raid"]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==5 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==6 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==7 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==8 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==9 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==10 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==11 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==12 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==13 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==14 then
                    HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==15 then
                    if HealBot_Config.EmergIncMelee[HEALBOT_DRUID]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_HUNTER]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_MAGE]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_PALADIN]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_PRIEST]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_ROGUE]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_SHAMAN]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_WARLOCK]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_WARRIOR]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                    end
                    if HealBot_Config.EmergIncMelee[HEALBOT_DEATHKNIGHT]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                    end
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==16 then
                    if HealBot_Config.EmergIncRange[HEALBOT_DRUID]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_HUNTER]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_MAGE]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_PALADIN]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_PRIEST]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_ROGUE]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_SHAMAN]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_WARLOCK]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_WARRIOR]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                    end
                    if HealBot_Config.EmergIncRange[HEALBOT_DEATHKNIGHT]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                    end
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==17 then
                    if HealBot_Config.EmergIncHealers[HEALBOT_DRUID]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_HUNTER]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_MAGE]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_PALADIN]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_PRIEST]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_ROGUE]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_SHAMAN]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_WARLOCK]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_WARRIOR]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                    end
                    if HealBot_Config.EmergIncHealers[HEALBOT_DEATHKNIGHT]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                    end
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==18 then
                    if HealBot_Config.EmergIncCustom[HEALBOT_DRUID]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DRUID]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_HUNTER]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_HUNTER]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_MAGE]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_MAGE]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_PALADIN]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PALADIN]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_PRIEST]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_PRIEST]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_ROGUE]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_ROGUE]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_SHAMAN]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_SHAMAN]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_WARLOCK]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARLOCK]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_WARRIOR]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_WARRIOR]]=true;
                    end
                    if HealBot_Config.EmergIncCustom[HEALBOT_DEATHKNIGHT]==1 then
                        HealBot_BuffWatchTargetSpell[HealBot_Class_En[HEALBOT_DEATHKNIGHT]]=true;
                    end
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==19 then
                    HealBot_BuffWatchTargetSpell["PvP"]=true
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==20 then
                    HealBot_BuffWatchTargetSpell["MainTanks"]=true
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==21 then
                    HealBot_BuffWatchTargetSpell["MyTargets"]=true
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==22 then
                    HealBot_BuffWatchTargetSpell["MyTargets"]=true
                elseif BuffDropDownClass[HealBot_Options_getDropDownId_bySpec(k)]==23 then
                    HealBot_BuffWatchTargetSpell["Name"]=true
                    if not FirstBuffLoad then HealBot_Options_Get_BuffWatchGUID(sName, "Buff", k) end
                end
                HealBot_buffbarcolr[sName]=buffbarcolrClass[k];
                HealBot_buffbarcolg[sName]=buffbarcolgClass[k];
                HealBot_buffbarcolb[sName]=buffbarcolbClass[k];
            end
            HealBot_setOptions_Timer(30)
        end
    end
    FirstBuffLoad=nil
end

local BuffWatchSpell=" "
StaticPopupDialogs["HEALBOT_OPTIONS_BUFFNAMEDTITLE"] = {
    text = HEALBOT_OPTIONS_BUFFNAMED.."%s",
    button1 = ACCEPT,
    button2 = CANCEL,
    OnShow = function()
        getglobal(this:GetName().."WideEditBox"):SetText(HealBot_GuessName())
    end,
    OnAccept = function()
        HealBot_Options_Set_BuffWatchGUID(getglobal(this:GetParent():GetName().."WideEditBox"):GetText())
    end,
    OnCancel = function()
        -- do nothing
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1,
    hasEditBox = 1,
    hasWideEditBox = 1,
};

local gName=nil
local gGUID=nil
local myTargets={}
function HealBot_GuessName()
    gName=nil
    gGUID=nil

    if HealBot_Config.HealBot_BuffWatchGUID[BuffWatchSpell] and (type(HealBot_Config.HealBot_BuffWatchGUID[BuffWatchSpell]) == "table") then
        tGUID=HealBot_Config.HealBot_BuffWatchGUID[BuffWatchSpell]
        for uGUID,_ in pairs(tGUID) do
            if HealBot_UnitName[uGUID] then
                if gName then
                    gName=gName..","..HealBot_UnitName[uGUID]
                else
                    gName=HealBot_UnitName[uGUID]
                end
            end
        end
    end
    
    if not gName then
        if UnitName("Target") and HealBot_UnitName[HealBot_UnitGUID("Target")] then
            gName=UnitName("Target")
        end
        for j=1,10 do
            gGUID=HealBot_retHealBot_MainTanks(j)
            if HealBot_UnitName[gGUID] then
                if gName then 
                    gName=gName..","..HealBot_UnitName[gGUID]
                else
                    gName=HealBot_UnitName[gGUID]
                end
                do break end
            end
            if not gGUID then
                do break end
            end
        end
        myTargets=HealBot_GetMyHealTargets()
        x=true
        table.foreach(myTargets, function (i,myGUID)
            if HealBot_UnitName[myGUID] then
                if gName and x then 
                    gName=gName..","..HealBot_UnitName[gGUID]
                    x=nil
                elseif x then
                    gName=HealBot_UnitName[gGUID]
                end
            end  
        end)
        if not gName then
            if UnitName("Party1") and HealBot_UnitName[UnitGUID("Party1")] then
                gName=UnitName("Party1")
            elseif UnitName("Party2") and HealBot_UnitName[UnitGUID("Party2")] then
                gName=UnitName("Party2")
            elseif UnitName("Party3") and HealBot_UnitName[UnitGUID("Party3")] then
                gName=UnitName("Party3")
            elseif UnitName("Party4") and HealBot_UnitName[UnitGUID("Party4")] then
                gName=UnitName("Party4")
            end
        end
        if gName then 
            gName=gName..","..UnitName("Player")
        else
            gName=UnitName("Player")..","..HEALBOT_SORTBY_NAME
        end
    end
       
    if not gName then gName=HEALBOT_SORTBY_NAME..","..HEALBOT_SORTBY_NAME end
    return gName
end

local BuffWatchType=nil
local BuffWatchID=nil
local Uname=nil
function HealBot_Options_Set_BuffWatchGUID(unitName)
    
    if BuffWatchType=="Buff" and HealBot_Config.HealBot_BuffWatchGUID[BuffWatchSpell] then
        tGUID=HealBot_Config.HealBot_BuffWatchGUID[BuffWatchSpell]
        if tGUID and type(tGUID)=="table" then
            for uGUID,_ in pairs(tGUID) do
                if HealBot_UnitBuff[uGUID] and HealBot_UnitBuff[uGUID]==BuffWatchSpell then
                    HealBot_UnitBuff[uGUID]=nil
                end
            end
        elseif tGUID then
            if HealBot_UnitBuff[tGUID] and HealBot_UnitBuff[tGUID]==BuffWatchSpell then
                HealBot_UnitBuff[tGUID]=nil
            end
        end
    end

    if strfind(unitName,",") then tName = HealBot_Split(unitName, ","); end
    tGUID={}

    if tName and type(tName)=="table" then
        for _,uName in pairs(tName) do
            uName=HealBot_Options_CleanName(uName)
            if HealBot_Derive_GUID_fuName(uName) then
                tinsert(tGUID, HealBot_Derive_GUID_fuName(uName));
            end
        end
    elseif tName then
        tName=HealBot_Options_CleanName(tName)
        if HealBot_Derive_GUID_fuName(tName) then
            tinsert(tGUID, HealBot_Derive_GUID_fuName(tName));
        end
    end
    
    HealBot_Config.HealBot_BuffWatchGUID[BuffWatchSpell]={}
    
    for _,uGUID in pairs(tGUID) do
        if HealBot_UnitID[uGUID] then
            HealBot_Config.HealBot_BuffWatchGUID[BuffWatchSpell][uGUID]=uGUID 
            HealBot_Queue_MyBuffsCheck(uGUID, HealBot_UnitID[uGUID])
        end
    end
end

function HealBot_Options_CleanName(unitName)
    Uname=strtrim(unitName)
    Uname=strupper(strsub(Uname, 1, 1))..strlower(strsub(Uname, 2))
    return Uname
end

function HealBot_Options_Get_BuffWatchGUID(spellName, BuffType, ddID)
    if not ClickedBuffGroupDD or ClickedBuffGroupDD~=ddID then return end
    BuffWatchSpell=spellName
    BuffWatchType=BuffType
    BuffWatchID=ddID
    StaticPopup_Show ("HEALBOT_OPTIONS_BUFFNAMEDTITLE", BuffWatchSpell);
    ClickedBuffGroupDD=nil
end

function HealBot_Options_Get_deBuffWatchGUID(spellName, BuffType, ddID)
    if not ClickedBuffGroupDD or ClickedBuffGroupDD~=ddID then return end
    BuffWatchSpell=spellName
    BuffWatchType=BuffType
    BuffWatchID=ddID
    StaticPopup_Show ("HEALBOT_OPTIONS_BUFFNAMEDTITLE", BuffWatchSpell);
    ClickedBuffGroupDD=nil
end

function HealBot_Options_RetBuffRGB(spellName)
    return HealBot_buffbarcolr[spellName],HealBot_buffbarcolg[spellName],HealBot_buffbarcolb[spellName];
end

function HealBot_Colorpick_OnClick(CDCType)
    HealBot_ColourObjWaiting=CDCType;
    HealBot_UseColourPick(HealBot_Config.CDCBarColour[CDCType].R,HealBot_Config.CDCBarColour[CDCType].G,HealBot_Config.CDCBarColour[CDCType].B, nil)
end

local R=nil
local G=nil
local B=nil
local A=nil
local setskincols=true
function HealBot_Returned_Colours(R, G, B, A)
  --R, G, B = ColorPickerFrame:GetColorRGB(); -- added by Diacono
  --A = OpacitySliderFrame:GetValue();
    if A then
        A = ((0-A)+1);
    end
    setskincols=true;
    if HealBot_ColourObjWaiting=="En" then
        Healbot_Config_Skins.btextenabledcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.btextenabledcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.btextenabledcolb[Healbot_Config_Skins.Current_Skin], 
        Healbot_Config_Skins.btextenabledcola[Healbot_Config_Skins.Current_Skin] = R, G, B, A;
    elseif HealBot_ColourObjWaiting=="Dis" then
        Healbot_Config_Skins.btextdisbledcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.btextdisbledcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.btextdisbledcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.btextdisbledcola[Healbot_Config_Skins.Current_Skin] = R, G, B, A;
    elseif HealBot_ColourObjWaiting=="Debuff" then
        Healbot_Config_Skins.btextcursecolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.btextcursecolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.btextcursecolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.btextcursecola[Healbot_Config_Skins.Current_Skin] = R, G, B, A;
    elseif HealBot_ColourObjWaiting=="Back" then
        Healbot_Config_Skins.backcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.backcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.backcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.backcola[Healbot_Config_Skins.Current_Skin] = R, G, B, A;
    elseif HealBot_ColourObjWaiting=="Bor" then
        Healbot_Config_Skins.borcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.borcola[Healbot_Config_Skins.Current_Skin] = R, G, B, A;
    elseif HealBot_ColourObjWaiting=="HeadB" then
        Healbot_Config_Skins.headbarcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headbarcola[Healbot_Config_Skins.Current_Skin] = R, G, B, A;
        HealBot_setOptions_Timer(150)
    elseif HealBot_ColourObjWaiting=="HeadT" then
        Healbot_Config_Skins.headtxtcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headtxtcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headtxtcolb[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.headtxtcola[Healbot_Config_Skins.Current_Skin] = R, G, B, A;
        HealBot_setOptions_Timer(150)
    elseif HealBot_ColourObjWaiting=="CustomBar" then
        Healbot_Config_Skins.barcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.barcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.barcolb[Healbot_Config_Skins.Current_Skin] = R, G, B;
        HealBot_Action_ResetUnitStatus()
    elseif HealBot_ColourObjWaiting=="HighlightBar" then
        Healbot_Config_Skins.highcolr[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.highcolg[Healbot_Config_Skins.Current_Skin],
        Healbot_Config_Skins.highcolb[Healbot_Config_Skins.Current_Skin] = R, G, B;
        HealBot_Action_SetHightlightAggroCols()
    elseif strsub(HealBot_ColourObjWaiting ,1,4)=="Buff" then
        id=tonumber(strsub(HealBot_ColourObjWaiting ,5));
        buffbarcolrClass = HealBot_Config.HealBotBuffColR
        buffbarcolgClass = HealBot_Config.HealBotBuffColG
        buffbarcolbClass = HealBot_Config.HealBotBuffColB
        buffbarcolrClass[id],
        buffbarcolgClass[id],
        buffbarcolbClass[id] = R, G, B;
        HealBot_setOptions_Timer(100)
        setskincols=false;
    else
        HealBot_Config.CDCBarColour[HealBot_ColourObjWaiting].R,
        HealBot_Config.CDCBarColour[HealBot_ColourObjWaiting].G,
        HealBot_Config.CDCBarColour[HealBot_ColourObjWaiting].B = R, G, B;
        HealBot_SetCDCBarColours();
        setskincols=false;
    end
    if setskincols then
        HealBot_setOptions_Timer(90)
    end
end

local prevR, prevG, prevB, prevA=nil,nil,nil,nil
function HealBot_UseColourPick(R, G, B, A)
    if not R then R=1 end
    if not G then G=1 end
    if not B then B=1 end
    prevR, prevG, prevB, prevA = R, G, B, A;
    if ColorPickerFrame:IsVisible() then 
        ColorPickerFrame:Hide();
    elseif A then
        ColorPickerFrame.hasOpacity = true;
        ColorPickerFrame.opacity = 1-A;
        ColorPickerFrame.func = function() local r,g,b=ColorPickerFrame:GetColorRGB(); local a=OpacitySliderFrame:GetValue() HealBot_Returned_Colours(r,g,b,a); end;
        ColorPickerFrame.cancelFunc = function() HealBot_Returned_Colours(prevR, prevG, prevB, 1-prevA); end; --added by Diacono
        ColorPickerFrame:ClearAllPoints();
        ColorPickerFrame:SetPoint("TOPLEFT","HealBot_Options","TOPRIGHT",0,-152);
        OpacitySliderFrame:SetValue(1-A);
        ColorPickerFrame:SetColorRGB(R, G, B);
        ColorPickerFrame:Show();
    else
        ColorPickerFrame.hasOpacity = false;
        ColorPickerFrame.func = function() HealBot_Returned_Colours(ColorPickerFrame:GetColorRGB()); end;
        ColorPickerFrame.cancelFunc = function() HealBot_Returned_Colours(prevR, prevG, prevB); end; --added by Diacono
        ColorPickerFrame:ClearAllPoints();
        ColorPickerFrame:SetPoint("TOPLEFT","HealBot_Options","TOPRIGHT",0,-152);
        ColorPickerFrame:SetColorRGB(R, G, B);
        ColorPickerFrame:Show();
    end
    return ColorPickerFrame:GetColorRGB();
end

function HealBot_SetCDCBarColours()
    HealBot_DiseaseColorpick:SetStatusBarColor(HealBot_Config.CDCBarColour[HEALBOT_DISEASE_en].R or 0.55,
                                               HealBot_Config.CDCBarColour[HEALBOT_DISEASE_en].G or 0.19,
                                               HealBot_Config.CDCBarColour[HEALBOT_DISEASE_en].B or 0.7,
                                               Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_MagicColorpick:SetStatusBarColor(HealBot_Config.CDCBarColour[HEALBOT_MAGIC_en].R or 0.26,
                                             HealBot_Config.CDCBarColour[HEALBOT_MAGIC_en].G or 0.33,
                                             HealBot_Config.CDCBarColour[HEALBOT_MAGIC_en].B or 0.83,
                                             Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_PoisonColorpick:SetStatusBarColor(HealBot_Config.CDCBarColour[HEALBOT_POISON_en].R or 0.12,
                                              HealBot_Config.CDCBarColour[HEALBOT_POISON_en].G or 0.46,
                                              HealBot_Config.CDCBarColour[HEALBOT_POISON_en].B or 0.24,
                                              Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_CurseColorpick:SetStatusBarColor(HealBot_Config.CDCBarColour[HEALBOT_CURSE_en].R or 0.83,
                                             HealBot_Config.CDCBarColour[HEALBOT_CURSE_en].G or 0.43,
                                             HealBot_Config.CDCBarColour[HEALBOT_CURSE_en].B or 0.09,
                                             Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_CustomColorpick:SetStatusBarColor(HealBot_Config.CDCBarColour[HEALBOT_CUSTOM_en].R or 0.45,
                                             HealBot_Config.CDCBarColour[HEALBOT_CUSTOM_en].G or 0,
                                             HealBot_Config.CDCBarColour[HEALBOT_CUSTOM_en].B or 0.26,
                                             Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin]);
    HealBot_DebTextColorpick:SetStatusBarColor(HealBot_Config.CDCBarColour[HEALBOT_DISEASE_en].R or 0.1,
                                               HealBot_Config.CDCBarColour[HEALBOT_DISEASE_en].G or 0.05,
                                               HealBot_Config.CDCBarColour[HEALBOT_DISEASE_en].B or 0.2,
                                               Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin])
    HealBot_Action_SetDebuffAggroCols()
end

function HealBot_SetBuffBarColours()
    buffbarcolrClass = HealBot_Config.HealBotBuffColR
    buffbarcolgClass = HealBot_Config.HealBotBuffColG
    buffbarcolbClass = HealBot_Config.HealBotBuffColB

    for k=1,10 do
        bar=getglobal("HealBot_Buff"..k.."Colour")
        if bar then
            bar:SetStatusBarColor(buffbarcolrClass[k],
                                  buffbarcolgClass[k],
                                  buffbarcolbClass[k],
                                  Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin]);
        end
    end
    HealBot_setOptions_Timer(40)
end
--------------------------------------------------------------------------------

function HealBot_Options_NotifyChan_OnTextChanged(self)
    Healbot_Config_Skins.NotifyChan[Healbot_Config_Skins.Current_Skin] = self:GetText()
end

function HealBot_SpellAutoButton_OnClick(self, autoType, autoMod)
    if HealBot_ActionBarsCombo==1 then
        if autoType=="Target" then combo = HealBot_Config.EnabledSpellTarget;
        elseif autoType=="Trinket1" then combo = HealBot_Config.EnabledSpellTrinket1;
        else combo = HealBot_Config.EnabledSpellTrinket2; end
    else
        if autoType=="Target" then combo = HealBot_Config.DisabledSpellTarget;
        elseif autoType=="Trinket1" then combo = HealBot_Config.DisabledSpellTrinket1;
        else combo = HealBot_Config.DisabledSpellTrinket2; end
    end
    button = HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button)
    combo[autoMod..button..HealBot_Config.CurrentSpec] = self:GetChecked() or 0;
    HealBot_setOptions_Timer(400)
end

local spellText=nil
function HealBot_Options_Click_OnTextChanged(self)
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledKeyCombo;
    else
        combo = HealBot_Config.DisabledKeyCombo;
    end
    button = HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button)
    spellText = strtrim(self:GetText())
    combo[button..HealBot_Config.CurrentSpec] = spellText
    if HealBot_GetSpellId(spellText) then
        HealBot_setOptions_Timer(70)
        HealBot_setOptions_Timer(400)
    elseif GetMacroIndexByName(spellText) or IsUsableItem(spellText) then
        HealBot_setOptions_Timer(400)
    end
    HealBot_Options_SoftReset_flag=true
end

function HealBot_Options_Shift_OnTextChanged(self)
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledKeyCombo;
    else
        combo = HealBot_Config.DisabledKeyCombo;
    end
    button = HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button)
    spellText = strtrim(self:GetText())
    combo["Shift"..button..HealBot_Config.CurrentSpec] = spellText
    if HealBot_GetSpellId(spellText) then
        HealBot_setOptions_Timer(70)
        HealBot_setOptions_Timer(400)
    elseif GetMacroIndexByName(spellText) or IsUsableItem(spellText) then
        HealBot_setOptions_Timer(400)
    end
    HealBot_Options_SoftReset_flag=true
end

function HealBot_Options_Ctrl_OnTextChanged(self)
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledKeyCombo;
    else
        combo = HealBot_Config.DisabledKeyCombo;
    end
    button = HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button)
    spellText = strtrim(self:GetText())
    combo["Ctrl"..button..HealBot_Config.CurrentSpec] = spellText
    if HealBot_GetSpellId(spellText) then
        HealBot_setOptions_Timer(70)
        HealBot_setOptions_Timer(400)
    elseif GetMacroIndexByName(spellText) or IsUsableItem(spellText) then
        HealBot_setOptions_Timer(400)
    end
    HealBot_Options_SoftReset_flag=true
end

function HealBot_Options_Alt_OnTextChanged(self)
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledKeyCombo;
    else
        combo = HealBot_Config.DisabledKeyCombo;
    end
    button = HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button)
    spellText = strtrim(self:GetText())
    combo["Alt"..button..HealBot_Config.CurrentSpec] = spellText
    if HealBot_GetSpellId(spellText) then
        HealBot_setOptions_Timer(70)
        HealBot_setOptions_Timer(400)
    elseif GetMacroIndexByName(spellText) or IsUsableItem(spellText) then
        HealBot_setOptions_Timer(400)
    end
    HealBot_Options_SoftReset_flag=true
end

function HealBot_Options_CtrlShift_OnTextChanged(self)
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledKeyCombo;
    else
        combo = HealBot_Config.DisabledKeyCombo;
    end
    button = HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button)
    spellText = strtrim(self:GetText())
    combo["Ctrl-Shift"..button..HealBot_Config.CurrentSpec] = spellText
    if HealBot_GetSpellId(spellText) then
        HealBot_setOptions_Timer(70)
        HealBot_setOptions_Timer(400)
    elseif GetMacroIndexByName(spellText) or IsUsableItem(spellText) then
        HealBot_setOptions_Timer(400)
    end
    HealBot_Options_SoftReset_flag=true
end

function HealBot_Options_AltShift_OnTextChanged(self)
    if HealBot_ActionBarsCombo==1 then
        combo = HealBot_Config.EnabledKeyCombo;
    else
        combo = HealBot_Config.DisabledKeyCombo;
    end
    button = HealBot_Options_ComboClass_Button(HealBot_Options_ComboButtons_Button)
    spellText = strtrim(self:GetText())
    combo["Alt-Shift"..button..HealBot_Config.CurrentSpec] = spellText
    if HealBot_GetSpellId(spellText) then
        HealBot_setOptions_Timer(70)
        HealBot_setOptions_Timer(400)
    elseif GetMacroIndexByName(spellText) or IsUsableItem(spellText) then
        HealBot_setOptions_Timer(400)
    end
    HealBot_Options_SoftReset_flag=true
end

function HealBot_Options_EnableHealthy_OnClick(self)
    HealBot_Config.EnableHealthy = self:GetChecked() or 0;
    HealBot_Action_ResetUnitStatus();
end

function HealBot_Options_EnableSmartCast_OnClick(self)
    HealBot_Config.SmartCast = self:GetChecked() or 0;
end

function HealBot_Options_SmartCastDisspell_OnClick(self)
    HealBot_Config.SmartCastDebuff = self:GetChecked() or 0;
end

function HealBot_Options_SmartCastBuff_OnClick(self)
    HealBot_Config.SmartCastBuff = self:GetChecked() or 0;
end

function HealBot_Options_SmartCastHeal_OnClick(self)
    HealBot_Config.SmartCastHeal = self:GetChecked() or 0;
end

function HealBot_Options_SmartCastRes_OnClick(self)
    HealBot_Config.SmartCastRes = self:GetChecked() or 0;
end

local HealBot_CombosKeys_List = {"","Shift","Ctrl","Alt"}
local HB_combo_prefix=nil
local SpellTxtE=nil
local SpellTxtD=nil
local SpellTxtB=nil
local HB_button=nil
function HealBot_Options_CheckCombos()  

    id=0;
  
    for j=1,5 do
        if j==1 then 
            HB_button="Left";
        elseif j==2 then 
            HB_button="Right";
        elseif j==3 then 
            HB_button="Middle";
        elseif j==4 then 
            HB_button="Button4";
        elseif j==5 then 
            HB_button="Button5";
        end
    
        for x=1, getn(HealBot_CombosKeys_List), 1 do
            HB_combo_prefix = HealBot_CombosKeys_List[x]..HB_button..HealBot_Config.CurrentSpec

            SpellTxtE = HealBot_Action_AttribSpellPattern(HB_combo_prefix)
            SpellTxtD = HealBot_Action_AttribDisSpellPattern(HB_combo_prefix)
      
            if SpellTxtE then
                if not HealBot_Spells[SpellTxtE] then
                    if not HealBot_OtherSpells[SpellTxtE] then
                        id = HealBot_GetSpellId(SpellTxtE);
                        if id then
                            HealBot_FindSpellRangeCast(id);
                        end
                    end
                end
            end
            if SpellTxtD then
                if not HealBot_Spells[SpellTxtD] then
                    if not HealBot_OtherSpells[SpellTxtD] then
                        id = HealBot_GetSpellId(SpellTxtD);
                        if id then
                            HealBot_FindSpellRangeCast(id);
                        end
                    end
                end
            end
        end
    end
end

--------------------------------------------------------------------------------

StaticPopupDialogs["HEALBOT_OPTIONS_SETDEFAULTS"] = {
    text = HEALBOT_OPTIONS_SETDEFAULTSMSG,
    button1 = HEALBOT_WORDS_YES,
    button2 = HEALBOT_WORDS_NO,
    OnAccept = function()
        HealBot_Options_SetDefaults();
    end,
    timeout = 0,
    whileDead = 1,
    hideOnEscape = 1
};

function HealBot_Options_Defaults_OnClick(self)
    StaticPopup_Show ("HEALBOT_OPTIONS_SETDEFAULTS");
end

function HealBot_Options_Reset_OnClick(self,mode)
    HealBot_SetResetFlag(mode)
end

function HealBot_Options_Info_OnClick(self)
    HealBot_Comms_Info()
end

function HealBot_Options_SetDefaults()
    HealBot_Config = HealBot_ConfigDefaults;
    HealBot_Globals = HealBot_GlobalsDefaults;
    if Healbot_Config_Skins.CastNotify[Healbot_Config_Skins.Current_Skin] then HealBot_Options_CastNotify_OnClick(nil,0); end
--    table.foreach(HealBot_ConfigDefaults, function (x,val)
--        HealBot_Config[x] = val;
--    end);
--    table.foreach(HealBot_GlobalsDefaults, function (x,val)
--        HealBot_Globals[x] = val;
--    end);
    table.foreach(HealBot_Config_SkinsDefaults, function (key,val)
        if not Healbot_Config_Skins[key] then
            Healbot_Config_Skins[key] = val;
        end
    end);
    HealBot_InitNewChar(HealBot_PlayerClassEN)
    HealBot_Config.CurrentSpec=1
    HealBot_Update_SpellCombos()
    HealBot_Update_BuffsForSpec()
    for x,_ in pairs(HealBot_UnitDebuff) do
        HealBot_UnitDebuff[x]=nil;
    end
    for x,_ in pairs(HealBot_UnitBuff) do
        HealBot_UnitBuff[x]=nil;
    end
    HealBot_Options_Opened=false;
    HealBot_RecalcSpells();
    HealBot_Action_Reset();
    HealBot_ClearAllBuffs()
    HealBot_ClearAllDebuffs()
    ShowUIPanel(HealBot_Action)
    HealBot_Action_SetAllAttribs()
    HideUIPanel(HealBot_Options)
    HealBot_Config.ActionVisible = HealBot_Action:IsVisible();
    DoInitTab1=true
    DoInitTab2=true
    DoInitTab3=true
    DoInitTab4=true
    DoInitTab5=true
    DoInitTab6=true
    DoInitTab9=true
    DoInitTab10=true
end

function HealBot_Options_OnLoad(self)

    table.insert(UISpecialFrames,self:GetName());

  -- Tabs
    PanelTemplates_SetNumTabs(self,6);
    self.selectedTab = 1; 
    PanelTemplates_UpdateTabs(self);
    DoInitTab1=true
    DoInitTab2=true
    DoInitTab3=true
    DoInitTab4=true
    DoInitTab5=true
    DoInitTab6=true
    DoInitTab9=true
    DoInitTab10=true
    getglobal("HealBot_Options_HeadersSkinsFrame"):Hide()
    getglobal("HealBot_Options_IconsSkinsFrame"):Hide()
    getglobal("HealBot_Options_HealingSkinsFrame"):Hide()
    getglobal("HealBot_Options_IncHealsSkinsFrame"):Hide()
    getglobal("HealBot_Options_ChatSkinsFrame"):Hide()
    getglobal("HealBot_Options_BarsSkinsFrame"):Hide()
    getglobal("HealBot_Options_TextSkinsFrame"):Hide()
end

function HealBot_Options_OnShow(self)
    HealBot_Options_ShowPanel(self, self.selectedTab)
end

function HealBot_Options_Close()
    if HealBot_Options_SoftReset_flag then
        HealBot_Options_SoftReset_flag=false
        HealBot_setOptions_Timer(400)
    end
end

function HealBot_Options_ResetDoInittab(tabNo)
    if tabNo==1 then
        DoInitTab1=true
    elseif tabNo==2 then
        DoInitTab2=true
    elseif tabNo==3 then
        DoInitTab3=true
    elseif tabNo==4 then
        DoInitTab4=true
    elseif tabNo==5 then
        DoInitTab5=true
    elseif tabNo==6 then
        DoInitTab6=true
    elseif tabNo==9 then
        DoInitTab9=true
    else
        DoInitTab10=true
        hbHealDDlist=nil
        hbOtherDDlist=nil
        hbHelpItemSelect=nil
        HealBot_Options_SelectSpellsFrame:Hide()
        HealBot_Options_KeysFrame:Show()
    end
    if HealBot_Options:IsVisible() then
        HealBot_Options_Init(tabNo)
    end
end

function HealBot_Options_Init(tabNo)
    if tabNo==1 then
        if DoInitTab1 then
            HealBot_Options_DisableHealBot:SetChecked(HealBot_Config.DisableHealBot)
            HealBot_Options_ShowMinimapButton:SetChecked(HealBot_Config.ButtonShown)

            HealBot_Options_HideOptions:SetChecked(HealBot_Config.HideOptions)
            HealBot_Options_RightButtonOptions:SetChecked(HealBot_Config.RightButtonOptions)
            HealBot_Options_EnableLibQuickHealth:SetChecked(HealBot_Config.EnLibQuickHealth)
            HealBot_Options_NumberTestBars:SetValue(HealBot_Config.noTestBars)
            HealBot_Options_NumberTestTanks:SetValue(HealBot_Config.noTestTanks)
            HealBot_Options_NumberTestMyTargets:SetValue(HealBot_Config.noTestTargets)
            HealBot_Options_NumberTestPets:SetValue(HealBot_Config.noTestPets)
            HealBot_Options_TestBarsButton:SetText(HEALBOT_OPTIONS_TESTBARS.." "..HEALBOT_WORD_OFF)
            HealBot_Options_RangeCheckFreq:SetValue((HealBot_Config.RangeCheckFreq or 0.2)*10)
            HealBot_Options_EFClass_Reset()
            HealBot_Options_HealCommMethod_Refresh()
            HealBot_Options_EmergencyFClass_Refresh()
            DoInitTab1=nil
        end
        CPUProfiler=GetCVar("scriptProfile")
        HealBot_Options_CPUProfiler:SetChecked(CPUProfiler)
    elseif tabNo==2 and DoInitTab2 then
        HealBot_Options_ProtectPvP:SetChecked(HealBot_Config.ProtectPvP)
        HealBot_Options_EnableSmartCast:SetChecked(HealBot_Config.SmartCast)
        HealBot_Options_SmartCastDisspell:SetChecked(HealBot_Config.SmartCastDebuff)
        HealBot_Options_SmartCastBuff:SetChecked(HealBot_Config.SmartCastBuff)
        HealBot_Options_SmartCastHeal:SetChecked(HealBot_Config.SmartCastHeal)
        HealBot_Options_SmartCastRes:SetChecked(HealBot_Config.SmartCastRes)
        HealBot_Options_EnableHealthy:SetChecked(HealBot_Config.EnableHealthy)
        HealBot_Options_ActionBarsCombo_Refresh()
        HealBot_Options_CastButton_Refresh()
        HealBot_Options_ButtonCastMethod_Refresh()
        DoInitTab2=nil
    elseif tabNo==4 and DoInitTab4 then
        HealBot_Options_UpdateMedia(tabNo)
        HealBot_Options_SoundDebuffWarning:SetChecked(HealBot_Config.SoundDebuffWarning)
        HealBot_Options_MonitorDebuffs:SetChecked(HealBot_Config.DebuffWatch)
        HealBot_Options_IgnoreDebuffsClass:SetChecked(HealBot_Config.IgnoreClassDebuffs)
        HealBot_Options_IgnoreDebuffsNoHarm:SetChecked(HealBot_Config.IgnoreNonHarmfulDebuffs)
        HealBot_Options_IgnoreDebuffsDuration:SetChecked(HealBot_Config.IgnoreFastDurDebuffs)
        HealBot_Options_IgnoreDebuffsDurationSecs:SetValue(HealBot_Config.IgnoreFastDurDebuffsSecs)
        HealBot_Options_IgnoreDebuffsMovement:SetChecked(HealBot_Config.IgnoreMovementDebuffs)
        HealBot_Options_WarningSound:SetValue(soundsIndex[HealBot_Config.SoundDebuffPlay] or 0);    
        HealBot_Options_MonitorDebuffsInCombat:SetChecked(HealBot_Config.DebuffWatchInCombat)
        HealBot_Options_CDCTxt1_Refresh()
        HealBot_Options_CDCTxt2_Refresh()
        HealBot_Options_CDCTxt3_Refresh()
        HealBot_Options_CDCGroups1_Refresh()
        HealBot_Options_CDCGroups2_Refresh()
        HealBot_Options_CDCGroups3_Refresh()
        HealBot_Options_CDebuffTxt1_Initialize()
        HealBot_Options_ShowDebuffWarning:SetChecked(HealBot_Config.ShowDebuffWarning)
        HealBot_SetCDCBarColours()
        HealBot_Options_CDCCol_ShowOnHealthBar:SetChecked(HealBot_Config.CDCshownHB)
        HealBot_Options_CDCCol_ShowOnAggroBar:SetChecked(HealBot_Config.CDCshownAB)
        DoInitTab4=nil
    elseif tabNo==3 and DoInitTab3 then
        HealBot_Options_UpdateMedia(tabNo)
        HealBot_Options_NewSkinb:Disable()
        HealBot_Options_Skins_Refresh()
        HealBot_Options_ShareSkin_Refresh()
        DoInitTab3=nil
    elseif tabNo==6 and DoInitTab6 then
        HealBot_Options_ShowTooltip:SetChecked(HealBot_Config.ShowTooltip)
        HealBot_Options_ShowTooltipUpdate:SetChecked(HealBot_Config.TooltipUpdate)
        HealBot_Options_HideTooltipInCombat:SetChecked(HealBot_Config.DisableToolTipInCombat)
        HealBot_Options_ShowTooltipTarget:SetChecked(HealBot_Config.Tooltip_ShowTarget)
        HealBot_Options_ShowTooltipMyBuffs:SetChecked(HealBot_Config.Tooltip_ShowMyBuffs)
        HealBot_Options_ShowTooltipSpellDetail:SetChecked(HealBot_Config.Tooltip_ShowSpellDetail)
        HealBot_Options_ShowTooltipInstant:SetChecked(HealBot_Config.Tooltip_Recommend)
        HealBot_Options_ShowTooltipPreDefined:SetChecked(HealBot_Config.Tooltip_PreDefined)
        HealBot_Options_TooltipPos_Refresh()
        HealBot_Options_TTAlpha:SetValue(HealBot_Config.ttalpha)
        DoInitTab6=nil
    elseif tabNo==5 and DoInitTab5 then
        HealBot_Options_MonitorBuffs:SetChecked(HealBot_Config.BuffWatch)
        HealBot_Options_MonitorBuffsInCombat:SetChecked(HealBot_Config.BuffWatchInCombat)
        HealBot_Options_BuffTxt1_Refresh()
        HealBot_Options_BuffTxt2_Refresh()
        HealBot_Options_BuffTxt3_Refresh()
        HealBot_Options_BuffTxt4_Refresh()
        HealBot_Options_BuffTxt5_Refresh()
        HealBot_Options_BuffTxt6_Refresh()
        HealBot_Options_BuffTxt7_Refresh()
        HealBot_Options_BuffTxt8_Refresh()
        HealBot_Options_BuffTxt9_Refresh()
        HealBot_Options_BuffTxt10_Refresh()
        HealBot_Options_BuffGroups1_Refresh()
        HealBot_Options_BuffGroups2_Refresh()
        HealBot_Options_BuffGroups3_Refresh()
        HealBot_Options_BuffGroups4_Refresh()
        HealBot_Options_BuffGroups5_Refresh()
        HealBot_Options_BuffGroups6_Refresh()
        HealBot_Options_BuffGroups7_Refresh()
        HealBot_Options_BuffGroups8_Refresh()
        HealBot_Options_BuffGroups9_Refresh()
        HealBot_Options_BuffGroups10_Refresh()
        HealBot_Options_ShortBuffTimer:SetValue(HealBot_Config.ShortBuffTimer)
        HealBot_Options_LongBuffTimer:SetValue(HealBot_Config.LongBuffTimer)
        DoInitTab5=nil
    elseif tabNo==9 and DoInitTab9 then
        HealBot_Options_DisableHealBot:SetChecked(HealBot_Config.DisableHealBot)
        HealBot_Options_EnableSmartCast:SetChecked(HealBot_Config.SmartCast)
        HealBot_Options_MonitorDebuffs:SetChecked(HealBot_Config.DebuffWatch)
        HealBot_Options_MonitorBuffs:SetChecked(HealBot_Config.BuffWatch)
        DoInitTab9=nil
        LSM.RegisterCallback("HealBot", "LibSharedMedia_Registered", function(event, mediatype, key) HealBot_UpdateUsedMedia(event, mediatype, key) end)  
        LSM.RegisterCallback("HealBot", "LibSharedMedia_SetGlobal", function(event, mediatype, key) HealBot_UpdateUsedMedia(event, mediatype, key) end) 
        HealBot_Options_SelectSpellsFrame:Hide()
    elseif tabNo==10 and DoInitTab10 then
        HealBot_Options_SelectHealSpellsCombo_Refresh()
        HealBot_Options_SelectOtherSpellsCombo_Refresh()
        HealBot_Options_SelectMacrosCombo_Refresh()
        HealBot_Options_SelectItemsCombo_Refresh()
        HealBot_Options_SelectCmdsCombo_Refresh()
        DoInitTab10=nil
    end
    if not HealBot_Options_Opened then
        HealBot_setOptions_Timer(100)
        HealBot_Options_Opened=true
        if HealBot_Config.SoundDebuffWarning>0 then
            HealBot_Options_WarningSound:Enable();
            HealBot_Options_PlaySound:Enable();
        else
            HealBot_Options_WarningSound:Disable();
            HealBot_Options_PlaySound:Disable();
        end
        if Healbot_Config_Skins.ShowHealthOnBar[Healbot_Config_Skins.Current_Skin]==0 then
            HealBot_BarHealthType1:Disable();
            HealBot_BarHealthType2:Disable();
            HealBot_BarHealthIncHeal:Disable();
            HealBot_BarHealthSepHeal:Disable();
        else
            HealBot_BarHealthType1:Enable();
            HealBot_BarHealthType2:Enable();
            HealBot_BarHealthIncHeal:Enable();
            HealBot_BarHealthSepHeal:Enable();
        end
        if Healbot_Config_Skins.ShowClassOnBar[Healbot_Config_Skins.Current_Skin]==0 then
            HealBot_Options_ShowClassOnBarType1:Disable();
            HealBot_Options_ShowClassOnBarType2:Disable();
        else
            HealBot_Options_ShowClassOnBarType1:Enable();
            HealBot_Options_ShowClassOnBarType2:Enable();
        end
        if Healbot_Config_Skins.SetBarClassColour[Healbot_Config_Skins.Current_Skin]>0 then
            HealBot_Options_BarClassCustomColour1:Enable();
            HealBot_Options_BarClassCustomColour2:Enable();
        else
            HealBot_Options_BarClassCustomColour1:Disable();
            HealBot_Options_BarClassCustomColour2:Disable();
        end
    end
end

function HealBot_Options_SetEFGroups()
    for x=1,8 do
        if Healbot_Config_Skins.ExtraIncGroup[Healbot_Config_Skins.Current_Skin][x] then 
            getglobal("HealBot_Options_EFGroup"..x):SetChecked(1)
        else
            getglobal("HealBot_Options_EFGroup"..x):SetChecked(nil)
        end
    end
end

function HealBot_Options_SetSkins()
    if hbCurSkin~=Healbot_Config_Skins.Current_Skin then
        HealBot_Options_BarAlpha:SetValue(Healbot_Config_Skins.Barcola[Healbot_Config_Skins.Current_Skin] or 95);
        HealBot_Options_BarAlphaInHeal:SetValue(Healbot_Config_Skins.BarcolaInHeal[Healbot_Config_Skins.Current_Skin] or 35);
        HealBot_Options_BarTextureS:SetValue(texturesIndex[Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]] or 1)
        HealBot_Options_BarHeightS:SetValue(Healbot_Config_Skins.bheight[Healbot_Config_Skins.Current_Skin] or 22)
        HealBot_Options_BarWidthS:SetValue(Healbot_Config_Skins.bwidth[Healbot_Config_Skins.Current_Skin] or 95)
        HealBot_Options_BarNumColsS:SetValue(Healbot_Config_Skins.numcols[Healbot_Config_Skins.Current_Skin] or 2)
        HealBot_Options_BarBRSpaceS:SetValue(Healbot_Config_Skins.brspace[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarBCSpaceS:SetValue(Healbot_Config_Skins.bcspace[Healbot_Config_Skins.Current_Skin] or 4)
        HealBot_Options_FontName:SetValue(fontsIndex[Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin]] or 0)
        HealBot_Options_FontHeight:SetValue(Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin] or 10)
        HealBot_Options_BarAlphaDis:SetValue(Healbot_Config_Skins.bardisa[Healbot_Config_Skins.Current_Skin] or 4)
        HealBot_Options_BarAlphaEor:SetValue(Healbot_Config_Skins.bareora[Healbot_Config_Skins.Current_Skin] or 32)
        HealBot_Options_Bar2Size:SetValue(Healbot_Config_Skins.bar2size[Healbot_Config_Skins.Current_Skin] or 0)
        HealBot_Options_HeadTextureS:SetValue(texturesIndex[Healbot_Config_Skins.headtexture[Healbot_Config_Skins.Current_Skin]] or 0)
        HealBot_Options_HeadWidthS:SetValue(Healbot_Config_Skins.headwidth[Healbot_Config_Skins.Current_Skin] or 0.72)
        HealBot_Options_HeadHightS:SetValue(Healbot_Config_Skins.headhight[Healbot_Config_Skins.Current_Skin] or 0.75)
        HealBot_Options_HeadFontNameS:SetValue(fontsIndex[Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin]] or 0)
        HealBot_Options_HeadFontHeightS:SetValue(Healbot_Config_Skins.headtextheight[Healbot_Config_Skins.Current_Skin] or 10)  
        HealBot_Options_ShowHeaders:SetChecked(Healbot_Config_Skins.ShowHeader[Healbot_Config_Skins.Current_Skin] or 0)
        HealBot_Options_AggroTrack:SetChecked(Healbot_Config_Skins.ShowAggro[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_AggroBar:SetChecked(Healbot_Config_Skins.ShowAggroBars[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_AggroTxt:SetChecked(Healbot_Config_Skins.ShowAggroText[Healbot_Config_Skins.Current_Skin] or 0)
        HealBot_Options_HighlightActiveBar:SetChecked(Healbot_Config_Skins.HighLightActiveBar[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_UseFluidBars:SetChecked(Healbot_Config_Skins.UseFluidBars[Healbot_Config_Skins.Current_Skin] or 0)
        HealBot_Options_BarUpdateFreq:SetValue((Healbot_Config_Skins.BarFreq[Healbot_Config_Skins.Current_Skin] or 2)*10)
        HealBot_Options_BarButtonShowHoT:SetChecked(Healbot_Config_Skins.ShowHoTicons[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarButtonShowRaidIcon:SetChecked(Healbot_Config_Skins.ShowRaidIcon[Healbot_Config_Skins.Current_Skin] or 1)
        
        HealBot_Options_BarButtonShowRaidIconStar:SetChecked(Healbot_Config_Skins.ShowRaidIconStar[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarButtonShowRaidIconCircle:SetChecked(Healbot_Config_Skins.ShowRaidIconCircle[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarButtonShowRaidIconDiamond:SetChecked(Healbot_Config_Skins.ShowRaidIconDiamond[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarButtonShowRaidIconTriangle:SetChecked(Healbot_Config_Skins.ShowRaidIconTriangle[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarButtonShowRaidIconMoon:SetChecked(Healbot_Config_Skins.ShowRaidIconMoon[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarButtonShowRaidIconSquare:SetChecked(Healbot_Config_Skins.ShowRaidIconSquare[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarButtonShowRaidIconCross:SetChecked(Healbot_Config_Skins.ShowRaidIconCross[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarButtonShowRaidIconSkull:SetChecked(Healbot_Config_Skins.ShowRaidIconSkull[Healbot_Config_Skins.Current_Skin] or 1)
        
        HealBot_HoTonBar_OnClick(nil,Healbot_Config_Skins.HoTonBar[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_HoTposBar_OnClick(nil,Healbot_Config_Skins.HoTposBar[Healbot_Config_Skins.Current_Skin] or 1)
        
        HealBot_BarButtonShowHoTx2Bar:SetChecked(Healbot_Config_Skins.HoTx2Bar[Healbot_Config_Skins.Current_Skin] or 0)
        HealBot_Options_ShowClassOnBarType_OnClick(nil,Healbot_Config_Skins.ShowClassType[Healbot_Config_Skins.Current_Skin] or 2)
        HealBot_Options_ShowClassOnBar:SetChecked(Healbot_Config_Skins.ShowClassOnBar[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarInClassColour:SetChecked(Healbot_Config_Skins.SetBarClassColour[Healbot_Config_Skins.Current_Skin] or 0)
        HealBot_Options_ShowNameOnBar:SetChecked(Healbot_Config_Skins.ShowNameOnBar[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_ShowHealthOnBar:SetChecked(Healbot_Config_Skins.ShowHealthOnBar[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_BarHealthIncHeal:SetChecked(Healbot_Config_Skins.BarHealthIncHeals[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_BarHealthSepHeal:SetChecked(Healbot_Config_Skins.BarHealthSepHeals[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_BarHealthType_OnClick(nil,Healbot_Config_Skins.BarHealthType[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_BarClassCustom_OnClick(nil,Healbot_Config_Skins.SetBarCustomColour[Healbot_Config_Skins.Current_Skin] or 2)
        HealBot_Options_BarTextInClassColour:SetChecked(Healbot_Config_Skins.SetClassColourText[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_Options_ShowDebuffIcon:SetChecked(Healbot_Config_Skins.ShowDebuffIcon[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_BarButtonShowHoTTextCount:SetChecked(Healbot_Config_Skins.ShowIconTextCount[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_BarButtonShowHoTTextCountSelfCast:SetChecked(Healbot_Config_Skins.ShowIconTextCountSelfCast[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_BarButtonShowHoTTextDuration:SetChecked(Healbot_Config_Skins.ShowIconTextDuration[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_BarButtonShowHoTTextDurationSelfCast:SetChecked(Healbot_Config_Skins.ShowIconTextDurationSelfCast[Healbot_Config_Skins.Current_Skin] or 1)
        HealBot_BarButtonIconScale:SetValue((Healbot_Config_Skins.IconScale[Healbot_Config_Skins.Current_Skin] or 7.5)*10)
        HealBot_BarButtonIconTextScale:SetValue((Healbot_Config_Skins.IconTextScale[Healbot_Config_Skins.Current_Skin] or 7.5)*10)
        HealBot_Options_AggroBarSize:SetValue(Healbot_Config_Skins.AggroBarSize[Healbot_Config_Skins.Current_Skin] or 2)
        HealBot_Options_NumberTextLines:SetChecked(Healbot_Config_Skins.DoubleText[Healbot_Config_Skins.Current_Skin] or 0)
        HealBot_Options_BarNumGroupPerCol:SetChecked(Healbot_Config_Skins.GroupsPerCol[Healbot_Config_Skins.Current_Skin] or 0)
        HealBot_Options_TextAlign:SetValue(Healbot_Config_Skins.TextAlignment[Healbot_Config_Skins.Current_Skin] or 2)
        HealBot_Options_SelfHeals:SetChecked(Healbot_Config_Skins.SelfHeals[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_PetHeals:SetChecked(Healbot_Config_Skins.PetHeals[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_GroupHeals:SetChecked(Healbot_Config_Skins.GroupHeals[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_TankHeals:SetChecked(Healbot_Config_Skins.TankHeals[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_SelfPet:SetChecked(Healbot_Config_Skins.SelfPet[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_EmergencyHeals:SetChecked(Healbot_Config_Skins.EmergencyHeals[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_FocusBar:SetChecked(Healbot_Config_Skins.SetFocusBar[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_VehicleHeals:SetChecked(Healbot_Config_Skins.VehicleHeals[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_MyTargetsList:SetChecked(Healbot_Config_Skins.ShowMyTargetsList[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_TargetBar:SetChecked(Healbot_Config_Skins.TargetHeals[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_TargetIncSelf:SetChecked(Healbot_Config_Skins.TargetIncSelf[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_TargetIncGroup:SetChecked(Healbot_Config_Skins.TargetIncGroup[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_TargetIncRaid:SetChecked(Healbot_Config_Skins.TargetIncRaid[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_TargetIncPet:SetChecked(Healbot_Config_Skins.TargetIncPet[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_TargetMode:SetChecked(Healbot_Config_Skins.TargetBarNormalMode[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_AlertLevel:SetValue(Healbot_Config_Skins.AlertLevel[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_VisibleRange:SetChecked(Healbot_Config_Skins.NotVisibleDisable[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_EmergencyFilter_Refresh()  -- Healbot_Config_Skins.EmergIncMonitor[Healbot_Config_Skins.Current_Skin]
        HealBot_Options_ExtraSort_Refresh()   -- Healbot_Config_Skins.ExtraOrder[Healbot_Config_Skins.Current_Skin]
        HealBot_Options_ExtraSubSort_Refresh()
        HealBot_Options_PartyFrames:SetChecked(Healbot_Config_Skins.HidePartyFrames[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_PlayerTargetFrames:SetChecked(Healbot_Config_Skins.HidePlayerTarget[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_CastNotify_OnClick(nil,Healbot_Config_Skins.CastNotify[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_NotifyChan:SetText(Healbot_Config_Skins.NotifyChan[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_NotifyHealMsg:SetText(Healbot_Config_Skins.NotifyHealMsg[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_NotifyOtherMsg:SetText(Healbot_Config_Skins.NotifyOtherMsg[Healbot_Config_Skins.Current_Skin])   
        HealBot_Options_CastNotifyResOnly:SetChecked(Healbot_Config_Skins.CastNotifyResOnly[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_ActionAnchor_Refresh()   -- Healbot_Config_Skins.Panel_Anchor[Healbot_Config_Skins.Current_Skin]
        HealBot_Options_SkinDefault_Refresh()  -- Healbot_Config_Skins.SkinDefault[Healbot_Config_Skins.Current_Skin]
        HealBot_Options_Class_HoTctlName_Refresh()
        HealBot_Options_Class_HoTctlAction_Refresh()
        HealBot_Options_ShowIncomingHeals:SetChecked(Healbot_Config_Skins.ShowIncHeals[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_incHealsDirectDur:SetValue(Healbot_Config_Skins.incHealDur[Healbot_Config_Skins.Current_Skin]["D"] or 5)
        HealBot_Options_incHealsHoTDur:SetValue(Healbot_Config_Skins.incHealDur[Healbot_Config_Skins.Current_Skin]["H"] or 3)
        HealBot_Options_incHealsChanDur:SetValue(Healbot_Config_Skins.incHealDur[Healbot_Config_Skins.Current_Skin]["C"] or 3)
        HealBot_Options_ActionLocked:SetChecked(Healbot_Config_Skins.ActionLocked[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_AutoShow:SetChecked(Healbot_Config_Skins.AutoClose[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_PanelSounds:SetChecked(Healbot_Config_Skins.PanelSounds[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_SubSortIncGroup:SetChecked(Healbot_Config_Skins.SubSortIncGroup[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_SubSortIncPets:SetChecked(Healbot_Config_Skins.SubSortIncPet[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_SubSortIncVehicle:SetChecked(Healbot_Config_Skins.SubSortIncVehicle[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_SubSortIncMainTanks:SetChecked(Healbot_Config_Skins.SubSortIncTanks[Healbot_Config_Skins.Current_Skin])
        HealBot_Options_SubSortIncMyTargets:SetChecked(Healbot_Config_Skins.SubSortIncMyTargets[Healbot_Config_Skins.Current_Skin])
        
        HealBot_Options_SetEFGroups()
        HealBot_SetSkinColours()
        HealBot_Action_SetHightlightAggroCols()
        HealBot_Options_SetSkinBars()
        if Healbot_Config_Skins.Current_Skin==HEALBOT_SKINS_STD then
            HealBot_Options_DeleteSkin:Disable();
        else
            HealBot_Options_DeleteSkin:Enable();
        end
        if (Healbot_Config_Skins.bar2size[Healbot_Config_Skins.Current_Skin] or 0)==0 then
            HealBot_UnRegister_Mana()
        else
            HealBot_Register_Mana()
        end
        HealBot_Config.Current_Skin = Healbot_Config_Skins.Current_Skin
        HealBot_Config.Skin_ID = Healbot_Config_Skins.Skin_ID
        hbCurSkin=Healbot_Config_Skins.Current_Skin
    end
end

function HealBot_Options_SetSkinBars()
    HealBot_HeadBarColorpickt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.headtextheight[Healbot_Config_Skins.Current_Skin],"");
    HealBot_HeadTextColorpickt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.headtextheight[Healbot_Config_Skins.Current_Skin],"");
    HealBot_EnTextColorpickt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin],"");
    HealBot_DisTextColorpickt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin],"");
    HealBot_DebTextColorpickt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin],"");
    HealBot_BarCustomColourt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin],"");
    HealBot_DiseaseColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_MagicColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_PoisonColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_CurseColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_CustomColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_EnTextColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_EnTextColorpickin:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_DisTextColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_DebTextColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_HeadBarColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.headtexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_HeadTextColorpick:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.headtexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff1Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff2Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff3Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff4Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff5Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff6Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff7Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff8Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff9Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_Buff10Colour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_BarCustomColour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    HealBot_HighlightActiveBarColour:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
    barScale = HealBot_EnTextColorpick:GetScale();
    HealBot_EnTextColorpick:SetScale(barScale + 0.01);
    HealBot_EnTextColorpick:SetScale(barScale);
    HealBot_DisTextColorpick:SetScale(barScale + 0.01);
    HealBot_DisTextColorpick:SetScale(barScale);
    HealBot_DebTextColorpick:SetScale(barScale + 0.01);
    HealBot_DebTextColorpick:SetScale(barScale);
    HealBot_BarCustomColour:SetScale(barScale + 0.01);
    HealBot_BarCustomColour:SetScale(barScale);
end

local HealBot_Options_CurrentPanel = 0;

function HealBot_Options_ShowPanel(self, tabNo)
    if HealBot_Options_CurrentPanel>0 then
        getglobal("HealBot_Options_Panel"..HealBot_Options_CurrentPanel):Hide();
    end
    HealBot_Options_CurrentPanel = tabNo;
    if HealBot_Options_CurrentPanel>0 then
        getglobal("HealBot_Options_Panel"..HealBot_Options_CurrentPanel):Show();
        getglobal("HealBot_OptionsTab"..HealBot_Options_CurrentPanel):Show();
        HealBot_Options_Init(HealBot_Options_CurrentPanel)
    end
end

local HealBot_Options_CurrentSkinsPanel="HealBot_Options_GeneralSkinsFrame"
local HealBot_Options_CurrentbarName="HealBot_SkinsFrameSelectGeneralFrame"
function HealBot_Options_ShowSkinsPanel(frameName,barName)
    getglobal(HealBot_Options_CurrentSkinsPanel):Hide()
    getglobal(HealBot_Options_CurrentbarName):SetStatusBarColor(0.58,0.08,0.08)
    getglobal(frameName):Show()
    getglobal(barName):SetStatusBarColor(1,0.35,0.35)
    HealBot_Options_CurrentSkinsPanel=frameName
    HealBot_Options_CurrentbarName=barName
end

function HealBot_Options_OnMouseDown(self)
    HealBot_StartMoving(self);
end

function HealBot_Options_OnMouseUp(self)
    HealBot_StopMoving(self);
end

function HealBot_Options_OnDragStart(self)
    HealBot_StartMoving(self);
end

function HealBot_Options_OnDragStop(self)
    HealBot_StopMoving(self);
end

function HealBot_Options_DisablePlayerFrame()
    PlayerFrame:UnregisterAllEvents()
    PlayerFrameHealthBar:UnregisterAllEvents()
    PlayerFrameManaBar:UnregisterAllEvents()
    PlayerFrame:Hide()
end

function HealBot_Options_EnablePlayerFrame()
    PlayerFrame:RegisterAllEvents()
    PlayerFrameHealthBar:RegisterAllEvents()
    PlayerFrameManaBar:RegisterAllEvents()
    PlayerFrame:Show();
end

function HealBot_Options_DisablePetFrame()
    PetFrame:UnregisterAllEvents()
    PetFrame:Hide()
end

function HealBot_Options_EnablePetFrame()
    PetFrame:RegisterAllEvents()
    PetFrame:Show();
end

local f=nil
function HealBot_Options_DisablePartyFrame()
    HIDE_PARTY_INTERFACE = "1"
    hooksecurefunc("ShowPartyFrame", function()
        for x = 1,4 do
            getglobal("PartyMemberFrame"..x):Hide()
        end
    end)
    for x = 1, 4 do
        f = getglobal("PartyMemberFrame"..x)
        f:Hide()
        f:UnregisterAllEvents()
        getglobal("PartyMemberFrame"..x.."HealthBar"):UnregisterAllEvents()
        getglobal("PartyMemberFrame"..x.."ManaBar"):UnregisterAllEvents()
    end
end

function HealBot_Options_EnablePartyFrame()
    HIDE_PARTY_INTERFACE = "0"
    hooksecurefunc("ShowPartyFrame", function()
        for x = 1,4 do
            getglobal("PartyMemberFrame"..x):Show()
        end
    end)
    for x = 1, 4 do
        f = getglobal("PartyMemberFrame"..x)
        if GetPartyMember(x) then
            f:Show()
        end
        f:RegisterAllEvents()
        getglobal("PartyMemberFrame"..x.."HealthBar"):RegisterAllEvents()
        getglobal("PartyMemberFrame"..x.."ManaBar"):RegisterAllEvents()
    end
end

function HealBot_Options_DisableTargetFrame()
    TargetFrame:UnregisterAllEvents()
    TargetFrameHealthBar:UnregisterAllEvents()
    TargetFrameManaBar:UnregisterAllEvents()
    TargetFrame:Hide()
    TargetFrameToT:UnregisterAllEvents()
    TargetFrameToT:Hide()
end

function HealBot_Options_EnableTargetFrame()
    TargetFrame:RegisterAllEvents()
    TargetFrameHealthBar:RegisterAllEvents()
    TargetFrameManaBar:RegisterAllEvents()
    TargetFrameToT:RegisterAllEvents()
end

function HealBot_Options_SetSliderValue(slider,value,updating)
    updatingMedia = updating
    slider:SetValue(-1) -- Pre change value so that text gets updated if value does not change but media does
    updatingMedia = updating
    slider:SetValue(value or 0)
end

function HealBot_Options_UpdateMedia(panel)
    HealBot_AddDebug("Update Media Called")
    if panel == 3 then
        textures = LSM:List('statusbar');
        for x,_ in pairs(texturesIndex) do
            texturesIndex[x]=nil
        end 
        for i=1,#textures do
            texturesIndex[textures[i]] = i
        end
        fonts = LSM:List('font');
        for x,_ in pairs(fontsIndex) do
            fontsIndex[x]=nil
        end 
        for i=1,#fonts do
            fontsIndex[fonts[i]] = i
        end
        HealBot_Options_val_OnLoad(HealBot_Options_HeadTextureS,HEALBOT_OPTIONS_SKINTEXTURE,1,#textures)
        HealBot_Options_val_OnLoad(HealBot_Options_HeadFontNameS,HEALBOT_OPTIONS_SKINFONT,1,#fonts)
        HealBot_Options_SetSliderValue(HealBot_Options_HeadTextureS,texturesIndex[Healbot_Config_Skins.headtexture[Healbot_Config_Skins.Current_Skin]],true)
        HealBot_Options_SetSliderValue(HealBot_Options_HeadFontNameS,fontsIndex[Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin]],true)
        HealBot_Options_val_OnLoad(HealBot_Options_BarTextureS,HEALBOT_OPTIONS_SKINTEXTURE,1,#textures)
        HealBot_Options_val_OnLoad(HealBot_Options_FontName,HEALBOT_OPTIONS_SKINFONT,1,#fonts)
        HealBot_Options_SetSliderValue(HealBot_Options_BarTextureS,texturesIndex[Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]],true)
        HealBot_Options_SetSliderValue(HealBot_Options_FontName,fontsIndex[Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin]],true)
    elseif panel == 4 then
        sounds = LSM:List('sound');
        for x,_ in pairs(soundsIndex) do
            soundsIndex[x]=nil
        end 
        for i=1,#sounds do
            soundsIndex[sounds[i]] = i
        end
        HealBot_Options_val_OnLoad(HealBot_Options_WarningSound,HEALBOT_OPTIONS_SOUND,1,#sounds)
        HealBot_Options_SetSliderValue(HealBot_Options_WarningSound,soundsIndex[HealBot_Config.SoundDebuffPlay],true)
    end
end

function HealBot_UpdateUsedMedia(event, mediatype, key)
    if mediatype == "statusbar" then
        if Healbot_Config_Skins.headtexture and key == Healbot_Config_Skins.headtexture[Healbot_Config_Skins.Current_Skin] then 
            for x=1,15 do
                h=getglobal("HealBot_Action_Header"..x);
                bar = HealBot_Action_HealthBar(h);
                bar:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.headtexture[Healbot_Config_Skins.Current_Skin]));
                bar.txt = getglobal(bar:GetName().."_text");
                bar.txt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.headtextheight[Healbot_Config_Skins.Current_Skin],"");
            end
        end
        if Healbot_Config_Skins.btexture and key == Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin] then 
            for x=1,51 do
                b=getglobal("HealBot_Action_HealUnit"..x);
                bar = HealBot_Action_HealthBar(b);
                bar2 = HealBot_Action_HealthBar2(b);
                bar3 = HealBot_Action_HealthBar3(b);
                bar:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
                bar2:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
                bar3:SetStatusBarTexture(LSM:Fetch('statusbar',Healbot_Config_Skins.btexture[Healbot_Config_Skins.Current_Skin]));
            end            
        end
    elseif mediatype == "font" then
        if Healbot_Config_Skins.headtextfont and key == Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin] then
            for x=1,15 do
                h=getglobal("HealBot_Action_Header"..x);
                bar = HealBot_Action_HealthBar(h);
                bar.txt = getglobal(bar:GetName().."_text");
                bar.txt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.headtextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.headtextheight[Healbot_Config_Skins.Current_Skin],"");
            end
        end
        if Healbot_Config_Skins.btextfont and key == Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin] then
            for x=1,51 do
                b=getglobal("HealBot_Action_HealUnit"..x);
                bar = HealBot_Action_HealthBar(b);
                bar.txt = getglobal(bar:GetName().."_text");
                bar.txt:SetFont(LSM:Fetch('font',Healbot_Config_Skins.btextfont[Healbot_Config_Skins.Current_Skin]),Healbot_Config_Skins.btextheight[Healbot_Config_Skins.Current_Skin],"");
            end        
        end
    --elseif mediatype == "background" then
    --elseif mediatype == "border" then
    elseif mediatype == "sound" then
        if key == HealBot_Config.SoundDebuffPlay then
        -- Do nothing
        end
    end
end
