
function OnNavigateComplete(Object)
  
  local value
  local usepm = ttvcore.GetPMState()

  if usepm==true then
     
	 local str = m_simpleTV.Common.string_toUTF8("<b>Используйте PasswordManager</b>",1251)
	 m_simpleTV.Dialog.SetElementHtml_UTF8(Object,"LogField",str)
	 m_simpleTV.Dialog.SetElementHtml_UTF8(Object,"PassField",str)
   else 
    value=m_simpleTV.Config.GetConfigString(m_simpleTV.Defines.ID_EXT_TORRENTTV_LOGIN)
    if value~=nil then  m_simpleTV.Config.SetElementValueString(Object,'Login',value) end

    value=m_simpleTV.Config.GetConfigString(m_simpleTV.Defines.ID_EXT_TORRENTTV_PASS)
    if value~=nil then m_simpleTV.Config.SetElementValueString(Object,'Pass1',value) end
  end	

  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_UPDATEPLSONSTART)
  if value~=nil then m_simpleTV.Config.SetCheckBoxValue(Object,'UpdateOnStart',value) end
  
  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_UPDATEPLSONREFRESH)
  if value~=nil then m_simpleTV.Config.SetCheckBoxValue(Object,'UpdateOnRefresh',value) end
  
  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_WITHOUTGROUP)
  if value==nil then value=0 end 
  m_simpleTV.Config.SetCheckBoxValue(Object,'CheckboxGroup',value)
  
  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_HDGROUP)
  if value==nil then value=1 end
  m_simpleTV.Config.SetCheckBoxValue(Object,'CheckboxHDGroup',value) 
  
  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_AUTOREFRESH)
  if value==nil then value=0 end
  m_simpleTV.Config.SetCheckBoxValue(Object,'RefreshOnError',value) 
    
  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_NOTADDMENU)
  if value==nil then value=0 end
  m_simpleTV.Config.SetCheckBoxValue(Object,'NotAddMenu',value) 	
  
  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_NOT_USE_TVS) or 0
  m_simpleTV.Config.SetCheckBoxValue(Object,'NotUseTVSScrapper',value) 	

  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_VIP_USE)
  if value==nil then value=1 end
  m_simpleTV.Config.SetCheckBoxValue(Object,'VIP_Use',value) 	
 
  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_VIP_USELQ)
  if value==nil then value=1 end
  m_simpleTV.Config.SetCheckBoxValue(Object,'VIP_UseLQ',value) 
  
  value=m_simpleTV.Config.GetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_VIP_LQGROUP)
  if value==nil then value=1 end
  m_simpleTV.Config.SetCheckBoxValue(Object,'VIP_LQGroup',value) 
	
m_simpleTV.Config.AddEventHandler(Object,'OnClick','ButtonRefreshPlst','OnClickButtonRefreshPlst')

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

function OnOk(Object)
 local value 
 local usepm = ttvcore.GetPMState()
 
 if usepm==true then
 
   else 
   value = m_simpleTV.Config.GetElementValueString(Object,'Login')
   if value~=nil then m_simpleTV.Config.SetConfigString(m_simpleTV.Defines.ID_EXT_TORRENTTV_LOGIN,value) end

   value = m_simpleTV.Config.GetElementValueString(Object,'Pass1')
   if value~=nil then m_simpleTV.Config.SetConfigString(m_simpleTV.Defines.ID_EXT_TORRENTTV_PASS,value) end
 end

 value = m_simpleTV.Config.GetCheckBoxValue(Object,'UpdateOnStart')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_UPDATEPLSONSTART,value) end

 value = m_simpleTV.Config.GetCheckBoxValue(Object,'UpdateOnRefresh')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_UPDATEPLSONREFRESH,value) end
 
 value = m_simpleTV.Config.GetCheckBoxValue(Object,'CheckboxGroup')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_WITHOUTGROUP,value) end
 
 value = m_simpleTV.Config.GetCheckBoxValue(Object,'CheckboxHDGroup')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_HDGROUP,value) end
 
 value = m_simpleTV.Config.GetCheckBoxValue(Object,'RefreshOnError')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_AUTOREFRESH,value) end
 
 value = m_simpleTV.Config.GetCheckBoxValue(Object,'NotAddMenu')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_NOTADDMENU,value) end
 
 value = m_simpleTV.Config.GetCheckBoxValue(Object,'NotUseTVSScrapper')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_NOT_USE_TVS,value) end

 value = m_simpleTV.Config.GetCheckBoxValue(Object,'VIP_Use')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_VIP_USE,value) end
  
 value = m_simpleTV.Config.GetCheckBoxValue(Object,'VIP_UseLQ')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_VIP_USELQ,value) end

 value = m_simpleTV.Config.GetCheckBoxValue(Object,'VIP_LQGroup')
 if value~=nil then m_simpleTV.Config.SetConfigInt(m_simpleTV.Defines.ID_EXT_TORRENTTV_VIP_LQGROUP,value) end

 require('ttvcore')
 ttvcore.TorrentTVCloseSession()
 
end
------------------------------------------------------------------
function OnClickButtonRefreshPlst(Object)

 OnOk(Object)
 dofile(m_simpleTV.MainScriptDir .. 'user\\TorrentTV\\TorrentTVRefreshPls.lua')
 
end
------------------------------------------------------------------
