function PacketsProfile(packet_id,create,store){
	
	var some = Math.random();
	var PacketsProfile = 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: 'name', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'Название'},
			    {xtype:'label', text: 'Скорость Download в Kbit/s:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', disabled: false, name: 'speed_down', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'Скорость Download'},
			    {xtype:'label', text: 'Скорость Upload в Kbit/s:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', disabled: false, name: 'speed_up', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'Скорость Upload'},
			    {xtype:'label', text: 'Цена:', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%'},
			    {xtype: 'textfield', disabled: false, name: 'price', cls:'x-form-check-group-label', hideLabel: true, anchor:'100%',emptyText:'Цена'}
			    	]
			
        }],
        buttons:[{
			text: 'Сохранить',
			handler: function(){
                PacketsProfile.getForm().submit({
                    url: 'wrapper.php?mod=services&sub=packets&act=save&packet_id='+packet_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: 310,
		minWidth: 300,
		minHeight: 200,
		layout: 'fit',
		plain: true,
		bodyStyle: 'padding:4px;',
		buttonAlign: 'center',
		items: PacketsProfile
	});
	
	var conn = new Ext.data.Connection();
	conn.request({
		url: "wrapper.php?mod=services&sub=packets&act=get",
		method: 'POST',
		params: {
			"packet_id": packet_id
		},
		success: function(req){
			var data = Ext.decode(req.responseText);
			window.show();
		},
		failure: function(){
			Ext.Msg.alert('Status', 'Ошибка');
		}
	});		
	
	
}

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

		var fields = [
						{name: 'id'},
						{name: 'name'},
						{name: 'speed_down'},
						{name: 'speed_up'},
						{name: 'price'},
					];
					
		var mapping = [
						{name: 'id', mapping: 'id'},
						{name: 'name', mapping: 'name'},
						{name: 'speed_down', mapping: 'speed_down'},
						{name: 'speed_up', mapping: 'speed_up'},
						{name: 'price', mapping: 'price'},
					];	
					
					
		var columns = 	[
							{
								header: '#',
								dataIndex: 'id',
								hidden: true,
								sortable: true
							},{
								header: 'Название',
								dataIndex: 'name',
								sortable: true
							},{
								header: 'Скорость Download Kbit/s',
								dataIndex: 'speed_down',
								sortable: true
							},{
								header: 'Скорость Upload Kbit/s',
								dataIndex: 'speed_up',
								sortable: true
							},{
								header: 'Стоимость',
								dataIndex: 'price',
								sortable: true
							}
						];					
	
	var store = new Ext.data.GroupingStore({
			remoteSort: true,
			sortInfo:{field: 'id', direction: "DESC"},
			proxy: new Ext.data.HttpProxy({
				url: "wrapper.php?mod=services&sub=packets&act=get"
			}),
			reader: new Ext.data.JsonReader({
				root: 'data',
				id: 'id',
				totalProperty: 'totalCount',
				fields: fields
			},
				mapping
			)
		});
	
	var grid = new Ext.grid.GridPanel({
		id: 'grid-packets-',
		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: "packets-note",
		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
        })
	});

	
	var tp = Ext.getCmp('main-tabs');
	tp.add(grid).show();
	tp.doLayout();
	
	store.load({
		params: {
			start: 0,
			limit: 50
		}
	});
}