/*jslint laxbreak:true */
/*jslint laxcomma:true */
/*jslint loopfunc:true */
/*jslint strict:true */
/*jslint browser:true */
/*jslint devel:true */

define([
	"underscore"
	, "jquery"
	, "backbone"

	, "text!../../templates/app/layout.html"

	, "jquery-layout"
	, "jquery-ui"
]
, function (
_
, $
, Backbone

, tmplAppLayout
) {
	"use strict";

	var App		= Backbone.View.extend({
		el:				$("body")

		, Layout:		null
		, layoutItems:	null

		, events: {
		}

		, initialize: function() {
			_.bindAll(this
				, "toggleSideBar"
			);

			var that	= this
			;

			App.__super__.initialize.apply(that);

			that.$el.html(tmplAppLayout);

			that.Layout	= that.$el.layout({
				//applyDefaultStyles:		true
				defaults:		{
					closable:			false
					, resizable:		false
					, slidable:			false
					, spacing_open:		0
					, spacing_closed:	0
				}

				, north:		{
					size:				52
				}

				, west:		{
					size:				150
					, closable:			true
					, fxName:			"slider"
					// TODO: fx does not work
				}

				, center:	{
					resizable:			false
				}

				, south:	{
					size:				30
				}
			});

			return that;
		}

		, toggleSideBar:	function () {
			this.Layout.toggle("west");
		}
	});
	return App;
});