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

function GenericSearchFieldView(scope){
    BaseView.call(this,scope);
    // KeySequencer.call(this,{
    //         element:$('#fldSearchField',scope.element)
    //         ,on_sequence_ready:on_sequence_ready
    //         ,on_sequence_changed:on_sequence_changed
    //         ,delay:400
    //         ,min_value_length:3
    //     });
	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;
	});
	
	$('#clear_field_action',scope.element).bind('click',function(e){
		alert("asdas")
		$('#fldSearchField',scope.element).val("");
		return false;
	});
	
	

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

    
    function on_sequence_changed(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});
	};
};
