
var testHandler = function(e) {alert("test");};

Ext.ux.SimpleSearch = function(cfg) {
	Ext.apply(cfg,{
		items : [{
			xtype : 'textfield',
			width : 100,
			name : 'searchfield',
			autoWidth : true,
			emptyText: 'type here to search...'
		},{tag: 'div', height: 5},{
			xtype : 'dataview',
			itemSelector : 'div.ux-item',
			cls : 'ux-data-view-list',
			store : cfg.store,
			tpl : new Ext.XTemplate(
				'<tpl for=".">',
		        	'<div class="ux-item"><a  ext:qtitle="{name}" ext:qtip="{url}" href="{url}" target="_blank">{name}</a></div>',
				'</tpl>'
			),
			overClass : 'ux-item-over',
			style : {'overflow-y': 'scroll','height':cfg.height-30}
		}],
		bodyStyle : {'padding':'0px'}
	});		

		
	
	Ext.ux.SimpleSearch.superclass.constructor.call(this,cfg);
};

Ext.extend(Ext.ux.SimpleSearch,Ext.Panel,{
	
	onRender : function(ct, position) {
		Ext.ux.SimpleSearch.superclass.onRender.call(this,ct, position);
		
		this.getEl().on('keyup',this.filter,this);
		this.list = this.items.get(2);
		this.input = this.items.get(0);
		
		this.list.store.load();
		//this.list.on('click',function(list, index, node, e) {     new Ext.ToolTip({
	      //  target: node,
	       /// html: 'Click the X to close me',
	       // title: 'My Tip Title',
	       // autoHide: true
    	//}) });

		//this.on('afterrender',this.doAfter,this);
	},
	doLayout : function(shallow) {
		Ext.ux.SimpleSearch.superclass.doLayout.call(this,shallow);
		this.items.get(0).getEl().setWidth(this.getInnerWidth());
		this.items.get(2).setWidth(this.getInnerWidth());
		this.list.setHeight(this.getInnerHeight() - 30);
	},
	filter : function(e) {
		this.items.get(2).store.filter('name',this.items.get(0).getValue(),true,false);
	}		
});
