function UserProfile(user_id,create,store){
	
	var some = Math.random();
	var userProfile = new Ext.FormPanel({
		frame: true,
		region: 'center',
        bodyStyle: 'padding:4px 4px 0',
        items: [{
			xtype: 'fieldset',
            collapsible: false,
            autoHeight: true,
            collapsed: false,
            bodyStyle: 'margin:4px;',
            items: [
			    {xtype: 'hidden', disabled: true, name: 'id', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'ID'},
			    {xtype:'label', text: 'Логин:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', disabled: !create, name: 'login', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'Логин'},
			    {xtype:'label', text: 'Новый пароль:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', inputType:"password", disabled: false, name: 'new_pass', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype:'label', text: 'Новый пароль (подтвердить):', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', inputType:"password", disabled: false, name: 'new_pass_confirm', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype:'label', text: 'Ф.И.О:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', disabled: false, name: 'full_name', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'ФИО'},
			    {xtype:'label', text: 'E-mail:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', disabled: false, name: 'email', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'E-mail'},
			    {xtype:'label', text: 'Номер мобильного телефона:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', disabled: false, name: 'mobile_phone', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'+7 928XXXXXXX'},
			    {xtype:'label', text: 'Номер домашнего телефона:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', disabled: false, name: 'home_phone', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'+7 495 XXXXXXX'}
			]
			
        }],
        buttons:[{
			text: 'Сохранить',
			handler: function(){
                userProfile.getForm().submit({
                    url: 'wrapper.php?mod=users&act=save&user_id='+user_id,
                    waitMsg: 'Выполнение запроса...',
                    success: function(p, o){
						if (o.result.success) {
							window.close();
							store.reload();
						} else {
							Ext.Msg.alert("Ошибка!",o.result.errors);
						}
                    },
					failure: function(form, o) {
						Ext.Msg.alert("Ошибка!",o.result.errors);
					}
                });
		      }
        	},{
        	text:'Закрыть',
        	handler: function(){
        		window.close();
        	}
        }
      ]
    });
    	
	var window = new Ext.Window({
		title: 'Профиль Пользователя',
		width: 400,
		height: 450,
		minWidth: 300,
		minHeight: 200,
		layout: 'fit',
		plain: true,
		bodyStyle: 'padding:4px;',
		buttonAlign: 'center',
		items: userProfile
	});
	
	var conn = new Ext.data.Connection();
	conn.request({
		url: "wrapper.php?mod=users&act=get",
		method: 'POST',
		params: {
			"user_id": user_id
		},
		success: function(req){
			var data = Ext.decode(req.responseText);
			window.show();
		},
		failure: function(){
			Ext.Msg.alert('Status', 'Ошибка');
		}
	});		

}

function getUsers(){
	
		var buttons=$.ajax({
		  url: "js_wrapper.php?mod=users&act=buttons",
		  async: false
		 }).responseText;

		var fields = [
						{name: 'id'},
						{name: 'login'},
						{name: 'full_name'},
						{name: 'mobile_phone'},
						{name: 'icq'},
						{name: 'skype'}
					];
					
		var mapping = [
						{name: 'id', mapping: 'id'},
						{name: 'login', mapping: 'login'},
						{name: 'full_name', mapping: 'full_name'},
						{name: 'mobile_phone', mapping: 'mobile_phone'},
						{name: 'icq', mapping: 'icq'},
						{name: 'skype', mapping: 'skype'}
					];	
					
		var columns = 	[
							{
								header: '#',
								dataIndex: 'id',
								hidden: true,
								sortable: true
							},{
								header: 'Пользователь',
								dataIndex: 'login',
								sortable: true
							},{
								header: 'Полное имя',
								dataIndex: 'full_name',
								sortable: true
							},{
								header: 'Номер моб. тел.',
								dataIndex: 'mobile_phone',
								sortable: true
							},{
								header: '#ICQ',
								dataIndex: 'icq',
								sortable: true
							},{
								header: 'Skype',
								dataIndex: 'skype',
								sortable: true
							}
						];					
	
	var store = new Ext.data.GroupingStore({
			remoteSort: true,
			sortInfo:{field: 'id', direction: "DESC"},
			proxy: new Ext.data.HttpProxy({
				url: "wrapper.php?mod=users&act=get"
			}),
			reader: new Ext.data.JsonReader({
				root: 'data',
				id: 'id',
				totalProperty: 'totalCount',
				fields: fields
			},
				mapping
			)
		});
	
	var grid = new Ext.grid.GridPanel({
		id: 'grid-users-',
		region: 'center',
		closable: true,
		store: store,
		groupField:'id',
		columns:columns,
		view: new Ext.grid.GroupingView({
			forceFit:true,
			groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
	    }),
		sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
		iconCls: "user-group",
		title: 'Пользователи',
		loadMask: {
			msg: "Загрузка данных..."
		},
		tbar: eval(buttons),

		bbar: new Ext.PagingToolbar({
			pageSize: 50,
			store: store,
			displayInfo: true,
			displayMsg: 'Отображаемые записи {0} - {1} of {2}',
			emptyMsg: "Нет записей"
		}),
		view: new Ext.grid.GroupingView({
            forceFit:true,
            showGroupName: false,
            enableNoGroups:false, // REQUIRED!
            hideGroupedColumn: true
        })
	});


	{
		
		grid.on('rowdblclick', function(grid, row, e) {
				var id=grid.getView().ds.getAt(row).data.id;
				var conn = new Ext.data.Connection();
				conn.request({
					url: "wrapper.php?mod=users&act=details",
					method: 'POST',
					params: {
						"id": id
					},
					success: function(req){
						var data = Ext.decode(req.responseText);
						tplDetails.overwrite(panelDetails.body, data);
					},
					failure: function(){
						Ext.Msg.alert('Status', 'Ошибка');
					}
				});		
				
				var tplDetails = new Ext.XTemplate(
				    '<p><tpl for="data">',
					'<p><b>ID:</b> {id}</p>',
				    '<p><b>Логин:</b> {login}</p>',
				    '<p><b>Полное Имя:</b> {full_name}</p>',
				    '<p><b>E-mail:</b> {email}</p>',
				    '<p><b>Мобильный телефон:</b> {mobile_phone}</p>',
				    '<p><b>Домашний телефон:</b> {home_phone}</p>',
				    '<p><b>Рабочий телефон:</b> {work_phone}</p>',
				    '<p><b>#ICQ:</b> {icq}</p>',
				    '<p><b>Skype:</b> {skype}</p>',
				    '</tpl></p>'
		
				);
		
				var panelDetails= new Ext.Panel({ 
					title:'Детали',
					frame: true,
					collapsible:true,
					autoScroll:true
				});						
				
				var m_user_details = new Ext.Panel({  
					title: 'Детали пользователя',
					layout:'border',
					closable: true,
					items:[{  
						title: 'Детали пользователя',
						frame: true,
						region:'center',
						autoScroll:true,
						items:[panelDetails]
					}]
				}); 			
				
				var tp = Ext.getCmp('main-tabs');
				tp.add(m_user_details).show();
				tp.doLayout();
				
			});
		
	}

	    var panel= {
	    	id: 'panel-users-',
			title: 'Пользователи',
			iconCls: 'user-group',
			closable: true,
			layout:'border',
			items:[grid]
		};
	
	var tp = Ext.getCmp('main-tabs');
	tp.add(panel).show();
	tp.doLayout();
	
	store.load({
		params: {
			start: 0,
			limit: 50
		}
	});
}