Index: branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3589)
+++ branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3709)
@@ -3395,7 +3395,7 @@
                                             {
                                                 // Remove accents from criteria, because method remove accents is broken.
-                                                $filter .= '"'.strtr($filter_array[1],
-                                                    "áàâãäéèêëíìîïóòôõöúùûüçÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ",
-                                                    "aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC").'"';
+                                                $a = 'áàâãäéèêëíìîïóòôõöúùûüçÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ';
+                                                $b = 'aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC';
+                                                $filter .= '"'.strtr($filter_array[1], $a, $b).'"';
                                             }
                                             else {
Index: branches/2.2/expressoMail1_2/js/search.js
===================================================================
--- branches/2.2/expressoMail1_2/js/search.js	(revision 3682)
+++ branches/2.2/expressoMail1_2/js/search.js	(revision 3709)
@@ -134,13 +134,13 @@
                                                         + '     <label>'+get_lang("Since Date")+':</label>'
                                                         + '     <input style="margin-left: 6px;" type="text" id="since_date" size="8">'
-                                                        + '     <img id="since_date-trigger" src="/phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>'
+                                                        + '     <img id="since_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>'
                                                         + '     <label style="margin-left: 20px;">'+get_lang('Before Date')+':</label>'
                                                         + '     <input style="margin-left: 6px;" type="text" id="before_date" size="8">'
-                                                        + '     <img id="before_date-trigger" src="/phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>'
+                                                        + '     <img id="before_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>'
                                                         + '     <br style="margin-bottom:15px"/>'
 
                                                         + '     <label>'+get_lang('On Date')+':</label>'
                                                         + '     <input style="margin-left: 6px;" type="text" id="on_date" size="8">'
-                                                        + '     <img style="margin-right: -8px" id="on_date-trigger" src="/phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>&nbsp;&nbsp;</spam>'
+                                                        + '     <img style="margin-right: -8px" id="on_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>&nbsp;&nbsp;</spam>'
                                                         + '     <br style="margin-bottom:30px"/>'
 
@@ -841,170 +841,201 @@
 			// Verifica se os campos estão preenchidos;
 			if(trim(Element("txt_ass").value) != ""){
-				fields += "SUBJECT " +  "<=>" +encodeURIComponent(Element("txt_ass").value) + "##";
+				fields += "SUBJECT " +  "<=>" +url_encode(Element("txt_ass").value) + "##";
 			}
 			if(trim(Element("txt_body").value) != ""){
-				fields += "BODY " + "<=>" + encodeURIComponent(Element("txt_body").value) + "##";
+				fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + "##";
 			}
 			if(trim(Element("txt_de").value) != ""){
-				fields += "FROM " + "<=>" + encodeURIComponent(Element("txt_de").value) + "##";
+				fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + "##";
 			}
 			if(trim(Element("txt_para").value) != ""){
-				fields += "TO " + "<=>" + encodeURIComponent(Element("txt_para").value) + "##";
+				fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + "##";
 			}
 			if(trim(Element("txt_cc").value) != ""){
-				fields += "CC " + "<=>" + encodeURIComponent(Element("txt_cc").value) + "##";
-			}
-                        if (trim(Element("since_date").value) != ""){
-                            if (validate_date(Element("since_date").value))
-                            {
-                                fields += "SINCE " + "<=>" + encodeURIComponent(Element("since_date").value) + "##";
-                            }
-                            else
-                                {
-                                    alert(get_lang('Invalid date on field %1'), get_lang('Since Date'));
-                                    return false;
-                                }
-                        }
-                        if (trim(Element("before_date").value) != ""){
-                            if (validate_date(Element("before_date").value))
-                            {
-                                fields += "BEFORE " + "<=>" + encodeURIComponent(Element("before_date").value) + "##";
-                            }
-                            else
-                                {
-                                    alert(get_lang('Invalid date on field %1'), get_lang('Before Date'));
-                                    return false;
-                                }
-                        }
-                        if(trim(Element("on_date").value) != ""){
-                            if (validate_date(Element("on_date").value))
-                            {
-                                fields += "ON " + "<=>" + encodeURIComponent(Element("on_date").value) + "##";
-                            }
-                            else
-                                {
-                                    alert(get_lang('Invalid date on field %1'), get_lang('On Date'));
-                                    return false;
-                                }
-
-                        }
-                        if(trim(Element("flagged").options[Element("flagged").selectedIndex].value) != ""){
-                            if (Element("flagged").options[Element("flagged").selectedIndex].value == "FLAGGED"){
-                                fields += "FLAGGED##";
-                            }
-                            else {
-                                fields += "UNFLAGGED##";
-                            }
-                        }
-                        if(trim(Element("seen").options[Element("seen").selectedIndex].value) != ""){
-                            if (Element("seen").options[Element("seen").selectedIndex].value == "SEEN"){
-                                fields += "SEEN##";
-                            }
-                            else {
-                                fields += "UNSEEN##";
-                            }
-                        }
-                        if(trim(Element("answered").options[Element("answered").selectedIndex].value) != ""){
-                            //switch (Element("answered").options[Element("answered").selectedIndex].value){
-                            //    case "FORWARDED":
-                            //        fields += "ANSWERED##DRAFT##";
-                            //        break;
-                            //    case "ANSWERED":
-                            //        fields += "ANSWERED##UNDRAFT";
-                            //        break;
-                            //    case "UNFORWARDED":
-                            //        fields += "UNDRAFT##";
-                            //    case "UNANSWERED":
-                            //        fields += "UNANSWERED##";
-                            //}
-                            if (Element("answered").options[Element("answered").selectedIndex].value == "ANSWERED"){
-                                fields += "ANSWERED##";
-                            }
-                            else {
-                                fields += "UNANSWERED##";
-                            }
-                        }
-                        if(trim(Element("recent").options[Element("recent").selectedIndex].value) != ""){
-                            if (Element("answered").options[Element("answered").selectedIndex].value == "RECENT"){
-                                fields += "RECENT##";
-                            }
-                            else {
-                                fields += "OLD##";
-                            }
-                        }
-			if(value) {
-				fields = "##ALL " +  "<=>" +encodeURIComponent(value) + "##";
-			}
-
-		if(fields == "##"){
-			alert(get_lang("Define some search parameters!"));
-			return false;
-		}
-		var local_folders = new Array();
-		var temp;
-
-		if(Element("check_all_msg").checked){
-			this.all_mailboxes();
-			var nm_box = new Array;
-			for(var i=0; i < EsearchE.all_boxes.length; i++){
-				nm_box[i] = EsearchE.all_boxes[i] + fields;
-			}
-			if (preferences.use_local_messages == 1) {
-				temp = expresso_local_messages.list_local_folders();
-				for (var x in temp) {
-					local_folders.push(temp[x][0]);
-				}
-			}
-		}else{
-			var nm_box = new Array;
-			var sel_combo = Element("sel_search_nm_box1");
-			if( sel_combo.options.length <= 0){
-				alert(get_lang("Define the boxes to search!"));
+				fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + "##";
+			}
+            if (trim(Element("since_date").value) != ""){
+                if (validate_date(Element("since_date").value))
+                {
+                    fields += "SINCE " + "<=>" + url_encode(Element("since_date").value) + "##";
+                }
+                else
+                {
+                    alert(get_lang('Invalid date on field %1'), get_lang('Since Date'));
+                    return false;
+                }
+            }
+            if (trim(Element("before_date").value) != ""){
+                if (validate_date(Element("before_date").value))
+                {
+                    fields += "BEFORE " + "<=>" + url_encode(Element("before_date").value) + "##";
+                }
+                else
+                {
+                    alert(get_lang('Invalid date on field %1'), get_lang('Before Date'));
+                    return false;
+                }
+            }
+            if(trim(Element("on_date").value) != ""){
+                if (validate_date(Element("on_date").value))
+                {
+                    fields += "ON " + "<=>" + url_encode(Element("on_date").value) + "##";
+                }
+                else
+                {
+                    alert(get_lang('Invalid date on field %1'), get_lang('On Date'));
+                    return false;
+                }
+
+            }
+            if(trim(Element("flagged").options[Element("flagged").selectedIndex].value) != ""){
+                if (Element("flagged").options[Element("flagged").selectedIndex].value == "FLAGGED")
+                {
+                    fields += "FLAGGED##";
+                }
+                else
+                {
+                    fields += "UNFLAGGED##";
+                }
+            }
+            if(trim(Element("seen").options[Element("seen").selectedIndex].value) != "")
+            {
+                if (Element("seen").options[Element("seen").selectedIndex].value == "SEEN")
+                {
+                    fields += "SEEN##";
+                }
+                else
+                {
+                    fields += "UNSEEN##";
+                }
+            }
+            
+            if(trim(Element("answered").options[Element("answered").selectedIndex].value) != "")
+            {
+                //switch (Element("answered").options[Element("answered").selectedIndex].value){
+                //    case "FORWARDED":
+                //        fields += "ANSWERED##DRAFT##";
+                //        break;
+                //    case "ANSWERED":
+                //        fields += "ANSWERED##UNDRAFT";
+                //        break;
+                //    case "UNFORWARDED":
+                //        fields += "UNDRAFT##";
+                //    case "UNANSWERED":
+                //        fields += "UNANSWERED##";
+                //}
+                if (Element("answered").options[Element("answered").selectedIndex].value == "ANSWERED"){
+                    fields += "ANSWERED##";
+                }
+                else {
+                    fields += "UNANSWERED##";
+                }
+            }
+            if(trim(Element("recent").options[Element("recent").selectedIndex].value) != "")
+            {
+                if (Element("answered").options[Element("answered").selectedIndex].value == "RECENT")
+                {
+                    fields += "RECENT##";
+                }
+                else
+                {
+                    fields += "OLD##";
+                }
+            }
+			
+            if( value )
+            {
+				fields = "##ALL " +  "<=>" +url_encode(value) + "##";
+			}
+
+			if( fields == "##" )
+			{
+				alert(get_lang("Define some search parameters!"));
 				return false;
 			}
-
-			for(var i=0; i < sel_combo.options.length; i++){
-				sel_combo.options[i].selected = true;
-			}
-			for(var i=0; i < sel_combo.options.length; i++){
-				if(sel_combo.options[i].selected == true){
-					if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value))
-						nm_box[nm_box.length] = sel_combo.options[i].value + fields;
-					else
-						local_folders.push(sel_combo.options[i].value.substr(6));
-				}
-			}
-		}
-		var handler = function(data){
-			var tmp;
-			var countTmp= new Array();
-
-                        var dataTemp = data.split('=sumResults=');
-                        var sumResults = dataTemp[0];
-
-                        var data = dataTemp[1] ? dataTemp[1] : dataTemp[0];
-
-			if (local_folders.length > 0) {
-				tmp = expresso_local_messages.search(local_folders, fields);
-				if (tmp!=false) {
-					var tmp2 = tmp.substr(2, data.length - 4);
-					countTmp = tmp.split('####');
-				}
-			}
-                        if ((sumResults == "none") && (countTmp.length==0)){
-                            alert(get_lang("None result was found."));
-                        }
-                        else
-                        {
-                            EsearchE.mount_result((sumResults=='none')?tmp:(countTmp.length==0)?data:data+tmp);
-                        }
-
-		}
-		var args   = "$this.imap_functions.search_msg";
-		var params = "condition=" + nm_box;
-		if(expresso_offline)
-			handler('none');
-		else
-			cExecute(args,handler,params);
+			
+			var local_folders = new Array();
+			var temp;
+
+			if( Element("check_all_msg").checked )
+			{
+				this.all_mailboxes();
+				var nm_box = new Array;
+				for(var i=0; i < EsearchE.all_boxes.length; i++)
+				{
+					nm_box[i] = EsearchE.all_boxes[i] + fields;
+				}
+				
+				if ( preferences.use_local_messages == 1)
+				{
+					temp = expresso_local_messages.list_local_folders();
+					for (var x in temp)
+					{
+						local_folders.push(temp[x][0]);
+					}
+				}
+			}
+			else
+			{
+				var nm_box = new Array;
+				var sel_combo = Element("sel_search_nm_box1");
+				if( sel_combo.options.length <= 0){
+					alert(get_lang("Define the boxes to search!"));
+					return false;
+				}
+	
+				for(var i=0; i < sel_combo.options.length; i++)
+				{
+					sel_combo.options[i].selected = true;
+				}
+				for(var i=0; i < sel_combo.options.length; i++)
+				{
+					if(sel_combo.options[i].selected == true)
+					{
+						if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value))
+							nm_box[nm_box.length] = sel_combo.options[i].value + fields;
+						else
+							local_folders.push(sel_combo.options[i].value.substr(6));
+					}
+				}
+			}
+			var handler = function(data){
+				var tmp;
+				var countTmp= new Array();
+	
+	                        var dataTemp = data.split('=sumResults=');
+	                        var sumResults = dataTemp[0];
+	
+	                        var data = dataTemp[1] ? dataTemp[1] : dataTemp[0];
+	
+				if ( local_folders.length > 0 )
+				{
+					tmp = expresso_local_messages.search(local_folders, fields);
+					if ( tmp!=false )
+					{
+						var tmp2 = tmp.substr(2, data.length - 4);
+						countTmp = tmp.split('####');
+					}
+				}
+                
+				if ((sumResults == "none") && (countTmp.length==0)){
+                    alert(get_lang("None result was found."));
+                }
+                else
+                {
+                    EsearchE.mount_result((sumResults=='none')?tmp:(countTmp.length==0)?data:data+tmp);
+                }
+	
+			}
+			
+			var args   = "$this.imap_functions.search_msg";
+			var params = "condition=" + nm_box;
+			
+			if(expresso_offline)
+				handler('none');
+			else
+			{
+				cExecute(args,handler,params);
+			}
 	}
 	// clean;
