Index: pro-bachkim-filespace/sourcecode/assets/js/vstree.js
===================================================================
--- pro-bachkim-filespace/sourcecode/assets/js/vstree.js	(revision 16)
+++ pro-bachkim-filespace/sourcecode/assets/js/vstree.js	(revision 17)
@@ -8,5 +8,5 @@
 			if( o.host == undefined ) o.host = 'http://localhost/';
 			if( o.script == undefined ) o.script = 'ajax/privatecontent/getcontent';
-			if( o.container == undefined ) o.container = $(this);
+			if( o.container == undefined ) o.container = null;
 			if( o.dirIDprefix == undefined ) o.dirIDprefix = 'vsdir_';
 
@@ -18,6 +18,8 @@
 			if( o.directoryTreeData == undefined ) o.directoryTreeData = null;
 			if( o.grid == undefined ) o.grid = null;
+			if( o.contextmenuON == undefined ) o.contextmenuON = true;
 			
 			var currentObj = {};
+			if ( currentObj.type == undefined ) currentObj.type = 'directory';
 			
 			// PRIVATE methods
@@ -49,4 +51,6 @@
 
 			var renderTree = function  (parseData) {
+				$(o.container).find ('.vstree').remove();
+				
 				o.directoryTreeData = parseData;				
 				var directoryData = parseData.DIRECTORIES;
@@ -56,5 +60,5 @@
 					name:o.homeDirNameDisplay,
 				});
-
+				
 				selectDir($(homeNode).find('> A'));
 				if (directoryData != null) {
@@ -63,5 +67,5 @@
 							id: directoryData[i].id,
 							name: directoryData[i].name,
-							curentNode: $('#' + o.dirIDprefix + directoryData[i].parentID).find('> A'),
+							currentNode: $(o.container).find('#' + o.dirIDprefix + directoryData[i].parentID).find('> A'),
 							hidden: (directoryData[i].parentID > 0) ? true : false
 						})
@@ -75,5 +79,5 @@
 				if( d.id == undefined ) d.id = null;
 				if( d.name == undefined ) d.name = null;
-				if( d.curentNode == undefined ) d.curentNode = null;
+				if( d.currentNode == undefined ) d.currentNode = null;
 				if( d.hidden == undefined ) d.hidden = true;
 				if( d.clickEvent == undefined ) d.clickEvent = openDir;
@@ -85,10 +89,10 @@
 					disabledItemsList = ['cut','delete'];
 				
-				if (d.curentNode != null) {
+				if (d.currentNode != null) {
 					var strHTML = '<ul class="vstree"><li id="' + o.dirIDprefix + d.id + '" class="directory collapsed"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>';
 
-					$(d.curentNode).parent().append(strHTML);
+					$(d.currentNode).parent().append(strHTML);
 					if (d.hidden == true) 
-						$('#' + o.dirIDprefix + d.id).parent().css('display','none');
+						$(o.container).find('#' + o.dirIDprefix + d.id).parent().css('display','none');
 					
 				}else if (d.id == 0){
@@ -103,5 +107,5 @@
 					newdir.id = d.id;
 					newdir.name = d.name;
-					newdir.parentID = $(d.curentNode).parent().attr('id').substring(o.dirIDprefix.length, $(d.curentNode).parent().attr('id').length);
+					newdir.parentID = $(o.container).find(d.currentNode).parent().attr('id').substring(o.dirIDprefix.length, $(d.currentNode).parent().attr('id').length);
 					o.directoryTreeData.DIRECTORIES.push(newdir);
 					sendtoGrid();
@@ -109,27 +113,31 @@
 				
 				//bind event on new node
-				$('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this);return false;});
-				
-				$('#' + o.dirIDprefix + d.id).find('a').contextMenu({
-					menu: 'treeMenu',
-					disabledItems: disabledItemsList
-				}, function(action, el, pos) {
-					selectDir(el);
-					switch(action) {
-						case 'rename':
-							rename(el);
-							break;
-						case 'share':
-							o.grid.showModal(action, currentObj);
-							break;
-						default:
-							break;
-					}
-				});
+				$(o.container).find('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this);return false;});
+				
+				if (o.contextmenuON) {
+					$(o.container).find('#' + o.dirIDprefix + d.id).find('a').contextMenu({
+						menu: 'treeMenu',
+						disabledItems: disabledItemsList
+					}, function(action, el, pos) {
+						selectDir(el);
+						switch(action) {
+							case 'rename':
+								rename(el);
+								break;
+							case 'share':
+							case 'copy':
+							case 'cut':
+								o.grid.showModal(currentObj, action);
+								break;
+							default:
+								break;
+						}
+					});
+				}
 				
 				if (d.customEvent != null) 
-					$('#' + o.dirIDprefix + d.id).find('a').bind(d.customEvent.eventName, function(e){d.customEvent.eventTrigger(this)});
-
-				return $('#' + o.dirIDprefix + d.id);
+					$(o.container).find('#' + o.dirIDprefix + d.id).find('a').bind(d.customEvent.eventName, function(e){d.customEvent.eventTrigger(this)});
+
+				return $(o.container).find('#' + o.dirIDprefix + d.id);
 			}
 			//END - Create a node of Tree
@@ -178,4 +186,6 @@
 
 			var sendtoGrid = function () {
+				if (o.grid == null) return false;
+				
 				o.grid.getData({
 								directoryTreeData: o.directoryTreeData,
@@ -327,4 +337,8 @@
         		return this;
     		};
+    		
+    		this.getSelectedObj = function () {
+    			return currentObj;
+    		}
 
 			return this.initialize();
