AWP.Control.Layout = function(config) {
	AWP.Control.Layout.superclass.constructor.call(this, config);
};

Ext.extend(AWP.Control.Layout, Ext.Panel, {
	expandSouth: function(callback, scope, options) {
		var southPanel = this.getComponent('south');
		if (southPanel.collapsed) {
			southPanel.addListener('expand', function() {
				callback.apply(scope, options);
			}, this, {single: true})
			southPanel.expand();
		} else {
			callback.apply(scope, options);
		}
	}
});

AWP.Control.Layout.AWP = function() {
	var hBody = Ext.fly(document.body).getHeight();
	var hHead = document.getElementById('header') ? Ext.fly('header').getHeight() * 2 : 0;
	
	var config = {
		layout: 'border',
		height: 1000,// + AWP.cfg.LAYOUT.southRegionHeight - ,
		renderTo: 'layout-main',
		border: false,
		items: [{
				region: 'center',
				margins: '0 0 0 0',
				cmargins: '0 0 0 0',
				border: false,
				contentEl: 'layout-center'
			},{
				id: 'west',
				region: 'west',
				// 2009-07-03, Ma: use customized title
				//title: 'Search for Data',
				layout: 'accordion',
				layoutConfig: { animate: false },
				width: 200,
				margins: '0 0 0 0',
				cmargins: '0 0 0 0',
				border: false,
				autoScroll: true,
				collapsible: true,
				contentEl: 'layout_search'
			},{
				id: 'east',
				region: 'east',
				// 2009-07-03, Ma: use customized title
				//title: 'Spatia Data Catalog',
				layout: 'accordion',
				width: 200,
				margins: '0 0 0 0',
				cmargins: '0 0 0 0',
				border: false,
				autoScroll: true,
				collapsible: true,
				//collapsed: false,
				//contentEl: 'layout-east',
				contentEl: 'layer-tree'
			},{
				id: 'south',
				region: 'south',
				// 2009-07-03, Ma: use customized title
				//title: 'Search Results',
				margins: '0 0 0 0',
				cmargins: '0 0 0 0',
				border: false,
				collapsible: false,
				collapsed: false,
				height: AWP.cfg.LAYOUT.southRegionHeight,
				contentEl: 'layout-south'
		}]
	}
	return new AWP.Control.Layout(config);
}

AWP.Control.Layout.SEAWA = function() {
	var config = {
		layout: 'border',
		height: 850,
		renderTo: 'layout-main',
		border: false,
		items: [{
				region: 'center',
				margins: '0 0 0 0',
				cmargins: '0 0 0 0',
				border: false,
				contentEl: 'layout-center'
			},{
				id: 'west',
				region: 'west',
				layout: 'accordion',
				layoutConfig: { animate: false },
				width: 230,
				margins: '0 0 0 0',
				cmargins: '0 0 0 0',
				border: false,
				autoScroll: true,
				collapsible: true,
				collapsed: false,
				contentEl: 'layout-west'
			},{
				id: 'east',
				region: 'east',
				layout: 'accordion',
				width: 200,
				margins: '0 0 0 0',
				cmargins: '0 0 0 0',
				border: false,
				autoScroll: true,
				collapsible: true,
				collapsed: true,
				contentEl: 'layer-tree'
			}]
	}
	return new AWP.Control.Layout(config);
}
