Index: trunk/expressoMail1_2/templates/default/folderExpresso.ejs
===================================================================
--- trunk/expressoMail1_2/templates/default/folderExpresso.ejs	(revision 5744)
+++ trunk/expressoMail1_2/templates/default/folderExpresso.ejs	(revision 5744)
@@ -0,0 +1,8 @@
+<div style="background: #F7F7F7; float:left; position: absolute; left:10px; border:2px outset #000; top:20px; width: 390px !important; height: 215px !important; overflow:auto;"></div>
+
+<div style="position: absolute; left: 410px; top:20px;">
+	<input type="button" onclick="proxy_mensagens.proxy_create_folder();" value="<%=data.new_folder%>" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" /><br/>
+	<input type="button" onclick="proxy_mensagens.proxy_remove_folder();" value="<%=data.delete_folder%>" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" /><br/>
+	<input type="button" onclick="proxy_mensagens.proxy_rename_folder();" value="<%=data.rename_folder%>" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" /><br/>
+	<input type="button" onclick="proxy_mensagens.proxy_export_all_msg();" value="<%=data.export_messages%>" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" />
+</div>
Index: trunk/expressoMail1_2/templates/xsl/treeFolders.xsl
===================================================================
--- trunk/expressoMail1_2/templates/xsl/treeFolders.xsl	(revision 5440)
+++ 	(revision )
@@ -1,22 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-	
-	<xsl:output method="html" omit-xml-declaration="yes"/>
-	<xsl:param name="delete_folder"/>
-	<xsl:param name="export_messages"/>
-	<xsl:param name="new_folder"/>
-	<xsl:param name="rename_folder"/>
-	
-	<xsl:template match="treeFolders">
-
-		<div style="background: #F7F7F7; float:left; position: absolute; left:10px; border:2px outset #000; top:20px; width: 390px !important; height: 215px !important; overflow:auto;"></div>
-
-		<div style="position: absolute; left: 410px; top:20px;">
-			<input type="button" onclick="proxy_mensagens.proxy_create_folder();" value="{$new_folder}" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" /><br/>
-			<input type="button" onclick="proxy_mensagens.proxy_remove_folder();" value="{$delete_folder}" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" /><br/>
-			<input type="button" onclick="proxy_mensagens.proxy_rename_folder();" value="{$rename_folder}" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" /><br/>
-			<input type="button" onclick="proxy_mensagens.proxy_export_all_msg();" value="{$export_messages}" class="button ui-button ui-widget ui-state-default ui-corner-all" role="button" aria-disabled="false" />
-		</div>
-
-	</xsl:template>
-</xsl:stylesheet>
Index: trunk/expressoMail1_2/js/common_functions.js
===================================================================
--- trunk/expressoMail1_2/js/common_functions.js	(revision 5738)
+++ trunk/expressoMail1_2/js/common_functions.js	(revision 5744)
@@ -622,11 +622,12 @@
 }
 
-function folderbox(){
+function folderbox()
+{
 	connector.loadScript("TreeS");
-	if (typeof(ttree) == 'undefined'){
-		setTimeout('folderbox()',500);
-		return false;
-	}
-	ttree.make_Window();
+
+	if( typeof(window.ttree) == 'undefined')
+		setTimeout(function(){ folderbox(); }, 200 );
+	else
+		ttree.load();
 }
 
Index: trunk/expressoMail1_2/js/TreeS.js
===================================================================
--- trunk/expressoMail1_2/js/TreeS.js	(revision 5581)
+++ trunk/expressoMail1_2/js/TreeS.js	(revision 5744)
@@ -1,35 +1,80 @@
-function treeS()
+(function()
 {
-	this.FOLDER 		= "";
-	this.xtools 		= new xtools('../expressoMail1_2/templates/');
-	this.parentHtml		= null;
-}
-
-treeS.prototype.make_Window = function()
-{
-	var div 	= null;
-	var args	= null;
+	var FOLDER	=	"";
 	
-	args = 
+	function foldersExpresso(){ }
+	
+	function load()
 	{
-		"delete_folder"		: get_lang('Delete folder'),
-		"export_messages"	: get_lang('Export messages'),
-		"new_folder" 		: get_lang('New folder'),
-		"rename_folder"		: get_lang('Rename folder')
-	};
-
-	div					= document.createElement("div");
-	div.id				= "divTreeFolders";
-	div.innerHTML		= this.xtools.parse(this.xtools.xml('treeFolders'), 'treeFolders.xsl', args );
-	this.parentHtml 	= div;
+		var div = document.createElement("div");
+		
+		var args = 
+		{
+			"delete_folder"		: get_lang('Delete folder'),
+			"export_messages"	: get_lang('Export messages'),
+			"new_folder" 		: get_lang('New folder'),
+			"rename_folder"		: get_lang('Rename folder')
+		};
+		
+		$(div).html(DataLayer.render("./templates/default/folderExpresso.ejs", args ));
+		
+		$(div).dialog(
+		{
+			resizable	: false,
+			title		: get_lang("Manager your folders and export messages"),
+			position	: 'center',
+			width		: 600,
+			height		: 300,
+			modal		: false,
+			buttons		: [
+							{
+								text: get_lang("Close"),
+								click: function()
+								{
+									$(this).dialog("destroy");
+									div.removeChild( div.firstChild );
+								},
+								style: "margin-top: -2.1em" 
+							}
+			],
+			beforeClose	: function()
+			{ 
+				$(this).dialog("destroy");
+				div.removeChild( div.firstChild );
+			},
+			open : function()
+			{
+				if( folders.length == 0 )
+				{
+					write_msg( "ERRO : Sem dados" );
+					$(div).dialog("destroy");
+					div.removeChild(div.firstChild);
+					return false;
+				}
+				else
+				{
+					if( Element('dftree_treeFolders') != null )
+					{
+						$(div).dialog("destroy");
+						div.removeChild( div.firstChild );
+						return;
+					}
+					else
+					{
+						make_tree(div.firstChild);
+					}
+				}
+			}
+		});
+	}
 	
-	var openWindow = function()
+	
+	function make_tree()
 	{
-		if( folders.length == 0 )
+		var elementHtml = null;
+		
+		if( arguments.length > 0 )
 		{
-			write_msg( "ERRO : Sem dados" );
-			$(div).dialog("destroy");
-			div.removeChild( div.firstChild );
-			return false;
+			elementHtml = arguments[0];
 		}
 		else
@@ -37,157 +82,114 @@
 			if( Element('dftree_treeFolders') != null )
 			{
-				$(div).dialog("destroy");
-				div.removeChild( div.firstChild );
-				return;
-			}
-			else
-			{
-				ttree.make_tree(div.firstChild);
+				elementHtml = Element('dftree_treeFolders').parentNode.parentNode;
+				Element('dftree_treeFolders').innerHTML = "";
 			}
 		}
-	};
+		
+		var treeFolders = new dFTree({ name : 'treeFolders' });
+		
+		if( !expresso_offline )
+		{
+			var root	= new dNode({ id : 'root', caption: get_lang('My Folders'), onClick: "ttree.setFolder('root')" });
+			
+			treeFolders.add(root, 'root');
 
-	$(div).dialog(
-	{
-		resizable	: false,
-		title		: get_lang("Manager your folders and export messages"),
-		position	: 'center',
-		width		: 600,
-		height		: 300,
-		modal		: false,
-		buttons		: [
-						{
-							text: get_lang("Close"),
-							click: function()
-							{
-								$(this).dialog("destroy");
-								div.removeChild(div.firstChild);
-							},
-							style: "margin-top: -2.1em" 
-						}
-		],
-		beforeClose	: function()
-		{ 
-			$(this).dialog("destroy");
-			div.removeChild(div.firstChild);
-		},
-		open		: function()
+			for(var i = 0; i < folders.length ; i++ )
+			{
+				var nn = new dNode({ id:folders[i].folder_id, caption: lang_folder(folders[i].folder_name), plusSign:folders[i].folder_hasChildren, onClick: "ttree.setFolder('"+folders[i].folder_id+"')"});
+				
+				if ( folders[i].folder_parent == '' )
+				{
+					folders[i].folder_parent = 'root';
+				}
+	            else if ( folders[i].folder_parent.indexOf('user') != -1 )
+	            {
+	            	//if ( treeFolders.getNodeById('user') )
+	            	{
+	            		var n_root_shared_folders = new dNode({ id:'user', caption:get_lang("Shared Folders"), plusSign:true});
+	                    treeFolders.add( n_root_shared_folders,'root');
+	                }
+	            }
+
+				// Ver Ticket #1548
+				if( folders[i].folder_parent != 'root')
+				{
+	                var node_parent = treeFolders.getNodeById(folders[i].folder_parent);
+	                
+	                if( typeof node_parent != 'undefined')
+	                {
+	                	node_parent.plusSign = true;
+	                	treeFolders.alter(node_parent);
+	                }
+	            }
+				
+				treeFolders.add( nn, folders[i].folder_parent );
+			}
+		}	
+
+		//Pastas locais
+		if ( preferences.use_local_messages == 1 ) 
 		{
-			openWindow();
+			var n_root_local = new dNode({ id : "local_root", caption : get_lang("local folders"), onClick: "ttree.setFolder('root')" });
+			
+			treeFolders.add( n_root_local, 'root' );
+			
+			var local_folders = expresso_local_messages.list_local_folders();
+			
+			//Coloca as pastas locais.
+			for (var i in local_folders)
+			{ 
+				var node_parent = "local_root";
+				var new_caption = local_folders[i][0];
+				
+				if( local_folders[i][0].indexOf("/") != "-1" )
+				{
+					final_pos	= local_folders[i][0].lastIndexOf("/");
+					node_parent = "local_"+local_folders[i][0].substr(0,final_pos);
+					new_caption = local_folders[i][0].substr(final_pos+1);
+				}
+				            
+				if ( local_folders[i][1] > 0 )
+				{
+					var nodeLocal = new dNode({
+												id: "local_" + local_folders[i][0],
+												caption: lang_folder(new_caption) + '<font style=color:red>&nbsp(</font><span id="local_unseen" style=color:red>' + local_folders[i][1] + '</span><font style=color:red>)</font>',
+												plusSign: local_folders[i][2]
+					});
+				}
+				else
+				{
+					var nodeLocal = new dNode({
+												id: "local_" + local_folders[i][0],
+												caption: lang_folder(new_caption),
+												plusSign: local_folders[i][2]
+					});
+				}
+				treeFolders.add(nodeLocal, node_parent);
+			}
 		}
-	});
 
-}
-
-treeS.prototype.setFolder = function(folderName)
-{
-	this.FOLDER = folderName;
-}
-
-treeS.prototype.make_tree = function ()
-{
-	var elementHtml = null;
-	
-	if( arguments.length > 0 )
-	{
-		elementHtml = arguments[0];
-	}
-	else
-	{
-		if( Element('dftree_treeFolders') != null )
-		{
-			elementHtml = Element('dftree_treeFolders').parentNode.parentNode;
-			Element('dftree_treeFolders').innerHTML = "";
-		}
+		treeFolders.draw(elementHtml);
+		treeFolders.getNodeById("root")._select();
+		root.changeState();
+		
 	}
 	
-	var treeFolders = new dFTree({ name : 'treeFolders' });
+	function getFolder()
+	{
+		return FOLDER;
+	}
 	
-	if( !expresso_offline )
+	function setFolder()
 	{
-		var root	= new dNode({ id : 'root', caption: get_lang('My Folders'), onClick: "ttree.setFolder('root')" });
-		
-		treeFolders.add(root, 'root');
-
-		for(var i = 0; i < folders.length ; i++ )
-		{
-			var nn = new dNode({ id:folders[i].folder_id, caption: lang_folder(folders[i].folder_name), plusSign:folders[i].folder_hasChildren, onClick: "ttree.setFolder('"+folders[i].folder_id+"')"});
-			
-			if ( folders[i].folder_parent == '' )
-			{
-				folders[i].folder_parent = 'root';
-			}
-            else if ( folders[i].folder_parent.indexOf('user') != -1 )
-            {
-            	//if ( treeFolders.getNodeById('user') )
-            	{
-            		var n_root_shared_folders = new dNode({ id:'user', caption:get_lang("Shared Folders"), plusSign:true});
-                    treeFolders.add( n_root_shared_folders,'root');
-                }
-            }
-
-			// Ver Ticket #1548
-			if( folders[i].folder_parent != 'root')
-			{
-                var node_parent = treeFolders.getNodeById(folders[i].folder_parent);
-                
-                if( typeof node_parent != 'undefined')
-                {
-                	node_parent.plusSign = true;
-                	treeFolders.alter(node_parent);
-                }
-            }
-			
-			treeFolders.add( nn, folders[i].folder_parent );
-		}
-	}	
-
-	//Pastas locais
-	if ( preferences.use_local_messages == 1 ) 
-	{
-		var n_root_local = new dNode({ id : "local_root", caption : get_lang("local folders"), onClick: "ttree.setFolder('root')" });
-		
-		treeFolders.add( n_root_local, 'root' );
-		
-		var local_folders = expresso_local_messages.list_local_folders();
-		
-		//Coloca as pastas locais.
-		for (var i in local_folders)
-		{ 
-			var node_parent = "local_root";
-			var new_caption = local_folders[i][0];
-			
-			if( local_folders[i][0].indexOf("/") != "-1" )
-			{
-				final_pos	= local_folders[i][0].lastIndexOf("/");
-				node_parent = "local_"+local_folders[i][0].substr(0,final_pos);
-				new_caption = local_folders[i][0].substr(final_pos+1);
-			}
-			            
-			if ( local_folders[i][1] > 0 )
-			{
-				var nodeLocal = new dNode({
-											id: "local_" + local_folders[i][0],
-											caption: lang_folder(new_caption) + '<font style=color:red>&nbsp(</font><span id="local_unseen" style=color:red>' + local_folders[i][1] + '</span><font style=color:red>)</font>',
-											plusSign: local_folders[i][2]
-				});
-			}
-			else
-			{
-				var nodeLocal = new dNode({
-											id: "local_" + local_folders[i][0],
-											caption: lang_folder(new_caption),
-											plusSign: local_folders[i][2]
-				});
-			}
-			treeFolders.add(nodeLocal, node_parent);
-		}
+		FOLDER = arguments[0];
 	}
-
-	treeFolders.draw(elementHtml);
-	treeFolders.getNodeById("root")._select();
-	root.changeState();
-}
-
-/* Build the Object */
-var ttree = new treeS();
+	
+	foldersExpresso.prototype.load		= load;
+	foldersExpresso.prototype.getFolder	= getFolder;
+	foldersExpresso.prototype.setFolder	= setFolder;
+	foldersExpresso.prototype.make_tree	= make_tree;
+	
+	window.ttree = new foldersExpresso;
+	
+})();
Index: trunk/expressoMail1_2/js/TreeShow.js
===================================================================
--- trunk/expressoMail1_2/js/TreeShow.js	(revision 5486)
+++ trunk/expressoMail1_2/js/TreeShow.js	(revision 5744)
@@ -17,16 +17,10 @@
 			ttree.make_tree();
 			
-			// Update dftree_tree_folders;
-			//if(Element('content_folders'))
-			//{
-				//Element('content_folders').innerHTML = "";
-			//}
-			
 			draw_new_tree_folder();
 			
-			ttree.FOLDER = ttreeBox.name_folder;
-			
-			if (tree_folders.getNodeById(ttree.FOLDER))
-				tree_folders.getNodeById(ttree.FOLDER)._select();
+			ttree.setFolder(ttreeBox.name_folder);
+			
+			if(tree_folders.getNodeById(ttree.getFolder()))
+				tree_folders.getNodeById(ttree.getFolder())._select();
 
 			if(expand_local_root)
@@ -82,5 +76,5 @@
  			if(name_folder == arr_nm_folder[i])
  			{
-				ttree.FOLDER = "";
+				ttree.setFolder("");
 				return true;
  			}
@@ -92,8 +86,8 @@
 	Tree_Box.prototype.validate = function(func)
 	{
-		var aux = ttree.FOLDER.split(cyrus_delimiter);
+		var aux = ttree.getFolder().split(cyrus_delimiter);
 		var aux2;
 
-		if( ttree.FOLDER != "" )
+		if( ttree.getFolder() != "" )
 		{
 			if(aux.length > 1)
@@ -143,9 +137,9 @@
 				if( func == "rename" )
 				{
-					if(ttree.FOLDER == "root"){
+					if( ttree.getFolder() == "root"){
 	                	alert(get_lang("It's not possible rename this folder!"));
 						return false;
 					}
-					if(ttree.FOLDER == get_current_folder()){
+					if( ttree.getFolder() == get_current_folder()){
                         alert(get_lang("It's not possible rename this folder, because it is being used in the moment!"));
 						return false;
@@ -184,5 +178,5 @@
 	{
 
-		var aux   = ttree.FOLDER.split(cyrus_delimiter);
+		var aux   = ttree.getFolder().split(cyrus_delimiter);
 		var delimExp = new RegExp('\\'+cyrus_delimiter,"g"); 
 	        newp = newp.replace(delimExp,'_'); 
@@ -204,5 +198,5 @@
 			}else{
 				newp2 = newp;
-				newp = ttree.FOLDER + cyrus_delimiter + newp;
+				newp = ttree.getFolder() + cyrus_delimiter + newp;
 			}
 		}
@@ -233,5 +227,5 @@
 	// Funcao para renomear a pasta;
 	Tree_Box.prototype.rename = function(rename){
-		var old_box  = ttree.FOLDER;
+		var old_box  = ttree.getFolder();
 		var aux = old_box.split(cyrus_delimiter);
 		var rename_new = "";
@@ -282,6 +276,6 @@
 	Tree_Box.prototype.export_all_msg = function(){
 			
-		if(ttree.FOLDER == "root"){return false;}
-		var nm_bx = ttree.FOLDER.split(cyrus_delimiter);
+		if(ttree.getFolder() == "root"){return false;}
+		var nm_bx = ttree.getFolder().split(cyrus_delimiter);
 		var name_f = nm_bx[nm_bx.length -1];
 		var hand_export = function(data){
@@ -294,5 +288,5 @@
 			  download_attachments(null, null, data, null,null, name_f +'.zip');
 		}
-		cExecute("$this.exporteml.export_all",hand_export,"folder="+ttree.FOLDER);	
+		cExecute("$this.exporteml.export_all",hand_export,"folder="+ttree.getFolder());	
 		write_msg(get_lang('You must wait while the messages will be exported...'));			
 	}
@@ -300,9 +294,9 @@
 	// Função para deletar a pasta;
 	Tree_Box.prototype.del = function(){
-		var folder_name = ttree.FOLDER;
-		var aux = ttree.FOLDER.split(cyrus_delimiter);
-
-		if(aux[0] == "root" || ttree.FOLDER == ""){
-                        alert(get_lang("Select a folder!"));
+		var folder_name = ttree.getFolder();
+		var aux = ttree.getFolder().split(cyrus_delimiter);
+
+		if( aux[0] == "root" || ttree.getFolder() == "" ){
+			alert(get_lang("Select a folder!"));
 			return false;
 		}
@@ -325,5 +319,5 @@
 		var aux1 = aux.pop();
 
-		if(ttree.FOLDER == get_current_folder()){
+		if( ttree.getFolder() == get_current_folder()) {
             alert(get_lang("It's not possible delete this folder, because it is being used in the moment!"));
 			return false;
