Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5300)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5302)
@@ -28,22 +28,44 @@
 	var $imap_sentfolder;
 	var $rawMessage;
-
+	var $folders;
+
+	
 	function imap_functions (){
 		$this->init();
-	}
+	} 
 	
 	function init(){
-		$this->foldersLimit = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['imap_max_folders'] ?  $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['imap_max_folders'] : 20000; //Limit of folders (mailboxes) user can see
-	 	$this->username 	  = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
-		$this->password 	  = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
-		$this->imap_server	  = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
-		$this->imap_port	  = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
-		$this->imap_delimiter = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'];
-		$this->functions	  = new functions();
+		$this->foldersLimit    = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['imap_max_folders'] ?  $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['imap_max_folders'] : 20000; //Limit of folders (mailboxes) user can see
+	 	$this->username 	   = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
+		$this->password 	   = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
+		$this->imap_server	   = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
+		$this->imap_port	   = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
+		$this->imap_delimiter  = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'];
+		$this->functions	   = new functions();
 		$this->imap_sentfolder = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']   ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']   : str_replace("*","", $this->functions->getLang("Sent"));
 		$this->has_cid = false;
-		$this->prefs = $_SESSION['phpgw_info']['user']['preferences']['expressoMail'];
-
-
+		$this->prefs 		   = $_SESSION['phpgw_info']['user']['preferences']['expressoMail'];
+		
+		//armazena os caminhos das pastas ( sent, spam, drafts, trash )
+		//$this->folders['sent']    = $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']; //Variavel folders armazena o caminho /sent
+		$this->folders['sent']    =  $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']; //Variavel folders armazena o caminho /sent
+		$this->folders['spam']    =  $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'];
+		$this->folders['drafts']  =  $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'];
+		$this->folders['trash']   =  $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'];
+		
+		if( empty ( $this->folders['sent'] ) ){
+		  //$this->folders['sent'] = $this->imap_delimiter . 'Sent';	
+		  $this->folders['sent'] = 'Sent';
+		}
+		if( empty ( $this->folders['spam'] ) ){
+		  $this->folders['spam'] = 'Spam';	
+		}
+		if( empty ( $this->folders['drafts'] ) ){
+		  $this->folders['drafts'] = 'Drafts';	
+		}
+		if( empty ( $this->folders['trash'] ) ){
+		  $this->folders['trash'] = 'Trash';	
+		}
+		
 		if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes')
 		{
@@ -55,4 +77,23 @@
 		}
 	}
+	
+	function mount_url_folder($folders){
+		
+		if(strlen($folders) == 1){
+			
+			$var = $this->imap_delimiter.$folders[0];
+			return $var;
+			
+		} else {
+		
+		$var = "";
+		for($i = 0; $i<strlen($folders)-1; $i++){
+		   	$var += $folders[$i].$this->imap_delimiter;
+		}
+			$var += $folders[strlen($folders) - 1];
+			return $var;
+		}
+	}
+	
 	// BEGIN of functions.
 	function open_mbox($folder = False,$force_die=true)
@@ -384,5 +425,7 @@
 			
 			// PLEASE, BE CAREFULL!!! YOU SHOULD USE EMAIL CONFIGURATION VALUES (EMAILADMIN MODULE)
-			$tmp_box = mb_convert_encoding('INBOX'.$this->imap_delimiter.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'].$this->imap_delimiter.'tmpMoveToLocal', "UTF7-IMAP", "UTF-8");
+			//$tmp_box = mb_convert_encoding('INBOX'.$this->folders['trash'].$this->imap_delimiter.'tmpMoveToLocal', "UTF7-IMAP", "UTF-8");
+			$tmp_box = mb_convert_encoding($this->mount_url_folder(array("INBOX",$this->folders['trash'],"tmpMoveToLocal")), "UTF7-IMAP", "UTF-8");
+			
 			if ( ! imap_createmailbox( $this->mbox,"{".$this -> imap_server."}$tmp_box" ) )
 				return $this->functions->getLang( 'Import to Local : fail...' );
@@ -2357,17 +2400,17 @@
 					break;
 				case 1:
-					if( ($p = $this->getFolderPos($folders , $user . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] )) || $p === 0 )
+					if( ($p = $this->getFolderPos($folders , $user . $this->mount_url_folder(array($this->folders['drafts'])) )) || $p === 0 )
 						$principals[] = $folders[$p];
 					break;
 				case 2:
-					if( ($p = $this->getFolderPos($folders , $user . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] )) || $p === 0 )
+					if( ($p = $this->getFolderPos($folders , $user . $this->mount_url_folder(array($this->folders['sent'])) )) || $p === 0 )
 						$principals[] = $folders[$p];
 					break;
 				case 3:
-					if( ($p = $this->getFolderPos($folders , $user . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] )) || $p === 0 )
+					if( ($p = $this->getFolderPos($folders , $user . $this->mount_url_folder(array($this->folders['spam'])) )) || $p === 0 )
 						$principals[] = $folders[$p];
 					break;
 				case 4:
-					if( ($p = $this->getFolderPos($folders , $user . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] )) || $p === 0  )
+					if( ($p = $this->getFolderPos($folders , $user . $this->mount_url_folder(array($this->folders['trash'])) )) || $p === 0  )
 						$principals[] = $folders[$p];                                           
 					break;
@@ -4375,5 +4418,7 @@
 		$before_date = date("m/d/Y", strtotime("-".$params['before_date']." day"));
 		$criteria =  'BEFORE "'.$before_date.'"';
-		$mbox_stream = $this->open_mbox('INBOX'.$this->imap_delimiter.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']);
+		//$mbox_stream = $this->open_mbox('INBOX'.$this->folders['trash']);
+		$mbox_stream = $this->open_mbox($this->mount_url_folder(array("INBOX",$this->folders['trash'])));
+		
 		// Free others requests 
                 session_write_close(); 
Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 5292)
+++ trunk/expressoMail1_2/js/main.js	(revision 5302)
@@ -7,5 +7,22 @@
 var results_search_messages = ""; 
 var cabecalho = '<h4>ExpressoLivre - ExpressoMail</h4>'; 
-
+	
+function mount_url_folder(folders){
+	
+	if(folders.length == 1){
+		
+		var url = cyrus_delimiter+folders[0];
+		return url;
+		
+	} else {
+	
+	var url = "";
+	for(var i = 0; i < (folders.length -1); i++){
+		url += folders[i]+cyrus_delimiter;
+	}
+	url += folders[folders.length - 1];
+	return url;
+	}
+}
 function init(){
 	if (!is_ie)
@@ -546,5 +563,5 @@
  		          userTrashFolder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Trash'];  
  		        } 
-				else userTrashFolder = 'INBOX'+cyrus_delimiter+special_folders['Trash']; 
+				else userTrashFolder = mount_url_folder(["INBOX","Trash"]); 
  	 
  		        if(openTab.type[currentTab] == 1) 
@@ -719,5 +736,5 @@
 				if(tr.getAttribute('name') == current_folder)
 					remove_currente_folder += tr.id.replace(/_[a-zA-Z0-9]+/,"")+',';
-				if ((action == 'delete' && tr.getAttribute('name') == 'INBOX'+cyrus_delimiter+special_folders['Trash']) || !(parseInt(preferences.save_deleted_msg)))
+				if ((action == 'delete' && tr.getAttribute('name') == mount_url_folder(["INBOX","Trash"])) || !(parseInt(preferences.save_deleted_msg)))
 				{
 					msg_to_delete +=   ','+special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
@@ -738,5 +755,5 @@
 			if(tr.getAttribute('name') == current_folder)
 					remove_currente_folder += tr.id.replace(/_[a-zA-Z0-9]+/,"")+',';
-			if((action == 'delete' && tr.getAttribute('name') == 'INBOX'+cyrus_delimiter+special_folders['Trash']) || !(parseInt(preferences.save_deleted_msg))){
+			if((action == 'delete' && tr.getAttribute('name') == mount_url_folder(["INBOX","Trash"])) || !(parseInt(preferences.save_deleted_msg))){
 				msg_to_delete = special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,"");
 			}else if (!(tr.getAttribute('name') == new_folder && action != 'delete')){
@@ -754,5 +771,5 @@
 			params += "&new_folder_name_move="+url_encode(new_folder_name);
 		
-			new_folder = 'INBOX'+cyrus_delimiter+special_folders['Trash'];
+			new_folder = mount_url_folder(["INBOX","Trash"]);
 			new_folder_name = special_folders['Trash'];
 			params += "&selected_messages_delete="+url_encode(msg_to_delete);
@@ -760,5 +777,5 @@
 			cExecute ("$this.imap_functions.move_delete_search_messages", handler_move_search_msgs, params);
 		}else if(msg_to_delete != ""){
-			new_folder = 'INBOX'+cyrus_delimiter+special_folders['Trash'];
+			new_folder = mount_url_folder(["INBOX","Trash"]);
 			new_folder_name = special_folders['Trash'];
 			params += "&delete=true";
@@ -1087,5 +1104,5 @@
 {
     var msgs_to_remove = {};
-    var target = 'INBOX' + cyrus_delimiter + special_folders['Trash'] + cyrus_delimiter + 'tmpMoveToLocal';
+    var target = mount_url_folder(["INBOX","Trash"]) + cyrus_delimiter + 'tmpMoveToLocal';
     
     success = expresso_local_messages.select_mail( [ 'original_id', 'original_folder' ], success );
@@ -2563,5 +2580,4 @@
 			}
 		}
-
 		
 		draw_tree_folders();
@@ -2962,10 +2978,10 @@
 		if(!verify_session(data))
 			return;
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+special_folders['Trash']).alter({caption: get_lang("Trash")});
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+special_folders['Trash'])._refresh();
+		tree_folders.getNodeById(mount_url_folder(["INBOX","Trash"])).alter({caption: get_lang("Trash")});
+		tree_folders.getNodeById(mount_url_folder(["INBOX","Trash"]))._refresh();
 		update_quota(get_current_folder());
 		if (data){
 			write_msg(get_lang('Your Trash folder was empty.'));
-			if (get_current_folder() == 'INBOX'+cyrus_delimiter+special_folders['Trash']){
+			if (get_current_folder() == mount_url_folder(["INBOX","Trash"])){
 				draw_paging(0);
 				remove_rows(document.getElementById("table_box"));				
@@ -2987,10 +3003,10 @@
 		if(!verify_session(data))
 			return;
-		if (get_current_folder() == 'INBOX'+cyrus_delimiter+special_folders['Spam']){
+		if (get_current_folder() == mount_url_folder(["INBOX","Spam"])){
 			draw_paging(0);
 			remove_rows(document.getElementById("table_box"));
 		}
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+special_folders['Spam']).alter({caption: get_lang("Spam")});
-		tree_folders.getNodeById('INBOX'+cyrus_delimiter+special_folders['Spam'])._refresh();
+		tree_folders.getNodeById(mount_url_folder(["INBOX","Spam"])).alter({caption: get_lang("Spam")});
+		tree_folders.getNodeById(mount_url_folder(["INBOX","Spam"]))._refresh();
 		update_quota(get_current_folder());
 		if (data)
@@ -3155,5 +3171,5 @@
 	else
 	{
-		new_folder = 'INBOX' + cyrus_delimiter + special_folders['Spam'];
+		new_folder = mount_url_folder(["INBOX","Spam"]);
 	}
 	var new_folder_name = 'Spam';
@@ -3171,5 +3187,5 @@
 	else if(currentTab != 0 && currentTab.indexOf("search_")  >= 0){
 		var content_search = document.getElementById('content_id_'+currentTab);'INBOX/Trash', 'Trash',
-		move_search_msgs('content_id_'+currentTab,  'INBOX'+cyrus_delimiter+special_folders['Spam'], special_folders['Spam']);
+		move_search_msgs('content_id_'+currentTab,  mount_url_folder(["INBOX","Spam"]), special_folders['Spam']);
 		refresh();
 		return;
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 5301)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 5302)
@@ -18,4 +18,5 @@
 	'edit':5
 	}
+
 var currentTab,numBox = 0; // Open Tab and num of mailboxes opened at context
 // Objeto Map, talvez o ideal fosse adicionar este objeto à Api do egroupware, e carregá-lo
@@ -23,4 +24,5 @@
 
 function draw_tree_folders(folders){
+	
 	// Check if the tree folders alredy exist.
 	if (Element('dftree_tree_folders')){
@@ -209,8 +211,8 @@
 		}
 
-		var trash_span = document.getElementById('lINBOX'+cyrus_delimiter+special_folders['Trash']  + 'tree_folders'); 
-                var draft_span = document.getElementById('lINBOX'+cyrus_delimiter+special_folders['Drafts'] + 'tree_folders'); 
-                var sent_span  = document.getElementById('lINBOX'+cyrus_delimiter+special_folders['Sent'] + 'tree_folders'); 
-                var spam_span  = document.getElementById('lINBOX'+cyrus_delimiter+special_folders['Spam'] + 'tree_folders');
+		var trash_span = document.getElementById(mount_url_folder(["lINBOX","Trash"])  + 'tree_folders'); 
+                var draft_span = document.getElementById(mount_url_folder(["lINBOX","Drafts"]) + 'tree_folders'); 
+                var sent_span  = document.getElementById(mount_url_folder(["lINBOX","Sent"]) + 'tree_folders'); 
+                var spam_span  = document.getElementById(mount_url_folder(["lINBOX","Spam"]) + 'tree_folders');
 		//local folders
 		var sent_local_conf = this.preferences.save_in_folder.replace("INBOX"+cyrus_delimiter,"local_");
@@ -247,5 +249,5 @@
 
 		draw_paging(Element('tot_m').innerHTML);
-		if(document.getElementById("nINBOX"+cyrus_delimiter+special_folders['Trash']+"tree_folders"))
+		if(document.getElementById(mount_url_folder(["nINBOX","Trash"])+"tree_folders"))
 		{
 			var trash = document.createElement("SPAN");
@@ -258,7 +260,7 @@
 			trash.onmouseover = function() {trash.style.color="red";};
 			trash.onmouseout= function() {trash.style.color="#666666";};
-			document.getElementById("nINBOX"+cyrus_delimiter+special_folders['Trash']+"tree_folders").appendChild(trash);
-		}
-		if(document.getElementById("nINBOX"+cyrus_delimiter+special_folders['Spam']+"tree_folders"))
+			document.getElementById(mount_url_folder(["nINBOX","Trash"])+"tree_folders").appendChild(trash);
+		}
+		if(document.getElementById(mount_url_folder(["nINBOX","Spam"])+"tree_folders"))
 		{
 						var spam = document.createElement("SPAN");
@@ -272,7 +274,6 @@
 						spam.onmouseover = function() {spam.style.color="red";};
 						spam.onmouseout= function() {spam.style.color="#666666";};
-						document.getElementById("nINBOX"+cyrus_delimiter+special_folders['Spam']+"tree_folders").appendChild(spam);
+						document.getElementById(mount_url_folder(["nINBOX","Spam"])+"tree_folders").appendChild(spam);
 			   }
-
 
 		if(!expresso_offline)
@@ -1174,4 +1175,5 @@
 	if ((preferences.use_shortcuts == '1') && (headers_msgs[0]))
 		select_msg(headers_msgs[0].msg_number, 'null', true);
+		
 
 	var tdFolders  =  Element("folderscol");
