;(function($) {
	
	$.widget("ui.tsfDelete", $.extend({
	
		onLoaded: function(data) {
			$("#delete-message-box").fadeIn(800).fadeOut(800);
		},
	
		_init: function() {
			
			this.init.apply(this, arguments);
		},
		
	    init: function() {
			$.widget.prototype._init.apply(this,arguments)
	
			this.ajaxController = new AjaxController(this, '/tour/', '.php')
			var self = this
	
			this.element.click(function() {
	
				var tsf = $('#tsf').tourSearchForm('getParams')
				var count = $('#tsr').searchTourList('getCount')
	
				if (!count) {
					jAlert("Сначала осуществите поиск")
					return
				}
	
				if (!confirm("Удалить ВСЕ результаты подбора? \n"+
					"Их около "+count+".\n" +
					"Вы уверены?")) {
					return
				}
	
				var tsf_query = makeQuery(tsf)
				self.ajaxController.sendRequest({url:'delete', data: 'tsf='+tsf_query+'&nocache='+Math.random()})
			})
	
	    }
	
	
	}, stringLoadingWidgetMixin));
})(jQuery)