Index: branches/2.2/expressoMail1_2/js/search.js
===================================================================
--- branches/2.2/expressoMail1_2/js/search.js	(revision 5067)
+++ branches/2.2/expressoMail1_2/js/search.js	(revision 5086)
@@ -331,5 +331,5 @@
 	}
 	
-	searchE.prototype.viewLocalMessage = function()
+	searchE.prototype.viewLocalMessage = function(borderID, sortType)
 	{
 		var data		  	= [2];
@@ -349,7 +349,7 @@
 			if ( local_folders.length > 0 ){
 				if (this.folders.length >0)
-					gears = expresso_local_messages.search( this.folders, expresso_local_messages.getFilter() );
+					gears = expresso_local_messages.search( this.folders, expresso_local_messages.getFilter(),sortType );
 				else
-					gears = expresso_local_messages.search( local_folders, expresso_local_messages.getFilter() );
+					gears = expresso_local_messages.search( local_folders, expresso_local_messages.getFilter(), sortType );
 			}
 			data['data_gears']	= gears;
@@ -358,5 +358,7 @@
         	write_msg( data['num_msgs'] + " " + get_lang("results found") );
 			
-			EsearchE.mount_result( data );
+			delete_border( borderID, false );
+			
+			EsearchE.mount_result( data, sortType );
 		}
 	}
@@ -638,11 +640,11 @@
 			if( Data['data'] )
 			{
-				td_element1.onclick		= function(){ EsearchE.searchFor(border_id, 'SORTBOX_REVERSE'); };
-				td_element1.innerHTML	= "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
+				td_element1.onclick		= function(){ EsearchE.searchFor(border_id, 'SORTBOX_REVERSE'); };	
 			}
 			else
 			{
-				td_element1.innerHTML	= "<b>"+get_lang("Folder")+"</b>";
-			}
+				td_element1.onclick		= function(){ EsearchE.viewLocalMessage(border_id,'SORTBOX_REVERSE'); };
+			}
+			td_element1.innerHTML	= "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
 		}
 		else
@@ -654,4 +656,5 @@
 			else
 			{
+				td_element1.onclick		= function(){ EsearchE.viewLocalMessage(border_id,'SORTBOX'); };
 				//alert('Ordenando localMessage');
 			}
@@ -669,10 +672,10 @@
 			{
 				td_element2.onclick		= function(){ EsearchE.searchFor(border_id, 'SORTWHO_REVERSE'); };
-				td_element2.innerHTML	= "<b>"+get_lang("who")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
 			}
 			else
 			{
-				td_element2.innerHTML	= "<b>"+get_lang("who")+"</b>";
-			}
+				td_element2.onclick		= function(){ EsearchE.viewLocalMessage(border_id,'SORTWHO_REVERSE'); };
+			}
+			td_element2.innerHTML	= "<b>"+get_lang("who")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
 		}
 		else
@@ -684,5 +687,5 @@
 			else
 			{
-				//alert('Ordenando localMessage');
+				td_element2.onclick		= function(){ EsearchE.viewLocalMessage(border_id, 'SORTWHO'); };
 			}
 			td_element2.innerHTML	= ( sort_type == 'SORTWHO_REVERSE' ) ? arrow_ascendant(get_lang("who")) : get_lang("who");
@@ -699,10 +702,11 @@
 			{
 				td_element3.onclick		= function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE'); };
-				td_element3.innerHTML	= "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";				
+								
 			}
 			else
 			{
-				td_element3.innerHTML	= "<b>"+get_lang("subject")+"</b>";
-			}
+				td_element3.onclick		= function(){ EsearchE.viewLocalMessage(border_id, 'SORTSUBJECT_REVERSE'); };
+			}
+			td_element3.innerHTML	= "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
 		}
 		else
@@ -714,5 +718,5 @@
 			else
 			{
-				//alert('Ordenando localMessage');
+				td_element3.onclick		= function(){ EsearchE.viewLocalMessage( border_id, 'SORTSUBJECT'); };
 			}
 			td_element3.innerHTML	= ( sort_type == 'SORTSUBJECT_REVERSE' ) ? arrow_ascendant(get_lang("subject")) : get_lang("subject");
@@ -729,10 +733,10 @@
 			{
 				td_element4.onclick		= function(){ EsearchE.searchFor(border_id, 'SORTDATE_REVERSE'); };
-				td_element4.innerHTML	= "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
 			}
 			else
 			{
-				td_element4.innerHTML	= "<b>"+get_lang("Date")+"</b>";
-			}
+				td_element4.onclick		= function(){ EsearchE.viewLocalMessage(border_id, 'SORTDATE_REVERSE'); };
+			}
+			td_element4.innerHTML	= "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
 		}
 		else
@@ -744,5 +748,5 @@
 			else
 			{
-				//alert('Ordenando localMessage');
+				td_element4.onclick		= function(){ EsearchE.viewLocalMessage(border_id, 'SORTDATE'); };
 			}
 			td_element4.innerHTML	= ( sort_type == 'SORTDATE_REVERSE' ) ? arrow_ascendant(get_lang("Date")) : get_lang("Date");
@@ -759,10 +763,11 @@
 			{
 				td_element5.onclick		= function(){ EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE'); };
-				td_element5.innerHTML	= "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";				
+								
 			}
 			else
 			{
-				td_element5.innerHTML	= "<b>"+get_lang("size")+"</b>";
-			}
+				td_element5.onclick		= function(){ EsearchE.viewLocalMessage(border_id, 'SORTSIZE_REVERSE'); };
+			}
+			td_element5.innerHTML	= "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>";
 		}
 		else
@@ -774,5 +779,5 @@
 			else
 			{
-				//alert('Ordenando localMessage');
+				td_element5.onclick		= function(){ EsearchE.viewLocalMessage(border_id, 'SORTSIZE'); };
 			}
 			td_element5.innerHTML	= ( sort_type == 'SORTSIZE_REVERSE' ) ? arrow_ascendant(get_lang("size")) : get_lang("size");
@@ -813,6 +818,6 @@
 		
 		resizeWindow();
-
-		EsearchE.show_paging( Data['num_msgs'] );
+		if( Data['data'] )
+			EsearchE.show_paging( Data['num_msgs'] );
 	}
 
@@ -1103,6 +1108,10 @@
             	if( (tmp.length > 0) && (!data['num_msgs']) )
             	{
-            		EsearchE.folders = local_folders; 
-            		EsearchE.viewLocalMessage();
+            		//EsearchE.folders = local_folders;
+            		var data_local = [2]; 
+            		data_local['data_gears'] = tmp;
+					data_local['num_msgs'] = tmp.length;
+            		EsearchE.mount_result(data_local);
+            	//	EsearchE.viewLocalMessage();
             	}
             	else
