Index: /trunk/expressoMail1_2/inc/class.ScriptS.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.ScriptS.inc.php	(revision 330)
+++ /trunk/expressoMail1_2/inc/class.ScriptS.inc.php	(revision 564)
@@ -13,6 +13,6 @@
 	var $rules;						// Regras do sieve;
 	var $errstr;					// Erros retornados;
-	var $size;						// var tamanho;
-	var $so;						// para verificar se a regra foi criada por outro tipo serviço de filtros;
+	var $size;						// Tamanho;
+	var $so;						// Verifica se a regra foi criada por outro tipo serviço de filtros;
 	var $continuebit;
 	var $sizebit;
@@ -22,4 +22,7 @@
 	var $newrules = array();
 	var $newout;
+	var $teste;
+	var $EmailVoip;
+	var $EmailExpresso;
 	
 	function ScriptS(){
@@ -42,4 +45,7 @@
     	$this->keepbit 		= 8;
     	$this->regexbit 	= 128;
+    	
+    	$this->EmailVoip = trim($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_email_redirect']);
+    	$this->EmailExpresso = trim($_SESSION['phpgw_info']['expressomail']['user']['email']);
     	
 	}
@@ -189,20 +195,27 @@
 			return "Ok";
 		}else{
-			return "Problemas na criação do arquivo!";
+			return "Problemas na criação do arquivo!\n" . $this->teste;
 		}
 	}
 
-        function convert_specialchar($input){
-	          $special_char = false;
-		  for ( $i = 0; $i < strlen($input); $i++ )
-		      if ( preg_match('/[ÁáÉéÍíÓóÚúÀàÈèÌìÒòÙùÇçÃãÕõÂâÊêÔô®©§ªºÐ¹²³°¢¿Æ£µøæß«»Ø÷±¬]/', $input[$i]) )
-		      {
-		          $special_char = true;
-		          $input = preg_replace('/'.$input[$i].'/', '=' . bin2hex($input[$i]), $input);
-		      }
-		      
-           if ( $special_char )
-		   {
-		   /*  When using arrays with pattern and replacement, the keys are processed in the order they appear in the array. See preg_replace in php.net/preg_replace */
+    function convert_specialchar($input)
+    {
+      $special_char = false;
+	  for ( $i = 0; $i < strlen($input); $i++ )
+	  {
+	      if ( preg_match('/[ÁáÉéÍíÓóÚúÀàÈèÌìÒòÙùüÇçÃãÕõÂâÊêÔô®©§ªºÐ¹²³°¢¿Æ£µøæß«»Ø÷±¬]/', $input[$i]) )
+	      {
+	          $special_char = true;
+	          $input = preg_replace('/'.$input[$i].'/', '=' . bin2hex($input[$i]), $input);
+	      }
+	  }   
+      
+      if ( $special_char )
+	  {
+		   /* *
+		    * When using arrays with pattern and replacement, 
+		    * the keys are processed in the order they appear in the array. 
+		    * See preg_replace in php.net/preg_replace 
+		    * */
 		   $patterns[0] = '/=c3/i';
 		   $patterns[1] = '/ /';
@@ -210,10 +223,8 @@
 		   $replacements[0] = '_';
 		   $input = preg_replace($patterns, $replacements, $input);
-		   }
-		//   if (($input{0}) && (!eregi('^[a-zA-Z0-9=\-@&\.#\$!?%:\+_<>\(\)\"\ ]+$',$input)))
-		//		return false;	
-		//	else
-           		return($input);
-        }
+	   }
+       
+       return($input);
+    }
 
 	// Grava a nova regra;
@@ -227,6 +238,8 @@
 		$regexused = 0;
 		$rejectused = 0;
+		$notify = 0;
 		$newscriptbody = "";
     	$continue = 1;
+    	$tmpSubject = "";
     	
 		// Recebe os valores das regras;
@@ -237,5 +250,6 @@
           $rule['from'] 	     = $this->convert_specialchar($tmp1[3]);
           $rule['to']            = $this->convert_specialchar($tmp1[4]);
-	 	  $rule['subject'] = $this->convert_specialchar($tmp1[5]);
+	 	  $tmpSubject			 = $tmp1[5];
+	 	  $rule['subject'] 		 = $this->convert_specialchar($tmp1[5]);
           $rule['action'] 	     = $tmp1[6];
 		  $rule['action_arg']    = utf8_encode(preg_replace("/\\r\\n/","\r\n",$tmp1[7]));
@@ -337,14 +351,28 @@
 	        if (!$rule['unconditional']) $newruletext .= ") {\n\t";
 	
-	        if (preg_match("/folder/i",$rule['action'])) {
+	        if (preg_match("/folder/i",$rule['action']))
+	        {
 	            $newruletext .= "fileinto \"" . $rule['action_arg'] . "\";";
 	        }
-	        if (preg_match("/reject/i",$rule['action'])) {
+	        
+	        if (preg_match("/reject/i",$rule['action']))
+	        {
 	            $newruletext .= "reject text: \n" . $rule['action_arg'] . "\n.\n;";
 	            $rejectused = 1;
 	        }
-	        if (preg_match("/address/i",$rule['action'])) {
+	        
+	        if (preg_match("/address/i",$rule['action']))
+	        {
 	            $newruletext .= "redirect \"" . $rule['action_arg'] . "\";";
 	        }
+	        
+	        if (preg_match("/notify/i",$rule['action']))
+	        {
+				$newruletext .= "notify :method \"mailto\" :options [\"".$this->EmailVoip ."\"]:" .
+								"message \"<expressovoip><from>". $this->EmailExpresso."</from>".
+								"<br/><Subject>".utf8_encode($tmpSubject)."</Subject></expressovoip>\";";
+				$notify = 1;					        	
+	        }
+	        
 	        if (preg_match("/discard/i",$rule['action'])) {
 	            $newruletext .= "discard;";
@@ -362,5 +390,5 @@
 	      }
 		}// Fim do Foreach;
-		
+		$this->teste = $newscriptbody;		
 		// Para a regras fora do escritorio;
         unset($tmp);
@@ -389,4 +417,8 @@
 	    if ($activerules) {
 	        $newscripthead .= "require [\"fileinto\"";
+	        
+	        if($notify){
+	        	$newscripthead .= ",\"notify\"";	        	
+	        }
 	        if($regexused){
 	        	$newscripthead .= ",\"regex\"";
@@ -405,7 +437,4 @@
 	    }
 		
-		//preg_replace("/[\\n\\r]/","", $p); 		
-		
-  
 	    // Cria o rodapé do arquivo;
 	    $newscriptfoot  = "";
Index: /trunk/expressoMail1_2/js/filters.js
===================================================================
--- /trunk/expressoMail1_2/js/filters.js	(revision 246)
+++ /trunk/expressoMail1_2/js/filters.js	(revision 564)
@@ -14,4 +14,6 @@
 		this.for_email_img = new Image();
 		this.for_email_img.src = 'templates/default/images/filtro/answered.gif';
+		this.telephone_voip = new Image();
+		this.telephone_voip.src = 'templates/default/images/filtro/telephone_voip.jpg';
 	}		
 
@@ -30,5 +32,5 @@
 		var form_cont = document.createElement("SPAN");
 		form_cont.id = "form_status";
-		form_cont.style.display = "";			
+		form_cont.style.display = "block";			
 		form_cont.style.position = "absolute";
 		form_cont.style.top = "10px";
@@ -81,25 +83,31 @@
 		Element('form_status').innerHTML = "";
 		var list = "";
+	
 		// rules
 		if(filter.rulest.length == 0){
-			list = "<img id='set_rules_img' src='"+this.grp_close_img.src+"' border='0'>&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>";		
+			list = "<img id='set_rules_img' src='" + this.grp_close_img.src + "' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>";		
 		}else{
-			if (filter.rulest.length < rules_limit ) //Limit of rules
-				list = "<img id='set_rules_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"set_rules\") border='0'>&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>";
+			if ( filter.rulest.length < rules_limit ) //Limit of rules
+				list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule();'>" + get_lang("new rule") + "</a>";
 			else
-				list = "<img id='set_rules_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"set_rules\") border='0'>&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules");
-				
+				list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' />&nbsp;<span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules");
+			
 			list += "<div id='set_rules'>";
-			for(var i=0; i < filter.rulest.length; i++){
-				list += "<input id=rule_"+i+" type='checkBox'>&nbsp;<img src='"+this.filter_img.src+"' width='16' height='16' border='0'>&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i) + "<br>";
+			
+			for(var i= 0; i < filter.rulest.length; i++)
+			{
+				list += "<input id=rule_"+i+" type='checkBox'>&nbsp;<img src='"+this.filter_img.src+"' width='16' height='16' border='0' />&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i,'') + "<br>";
 			}
-		}
-		list += "</div><br>";
+			list += "</div>";			
+		}
+		
+		list += "<br/>";
+		
 		// out office
 		if(!filter.out_officeR){
-			list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0'>&nbsp;";
+			list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0' />&nbsp;";
 			list += "<span><b>"+get_lang('out office') + " - ( 0 ) </b></span> " + "<a href='javascript:filters.n_out_office()'>" + get_lang("new rule") + "</a>";			
 		}else{
-			list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick=filters.hidden(\"set_out\") border='0'>&nbsp;";
+			list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"set_out\");' border='0' />&nbsp;";
 			list += "<span><b>"+get_lang('out office') + " - ( 1 )</b></span>";
 			list += "<div id='set_out'>";
@@ -108,10 +116,39 @@
 			list += "</div>";
 		}
+		list += "<br/>";
+	
+		// Voip
+		if(preferences.voip_email_redirect)
+		{
+			if( filter.rulesVoip.length == 0)
+			{
+				list += "<img id='voip_rule_img' src='"+this.grp_close_img.src+"' border='0' />&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter();'>" + get_lang("new rule") + "</a>";		
+			}
+			else
+			{
+				if ( filter.rulest.length < rules_limit ) //Limit of rules
+					list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/>&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter()'>" + get_lang("new rule") + "</a>";
+				else
+					list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/>&nbsp;<span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules");
+					
+				list += "<div id='voip_rule'>";
+				for(var i= 0; i < filter.rulesVoip.length; i++)
+				{
+					list += "<input id='voip_rule_"+i+"' type='checkBox'>&nbsp;<img src='"+this.telephone_voip.src+"' width='16' height='16' border='0'/>&nbsp;" + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulesVoip[i],i,'voip') + "<br>";
+				}
+				list += "</div>";
+			}
+		}
+
 		Element("form_body").innerHTML = list;
 	}
 	
-	cfilterSh.prototype.vl_rule = function(rule,pos){
-		var aux = rule.split("&&");
-		return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(aux[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + aux[3] + " - <b>" + get_lang("Action") + ":</b> " + aux[6] + "</a>";
+	cfilterSh.prototype.vl_rule = function(rule,pos,type)
+	{
+		var fields = rule.split("&&");
+		if(type == 'voip')
+			return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','voip')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - " + fields[3] + " <b>" + get_lang("Subject") + ":</b> " + fields[5] + "</a>";
+		else
+			return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + fields[3] + " - <b>" + get_lang("Action") + ":</b> " + fields[6] + "</a>";
 	}
 	
@@ -121,8 +158,9 @@
 	}
 	
-	cfilterSh.prototype.n_rule = function(){
+	cfilterSh.prototype.n_rule = function()
+	{
 		Element('form_body').innerHTML = "";
 		Element('form_body').innerHTML = filter.forms_();	
-		Element('div_rule').style.display = "";
+		Element('div_rule').style.display = "block";
 		filter.ac_form = "new_rule";
 		Element('form_buttons').style.display = 'none';
@@ -131,27 +169,38 @@
 	}
 
-	cfilterSh.prototype.n_out_office = function(){
+	cfilterSh.prototype.n_out_office = function()
+	{
 		Element('form_body').innerHTML = "";
 		Element('form_body').innerHTML = filter.forms_();	
-		Element('div_vacation').style.display = "";			
+		Element('div_vacation').style.display = "block";			
 		Element('form_buttons').style.display = 'none';
 		filter.ac_form = "new_out";	
-		}
-
-	cfilterSh.prototype.hidden = function(el){
-		var _this = this;
+	}
+
+	cfilterSh.prototype.n_voipFilter = function()
+	{
+		Element('form_body').innerHTML = "";
+		Element('form_body').innerHTML = filter.forms_();
+		Element('div_voipFilter').style.display = "block";	
+		Element('form_buttons').style.display = 'none';
+		filter.ac_form = "new_voip";
+	}
+
+	function visibleRulesFalse(el)
+	{
 		Element(el).style.display = "none";
-		Element(el+"_img").src = _this.grp_close_img.src;
-		Element(el+"_img").onclick = function(){filters.un_hidden(el);}
-	}
-
-	cfilterSh.prototype.un_hidden = function(el){
-		var _this = this;
+		Element(el+"_img").src = filters.grp_close_img.src;
+		Element(el+"_img").onclick = function(){visibleRulesTrue(el);};
+	}
+
+	function visibleRulesTrue(el)
+	{
 		Element(el).style.display = "";
-		Element(el+"_img").src = _this.grp_open_img.src;
-		Element(el+"_img").onclick = function(){filters.hidden(el);}
-	}
-
-	cfilterSh.prototype.showWindow = function (div){
+		Element(el+"_img").src = filters.grp_open_img.src;
+		Element(el+"_img").onclick = function(){visibleRulesFalse(el);};
+	}
+
+	cfilterSh.prototype.showWindow = function (div)
+	{
 		if(! this.filter_Sh[div.id]) {
 			div.style.width = "680px";
Index: /trunk/expressoMail1_2/js/filter.js
===================================================================
--- /trunk/expressoMail1_2/js/filter.js	(revision 377)
+++ /trunk/expressoMail1_2/js/filter.js	(revision 564)
@@ -1,10 +1,11 @@
-function charCounter(form)
-{
-	if (form.value.length >= 300) {
-		alert(get_lang("You have exceeded the number of allowed characters"));
-		return false;
-	}
-
-}
+
+	function charCounter(form)
+	{
+		if (form.value.length >= 300)
+		{
+			alert(get_lang("You have exceeded the number of allowed characters"));
+			return false;
+		}
+	}
 
 	function cfilter(){
@@ -12,4 +13,5 @@
 		this.mode_in   = "";
 		this.rulest		 = new Array;
+		this.rulesVoip	 = new Array;
 		this.out_officeR = "";
 		this.out_officeF = false;
@@ -37,12 +39,24 @@
 		
 	}
-	
-	cfilter.prototype.load_rules = function(){
+
+	
+	cfilter.prototype.load_rules = function()
+	{
 		var _this = this;
-		if(_this.rulest.length == 0){
-			var handler_sieve = function(data){
+		var cont1 = parseInt(0);
+		var cont2 = parseInt(0);
+				
+		if( _this.rulest.length == 0 )
+		{
+			var handler_sieve = function(data)
+			{
 				if(data.rule.length > 0){
-					for(var i=0 ; i < data.rule.length; i++){
-						_this.rulest[_this.rulest.length] = data.rule[i];
+					for(var i=0 ; i < data.rule.length; i++)
+					{
+						var fields = data.rule[i].split("&&");
+						if( fields[6] == 'notify' && fields[7] == preferences.voip_email_redirect )
+							_this.rulesVoip[cont1++] = data.rule[i];
+						else
+							_this.rulest[cont2++] = data.rule[i];
 					}
 				}
@@ -73,16 +87,29 @@
 	}
 	
-	cfilter.prototype.form_r = function(pos){
+	cfilter.prototype.form_r = function(pos,type)
+	{
 		Element('form_body').innerHTML = "";
 		Element('form_body').innerHTML = this.forms_();
-		Element('div_rule').style.display = "";	
-		this.ac_form = "old_rule";
-		this.ind = pos;
-		this.r_rules_form(pos);
-	}
-	
-	cfilter.prototype.get_email = function(){
+		this.ind = pos;		
+		
+		if( type === 'voip')
+		{
+			this.ac_form = "old_voip";
+			Element('div_voipFilter').style.display = "";
+			this.r_rules_form(pos, type);	
+		}
+		else
+		{
+			this.ac_form = "old_rule";
+			Element('div_rule').style.display = "";	
+			this.r_rules_form(pos, type);
+		}
+	}
+	
+	cfilter.prototype.get_email = function()
+	{
 		var _this = this;
-		var handler_get_email = function(data){
+		var handler_get_email = function(data)
+		{
 			_this.email_ld = data ? data : "";
 		}
@@ -90,5 +117,6 @@
 	}
 	
-	cfilter.prototype.sel_boxes = function(){
+	cfilter.prototype.sel_boxes = function()
+	{
 		var nm_folders = tree_folders.getNodesList(cyrus_delimiter);
 		if(document.getElementById("select_mailboxes") != null){
@@ -100,6 +128,8 @@
 				}
 			}
-			for(var i=0; i < nm_folders.length; i++){
-				if(nm_folders[i].id != "root"){
+			for(var i=0; i < nm_folders.length; i++)
+			{
+				if(nm_folders[i].id != "root")
+				{
 					var opt = new Option(nm_folders[i].caption,nm_folders[i].id,false,true);
 					sel_nm[sel_nm.length] = opt;
@@ -125,49 +155,58 @@
 	}
 
-	cfilter.prototype.r_rules_form = function(ind){
+	cfilter.prototype.r_rules_form = function(ind, type)
+	{
+		var fields = new Array;
+		var _this = this;
 		
 		// hide buttons
 		Element('form_buttons').style.display = 'none';
-
-		this.sel_boxes();
-		var aux = new Array;
-		var _this = this;
-		if(this.rulest.length == 0){
-			return false;
-		}
-		aux = _this.rulest[ind].split("&&");
-		document.getElementById("field1").value = aux[3];
-		document.getElementById("field2").value = aux[4];
-		document.getElementById("field3").value = aux[5];
-		document.getElementById("field4").value = aux[11];				
-		
-		switch(aux[6]){
-			case "folder":
-				document.getElementById("radio1").checked  = true;
-				var name_mb = aux[7];
-				var sel_mb = document.getElementById("select_mailboxes");
-				for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) ==  name_mb){sel_mb.options[i].selected = true;}}
-				break;
-			case "address":
-				document.getElementById("radio2").checked   = true;
-				document.getElementById("field5").value 	= aux[7];
-				break;
-			case "reject":
-				 document.getElementById("radio3").checked  = true;
-				 var text0 = aux[7].split("\\n");				 	
-				 for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";}
-				 break;
-			case "discard":
-				document.getElementById("radio4").checked 	= true;
-				break;
-		}
-		var mark_values = this.values[aux[8]].split(",");
-		for(var i=0; i < mark_values.length; i++){
-			if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){
-				document.getElementById(mark_values[i]).checked = true;
-			}
-			if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){
-				var mark_val = mark_values[i].split("=");
-				document.getElementById(mark_val[0]).options[mark_val[1]].selected = true;
+		
+		if( type === 'voip')
+		{
+			fields = _this.rulesVoip[ind].split("&&");
+			document.getElementById("field9").value = fields[5];			
+		}
+		else
+		{
+			this.sel_boxes();
+			if(this.rulest.length == 0){
+				return false;
+			}
+			fields = _this.rulest[ind].split("&&");
+			document.getElementById("field1").value = fields[3];
+			document.getElementById("field2").value = fields[4];
+			document.getElementById("field3").value = fields[5];
+			document.getElementById("field4").value = fields[11];				
+			
+			switch(fields[6]){
+				case "folder":
+					document.getElementById("radio1").checked  = true;
+					var name_mb = fields[7];
+					var sel_mb = document.getElementById("select_mailboxes");
+					for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) ==  name_mb){sel_mb.options[i].selected = true;}}
+					break;
+				case "address":
+					document.getElementById("radio2").checked   = true;
+					document.getElementById("field5").value 	= fields[7];
+					break;
+				case "reject":
+					 document.getElementById("radio3").checked  = true;
+					 var text0 = fields[7].split("\\n");				 	
+					 for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";}
+					 break;
+				case "discard":
+					document.getElementById("radio4").checked 	= true;
+					break;
+			}
+			var mark_values = this.values[fields[8]].split(",");
+			for(var i=0; i < mark_values.length; i++){
+				if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){
+					document.getElementById(mark_values[i]).checked = true;
+				}
+				if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){
+					var mark_val = mark_values[i].split("=");
+					document.getElementById(mark_val[0]).options[mark_val[1]].selected = true;
+				}
 			}
 		}
@@ -224,19 +263,22 @@
 	 * quando a caixa de seleção para manter o e-mail na caixa de entrada do usuário for selecionada
 	 */
-	cfilter.prototype.disable_radio3 =  function(){
-
+	cfilter.prototype.disable_radio3 =  function()
+	{
 		radio3 = Element('radio3');
 		field6 = Element('field6');
 		cb2 = Element('checkBox2');
 
-		if (cb2.checked){
+		if (cb2.checked)
+		{
 			radio3.disabled = true;
 			field6.disabled = true;
 
-			if (radio3.checked){
+			if (radio3.checked)
+			{
 				radio3.checked = false;
 			}
 		}
-		else{
+		else
+		{
 			radio3.disabled = false;
 			field6.disabled = false;
@@ -245,35 +287,41 @@
 	}
 
-	cfilter.prototype.forms_ = function(){
-			var form   = "";
-			form  	   = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+
-						 "<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('Also check message against next rule') + "</td></tr>"+
-						 "<tr><td colspan='2'><input type='checkBox' id='checkBox2' onclick='filter.disable_radio3();' name='checkb'>"+get_lang('Keep a copy of the message at your Inbox')+ "</td><tr>"+
-						 "<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+
-						 "<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+
-						 "<option value='0'>"+get_lang("with all")+"</option><option value='1'>"+get_lang("with some")+"</option>"+
-						 "</select></td><td>"+get_lang('The field \"%1\" of the message it contains',get_lang('From'))+".: <input type='text' id='field1' name='field1' size='35' maxlength='200'></td>"+
-						 "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('To'))+".: <input type='text' id='field2' name='field2' size='35' maxlength='200'></td>"+
-						 "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('Subject'))+".: <input type='text' id='field3' name='field3' size='35' maxlength='200'></td>"+
-						 "</tr><tr><td>"+get_lang('The size of the message is')+".: &nbsp<select id='select_size' name='select_size'>"+
-						 "<option value='0'>"+get_lang("Less than")+"</option><option value='1'>"+get_lang("Greater than")+"</option>"+						 
-						 "</select>&nbsp;<input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+
-						 "</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+
-						 "</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+
-						 "<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('Store at')+".:</td>"+
-						 "<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+
-						 "</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('Forward to the address')+".:</td>"+
-						 "<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+
-						 "</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('Send a rejection message')+".:</td>"+
-						 "<td width='50%'><textarea id='field6' onkeypress='return charCounter(this);' name='field6' rows='3' cols='25'></textarea></td>"+
-						 "</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('Erase the message')+"</td>"+
-						 "</tr></table></div><div id='div_vacation' style='display:none'>"+
-						 "<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+
- 						 "<tr><td colspan='3'><br><b>"+get_lang('out office')+"</b></td></tr>"+
-						 //"<tr><td colspan='3'><br>"+get_lang('Subject')+".: <input type='text' id='field7' name='field7' size='35' maxlength='200'/></td></tr>"+
-						 "<tr><td colspan='3'><br>"+get_lang('With the following message')+".:</td>"+
-	 					 "</tr><tr><td colspan='3'><textarea id='field8' onkeypress='return charCounter(this);' rows='8' cols='50'></textarea></td></tr></table></div>"+
-	 					 "<span align='right'><input type='button' value="+get_lang("Back")+" onclick='filter.form_m()'></span>"+
-	 					 "<span align='right'><input type='button' value="+get_lang("Save")+" onclick='filter.saved_rules()'></span>";	 					 
+	cfilter.prototype.forms_ = function()
+	{
+			 var form = "";
+				 form = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+
+						"<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('Also check message against next rule') + "</td></tr>"+
+						"<tr><td colspan='2'><input type='checkBox' id='checkBox2' onclick='filter.disable_radio3();' name='checkb'>"+get_lang('Keep a copy of the message at your Inbox')+ "</td><tr>"+
+						"<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+
+						"<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+
+						"<option value='0'>"+get_lang("with all")+"</option><option value='1'>"+get_lang("with some")+"</option>"+
+						"</select></td><td>"+get_lang('The field \"%1\" of the message it contains',get_lang('From'))+".: <input type='text' id='field1' name='field1' size='35' maxlength='200'></td>"+
+						"</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('To'))+".: <input type='text' id='field2' name='field2' size='35' maxlength='200'></td>"+
+						"</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('Subject'))+".: <input type='text' id='field3' name='field3' size='35' maxlength='200'></td>"+
+						"</tr><tr><td>"+get_lang('The size of the message is')+".: &nbsp<select id='select_size' name='select_size'>"+
+						"<option value='0'>"+get_lang("Less than")+"</option><option value='1'>"+get_lang("Greater than")+"</option>"+						 
+						"</select>&nbsp;<input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+
+						"</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+
+						"</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+
+						"<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('Store at')+".:</td>"+
+						"<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+
+						"</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('Forward to the address')+".:</td>"+
+						"<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+
+						"</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('Send a rejection message')+".:</td>"+
+						"<td width='50%'><textarea id='field6' onkeypress='return charCounter(this);' name='field6' rows='3' cols='25'></textarea></td>"+
+						"</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('Erase the message')+"</td>"+
+						"</tr></table></div><div id='div_vacation' style='display:none'>"+
+						"<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+
+ 						"<tr><td colspan='3'><br><b>"+get_lang('out office')+"</b></td></tr>"+
+						//"<tr><td colspan='3'><br>"+get_lang('Subject')+".: <input type='text' id='field7' name='field7' size='35' maxlength='200'/></td></tr>"+
+						"<tr><td colspan='3'><br>"+get_lang('With the following message')+".:</td>"+
+	 					"</tr><tr><td colspan='3'><textarea id='field8' onkeypress='return charCounter(this);' rows='8' cols='50'></textarea></td></tr></table></div>" +
+						"<div id='div_voipFilter' style='display:none'>" +
+						"<br/><table id='table_voipFilter'>" +
+						"<tr><td>"+get_lang("Type the subject of the message for receiving a phone warning")+" .:"+
+						"</td></tr><tr><td><input type='text' id='field9' size='50' maxlength='200'>" +
+						"</td></tr><br/></table></div>" +
+				 		"<span align='right'><input type='button' value="+get_lang("Back")+" onclick='filter.form_m()'></span>"+
+				 		"<span align='right'><input type='button' value="+get_lang("Save")+" onclick='filter.saved_rules()'></span>";
 		return form;
 	}
@@ -314,4 +362,23 @@
 			}
 		}
+
+		// Voip
+		if(Element("voip_rule_0") != null){
+			for(var i=0; i < this.rulesVoip.length; i++){
+				if(Element("voip_rule_"+i).checked){
+					var aux_rul = this.rulesVoip[i].split("&&");
+					if(aux_rul[2] != param){
+						aux_rul[2] = param;					
+						var rl = "";
+						for(var j=0; j < aux_rul.length; j++){
+							rl += aux_rul[j] + "&&";
+						}
+						rl = rl.substr(0,(rl.length - 2));
+						this.rulesVoip[i] = rl;					
+					}
+				}
+			}
+		}
+		
 		this.reload_rules();
 	}
@@ -347,5 +414,6 @@
 	}
 	
-	cfilter.prototype.e_newrule = function(nw_rule){
+	cfilter.prototype.e_newrule = function(nw_rule)
+	{
 
 		var new_rl = "";
@@ -399,15 +467,41 @@
 			}
 		}
+		
+		// Voip
+		if(Element("voip_rule_0") != null){
+			for(var i=0; i < _this.rulesVoip.length; i++){
+				if(Element("voip_rule_"+i).checked){_this.rulesVoip[i] = "delete";}
+			}
+			for(var i=0; i < _this.rulesVoip.length; i++){
+				if(_this.rulesVoip[i] == "delete"){_this.rulesVoip.splice(i,1);i--;}
+			}
+		}
+	
+		if(_this.rulesVoip.length > 0){
+			var cont = parseInt(1);
+			for(var i=0; i < _this.rulesVoip.length ; i++){
+				var n_rulest = _this.rulesVoip[i].split("&&");
+				n_rulest[1] = cont;
+				cont = cont + parseInt(2);
+				var aux = "";
+				for(var j=0; j < n_rulest.length; j++){aux += n_rulest[j] + "&&";}
+				aux = aux.substr(0,(aux.length - 2));
+				_this.rulesVoip[i] = aux;
+			}
+		} 
+
 		_this.reload_rules();
 	}
 	
-	cfilter.prototype.reload_rules = function(){
+	cfilter.prototype.reload_rules = function()
+	{
 		this.saved_all();
 		Element('form_body').innerHTML = "";
 		this.load_rules();
-		
-		if(this.out_officeF){
+
+		if(this.out_officeF)
+		{
 			write_msg(get_lang("Attention, you are in out of office mode."), true);
-		}else {
+		}else{
 			clean_msg();
 			this.out_officeF = false;
@@ -422,14 +516,19 @@
 		var n_rule = "";
 
-		if(form[1] == "rule"){
+		if(form[1] == "rule")
+		{
 			mount_rule = "#rule&&";
-			if(form[0] == "new"){
+			if(form[0] == "new")
+			{
 				n_rule = "1&&";
-				if(this.rulest.length > 0){
+				if(this.rulest.length > 0)
+				{
 					aux = this.rulest[this.rulest.length - parseInt(1)].split("&&");
 					n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&";
 				}
 				mount_rule += n_rule + "ENABLED&&";
-			}else{
+			}
+			else
+			{
 				n_rule = this.rulest[this.ind].split("&&");
 				mount_rule += n_rule[1] + "&&";
@@ -503,8 +602,12 @@
 			}
 			if(form[0] == "new")
+			{
 				this.rulest[this.rulest.length] = mount_rule;
+			}
 			else
 				this.rulest[this.ind] = mount_rule;
-		}else{
+		}
+		else if(form[1] == "out")
+		{
 			mount_rule = "";
 			var fld_emails = this.email_ld; // Get first email of list!
@@ -522,40 +625,124 @@
 			this.out_officeR = mount_rule;
 		}
+		else if(form[1] == "voip")
+		{
+			if( Element("field9").value != "" && LTrim(Element("field9").value) != "" )
+			{
+				mount_rule = "#rule&&";
+				if(form[0] == "new")
+				{
+					n_rule = "1&&";
+					if( this.rulesVoip.length > 0 )
+					{
+						aux = this.rulesVoip[this.rulesVoip.length - parseInt(1)].split("&&");
+						n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&";
+					}
+					mount_rule += n_rule + "ENABLED&&";
+				}
+				else
+				{
+					n_rule = this.rulesVoip[this.ind].split("&&");
+					mount_rule += n_rule[1] + "&&";
+					mount_rule += n_rule[2] + "&&";
+				}
+
+				if ( Element("field9").value.indexOf("#") >= 0 )
+				{
+					alert(get_lang('Caracter "#" is not allowed!'));
+					return false;
+				}
+				
+				mount_rule = mount_rule + "&&&&" + Element("field9").value + "&&notify&&" + preferences.voip_email_redirect + "&&8&&&&&&0";
+
+				if( form[0] == "new" )
+				{
+					this.rulesVoip[this.rulesVoip.length] = mount_rule;
+				}
+				else
+				{
+					this.rulesVoip[this.ind] = mount_rule;
+				}
+			}
+			else
+			{
+				alert( 'CAMPOS EM BRANCO !!' );
+				return false;
+			}
+		}
+		
 		Element('form_buttons').style.display = '';
 		this.reload_rules();
 	}
 
-	cfilter.prototype.close_frm= function(){
+	cfilter.prototype.close_frm= function()
+	{
 		filters.filter_Sh['window_ffilter_ccform'].close();
 	}
 	
-	cfilter.prototype.saved_all = function(){
+	cfilter.prototype.saved_all = function()
+	{
 		var aux_rul = "";
 		var _this = this;
-		if(_this.rulest.length > 0){
-			for(var i=0; i < _this.rulest.length; i++){
-				var aux = _this.rulest[i].split("&&");				
+		var cont = 0;
+		
+		// Regras Gerais
+		if(_this.rulest.length > 0)
+		{
+			for(var i=0; i < _this.rulest.length; i++)
+			{
+				var fieldsNormal = _this.rulest[i].split("&&");				
 				aux_rul += "_begin_##";
-				for(var j=0 ; j < aux.length; j++){
-					if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);}
-					else{aux_rul += url_encode(aux[j]) + "##";}
+				for(var j=0 ; j < fieldsNormal.length; j++)
+				{
+					aux_rul += url_encode(fieldsNormal[j]) + "##";
+					cont = parseInt(fieldsNormal[1]);					
 				}	
 				aux_rul += "_end_\n";
 			}
 		}
-		if(_this.out_officeR.length > 0){
+	
+		// Voip
+		if(_this.rulesVoip.length > 0)
+		{
+			for(var i=0; i < _this.rulesVoip.length; i++)
+			{
+				var fieldsVoip = _this.rulesVoip[i].split("&&");
+				aux_rul += "_begin_##";
+				for(var j=0 ; j < fieldsVoip.length; j++)
+				{
+					if(j == 1)
+					{
+						if( cont == 0 )
+							cont = parseInt(1);
+						else
+							cont = parseInt(cont) + parseInt(2);
+						aux_rul += cont;
+						aux_rul += "##";
+					}
+					else
+						aux_rul += url_encode(fieldsVoip[j]) + "##";
+				}
+				aux_rul += "_end_\n";
+			}
+		}
+		
+		// Fora do Escritório
+		if(_this.out_officeR.length > 0)
+		{
 				var aux = _this.out_officeR.split("&&");				
 				aux_rul += "_begin_##";
-				for(var j=0 ; j < aux.length; j++){
-					if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);}
-					else{aux_rul += url_encode(aux[j]) + "##";}
+				for(var j=0 ; j < aux.length; j++)
+				{
+					aux_rul += url_encode(aux[j]) + "##";					
 				}	
 				aux_rul += "_end_\n";
-				_this.out_officeF = (aux[4].replace("\n","") == "off") ? false : true;
+				_this.out_officeF = (aux[4].replace("\n","") === "off") ? false : true;
 				//Save outoffice in prefs:
 				connector.loadScript("preferences");
 				prefe.save("outoffice", _this.out_officeF);
 		}
-		var h_filter = function(data){
+		
+		var h_filter = function(data)
+		{
 			if(data != "Ok"){alert("Erro : \n" + data);}
 		}
Index: /trunk/expressoMail1_2/index.php
===================================================================
--- /trunk/expressoMail1_2/index.php	(revision 537)
+++ /trunk/expressoMail1_2/index.php	(revision 564)
@@ -42,5 +42,7 @@
 	$voip_enabled = false;
 	$voip_groups = array();
+	
 	if($GLOBALS['phpgw_info']['server']['voip_groups']) {
+		$emailVoip = false;
 		foreach(explode(",",$GLOBALS['phpgw_info']['server']['voip_groups']) as $i => $voip_group){
 			$a_voip = explode(";",$voip_group);			
@@ -50,4 +52,5 @@
 			if(array_search($group['account_name'],$voip_groups) !== FALSE){		 
 				$voip_enabled = true;
+				$emailVoip = $GLOBALS['phpgw_info']['server']['voip_email_redirect'];
 				break;
 			}
@@ -70,6 +73,8 @@
 	$_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email'];
 	
+	
 	$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = array(
 			'voip_enabled'						=> $voip_enabled,
+			'voip_email_redirect'				=> $emailVoip,
 			'outoffice'							=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['outoffice'],
 			'telephone_number'					=> $GLOBALS['phpgw_info']['user']['telephonenumber'],
@@ -93,5 +98,5 @@
     		
 	);
-	
+
 	$template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
 	$template->set_var("txt_loading",lang("Loading"));
