function OnNavigateComplete(Object)

  m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','CheckButton','OnClickCheckButton')
  m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','UncheckButton','OnClickUncheckButton')

  m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','LocalCheckButton','OnClickLocalCheckButton')
 m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','LocalUncheckButton','OnClickLocalUncheckButton')
  m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','LocalLoadButton','OnClickLocalLoadButton')

  m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','MiscCheckButton','OnClickMiscCheckButton')
m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','MiscUncheckButton','OnClickMiscUncheckButton')
  m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','MisclLoadButton','OnClickMiscLoadButton')
 
  m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','worldCheckButton','OnClickWorldCheckButton')
m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','worldUncheckButton','OnClickWorldUncheckButton')
  m_simpleTV.Dialog.AddEventHandler(Object,'OnClick','worldLoadButton','OnClickWorldLoadButton')

  local conf = m_simpleTV.MainScriptDir .. "user/tvplaylists/tvmenu.ini"
  local fhandle = io.open (conf , "r")
if fhandle == nil then 

 -- m_simpleTV.Dialog.SetCheckBoxValue(Object,'UseLocalLogo',1)

  local SibirRange1 = '176.51.0.0'  
  local SibirRange2 = '176.51.20.255'  
  local SibirPorts = '1234'  
  local SibirRate = '500'  

  local MiralogicRange1 = '46.48.0.0'
  local MiralogicRange2 = '46.48.100.255'  
  local MiralogicPorts = '81'  
  local MiralogicRate = '500'  

  local TriolanRange1 = '109.86.168.0'  
  local TriolanRange2 = '109.87.47.255'  
  local TriolanPorts = '4022,8888,1212'  
  local TriolanRate = '500'  

  local CDSRange1 = '5.105.0.0'  
  local CDSRange2 = '5.105.40.255'  
  local CDSPorts = '1234'  
  local CDSRate = '500'  

  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'SibirRange1', SibirRange1)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'SibirRange2', SibirRange2)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'SibirPorts', SibirPorts)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'SibirRate', SibirRate)

  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'MiralogicRange1', MiralogicRange1)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'MiralogicRange2', MiralogicRange2)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'MiralogicPorts', MiralogicPorts)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'MiralogicRate', MiralogicRate)

  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'TriolanRange1', TriolanRange1)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'TriolanRange2', TriolanRange2)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'TriolanPorts', TriolanPorts)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'TriolanRate', TriolanRate)

  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'CDSRange1', CDSRange1)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'CDSRange2', CDSRange2)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'CDSPorts', CDSPorts)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'CDSRate', CDSRate)
 
  return 
end
  local str = fhandle:read('*all')
  fhandle:close()

  local value
  if str == nil or str == '' then value=0 end

  if string.match(str,'Hasbahca') then value=1 else value=0 end
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Hasbahca',value)

  if string.match(str,'Filmon') then value=1 else value=0 end
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Filmon',value)
 
--  if string.match(str,'Lamp') then value=1 else value=0 end
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Lamp',value)

  if string.match(str,'Edem') then value=1 else value=0 end
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Edem',value)

--  if string.match(str,'4iptv') then value=1 else value=0 end 
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'4iptv',value)

  if string.match(str,'TTV') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'TTV',value)

--  if string.match(str,'NTV') then value=1 else value=0 end  
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'NTVPlus',value)

--  if string.match(str,'VietTV') then value=1 else value=0 end  
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'VietTV',value)

--  if string.match(str,'YooLive') then value=1 else value=0 end  
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'YooLive',value)

  if string.match(str,'Preset') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'PresetPls',value)

  if string.match(str,'World') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'WorldPls',value)

  if string.match(str,'Miscellaneous') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscPls',value)
---------------------
  if string.match(str,'UpdateAtStartTTV') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'UpdateAtStartTTV',value)

--  if string.match(str,'UpdateAtStartLamp') then value=1 else value=0 end  
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'UpdateAtStartLamp',value)

  if string.match(str,'UseLocalLogo') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'UseLocalLogo',value)

  if string.match(str,'DownloadLogo') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'DownloadLogo',value)
-----------------
  if string.match(str,'ScanSibir') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'ScanSibir',value)

  if string.match(str,'ScanMiralogic') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'ScanMiralogic',value)

  if string.match(str,'ScanTriolan') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'ScanTriolan',value)

  if string.match(str,'ScanCDS') then value=1 else value=0 end  
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'ScanCDS',value)

  local SibirRange1 = string.match(str,'SibirRange1=(.-);')
  if SibirRange1 == nil then SibirRange1 = '176.51.0.0' end
  local SibirRange2 = string.match(str,'SibirRange2=(.-);')
  if SibirRange2 == nil then SibirRange2 = '176.51.20.255' end
  local SibirPorts = string.match(str,'SibirPorts=(.-);')
  if SibirPorts == nil then SibirPorts = '1234' end
  local SibirRate = string.match(str,'SibirRate=(.-);')
  if SibirRate == nil then SibirRate = '500' end

  local MiralogicRange1 = string.match(str,'MiralogicRange1=(.-);')
  if MiralogicRange1 == nil then MiralogicRange1 = '46.48.0.0' end
  local MiralogicRange2 = string.match(str,'MiralogicRange2=(.-);')
  if MiralogicRange2 == nil then MiralogicRange2 = '46.48.40.255' end
  local MiralogicPorts = string.match(str,'MiralogicPorts=(.-);')
  if MiralogicPorts == nil then MiralogicPorts = '81' end
  local MiralogicRate = string.match(str,'MiralogicRate=(.-);')
  if MiralogicRate == nil then MiralogicRate = '500' end

  local TriolanRange1 = string.match(str,'TriolanRange1=(.-);')
  if TriolanRange1 == nil then TriolanRange1 = '109.86.168.0' end
  local TriolanRange2 = string.match(str,'TriolanRange2=(.-);')
  if TriolanRange2 == nil then TriolanRange2 = '109.87.47.255' end
  local TriolanPorts = string.match(str,'TriolanPorts=(.-);')
  if TriolanPorts == nil then TriolanPorts = '4022,8888,1212' end
  local TriolanRate = string.match(str,'TriolanRate=(.-);')
  if TriolanRate == nil then TriolanRate = '500' end

  local CDSRange1 = string.match(str,'CDSRange1=(.-);')
  if CDSRange1 == nil then CDSRange1 = '5.105.0.0' end
  local CDSRange2 = string.match(str,'CDSRange2=(.-);')
  if CDSRange2 == nil then CDSRange2 = '5.105.40.255' end
  local CDSPorts = string.match(str,'CDSPorts=(.-);')
  if CDSPorts == nil then CDSPorts = '1234' end
  local CDSRate = string.match(str,'CDSRate=(.-);')
  if CDSRate == nil then CDSRate = '500' end

  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'SibirRange1', SibirRange1)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'SibirRange2', SibirRange2)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'SibirPorts', SibirPorts)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'SibirRate', SibirRate)

  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'MiralogicRange1', MiralogicRange1)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'MiralogicRange2', MiralogicRange2)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'MiralogicPorts', MiralogicPorts)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'MiralogicRate', MiralogicRate)

  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'TriolanRange1', TriolanRange1)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'TriolanRange2', TriolanRange2)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'TriolanPorts', TriolanPorts)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'TriolanRate', TriolanRate)

  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'CDSRange1', CDSRange1)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'CDSRange2', CDSRange2)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'CDSPorts', CDSPorts)
  m_simpleTV.Dialog.SetElementText_UTF8(Object, 'CDSRate', CDSRate)


  m_simpleTV.Dialog.SetElementValueString(Object,'LocalSibir','Sibir')
  m_simpleTV.Dialog.SetElementValueString(Object,'LocalTriolan','Triolan')
  m_simpleTV.Dialog.SetElementValueString(Object,'LocalNTVPlus','NTV Plus')
  --m_simpleTV.Dialog.SetElementValueString(Object,'LocalZabava','Zabava')
  --m_simpleTV.Dialog.SetElementValueString(Object,'LocalDivan','Divan')
  m_simpleTV.Dialog.SetElementValueString(Object,'LocalMiralogic','Miralogic')
  m_simpleTV.Dialog.SetElementValueString(Object,'LocalSatx','Sat-x')
  m_simpleTV.Dialog.SetElementValueString(Object,'LocalCDS','CDS')


  m_simpleTV.Dialog.SetElementValueString(Object,'MiscLugansk','Lugansk')
  m_simpleTV.Dialog.SetElementValueString(Object,'MiscPosle','TV Posle')
  m_simpleTV.Dialog.SetElementValueString(Object,'MiscKinoman','Kinoman')
  m_simpleTV.Dialog.SetElementValueString(Object,'MiscSatElit','SatElit')
  m_simpleTV.Dialog.SetElementValueString(Object,'MiscRockin','Rockin')
  m_simpleTV.Dialog.SetElementValueString(Object,'MiscTutHD','TutHD')


  m_simpleTV.Dialog.SetElementValueString(Object,'worldVietTV','VietTV')
--  m_simpleTV.Dialog.SetElementValueString(Object,'worldYooLive','YooLive')
  m_simpleTV.Dialog.SetElementValueString(Object,'worldOneplayTV','OneplayTV')
--  m_simpleTV.Dialog.SetElementValueString(Object,'world4iptv','4iptv')
  m_simpleTV.Dialog.SetElementValueString(Object,'worldArconaiTV','ArconaiTV')
  m_simpleTV.Dialog.SetElementValueString(Object,'worldYamgoTV','YamgoTV')
  m_simpleTV.Dialog.SetElementValueString(Object,'worldspbtv','SPBTV')
  m_simpleTV.Dialog.SetElementValueString(Object,'worldDivan','Divan')
  m_simpleTV.Dialog.SetElementValueString(Object,'worldDittoTV','DittoTV')
end
------------------------------------------------------------------
function OnClickCheckButton(Object)

  local value=1
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Hasbahca',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Lamp',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Edem',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'4iptv',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'SatElit',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Lugansk',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Kinoman',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'NTVPlus',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'VietTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'PresetPls',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'WorldPls',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscPls',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'TTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Filmon',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'YooLive',value)

end

function OnClickUncheckButton(Object)

  local value=0
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Hasbahca',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Lamp',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Edem',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'4iptv',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'SatElit',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Lugansk',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Kinoman',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'NTVPlus',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'VietTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'PresetPls',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'WorldPls',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscPls',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'TTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'Filmon',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'YooLive',value)
end
--------------------------------------------------------------
function OnClickLocalCheckButton(Object)

  local value=1
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalSibir',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalTriolan',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalNTVPlus',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalZabava',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalDivan',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalMiralogic',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalSatx',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalCDS',value)

end

function OnClickLocalUncheckButton(Object)

  local value=0
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalSibir',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalTriolan',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalNTVPlus',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalZabava',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalDivan',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalMiralogic',value)
 -- m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalSatx',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'LocalCDS',value)

end

function OnClickMiscCheckButton(Object)

  local value=1
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscLugansk',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscPosle',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscKinoman',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscSatElit',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscRockin',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscTutHD',value)

end

function OnClickMiscUncheckButton(Object)

  local value=0
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscLugansk',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscPosle',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscKinoman',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscSatElit',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscRockin',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'MiscTutHD',value)

end

function OnClickWorldCheckButton(Object)

  local value=1
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'world4iptv',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldVietTV',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldYooLive',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldOneplayTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldArconaiTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldYamgoTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldspbtv',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldDivan',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldDittoTV',value)

end

function OnClickWorldUncheckButton(Object)

  local value=0
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'world4iptv',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldVietTV',value)
--  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldYooLive',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldOneplayTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldArconaiTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldYamgoTV',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldspbtv',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldDivan',value)
  m_simpleTV.Dialog.SetCheckBoxValue(Object,'worldDittoTV',value)

end
---------------------------------------------------------------
function OnClickWorldLoadButton(Object)

  local fip = ''
  local spb = ''
  local div = ''
  local vie = ''
  local arb = ''
  local lat = ''
  local arc = ''
  local yam = ''
  local dit = ''


--[[]
  local fipvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'world4iptv')
  if fipvalue~=nil and fipvalue~=0 then
    fip = m_simpleTV.Dialog.GetElementValueString(Object,'world4iptv') 
    fip =  fip .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/4iptv/4iptv.lua')  
  end 
]]
  local spbvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'worldspbtv')
  if spbvalue~=nil and spbvalue~=0 then
    spb = m_simpleTV.Dialog.GetElementValueString(Object,'worldspbtv') 
    spb =  spb .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/spbtv/spbtv.lua')  
  end 

  local divvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'worldDivan')
  if divvalue~=nil and divvalue~=0 then
    div = m_simpleTV.Dialog.GetElementValueString(Object,'worldDivan') 
    div =  div .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/divan/divan.lua')  
  end 

  local vievalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'worldVietTV')
  if vievalue~=nil and vievalue~=0 then
    vie = m_simpleTV.Dialog.GetElementValueString(Object,'worldVietTV') 
    vie =  vie .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/viet/hplus.lua')  
    m_simpleTV.Common.Wait(1000)	 
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/viet/ztv.lua')
    m_simpleTV.Common.Wait(1000)	 
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/viet/fptplay.lua')
  end 

--[[
  local arbvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'worldYooLive')
  if arbvalue~=nil and arbvalue~=0 then
    arb = m_simpleTV.Dialog.GetElementValueString(Object,'worldYooLive') 
    arb =  arb .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/yoolive/yoolivepls.lua')  
  end 


  local latvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'worldOneplayTV')
  if latvalue~=nil and latvalue~=0 then
    lat = m_simpleTV.Dialog.GetElementValueString(Object,'worldOneplayTV') 
    lat =  lat .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/oneplaytv/oneplaytv.lua')  
  end 
]]
  local arcvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'worldArconaiTV')
  if arcvalue~=nil and arcvalue~=0 then
    arc = m_simpleTV.Dialog.GetElementValueString(Object,'worldArconaiTV') 
    arc =  arc .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/arconai/arconaitv.lua')  
  end 

  local yamvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'worldYamgoTV')
  if yamvalue~=nil and yamvalue~=0 then
    yam = m_simpleTV.Dialog.GetElementValueString(Object,'worldYamgoTV') 
    yam =  yam .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/yamgo/yamgo.lua')  
  end 

  local ditvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'worldDittoTV')
  if ditvalue~=nil and ditvalue~=0 then
    dit = m_simpleTV.Dialog.GetElementValueString(Object,'worldDittoTV') 
    dit =  dit .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/ditto/dittotv.lua')  
  end 

    if divvalue ~= 0 or spbvalue ~= 0 or vievalue ~= 0 or arbvalue ~= 0 or latvalue ~= 0 or arcvalue ~= 0 or yamvalue ~= 0 or ditvalue ~= 0 then
      m_simpleTV.Interface.MessageBox('WorldTV playlists: ' .. spb .. div ..  vie .. arb .. lat .. arc .. yam .. dit .. '\nloading is complete.','Load WorldTV playlists',0,Object)
    end

end

function OnClickMiscLoadButton(Object)

  local lug = ''
  local psl = ''
  local kin = ''
  local sat = ''
  local rck = ''
  local tut = ''


  local lugvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'MiscLugansk')
  if lugvalue~=nil and lugvalue~=0 then
    lug = m_simpleTV.Dialog.GetElementValueString(Object,'MiscLugansk') 
    lug =  lug .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/lugansk/lugansk.lua')
  end 

  local pslvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'MiscPosle')
  if pslvalue~=nil and pslvalue~=0 then
    psl = m_simpleTV.Dialog.GetElementValueString(Object,'MiscPosle') 
    psl =  psl .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/tvposle/tvposle.lua')  
  end 

  local kinvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'MiscKinoman')
  if kinvalue~=nil and kinvalue~=0 then
    kin = m_simpleTV.Dialog.GetElementValueString(Object,'MiscKinoman') 
    kin =  kin .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/kinoman/kinoman.lua')  
  end 
--[[
  local satvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'MiscSatElit')
  if satvalue~=nil and satvalue~=0 then
    sat = m_simpleTV.Dialog.GetElementValueString(Object,'MiscSatElit') 
    sat =  sat .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/satelit/satelit.lua')  
  end 

  local rckvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'MiscRockin')
  if rckvalue~=nil and rckvalue~=0 then
    rck = m_simpleTV.Dialog.GetElementValueString(Object,'MiscRockin') 
    rck =  rck .. ', '
   dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/rockin/zabava.lua')
   m_simpleTV.Common.Wait(5000)
  dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/rockin/ntv.lua')
  m_simpleTV.Common.Wait(5000)	 
   dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/rockin/divan.lua')
  end 
]]
  local tutvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'MiscTutHD')
  if tutvalue~=nil and tutvalue~=0 then
    tut = m_simpleTV.Dialog.GetElementValueString(Object,'MiscTutHD') 
    tut =  tut .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/tuthd/tuthdpls.lua')  
  end 

    if lugvalue ~= 0 or pslvalue ~= 0 or kinvalue ~= 0 or satvalue ~= 0 or rckvalue ~=0 or tutvalue ~=0 then
      m_simpleTV.Interface.MessageBox('Miscellaneous playlists: ' .. lug .. psl .. kin .. sat.. rck .. tut .. '\nloading is complete.','Load miscellaneous playlists',0,Object)
    end
end

function OnClickLocalLoadButton(Object)

  local sib = ''
  local tri = ''
  local ntv = ''
  local zab = ''
  local dvn = ''
  local mlg = ''
  local sat = ''
  local cds = ''

  local svalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'LocalSibir')
  if svalue~=nil and svalue~=0 then
    sib = m_simpleTV.Dialog.GetElementValueString(Object,'LocalSibir') 
    sib =  sib .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/sibir/loadsibirm3u.lua')
  end 

  local tvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'LocalTriolan')
  if tvalue~=nil and tvalue~=0 then 
    tri = m_simpleTV.Dialog.GetElementValueString(Object,'LocalTriolan') 
    tri =  tri .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/triolan/loadtriolanm3u.lua')  
  end    

  local nvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'LocalNTVPlus')
  if nvalue~=nil and nvalue~=0 then 
    ntv = m_simpleTV.Dialog.GetElementValueString(Object,'LocalNTVPlus') 
    ntv =  ntv .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/ntv/loadntvplusm3u.lua')  
  end    
--[[
  local zvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'LocalZabava')
  if zvalue~=nil and zvalue~=0 then 
    zab = m_simpleTV.Dialog.GetElementValueString(Object,'LocalZabava') 
    zab =  zab .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/zabava/loadzabavam3u.lua')  
  end    

  local dvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'LocalDivan')
  if dvalue~=nil and dvalue~=0 then 
    dvn = m_simpleTV.Dialog.GetElementValueString(Object,'LocalDivan') 
    dvn =  dvn .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/divan/loaddivanm3u.lua')  
  end    
]]
  local mirvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'LocalMiralogic')
  if mirvalue~=nil and mirvalue~=0 then 
    mlg = m_simpleTV.Dialog.GetElementValueString(Object,'LocalMiralogic') 
    mlg =  mlg .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/miralogic/loadmiralogicm3u.lua')  
  end   
--[[
  local satvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'LocalSatx')
  if satvalue~=nil and satvalue~=0 then 
    sat = m_simpleTV.Dialog.GetElementValueString(Object,'LocalSatx') 
    sat =  sat .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/satx/loadsatxm3u.lua')  
  end  
]]

  local cdsvalue = m_simpleTV.Dialog.GetCheckBoxValue(Object,'LocalCDS')
  if cdsvalue~=nil and cdsvalue~=0 then 
    cds = m_simpleTV.Dialog.GetElementValueString(Object,'LocalCDS') 
    cds =  cds .. ', '
    dofile(m_simpleTV.MainScriptDir .. 'user/tvplaylists/cds/loadcdsm3u.lua')  
  end  

    if svalue ~= 0 or tvalue ~= 0 or nvalue ~= 0 or zvalue ~= 0 or dvalue ~= 0 or mirvalue~=0 or satvalue~= 0 then
      m_simpleTV.Interface.MessageBox('Preset playlists: ' .. sib .. tri .. ntv .. zab .. dvn .. mlg .. sat .. cds .. '\nloading is complete.','Load preset playlists',0,Object)
    end
end

------------------------------------------------------------------
function OnOk(Object)

 local conf = m_simpleTV.MainScriptDir .. "user/tvplaylists/tvmenu.ini"
 local fhandle = io.open (conf , "w+")
 if fhandle == nil then return end
 fhandle:write('')
 fhandle:close()

  local value
  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'Hasbahca') 
  if value~=nil and value~=0 then 
        value = '<"Hasbahca (World) VIP","user/tvplaylists/hasbahca/hasbahca.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'Filmon') 
  if value~=nil and value~=0 then 
        value = '<"Filmon LiveTV (World)","user/tvplaylists/filmon/filmonpls.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'TTV') 
  if value~=nil and value~=0 then 
        value = '<"TTV (Torrent TV)","user/tvplaylists/ttv/ttv.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
--[[]
  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'Lamp') 
  if value~=nil and value~=0 then 
        value = '<"Lamp (Russian)","user/tvplaylists/lamp/lamp.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
]]
  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'Edem') 
  if value~=nil and value~=0 then 
        value = '<"Edem.tv (Russian)","user/tvplaylists/edemtv/EdemTVinit.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
--[[
  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'4iptv') 
  if value~=nil and value~=0 then 
        value = '<"4ip.tv (Russian)","user/tvplaylists/4iptv/4iptv.lua">'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'NTVPlus') 
  if value~=nil and value~=0 then 
        value = '<"NTV Plus (Russian)","user/tvplaylists/ntv/ntvwebpls.lua">'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'VietTV') 
  if value~=nil and value~=0 then 
        value = '<"VietTV (Vietnamese)","user/tvplaylists/viet/vietinit.lua">'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'YooLive') 
  if value~=nil and value~=0 then 
        value = '<"YooLive (Arabic)","user/tvplaylists/yoolive/yoolivepls.lua">'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
]]
  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'PresetPls') 
  if value~=nil and value~=0 then 
        value = '<"Preset playlists","user/tvplaylists/tvscr/loadpresetpls.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'WorldPls') 
  if value~=nil and value~=0 then 
        value = '<"World TV playlists","user/tvplaylists/tvscr/loadworldpls.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'MiscPls') 
  if value~=nil and value~=0 then 
        value = '<"Miscellaneous playlists ","user/tvplaylists/tvscr/loadmiscpls.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
-----------------------------Scan OSD menu
        value = '<"Scan","user/tvplaylists/tvscr/scansvr.lua">\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()

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

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'UpdateAtStartTTV') 
  if value~=nil and value~=0 then 
        value = 'UpdateAtStartTTV=1;\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
--[[]
  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'UpdateAtStartLamp') 
  if value~=nil and value~=0 then 
        value = 'UpdateAtStartLamp=1;\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
]]
  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'UseLocalLogo') 
  if value~=nil and value~=0 then 
        value = 'UseLocalLogo=1;\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'DownloadLogo') 
  if value~=nil and value~=0 then 
        value = 'DownloadLogo=1;\n'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	

  local scan_opt
  local SibirRange1 = m_simpleTV.Dialog.GetElementValueString(Object,'SibirRange1')
  local SibirRange2 = m_simpleTV.Dialog.GetElementValueString(Object,'SibirRange2')
  local SibirPorts = m_simpleTV.Dialog.GetElementValueString(Object,'SibirPorts')
  local SibirRate = m_simpleTV.Dialog.GetElementValueString(Object,'SibirRate')

if SibirRange1 ~= '' and SibirRange2 ~= '' and SibirPorts ~= '' and SibirRate ~= '' then
   scan_opt = 
'#Sibir\n' ..
'rate = ' .. SibirRate .. '\n' ..
'output-format = list\n' ..
'output-filename = sibirsvr.txt\n' ..
'ports = ' .. SibirPorts .. '\n' ..
'range = ' .. SibirRange1 .. '-' .. SibirRange2 .. '\n' 

elseif SibirRange1 == '' or SibirRange2 == '' or SibirPorts == '' or SibirRate == '' then
  scan_opt = 
'#Sibir\n' ..
'rate = 500\n' ..
'output-format = list\n' ..
'output-filename = sibirsvr.txt\n' ..
'ports = 1234\n' ..
'range = 176.51.0.0-176.51.20.255\n' 
end
  	fhandle = io.open (m_simpleTV.MainScriptDir .. 'user\\tvplaylists\\misc\\masscan\\sibir.conf' , "w+")
        fhandle:write(scan_opt)
        fhandle:close()

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'ScanSibir') 
  if value~=nil and value~=0 and SibirRange1 ~= '' and SibirRange2 ~= '' and SibirPorts ~= '' and SibirRate ~= '' then 
        value = 'ScanSibir=1;\n' .. 
'SibirRange1=' .. SibirRange1 .. ';\n' .. 
'SibirRange2=' .. SibirRange2 .. ';\n' .. 
'SibirPorts=' .. SibirPorts .. ';\n' .. 
'SibirRate=' .. SibirRate .. ';\n'  
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
        m_simpleTV.User.Sibir.LastCheckServer = nil
        m_simpleTV.User.Sibir.ScanServer = nil
   end	
   if value == 0 then m_simpleTV.User.Sibir.LastServer = nil m_simpleTV.User.Sibir.ScanServer = nil end
-------------------------------------------------------
  local MiralogicRange1 = m_simpleTV.Dialog.GetElementValueString(Object,'MiralogicRange1')
  local MiralogicRange2 = m_simpleTV.Dialog.GetElementValueString(Object,'MiralogicRange2')
  local MiralogicPorts = m_simpleTV.Dialog.GetElementValueString(Object,'MiralogicPorts')
  local MiralogicRate = m_simpleTV.Dialog.GetElementValueString(Object,'MiralogicRate')

if MiralogicRange1 ~= '' and MiralogicRange2 ~= '' and MiralogicPorts ~= '' and MiralogicRate ~= '' then
   scan_opt = 
'#Miralogic\n' ..
'rate = ' .. MiralogicRate .. '\n' ..
'output-format = list\n' ..
'output-filename = miralogicsvr.txt\n' ..
'ports = ' .. MiralogicPorts .. '\n' ..
'range = ' .. MiralogicRange1 .. '-' .. MiralogicRange2 .. '\n' 

elseif MiralogicRange1 == '' or MiralogicRange2 == '' or MiralogicPorts == '' or MiralogicRate == '' then
  scan_opt = 
'#Miralogic\n' ..
'rate = 500\n' ..
'output-format = list\n' ..
'output-filename = miralogicsvr.txt\n' ..
'ports = 81\n' ..
'range = 46.48.0.0-46.48.100.255\n' 
end
  	fhandle = io.open (m_simpleTV.MainScriptDir .. 'user\\tvplaylists\\misc\\masscan\\miralogic.conf' , "w+")
        fhandle:write(scan_opt)
        fhandle:close()

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'ScanMiralogic') 
  if value~=nil and value~=0 and MiralogicRange1 ~= '' and MiralogicRange2 ~= '' and MiralogicPorts ~= '' and MiralogicRate ~= '' then 
        value = 'ScanMiralogic=1;\n' ..
'MiralogicRange1=' .. MiralogicRange1 .. ';\n' .. 
'MiralogicRange2=' .. MiralogicRange2 .. ';\n' .. 
'MiralogicPorts=' .. MiralogicPorts .. ';\n' .. 
'MiralogicRate=' .. MiralogicRate .. ';\n' 
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
   if value == 0 then m_simpleTV.User.Miralogic.LastServer = nil m_simpleTV.User.Miralogic.ScanServer = nil end
-----------------------------------------------------
  local TriolanRange1 = m_simpleTV.Dialog.GetElementValueString(Object,'TriolanRange1')
  local TriolanRange2 = m_simpleTV.Dialog.GetElementValueString(Object,'TriolanRange2')
  local TriolanPorts = m_simpleTV.Dialog.GetElementValueString(Object,'TriolanPorts')
  local TriolanRate = m_simpleTV.Dialog.GetElementValueString(Object,'TriolanRate')

if TriolanRange1 ~= '' and TriolanRange2 ~= '' and TriolanPorts ~= '' and TriolanRate ~= '' then
   scan_opt = 
'#Triolan\n' ..
'rate = ' .. TriolanRate .. '\n' ..
'output-format = list\n' ..
'output-filename = triolansvr.txt\n' ..
'ports = ' .. TriolanPorts .. '\n' ..
'range = ' .. TriolanRange1 .. '-' .. TriolanRange2 .. '\n' 

elseif TriolanRange1 == '' or TriolanRange2 == '' or TriolanPorts == '' or TriolanRate == '' then
  scan_opt = 
'#Triolan\n' ..
'rate = 500\n' ..
'output-format = list\n' ..
'output-filename = triolansvr.txt\n' ..
'ports = 4022,8888,1212\n' ..
'range = 109.86.168.0-109.87.47.255\n' 
end
  	fhandle = io.open (m_simpleTV.MainScriptDir .. 'user\\tvplaylists\\misc\\masscan\\triolan.conf' , "w+")
        fhandle:write(scan_opt)
        fhandle:close()

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'ScanTriolan') 
  if value~=nil and value~=0 and TriolanRange1 ~= '' and TriolanRange2 ~= '' and TriolanPorts ~= '' and TriolanRate ~= '' then 
        value = 'ScanTriolan=1;\n' ..
'TriolanRange1=' .. TriolanRange1 .. ';\n' .. 
'TriolanRange2=' .. TriolanRange2 .. ';\n' .. 
'TriolanPorts=' .. TriolanPorts .. ';\n' .. 
'TriolanRate=' .. TriolanRate .. ';\n' 
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
   if value == 0 then m_simpleTV.User.Triolan.LastServer = nil m_simpleTV.User.Triolan.ScanServer = nil end
---------------------------------------------------------------------------------
  local CDSRange1 = m_simpleTV.Dialog.GetElementValueString(Object,'CDSRange1')
  local CDSRange2 = m_simpleTV.Dialog.GetElementValueString(Object,'CDSRange2')
  local CDSPorts = m_simpleTV.Dialog.GetElementValueString(Object,'CDSPorts')
  local CDSRate = m_simpleTV.Dialog.GetElementValueString(Object,'CDSRate')

if CDSRange1 ~= '' and CDSRange2 ~= '' and CDSPorts ~= '' and CDSRate ~= '' then
   scan_opt = 
'#CDS\n' ..
'rate = ' .. CDSRate .. '\n' ..
'output-format = list\n' ..
'output-filename = cdssvr.txt\n' ..
'ports = ' .. CDSPorts .. '\n' ..
'range = ' .. CDSRange1 .. '-' .. CDSRange2 .. '\n' 

elseif CDSRange1 == '' or CDSRange2 == '' or CDSPorts == '' or CDSRate == '' then
  scan_opt = 
'#CDS\n' ..
'rate = 500\n' ..
'output-format = list\n' ..
'output-filename = cdssvr.txt\n' ..
'ports = 1234\n' ..
'range = 5.105.0.0-5.105.40.255\n' 
end
  	fhandle = io.open (m_simpleTV.MainScriptDir .. 'user\\tvplaylists\\misc\\masscan\\cds.conf' , "w+")
        fhandle:write(scan_opt)
        fhandle:close()

  value = m_simpleTV.Dialog.GetCheckBoxValue(Object,'ScanCDS') 
  if value~=nil and value~=0 and CDSRange1 ~= '' and CDSRange2 ~= '' and CDSPorts ~= '' and CDSRate ~= '' then 
        value = 'ScanCDS=1;\n' ..
'CDSRange1=' .. CDSRange1 .. ';\n' .. 
'CDSRange2=' .. CDSRange2 .. ';\n' .. 
'CDSPorts=' .. CDSPorts .. ';\n' .. 
'CDSRate=' .. CDSRate .. ';\n' 
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
   end	
   if value == 0 then m_simpleTV.User.CDS.LastServer = nil m_simpleTV.User.CDS.ScanServer = nil end
------------------------------------------------------------------------------


 local fhandle = io.open (conf , "r")
 if fhandle == nil then return end
 value = fhandle:read('*all')
 fhandle:close()

 if value == '' then 
        value = '<"Not available","">'
  	fhandle = io.open (conf , "a+")
        fhandle:write(value)
        fhandle:close()
 end


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