game_window = {}

function game_window.ReturnToMainMenu(_owner)
	local window_game = s4.ConvertToGameWindow(_owner)
	--window_game.PauseGame(false)
	--sf.core.g_applicationmisc.GetTimeManager().GetTimer(_T("animation_timer")).SetK(1)
	--sf.core.g_Application.GetTimeManager().GetTimer(_T("game")).SetK(1)
	--sf.core.g_Application.GetTimeManager().GetTimer(_T("animation_timer")).SetK(1)
	main_menu.show_main_menu(false, false)
end

function game_window.win_game_script(_owner, _name, _gems, _score)
	--[[
	local app = sf.core.g_Application
	local window = sf.gui.CWindow()
	window.Load(
		app.GetSettings().GetChild(_T("GUI"), false).GetChildByAttribute(_T("window"), _T("id"), _T("s4_win_dialog"), true), 
		app.GetSettings().GetChild(_T("GUITemplates"), false))
	local name_label_widget = __cast(window.GetWidget(_T("label_name")).get(), "sf.gui.CLabelWidget")
	name_label_widget.SetText(_name)
	local gems_label_widget = __cast(window.GetWidget(_T("label_total_gems")).get(), "sf.gui.CLabelWidget")
	gems_label_widget.SetText(_T(tostring(_gems)))

	local score_label_widget = __cast(window.GetWidget(_T("label_score")).get(), "sf.gui.CLabelWidget")
	score_label_widget.SetText(_T(tostring(_score)))
	
	--local label_widget = __cast(window.GetWidget(_T("message_label")).get(), "sf.gui.CLabelWidget")
	--label_widget.SetText(_T("you win game"))
	window.UpdateLayout()                                             
	MoveWindowToCenter(_owner, window)
	
	window_ptr = sf.gui.CBaseWindowPtrT(window)
	local modal_res = _owner.DoModal(window_ptr)
	window_ptr = nil
	collectgarbage()
	if modal_res == 1 then
		
	end]]

	game_window.ReturnToMainMenu(_owner)	
	--main_menu.show_main_menu(false, false)
end

function game_window.win_dialog_script(_owner, _action, _child)
	if _child then
		if _child.GetId()==_T("ok") and _action==_T("pressed") then
			_owner.EndModal(1)
		end
	end
end

function game_window.lose_game_script(_owner)
	local app = sf.core.g_Application
	local window = sf.gui.CWindow()
	window.Load(
		app.GetSettings().GetChild(_T("GUI"), false).GetChildByAttribute(_T("window"), _T("id"), _T("s4_lose_dialog"), true), 
		app.GetSettings().GetChild(_T("GUITemplates"), false))
	window.UpdateLayout()                                             
	MoveWindowToCenter(_owner, window)
	window_ptr = sf.gui.CBaseWindowPtrT(window)
	local modal_res = _owner.DoModal(window_ptr)
	window_ptr = nil
	collectgarbage()
	local window_game = s4.ConvertToGameWindow(_owner)
	if modal_res == 1 then
		window_game.InitGame(window_game.GetCampaignGUID(), window_game.GetLevelIndex(), 0, 0, game.StartLivesNum)
	elseif modal_res == 0 then
		game_window.ReturnToMainMenu(_owner)
	end
	
end

function game_window.lose_dialog_script(_owner, _action, _child)
	if _child then
		if _child.GetId()==_T("continue") and _action==_T("pressed") then
			_owner.EndModal(1)
		elseif _child.GetId()==_T("cancel") and _action==_T("pressed") then
			_owner.EndModal(0)
		end
	end
end

function game_window.start_game_menu_script(_owner)
	--[[
	local window = sf.gui.CWindow()
	local app = sf.core.g_Application
	window.Load(
		app.GetSettings().GetChild(_T("GUI"), false).GetChildByAttribute(_T("window"), _T("id"), _T("s4_options"), false),
		app.GetSettings().GetChild(_T("GUITemplates"), false))
	window.UpdateLayout()
	MoveWindowToCenter(_owner, window)
	
	local window_ptr = sf.gui.CBaseWindowPtrT(window)
	local modal_res = _owner.DoModal(window_ptr)
	window_ptr = nil
	collectgarbage()
	]]
	local modal_res = options_window.run_options_window(_owner, false)
	local window_game = s4.ConvertToGameWindow(_owner)
	if modal_res == 1 then
		window_game.PauseGame(false)
	elseif modal_res == 2 then
		local s4app = __cast(sf.core.g_Application, s4.CS4App) 
		if s4app.IsPlayTest()==true then
			s4.g_Statistics.Instance().GetCurrentRecord().StopReason = 3 -- s4.CStatistics.AbortByMainMenu
			s4.g_Statistics.Instance().Save()
			s4.g_Statistics.Instance().Clear()
		end
		game_window.ReturnToMainMenu(_owner)
	elseif modal_res == 0 then
		window_game.PauseGame(false)
	end
	
end

function game_window.lose_dialog_script(_owner, _action, _child)
	if _child then
		if _child.GetId()==_T("continue") and _action==_T("pressed") then
			_owner.EndModal(1)
		elseif _child.GetId()==_T("cancel") and _action==_T("pressed") then
			_owner.EndModal(0)
		end
	end
end

game_window.dif_checkboxses = {}


function game_window.select_difficulty_level_script(_owner, _action, _child)
	if _child then
		if _action==_T("check_changed") then
			local selected_checkbox_id = T_(_child.GetId())
		
			local selected_checkbox_num = -1
			for checkbox_num in pairs(game_window.dif_checkboxses) do
				if game_window.dif_checkboxses[checkbox_num].id == selected_checkbox_id.c_str() then
					selected_checkbox_num = checkbox_num
					if game_window.dif_checkboxses[checkbox_num].widget then
						game_window.dif_checkboxses[checkbox_num].widget.Check(true, false)
					end
					
				else
					if game_window.dif_checkboxses[checkbox_num].widget then
						game_window.dif_checkboxses[checkbox_num].widget.Check(false, false)
					end
				end
			end
		elseif _child.GetId()==_T("ok") and _action==_T("pressed") then
			for checkbox_num in pairs(game_window.dif_checkboxses) do
				if game_window.dif_checkboxses[checkbox_num].widget then
					if game_window.dif_checkboxses[checkbox_num].widget.IsChecked() then
						s4.g_Difficulty.Instance().SetDifficultyLevel(checkbox_num)
						break;
					end
				end
			end

		_owner.EndModal(1)
		end
	end



--[[
		elseif _action==_T("check_changed") then
			if options_window.checkbox_params[T_(_child.GetId()).c_str()] then
				local checkbox_widget = options_window.checkbox_params[T_(_child.GetId()).c_str()].widget
				if checkbox_widget then
					local checkbox_value = checkbox_widget.IsChecked()
					local set_fun = options_window.checkbox_params[T_(_child.GetId()).c_str()].set_function
					if set_fun then
						set_fun(checkbox_value)
						options_window.fill_widgets()
					end
				end
			end





	if _child.GetId()==_T("easy") and _action==_T("pressed") then
			_owner.EndModal(1)
		elseif _child.GetId()==_T("normal") and _action==_T("pressed") then
			_owner.EndModal(1)
		elseif _child.GetId()==_T("hard") and _action==_T("pressed") then
			_owner.EndModal(1)
		elseif _child.GetId()==_T("expert") and _action==_T("pressed") then
			_owner.EndModal(1)
		elseif _child.GetId()==_T("ok") and _action==_T("pressed") then
			_owner.EndModal(1)
		end
	end
]]
	
end

function game_window.run_difficulty_window(_owner)
	game_window.dif_checkboxses[0] = {}
	game_window.dif_checkboxses[0].id = "easy_checkbox"
	game_window.dif_checkboxses[0].widget = 0
		
	game_window.dif_checkboxses[1] = {}
	game_window.dif_checkboxses[1].id = "normal_checkbox"
	game_window.dif_checkboxses[1].widget = 0

	game_window.dif_checkboxses[2] = {}
	game_window.dif_checkboxses[2].id = "hard_checkbox"
	game_window.dif_checkboxses[2].widget = 0

	game_window.dif_checkboxses[3] = {}
	game_window.dif_checkboxses[3].id = "expert_checkbox"
	game_window.dif_checkboxses[3].widget = 0

	options_window.current_screen_mode = s4.g_GameOptions.Instance().GetScreenMode() 
	local app = sf.core.g_Application
	local window = sf.gui.CWindow()
	window.Load(
		app.GetSettings().GetChild(_T("GUI"), false).GetChildByAttribute(_T("window"), _T("id"), _T("s4_select_difficulty_level"), true), 
		app.GetSettings().GetChild(_T("GUITemplates"), false))
	window.UpdateLayout()                            
	options_window.owner_window = window
	MoveWindowToCenter(_owner, window)
	
	local current_dif_level = s4.g_Difficulty.Instance().GetDifficultyLevel()
	
	
	for checkbox_num in pairs(game_window.dif_checkboxses) do
		game_window.dif_checkboxses[checkbox_num].widget = 
			__cast(window.GetWidget(_T(game_window.dif_checkboxses[checkbox_num].id), true).get(), "sf.gui.CCheckboxWidget")
	end

	for checkbox_num in pairs(game_window.dif_checkboxses) do
		if game_window.dif_checkboxses[checkbox_num].widget then
			game_window.dif_checkboxses[checkbox_num].widget.Check(false, false)
		end
	end
	game_window.dif_checkboxses[current_dif_level].widget.Check(true, false)
	
	--[[
	if _hide_game_buttons then
		help_button = __cast(window.GetWidget(_T("help"), true).get(), "sf.gui.CButtonWidget")
		main_menu_button = __cast(window.GetWidget(_T("main_menu"), true).get(), "sf.gui.CButtonWidget")
		continue_button = __cast(window.GetWidget(_T("continue"), true).get(), "sf.gui.CButtonWidget")
		

		continue_button.SetText(sf.misc.g_StringTable.Instance().FormatByStringsID(options_window.main_menu_options_ok_button_string_id))

		set_widget_flag_value(help_button, sf.gui.CBaseWidget.FlagHidden, true)
		set_widget_flag_value(help_button, sf.gui.CBaseWidget.FlagDisabled, true)

		set_widget_flag_value(main_menu_button, sf.gui.CBaseWidget.FlagHidden, true)
		set_widget_flag_value(main_menu_button, sf.gui.CBaseWidget.FlagDisabled, true)
	end
	
	options_window.init_options_window(window)	
	]]
	window_ptr = sf.gui.CBaseWindowPtrT(window)
	return _owner.DoModal(window_ptr)
end



function game_window.start_dificulty_menu_script(_owner)
	--[[
	local window = sf.gui.CWindow()
	local app = sf.core.g_Application
	window.Load(
		app.GetSettings().GetChild(_T("GUI"), false).GetChildByAttribute(_T("window"), _T("id"), _T("s4_options"), false),
		app.GetSettings().GetChild(_T("GUITemplates"), false))
	window.UpdateLayout()
	MoveWindowToCenter(_owner, window)
	
	local window_ptr = sf.gui.CBaseWindowPtrT(window)
	local modal_res = _owner.DoModal(window_ptr)
	window_ptr = nil
	collectgarbage()
	]]
	local modal_res = game_window.run_difficulty_window(_owner)
	local window_game = s4.ConvertToGameWindow(_owner)
	window_game.PauseGame(false)

	--[[
	local window_game = s4.ConvertToGameWindow(_owner)
	if modal_res == 1 then
		window_game.PauseGame(false)
	elseif modal_res == 2 then
		local s4app = __cast(sf.core.g_Application, s4.CS4App) 
		if s4app.IsPlayTest()==true then
			s4.g_Statistics.Instance().GetCurrentRecord().StopReason = 3 -- s4.CStatistics.AbortByMainMenu
			s4.g_Statistics.Instance().Save()
			s4.g_Statistics.Instance().Clear()
		end
		game_window.ReturnToMainMenu(_owner)
	elseif modal_res == 0 then
		window_game.PauseGame(false)
	end
	]]
end

--[[
function game_window.game_window_dialog_script(_owner, _action, _child)
	if _action==_T("key_down_escape") then
		_owner.EndModal(1)
	elseif _child.GetId()==_T("continue") and _action==_T("pressed") then
		_owner.EndModal(1)
	elseif _child.GetId()==_T("main_menu") and _action==_T("pressed") then
		_owner.EndModal(0)
	end
end
]]

function game_window.level_rating(_owner, _action, _child)

	local app = sf.core.g_Application
	local window = sf.gui.CWindow()
	window.Load(
		app.GetSettings().GetChild(_T("GUI"), false).GetChildByAttribute(_T("window"), _T("id"), _T("s4_level_rating"), true), 
		app.GetSettings().GetChild(_T("GUITemplates"), false))
	window.UpdateLayout()                                             
	MoveWindowToCenter(_owner, window)
	window_ptr = sf.gui.CBaseWindowPtrT(window)
	
	_owner.DoModal(window_ptr)
	
	local combobox_rating = __cast(window.GetWidget(_T("combobox_rating")), sf.gui.CComboBoxWidget)
	local edit_opinion = __cast(window.GetWidget(_T("edit_opinion")), sf.gui.CEditWidget)
	local stat_record = s4.g_Statistics.Instance().GetCurrentRecord()
	
		
	if stat_record then
	
		stat_record.Rating = (combobox_rating.GetSelectedLine()+1)
		stat_record.Opinion = std.wstring(edit_opinion.GetText())
	
	end
	
	window_ptr = nil
	collectgarbage()
end

function game_window.level_rating_action(_owner, _action, _child)
	
	if _child then
		
		if _child.GetId()==_T("combobox_rating") and _action==_T("line_selected") then
		
			local combobox_rating = __cast(_child, sf.gui.CComboBoxWidget)
			if combobox_rating.GetSelectedLine() ~= -1 then
			
				local button_next = __cast(_owner.GetWidget(_T("button_next")), sf.gui.CButtonWidget)
				button_next.DisableButton(false)
			
			end
		
		elseif _child.GetId()==_T("button_next") and _action==_T("pressed") then
		
			_owner.EndModal(1)

		end
	end
end


send_statistics = {}

send_statistics.app = sf.core.g_Application

send_statistics.strings = {}
send_statistics.strings[0] = sf.misc.g_StringTable.Instance().FormatByStringsID(_T("$559"))

send_statistics.enum = {}
send_statistics.enum.connection_failed = 0
send_statistics.enum.transfer_failed = 1
send_statistics.enum.paused = 2
send_statistics.enum.cancelled = 3
send_statistics.enum.successful = 4

send_statistics.server = send_statistics.app.GetSettings().GetChild(_T("settings"), false).GetValue(_T("send_statistics_server"))
send_statistics.recipient = send_statistics.app.GetSettings().GetChild(_T("settings"), false).GetValue(_T("send_statistics_recipient"))

function send_statistics.LoadWindow(_owner, _window, _id)

	_window.Load(	send_statistics.app.GetSettings().GetChild(_T("GUI"), false).GetChildByAttribute(_T("window"), _T("id"), _id, true),
					send_statistics.app.GetSettings().GetChild(_T("GUITemplates"), false))
	
	_window.UpdateLayout()
	
	_window.SetOffset(	(_owner.GetSize().X - _window.GetSize().X) / 2.0,
						(_owner.GetSize().Y - _window.GetSize().Y) / 2.0)

end

send_statistics.on_child_action = {}

send_statistics.on_child_action.sending_statistics_connection = function(_owner, _action, _child)

	if _action == _T("pressed") then
		
		if _child.GetId() == _T("cancel") then _owner.EndModal(1) end
		if _child.GetId() == _T("continue") then _owner.EndModal(0) end
		
	end

end

send_statistics.on_child_action.sending_statistics = function(_owner, _action, _child)

	if _action == _T("pressed") then

		local smtp_client = __cast(_owner.GetWidget(_T("smtp_client")), sf.gui.CSMTPClient)
		smtp_client.Pause(true)
		
		_owner.EndModal(send_statistics.enum.paused)
	
	elseif _action == _T("changed") then

		local label_progress = __cast(_owner.GetWidget(_T("label_progress")), sf.gui.CLabelWidget);
		local progress_bar = __cast(_owner.GetWidget(_T("progress")), sf.gui.CProgressBarWidget);
		local smtp_client = __cast(_child, sf.gui.CSMTPClient)
		local state = smtp_client.GetState()
		
		local progress = (100 * smtp_client.GetProgress())
		local progress_text = _T(string.format(T_(send_statistics.strings[0]).c_str(), progress))

		label_progress.SetText(progress_text)
		progress_bar.SetValue(smtp_client.GetProgress())
		
		if state == sf.gui.CSMTPClient.StateConnectingFailed then
		
			_owner.EndModal(send_statistics.enum.connection_failed)
		
		elseif state == sf.gui.CSMTPClient.StateTransferringFailed then
		
			_owner.EndModal(send_statistics.enum.transfer_failed)
		
		elseif state == sf.gui.CSMTPClient.StateTransferringSuccessful then
			
			_owner.EndModal(send_statistics.enum.successful)
			
		end
		
	end

end

send_statistics.on_child_action.sending_statistics_disconnect = function(_owner, _action, _child)

	if _action == _T("pressed") then
		
		if _child.GetId() == _T("cancel") then _owner.EndModal(1) end
		if _child.GetId() == _T("continue") then _owner.EndModal(0) end
		
	end

end

send_statistics.on_child_action.sending_statistics_cancel = function(_owner, _action, _child)

	if _action == _T("pressed") then
		
		if _child.GetId() == _T("no") then _owner.EndModal(0) end
		if _child.GetId() == _T("yes") then _owner.EndModal(1) end
		
	end

end

send_statistics.on_child_action.sending_statistics_complete = function(_owner, _action, _child)

	if _action == _T("pressed") then
		
		if _child.GetId() == _T("ok") then _owner.EndModal(1) end
		
	end

end

send_statistics.on_child_action.sending_statistics_need_send = function(_owner, _action, _child)

	if _action == _T("pressed") then
		if _child.GetId() == _T("button_send") then 
			_owner.EndModal(1)
		elseif _child.GetId() == _T("button_skip") then 
			_owner.EndModal(0)
		end
	end
	
end

function game_window.save_statistics()

	local diffs = {}
	diffs[0] = "Easy"
	diffs[1] = "Normal"
	diffs[2] = "Hard"
	diffs[3] = "Expert"
	
	local reasons = {}
	reasons[0] = "Unknown"
	reasons[1] = "Complete"
	reasons[2] = "CompleteWarp"
	reasons[3] = "ByMainMenu"
	reasons[4] = "ByCloseButton"
	reasons[5] = "LostAllLives"
	
	local app = sf.core.g_Application
	local file_name = _T("stat.txt")
	local sending_text = _T("")
	local format_text = "%-12s\t%-33s\t%-15s\t%-20s\t%-8s\t%-10s\t%-11s\t%-11s\t%-11s\t%-11s\t%-11s\t%-11s\t%-15s\t%-5s\t%s\n"
	
	local file_exist = sf.misc.CheckExistPath(file_name)
	local append = true
	
	if file_exist==false then 
	
		append = false
	
		sending_text = sending_text + _T(string.format(format_text,	"Name", 
																	"GUID", 
																	"Difficulty", 
																	"Campaign", 
																	"LevelN", 
																	"Time", 
																	"LivesStart", 
																	"LivesEnd", 
																	"LevelScore", 
																	"TotalScore", 
																	"LevelGems", 
																	"TotalGems",
																	"StopReason",
																	"Grade",
																	"Description" ))
		sending_text = sending_text + _T("\n")

	end
	
	local rec_i = s4.g_Statistics.Instance().GetRecords()
	
	while rec_i.IsEnd()==false do
	
		local record = rec_i.Get()
		
		if record.StopReason ~= 0 then
		
			local secs = record.LevelTime
			local mins = secs/60
			local hours = mins/60
			mins = math.mod(mins, 60)
			secs = math.mod(secs, 60)
					
			sending_text = sending_text + _T(string.format(format_text, 	T_(record.PlayerName).c_str(),
																			T_(record.PlayerGUID).c_str(),
																			diffs[record.Difficulty],
																			T_(sf.misc.g_StringTable.Instance().FormatByStringsID(record.CampaignName)).c_str(),
																			tostring(record.LevelNumber+1),
																			string.format("%0.2i:%0.2i:%0.2i", hours, mins, secs),
																			tostring(record.LivesStart), 
																			tostring(record.LivesEnd), 
																			tostring(record.ScoresEnd-record.ScoresStart), 
																			tostring(record.ScoresEnd), 
																			tostring(record.GemsEnd-record.GemsStart), 
																			tostring(record.GemsEnd), 
																			reasons[record.StopReason], 
																			tostring(record.Rating), 
																			T_(record.Opinion).c_str()))
		end
		
		rec_i.Next()
	end
		
	sf.misc.WriteFile(file_name, sending_text, append, true)
	sf.misc.SetNamedFullAccess(file_name, false)

end

game_window.need_send_statistics = function(_owner, _action, _child)

	local app = sf.core.g_Application
	local result_sending = 0

	while result_sending == 0 do

		local dialog_need_send_statistics = sf.gui.CWindow()
		send_statistics.LoadWindow(_owner, dialog_need_send_statistics, _T("sending_statistics_need_send"))
		local dialog_need_send_statistics_ptr = sf.gui.CBaseWindowPtrT(dialog_need_send_statistics)
		
		local force_send_statistics = (app.GetSettings().GetChild(_T("settings"), false).GetValue(_T("force_send_statistics"))==_T("true"))
		local button_skip = __cast(dialog_need_send_statistics.GetWidget(_T("button_skip")), "sf.gui.CButtonWidget")
		if button_skip then button_skip.DisableButton(force_send_statistics) end
		
		if _owner.DoModal(dialog_need_send_statistics_ptr)==1 then
			result_sending = game_window.send_statistics(_owner)
		else
			break;
		end
	
	end

end

function game_window.send_statistics(_owner)

	local app = sf.core.g_Application
	local file_name = _T("stat.txt")

	local dialog_sending = sf.gui.CWindow()
	local dialog_sending_ptr = sf.gui.CBaseWindowPtrT(dialog_sending)
	
	send_statistics.LoadWindow(_owner, dialog_sending, _T("sending_statistics"))

	local smtp_client = sf.gui.CSMTPClient(_T("smtp_client"))
	local smtp_client_ptr = sf.gui.CWidgetPtrT(smtp_client)

	dialog_sending.AddWidget(smtp_client_ptr)

	local profile = s4.g_ProfileManager.Instance().GetCurrentProfile()

	local server = send_statistics.server
	local recipient = send_statistics.recipient
	local sender = _T("")
	if profile then sender = profile.GetName() end
	local subject = _T("statistics")
	local body = _T("")
	
	local sending_result = send_statistics.enum.paused	
	
	while sending_result ~= send_statistics.enum.successful and sending_result ~= send_statistics.enum.cancelled do
				
		sending_result = send_statistics.enum.paused
					
		while sending_result == send_statistics.enum.paused do
	
			smtp_client.Send(server, recipient, sender, subject, body, file_name);
			
			sending_result = _owner.DoModal(dialog_sending)
			
			if sending_result == send_statistics.enum.paused then
				
				local dialog_cancel = sf.gui.CWindow()
				send_statistics.LoadWindow(_owner, dialog_cancel, _T("sending_statistics_cancel"))
				local dialog_cancel_ptr = sf.gui.CBaseWindowPtrT(dialog_cancel)
				
				if _owner.DoModal(dialog_cancel) == 1 then
				
					smtp_client.Abort()
					sending_result = send_statistics.enum.cancelled
					
				else
				
					smtp_client.Pause(false)
				
				end
			
			end
		
		end
		
		if sending_result == send_statistics.enum.connection_failed then
		
			local dialog_connection_error = sf.gui.CWindow()
			send_statistics.LoadWindow(_owner, dialog_connection_error, _T("sending_statistics_connection"))
			local dialog_connection_error_ptr = sf.gui.CBaseWindowPtrT(dialog_connection_error)
			
			if _owner.DoModal(dialog_connection_error_ptr) == 1 then 
				sending_result = send_statistics.enum.cancelled 
			end
	
		elseif sending_result == send_statistics.enum.transfer_failed then
		
			local dialog_connection_error = sf.gui.CWindow()
			send_statistics.LoadWindow(_owner, dialog_connection_error, _T("sending_statistics_disconnect"))
			local dialog_connection_error_ptr = sf.gui.CBaseWindowPtrT(dialog_connection_error)
			
			if _owner.DoModal(dialog_connection_error_ptr) == 1 then 
				sending_result = send_statistics.enum.cancelled 
			end
	
		end
	
	end
	
	if sending_result == send_statistics.enum.successful then
			
		sf.misc.ShDeleteFile(file_name)
			
		local dialog_sending_complete = sf.gui.CWindow()
		send_statistics.LoadWindow(_owner, dialog_sending_complete, _T("sending_statistics_complete"))
		local dialog_sending_complete_ptr = sf.gui.CBaseWindowPtrT(dialog_sending_complete)

		_owner.DoModal(dialog_sending_complete_ptr)
		
		return 1
	
	end
	
	return 0

end
