jQuery(
	function($) {

		/**
		For resize panels on main screen
		*/
		var maxWidth = 0;
		function getDirTreeMaxWidth () {
			var scrWidth = $('#main-content').width();
			return parseInt(scrWidth / 2);
		}

		function layout () 
		{
			var scrWidth = $('#main-content').width();
			var scrHeght = $(window).height();
			var dirTreeHeight = scrHeght - $('#title-bar').height() - $('#tools-bar').height() - $('#status-bar').height() - 2;

			$('#directory-view-container').height(dirTreeHeight);
			$('#directory-content-view-container').height(dirTreeHeight);
			$('#directory-content-view-container').width('calc(100% - ' + ($('#directory-view-container').width() + 8) + 'px)');
			var scollWidth = $('#directory-content-view-container').width();

			maxWidth = getDirTreeMaxWidth();

			$('#treeview-container').height(dirTreeHeight - 5);
		}

		layout ();

		$('#directory-view-container').resizable({
			maxWidth: maxWidth,
			minWidth: 220,
			handles: "e",
			resize: function (event, ui) {
				layout ();
			}
		});

		$(window).resize (function() {layout ();$('#directory-view-container').resizable({maxWidth: maxWidth});});

		/**
		END - For resize panels on main screen
		*/


		/**
		For Directory Tree
		*/

		var privateGrid = $('#file-container').violetGrid ({directoryContent:null});
		
		var privateTree =  $('#treeview-container').violetTree({
			container: $('#treeview-container'),
			expandEasing: 'easeOutBounce', 
			collapseEasing: 'easeOutBounce',
			homeDirNameDisplay: "Thư mục gốc",
			grid: privateGrid
		});
		
		/*var selectTree = $('#select-destination-tree').violetTree({
			container: $('#select-destination-tree'),
			expandEasing: 'easeOutBounce', 
			collapseEasing: 'easeOutBounce',
			homeDirNameDisplay: "Thư mục gốc"
		});*/
		
		$('#select-destination-tree').slimScroll({
	        height: '250px',
	        alwaysVisible: true,
	        disableFadeOut: true
	    });
		
		$('#btnNewFolder').click (function(){
		});
		
		/*$('#btnCopy').click (function(){
			privateTree.copy();
		});*/
		
		$('#btnDel').click (function() {
			var curDir = privateTree.getCurrentDir();
			privateTree.deleteDir(curDir);
		});
		
		$('#btnUpload').click (function() {
			var curDir = privateTree.getCurrentDir();
			privateTree.upload();
		});
		


		/**
		END - For Directory Tree
		*/

	}
);