
    local fhandle = io.open (m_simpleTV.MainScriptDir ..  "user/tvplaylists/tvmenu.ini")   
   if fhandle == nil then return end
   local str = fhandle:read('*a')
   fhandle:close()

   m_simpleTV.User.CDS.ScanServer = string.match(str,'ScanCDS=(%d);')
   if m_simpleTV.User.CDS.ScanServer == nil then m_simpleTV.User.CDS.ScanServer = 0 end

if m_simpleTV.Control.ChangeAdress ~= 'No' then return end

if not string.match( m_simpleTV.Control.CurrentAdress, '%$cdssvr' ) then return end

local inAdr = m_simpleTV.Control.CurrentAdress
m_simpleTV.Control.ChangeAdress='Yes'
m_simpleTV.Control.CurrentAdress = 'error'

if m_simpleTV.User.CDS.LastServer ~= nil and m_simpleTV.User.CDS.ScanServer == '1' then
  if m_simpleTV.User.CDS.SvrTable == nil then
    dofile(m_simpleTV.MainScriptDir .. "user/tvplaylists/cds/cdssvr.lua") 
    if m_simpleTV.User.CDS.SvrTable == nil then return end 
  end
end

if m_simpleTV.User.CDS.LastServer ==nil then
   if m_simpleTV.User.CDS.LastCheckServer == nil and m_simpleTV.User.CDS.ScanServer == '1' then
     dofile(m_simpleTV.MainScriptDir .. "user/tvplaylists/cds/checkcdssvr.lua") 
   end 
   dofile(m_simpleTV.MainScriptDir .. "user/tvplaylists/cds/getserver.lua")  

   if m_simpleTV.User.CDS.LastServer ==nil then return end
end

m_simpleTV.Control.EventPlayingInterval=1000
m_simpleTV.Control.EventTimeOutInterval=5000  

m_simpleTV.Control.CurrentAdress = string.gsub(inAdr,'%$cdssvr',m_simpleTV.User.CDS.LastServer)
--debug_in_file(m_simpleTV.Control.CurrentAdress .. '\n')