Index: /trunk/expressoMail1_2/js/search.js
===================================================================
--- /trunk/expressoMail1_2/js/search.js	(revision 607)
+++ /trunk/expressoMail1_2/js/search.js	(revision 645)
@@ -154,9 +154,9 @@
 	function date_comp(a,b)
 	{
-		var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--\d*$/g);
+		var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
 		data1 = data1[0].substr(0, data1[0].indexOf('--'))
 		with ( data1 ) 
 			data1 = Date.UTC(substr(6), substr(3, 2), substr(0, 2));
-		var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--\d*$/g);
+		var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
 		data2 = data2[0].substr(0, data2[0].indexOf('--'))
 		with ( data2 )
@@ -214,5 +214,5 @@
 	function size_comp(a,b)
 	{
-		var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--\d*$/g);
+		var data1 = a.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
 		data1 = data1[0].substr(data1[0].indexOf('--')+2)
 		data1 = data1.substr(0,data1.indexOf('--'))
@@ -224,5 +224,5 @@
 				size_a = size_a * 1048576;
 		
-		var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--\d*$/g);
+		var data2 = b.match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
 		data2 = data2[0].substr(data2[0].indexOf('--')+2)
 		data2 = data2.substr(0,data2.indexOf('--'))
@@ -243,46 +243,53 @@
 		var_tmp  = var_tmp.split("####");
 		var cont = parseInt(0);
-		if (sort_type == 'SORTDATE')
-			var_tmp.sort(date_comp);
-		if (sort_type == 'SORTBOX')
-			var_tmp.sort(box_comp);	
-		if (sort_type == 'SORTSUBJECT')
-			var_tmp.sort(subject_comp);	
-		if (sort_type == 'SORTWHO')
-			var_tmp.sort(who_comp);	
-		if (sort_type == 'SORTSIZE')
-			var_tmp.sort(size_comp);	
-		
+		switch (sort_type)
+		{
+			case 'SORTDATE':
+				var_tmp.sort(date_comp);
+				break;
+			case 'SORTBOX':
+				var_tmp.sort(box_comp);
+				break;
+			case 'SORTSUBJECT':
+				var_tmp.sort(subject_comp);
+				break;
+			case 'SORTWHO':
+				var_tmp.sort(who_comp);
+				break;
+			case 'SORTSIZE':
+				var_tmp.sort(size_comp);
+				break;
+			default:
+				var showMsg = 1;
+		}
+
 		for(var i=0; i < var_tmp.length; i++){
-			if(var_tmp[i] != ""){
+			if(var_tmp[i] != "")
+			{
 				nw_array[cont] = var_tmp[i];
 				cont++;
 			}
 		}
+		if(nw_array.length > 0 && showMsg)
+			write_msg(nw_array.length + " "+ get_lang('results found'));
 		numBox++;
 		var border_id = create_border(get_lang("Search Results"), "search_" + numBox);
 		var table = document.createElement("TABLE");
 		table.id    = "table_resultsearch_" + numBox;
-		table.width = "100%";
-		table.borderColorDark = "#bbbbbb";
 		table.frame = "void";
 		table.rules = "rows";
 		table.cellPadding = "0";
 		table.cellSpacing = "0";
+		table.class = "table_box";
 
 		var tbody = document.createElement("TBODY");
 		tbody.id    = "tbody_resultsearch_" + numBox;
-		if(nw_array.length > 0){
-			write_msg(nw_array.length + " "+ get_lang('results found'));			
-		}
-
 		for( var i=0; i < nw_array.length; i++){
 			var tr = document.createElement("TR");
-			tr.style.height = "30px";
-			tr.className = 'tr_msg_read';
-
-			if (nw_array[i].match(/.*--.*--\w*--\d{2}\/\d{2}\/\d{4}--\d+? \w*b--\d*$/g) == null) //subject with "--"
+			tr.style.height = preferences.line_height;
+
+			if (nw_array[i].match(/.*--.*--\w*--\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g) != null) //subject with "--"
 			{
-				var aux1 = nw_array[i].match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--\d*$/g);
+				var aux1 = nw_array[i].match(/\d{2}\/\d{2}\/\d{4}--\d+? \w*b--.*--\d*$/g);
 				aux1 = aux1[0].split("--");
 				nw_array[i] = nw_array[i].substr(0, nw_array[i].indexOf(aux1[0])-2);
@@ -298,62 +305,97 @@
 			var aux = nw_array[i].split("--");
 			}
-			for(var j=0 ; j < aux.length ; j++){
-					var mailbox = aux[0];
-					var uid_msg = aux[5];
-					tr.id = uid_msg;
-					tr.name = mailbox;
-					var td = document.createElement("TD");					
-					
-				if( j <= 5){
-					if( j == 0){
-						td.style.width = "1%";					
-						var subject_encode = url_encode(aux[2]);
-						var td1 = '<input type="checkbox" id="check_box_message_'+uid_msg+'"></input>';
+			var mailbox = aux[0];
+			var uid_msg = aux[6];
+			var subject = aux[2];
+			tr.id = uid_msg;
+			tr.name = mailbox;
+
+			for(var j=0 ; j <= 10 ; j++)
+			{
+				var td = document.createElement("TD");					
+				if (j == 0)
+				{
+					td.style.width = "1%";
+					var td1 = '<input type="checkbox" id="check_box_message_'+uid_msg+'"></input>';
+				}
+				if (j == 1)
+				{
+					td.style.width = "2%";
+					td1 = '';
+				}
+				if (j == 2)
+				{
+					td.style.width = "1%";
+					td.id = "td_message_answered_"+uid_msg;
+					td1 = '';
+				}
+				if (j == 3)
+				{
+					td.style.width = "1%";
+					td.id = "td_message_important_"+uid_msg;
+					td1 = '';
+				}
+				if (j == 4)
+				{
+					td.style.width = "1%";
+					td.id = "td_message_sent_"+uid_msg;
+					td1 = '';
+				}
+				if (j == 5)
+				{
+					td.style.width = "14%";					
+					var nm_box = aux[0].split(cyrus_delimiter);
+					var td1 = nm_box.pop();
+					td.setAttribute("NoWrap","true");
+					td.style.overflow = "hidden";
+					td.style.color = "#42795b";
+					td.style.fontWeight = "bold";
+					if(td1 == "INBOX"){
+						var td1  = get_lang("Inbox");
 					}
-					if( j == 1){
-						td.style.width = "20%";					
-						var nm_box = aux[0].split(cyrus_delimiter);
-						var td1 = nm_box.pop();
-						td.setAttribute("NoWrap","true");
-						td.style.overflow = "hidden";
-						td.style.color = "#42795b";
-						td.style.fontWeight = "bold";
-						if(td1 == "INBOX"){
-							var td1  = get_lang("Inbox");
-						}
-					}
-					if( j == 2){
-						var subject_encode = url_encode(aux[2]);
-						td.width = "20%";					
-						var td1  =  '<div style="width:100%;overflow:hidden">'+aux[1]+"</div>";
-					}
-					if( j == 3){
-						var subject_encode = url_encode(aux[2]);
-						if (! subject_encode)
-							aux[2] = get_lang("no subject") + "...";
-						td.width = "30%";					
-						var td1  = '<div style="width:100%;overflow:hidden"><a href=javascript:void(0) onclick=EsearchE.open_msg(\"' + url_encode(mailbox) + '\",\"' + uid_msg + '\",\"' + subject_encode + '\")>' + aux[2] +'</a></div>';
-
-					}
-					if( j == 4){
-						td.width = "14%";					
-						td.align = "center";
-						var td1  = aux[3];
-					}
-					if( j == 5){
-						td.width = "15%";
-						td.align = "center";
-						var td1  = aux[4];
-					}
-
-					td.innerHTML = td1;
-					tr.appendChild(td);
-				}
+				}
+				if( j == 6)
+				{
+					var subject_encode = url_encode(aux[1]);
+					td.style.width = "20%";					
+					var td1  =  '<div style="width:100%;overflow:hidden">'+aux[1]+"</div>";
+				}
+				if( j == 7)
+				{
+					var subject_encode = url_encode(subject);
+					if (! subject_encode)
+						aux[2] = get_lang("no subject") + "...";
+					td.style.width = "35%";					
+					var td1  = '<div style="width:100%;overflow:hidden"><a href=javascript:void(0) onclick=EsearchE.open_msg(\"' + url_encode(mailbox) + '\",\"' + uid_msg + '\",\"' + subject_encode + '\")>' + aux[2] +'</a></div>';
+
+				}
+				if( j == 8)
+				{
+					td.style.width = "15%";					
+					td.align = "center";
+					var td1  = aux[3];
+				}
+				if( j == 9)
+				{
+					td.style.width = "10%";
+					td.align = "center";
+					var td1  = aux[4];
+				}
+				if (j == 10)
+				{
+					if (aux[5].match("U"))
+						tr.className = 'tr_msg_unread';
+					else
+						tr.className = 'tr_msg_read';
+					if (aux[5].match("F"))
+						tr.className = 'flagged_msg';
+					var td1 = '';
+				}
+				td.innerHTML = td1;
+				tr.appendChild(td);
 			}
 			aux.splice(0,(aux.length));
 
-		subject = tr.firstChild;
-		subject = subject.nextSibling.nextSibling.nextSibling.firstChild.firstChild.innerHTML;
-		_dragArea.makeDragged(tr, uid_msg, subject, true, mailbox);
+		_dragArea.makeDragged(tr, uid_msg, subject_encode, true, mailbox);
 		tbody.appendChild(tr);
 		}
@@ -416,25 +458,25 @@
 		td_element1.align = "left";
 		td_element1.onclick = function () { EsearchE.mount_result(data,'SORTBOX'); delete_border(border_id,false);};
-		td_element1.innerHTML = get_lang("Folder");
+		td_element1.innerHTML = (sort_type == 'SORTBOX')?"<b>"+get_lang("folder")+"</b>":get_lang("folder");
 		td_element2 = document.createElement("TD");
 		td_element2.setAttribute("width", "20%");
 		td_element2.align = "left";
 		td_element2.onclick = function () { EsearchE.mount_result(data,'SORTWHO'); delete_border(border_id,false);};
-		td_element2.innerHTML = get_lang("Who");
+		td_element2.innerHTML = (sort_type == 'SORTWHO')?"<b>"+get_lang("Who")+"</b>":get_lang("Who");
 		td_element3 = document.createElement("TD");
-		td_element3.setAttribute("width", "30%");
+		td_element3.setAttribute("width", "35%");
 		td_element3.align = "left";
 		td_element3.onclick = function () { EsearchE.mount_result(data,'SORTSUBJECT'); delete_border(border_id,false);};
-		td_element3.innerHTML = get_lang("Subject");
+		td_element3.innerHTML = (sort_type == 'SORTSUBJECT')?"<b>"+get_lang("Subject")+"</b>":get_lang("Subject");
 		td_element4 = document.createElement("TD");
-		td_element4.setAttribute("width", "14%");
+		td_element4.setAttribute("width", "15%");
 		td_element4.align = "center";
 		td_element4.onclick = function () { EsearchE.mount_result(data,'SORTDATE'); delete_border(border_id,false);};
-		td_element4.innerHTML = get_lang("Date");
+		td_element4.innerHTML = (sort_type == 'SORTDATE')?"<b>"+get_lang("Date")+"</b>":get_lang("Date");
 		td_element5 = document.createElement("TD");
-		td_element5.setAttribute("width", "15%");
+		td_element5.setAttribute("width", "10%");
 		td_element5.align = "center";
 		td_element5.onclick = function () { EsearchE.mount_result(data,'SORTSIZE'); delete_border(border_id,false);};
-		td_element5.innerHTML = get_lang("Size");
+		td_element5.innerHTML = (sort_type == 'SORTSIZE')?"<b>"+get_lang("Size")+"</b>":get_lang("Size");
 	
 		tr_element.appendChild(td_element0);
