BorrowerAndLender = {}
local function EndsWith(String,End)
   return End=='' or string.sub(String,-string.len(End))==End
end

local originalLevel = 1
local inBank

local function WhoAmI(eventCode, options)
	if EndsWith(ZO_ChatterOption1:GetText(), GetString(SI_INTERACT_OPTION_BANK)) then
		inBank = true
		local control = ZO_OptionsWindow.controlTable[2][9]
		originalLevel = control.currentChoice
		control.value = 1
		SetSetting(control.system, control.settingId, 1)
		ZO_Options_UpdateOption(control)
	end
end

local function WhoIWas(eventCode)
	if inBank then
		local control = ZO_OptionsWindow.controlTable[2][9]
		control.value = originalLevel
		SetSetting(control.system, control.settingId, originalLevel)
		ZO_Options_UpdateOption(control)
		inBank = false
	end
end
local function BorrowerAndLenderLoaded(eventCode, addOnName)

	if(addOnName ~= "Borrower And Lender") then
        return
    end

	EVENT_MANAGER:RegisterForEvent("BALWho", EVENT_CHATTER_BEGIN, WhoAmI)
	EVENT_MANAGER:RegisterForEvent("BALWas", EVENT_CHATTER_END, WhoIWas)
end


EVENT_MANAGER:RegisterForEvent("BorrowerAndLenderLoaded", EVENT_ADD_ON_LOADED, BorrowerAndLenderLoaded)