Index: trunk/expressoMail1_2/js/search.js
===================================================================
--- trunk/expressoMail1_2/js/search.js	(revision 4843)
+++ trunk/expressoMail1_2/js/search.js	(revision 4853)
@@ -380,5 +380,5 @@
     			if ( local_folders.length > 0 ){
                             expresso_local_messages.setSortType(sortType);
-                            gears = expresso_local_messages.search( local_folders, expresso_local_messages.getFilter() );
+                            gears = expresso_local_messages.search( expresso_local_messages.getFolders(), expresso_local_messages.getFilter() );
                         }
     		}
@@ -428,5 +428,5 @@
 
 			if ( local_folders.length > 0 )
-				gears = expresso_local_messages.search( local_folders, expresso_local_messages.getFilter() );
+				gears = expresso_local_messages.search( expresso_local_messages.getFolders(), expresso_local_messages.getFilter() );
 
 			data['data_gears']	= gears;
@@ -923,5 +923,5 @@
 		table_element.appendChild(colgr_element);
 
-		if( parseInt( Data['gears_num_msgs'] ) > 0 )
+		if( parseInt( Data['gears_num_msgs'] ) > 0 && !Data['data_gears'])
 		{
 			var _div_gears = document.createElement("div");
@@ -1223,55 +1223,54 @@
 		}
 		
-		var handler = function( data )
-		{
-        	var allMsg 	= [3];
-        	var count  	= ( data['num_msgs'] ) ?  data['num_msgs'] : "0";
-			var tmp		= [];
-
-			// Gears - local
-			if ( local_folders.length > 0 ){
-                            expresso_local_messages.setSortType('SORTDATE');
-                            tmp = expresso_local_messages.search( local_folders, fields );
-                        }
-
-            if( data['num_msgs'] )
+            var handler = function( data )
             {
-            	allMsg['data'] 		= data['data'];
-            	allMsg['num_msgs']	= data['num_msgs'];
-            } 
-
-        	if( tmp.length > 0 )	
-            {
-        		allMsg['gears_num_msgs'] = tmp.length ;
+                var allMsg 	= [3];
+                var tmp		= [];
+
+                // Gears - local
+                if ( local_folders.length > 0 ){
+                    expresso_local_messages.setSortType('SORTDATE');
+                    tmp = expresso_local_messages.search( local_folders, fields );
+                }
+                var count = data['num_msgs'] ?  data['num_msgs'] : tmp.length > 0 ? tmp.length : "0";
+
+                if( data['num_msgs'] )
+                {
+                    allMsg['data'] 		= data['data'];
+                    allMsg['num_msgs']	= data['num_msgs'];
+                }
+
+                if( tmp.length > 0 )
+                {
+                    allMsg['gears_num_msgs'] = tmp.length ;
+                }
+
+                if( data['num_msgs'] == 0 && tmp.length < 0)
+                {
+                    alert( get_lang("None result was found.") );
+                }
+                else
+                {
+                    if(tmp.length > 0 && !data['num_msgs'])
+                    {
+                        allMsg['data_gears'] = tmp;
+                    }
+
+                    write_msg( count + " " + get_lang("results found") );
+                    EsearchE.mount_result( allMsg, 'SORTDATE' );
+                }
             }
+
+            this.condition	= nm_box;
+            this.page		= 0;
+            var args		= "$this.imap_functions.search_msg";
+            var params		= "condition=" + nm_box+ "&page=0"+ "&sort_type=SORTDATE";
+
+            if( expresso_offline )
+                    handler('none');
+            else
+                    cExecute( args, handler, params);
             
-        	if( ( data['num_msgs'] ) == 0 )
-        	{
-                alert( get_lang("None result was found.") );
-        	}
-            else
-            {
-            	if( (tmp.length > 0) && (!data['num_msgs']) ) 
-            	{
-            		EsearchE.viewLocalMessage();
-            	}
-            	else
-            	{
-            		write_msg( count + " " + get_lang("results found") );
-            		EsearchE.mount_result( allMsg, 'SORTDATE' );
-            	}
-            }
-		}
-
-		this.condition	= nm_box;
-		this.page		= 0;
-		var args		= "$this.imap_functions.search_msg";
-		var params		= "condition=" + nm_box+ "&page=0"+ "&sort_type=SORTDATE";
-		
-		if( expresso_offline )
-			handler('none');
-		else
-			cExecute( args, handler, params);
-	}
+        }
 	// clean;
 	searchE.prototype.func_clean = function()
Index: trunk/expressoMail1_2/js/local_messages.js
===================================================================
--- trunk/expressoMail1_2/js/local_messages.js	(revision 4852)
+++ trunk/expressoMail1_2/js/local_messages.js	(revision 4853)
@@ -8,4 +8,5 @@
     this.store = null;
     this.filterSerch = "";
+    this.folders = [];
     this.sortType = "";
 }
@@ -934,4 +935,14 @@
 }
 
+local_messages.prototype.setFolders = function(sFolders)
+{
+    this.folders = sFolders;
+}
+
+local_messages.prototype.getFolders = function()
+{
+    return this.folders;
+}
+
 local_messages.prototype.setFilter = function(sFilter)
 {
@@ -959,4 +970,5 @@
     this.init_local_messages();
     this.setFilter(sFilter);
+    this.setFolders(folders);
     var filters = sFilter.replace(/^##|##$/g,"").split('##');
     var friendly_filters = new Array();
