/**
 * @class Roo.gui.ApplicationPanel
 * @extends Ext.Panel
 *
 * The ApplicationPanel is located below the header (and tabs).
 * It switches between the "home" page and the layout of the application (map and surrounding panels)
 *
 * @author ssmeman
 * @version 1.0
 */

/**
 * @constructor
 * @param {Object} config Configuration options
 */
Roo.gui.ApplicationPanel = Ext.extend(Ext.Panel, {
	id : 'card'
	,buttonClose: messages.button.closeText()
	,aboutWindow_titleText: messages.contentPanel.aboutPanel.title()
	,contactWindow_titleText: messages.contentPanel.contactPanel.title()

	,initComponent : function() {
		// hard coded
		var config = {
			hideMode : !Ext.isIE?'offsets':'display'
			,layout : 'card'
			,activeItem : 'home'
			,border: false
			,defaults: {
				border: false
			}
			,items : [{
				id : 'actionAndContent'
				,layout : 'border'
				,defaults: {
					border: false
				}
				,items : [{
					xtype : 'actionPanel'
				},{
					xtype : 'contentPanel'
				}]
			},{
				id : 'home'
				,layout: 'border'
				,defaults: {
					border: false
				}
				,items : [{
					xtype: 'panel'
					,id: 'home-text'
					,region: 'center'
					,autoScroll : true
					,preventBodyReset: true
					,autoLoad : {
						url : './content/home.jsp?'
					}
				}]
			}]
		};

		// apply config
		Ext.apply(this, config);
		Ext.apply(this.initialConfig, config);

		// Call parent (required)
		Roo.gui.ApplicationPanel.superclass.initComponent.apply(this, arguments);

		eventHub.on({
			scope : this
			,'changedCard' : function(cardFunction) {
				switch (cardFunction.id) {
				case 'uitleg' :
					this.getLayout().setActiveItem('home');
					break;
				case 'main' :
					this.getLayout().setActiveItem('actionAndContent');
					break;
				}
			}
		});
	}

	,showContact: function() {
		var window = new Ext.Window({
			id: 'contact-window'
			,title: this.contactWindow_titleText
			,width: 990
			,height: 600
			,constrain: true
			,autoScroll: true
			,autoLoad : {
				url : './content/contact.jsp'
			}
			,buttons: [{
				text: this.buttonClose
				,handler: function(target, event) {
					target.findParentByType('window').close();
				}
			}]
		});
		window.show();
	}
	,showAbout: function() {
		var window = new Ext.Window({
			id: 'about-window'
			,title: this.aboutWindow_titleText
			,width: 500
			,height: 300
			,constrain: true
			,autoScroll: true
			,preventBodyReset: true
			,autoLoad : {
				url : './content/over.html'
			}
			,buttons: [{
				text: this.buttonClose
				,handler: function(target, event) {
					target.findParentByType('window').close();
				}
			}]
		});
		window.show();
	}
});

// register xtype to allow for lazy initialization
Ext.reg('applicationPanel', Roo.gui.ApplicationPanel);