Ext.onReady(function(){
	// alert('ExtJS ready!');
    // Custom rendering Template
	//#{tagUrl}<br />
    var resultTpl = new Ext.XTemplate(
        '<tpl for="."><div class="search-item">',
            '<h3><span>{tag_hits} brukere</span>{title}</h3>',
            '{excerpt}',
        '</div></tpl>'
    );

	
    var ds = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url: '/minside/ajax'
        }),
        reader: new Ext.data.JsonReader({
            root: 'topics',
            totalProperty: 'totalCount',
            id: 'tag_id'
        }, [
            {name: 'title', mapping: 'tag_name'},
			{name: 'tagUrl', mapping: 'tag_url'},
            {name: 'tagId', mapping: 'tag_id'},
            {name: 'tag_hits', mapping: 'tag_hits'},
            {name: 'excerpt', mapping: 'tag_description'}
        ])
    });


    
    var search1 = new Ext.form.ComboBox({
        store: ds,
        displayField:'title',
        typeAhead: false,
		minChars: 1,
        loadingText: 'Søker...',
        hideTrigger:true,
        tpl: resultTpl,
        applyTo: 'user-cat-1',
        itemSelector: 'div.search-item'
    });
	
    var search2 = new Ext.form.ComboBox({
        store: ds,
        displayField:'title',
        typeAhead: false,
		minChars: 1,
        loadingText: 'Søker...',
        hideTrigger:true,
        tpl: resultTpl,
        applyTo: 'user-cat-2',
        itemSelector: 'div.search-item'
    });
	
    var search3 = new Ext.form.ComboBox({
        store: ds,
        displayField:'title',
        typeAhead: false,
		minChars: 1,
        loadingText: 'Søker...',
        hideTrigger:true,
        tpl: resultTpl,
        applyTo: 'user-cat-3',
        itemSelector: 'div.search-item'
    });
    var search4 = new Ext.form.ComboBox({
        store: ds,
        displayField:'title',
        typeAhead: false,
		minChars: 1,
        loadingText: 'Søker...',
        hideTrigger:true,
        tpl: resultTpl,
        applyTo: 'user-cat-4',
        itemSelector: 'div.search-item'
    });
});