{

	xtype: 'container',

	require: [
		'Ext.ux.stackorganizer.Field'
	],

	layout: 'fit',

	_pagestack: null,
	_parent: null,

	onInitialize: function(i_widget, i_owner) {

		var i_parent = i_owner.getDataParent(),
			o_config = i_owner._config,
			i_stack;

		i_widget._parent = i_parent;
		
		i_widget._pagestack = i_stack = Ext.create('Ext.ux.stackorganizer.Field', {
			dataTokenKey: 'PAGPAGTKN',
			xpd: 'stack.xpd',
			supportXpd: 'pages.xpd',
			dataParent: i_parent,
			name: 'PAGPAGTKN_XPD',
			cid: i_owner._config.id,
			border: false,
			listeners: {
				'needcid': {
					fn: function (i_s) {
						i_s.setCid(i_stack.getCid());	
					}
				}
			}
		});

		i_widget.add(i_stack);
	},

	getStack: function () {
		return this._pagestack;
	},
	getValue: function () {

		return this.getStack().getValue();
	},
	getDataParent: function () {

		return this.getStack().getDataParent();
	},

	doSave: function(f_callback) {

		f_callback || (f_callback=Ext.emptyFn);

		if ( !this.isDirty() ) {
			f_callback();
			return false;
		}

		var i_widget = this,
			i_stack = i_widget._pagestack,
			i_stackPanel = i_stack.getStackPanel(),
			o_value = i_stackPanel.getValue(),
			b_new = !o_value.stacktoken,
			token = i_stack.getToken(),
			n_token = Number(token),
			s_value;

		o_value.token = n_token;
		s_value = i_stack.rawToValue(o_value);

		Ext.Ajax.request({
			url: '/wsh-services/wshproxy.aspx',
			params: {
				action: 'updateStack',
				jsonData: s_value
			},
			success: function (o_resp) {

				if ( b_new ) {

					var o_json;

					try { o_json = ip2.JSON.parse(o_resp.responseText) }
					catch (err) {  }

					o_value.stacktoken = o_json.stacktoken;

					s_value = i_stack.rawToValue(o_value);
				}

				i_stack.resetOriginalValue(s_value);

				f_callback();
			}
		});

		return i_widget;	
	},
	doDelete: function(f_callback) {
		
		f_callback && f_callback();
	},

	isDirty: function() {
		
		return i_stack = this.getStack().isDirty();
	}
}