function OnNavigateComplete(Object3) 
m_simpleTV.Dialog.SetWindowIcon(Object3,m_simpleTV.MainScriptDir .. 'user\\Tools\\css\\favicon.ico',false)
  m_simpleTV.Config.AddEventHandler(Object3,'OnClick','ButtonFolderPicker','OnFolderPicker')
  m_simpleTV.Config.AddEventHandler(Object3,'OnClick','SaveButton','OnClickSaveButton')
  m_simpleTV.Config.AddEventHandler(Object3,'OnClick','CloseButton','OnClickCloseButton')
  m_simpleTV.Config.AddEventHandler(Object3,'OnClick','ButtonClearFilename','OnClickButtonClearFilename')

local disk = os.getenv('HOMEDRIVE')
local path = os.getenv('HOMEPATH')
m_simpleTV.Config.SetElementValueString(Object3,'Path',disk..path..'\\Desktop\\')
local filename = 'new_playlist.txt'
m_simpleTV.Config.SetElementValueString(Object3,'Filename',filename)
end
-----------------------------------------------------------------
function OnFolderPicker(Object3)
 local path =  m_simpleTV.Common.FolderPicker('Select directory')
 if path~=nil then 
    path = path .. '\\'
    m_simpleTV.Config.SetElementValueString(Object3,'Path',path) 
 end	
 
end
-----------------------------------------------------------------
function OnClickSaveButton(Object3)

 local Object =  m_simpleTV.Dialog.FindWindowById( 'tools_window_1' )
 local value = m_simpleTV.Config.GetElementValueString_UTF8(Object,'outText')
 local path = m_simpleTV.Config.GetElementValueString(Object3,'Path')
 local filename = m_simpleTV.Config.GetElementValueString(Object3,'Filename')
if filename == '' then return end
 path = path .. filename
 local fhandle = io.open (path , "w+")
 if fhandle==nil then return end
 fhandle:write(value)
 fhandle:close()
 m_simpleTV.OSD.ShowMessage('File saved successfully',0xFF00,5)
  m_simpleTV.Config.SetElementText(Object3, 'Mess', 'File saved successfully')
m_simpleTV.Common.Wait(2000)
m_simpleTV.Dialog.Close(Object3)
end
-----------------------------------------------------------------
function OnClickButtonClearFilename(Object3)
  m_simpleTV.Config.SetElementText(Object3, 'Filename', '')
end

function OnClickCloseButton(Object3)
  m_simpleTV.Dialog.Close(Object3)
end