{
	xtype: 'container',

	require: [
		'Ext.dfd.ux.packing.view.PackingManager'
	],

	closable: false,
	layout:'fit',
	onInitialize : function(i_widget, i_owner){

		var b_logoff = Boolean(ip2.qrystr.getValue('logoff')) || false;
		var a_modes = Ext.JSON.decode(ip2.qrystr.getValue('modes'), true) || [];

		var i_container = Ext.widget("packingmanager", {
			logoff: b_logoff,
			modes: a_modes
		});

		i_widget.add(i_container);

		window.onunload = function() {
			if (!i_container.isDestroyed) {
				var i_controller = i_container.getController();
				i_controller.close();
			}
		};

		ip2.addLogout(function() {
			if (!i_container.isDestroyed) {
				var i_controller = i_container.getController();
				i_controller.close();
			}
		});

		var a_buffer = [];

		function keyDown(i_event) {
			if (i_widget.ownerCt.getActiveTab && i_widget.ownerCt.getActiveTab() != i_widget) {
				a_buffer = [];
				return;
			}

			var i_viewModel = i_container.getViewModel();
			var i_grid = i_viewModel.get("packinggrid");
			var i_field = i_grid.down("#scancode");

			if (i_field.hasFocus) {
				a_buffer = [];
				return;
			}

			var tn = i_event.target.tagName.toLowerCase();

			if (tn == 'input' || tn == 'textarea') {
				return;
			}

			if (i_event.ctrlKey) {
				return;
			}

			// THIS IS NEEDED FOR Epiphany
			i_event.preventDefault();
		}

		function keyUp(i_event) {
			if (i_widget.ownerCt.getActiveTab && i_widget.ownerCt.getActiveTab() != i_widget) {
				return;
			}

			var n_code = i_event.keyCode;
			if (n_code > 95) {
				n_code = n_code - 48;
			}

			if (n_code >= 48 && n_code <= 57
				|| n_code >= 65 && n_code <= 90) {
				a_buffer.push(String.fromCharCode(n_code));
			}
			else if (n_code == 13) {

				var i_viewModel = i_container.getViewModel();
				var i_grid = i_viewModel.get("packinggrid");
				var i_field = i_grid.down("#scancode");
				var i_packbutton = i_grid.down("#packbutton");

				if (!i_field.hasFocus && a_buffer.length > 0) {
					var s_value = a_buffer.join("");
					i_field.setValue(s_value);
					i_field.doKeyEnter();
					a_buffer = [];
				}
				else {
					i_packbutton.getEl().dom.click();
				}
			}
		}

		document.body.addEventListener('keydown', keyDown);
		document.body.addEventListener('keyup', keyUp);

		i_widget.on({
			destroy: {
				fn: function() {
					document.body.removeEventListener('keydown', keyDown);
					document.body.removeEventListener('keyup', keyUp);
				}
			}
		});
	}
}
