Index: sandbox/2.5.0-expresso1/expressoMail1_2/js/abas.js
===================================================================
--- sandbox/2.5.0-expresso1/expressoMail1_2/js/abas.js	(revision 7296)
+++ sandbox/2.5.0-expresso1/expressoMail1_2/js/abas.js	(revision 7346)
@@ -257,5 +257,8 @@
 				cc = document.getElementById("em_message_search").value;
 			else{
-				cc = document.getElementsByName(currentTab)[0].value;
+				if (currentTab == 0)
+					cc = "";
+				else
+					cc = document.getElementsByName(currentTab)[0].value;
 			}
 		}else{
Index: sandbox/2.5.0-expresso1/expressoMail1_2/js/search.js
===================================================================
--- sandbox/2.5.0-expresso1/expressoMail1_2/js/search.js	(revision 7296)
+++ sandbox/2.5.0-expresso1/expressoMail1_2/js/search.js	(revision 7346)
@@ -1,3 +1,5 @@
 	xhr = false;
+
+	var folder 		= {};
 	
 	function searchE()
@@ -144,47 +146,44 @@
 	}
 	
+	//draws folder list
 	searchE.prototype.foldersTree = function()
 	{
-		var treeFoldersSearch = new dFTree({name : 'treeFoldersSearch'});
-		
-		var root	= new dNode({id : 'root', caption: get_lang('My Folders'), onClick: "ttree.setFolder('root')"});
-		
-		treeFoldersSearch.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+"')"});
+		/*Insere a árvore de diretórios*/
+
+		var foldersTree = jQuery("#divFoldersSearch")
+		.removeClass('empty-container')
+		//Marcosw início - Adicionado parametro cp_tree3
+		.html(DataLayer.render(BASE_PATH + 'api/templates/foldertree.ejs', {folders: [cp_tree1, cp_tree2, cp_tree3 ]}))
+		//Marcosw fim
+		.find("#foldertree").treeview()
+		.click(function(event)
+		{
+			//request new selected folder messages
+			var target = $(event.target);
+
+			if( target.is('.collapsable-hitarea, .expandable-hitarea, .lastCollapsable, .lastExpandable, .treeview') )
+			    return;
+
+			if( !target.attr('id') )
+			    target = target.parent();
+
+	        if (target.attr('id') == "foldertree") return;
 			
-			if ( folders[i].folder_parent == '' )
-			{
-				folders[i].folder_parent = 'root';
-			}
-            else if ( folders[i].folder_parent.indexOf('user') != -1 )
-            {
-            	//if ( treeFoldersSearch.getNodeById('user') )
-            	{
-            		var n_root_shared_folders = new dNode({id:'user', caption:get_lang("Shared Folders"), plusSign:true});
-                    treeFoldersSearch.add( n_root_shared_folders,'root');
-                }
-            }
-
-			// Ver Ticket #1548
-			if( folders[i].folder_parent != 'root')
-			{
-                var node_parent = treeFoldersSearch.getNodeById(folders[i].folder_parent);
-                
-                if( typeof node_parent != 'undefined')
-                {
-                	node_parent.plusSign = true;
-                	treeFoldersSearch.alter(node_parent);
-                }
-            }
+			folder 			= {};
+			folder.id 		= target.attr('id');
+			folder.child 	= target.find('.folder');
+			folder.caption	= target.find('span').attr('title');			
 			
-			treeFoldersSearch.add( nn, folders[i].folder_parent );
-		}
-
-		treeFoldersSearch.draw( $("#divFoldersSearch")[0] );
-		treeFoldersSearch.getNodeById("root")._select();
-		root.changeState();
+			$('.filetree span.folder.selected').removeClass('selected');
+			if(!target.is('#foldertree > .expandable, #foldertree > .collapsable'))
+				$(target).children('.folder').addClass('selected');
+
+			selectedFolder = {
+			    id: folder.id, 
+			    name: folder.child.attr('title'),
+			    'class': folder.child.attr('class')
+			};
+		});
+
 	}
 	
@@ -1291,4 +1290,5 @@
 	{
 		var sel = Element("sel_search_nm_box1");
+		this.name_box_search = folder.id;
 		
 		if (!proxy_mensagens.is_local_folder(this.name_box_search))
@@ -1314,6 +1314,7 @@
 				name_box_def = this.name_box_search.substr(final_pos+1);
 			}
-			else
-				name_box_def = this.name_box_search.substr(6);//Retira o 'local_'
+			else {
+				name_box_def = folder.caption + " (local)"; //this.name_box_search.substr(6);//Retira o 'local_'
+			}
 		}
 		
@@ -1582,5 +1583,7 @@
 			{
 				expresso_local_messages.setSortType('SORTDATE');
-				tmp = expresso_local_messages.search( local_folders, fields );
+				//tmp = expresso_local_messages.search( local_folders, fields );
+				expresso_mail_archive.search(local_folders, fields);
+				tmp = expresso_mail_archive.search_queryresult;
 			}
 
@@ -1591,7 +1594,11 @@
 			}
 
-			if ( tmp.length > 0 )
-			{
-				allMsg['gears_num_msgs'] = tmp.length ;
+			if (tmp) {
+				if ( tmp.length > 0 )
+				{
+					allMsg['gears_num_msgs'] = tmp.length ;
+				}
+			} else {
+				allMsg['gears_num_msgs'] = 0;
 			}
 
@@ -1602,5 +1609,5 @@
 			else
 			{
-				if( ( tmp.length > 0) && ( !data['num_msgs'] ) ) 
+				if( ( tmp && tmp.length > 0) && ( !data['num_msgs'] ) ) 
 				{
 					EsearchE.viewLocalMessage();
@@ -1612,5 +1619,4 @@
 						EsearchE.func_clean();
 					}
-					
 					write_msg( count + " " + get_lang("results found") );
 					
