Ext.onReady(function(){
	Ext.menu.RangeMenu.prototype.icons = {
	  gt: 'img/greater_then.png', 
	  lt: 'img/less_then.png',
	  eq: 'img/equals.png'
	};
	Ext.grid.filter.StringFilter.prototype.icon = 'img/find.png';
    
  	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	  
	var ds = new Ext.data.JsonStore({
	  url:'f.php',
    id: 'id',
    totalProperty: 'total',
    root: 'data',
    fields: [
   //   {name:'id'}, 
      {name:'Nome'}, 
      {name:'Cidade'}, 
      {name:'UF'}, 
      {name:'Pais'}
    ],
	  sortInfo: {field: 'Nome', direction: 'ASC'},
	  remoteSort: true
	});
  
	var filters = new Ext.grid.GridFilters({
	  filters:[
	  // {type: 'numeric',  dataIndex: 'id'},
	    {type: 'string',  dataIndex: 'Nome'},
	    {type: 'string', dataIndex: 'Cidade'},
	    {type: 'string',  dataIndex: 'UF'},
	    {type: 'string',  dataIndex: 'Pais'}
		]});
	
	var cm = new Ext.grid.ColumnModel([
	 // {dataIndex: 'id', header: 'Id'},
	  {dataIndex: 'Nome', header: 'Nome', id: 'Nome'},
	  {dataIndex: 'Cidade', header: 'Cidade'},
	  {dataIndex: 'UF',header: 'Estado'}, 
	  {dataIndex: 'Pais', header: 'Pais'}
		]);
	cm.defaultSortable = true;
	
	var grid = new Ext.grid.GridPanel({
	  id: 'example',
	  title: 'Família Imigrantes FM',
	  ds: ds,
	  cm: cm,
	  enableColLock: false,
	  loadMask: true,
	  plugins: filters,
	  height:220,
	  width:458,        
	  el: 'grid-example',
	//  buttonAlign :'center',
    autoExpandColumn: 'Nome',
	  bbar: new Ext.PagingToolbar({
	    store: ds,
	    pageSize: 6,
	    plugins: filters,
		  items:[
            '-', {
            pressed: true,
            enableToggle:true,
	         text: 'Novo Integrante...',
            iconCls: 'new-topic',
		   // cls: 'x-btn-text-icon details',
            toggleHandler: function(btn, pressed){
                var view = grid.getView();
                view.showPreview = pressed;
				 window.location = "../../../cad_img.htm";
                view.refresh();
            }

        }]

	  })
	});
	grid.render();
	
	ds.load({params:{start: 0, limit: 6}});
});