Ext.namespace('TJ.Admin.LM');

TJ.comp.PageLayoutPopupWindow = Ext.extend(TJ.comp.GenericPopupWindow,{
	stateId: 'TJ_Admin_LayoutPopupWindow',		// same stateId for both windows.
	width: 800,
	height: 500,
	title: 'Page Layout Editor',
	mode: 'page',
	initComponent: function() {
		this.items = this.designer = new TJ.Admin.LM.Designer({mode: this.mode});
		TJ.comp.PageLayoutPopupWindow.superclass.initComponent.call(this);
	},
	setValue: function(value){		// This will be JSON
		this.designer.setValue(value)
	},
	getValue: function(){
		return this.designer.getValue();
	}
});



TJ.comp.PageLayout = Ext.extend(TJ.comp.GenericTriggerField,{
	getDisplayValue:function(){
		console.log('dispvalue',this.objectValue);


		if(this.value==='')
			return 'Blank';
		try
		{
			this.json = Ext.util.JSON.decode(this.value);			
		}
		catch (ex)
		{
			this.json={};
		}

		if(this.json  && this.json.title)
			return 'Title: ' + this.json.title;
		return 'Invalid Layout! ' + this.value;
	},
	popupClass:TJ.comp.PageLayoutPopupWindow
});

Ext.reg('tjpagelayout',TJ.comp.PageLayout);

TJ.comp.ContentLayoutPopupWindow = Ext.extend(TJ.comp.PageLayoutPopupWindow,{
	title: 'Content Layout Editor',
	mode: 'content'
});

TJ.comp.ContentLayout = Ext.extend(TJ.comp.PageLayout,{
	popupClass: TJ.comp.ContentLayoutPopupWindow

});

Ext.reg('tjcontentlayout',TJ.comp.ContentLayout);


TJ.comp.SetLayoutPopupWindow = Ext.extend(TJ.comp.PageLayoutPopupWindow,{
	title: 'Layout Set Editor',
	mode: 'set'
});

TJ.comp.SetLayout = Ext.extend(TJ.comp.PageLayout,{
	popupClass: TJ.comp.SetLayoutPopupWindow

});

Ext.reg('tjsetlayout',TJ.comp.SetLayout);