if m_simpleTV.Common.GetVersion() < 880 then  --b12.7.6
   local mess = "simpleTV version too old [".. select(2,m_simpleTV.Common.GetVersion())  .. "], need 0.5.0 b12.7.6"
   m_simpleTV.Interface.MessageBox(mess,"httpTimeshift",0x10)  
  return
 end

if not string.match(package.path, "user/httptimeshift/core", 0) then
  package.path = package.path .. ";" .. m_simpleTV.MainScriptDir .. "user/httptimeshift/core/?.lua"
end

local lang_code = m_simpleTV.Interface.GetLanguage()
  if m_simpleTV.Interface.GetLanguageCountry then
     lang_code = m_simpleTV.Interface.GetLanguageCountry()
end 

m_simpleTV.Interface.AddTranslator(   m_simpleTV.MainScriptDir_UTF8 
								     .. "user/httptimeshift/translations/lang_" 
								     .. lang_code)

require("httpTimeshift")

AddFileToExecute("onconfig", m_simpleTV.MainScriptDir .. "user/httptimeshift/initconfig.lua")

if httpTimeshift.isEnabled() then
  m_simpleTV.Timeshift.AddHandler('httpTimeshiftHandler', 5000,2,10)

  if httpTimeshift.isOldEnabled() then 
    pcall (function () dofile (m_simpleTV.MainScriptDir .. "user/httptimeshift/tvtimeshift.lua");end)
  end  
  
  if httpTimeshift.isGuiEnabled() then
-- Add ext Menu
	local t = {}
	t.utf8 = true -- string coding
	t.name = httpTimeshift.tr('Archive')
	t.luastring = 'user/httptimeshift/GUI/showDialog.lua' 
	t.key = 0x01000002
	t.ctrlkey = 2 -- modifier keys (type: number) (available value: 0 - not modifier keys, 1 - CTRL, 2 - SHIFT, 3 - CTRL + SHIFT )
	t.location = 0 --(0) - 0 - in main menu, 1 - in playlist menu, -1 all
	t.image = m_simpleTV.MainScriptDir_UTF8 .. 'user/httptimeshift/GUI/img/timeshift.png'
	m_simpleTV.Interface.AddExtMenuT(t)
 end    
 
 ---------------------------------------------------------------------
 --load extensions
 ---------------------------------------------------------------------
 require'ex'
 local pathname = m_simpleTV.MainScriptDir .. 'user/httptimeshift/extensions/'
 for entry in os.dir(pathname) do
  if string.match(entry.name,'%.lua$') then
	 dofile (pathname .. entry.name)
  end
 end
 ---------------------------------------------------------------------
end    


