/**
  * Application Layout
  * by Jozef Sakalos, aka Saki
  * http://extjs.com/learn/Tutorial:Application_Layout_for_Beginners
  */
 
// reference local blank image
Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';
 
// create namespace
Ext.namespace('AdmeaDossier');


// create application
AdmeaDossier.app = function()
{
	// do NOT access DOM from here; elements don't exist yet
 
	// private variables
	var saveSession = false;

	
	// private functions

	
	// public space
	return {
		// public properties, e.g. strings to translate
		/*
		var mask = new Ext.LoadMask( Ext.getBody(), {
			msg: 'Initialising page...',
			removeMask: true
		});
	
		mask.enable();
		mask.show();
		*/
		// Windows
		viewport: null,
		loginPanel: null,
		
		// Panels
		tree: null,
		northPanel: null,
		contentPanel: null,
		southPanel: null,
		
		// Controls
		loginForm: null,
		submitBtn: null,

		updateInterface : function()
		{
			AdmeaDossier.Toolbar.update();
			AdmeaDossier.Statusbar.update();
		},

		// public methods
		init : function() {

			Ext.state.Manager.setProvider( new Ext.state.CookieProvider(
				{
					// path: "/cgi-bin/",
					expires: new Date(new Date().getTime()+(1000*60*60*24*30)) //30 days
					// domain: "dev"
			   }
			));

			this.northPanel = new Ext.Panel({
				region:'north',
				contentEl: 'titlebar',
				cls: 'titlebar',
				hideBorders: true,
				border: false,
				height:66
			});
			
			this.southPanel = new Ext.Panel({ 
				region:'south',
				contentEl: 'statusbar',
				cls: 'statusbar',
				hideBorders: true,
				border: false,
				height: 28
			});

			this.tree = AdmeaDossier.NodeTree.init(
				{
					el: 'treepanel',
					enableDD: false
				}
			);
			
			this.contentPanel = AdmeaDossier.Content.init();
			
			AdmeaDossier.Session.init();

			this.viewport = new Ext.Viewport({
				layout:'border',
				items:
				[
					this.northPanel,
					this.contentPanel,
					this.tree,
					this.southPanel
				]
			});

			this.contentPanel.header.addClass( 'panelHeaders' );
			this.tree.header.addClass( 'panelHeaders' );

			this.contentPanel.syncSize();
			this.tree.syncSize();

    		this.viewport.doLayout();

			this.tree.on( "click", AdmeaDossier.Content.nodeGetPage );
    		
    	    Ext.QuickTips.init();

			// turn on validation errors beside the field globally
		    Ext.form.Field.prototype.msgTarget = 'side';

			AdmeaDossier.Session.refresh();

			this.updateInterface();
			
			Ext.get( 'loading-background' ).hide( true );
			setTimeout( function() { Ext.get( 'loading' ).remove(); }, 750 );
		}
	};
}(); // end of app
 
// end of file
