Ext.onReady(function()	{
	Ext.QuickTips.init();

	var pageSize = 5;
	var ds = new Ext.data.JsonStore({
		autoLoad: {params: { limit: pageSize , start:0 }},
		url:'/support/get_news.php',
		totalProperty: 'results',
		root: 'rows',
		fields: ['Subject', 'Content', {name: 'Date_Entry', type: 'date', dateFormat: 'Y-m-d H:i:s'}]
	});

	var tpl = new Ext.XTemplate(
		'<tpl for=".">',
		'<div class="news_title"><div class="news_date">{[values.Date_Entry.format("M d, Y")]}</div>{Subject}</div>',
		'<div class="news_content">{Content}</div>',
		'</tpl>'
	);
	
	new Ext.Panel({
		applyTo: 'list',
		width: '100%',
		border: false,
		layout:'fit',
		items: new Ext.DataView({
			id: 'view',
			store: ds,
		    tpl: tpl,
		    autoHeight:true,
	        itemSelector:'',
		    emptyText: '<div style="padding:40px 20px; border-bottom: 1px solid #EBEBEB;">News not found</div>'
		}),
		bbar: new Ext.PagingToolbar({
			store: ds,
			displayInfo: true,
			style: 'border:1px solid #EBEBEB; border-top: none;  background: #F7F8F6 none;',
			pageSize: pageSize,
			emptyMsg: 'News not found'
		})
	});

	Ext.get('submit').on('click', function()	{
		t = Ext.DomQuery.selectNode('input[name=type]:checked');

		ds.setBaseParam('type', Ext.get(t).getValue());
		ds.setBaseParam('keyword', Ext.get('keyword').getValue());
		ds.load({params: {'start': 0, 'limit': pageSize}});
	});
});
