//  @import com.hedgehoglab.application.view.BaseView;
//  @import com.hedgehoglab.KeySequencer;

function SearchContactsView(scope){
    BaseView.call(this,scope);
    KeySequencer.call(this,{
        element:$('#fldSearchField',scope.element)
        ,on_sequence_ready:on_sequence_ready
        ,on_sequence_changed:on_sequence_changed
        ,thread_count:50
        ,thread_timeout:10
        ,min_value_length:3
    });

	$('#fldSearchField',scope.element).bind('keyup',function(e){
		return e.keyCode!=13;
	});

    var _this=this;
	var _term="";
	
    function on_sequence_ready(event){
		_term=event.val;
        _this.raise_event("on_search_term_changed",{term:event.val});
    };

    
    function on_sequence_changed(event){
	// console.log(event);
        if(event.val ==""){
			_term=event.val;
            _this.raise_event("on_search_term_empty",{term:event.val});
        }
    };


    $('#fldSearchField',scope.element).val("");
	
	this.repeat_search=function(e){
		// alert(_term)
		on_sequence_ready({val:_term});
	};
};
