Index: /branches/2.2/phpgwapi/inc/class.sessions.inc.php
===================================================================
--- /branches/2.2/phpgwapi/inc/class.sessions.inc.php	(revision 1464)
+++ /branches/2.2/phpgwapi/inc/class.sessions.inc.php	(revision 3018)
@@ -343,35 +343,5 @@
 			}
 
-			/* ExpressoLivre
-			   Necessário comentar para que o redirecionamento de uma sessão
-			   https para uma http funcionasse atrás de um proxy
-			*/
-
-			/*
-			if (@$GLOBALS['phpgw_info']['server']['sessions_checkip'])
-			{
-				if((PHP_OS != 'Windows') && (PHP_OS != 'WINNT') &&
-					(!$GLOBALS['phpgw_info']['user']['session_ip'] || $GLOBALS['phpgw_info']['user']['session_ip'] != $this->getuser_ip())
-				)
-				{
-					//echo "IP do cliente com https   ---->  ".$GLOBALS['phpgw_info']['user']['session_ip'];
-					//echo "<BR>IP do cliente com http ---->  ".$this->getuser_ip();
-					if(is_object($GLOBALS['phpgw']->log))
-					{
-						// This needs some better wording
-						$GLOBALS['phpgw']->log->message(array(
-							'text' => 'W-VerifySession, IP %1 doesn\'t match IP %2 in session table',
-							'p1'   => $this->getuser_ip(),
-							'p2'   => $GLOBALS['phpgw_info']['user']['session_ip'],
-							'line' => __LINE__,
-							'file' => __FILE__
-						));
-						$GLOBALS['phpgw']->log->commit();
-					}
-					return False;
-				}
-			}
-			*/
-
+			
 			$GLOBALS['phpgw']->acl->acl($this->account_id);
 			$GLOBALS['phpgw']->accounts->accounts($this->account_id);
@@ -408,24 +378,5 @@
 		function getuser_ip()
 		{
-		/*
-			if (getenv(HTTP_X_FORWARDED_FOR))
-			{
-			        if (getenv(HTTP_CLIENT_IP))
-	        		{
-					$ip=getenv(HTTP_CLIENT_IP);
-				}
-				else
-				{
-					$ip=getenv(HTTP_X_FORWARDED_FOR);
-				}
-				$ip_proxy=getenv(REMOTE_ADDR);
-			}
-			else
-			{
-				$ip=getenv(REMOTE_ADDR);
-			}
-			return $ip;
-		*/
-			return (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']);
+			return (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR']."," : "").$_SERVER['REMOTE_ADDR']; 
 		}
 
Index: /branches/2.2/phpgwapi/inc/class.setup.inc.php
===================================================================
--- /branches/2.2/phpgwapi/inc/class.setup.inc.php	(revision 1322)
+++ /branches/2.2/phpgwapi/inc/class.setup.inc.php	(revision 3018)
@@ -863,6 +863,6 @@
 				}
 				/* Load up some configured values */
-				$this->db->query("SELECT config_name,config_value FROM phpgw_config "
-					. "WHERE config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%'",__LINE__,__FILE__);
+				$this->db->query("SELECT config_name,config_value,config_app FROM phpgw_config " 
+					. "WHERE config_app = 'phpgwapi' AND (config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%')",__LINE__,__FILE__); 
 				while($this->db->next_record())
 				{
Index: /branches/2.2/phpgwapi/inc/class.sessions_php4.inc.php
===================================================================
--- /branches/2.2/phpgwapi/inc/class.sessions_php4.inc.php	(revision 2)
+++ /branches/2.2/phpgwapi/inc/class.sessions_php4.inc.php	(revision 3018)
@@ -125,10 +125,8 @@
 			else
 			{
-				$sessions = $this->list_sessions(0,'','',True);
-				
-				if (isset($sessions[$sessionid]))
-				{
-					//echo "<p>session_php4::destroy($session_id): unlink('".$sessions[$sessionid]['php_session_file'].")</p>\n";
-					@unlink($sessions[$sessionid]['php_session_file']);
+				if(@opendir($path = ini_get('session.save_path'))){ 
+					$session_file = $path."/sess_".$sessionid; 
+					if (file_exists($session_file)) 
+						@unlink($session_file); 
 				}
 			}
@@ -199,6 +197,4 @@
 		function list_sessions($start,$order,$sort,$all_no_sort = False)
 		{
-			//echo "<p>session_php4::list_sessions($start,'$order','$sort',$all)</p>\n";
-			$session_cache = $this->appsession('php4_session_cache','phpgwapi');
 
 			$values = array();
@@ -211,50 +207,15 @@
 			while ($file = readdir($dir))
 			{
-				if (substr($file,0,5) != 'sess_')
+				if (substr($file,0,5) != 'sess_' || !is_readable($path. '/' . $file))
 				{
 					continue;
 				}
-				if (isset($session_cache[$file]))	// use copy from cache
-				{
-					$session = $session_cache[$file];
-
-					if ($session['session_flags'] == 'A' || !$session['session_id'] ||
-						$session['session_install_id'] != $GLOBALS['phpgw_info']['server']['install_id'])
-					{
-						continue;	// no anonymous sessions or other domains or installations
-					}
-					if (!$all_no_sort)	// we need the up-to-date data --> unset and reread it
-					{
-						unset($session_cache[$file]);
-					}
-				}
-				if (!isset($session_cache[$file]))	// not in cache, read and cache it
-				{
-					if (!is_readable($path. '/' . $file))
-					{
-						continue;	// happens if webserver runs multiple user-ids
-					}
-					$session = '';
-					if (($fd = fopen ($path . '/' . $file,'r')))
-					{
-						$session = ($size = filesize ($path . '/' . $file)) ? @fread ($fd, $size) : 0;
-						fclose ($fd);
-					}
-					if (substr($session,0,14) != 'phpgw_session|')
-					{
-						continue;
-					}
-					$session = unserialize(substr($session,14));
-					unset($session['phpgw_app_sessions']);	// not needed, saves memory
-					$session_cache[$file] = $session;
-				}
-				if($session['session_flags'] == 'A' || !$session['session_id'] ||
-					$session['session_install_id'] != $GLOBALS['phpgw_info']['server']['install_id'])
-				{
-					continue;	// no anonymous sessions or other domains or installations
-				}
-				//echo "file='$file'=<pre>"; print_r($session); echo "</pre>"; 
-
-				$session['php_session_file'] = $path . '/' . $file;
+				$session = ''; 
+				if (($fd = fopen ($path . '/' . $file,'r'))) 
+				{ 
+					$session = ($size = filesize ($path . '/' . $file)) ? @fread ($fd, $size) : 0; 
+					fclose ($fd); 
+				} 
+				$session = unserialize(substr($session,14)); 
 				$values[$session['session_id']] = $session;
 			}
@@ -280,5 +241,4 @@
 				reset($values);
 			}
-			$this->appsession('php4_session_cache','phpgwapi',$session_cache);
 
 			return $values;
Index: /branches/2.2/phpgwapi/inc/functions.inc.php
===================================================================
--- /branches/2.2/phpgwapi/inc/functions.inc.php	(revision 1463)
+++ /branches/2.2/phpgwapi/inc/functions.inc.php	(revision 3018)
@@ -29,12 +29,5 @@
 
 	error_reporting(error_reporting() & ~E_NOTICE);
-
-	if (!function_exists('version_compare'))//version_compare() is only available in PHP4.1+
-	{
-		echo 'eGroupWare requires PHP 4.1 or greater.<br>';
-		echo 'Please contact your System Administrator';
-		exit;
-	}
-
+	
 	include(PHPGW_API_INC.'/common_functions.inc.php');
 	
@@ -378,4 +371,15 @@
 		reset($GLOBALS['phpgw_info']['flags']);
 
+
+		if(!include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme'))  
+		{  
+			/* Hope we don't get to this point.  Better then the user seeing a */  
+			/* complety back screen and not know whats going on                */  
+			echo '<body bgcolor="FFFFFF">';  
+			$GLOBALS['phpgw']->log->write(array('text'=>'F-Abort, No themes found'));  
+
+			exit;  
+		}  
+
 		/*************************************************************************\
 		* These lines load up the templates class                                 *
@@ -390,51 +394,4 @@
 		}
 
-		/*************************************************************************\
-		* These lines load up the themes                                          *
-		\*************************************************************************/
-		if (! $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'])
-		{
-			if (@$GLOBALS['phpgw_info']['server']['template_set'] == 'user_choice')
-			{
-				$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = 'default';
-			}
-			else
-			{
-				$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $GLOBALS['phpgw_info']['server']['template_set'];
-			}
-		}
-		if (@$GLOBALS['phpgw_info']['server']['force_theme'] == 'user_choice')
-		{
-			if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme']))
-			{
-				$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = 'default';
-			}
-		}
-		else
-		{
-			if (isset($GLOBALS['phpgw_info']['server']['force_theme']))
-			{
-				$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $GLOBALS['phpgw_info']['server']['force_theme'];
-			}
-		}
-
-		if(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '.theme'))
-		{
-			include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '.theme');
-		}
-		elseif(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme'))
-		{
-			include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme');
-		}
-		else
-		{
-			/* Hope we don't get to this point.  Better then the user seeing a */
-			/* complety back screen and not know whats going on                */
-			echo '<body bgcolor="FFFFFF">';
-			$GLOBALS['phpgw']->log->write(array('text'=>'F-Abort, No themes found'));
-
-			exit;
-		}
-		unset($theme_to_load);
 
 		/*************************************************************************\
@@ -488,20 +445,3 @@
 		}
 
-		/*************************************************************************\
-		* Load the app include files if the exists                                *
-		\*************************************************************************/
-		/* Then the include file */
-		if (PHPGW_APP_INC != "" &&
-                   ! preg_match ("/phpgwapi/i", PHPGW_APP_INC) &&
-                   file_exists(PHPGW_APP_INC . '/functions.inc.php') &&
-                   !isset($_GET['menuaction']))
-		{
-			include(PHPGW_APP_INC . '/functions.inc.php');
-		}
-		if (!@$GLOBALS['phpgw_info']['flags']['noheader'] &&
-			!@$GLOBALS['phpgw_info']['flags']['noappheader'] &&
-			file_exists(PHPGW_APP_INC . '/header.inc.php') && !isset($_GET['menuaction']))
-		{
-			include(PHPGW_APP_INC . '/header.inc.php');
-		}
-	}
+	}
Index: /branches/2.2/phpgwapi/inc/class.common.inc.php
===================================================================
--- /branches/2.2/phpgwapi/inc/class.common.inc.php	(revision 1576)
+++ /branches/2.2/phpgwapi/inc/class.common.inc.php	(revision 3018)
@@ -1264,29 +1264,44 @@
 			$tpl->set_var('app_css', $app_css);
 
-			// search for app specific css file
-			if(@isset($GLOBALS['phpgw_info']['flags']['currentapp']))
-			{
-				$appname = $GLOBALS['phpgw_info']['flags']['currentapp'];
-
-				if(file_exists(PHPGW_SERVER_ROOT . SEP . $appname . SEP
-					. 'templates' . SEP . $GLOBALS['phpgw_info']['server']['template_set']
-					. SEP . 'app.css')
-				)
-				{
-					$tpl->set_var('css_file', '<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url']
-						. "/$appname/templates/".$GLOBALS['phpgw_info']['server']['template_set']
-						. "/app.css".'" type=text/css rel=StyleSheet>');
-				}
-				elseif(file_exists(PHPGW_SERVER_ROOT . SEP . $appname . SEP
-					. 'templates' . SEP . 'default'
-					. SEP . 'app.css')
-				)
-				{
-					$tpl->set_var('css_file', '<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url']
-					."/$appname/templates/default/app.css".'" type=text/css rel=StyleSheet>');
-				}
-			}
-
-			return $tpl->subst('css');
+			// search for app specific css filie
+			if ( @ isset( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] ) ) 
+			{ 
+				$css = "/%s/templates/%s/%s.css"; 
+
+				global $path, $link, $template; 
+
+				$path = PHPGW_SERVER_ROOT . str_replace( '/', SEP, $css ); 
+
+				$link = '<LINK href="%s" type="text/css" rel="StyleSheet">'; 
+				$link = sprintf( $link, 
+					"{$GLOBALS[ 'phpgw_info' ][ 'server' ][ 'webserver_url' ]}{$css}" 
+				); 
+
+				$template = $GLOBALS[ 'phpgw_info' ][ 'server' ][ 'template_set' ]; 
+
+				function _css( $module, $css ) 
+				{ 
+					global $link, $path, $template; 
+
+					if ( file_exists( sprintf( $path, $module, $template, str_replace( '/', SEP, $css ) ) ) ) 
+						return sprintf( $link, $module, $template, $css ); 
+
+					if ( file_exists( sprintf( $path, $module, 'default', str_replace( '/', SEP, $css ) ) ) ) 
+						return sprintf( $link, $module, 'default', $css ); 
+
+					return ''; 
+				} 
+
+				$css = _css( 'phpgwapi', 'css/base' ); 
+				$css .= _css( 'phpgwapi', "css/{$GLOBALS[ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ]}" ); 
+				$css .= _css( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'currentapp' ], "css/{$GLOBALS[ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ]}" ); 
+				$css .= _css( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'currentapp' ], 'app' ); 
+
+				if ( $css ) 
+					$tpl -> set_var( 'css_file', $css ); 
+			} 
+
+			return $tpl -> subst('css'); 
+
 		}
 
Index: /branches/2.2/phpgwapi/templates/classic/css/celepar.css
===================================================================
--- /branches/2.2/phpgwapi/templates/classic/css/celepar.css	(revision 1532)
+++ /branches/2.2/phpgwapi/templates/classic/css/celepar.css	(revision 3018)
@@ -352,5 +352,5 @@
 .dsused
 {
-	        background-image: url(../../../../expressoMail1_2/templates/default/images/dsused_classic.gif) !important;
+	background-image: url(../../../../expressoMail1_2/templates/default/images/dsused_classic.gif) !important;
 }
 #fmLocation
@@ -413,2 +413,231 @@
 	background-color:white;
 }
+
+.toolbar
+{
+       background-image:url(../../../../phpgwapi/templates/default/images/fundo_topo.gif);
+       position:absolute;
+}
+
+.logo_expresso
+{
+
+	background:transparent url(../../../../phpgwapi/templates/default/images/logo_expresso_classic.png) no-repeat scroll right 0px;
+	right:0px;
+	position:absolute;
+	width:191px;
+}
+
+.navbar_but
+{
+        background-image: url(../../../../phpgwapi/templates/default/images/back_app_classic.png) !important;
+        width: 40px !important;
+        height: 40px !important;
+        padding: 0 19px 0 13px !important;
+        vertical-align: center !important;
+        text-align: center !important;
+}
+
+.navbar_butOver
+{
+        background-image: url(../../../../phpgwapi/templates/default/images/back_app_classic.png) !important;
+        width: 40px !important;
+        height: 40px !important;
+        vertical-align: center !important;
+        text-align: center !important;
+	padding: 0 19px 0 13px !important;
+
+}
+
+.navbar_butOut
+{
+        background-image: url(../../../../phpgwapi/templates/default/images/back_app_classic.png) !important;
+        width: 40px !important;
+        height: 40px !important;
+        vertical-align: center !important;
+        text-align: center !important;
+        padding: 0 19px 0 13px !important;
+
+
+}
+#expressoAdmin12id,
+#adminid,
+#homeid,
+#contactcenterid,
+#expressoMail12id,
+#newsadminid,
+#calendarid,
+#jabberitmessengerid,
+#logout_id
+{
+	width: 32px !important;
+	height: 32px !important;
+
+}
+
+table.inboxElements th,
+.table_elements_tr_header,
+.message_header{
+        background-color: #CCCCCC !important;
+}
+
+.table_message_header_box{
+        width: 100% !important;
+        color: black !important;
+        border-style: solid !important;
+        border-width: 0px !important;
+        border-collapse: collapse !important;
+        border-color: #bbbbbb !important;
+        font-family: Arial !important;
+        font-size: 13px !important;
+        cursor: pointer !important;
+}
+.font-menu
+{
+    text-decoration: none !important;
+    text-align: center !important;
+    font: bold 13px Lucidatypewriter,monospace !important;
+    color: #505050 !important;
+}
+.font-menu-sel
+{
+    text-decoration: none !important;
+    text-align: center !important;
+    font: bold 11px Lucidatypewriter,monospace !important;
+    color:#0000FF !important;
+}
+
+.menu-sel
+{
+    text-decoration: none !important;
+    text-align: center !important;
+    font: bold 11px Lucidatypewriter,monospace !important;
+    color:#0000FF !important;
+    height: 20px !important;
+    background-color: #F7F7F7 !important;
+    margin-bottom: 0px !important;
+    border-left: 1px solid #000000 !important;
+    border-top: 1px solid #000000 !important;
+    border-right: 1px solid #000000 !important;
+    padding:0px 5px 0px 0px !important;
+    -moz-border-radius: 9px 9px 0px 0px !important;
+    -moz-user-select: none !important;
+    cursor: pointer !important;
+}
+
+.menu
+{
+    text-decoration: none !important;
+    text-align: center !important;
+    color: #505050 !important;
+    height: 20px !important;
+    background-color:#E5E5E5 !important;
+    margin-bottom: 0px !important;
+    border-left: 1px solid #c0c0c0 !important;
+    border-top: 1px solid #c0c0c0 !important;
+    border-right: 1px solid #c0c0c0 !important;
+    border-bottom: 1px solid #000000 !important;
+    padding:0px 5px 0px 0px !important;
+    -moz-border-radius: 9px 9px 0px 0px !important;
+    -moz-user-select: none !important;
+    cursor: pointer !important;
+}
+
+.last_menu
+{
+        border-bottom: 1px solid #000000 !important;
+        -moz-border-radius: 0px 0px 0px 0px !important;
+}
+.conteudo {
+    font-family: Verdana, Arial, Helvetica, sans-serif !important;
+    font-size: 10px !important;
+    font-weight: normal !important;
+    color: #000033 !important;
+        padding: 1px !important;
+    border-color: gray gray gray gray !important;
+
+        border-right: 1px solid #000000 !important;
+        border-left: 1px solid #000000 !important;
+        border-bottom: 1px solid #000000 !important;
+        width:99.5% !important;
+    -moz-border-radius: 0px 0px 6px 6px !important;
+}
+
+.table_message{
+        background-color: #CCCCCC !important;
+		background-image: none !important;
+        padding: 1px !important;
+        cursor: default !important;
+        border-width: 1px 1px 1px 1px !important;
+        border-spacing: 0px 1px !important;
+        border-style: outset outset outset outset !important;
+        border-color: gray gray gray gray !important;
+        border-collapse: separate !important;
+        -moz-border-radius: 3px 3px 3px 3px !important;
+}
+
+.image-menu {
+	padding: 3px 0px 3px 5px !important;
+	border-top: 1px solid #000000 !important;
+	border-right: 1px solid #000000 !important;
+	border-left: 1px solid #000000 !important;
+	border-bottom: 1px solid #000000 !important;
+	-moz-border-radius: 9px 9px 9px 9px !important;
+}
+
+.image-menu,
+.menu-degrade
+{
+	background-image: none !important;
+}
+
+.content-menu-td {
+        border: 1px solid #f7f7f7 !important;
+}
+
+.content-menu {
+	background: none !important;
+	padding: 4px !important;
+	width:162px !important;
+	border-top: 1px solid #000000 !important;
+	border-right: 1px solid #000000 !important;
+	border-left: 1px solid #000000 !important;
+	border-bottom: 1px solid #000000 !important;
+	-moz-border-radius: 9px 9px 9px 9px !important;
+	position: relative !important;
+	overflow: auto !important;
+}
+
+.message_options_trash,
+.message_options_import,
+.message_options_inactive,
+.message_options_export,
+.message_options_move,
+.message_options_print,
+.message_options_active,
+.message_options,
+.message_options_over
+{
+	color:blue !important;
+	font-weight: normal !important;
+	background-image: none !important;
+	padding:0 7 0 0 !important;
+}
+.l{
+	background-image: none !important;
+	color: #666666 !important;
+
+}
+.sl
+{
+	background-image: none !important;
+	color: blue !important;
+}
+.linha0, 
+.tr_msg_read2,
+.tr_msg_read {
+-moz-user-select:none !important;
+background-color:#FFFFFF !important;
+border-bottom:1px solid #CFCFCF !important;
+color:black !important;
+}
Index: /branches/2.2/phpgwapi/templates/classic/head.tpl
===================================================================
--- /branches/2.2/phpgwapi/templates/classic/head.tpl	(revision 1151)
+++ /branches/2.2/phpgwapi/templates/classic/head.tpl	(revision 3018)
@@ -13,5 +13,4 @@
 		<link rel="icon" href="{img_icon}" type="image/x-ico" />
 		<link rel="shortcut icon" href="{img_shortcut}" />
-		<link href="{theme_css}" title="eGroupWareStyle" type="text/css" rel="StyleSheet"/>
 		<META http-equiv="Default-Style" content="eGroupWareStyle">
 		{slider_effects}
Index: /branches/2.2/phpgwapi/templates/default/css/celepar.css
===================================================================
--- /branches/2.2/phpgwapi/templates/default/css/celepar.css	(revision 1704)
+++ /branches/2.2/phpgwapi/templates/default/css/celepar.css	(revision 3018)
@@ -438,4 +438,7 @@
 }
 
+table.inboxElements th,
+.table_elements_tr_header,
+.info_tr_header,
 .message_header{
         background-color: #CCCCCC !important;
@@ -475,5 +478,4 @@
     color:#0000FF !important;
     height: 20px !important;
-    width:220px !important;
     background-color: #F7F7F7 !important;
     margin-bottom: 0px !important;
@@ -493,5 +495,4 @@
     color: #505050 !important;
     height: 20px !important;
-    width:220px !important;
     background-color:#E5E5E5 !important;
     margin-bottom: 0px !important;
@@ -601,4 +602,6 @@
 	background-image: none !important;
 }
+
+.linha0,
 .tr_msg_read2,
 .tr_msg_read {
Index: /branches/2.2/phpgwapi/templates/default/css/comics.css
===================================================================
--- /branches/2.2/phpgwapi/templates/default/css/comics.css	(revision 1195)
+++ /branches/2.2/phpgwapi/templates/default/css/comics.css	(revision 3018)
@@ -486,4 +486,7 @@
 }
 
+table.inboxElements th,
+.table_elements_tr_header,
+.info_tr_header,
 .message_header
 {
@@ -505,8 +508,8 @@
 {
 	-moz-border-radius-topleft:5px !important;
-        -moz-border-radius-topright:5px !important;
-        background-color: white !important;
-        border: 2px solid black !important;
-        border-bottom: 0px !important;
+	-moz-border-radius-topright:5px !important;
+	background-color: white !important;
+	border: 2px solid black !important;
+	border-bottom: 0px !important;
 	color black !important;
 }
Index: /branches/2.2/phpgwapi/templates/default/css/rochas.css
===================================================================
--- /branches/2.2/phpgwapi/templates/default/css/rochas.css	(revision 1719)
+++ /branches/2.2/phpgwapi/templates/default/css/rochas.css	(revision 3018)
@@ -1,514 +1,292 @@
-ul
-{
-	list-style-image: url("../images/orange-ball.png");
-}
-
-.grid_email_class
-{
-	border-bottom:1px solid #cfcfcf;
-}
-.selected_shortcut_msg {
-	color:	black	!important;
-	background-color: BurlyWood !important;
-}
-
-body 
-{
-	margin: 0px !important;
-	background-color:#E9E9E9 !important;
-	font-size: 11px !important;
-	font-family: Verdana, Arial, Helvetica, sans-serif !important;
-	padding:0px !important;
-}
-
-img
-{
-	border-width:0px !important;
-	border-style:none !important;
-	/*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader;
-*/
-}
-
-a:link,a:visited
-{
-	cursor:pointer !important;
-	color: #000066 !important;
-	text-decoration: none !important;
-}
-
-/*
-a:visited 
-{
-	color: #006699; 
-	text-decoration: none;
-}
-*/
-a:hover,a:active
-{
-	cursor:pointer !important;
-	color: #ff9933 !important;
-	text-decoration: underline !important;
-}
-/*
-a:active 
-{
-	color: #006699; 
-	text-decoration: underline;
-}
-*/
-input,button
-{
-	font-size: 11px !important; 
-	color: #006699 !important;
-	font-family: Arial, Helvetica, sans-serif !important;
-	border: 1px #bbbbbb solid !important;
-}
-input.em_button_like_span {
-	color:#886633 !important;
-}
-input[type=submit],input[type=button],button
-{
-	margin:1px !important;
-	padding:1px !important;
-	cursor: pointer !important; 
-	cursor: hand !important;
+body
+{
+	background-color: #e9e9e9;
+}
+
+a:link,
+a:visited
+{
+	color: #000066;
+}
+
+a:hover,
+a:active
+{
+	color: #ff9933;
+}
+
+a.divSideboxEntry,
+.divSideboxEntry
+{
+	background-color: #eee;
+}
+
+a.textSidebox
+{
+	border-top-color: #aaa;
+}
+
+input,
+button
+{
+	border-color: #bbb;
+	color: #069;
 }
 
 input[type=image]
 {
-	cursor: pointer !important; 
-	cursor: hand !important;
-	border: 0px #bbbbbb none !important;
-}
-select 
-{
-	font-size: 11px !important; 
-	color: #000066 !important; 
-	font-family: Arial, Helvetica, sans-serif !important;
-	border: 1px #bbbbbb solid !important;
-	z-index: -1 !important;
-}
-
-td
-{
-	font-size: 11px !important;
-	/*text-align:left;*/
-	/*	padding-top:1px;
-	padding-bottom:1px;*/
-}
-
-.divLoginbox 
-{
-	position:relative;
-	width: 300px; 
-	border-right: #9c9c9c 1px solid; 
-	border-top: #9c9c9c 1px solid; 
-	border-left: #9c9c9c 1px solid; 
-	border-bottom: #9c9c9c 1px solid
-}
-
-.divLoginboxHeader 
-{
-	text-align:center;
-	background-color:#dddddd;
-	padding-top:2px;
-	font-size:10px;
-	color:#666666;
-}
-.divSidebox 
-{
-	position:relative;
-	width: 147px; 
-	border-right: #9c9c9c 1px solid; 
-	border-top: #9c9c9c 1px solid; 
-	border-left: #9c9c9c 1px solid; 
-	border-bottom: #9c9c9c 1px solid
-}
-
-.tblHeadApp {
-
-	border-right: #9c9c9c 1px solid; 	
-	border-top: #9c9c9c 1px solid; 
-	border-left: #9c9c9c 1px solid; 
-	border-bottom: #9c9c9c 1px solid
-}
-
-.divSideboxHeader 
-{
-	text-align:center;
-	background-color:#000066;
-	padding-top:2px;
-	height: 15px;
-	color: #FFFFFF;
-
-}
-
-a.divSideboxEntry, .divSideboxEntry
-{
-	text-align:left;
-	height:16px;
-	background-color:#eeeeee;
-}
-
-a.appTitles,.appTitles
-{
-	font-size: 10px; 
-	height:18px;
-	padding-top:2px;
-	padding-bottom:2px;
-
-}
-
-a.textSidebox
-{
-	font-size: 10px; 
-	border-top: #aaaaaa 0px none;
-}
-
-.textSidebox
-{
-	font-size: 10px; 
-	height:18px;
-	padding-top:2px;
-	padding-bottom:2px;
-	border-top: #aaaaaa 1px solid;
-
-}
-
-.sideboxSpace
-{
-	height:9px;
-}
-
-.dsused
-{
-                background-image: url(../images/dsused.gif);
-}
-
-.greyLine
-{
-	margin:1px;
-	border-top-color:#7e7e7e;
-	border-top-width:1px;
-	border-top-style:solid;
-	height:1px;
-}
-
-.prefSection
-{
-	font-weight:bold;
-	font-size:16px;
-	line-height:40px;
-}
-
-#extraIcons
-{
-/*	position:absolute;
-	z-index:13;
-	right:10px;
-	top:113px;
-	visibility:hidden;*/
-/*	background-image:url(../images/alpha-white.png);*/
-	background-color:#eeeeee;
-	border-width:1px;
-	border-color:#7e7e7e;
-	border-style:solid;
-}
-
-.extraIconsRow
-{
-	border-top-color:#dddddd;
-	border-top-width:1px;
-	border-top-style:solid;
-	padding:2px;
-}
-
-#divMain
-{
-	background-color:white;
-	margin-top: 0px;
-	padding:9px;
-	border-color:#7e7e7e;
-	border-width:1px;
-	border-style:solid;
-}
-
-#divLogo
-{
-	position:absolute;
-	left:20px;
-	top:5px;
-	z-index:51;
-}
-
-#divAppIconBar
-{
-	background-color:white;
-	border-top-color:#9c9c9c;
-	border-top-width:1px;
-	border-top-style:solid;
-	background-image: url(../images/background-icon-bar.png); 
-	background-repeat: repeat-x
-}
-
-#divAppTextBar
-{
-	background-color:white;
-}
-
-#user_info
-{
-	color: black;
-}
-#links_bar
-{
-	        color: black;
-}
-
-#divStatusBar
-{
-	height:24px;
-	padding-left:10px;
-	padding-top:0px;
-}
-
-/*#divSubContainer
-{
-}
-*/
-#tdSidebox
-{
-	width:170px;
-	background-color:white;
-	overflow:visible;
-}
-
-
-#tdAppbox
-{
-	background-color:white;
-	width: 100%;
-}
-#divSideboxContainer
-{
-	position:relative;
-	width:150px;
-	top:0px;
-	left:0px;
-	background-color:white;
-	border-width:1px;
-	border-style:solid;
-	z-index:40;
+	border-color: #bbb;
+}
+
+select
+{
+	border-color: #bbb;
+	color: #006;
+}
+
+#divAppbox
+{
+	background: #eeeee0;
+	border-color: #9c9c9c;
 }
 
 #divAppboxHeader
 {
-	margin-top:2px;
-	margin-left:2px;
-	margin-right:2px;
-	font-family: Verdana, Arial, Helvetica, sans-serif;
+	background: #eeeee0;
+	border-color: #9c9c9c;
+	color: #006;
 	font-size: 14px;
 	font-weight: bold;
-	color: #000066;
+}
+
+#divAppIconBar
+{
+	background: #fff url( ../images/background-icon-bar.png ) repeat-x;
+	border-top-color: #9c9c9c;
+}
+
+#divAppTextBar
+{
+	background-color: #fff;
+}
+
+#divGenTime
+{
+	color: #f00;
+}
+
+#divMain
+{
+	background: #fff;
+	border-color: #7e7e7e;
+}
+
+#divPoweredBy
+{
+	background: #fff;
+	color: #999;
+}
+
+#divSideboxContainer
+{
+	background: #fff;
+}
+
+#extraIcons
+{
+	background: #eee;
+	border-color: #7e7e7e;
+}
+
+#links_bar,
+#user_info
+{
+	color: #000;
+}
+
+#tdAppbox
+{
+	background-color: #fff;
+}
+
+#tdSidebox
+{
+	background: #fff;
+}
+
+.conteudo
+{
+	border-color: #4A79B1;
+	color: #003;
+}
+
+.divSideboxHeader
+{
+	background: #006;
+	color: #fff;
+}
+
+.extraIconsRow
+{
+	border-top-color: #ddd;
+}
+
+.greyLine
+{
+	border-top-color: #7e7e7e;
+}
+
+.grid_email_class
+{
+	border-bottom-color: #cfcfcf;
+}
+
+.image-menu
+{
+	background: #ddf4fe url( ../../../../phpgwapi/templates/default/images/folder_bg_canyon.jpg ) no-repeat scroll center bottom;
+}
+
+.last_menu
+{
+	border-bottom-color: #4a79b1;
+}
+
+.logo_expresso
+{
+	background: url( ../../../../phpgwapi/templates/default/images/logo_expresso_canyon.png ) no-repeat;
+	width: 264px;
+	height: 35px;
+}
+
+.menu
+{
+	background: #a19183;
+	border-color: #f4f7fc;
+	border-bottom-color: #4a79b1;
+}
+
+.menu-sel
+{
+	background-color: #f7f7f7;
+	border-color: #A19183;
+	color: #00f;
+}
+
+.menu-degrade
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/degrade.png );
+}
+
+.navbar_but
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/back_app_canyon.png );
+}
+
+.navbar_butOver
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/back_app_over_canyon.png );
+}
+
+.navbar_butOut
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/back_app_out_canyon.png );
+}
+
+.tblHeadApp
+{
+	border-color: #9c9c9c;
+}
+
+.textSidebox
+{
+	border-top-color: #aaa;
+}
+
+.toolbar
+{
+	background-image: url(../../../../phpgwapi/templates/default/images/fundo_topo_canyon.png);
+}
+
+.whiteSpace
+{
+	width: 2px;
+}
+
+.linha0,
+.linha1,
+.tr_msg_read,
+.tr_msg_read2
+{
+	color: #615143;
+	background: #fff;
+}
+
+.linha1,
+.tr_msg_read2
+{
+	background: #eeeee0;
+}
+
+table.inboxElements th,
+.table_elements_tr_header,
+.info_tr_header,
+.message_header
+{
+	background: #cfb69e;
+}
+
+.content-menu
+{
+	padding: 0px;
+	background: #fff;
+}
+
+.divLoginbox
+{
+	border: 1px solid #9c9c9c;
+	position: relative;
+	width: 300px;
+}
+
+.divLoginboxHeader
+{
+	background-color: #ddd;
+	color: #666;
+	font-size: 10px;
+	padding-top: 2px;
 	text-align: center;
-	padding: 0px;
-	background-color: #eeeee0;
-	height:24px;
-	line-height:24px;
-	border-top-color:#9c9c9c;
-	border-top-width:1px;
-	border-top-style:solid;
-	border-left-color:#9c9c9c;
-	border-left-width:1px;
-	border-left-style:solid;
-	border-right-color:#9c9c9c;
-	border-right-width:1px;
-	border-right-style:solid;
-}
-
-#divAppbox
-{
-	background-color: #eeeee0;
-	padding-right:1px;
-	padding-top:1px;
-	padding-bottom:1px;
-	padding-left:15px;
-	border-bottom-color:#9c9c9c;
-	border-bottom-width:1px;
-	border-bottom-style:solid;
-	border-left-color:#9c9c9c;
-	border-left-width:1px;
-	border-left-style:solid;
-	border-right-color:#9c9c9c;
-	border-right-width:1px;
-	border-right-style:solid;
-	margin-top:0px;
-	margin-bottom:0px;
-	margin-left:2px;
-	margin-right:2px;
-
-}
-
-#user_info
-{
-padding-left:17px;
-
-}
-
-#admin_info
-{
-	position:relative;
-	text-align:center;
-	margin-right:10px;
-}
-
-#divGenTime
-{
-	bottom:14px;
-	font-size: 9px;
-	color: #ff0000;
-	text-align:center;
-	width:99%;
-}
-
-#divPoweredBy 
-{
-	font-family: Verdana, Arial, Helvetica, sans-serif;
-	font-size: 10px;
-	color: #999999;
-	text-decoration: none;
-	padding: 7px;
-	text-align: center;
-	background-color:white;
-}
-.navbar_but
-{
-        background-image: url(../../../../phpgwapi/templates/default/images/back_app_canyon.png) !important;
-        width: 40px;
-        height: 40px;
-        vertical-align: center;
-        text-align: center;
-        padding-right: 6px;
-        cursor:pointer;
-        cursor:hand;
-        background-repeat:no-repeat;
-}
-
-.navbar_butOver
-{
-        background-image: url(../../../../phpgwapi/templates/default/images/back_app_over_canyon.png) !important;
-        width: 40px;
-        height: 40px;
-        vertical-align: center !important;
-        text-align: center !important;
-        padding-right:6px;
-        cursor:pointer;
-        cursor:hand;
-        background-repeat:no-repeat;
-}
-
-.navbar_butOut
-{
-        background-image: url(../../../../phpgwapi/templates/default/images/back_app_out_canyon.png) !important;
-        width: 40px;
-        height: 40px;
-        vertical-align: center !important;
-        text-align: center !important;
-        padding-right:6px;
-        cursor:pointer;
-        cursor:hand;
-        background-repeat:no-repeat;
-}
-
-.toolbar
-{
-        background-image:url(../../../../phpgwapi/templates/default/images/fundo_topo_canyon.png);
-        position:absolute;
-}
-
-.logo_expresso
-{
-        background:url(../../../../phpgwapi/templates/default/images/logo_expresso_canyon.png) no-repeat;
-        width: 264px;
-        height: 35px;
-}
-
-.content-menu {
-        padding: 0px 0px 0px 0px !important;
-        background: #fff !important;
-}
-
-.image-menu {
-        padding: 0px 0px 0px 0px !important;
-        background: #ddf4fe url(../../../../phpgwapi/templates/default/images/folder_bg_canyon.jpg) no-repeat scroll center bottom !important;
-}
-
-.menu-degrade {
-          background-image: url(../../../../phpgwapi/templates/default/images/degrade.png) !important;
-          background-repeat: repeat-x;
-}
-
-.navbar_butOut
-{
-        background-image: url(../../../../phpgwapi/templates/default/images/back_app_out_canyon.png) !important;
-        width: 40px;
-        height: 40px;
-        vertical-align: center !important;
-        text-align: center !important;
-        padding-right:6px;
-        cursor:pointer;
-        cursor:hand;
-        background-repeat:no-repeat;
-}
-
-.toolbar
-{
-        background-image:url(../../../../phpgwapi/templates/default/images/fundo_topo_canyon.png);
-        position:absolute;
-}
-
-.logo_expresso
-{
-        background:url(../../../../phpgwapi/templates/default/images/logo_expresso_canyon.png) no-repeat;
-        width: 264px;
-        height: 35px;
-}
-
-.message_header{
-        background-color: #cfb69e !important;
-}
-.menu
-{
-	background-color:#a19183 !important;
-	border: 1px solid #f4f7fc !important;
-	border-bottom: 1px solid #4a79b1 !important;
-}
-.menu-sel{
-    color:#0000FF !important;
-    background-color:#F7F7F7 !important;
-    border-color: #A19183 !important;
-}
-.table_message{
-        background: url(../../../../phpgwapi/templates/default/images/fundo_topo_canyon.png) !important;
-}
-
-.message_options {
-	 color: #863 !important;
+}
+
+.divSidebox
+{
+	position: relative;
+	border: 1px solid #9c9c9c;
+	width: 147px;
+}
+
+.table_message
+{
+	background: url( ../../../../phpgwapi/templates/default/images/fundo_topo_canyon.png );
+}
+
+.message_options
+{
+	color: #863;
 }
 
 .tr_msg_unread
 {
-	background-color:#EEEEE0 !important;
-}
-.tr_msg_read {
-	color: #3f3f3f;
-	background-color: #ffffff;
-	-moz-user-select: none;
-}
-
-.tr_msg_read2 {
-	color: #3f3f3f;
-	background-color: #eeeee0;
-	-moz-user-select: none;
-}
-
+	color: #000;
+	font-style: oblique;
+}
+
+.selected_shortcut_msg
+{
+	color: #000;
+	background-color: BurlyWood;
+}
+
+input.em_button_like_span
+{
+	color: #886633;
+}
Index: /branches/2.2/phpgwapi/templates/default/css/escritorio.css
===================================================================
--- /branches/2.2/phpgwapi/templates/default/css/escritorio.css	(revision 1704)
+++ /branches/2.2/phpgwapi/templates/default/css/escritorio.css	(revision 3018)
@@ -430,4 +430,7 @@
 }
 
+table.inboxElements th,
+.table_elements_tr_header,
+.info_tr_header,
 .message_header
 {
@@ -484,2 +487,60 @@
 	background:transparent url(../../../../phpgwapi/templates/default/images/blackwhite.jpg) repeat-x;
 }
+
+
+.conteudo { 
+	font-family: Verdana, Arial, Helvetica, sans-serif; 
+	font-size: 10px; 
+	font-weight: normal; 
+	color: #000033; 
+	padding: 2px; 
+    border-left: 1px solid;
+    border-right: 1px solid;
+    border-bottom: 1px solid;
+    border-color: #4A79B1;
+	width:99.5%; 
+	overflow: none; 
+	-moz-border-radius: 0px 0px 6px 6px; 
+} 
+
+.whiteSpace{ 
+	width: 2px; 
+}
+
+.menu
+{
+	text-decoration: none;
+	text-align: center;
+	height: 20px;
+	background-color:#c8d7ea;
+	margin-bottom: 0px;
+	border: 1px solid #f4f7fc;
+	border-bottom: 1px solid #4a79b1;
+	padding:0px 5px 0px 0px;
+	-moz-border-radius: 9px 9px 0px 0px;
+	-moz-user-select: none;
+	cursor: pointer;
+}
+
+.last_menu
+{
+	border-bottom: 1px solid #4a79b1; 
+	-moz-border-radius: 0px 0px 0px 0px; 
+}
+
+.menu-sel
+{
+	text-decoration: none;
+	text-align: center;
+	font: bold 13px Lucidatypewriter,monospace;
+	color:#0000FF;
+	height: 20px;
+	background-color:#F7F7F7;
+	margin-bottom: 0px;
+	border: 1px solid #4a79b1;
+	border-bottom: 0px;
+	padding:0px 5px 0px 0px;
+	-moz-border-radius: 9px 9px 0px 0px;
+	-moz-user-select: none;
+	cursor: pointer;
+}
Index: /branches/2.2/phpgwapi/templates/default/css/cataratas.css
===================================================================
--- /branches/2.2/phpgwapi/templates/default/css/cataratas.css	(revision 1719)
+++ /branches/2.2/phpgwapi/templates/default/css/cataratas.css	(revision 3018)
@@ -1,491 +1,298 @@
-ul
-{
-	list-style-image: url("../images/orange-ball.png");
-}
-
-.grid_email_class
-{
-	border-bottom:1px solid #cfcfcf;
-}
-
-body 
-{
-	margin: 0px !important;
-	background-color:#E9E9E9 !important;
-	font-size: 11px !important;
-	font-family: Verdana, Arial, Helvetica, sans-serif !important;
-	padding:0px !important;
-}
-
-img
-{
-	border-width:0px !important;
-	border-style:none !important;
-	/*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader;
-*/
-}
-
-a:link,a:visited
-{
-	cursor:pointer !important;
-	color: #000066 !important;
-	text-decoration: none !important;
-}
-
-/*
-a:visited 
-{
-	color: #006699; 
-	text-decoration: none;
-}
-*/
-a:hover,a:active
-{
-	cursor:pointer !important;
-	color: #ff9933 !important;
-	text-decoration: underline !important;
-}
-/*
-a:active 
-{
-	color: #006699; 
-	text-decoration: underline;
-}
-*/
-input,button
-{
-	font-size: 11px !important; 
-	color: #006699 !important; 
-	font-family: Arial, Helvetica, sans-serif !important;
-	border: 1px #bbbbbb solid !important;
-}
-
-input[type=submit],input[type=button],button
-{
-	margin:1px !important;
-	padding:1px !important;
-	cursor: pointer !important; 
-	cursor: hand !important;
+body
+{
+	background-color: #e9e9e9;
+}
+
+a:link,
+a:visited
+{
+	color: #000066;
+}
+
+a:hover,
+a:active
+{
+	color: #ff9933;
+}
+
+a.divSideboxEntry,
+.divSideboxEntry
+{
+	background-color: #eee;
+}
+
+a.appTitles,
+.appTitles
+{
+	padding: 2px 2px;
+}
+
+a.textSidebox
+{
+	border-top-color: #aaa;
+}
+
+input,
+button
+{
+	border-color: #bbb;
+	color: #069;
 }
 
 input[type=image]
 {
-	cursor: pointer !important; 
-	cursor: hand !important;
-	border: 0px #bbbbbb none !important;
-}
-select 
-{
-	font-size: 11px !important; 
-	color: #000066 !important; 
-	font-family: Arial, Helvetica, sans-serif !important;
-	border: 1px #bbbbbb solid !important;
-	z-index: -1 !important;
-}
-
-td
-{
-	font-size: 11px !important;
-	/*text-align:left;*/
-	/*	padding-top:1px;
-	padding-bottom:1px;*/
-}
-
-.divLoginbox 
-{
-	position:relative;
-	width: 300px; 
-	border-right: #9c9c9c 1px solid; 
-	border-top: #9c9c9c 1px solid; 
-	border-left: #9c9c9c 1px solid; 
-	border-bottom: #9c9c9c 1px solid
-}
-
-.divLoginboxHeader 
-{
-	text-align:center;
-	background-color:#dddddd;
-	padding-top:2px;
-	font-size:10px;
-	color:#666666;
-}
-.divSidebox 
-{
-	position:relative;
-	width: 147px; 
-	border-right: #9c9c9c 1px solid; 
-	border-top: #9c9c9c 1px solid; 
-	border-left: #9c9c9c 1px solid; 
-	border-bottom: #9c9c9c 1px solid
-}
-
-.tblHeadApp {
-
-	border-right: #9c9c9c 1px solid; 	
-	border-top: #9c9c9c 1px solid; 
-	border-left: #9c9c9c 1px solid; 
-	border-bottom: #9c9c9c 1px solid
-}
-
-.divSideboxHeader 
-{
-	text-align:center;
-	background-color:#000066;
-	padding-top:2px;
-	height: 15px;
-	color: #FFFFFF;
-
-}
-
-a.divSideboxEntry, .divSideboxEntry
-{
-	text-align:left;
-	height:16px;
-	background-color:#eeeeee;
-}
-
-a.appTitles,.appTitles
-{
-	font-size: 10px; 
-	height:18px;
-	padding-top:2px;
-	padding-bottom:2px;
-
-}
-
-a.textSidebox
-{
-	font-size: 10px; 
-	border-top: #aaaaaa 0px none;
-}
-
-.textSidebox
-{
-	font-size: 10px; 
-	height:18px;
-	padding-top:2px;
-	padding-bottom:2px;
-	border-top: #aaaaaa 1px solid;
-
-}
-
-.sideboxSpace
-{
-	height:9px;
-}
-
-.greyLine
-{
-	margin:1px;
-	border-top-color:#7e7e7e;
-	border-top-width:1px;
-	border-top-style:solid;
-	height:1px;
-}
-
-.prefSection
-{
-	font-weight:bold;
-	font-size:16px;
-	line-height:40px;
-}
-
-#extraIcons
-{
-	background-color:#eeeeee;
-	border-width:1px;
-	border-color:#7e7e7e;
-	border-style:solid;
-}
-
-.extraIconsRow
-{
-	border-top-color:#dddddd;
-	border-top-width:1px;
-	border-top-style:solid;
-	padding:2px;
-}
-
-#divMain
-{
-	background-color:white;
-	margin-top: 0px;
-	padding:9px;
-	border-color:#7e7e7e;
-	border-width:1px;
-	border-style:solid;
-}
-
-#divLogo
-{
-	position:absolute;
-	left:20px;
-	top:5px;
-	z-index:51;
-}
-
-#divAppIconBar
-{
-	background-color:white;
-	border-top-color:#9c9c9c;
-	border-top-width:1px;
-	border-top-style:solid;
-	background-image: url(../images/background-icon-bar.png); 
-	background-repeat: repeat-x
-}
-
-#divAppTextBar
-{
-	background-color:white;
-}
-
-#user_info
-{
-	color: white;
-}
-#links_bar
-{
-	        color: white;
-}
-
-#divStatusBar
-{
-	height:24px;
-	padding-left:10px;
-	padding-top:0px;
-}
-
-/*#divSubContainer
-{
-}
-*/
-#tdSidebox
-{
-	width:170px;
-	background-color:white;
-	overflow:visible;
-}
-
-
-#tdAppbox
-{
-	background-color:white;
-	width: 100%;
-}
-#divSideboxContainer
-{
-	position:relative;
-	width:150px;
-	top:0px;
-	left:0px;
-	background-color:white;
-	border-width:1px;
-	border-style:solid;
-	z-index:40;
+	border-color: #bbb;
+}
+
+select
+{
+	border-color: #bbb;
+	color: #006;
+}
+
+#divAppbox
+{
+	background: #e6f3d9;
+	border-color: #9c9c9c;
 }
 
 #divAppboxHeader
 {
-	margin-top:2px;
-	margin-left:2px;
-	margin-right:2px;
-	font-family: Verdana, Arial, Helvetica, sans-serif;
+	background: #e6f3d9;
+	border-color: #9c9c9c;
+	color: #006;
 	font-size: 14px;
 	font-weight: bold;
-	color: #000066;
+}
+
+#divAppIconBar
+{
+	background: #fff url( ../images/background-icon-bar.png ) repeat-x;
+	border-top-color: #9c9c9c;
+}
+
+#divAppTextBar
+{
+	background-color: #fff;
+}
+
+#divGenTime
+{
+	color: #f00;
+}
+
+#divMain
+{
+	background: #fff;
+	border-color: #7e7e7e;
+}
+
+#divPoweredBy
+{
+	background: #fff;
+	color: #999;
+}
+
+#divSideboxContainer
+{
+	background: #fff;
+}
+
+#extraIcons
+{
+	background: #eee;
+	border-color: #7e7e7e;
+}
+
+#links_bar,
+#user_info
+{
+	color: #fff;
+}
+
+#tdAppbox
+{
+	background-color: #fff;
+}
+
+#tdSidebox
+{
+	background: #fff;
+}
+
+.conteudo
+{
+	border-color: #4A79B1;
+	color: #003;
+}
+
+.divSideboxHeader
+{
+	background-color: #006;
+	color: #fff;
+}
+
+.extraIconsRow
+{
+	border-top-color: #ddd;
+}
+
+.greyLine
+{
+	border-top-color: #7e7e7e;
+}
+
+.grid_email_class
+{
+	border-bottom-color: #cfcfcf;
+}
+
+.image-menu
+{
+	background: #a0b2cc url( ../../../../phpgwapi/templates/default/images/folder_bg_fozi.jpg ) no-repeat scroll center bottom;
+}
+
+.last_menu
+{
+	border-bottom-color: #4a79b1;
+}
+
+.logo_expresso
+{
+	background: url( ../../../../phpgwapi/templates/default/images/logo_expresso_fozi.gif ) no-repeat;
+	height: 35px;
+	width: 264px;
+}
+
+.menu
+{
+	background: #c8d7ea;
+	border-color: #f4f7fc;
+	border-bottom-color: #4a79b1;
+}
+
+.menu-sel
+{
+	background-color: #f7f7f7;
+	border-color: #4a79b1;
+	color: #00f;
+}
+
+.menu-degrade
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/degrade.png );
+}
+
+.navbar_but
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/back_app_fozi.png );
+}
+
+.navbar_butOver
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/back_app_over_fozi.png );
+}
+
+.navbar_butOut
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/back_app_out_fozi.png );
+}
+
+.tblHeadApp
+{
+	border-color: #9c9c9c;
+}
+
+.textSidebox
+{
+	border-top-color: #aaa;
+}
+
+.toolbar
+{
+	background-image: url( ../../../../phpgwapi/templates/default/images/fundo_topo_fozi.jpg );
+}
+
+.linha0,
+.linha1,
+.tr_msg_read,
+.tr_msg_read2
+{
+	color: #3f3f3f;
+	background: #fff;
+}
+
+.linha1,
+.tr_msg_read2
+{
+	background: #e6f3d9;
+}
+
+table.inboxElements th,
+.table_elements_tr_header,
+.info_tr_header,
+.message_header
+{
+	background-color: #98c17f;
+}
+
+.message_options_active {
+	color: #d00;
+	font-weight: bold;
+}
+
+.message_options_inactive {
+	color: #999;
+}
+
+.message_options {
+	color: blue;
+	font-weight: bold;
+}
+
+.message_options_over {
+	color: #d00;
+	font-weight: bold
+}
+
+.table_message{
+	background: #98c17f;
+}
+
+
+
+#fmStatusBar
+{
+	margin-left: 4px;
+	margin-bottom: 3px;
+	font-size: 10px;
+}
+
+.divLoginbox
+{
+	position: relative;
+	width: 300px;
+	border: 1px solid #9c9c9c;
+}
+
+.divLoginboxHeader
+{
 	text-align: center;
-	padding: 0px;
-	background-color: #e6f3d9;
-	height:24px;
-	line-height:24px;
-	border-top-color:#9c9c9c;
-	border-top-width:1px;
-	border-top-style:solid;
-	border-left-color:#9c9c9c;
-	border-left-width:1px;
-	border-left-style:solid;
-	border-right-color:#9c9c9c;
-	border-right-width:1px;
-	border-right-style:solid;
-}
-
-#divAppbox
-{
-	background-color: #e6f3d9;
-	padding-right:1px;
-	padding-top:1px;
-	padding-bottom:1px;
-	padding-left:15px;
-	border-bottom-color:#9c9c9c;
-	border-bottom-width:1px;
-	border-bottom-style:solid;
-	border-left-color:#9c9c9c;
-	border-left-width:1px;
-	border-left-style:solid;
-	border-right-color:#9c9c9c;
-	border-right-width:1px;
-	border-right-style:solid;
-	margin-top:0px;
-	margin-bottom:0px;
-	margin-left:2px;
-	margin-right:2px;
-
-}
-
-#fmStatusBar
-{
-	margin-left:4px;
-	margin-bottom:3px;
-	font-size: 10px; 
-/*	font-family: Verdana, Arial, Helvetica, sans-serif;*/
-	
-
-}
-
-
-#user_info
-{
-padding-left:17px;
-
-}
-
-#admin_info
-{
-	position:relative;
-	text-align:center;
-	margin-right:10px;
-}
-
-#divGenTime
-{
-	bottom:14px;
-	font-size: 9px;
-	color: #ff0000;
-	text-align:center;
-	width:99%;
-}
-
-#divPoweredBy 
-{
-	font-family: Verdana, Arial, Helvetica, sans-serif;
+	background-color: #ddd;
+	padding-top: 2px;
 	font-size: 10px;
-	color: #999999;
-	text-decoration: none;
-	padding: 7px;
-	text-align: center;
-	background-color:white;
-}
-
-.navbar_but
-{
-	background-image: url(../../../../phpgwapi/templates/default/images/back_app_fozi.png) !important; 
-	width: 40px;
-	height: 40px;
-	vertical-align: center;
-	text-align: center;
-	padding-right: 6px;
-	cursor:pointer;
-	cursor:hand;
-	background-repeat:no-repeat;
-}
-
-.navbar_butOver
-{
-	background-image: url(../../../../phpgwapi/templates/default/images/back_app_over_fozi.png) !important;
-	width: 40px;
-	height: 40px;
-	vertical-align: center !important;
-	text-align: center !important;
-	padding-right:6px;
-	cursor:pointer;
-	cursor:hand;
-	background-repeat:no-repeat;
-}
-
-.navbar_butOut
-{
-	background-image: url(../../../../phpgwapi/templates/default/images/back_app_out_fozi.png) !important;
-	width: 40px;
-	height: 40px;
-	vertical-align: center !important;
-	text-align: center !important;
-	padding-right:6px;
-	cursor:pointer;
-	cursor:hand;
-	background-repeat:no-repeat;
-}
-
-.toolbar
-{
-	background-image:url(../../../../phpgwapi/templates/default/images/fundo_topo_fozi.jpg);
-	position:absolute;
-}
-
-.logo_expresso
-{
-	background:url(../../../../phpgwapi/templates/default/images/logo_expresso_fozi.gif) no-repeat;
-	width: 264px;
-	height: 35px;
-}
-
-.content-menu {
-	padding: 0px 0px 0px 0px !important;
-	background: #fff !important;
-}
-
-.menu-degrade {
-          background-image: url(../../../../phpgwapi/templates/default/images/degrade.png) !important;
-          background-repeat: repeat-x;
-}
-
-.image-menu {
-	padding: 0px 0px 0px 0px !important;
-	background: #a0b2cc url(../../../../phpgwapi/templates/default/images/folder_bg_fozi.jpg) no-repeat scroll center bottom !important;
-}
-
-.message_header
-{
-	background-color: #98c17f !important;
-}
-
-.menu
-{
-	background-color:#c2d8b1 !important;
-	border: 1px solid #f4f7fc !important;
-	border-bottom: 1px solid #4a79b1 !important;
-}
-.message_options_active {
-	color: #D00 !important;
-	font-weight: bold !important;
-}
-
-.message_options_inactive {
-	color: #999 !important;
-}
-
-.message_options {
-	color: blue !important;
-	font-weight: bold !important;
-}
-
-.message_options_over {
-	color: #D00 !important;
-	font-weight: bold !important
-}
-
-.table_message{
-	background:#98C17F !important;
-}
-
-
-.tr_msg_read {
-	color: #3f3f3f;
-	background-color: #ffffff;
-	-moz-user-select: none;
-}
-
-.tr_msg_read2 {
-	color: #3f3f3f;
-	background-color: #e6f3d9;
-	-moz-user-select: none;
-}
+	color: #666;
+}
+
+.divSidebox
+{
+	position: relative;
+	width: 147px;
+	border: 1px solid #9c9c9c;
+}
+
+.content-menu
+{
+	padding: 0px 0px 0px 0px;
+	background: #fff;
+}
Index: /branches/2.2/phpgwapi/templates/default/css/metropole.css
===================================================================
--- /branches/2.2/phpgwapi/templates/default/css/metropole.css	(revision 1514)
+++ /branches/2.2/phpgwapi/templates/default/css/metropole.css	(revision 3018)
@@ -80,22 +80,16 @@
 }
 
-/*.tr_msg_read {
-background-color: #B0B0B0 !important;
-color:black !important;
-}
-
+.linha0,
+.linha1,
+.tr_msg_read,
 .tr_msg_read2 {
-background-color: #808080 !important;
-color: #E0E0E0 !important;
-}*/
-
-
-
-.tr_msg_read {
-background-color: white !important;
-}
-
+	color: #3f3f3f;
+	background-color: #ffffff;
+	-moz-user-select: none;
+}
+
+.linha1,
 .tr_msg_read2 {
-background-color: #E0E0E0 !important;
+	background-color: #E0E0E0 !important;
 }
 
@@ -289,4 +283,10 @@
 }
 */
+
+.dsused
+{
+	background-image: url(../images/dsused_black.gif);
+}
+
 #tdSidebox
 {
@@ -486,4 +486,7 @@
 	background-repeat:no-repeat;
 }
+.toolButton {
+	color:#FFF !important;
+}
 
 .toolbar
@@ -514,4 +517,7 @@
 }
 
+table.inboxElements th,
+.table_elements_tr_header,
+.info_tr_header,
 .message_header
 {
@@ -565,2 +571,58 @@
 	border-bottom: 1px solid gray !important;
 }
+
+.conteudo { 
+	font-family: Verdana, Arial, Helvetica, sans-serif; 
+	font-size: 10px; 
+	font-weight: normal; 
+	color: #000033; 
+	padding: 2px; 
+    border-left: 1px solid;
+    border-right: 1px solid;
+    border-bottom: 1px solid;
+    border-color: #4A79B1;
+	width:99.5%; 
+	overflow: none; 
+	-moz-border-radius: 0px 0px 6px 6px; 
+} 
+
+.whiteSpace{ 
+	width: 2px; 
+} 
+.menu
+{
+	text-decoration: none;
+	text-align: center;
+	height: 20px;
+	background-color:#c8d7ea;
+	margin-bottom: 0px;
+	border: 1px solid #f4f7fc;
+	border-bottom: 1px solid #4a79b1;
+	padding:0px 5px 0px 0px;
+	-moz-border-radius: 9px 9px 0px 0px;
+	-moz-user-select: none;
+	cursor: pointer;
+}
+
+.last_menu 
+{ 
+	border-bottom: 1px solid #4a79b1; 
+	-moz-border-radius: 0px 0px 0px 0px; 
+} 
+
+.menu-sel
+{
+	text-decoration: none;
+	text-align: center;
+	font: bold 13px Lucidatypewriter,monospace;
+	color:#FFFFFF;
+	height: 20px;
+	background-color:#7F7F7F;
+	margin-bottom: 0px;
+	border: 1px solid #FFF;
+	border-bottom: 0px;
+	padding:0px 5px 0px 0px;
+	-moz-border-radius: 9px 9px 0px 0px;
+	-moz-user-select: none;
+	cursor: pointer;
+}
Index: /branches/2.2/phpgwapi/templates/default/head.inc.php
===================================================================
--- /branches/2.2/phpgwapi/templates/default/head.inc.php	(revision 890)
+++ /branches/2.2/phpgwapi/templates/default/head.inc.php	(revision 3018)
@@ -33,9 +33,4 @@
 
 	#_debug_array($GLOBALS['phpgw_info']['user']['preferences']['common']);
-	$theme_css = ".".$GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/css/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'].'.css';
-	if(!file_exists($theme_css))
-	{
-		$theme_css = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/css/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'].'.css';
-	}
 
 	//pngfix defaults to yes
@@ -94,5 +89,4 @@
 		'website_title' => $GLOBALS['phpgw_info']['server']['site_title'].$app,
 		'body_tags'     => $bodyheader .' '. $GLOBALS['phpgw']->common->get_body_attribs(),
-		'theme_css'     => $theme_css,
 		'css'           => $GLOBALS['phpgw']->common->get_css(),
 		'java_script'   => $GLOBALS['phpgw']->common->get_java_script(),
Index: /branches/2.2/phpgwapi/templates/default/head.tpl
===================================================================
--- /branches/2.2/phpgwapi/templates/default/head.tpl	(revision 1247)
+++ /branches/2.2/phpgwapi/templates/default/head.tpl	(revision 3018)
@@ -13,5 +13,4 @@
 		<link rel="icon" href="{img_icon}" type="image/x-ico" />
 		<link rel="shortcut icon" href="{img_shortcut}" />
-		<link href="{theme_css}" title="eGroupWareStyle" type="text/css" rel="StyleSheet"/>
 		<META http-equiv="Default-Style" content="eGroupWareStyle">
 		{slider_effects}
Index: /branches/2.2/phpgwapi/templates/default/login_default.php
===================================================================
--- /branches/2.2/phpgwapi/templates/default/login_default.php	(revision 1933)
+++ /branches/2.2/phpgwapi/templates/default/login_default.php	(revision 3018)
@@ -104,5 +104,5 @@
 		unset($sslattributes);
 	}
-
+	session_start(); 
 	if(isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit)
 	{
@@ -406,5 +406,6 @@
 			{
 				$aux_captcha = '<div class="login_label" >
-               <img src="./security/captcha.php" title="'.lang('Security code').'" alt="'.lang('Security code').'" style="width:60;">
+ <input type="hidden" name="' . session_name() .'" value="' . session_id() . '" > 
+ <img src="./security/captcha.php?xsid='.session_id().'" title="'.lang('Security code').'" alt="'.lang('Security code').'" style="width:60;">  
 <br />
                 <input class="input" type="text" maxlength="50" size="20" name="codigo" id="codigo" value="" >
Index: /branches/2.2/expressoAdmin1_2/inc/class.manager.inc.php
===================================================================
--- /branches/2.2/expressoAdmin1_2/inc/class.manager.inc.php	(revision 1913)
+++ /branches/2.2/expressoAdmin1_2/inc/class.manager.inc.php	(revision 3018)
@@ -1,3 +1,3 @@
-<?
+<?php
 	/***********************************************************************************\
 	* Expresso Administração                 										   *
Index: /branches/2.2/expressoAdmin1_2/js/jscode/connector.js
===================================================================
--- /branches/2.2/expressoAdmin1_2/js/jscode/connector.js	(revision 317)
+++ /branches/2.2/expressoAdmin1_2/js/jscode/connector.js	(revision 3018)
@@ -499,5 +499,5 @@
 			 
 		id = url;
-		connector.newRequest(id, url, method, handler, params);
+		admin_connector.newRequest(id, url, method, handler, params);
 	}
 	
@@ -508,9 +508,9 @@
 	//	form: form element (for upload files)	
 	function cExecuteForm(url, form, handler){
-		connector.buildBar();
+		admin_connector.buildBar();
 		isExecuteForm = true;		
 		document.onmouseup = alertBut;
 		
-		connector.showProgressBar();
+		admin_connector.showProgressBar();
 		if(! (divUpload = document.getElementById('divUpload'))) {
 			divUpload		= document.createElement('DIV');		
@@ -554,8 +554,8 @@
 		if(isExecuteForm) {
 	    	if(confirm("There's an action processing. Do you want abort it?")) {
-		    	connector.hideProgressBar();
+		    	admin_connector.hideProgressBar();
 		    	isExecuteForm = false;
-		    	delete connector.requests[id];								
-				connector.requests[id] = null;
+		    	delete admin_connector.requests[id];								
+				admin_connector.requests[id] = null;
 	    		stop();		    		    		
 	    		return;
Index: /branches/2.2/expressoAdmin1_2/js/jscode/users.js
===================================================================
--- /branches/2.2/expressoAdmin1_2/js/jscode/users.js	(revision 1913)
+++ /branches/2.2/expressoAdmin1_2/js/jscode/users.js	(revision 3018)
@@ -139,5 +139,5 @@
 	if (document.forms[0].mailalternateaddress.value != '')
 		attrs_array['mailalternateaddress'] = document.forms[0].mailalternateaddress.value;
-	var attributes = connector.serialize(attrs_array);
+	var attributes = admin_connector.serialize(attrs_array);
 
 	var handler_validate_fields = function(data)
@@ -156,4 +156,6 @@
 			if (type == 'create_user')
 			{
+				// Turn enabled checkbox on create user. 
+                                document.getElementById('changepassword').disabled = false; 
 				cExecuteForm ("$this.user.create", document.forms[0], handler_create);
 			}
@@ -203,5 +205,5 @@
 	attrs_array['first_name'] = first_name;
 	attrs_array['second_name'] = second_name;
-	var attributes = connector.serialize(attrs_array);
+	var attributes = admin_connector.serialize(attrs_array);
 	
 	var handler_generate_login = function(data) {
@@ -539,5 +541,5 @@
 		attrs_array['type'] = 'rename_user';
 		attrs_array['uid'] = new_uid;
-		attributes = connector.serialize(attrs_array);
+		attributes = admin_connector.serialize(attrs_array);
 	
 		cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields);
Index: /branches/2.2/expressoAdmin1_2/templates/default/accounts_form.tpl
===================================================================
--- /branches/2.2/expressoAdmin1_2/templates/default/accounts_form.tpl	(revision 1991)
+++ /branches/2.2/expressoAdmin1_2/templates/default/accounts_form.tpl	(revision 3018)
@@ -98,20 +98,20 @@
 		<tr bgcolor={row_on}>
 			<td colspan="2">{lang_password_expired}:</td>
-			<td><input onchange="javascript:set_changepassword();" type="checkbox" {passwd_expired_checked} {disabled} name="passwd_expired" id="passwd_expired" value="1"</td>
+			<td><input onclick="javascript:set_changepassword();" type="checkbox" {passwd_expired_checked} {disabled} name="passwd_expired" id="passwd_expired" value="1"></td>
 		</tr>
 
 		<tr bgcolor={row_off}>
 			<td colspan="2">{lang_change_password}:</td>
-			<td><input type="checkbox" {changepassword_checked} {disabled} name="changepassword" id="changepassword" value="1"</td>
+			<td><input type="checkbox" {changepassword_checked} {disabled} name="changepassword" id="changepassword" value="1"></td>
 		</tr>
 
 		<tr bgcolor={row_on}>
 			<td colspan="2">{lang_account_active}:</td>
-			<td><input type="checkbox" {phpgwaccountstatus_checked} {disabled} name="phpgwaccountstatus" id="phpgwaccountstatus" value="1"</td>
+			<td><input type="checkbox" {phpgwaccountstatus_checked} {disabled} name="phpgwaccountstatus" id="phpgwaccountstatus" value="1"></td>
 		</tr>
 
 		<tr bgcolor={row_off}>
 			<td colspan="2">{lang_do_not_show_this_account_in_the_contact_center}:</td>
-			<td><input type="checkbox" {phpgwaccountvisible_checked} {disabled} name="phpgwaccountvisible" id="phpgwaccountvisible" value="1"</td>
+			<td><input type="checkbox" {phpgwaccountvisible_checked} {disabled} name="phpgwaccountvisible" id="phpgwaccountvisible" value="1"></td>
 		</tr>		
 		{start_coment_expired}
@@ -158,5 +158,5 @@
 		<tr bgcolor={row_off}>
 			<td>{lang_active_email_account}:</td>
-			<td><input type="checkbox" {accountstatus_checked} {disabled} name="accountstatus" id="accountstatus" value="1"</td>
+			<td><input type="checkbox" {accountstatus_checked} {disabled} name="accountstatus" id="accountstatus" value="1"></td>
 		</tr>
 	
@@ -186,5 +186,5 @@
 		<tr bgcolor={row_off}>
 			<td>{lang_only_forwarding}:</td>
-			<td><input type="checkbox" {deliverymode_checked} {disabled} name="deliverymode" id="deliverymode" value="1"</td>
+			<td><input type="checkbox" {deliverymode_checked} {disabled} name="deliverymode" id="deliverymode" value="1"></td>
 		</tr>
 
@@ -386,4 +386,6 @@
 <script type="text/javascript">
 tab.display(1);
+// Note: The "change_password" field must be disabled and checked when the "passwd_expired" field will be enabled.  
+set_changepassword(); 
 </script>
 
Index: /branches/2.2/admin/inc/class.uiconfig.inc.php
===================================================================
--- /branches/2.2/admin/inc/class.uiconfig.inc.php	(revision 1325)
+++ /branches/2.2/admin/inc/class.uiconfig.inc.php	(revision 3018)
@@ -200,4 +200,5 @@
 			$t->set_var('row_on',    $GLOBALS['phpgw_info']['theme']['row_on']);
 			$t->set_var('row_off',   $GLOBALS['phpgw_info']['theme']['row_off']);
+			$t->set_var('php_upload_limit',str_replace('M','',ini_get('upload_max_filesize')));
 			$t->pparse('out','header');
 
Index: /branches/2.2/contactcenter/inc/class.ui_data.inc.php
===================================================================
--- /branches/2.2/contactcenter/inc/class.ui_data.inc.php	(revision 1690)
+++ /branches/2.2/contactcenter/inc/class.ui_data.inc.php	(revision 3018)
@@ -2072,5 +2072,5 @@
 
 			/* Verify Data and performs insertion/update */
-			foreach($data as $field => &$value)
+			foreach($data as $field => $value)
 			{
 				if ($value == '' or is_null($value))
@@ -2082,4 +2082,6 @@
 				switch($field)
 				{
+					case 'names_ordered':
+						$data[$field] = urldecode($value); 
 					case 'corporate_name':
 					case 'job_title':
@@ -2089,8 +2091,7 @@
 					case 'given_names':
 					case 'family_names':
-					case 'names_ordered':
 					case 'pgp_key':
 					case 'notes':
-						/* Do Nothing. This is just to make sure no invalid field is passed */
+						$data[$field] = urldecode($data[$field]);
 						break;
 
@@ -2167,5 +2168,5 @@
 								if ($value['new_cities'][$type])
 								{
-									$value['new_cities'][$type]['id_state'] = $id_state;
+									$data[$field]['new_cities'][$type]['id_state'] = $id_state; 
 								}
 							}
@@ -2203,9 +2204,7 @@
 			}
 
-			$code = '$id = $this->bo->catalog->';
-
 			if (!is_null($id) and $id !== '')
 			{
-				$code .= $code.'update_single_info($id, $data);';
+				$id = $this->bo->catalog->update_single_info($id, $data); 
 				$result = array(
 					'msg' => lang('Updated Successfully!'),
@@ -2215,5 +2214,5 @@
 			else
 			{
-				$code .= 'add_single_entry($data);';
+				$id = $this->bo->catalog->add_single_entry($data); 
 				$result = array(
 					'msg' => lang('Entry Added Successfully!'),
@@ -2221,6 +2220,4 @@
 				);
 			}
-
-			eval($code);
 
 			if (!($id))
@@ -2371,6 +2368,5 @@
 					case 'notes':
 					case 'photo':
-						$value = urldecode( $value );
-						/* Do Nothing. This is just to make sure no invalid field is passed */
+						$data[$field] = urldecode( $value ); 
 						break;
 
Index: /branches/2.2/logout.php
===================================================================
--- /branches/2.2/logout.php	(revision 2)
+++ /branches/2.2/logout.php	(revision 3018)
@@ -20,5 +20,5 @@
 		'nonavbar'               => True
 	);
-	include('./header.inc.php');
+	include(dirname( __FILE__ ).'/header.inc.php');
 
 	$GLOBALS['sessionid'] = get_var('sessionid',array('GET','COOKIE'));
Index: /branches/2.2/preferences/preferences.php
===================================================================
--- /branches/2.2/preferences/preferences.php	(revision 1933)
+++ /branches/2.2/preferences/preferences.php	(revision 3018)
@@ -487,5 +487,5 @@
 		if (!is_admin() || $error)
 		{
-			$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
+			$GLOBALS['phpgw']->redirect_link('/'.$_GET['appname'].'/'); 
 		}
 		
Index: /branches/2.2/security/captcha.php
===================================================================
--- /branches/2.2/security/captcha.php	(revision 1574)
+++ /branches/2.2/security/captcha.php	(revision 3018)
@@ -111,4 +111,6 @@
   $GLOBALS['captcha'] = new captcha;
   // Guarda o string do captcha na session...
+  session_id($_REQUEST['xsid']); 
+  session_start(); 
   $_SESSION['CAPTCHAString'] = $GLOBALS['captcha'] ->GetCaptchaString();
   // Vai exibir a imagem do captcha...
Index: /branches/2.2/header.session.inc.php
===================================================================
--- /branches/2.2/header.session.inc.php	(revision 1464)
+++ /branches/2.2/header.session.inc.php	(revision 3018)
@@ -1,16 +1,57 @@
 <?php
-	session_id( $_COOKIE[ 'sessionid' ] );
-	session_start( );
+if ( isset( $_COOKIE[ 'sessionid' ] ) ) 
+	session_id( $_COOKIE[ 'sessionid' ] ); 
 
-	$sess = $_SESSION[ 'phpgw_session' ];
-        $connection_id = "{$sess['session_id']}{$sess['session_ip']}".substr($_SERVER[ 'HTTP_USER_AGENT' ],0,199);
+session_start( );
 
+$sess = $_SESSION[ 'phpgw_session' ];
+$invalidSession = false; 
+$user_agent = array(); 
+if (isset($GLOBALS['phpgw']) && !isset($_SESSION['connection_db_info'])){ 
+	$_SESSION['phpgw_info']['admin']['server']['sessions_checkip'] = $GLOBALS['phpgw_info']['server']['sessions_checkip'];
+	if($GLOBALS['phpgw_info']['server']['use_https'] == 1) { 
+		$new_ip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR']."," : ""). $_SERVER['REMOTE_ADDR']; 
+		$GLOBALS['phpgw']->db->query("UPDATE phpgw_access_log SET ip='$new_ip' WHERE account_id <> 0 and lo = 0 and sessionid='{$GLOBALS['sessionid']}'",__LINE__,__FILE__); 
+	} 
+	 $GLOBALS['phpgw']->db->query("select trim(sessionid),".($_SESSION['phpgw_info']['admin']['server']['sessions_checkip'] ? "ip," : "")."browser from phpgw_access_log where account_id <> 0 and lo = 0 and sessionid='{$GLOBALS['sessionid']}' limit 1",__LINE__,__FILE__); 
+	$GLOBALS['phpgw']->db->next_record(); 
+	if($GLOBALS['phpgw']->db->row( )) 
+		$_SESSION['connection_db_info']['user_auth'] = implode("",$GLOBALS['phpgw']->db->row( )); 
+} 
+if($_SESSION['connection_db_info']['user_auth']){ 
+	$invalidSession = true; 
+	$http_user_agent = substr($_SERVER[ 'HTTP_USER_AGENT' ],0,199); 
+	$user_ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? array($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_X_FORWARDED_FOR']) : array($_SERVER['REMOTE_ADDR']); 
+	$user_agent[] = ($_SESSION['phpgw_info']['admin']['server']['sessions_checkip'] ? "{$sess['session_id']}{$user_ip[0]}" : "{$sess['session_id']}").$http_user_agent;
+	if(count($user_ip) == 2) { 
+		$user_agent[] = "{$sess['session_id']}{$user_ip[1]}".$http_user_agent; 
+		$user_agent[] = $sess['session_id'].implode(",",array_reverse($user_ip)).$http_user_agent; 
+	} 
+	$pconnection_id = $_SESSION['connection_db_info']['user_auth']; 
+	if(array_search($pconnection_id, $user_agent)  !== FALSE) { 
+		$invalidSession = false; 
+	} 
+} 
+if (empty($_SESSION['phpgw_session']['session_id']) || $invalidSession) 
+{
+	if($_SESSION['connection_db_info']['user_auth'] && !strstr($_SERVER['SCRIPT_URL'],"/controller.php")) {
+		error_log( '[ INVALID SESSION ] >>>>' .$_SESSION['connection_db_info']['user_auth'].'<<<< - >>>>' . implode("",$user_agent), 0 ); 
+		$GLOBALS['phpgw']->session->phpgw_setcookie('sessionid'); 
+		$GLOBALS['phpgw']->redirect($GLOBALS['phpgw_info']['server']['webserver_url'].'/login.php?cd=10'); 
+	} 
 
-	if ($_SESSION['connection_db_info']['user_auth'] && implode('',$_SESSION['connection_db_info']['user_auth']) !== $connection_id)
-	{
-		setcookie("PHPSESSID","",0);
-		setcookie ("sessionid","",0);
-		echo lang("An important error has occured with your login, please contact your system administrator");	
-		exit;
-	}
+	setcookie(session_name(),"",0); // Removing session cookie. 
+	unset($_SESSION);                               // Removing session values. 
+	// From ExpressoAjax response "nosession" 
+	if(strstr($_SERVER['SCRIPT_URL'],"/controller.php")){ 
+		echo serialize(array("nosession" => true)); 
+		exit; 
+	} 
+} 
+else{ 
+	// From ExpressoAjax update session_dla (datetime last access).  
+	if(strstr($_SERVER['SCRIPT_URL'],"/controller.php")) 
+		$_SESSION['phpgw_session']['session_dla'] = time(); 
+
+}
 ?>
Index: /branches/2.2/calendar/inc/class.boicalendar.inc.php
===================================================================
--- /branches/2.2/calendar/inc/class.boicalendar.inc.php	(revision 678)
+++ /branches/2.2/calendar/inc/class.boicalendar.inc.php	(revision 3018)
@@ -1275,5 +1275,6 @@
 			if($this->line < count($ical_text))
 			{
-				$str = str_replace("\r\n",'',$ical_text[$this->line]);
+				$str = str_replace(array("\r\n","\r","\n"), '', $ical_text[$this->line]);
+
 				$this->line = $this->line + 1;
 				while(ereg("^[[:space:]]",$ical_text[$this->line]))
@@ -1282,4 +1283,6 @@
 					$this->line = $this->line + 1;
 				}
+				// Corrige a codificacao dos caracteres
+				$str = utf8_decode ( trim ($str) );
 				$this->debug("LINE : ".$str);
 				return $str;
@@ -1405,4 +1408,5 @@
 		function parse_parameters(&$event,$majortype,$value)
 		{
+			$this->debug ('value: '.$value);
 			if(!ereg('[\=\;]',$value))
 			{
@@ -1451,4 +1455,6 @@
 				}
 			}
+
+			$this->debug('parse_parameters array return_value: '._debug_array($return_value,False));
 
 			for($i=0;$i<count($return_value);$i++)
@@ -1528,5 +1534,5 @@
 			if($this->property[$majortype][$mode]['multiples'])
 			{
-				$this->debug(_debug_array($var,False));
+				$this->debug('parse_value var array: '._debug_array($var,False));
 				$event[$majortype][] = $var;
 			}
@@ -1540,10 +1546,13 @@
 					$t_var = $var[$majortype];
 					unset($var[$majortype]);
-					reset($t_var);
-					while(list($key,$val) = each($t_var))
-					{
-						$var[$key] = $val;
-					}
-					$this->debug($majortype.' : '._debug_array($var,False));
+					if ( $t_var )
+					{
+						reset($t_var);
+						while(list($key,$val) = each($t_var))
+						{
+							$var[$key] = $val;
+						}
+						$this->debug($majortype.' : '._debug_array($var,False));
+					}
 				}
 				$this->set_var($event,$majortype,$var);
@@ -2260,7 +2269,5 @@
 		function switch_partstat($var)
 		{
-//			$this->debug_str = True;
 			$this->debug('PARTSTAT = '.$var);
-//			$this->debug_str = False;
 			if(is_string($var))
 			{
@@ -2567,4 +2574,5 @@
 
 				ereg($property_regexp,$text,$temp);
+				$this->debug ('Majortype dump: '._debug_array($temp, false) );
 				$majortype = str_replace('-','_',strtolower($temp[1]));
 				$value = chop($temp[2]);
@@ -2767,5 +2775,5 @@
 				elseif($state == 'optional' || $state == 'required')
 				{
-					$this->debug('Mode : '.$mode.' Majortype : '.$majortype);
+					$this->debug('Mode : '.$mode.' Majortype : '.$majortype . ' Type : '.$type);
 					if($do_to_text)
 					{
@@ -3016,4 +3024,5 @@
 					break;
 			}
+			$this->debug ('ical parse result: ' . _debug_array ($ical, false));
 			$c_events = count($ical['event']);
 			for($i=0;$i<$c_events;$i++)
@@ -3056,4 +3065,24 @@
 						$so_event->set_ex_participants($ical['event'][$i]['ex_participants']['value']);
 					}
+					// Compatibilidade com agendamentos vindos do outlook/exchange
+					if ( isset ($ical['event'][$i]['attendee']) )
+					{
+						$c_attendees = count($ical['event'][$i]['attendee']);
+						$all_attendees = '';
+						for ( $a=0; $a < $c_attendees; $a++ )
+						{
+							$cname = '"'. $ical['event'][$i]['attendee'][$a]['cn'] .'"';
+							$email = $ical['event'][$i]['attendee'][$a]['mailto']['user'];
+							if ( $email )
+								$email = '<'. $email .'@'. $ical['event'][$i]['attendee'][$a]['mailto']['host'] .'>';
+							else
+								$email = '';
+							
+							$all_attendees .= $cname . $email .', ';
+						}
+						$this->debug ('All attendees: ' . $all_attendees);
+						$so_event->set_ex_participants($all_attendees);
+					}
+
 					if($ical['event'][$i]['location']['value'])
 					{
@@ -3296,5 +3325,5 @@
 					else
 					{
-//owner
+						$so_event->add_attribute('participants','A',(int)$GLOBALS['phpgw_info']['user']['account_id']);
 					}
 
@@ -3585,5 +3614,8 @@
 			if($this->debug_str)
 			{
-				echo $str."<br>\n";
+				//echo $str."<br>\n";
+				$log = fopen('/tmp/calendar.log', 'a') or die("nao foi possivel abrir o arquivo /tmp/calendar.log");
+				fwrite($log, $str . "\n");
+				fclose($log);
 			}
 		}
Index: /branches/2.2/calendar/inc/class.socalendar_sql.inc.php
===================================================================
--- /branches/2.2/calendar/inc/class.socalendar_sql.inc.php	(revision 1949)
+++ /branches/2.2/calendar/inc/class.socalendar_sql.inc.php	(revision 3018)
@@ -309,4 +309,5 @@
 							);
 
+					$result = array(); 
 					do
 					{
@@ -317,5 +318,5 @@
 						if($quociente == 1)
 						{
-							$result[] .= $dias_semana[$divisor];
+							$result[] = $dias_semana[$divisor];
 
 							$divisor = $divisor / 2;
@@ -335,5 +336,5 @@
 							{
 
-								$result[] .= $dias_semana[$divisor];
+								$result[] = $dias_semana[$divisor];
 
 								$divisor = $divisor / 2;
Index: /branches/2.2/expressoMail1_2/index.php
===================================================================
--- /branches/2.2/expressoMail1_2/index.php	(revision 1735)
+++ /branches/2.2/expressoMail1_2/index.php	(revision 3018)
@@ -62,4 +62,5 @@
 	
 	$preferences = $GLOBALS['phpgw']->preferences->read();
+	$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['enable_local_messages']; 
 	$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail'];
 	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_enabled'] = $voip_enabled;
@@ -163,6 +164,7 @@
 	include("inc/load_lang.php"); 
 
-	// INCLUDE these JS Files: 
-	echo "<script src='js/gears_init.js'></script>";
+	// INCLUDE these JS Files:
+	if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages']) 
+		echo "<script src='js/gears_init.js'></script>";
 	echo $obj -> getFilesJs("js/abas.js," .
 							"js/doiMenuData.js," .
Index: /branches/2.2/expressoMail1_2/templates/classic/index.tpl
===================================================================
--- /branches/2.2/expressoMail1_2/templates/classic/index.tpl	(revision 1151)
+++ /branches/2.2/expressoMail1_2/templates/classic/index.tpl	(revision 3018)
@@ -27,6 +27,5 @@
 					</tbody>
 				</table>
-				<div style="height:4px"></div>
-				<div id="search_div" align="center" style="white-space:nowrap">
+				<div id="search_div" align="center" style="padding-top:4px;white-space:nowrap"> 
 					<input type="text" id="em_message_search" size="16" maxlength="22" onfocus="javascript:onFocusQuickSearchEmail(this); return false;"/>
 					<a class='' onMouseOut="window.status='';return true;" title='{lang_Open_Search_Window}' onMouseOver="window.status='{lang_Open_Search_Window}';return true;" href="javascript:void(0);"  onClick="javascript:search_emails(Element('em_message_search').value)">
@@ -71,5 +70,5 @@
 						<tbody id="border_tbody">
 							<tr id="border_tr">
-								<td nowrap class="menu" onClick="alternate_border(0);"  id="border_id_0">&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">0</span> / <span id="tot_m">0</span>]</font>
+								<td nowrap class="menu" onClick="alternate_border(0);resizeWindow();"  id="border_id_0">&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">0</span> / <span id="tot_m">0</span>]</font>
 								</td>
 								<td nowrap id="border_blank" class="last_menu" width="100%">&nbsp;</td>								
Index: /branches/2.2/expressoMail1_2/templates/classic/main.css
===================================================================
--- /branches/2.2/expressoMail1_2/templates/classic/main.css	(revision 1570)
+++ /branches/2.2/expressoMail1_2/templates/classic/main.css	(revision 3018)
@@ -115,63 +115,4 @@
 }
 
-.menu-sel
-{
-    text-decoration: none;
-    text-align: center;
-    font: bold 13px Lucidatypewriter,monospace;
-   	color:#0000FF;
-    height: 20px;
-	width:220px;
-    background-color: #F7F7F7;
-    margin-bottom: 0px;
-    border-left: 1px solid #000000;
-    border-top: 1px solid #000000;
-    border-right: 1px solid #000000;
-    padding:0px 5px 0px 0px;
-    -moz-border-radius: 9px 9px 0px 0px;
-    -moz-user-select: none;
-    cursor: pointer;	
-}
-.menu
-{
-    text-decoration: none;
-    text-align: center;
-    font: bold 13px Lucidatypewriter,monospace;
-    color: #505050;
-    height: 20px;    
-	width:220px;
-    background-color:#E5E5E5;
-    margin-bottom: 0px;
-    border-left: 1px solid #c0c0c0;
-    border-top: 1px solid #c0c0c0;
-    border-right: 1px solid #c0c0c0;       
-    border-bottom: 1px solid #000000;
-	padding:0px 5px 0px 0px;
-    -moz-border-radius: 9px 9px 0px 0px;
-    -moz-user-select: none;
-    cursor: pointer;
-}
-
-.last_menu
-{
-	border-bottom: 1px solid #000000;
-	-moz-border-radius: 0px 0px 0px 0px;
-}
-
-.conteudo {
-    font-family: Verdana, Arial, Helvetica, sans-serif;
-    font-size: 10px;
-    font-weight: normal;
-    color: #000033;
-	padding: 1px;
-    border-color: gray gray gray gray;
-   
-	border-right: 1px solid #000000;
-	border-left: 1px solid #000000;
-	border-bottom: 1px solid #000000;
-	width:99.5%;
-    -moz-border-radius: 0px 0px 6px 6px;
-}
-
 .table_message{
 	background-color: #CCCCCC;
@@ -374,9 +315,9 @@
 }
 
+.message_options_active,
+.message_options_over,
 .message_options {
 	cursor: pointer;
-	color: blue;
 	white-space: nowrap;
-	/*padding:0 1.8;*/
 }
 .message_options_trash,
@@ -392,14 +333,5 @@
 }
 
-.message_options_active {
-	white-space: nowrap;	
-	color: blue;
-	cursor: pointer;
-}
-
 .message_options_over {
-	cursor: pointer;
-	color: blue;
-	white-space: nowrap;
 	font-weight: bold;
 	text-decoration: underline;
@@ -478,5 +410,4 @@
 	font-weight: bold !important;
 	font-size: 10px !important;
-	color: #666 !important;
 	text-decoration: none !important;
 	font-family: sans-serif !important;
Index: /branches/2.2/expressoMail1_2/templates/default/config.tpl
===================================================================
--- /branches/2.2/expressoMail1_2/templates/default/config.tpl	(revision 1466)
+++ /branches/2.2/expressoMail1_2/templates/default/config.tpl	(revision 3018)
@@ -1,4 +1,20 @@
 <!-- BEGIN header -->
-<form method="POST" action="{action_url}">
+<script type="text/javascript"> 
+function valida(pForm) 
+{ 
+        if((!document.getElementsByName('newsettings[expressoMail_Max_attachment_size]').item(0).value) || (!pForm.php_upload_limit.value)) 
+                return ExpressoLivre.form(pForm); 
+ 
+        if (parseInt(document.getElementsByName('newsettings[expressoMail_Max_attachment_size]').item(0).value) > parseInt(pForm.php_upload_limit.value)) 
+        { 
+                alert(pForm.valida_alert.value); 
+                return false; 
+        } 
+        else 
+                return ExpressoLivre.form(pForm); 
+} 
+</script> 
+<form method="POST" action="{action_url}" onsubmit="return valida( this );"> 
+<input type="hidden" name="php_upload_limit" value="{php_upload_limit}" /> 
 <table border="0" align="center">
    <tr bgcolor="{th_bg}">
@@ -75,5 +91,6 @@
     <td>{lang_Max_attachment_size}</td> 	 	 
     <td> 	 	 
-    <input size="1" name="newsettings[expressoMail_Max_attachment_size]" value="{value_expressoMail_Max_attachment_size}">&nbsp;Mb
+    <input size="1" name="newsettings[expressoMail_Max_attachment_size]" value="{value_expressoMail_Max_attachment_size}">&nbsp;Mb<span style='position:relative; left:20px;'>Max: {php_upload_limit}Mb.</span> 
+    <input type="hidden" name="valida_alert" value="{lang_Value_exceeds_the_PHP_upload_limit_for_this_server}" /> 
     </td>
     </tr>
Index: /branches/2.2/expressoMail1_2/templates/default/index.tpl
===================================================================
--- /branches/2.2/expressoMail1_2/templates/default/index.tpl	(revision 1588)
+++ /branches/2.2/expressoMail1_2/templates/default/index.tpl	(revision 3018)
@@ -11,10 +11,10 @@
 <tbody>
 <tr>
-	<td id="folderscol" width="162px" height="100%" valign="top">
-		<table id="folders_tbl" width="162px" border="0" cellspacing="0" cellpadding="0" border="0">
+	<td id="folderscol" width="170px" height="100%" valign="top"> 
+                <table id="folders_tbl" width="170px" border="0" cellspacing="0" cellpadding="0"> 
 		<tbody>
 		<tr>
 			<td class='content-menu'>
-				<table border="0" cellspacing="0" cellpadding="0" border="0" style="width:100%">
+				<table border="0" cellspacing="0" cellpadding="0" style="width:100%"> 
 					<tbody>
 						<tr>
@@ -59,5 +59,5 @@
 		<tr>
 			<td class="image-menu" valign="top" style="padding:0px">
-				<div id="content_folders" class="menu-degrade" style="height:100%;width:170px;overflow:auto"></div>
+				<div id="content_folders" class="menu-degrade" style="width:170px;height:100%;overflow:auto"></div> 
 			</td>
 		</tr>
@@ -97,5 +97,5 @@
 				<tbody id="border_tbody">
 					<tr id="border_tr">
-						<td nowrap class="menu" onClick="alternate_border(0);"  id="border_id_0">
+						<td nowrap class="menu" onClick="alternate_border(0);resizeWindow();"  id="border_id_0">
 							&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">[
 							<span id="new_m">0</span> / 
Index: /branches/2.2/expressoMail1_2/inc/class.db_functions.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.db_functions.inc.php	(revision 1992)
+++ /branches/2.2/expressoMail1_2/inc/class.db_functions.inc.php	(revision 3018)
@@ -1,6 +1,17 @@
 <?php
-define('PHPGW_INCLUDE_ROOT','../');	
-define('PHPGW_API_INC','../phpgwapi/inc');	
-include_once(PHPGW_API_INC.'/class.db.inc.php');
+if(!isset($_SESSION['phpgw_info']['expressomail']['server']['db_name'])) { 
+	include_once('../header.inc.php'); 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];  
+	$_SESSION['phpgw_info']['expressomail']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host']; 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port']; 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user']; 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass']; 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type']; 
+} 
+else{ 
+	define('PHPGW_INCLUDE_ROOT','../');      
+	define('PHPGW_API_INC','../phpgwapi/inc');       
+	include_once(PHPGW_API_INC.'/class.db.inc.php'); 
+} 
 include_once('class.dynamic_contacts.inc.php');
 	
@@ -214,4 +225,6 @@
 		if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] &&
 			$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) {
+			// Free others requests 
+                        session_write_close(); 
 			$dynamic_contact = new dynamic_contacts();
 			$dynamic = $dynamic_contact->dynamic_contact_toString();
@@ -353,4 +366,6 @@
 				$calendar = $fileContent;
 		}
+		// It's necessary to access calendar method. 
+		include_once(PHPGW_INCLUDE_ROOT.'/header.inc.php'); 
 			
 		$uiicalendar = CreateObject("calendar.uiicalendar");
Index: /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 1969)
+++ /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3018)
@@ -77,4 +77,6 @@
 	function get_range_msgs2($params)
 	{
+		// Free others requests 
+                session_write_close(); 
 		$folder = $params['folder'];
 		$msg_range_begin = $params['msg_range_begin'];
@@ -335,8 +337,14 @@
 			$head1 = explode(":",$head);
 			if ( (strtoupper($head1[0]) == "TO") ||
-					(strtoupper($head1[0]) == "FROM") ||
-					(strtoupper($head1[0]) == "SUBJECT") ||
-					(strtoupper($head1[0]) == "DATE") )
-				$header .= $head."\r\n";
+				(strtoupper($head1[0]) == "FROM") ||
+				(strtoupper($head1[0]) == "SUBJECT") ||
+				(strtoupper($head1[0]) == "DATE") || 
+				(strtoupper($head1[0]) == "CONTENT-TYPE")) { 
+
+					if(strtoupper($head1[0]) == "CONTENT-TYPE"){ 
+						$head = str_replace("multipart/mixed","text/html",$head);                        
+					} 
+					$header .= $head."\n"; 
+				} 
 		}
 
@@ -474,6 +482,6 @@
 		$body = $return_get_body['body'];
 		//Remoção de tags <span></span> para correção de erro no firefox
-		$body = mb_ereg_replace("<span><span>","",$body);
-		$body = mb_ereg_replace("</span></span>","",$body);
+		$body = mb_eregi_replace("<span><span>","",$body);
+		$body = mb_eregi_replace("</span></span>","",$body);
 
 		if($return_get_body['body']=='isCripted'){
@@ -492,9 +500,10 @@
 		}
 
-		$pattern = '/^[ \t]*Disposition-Notification-To(^:)*:(.+)*@(.+)*$/isUm';
+		$pattern = '/^[ \t]*Disposition-Notification-To:[ ]*<?[[:alnum:]\._-]+@[[:alnum:]_-]+[\.[:alnum:]]+>?/sm';
 		if (preg_match($pattern, $header_, $fields))
 		{
-			preg_match('/[[:alnum:]\._\-]+@[[:alnum:]_\-\.]+/',$fields[0], $matches);
-			$return['DispositionNotificationTo'] = "<".$matches[0].">";
+			if(preg_match('/[[:alnum:]\._\-]+@[[:alnum:]_\-\.]+/',$fields[0], $matches)){ 
+				$return['DispositionNotificationTo'] = "<".$matches[0].">"; 
+			} 
 		}
 
@@ -789,25 +798,40 @@
 		if(!$msg->structure[$msg_number]->parts) //Simple message, only 1 piece
 		{
-            if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){
-                $return['body']='isCripted';
-                return $return;
-            }
+			if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){
+				$return['body']='isCripted';
+				return $return;
+			}
 
 			$attachment = array(); //No attachments
 
-            if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){
-					$return['body']='isCripted';
-					return $return;
-			}
-
-			$content = '';
-			if (strtolower($msg->structure[$msg_number]->subtype) == "plain")
-			{
-				$content .= '<span style="font-family: monospace">' . nl2br($this->decodeBody((imap_body($this->mbox, $msg_number, FT_UID)), $msg->encoding[$msg_number][0], $msg->charset[$msg_number][0])) . '</span>';
-			}
-			else if (strtolower($msg->structure[$msg_number]->subtype) == "html")
-			{
-				$content .= $this->decodeBody(imap_body($this->mbox, $msg_number, FT_UID), $msg->encoding[$msg_number][0], $msg->charset[$msg_number][0]);
-			}
+			if(strtolower($msg->structure[$msg_number]->subtype) == 'x-pkcs7-mime'){
+				$return['body']='isCripted';
+				return $return;
+			}
+
+			$content = ''; 
+			// If simple message is subtype 'html' or 'plain', then get content body. 
+			if(strtolower($msg->structure[$msg_number]->subtype) == "html" ||  
+				strtolower( $msg -> structure[ $msg_number ] -> subtype ) == 'plain'){ 
+
+					$content = $this->decodeBody( 
+						imap_body( $this -> mbox, $msg_number, FT_UID ), 
+						$msg -> encoding[ $msg_number ][ 0 ], 
+						$msg -> charset[ $msg_number ][ 0 ] 
+					); 
+
+					if ( strtolower( $msg -> structure[ $msg_number ] -> subtype ) == 'plain' ) 
+					{ 
+						$content = str_replace( array( '<', '>' ), array( ' #$<$# ', ' #$>$# ' ), $content ); 
+						$content = htmlentities( $content ); 
+						$content = $this -> replace_links( $content ); 
+						$content = str_replace( array( ' #$&lt;$# ', ' #$&gt;$# ' ), array( '&lt;', '&gt;' ), $content ); 
+						$content = '<pre style="white-space:pre;word-wrap: break-word;white-space:pre-wrap;font-family: monospace;font-size:12px">' . $content . '</pre>'; 
+
+						$return[ 'body' ] = $content; 
+
+						return $return; 
+					} 
+				}
 		}
 		else
@@ -836,13 +860,18 @@
 
 				$file_type = strtolower($msg->file_type[$msg_number][$values]);
-				if($file_type == "message/rfc822")
-					$has_multipart = false;
-
-				if($file_type == "multipart/alternative")
-					$has_multipart = false;
+				if($file_type == "message/rfc822" || $file_type == "multipart/alternative") 
+				{ 
+					// Show only 'text/html' part, when message/rfc822 format contains 'text/plain' alternative part. 
+					if(array_key_exists($values+1, $msg->file_type[$msg_number]) && 
+						strtolower($msg->file_type[$msg_number][$values+1]) == 'text/plain' && 
+						array_key_exists($values+2, $msg->file_type[$msg_number]) && 
+						strtolower($msg->file_type[$msg_number][$values+2]) == 'text/html') { 
+							$has_multipart = false; 
+						} 
+				} 	
 
 				if(($file_type == "text/plain"
 					|| $file_type == "text/html")
-					&& $file_type != 'attachment')
+						&& $file_type != 'attachment')
 				{
 					if($file_type == "text/plain" && !$show_only_html && $has_multipart)
@@ -850,5 +879,6 @@
 						// if TXT file size > 100kb, then it will not expand.
 						if(!($file_type == "text/plain" && $msg->fsize[$msg_number][$values] > 102400)) {
-							$content .= nl2br(htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])));
+							 $content .= htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])); 
+	                                                 $content = '<pre style="white-space:pre;word-wrap: break-word;white-space:pre-wrap;font-family: monospace;font-size:12px">' . $content . '</pre>';    
 						}
 					}
@@ -860,8 +890,8 @@
 					}
 				}
-				else if($file_type == "message/delivery-status"){
+				 else if($file_type == "message/delivery-status" || $file_type == "message/feedback-report"){ 
 					$content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
-					$content .= nl2br($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]));
-
+					 $content .= $this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]); 
+                                        $content = '<pre style="white-space:pre;word-wrap: break-word;white-space:pre-wrap;font-family: monospace;font-size:12px">' . $content . '</pre>'; 
 				}
 				else if($file_type == "message/rfc822" || $file_type == "text/rfc822-headers"){
@@ -870,47 +900,65 @@
 					$att = new imap_attachment();
 					$attachments =  $att -> get_attachment_info($this->mbox,$msg_number);
-					if($attachments['number_attachments'] > 0) {
-						foreach($attachments ['attachment'] as $index => $attachment)
-						{
-							if ( in_array( strtolower( $attachment[ 'type' ] ), array( 'delivery-status', 'rfc822', 'rfc822-headers', 'plain' ) ) )
-							{
-								$obj = imap_rfc822_parse_headers( imap_fetchbody( $this -> mbox, $msg_number, $msg_part, FT_UID ), $msg -> encoding[ $msg_number ][ $values ] );
-
-								$content .= '<hr align="left" width="95%" style="border:1px solid #DCDCDC">';
-								$content .= '<br><table  style="margin:2px;border:1px solid black;background:#EAEAEA">';
-
-								$content .= '<tr><td><b>' . $this->functions->getLang("Subject")
-									. ':</b></td><td>' .$this->decode_string($obj->subject) . '</td></tr>';
-
-								$content .= '<tr><td><b>' . $this -> functions -> getLang( 'From' ) . ':</b></td><td>'
-									. $this -> replace_links( $this -> decode_string( $obj -> from[ 0 ] -> mailbox . '@' . $obj -> from[ 0 ] -> host) )
-									. '</td></tr>';
-
-								$content .= '<tr><td><b>' . $this->functions->getLang("Date") . ':</b></td><td>' . $obj->date . '</td></tr>';
-
-								$content .= '<tr><td><b>' . $this -> functions -> getLang( 'TO' ) . ':</b></td><td>'
-									. $this -> replace_links( $this -> decode_string( $obj -> to[ 0 ] -> mailbox . '@' . $obj -> to[ 0 ] -> host ) )
-									. '</td></tr>';
-
-								if ( $obj->cc )
-									$content .= '<tr><td><b>' . $this -> functions -> getLang( 'CC' ) . ':</b></td><td>'
-										. $this -> replace_links( $this -> decode_string( $obj -> cc[ 0 ] -> mailbox . '@' . $obj -> cc[ 0 ] -> host ) )
-										. '</td></tr>';
-
-								$content .= '</table><br>';
-
-								$content .= $this->decodeBody(
-									imap_fetchbody(
-										$this->mbox,
-										$msg_number,
-										( $attachment['part_in_msg'] + (
-											( strtolower( $attachment[ 'type' ] ) == 'delivery-status' ) ? 0 : 1 )
-										) . ".1",
-										FT_UID
-									),
-									$msg->encoding[ $msg_number ][ $values ],
-									$msg->charset[ $msg_number ][ $values ]
-								);
-								break;
+					if($attachments['number_attachments'] > 0) { 
+						foreach($attachments ['attachment'] as $index => $attachment) 
+						{ 
+							if ( in_array( strtolower( $attachment[ 'type' ] ), array( 'delivery-status', 'rfc822', 'rfc822-headers', 'plain' ) ) ) 
+							{ 
+								$obj = imap_rfc822_parse_headers( imap_fetchbody( $this -> mbox, $msg_number, $msg_part, FT_UID ), $msg -> encoding[ $msg_number ][ $values ] ); 
+
+								$content .= '<hr align="left" width="95%" style="border:1px solid #DCDCDC">'; 
+								$content .= '<br><table  style="margin:2px;border:1px solid black;background:#EAEAEA">'; 
+
+								$content .= '<tr><td><b>' . $this->functions->getLang("Subject") 
+									. ':</b></td><td>' .$this->decode_string($obj->subject) . '</td></tr>'; 
+
+								$content .= '<tr><td><b>' . $this -> functions -> getLang( 'From' ) . ':</b></td><td>' 
+									. $this -> replace_links( $this -> decode_string( $obj -> from[ 0 ] -> mailbox . '@' . $obj -> from[ 0 ] -> host) ) 
+									. '</td></tr>'; 
+
+								$content .= '<tr><td><b>' . $this->functions->getLang("Date") . ':</b></td><td>' . $obj->date . '</td></tr>'; 
+
+								$content .= '<tr><td><b>' . $this -> functions -> getLang( 'TO' ) . ':</b></td><td>' 
+									. $this -> replace_links( $this -> decode_string( $obj -> to[ 0 ] -> mailbox . '@' . $obj -> to[ 0 ] -> host ) ) 
+									. '</td></tr>'; 
+
+								if ( $obj->cc ) 
+									$content .= '<tr><td><b>' . $this -> functions -> getLang( 'CC' ) . ':</b></td><td>' 
+										. $this -> replace_links( $this -> decode_string( $obj -> cc[ 0 ] -> mailbox . '@' . $obj -> cc[ 0 ] -> host ) ) 
+										. '</td></tr>'; 
+
+								$content .= '</table><br>'; 
+
+
+								$id = ( ( strtolower( $attachment[ 'type' ] ) == 'delivery-status' ) ? false : true ); 
+								if ( strtolower( $msg->structure[$msg_number]->parts[1]->parts[0]->subtype ) == 'plain' ) 
+								{ 
+									$id = !$id; 
+									if ( $msg->structure[$msg_number]->parts[1]->parts[0]->encoding == 4 ) 
+										$msg->encoding[ $msg_number ][ $values ] = 'quoted-printable'; 
+								} 
+
+								$body = $this->decodeBody( 
+									imap_fetchbody( 
+										$this->mbox, 
+										$msg_number, 
+										( $attachment['part_in_msg'] + ( ( int ) $id ) ) . ".1", 
+										FT_UID 
+									), 
+									$msg->encoding[ $msg_number ][ $values ], 
+									$msg->charset[ $msg_number ][ $values ] 
+								); 
+
+								if ( strtolower( $msg->structure[$msg_number]->parts[1]->parts[0]->subtype ) == 'plain' ) 
+								{ 
+									$body = str_replace( array( '<', '>' ), array( ' #$<$# ', ' #$>$# ' ), $body ); 
+									$body = htmlentities( $body ); 
+									$body = $this -> replace_links( $body ); 
+									$body = str_replace( array( ' #$&lt;$# ', ' #$&gt;$# ' ), array( '&lt;', '&gt;' ), $body ); 
+									$body = '<pre style="white-space:pre;word-wrap: break-word;white-space:pre-wrap;font-family: monospace;font-size:12px">' . $body . '</pre>'; 
+								} 
+
+								$content .= $body; 
+								break; 
 							}
 						}
@@ -1151,32 +1199,68 @@
 	function replace_links( $body )
 	{
-  		$matches = array( );
-		// Verify exception.
-		@preg_match( "/<a href=\"notes:\/\/\//", $body, $matches );
-
-		// If there is no exception, then open the link in new window.
-		if ( count( $matches ) )
-			return $body;
-
-		// All links should be moderated and they should only have the attribute 'target="blank"'.
-		$pattern = '/<a[^>]+href="([^>"]+)"[^>]*>(.*)<\/a>/im';
-		$replacement = '<a href="$1" target="_blank">$2</a>';
+  		// Domains and IPs addresses found in the text and which is not a link yet should be replaced by one. 
+		// See more informations in www.iana.org 
+		$octets = array( 
+			'first' => '(2[0-3][0-9]|1[0-9]{2}|[1-9][0-9]?)', 
+			'middle' => '(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})', 
+			'last' => '(25[0-4]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)' 
+		); 
+
+		$ip = "\b{$octets[ 'first' ]}\.({$octets[ 'middle' ]}\.){2}{$octets[ 'last' ]}\b"; 
+
+		$top_level_domains = '(\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|as|asia|at|au|aw|ax|az|' 
+			. 'ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bl|bm|bn|bo|br|bs|bt|bv|bw|by|bz|' 
+			. 'ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|' 
+			. 'de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|' 
+			. 'ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|' 
+			. 'hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|' 
+			. 'ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|' 
+			. 'ma|mc|md|me|mf|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|' 
+			. 'mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|' 
+			. 'pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|' 
+			. 'sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|' 
+			. 'tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|' 
+			. 'ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))+\b'; 
+
+		$path = '(?>\/[\w\d\/\.\'\(\)\-\+~?!&#@$%|:;,*=_]+)?'; 
+		$port = '(?>:\d{2,5})?'; 
+		$domain = '(?>[\w\d_\-]+)'; 
+		$subdomain = "(?>{$domain}\.)*"; 
+		$protocol = '(?>(http|ftp)(s)?:\/\/)?'; 
+		$url = "(?>{$protocol}((?>{$subdomain}{$domain}{$top_level_domains}|{$ip}){$port}{$path}))"; 
+
+		$pattern = "/(<\w[^>]+|[\/\"'@=])?{$url}/";
+		ini_set( 'pcre.backtrack_limit', 300000 ); 
+
+		/* 
+		// PHP 5.3 
+		$replace = function( $matches ) 
+		{ 
+			if ( $matches[ 1 ] ) 
+				return $matches[ 0 ]; 
+
+			$url = ( $matches[ 2 ] ) ? $matches[ 2 ] : 'http'; 
+			$url .= "{$matches[ 3 ]}://{$matches[ 4 ]}"; 
+			return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>"; 
+		}; 
+		$body = preg_replace_callback( $pattern, $replace, $body ); 
+		 */ 
+
+		// PHP 5.2.x - Remover assim que possível 
+		$body = preg_replace_callback( $pattern, 
+			create_function( 
+				'$matches', 
+				'if ( $matches[ 1 ] ) return $matches[ 0 ];' 
+				. '$url = ( $matches[ 2 ] ) ? $matches[ 2 ] : "http";'
+				. '$url .= "{$matches[ 3 ]}://{$matches[ 4 ]}";'
+				. 'return "<a href=\"{$url}\" target=\"_blank\">{$matches[ 4 ]}</a>";'
+			), $body
+		);
+		ini_set( 'pcre.backtrack_limit', 100000 ); 
+		// E-mail address in the text should create a new e-mail on ExpressoMail
+		$pattern = '/( |<|&lt;|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|&gt;|<)/im'; 
+		$replacement = '$1<a href="mailto:$2">$2</a>$3';
 		$body = preg_replace( $pattern, $replacement, $body );
 
-		// Url found in the text and which is not a link yet should be replaced by one.
-		$pattern = '/(^|\w>|[ \(\[])((http(s)?:\/\/)?([\w\d_\-@]{2,}(\.[\w\d~?\/_=&#;\-:@$]+)+))/im';
-		$replacement = '$1<a href="http$4://$5" target="_blank">$2</a>';
-		$body = preg_replace( $pattern, $replacement, $body );
-
-		// E-mail address in the text should create a new e-mail on ExpressoMail
-		$pattern = '/( |<|&lt;|>)([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)( |>|&gt;|<)/im';
-		$replacement = '$1<a href="javascript:new_message_to(\'$2\')">$2</a>$3';
-		$body = preg_replace( $pattern, $replacement, $body );
-
-		// If there is an link with a "mailto:" in href attribute, it will changed to create a new e-mail on ExpressoMail.
-		$pattern = '/<a[^>]+href=["\']mailto:([^"]+)["\'][^>]*>([^<]+)<\/a>/im';
-		$replacement = '<a href="javascript:new_message_to(\'$1\')">$2</a>';
-		$body = preg_replace( $pattern, $replacement, $body );
-
 		return $body;
 	}
@@ -1184,5 +1268,5 @@
 	function get_signature($msg, $msg_number, $msg_folder)
 	{
-        include_once("../security/classes/CertificadoB.php");
+        include_once(dirname( __FILE__ ) ."/../../security/classes/CertificadoB.php");
 		include_once("class.db_functions.inc.php");
 		foreach ($msg->file_type[$msg_number] as $index => $file_type)
@@ -1557,17 +1641,22 @@
 			$this->delete_mailbox(array("del_past" => "INBOX/decifradas"));
 		}
-		$serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}";
-		$folders_list = imap_getmailboxes($mbox_stream, $serverString, ($params && $params['noSharedFolders']) ? "INBOX/*" : "*");
-		$folders_list = array_slice($folders_list,0,$this->foldersLimit);
-
-		$tmp = array();
-		$resultMine = array();
-		$resultDefault = array();
+
 
 		$inbox = 'INBOX';
 		$trash = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'];
-        	$drafts = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'];
-	        $spam = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'];
-        	$sent = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'];
+		$drafts = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'];
+		$spam = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'];
+		$sent = $inbox . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'];
+		$uid2cn = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn']; 
+		// Free others requests 
+		session_write_close(); 
+
+		$serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"; 
+		$folders_list = imap_getmailboxes($mbox_stream, $serverString, ($params && $params['noSharedFolders']) ? "INBOX/*" : "*"); 
+		$folders_list = array_slice($folders_list,0,$this->foldersLimit); 
+
+		$tmp = array(); 
+		$resultMine = array(); 
+		$resultDefault = array(); 
 
 		if (is_array($folders_list)) {
@@ -1593,5 +1682,5 @@
 				$result[$i]['folder_name'] = array_pop($tmp_folder_parent);
 				$result[$i]['folder_name'] = $result[$i]['folder_name'] == 'INBOX' ? 'Inbox' : $result[$i]['folder_name'];
-				if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['uid2cn'] && substr($folder_id,0,4) == 'user') {
+				if ($uid2cn && substr($folder_id,0,4) == 'user') {
 					//$this->ldap = new ldap_functions();
 					if ($cn = $this->ldap->uid2cn($result[$i]['folder_name'])) {
@@ -1798,7 +1887,4 @@
 				return "The server denied your request to send a mail, you cannot use this mail address.";
 		}
-
-		//new_message_to backs to mailto: pattern
-		$params['body'] = eregi_replace("<a href=\"javascript:new_message_to\('([^>]+)'\)\">[^>]+</a>","<a href='mailto:\\1'>\\1</a>",$params['body']);
 
 		$toaddress = implode(',',$db->getAddrs(explode(',',$params['input_to'])));
@@ -1997,53 +2083,7 @@
             $mail->Certs_crypt = $aux_mails;
         }
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-		//	Build CID for embedded Images!!!
-		$pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU';
-		$cid_imgs = '';
-		$name_cid_files = array();
-		preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER);
-		$cid_array = array();
-		foreach($cid_imgs[6] as $j => $val){
-				if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) )
-      			{
-                $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36);
-		        }
-		        $cid = $cid_array[$cid_imgs[4][$j].$val];
-        		$mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body);
-
-				if (!$forwarding_attachments[$cid_imgs[6][$j]-2]) // The image isn't in the same mail?
-				{
-					$fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64');
-					$fileName = "image_".($j).".jpg";
-					$fileCode = "base64";
-					$fileType = "image/jpg";
-				}
-				else
-				{
-					$attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2];
-					$file_description = unserialize(rawurldecode($attach_img));
-
-					foreach($file_description as $i => $descriptor){
-						$file_description[$i]  = eregi_replace('\'*\'','',$descriptor);
-					}
-					$fileContent = $this->get_forwarding_attachment($file_description[0], $cid_imgs[4][$j], $file_description[3], 'base64');
-					$fileName = $file_description[2];
-					$fileCode = $file_description[4];
-					$fileType = $this->get_file_type($file_description[2]);
-					unset($forwarding_attachments[$cid_imgs[6][$j]-2]);
-				}
-				$tempDir = ini_get("session.save_path");
-				$file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";
-				$f = fopen($tempDir.'/'.$file,"w");
-				fputs($f,$fileContent);
-				fclose($f);
-				if ($fileContent)
-					$mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType);
-				//else
-				//	return "Error loading image attachment content";
-
-		}
-////////////////////////////////////////////////////////////////////////////////////////////////////
+                // Build CID images 
+		$this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments); 
+
 		//	Build Uploading Attachments!!!
 		if ((count($attachments)) && ($params['is_local_forward']!="1")) //Caso seja forward normal...
@@ -2080,4 +2120,5 @@
 		{
 			// Bug fixed for array_search function
+			$name_cid_files = array(); 
 			if(count($name_cid_files) > 0) {
 				$name_cid_files[count($name_cid_files)] = $name_cid_files[0];
@@ -2142,6 +2183,71 @@
 		}
 	}
-
-    function add_recipients_cert($full_address)
+	function buildEmbeddedImages(&$mail,$msg_uid,&$forwarding_attachments) 
+	{ 
+		//      Build CID for embedded Images!!! 
+		$pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU'; 
+		$cid_imgs = ''; 
+		preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER); 
+		$cid_array = array(); 
+		foreach($cid_imgs[6] as $j => $val){ 
+			if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) ) 
+			{ 
+				$cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36); 
+			} 
+			$cid = $cid_array[$cid_imgs[4][$j].$val];  
+			$mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body); 
+
+			if ($msg_uid != $cid_imgs[4][$j]) // The image is not in the same mail? 
+			{ 
+				$fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64'); 
+				//prototype: get_forwarding_attachment ( folder, msg number, part, encoding) 
+				$fileName = "image_".($j).".jpg"; 
+				$fileCode = "base64"; 
+				$fileType = "image/jpg"; 
+				$file_attached[0] = $cid_imgs[2][$j]; 
+				$file_attached[1] = $cid_imgs[4][$j]; 
+				$file_attached[2] = $fileName; 
+				$file_attached[3] = $cid_imgs[6][$j]; 
+				$file_attached[4] = 'base64'; 
+				$file_attached[5] = strlen($fileContent); //Size of file 
+				$return_forward[] = $file_attached; 
+
+				$attachment_ = unserialize(rawurldecode($forwarding_attachments[$cid_imgs[6][$j]-2])); 
+				if ($file_attached[3] == $attachment_[3]) 
+					unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 	
+			} 
+			else 
+			{ 
+				$attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2]; 
+				$file_description = unserialize(rawurldecode($attach_img)); 
+				if (is_array($file_description)) 
+					foreach($file_description as $i => $descriptor){                                 
+						$file_description[$i]  = eregi_replace('\'*\'','',$descriptor); 
+					} 
+				$fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64'); 
+				$fileName = $file_description[2]; 
+				$fileCode = $file_description[4]; 
+				$fileType = $this->get_file_type($file_description[2]); 
+				unset($forwarding_attachments[$cid_imgs[6][$j]-2]); 
+				if (!empty($file_description)) 
+				{ 
+					$file_description[5] = strlen($fileContent); //Size of file 
+					$return_forward[] = $file_description; 
+				} 
+			} 
+			$tempDir = ini_get("session.save_path"); 
+			$file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";                                        
+			$f = fopen($tempDir.'/'.$file,"w"); 
+			fputs($f,$fileContent); 
+			fclose($f); 
+			if ($fileContent) 
+				$mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType); 
+			//else 
+			//      return "Error loading image attachment content";                                                 
+
+		} 
+		return $return_forward; 
+	} 
+	function add_recipients_cert($full_address)
 	{
 		$result = "";
@@ -2512,62 +2618,5 @@
 		$mail->Body = $body;
 
-		//	Build CID for embedded Images!!!
-		$pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU';
-		$cid_imgs = '';
-		$name_cid_files = array();
-		preg_match_all($pattern,$mail->Body,$cid_imgs,PREG_PATTERN_ORDER);
-		$cid_array = array();
-		foreach($cid_imgs[6] as $j => $val){
-				if ( !array_key_exists($cid_imgs[4][$j].$val, $cid_array) )
-      			{
-                $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36);
-		        }
-		        $cid = $cid_array[$cid_imgs[4][$j].$val];
-        		$mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body);
-
-				if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail?
-				{
-					$fileContent = $this->get_forwarding_attachment($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64');
-					//prototype: get_forwarding_attachment ( folder, msg number, part, encoding)
-					$fileName = "image_".($j).".jpg";
-					$fileCode = "base64";
-					$fileType = "image/jpg";
-					$file_attached[0] = $cid_imgs[2][$j];
-					$file_attached[1] = $cid_imgs[4][$j];
-					$file_attached[2] = $fileName;
-					$file_attached[3] = $cid_imgs[6][$j];
-					$file_attached[4] = 'base64';
-					$file_attached[5] = strlen($fileContent); //Size of file
-					$return_forward[] = $file_attached;
-				}
-				else
-				{
-					$attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2];
-					$file_description = unserialize(rawurldecode($attach_img));
-					foreach($file_description as $i => $descriptor){
-						$file_description[$i]  = eregi_replace('\'*\'','',$descriptor);
-					}
-					$fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64');
-					$fileName = $file_description[2];
-					$fileCode = $file_description[4];
-					$fileType = $this->get_file_type($file_description[2]);
-					unset($forwarding_attachments[$cid_imgs[6][$j]-2]);
-					if (!empty($file_description))
-					{
-						$file_description[5] = strlen($fileContent); //Size of file
-						$return_forward[] = $file_description;
-					}
-				}
-				$tempDir = ini_get("session.save_path");
-				$file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";
-				$f = fopen($tempDir.'/'.$file,"w");
-				fputs($f,$fileContent);
-				fclose($f);
-				if ($fileContent)
-					$mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType);
-				//else
-				//	return "Error loading image attachment content";
-
-		}
+		$return_forward = $this->buildEmbeddedImages($mail,$msg_uid,$forwarding_attachments); 
 
 	//	Build Forwarding Attachments!!!
@@ -3159,4 +3208,6 @@
 		$criteria =  'BEFORE "'.$before_date.'"';
 		$mbox_stream = $this->open_mbox('INBOX'.$this->imap_delimiter.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']);
+		// Free others requests 
+                session_write_close(); 
 		$messages = imap_search($mbox_stream, $criteria, SE_UID);
 		if (is_array($messages)){
@@ -3201,5 +3252,4 @@
 
 	function search_msg($params = ''){
-            $retorno = "";
             $mbox_stream = "";
             if(strpos($params['condition'],"#")===false) { //local messages
@@ -3280,4 +3330,10 @@
                                 foreach($search_criteria as $new_search)
                                 {
+				    $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream); 
+				    $elem['boxname'] = mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ); 
+				    $elem['uid'] = $new_search; 
+				    $retorno[] = $elem; 
+
+				    /* NOTE: This code was lost on 2.2 merge 
                                     if ($search_result_number != '65536' && $sum == $search_result_number)
                                     {
@@ -3290,5 +3346,6 @@
                                         $retorno .= $m_token;
                                         $sum ++;
-                                    }
+				    }
+				     */
                                 }
                             }
@@ -3300,11 +3357,16 @@
                         {
                             foreach($search_criteria as $new_search)
-                            {
-                                if ($search_result_number != '65536' && $sum == $search_result_number)
+			    {
+				    $elem = $this->get_msg_detail($new_search,$name_box,$mbox_stream); 
+				    $elem['boxname'] = mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ); 
+				    $elem['uid'] = $new_search; 
+				    $retorno[] = $elem; 
+		                //  NOTE: This code was lost on 2.2 merge 
+				/*if ($search_result_number != '65536' && $sum == $search_result_number)
                                 {
                                     return $retorno ? $sum . "=sumResults=" . $retorno : "none";
                                 }
                                 $retorno .= trim("##".mb_convert_encoding( $name_box, "ISO_8859-1", "UTF7-IMAP" ) . "--" . $this->get_msg($new_search,$name_box,$mbox_stream) . "--" . $new_search."##"."\n");
-                                $sum++;
+				$sum++;*/
                             }
                         }
@@ -3327,8 +3389,8 @@
 	}
 
-	function get_msg($uid_msg,$name_box, $mbox_stream )
+	function get_msg_detail($uid_msg,$name_box, $mbox_stream )
 	{
 		$header = $this->get_header($uid_msg);
-		include_once("class.imap_attachment.inc.php");
+		require_once("class.imap_attachment.inc.php");
 		$imap_attachment = new imap_attachment();
 		$attachments =  $imap_attachment->get_attachment_headerinfo($mbox_stream, $uid_msg);
@@ -3347,17 +3409,11 @@
 		if($header->from[0]->personal != "")
 			$from = $header->from[0]->personal;
-		$ret_msg = $this->decode_string($from) . "--" . $subject . "--". gmdate("d/m/Y",$header ->udate)."--". $this->size_msg($header->Size) ."--". $flag;
+		$ret_msg['from'] = $this->decode_string($from); 
+		$ret_msg['subject'] = $subject; 
+		$ret_msg['udate'] = $header ->udate; 
+		$ret_msg['size'] = $header->Size; 
+		$ret_msg['flag'] = $flag; 
 		return $ret_msg;
 	}
-
-	function size_msg($size){
-		$var = floor($size/1024);
-		if($var >= 1){
-			return $var." kb";
-		}else{
-			return $size ." b";
-		}
-	}
-
 	function ob_array($the_object)
 	{
Index: /branches/2.2/expressoMail1_2/inc/gotodownload.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/gotodownload.php	(revision 1937)
+++ /branches/2.2/expressoMail1_2/inc/gotodownload.php	(revision 3018)
@@ -12,5 +12,5 @@
 	$msg_number = $_GET['msg_number'];
 	$idx_file = $_GET['idx_file'];
-	$newfilename = $_GET['newfilename'];
+	$newfilename = urldecode($_GET['newfilename']);
 	$msg_part = $_GET['msg_part'];
 	$msg_folder = $_GET['msg_folder'];
@@ -171,11 +171,30 @@
 			if (preg_match("#^".ini_get('session.save_path')."/(".$GLOBALS['phpgw']->session->sessionid."/)*[A-z]+_".$GLOBALS['phpgw']->session->sessionid."[A-z0-9]*(\.[A-z]{3,4})?$#",$strFileName))
 			{
-				readfile($strFileName);
-				exec("rm -f ".escapeshellcmd(escapeshellarg($strFileName)));
+				if (preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$strFileName)) {
+					//avoid stuck request 
+					session_write_close(); 
+
+					//reset time limit for big files 
+					set_time_limit(0); 
+					ob_end_flush(); 
+
+					if ($fp = fopen ($strFileName, 'rb')) 
+					{ 
+						$bufferSize=1024; 
+						for ($i=$bufferSize; $i<=(filesize($strFileName)+$bufferSize); $i+=$bufferSize)  
+						{ 
+							echo fread($fp, $i); 
+							flush(); 
+						} 
+						fclose ($fp); 
+					} 
+					//readfile($strFileName); 	
+
+					exec("rm -f ".escapeshellcmd(escapeshellarg($strFileName)));
+				}
+				else 
+					if (preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$strFileName)) {
+						readfile($strFileName);
+					}
 			}
-			else 
-				if (preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$strFileName)) {
-					readfile($strFileName);
-				}
-	}
 ?>
Index: /branches/2.2/expressoMail1_2/inc/show_thumbs.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/show_thumbs.php	(revision 1040)
+++ /branches/2.2/expressoMail1_2/inc/show_thumbs.php	(revision 3018)
@@ -1,12 +1,5 @@
 <?php
-if(!isset($GLOBALS['phpgw_info'])){
-	$GLOBALS['phpgw_info']['flags'] = array(
-		'currentapp' => 'expressoMail1_2',
-		'nonavbar'   => true,
-		'noheader'   => true
-	);
-}
-require_once '../../header.inc.php';
 
+	require_once '../../header.session.inc.php'; 
 	$username = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
 	$password = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
@@ -31,18 +24,16 @@
 	$image_mail = imap_fetchbody($mb, $msg_num, $msg_part, FT_UID);
 	$image = imap_base64($image_mail);
-	$image = imagecreatefromstring ($image);
-	
-	header("Content-Type: ".$file_type);
-	header("Content-Disposition: inline");
- 
-	$pic = $image;
-    if ($pic) {
-        $width = imagesx($pic);
-        $height = imagesy($pic);
-        $twidth = 160; # width of the thumb 160 pixel
-        $theight = $twidth * $height / $width; # calculate height
-        $thumb = imagecreatetruecolor ($twidth, $theight);
+	$pic = @imagecreatefromstring ($image);
+	if($pic !== FALSE) { 
+		header("Content-Type: ".$file_type); 
+		header("Content-Disposition: inline");
+		$width = imagesx($pic);
+		$height = imagesy($pic);
+		$twidth = 160; # width of the thumb 160 pixel
+		$theight = $twidth * $height / $width; # calculate height
+		$theight =  $theight < 1 ? 1 : $theight; 
+		$thumb = imagecreatetruecolor ($twidth, $theight);
 		imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb
 		imagejpeg($thumb,"",75); # Thumbnail as JPEG
-    }
+	}
 ?>
Index: /branches/2.2/expressoMail1_2/inc/class.ScriptS.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.ScriptS.inc.php	(revision 1352)
+++ /branches/2.2/expressoMail1_2/inc/class.ScriptS.inc.php	(revision 3018)
@@ -62,5 +62,6 @@
 			if(!$aux){
 				// Caso de erro, grava dentro da variável errstr;
-				$this->errstr = "O arquivo não foi criado";
+                                $this->errstr = "Error: file not created"; 
+                                return $this->errstr; 
 			}
 			// Mata a variavel;
@@ -71,5 +72,6 @@
 			if(!$aux){
 				// Caso de erro, grava dentro da variavel errstr;
-				$this->errstr = "O arquivo não foi ativado";
+                                $this->errstr = "Error: error to activate file"; 
+                                return $this->errstr; 
 			}
 			else{
@@ -84,9 +86,6 @@
 		$this->SieveS->close();
 			
-		if($this->rules){		
+		if($this->rules)
 			return $this->rules;
-		}else{
-			return $this->errstr;
-		}
 			
 	}
@@ -99,4 +98,5 @@
 	
 		$var_decode = rawurldecode($params['arfilter']);
+		$var_decode = preg_replace('/\n\./', '.', $var_decode);
 		
 		$narray  = explode("_end_",$var_decode);
Index: /branches/2.2/expressoMail1_2/inc/class.message_components.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.message_components.inc.php	(revision 1739)
+++ /branches/2.2/expressoMail1_2/inc/class.message_components.inc.php	(revision 3018)
@@ -112,11 +112,11 @@
                     $skip_next    = ($ftype == 'message/rfc822')?        true : false;
 
-                    if ($ftype == 'multipart/mixed' || $skip_part == true && $ftype == 'multipart/alternative' || $ftype == 'multipart/related' )
+		    if ($ftype == 'multipart/report' || $ftype == 'multipart/mixed' || $skip_part == true && $ftype == 'multipart/alternative' || ( $ftype == 'multipart/related' && strtolower( $parts[$p]->parts[0]->subtype ) == 'alternative' ) ) 
                     {
                         $n--;
                     }
                     else
-                    {
-                        $this->pid[$mid][$n]       = ($is_sub_part == false)? $i : ($sub_pid == '' ? '1' : $sub_pid).'.'.$i;
+		    {
+			$this->pid[$mid][$n]       = ($is_sub_part == false || $skip_part && $ftype == 'multipart/related' )? $i : ($sub_pid == '' ? '1' : $sub_pid).'.'.$i; 
                         $this->file_type[$mid][$n] = $ftype;
                         $this->encoding[$mid][$n]  = $encoding;
Index: /branches/2.2/expressoMail1_2/inc/class.SieveS.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.SieveS.inc.php	(revision 1149)
+++ /branches/2.2/expressoMail1_2/inc/class.SieveS.inc.php	(revision 3018)
@@ -178,5 +178,5 @@
 
 		//Verifica a conexao
-		if(!$this->socket){
+		if(!is_resource($this->socket)){ 
 			$this->errstr = "listscripts: sem conexão para o servidor $this->host";
 			return false;
@@ -187,5 +187,5 @@
 	
 		$said = $this->read();
-		while (!preg_match("/^OK/",$said) && !preg_match("/^NO/",$said)) {
+		while (is_resource($this->socket) && (!preg_match("/^OK/",$said) && !preg_match("/^NO/",$said))) { 
 	
 		    // Cyrus v1 script lines look like '"script*"' with the 
Index: /branches/2.2/expressoMail1_2/inc/show_img.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/show_img.php	(revision 1040)
+++ /branches/2.2/expressoMail1_2/inc/show_img.php	(revision 3018)
@@ -1,12 +1,5 @@
 <?php
-if(!isset($GLOBALS['phpgw_info'])){
-        $GLOBALS['phpgw_info']['flags'] = array(
-                'currentapp' => 'expressoMail1_2',
-                'nonavbar'   => true,
-                'noheader'   => true
-        );
-}
-require_once '../../header.inc.php';
 
+	require_once '../../header.session.inc.php'; 
 	header("Content-Type: image/jpeg");
 	if($_GET['msg_num'] && $_GET['msg_part'] && $_GET['msg_folder']) {
Index: /branches/2.2/expressoMail1_2/inc/show_embedded_attach.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/show_embedded_attach.php	(revision 1040)
+++ /branches/2.2/expressoMail1_2/inc/show_embedded_attach.php	(revision 3018)
@@ -1,11 +1,5 @@
 <?php
-if(!isset($GLOBALS['phpgw_info'])){
-        $GLOBALS['phpgw_info']['flags'] = array(
-                'currentapp' => 'expressoMail1_2',
-                'nonavbar'   => true,
-                'noheader'   => true
-        );
-}
-require_once '../../header.inc.php';
+
+	require_once '../../header.session.inc.php'; 
 
 	$username = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
Index: /branches/2.2/expressoMail1_2/inc/hook_home.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/hook_home.inc.php	(revision 1402)
+++ /branches/2.2/expressoMail1_2/inc/hook_home.inc.php	(revision 3018)
@@ -11,6 +11,8 @@
 	$current_app = 'expressoMail1_2';
 	$current_name	 = 'Expresso Mail';
-	$preferences = $GLOBALS['phpgw']->preferences->read();
-        $_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail'];
+	if(!$_SESSION['phpgw_info']['user']['preferences']['expressoMail']) { 
+		$preferences = $GLOBALS['phpgw']->preferences->read(); 
+		$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail'];
+	}
   	$homedisplay = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['mainscreen_showmail'];
 	if($homedisplay=='True')
Index: /branches/2.2/expressoMail1_2/inc/class.functions.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.functions.inc.php	(revision 1572)
+++ /branches/2.2/expressoMail1_2/inc/class.functions.inc.php	(revision 3018)
@@ -116,6 +116,10 @@
             	$h = ord($c{0});   
 	            if ($h <= 0x7F || $h < 0xC2) {
-	            	$result .= $c;
-	            }
+			    // fixing curly brackets 
+			    if($h == 0x7B || $h == 0x7D) 
+				    $result .= "&#" . $h . ";"; 
+			    else 
+				    $result .= $c;
+		    }
 	           	else if ($h <= 0xDF) {
 	                $h = ($h & 0x1F) << 6 | (ord($c{1}) & 0x3F);
Index: /branches/2.2/expressoMail1_2/inc/class.phpmailer.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.phpmailer.php	(revision 1793)
+++ /branches/2.2/expressoMail1_2/inc/class.phpmailer.php	(revision 3018)
@@ -525,34 +525,16 @@
         for($i = 0; $i < count($this->to); $i++)
         {
-            if($this->valEm($this->to[$i][0]))
-            {
-                if(!$this->smtp->Recipient($this->to[$i][0]))  $bad_rcpt[] = $this->to[$i][0];
-            }
-            else
-            {
-                $errorx .= $this->to[$i][0] . ', ';
-            }
+		if(!$this->smtp->Recipient($this->to[$i][0]))
+			$bad_rcpt[] = $this->to[$i][0];
         }
         for($i = 0; $i < count($this->cc); $i++)
         {
-            if($this->valEm($this->cc[$i][0]))
-            {
-                if(!$this->smtp->Recipient($this->cc[$i][0])) $bad_rcpt[] = $this->cc[$i][0];
-            }
-			else
-            {
-                $errorx .= $this->cc[$i][0] . ', ';
-            }
+		if(!$this->smtp->Recipient($this->cc[$i][0]))
+			$bad_rcpt[] = $this->cc[$i][0];
         }
         for($i = 0; $i < count($this->bcc); $i++)
         {
-            if($this->valEm($this->bcc[$i][0]))
-            {
-                if(!$this->smtp->Recipient($this->bcc[$i][0])) $bad_rcpt[] = $this->bcc[$i][0];
-            }
-			else
-            {
-                $errorx .= $this->bcc[$i][0] . ', ';
-            }
+                if(!$this->smtp->Recipient($this->bcc[$i][0]))
+			$bad_rcpt[] = $this->bcc[$i][0];      
         }
         if($errorx != '')
@@ -728,31 +710,4 @@
     }
 
-    function valEm($email)
-    {
-        $mail_retorno = FALSE;
-        if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@"))
-        {
-            if ((!strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," ")))
-            {
-                //testa se tem caracter .
-                if (substr_count($email,".")>= 1)
-                {
-                    //obtem a terminação do dominio
-                    $term_dom = substr(strrchr ($email, '.'),1);
-                    //verifica se terminação do dominio esta correcta
-                    if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) )
-                    {
-                        $antes_dom = substr($email,0,strlen($email) - strlen($term_dom) - 1);
-                        $caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1);
-                        if ($caracter_ult != "@" && $caracter_ult != ".")
-                        {
-                            $mail_retorno = TRUE;
-                        }
-                    }
-                }
-            }
-        }
-        return $mail_retorno;
-    }
 
     /**
Index: /branches/2.2/expressoMail1_2/inc/show_user_photo.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/show_user_photo.php	(revision 1495)
+++ /branches/2.2/expressoMail1_2/inc/show_user_photo.php	(revision 3018)
@@ -1,11 +1,5 @@
 <?php
-if(!isset($GLOBALS['phpgw_info'])){
-	$GLOBALS['phpgw_info']['flags'] = array(
-		'currentapp' => 'expressoMail1_2',
-		'nonavbar'   => true,
-		'noheader'   => true
-	);
-}
-require_once '../../header.inc.php';
+
+	require_once '../../header.session.inc.php'; 
 
 
Index: /branches/2.2/expressoMail1_2/js/abas.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/abas.js	(revision 1994)
+++ /branches/2.2/expressoMail1_2/js/abas.js	(revision 3018)
@@ -113,4 +113,5 @@
 			return alternate_border(id_value);
 		var ID = id_value;
+		openTab.imapBox[ID] = current_folder;
 	}
 	td = document.createElement("TD");
@@ -124,5 +125,5 @@
 
 	td.setAttribute("align", "right");
-	td.onclick = function(){alternate_border(ID);};
+	td.onclick = function(){alternate_border(ID);resizeWindow()};
 	td.setAttribute("noWrap","true");
         td.alt = borderTitle;
@@ -152,20 +153,6 @@
 	div.style.display='';
 
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden')
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;
-
-	div.style.height = document.body.clientHeight - offset - (is_ie ? 76 : 86);
 	div.style.overflow = "hidden";
 
-	if(!is_ie) {
-		var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-		var defaultWidth = document.body.clientWidth - 27;
-		if(!menuHidden)
-			defaultWidth -= Element("folderscol").offsetWidth;
-
-		div.style.width = defaultWidth;
-	}
 	Element("exmail_main_body").insertBefore(div,Element("footer_menu"));
 	alternate_border(ID);
@@ -213,25 +200,25 @@
 		if (body)
 		{
-				var save_link = Element("save_message_options_"+ID);
-				if (openTab.toPreserve[ID] == undefined)
-					openTab.toPreserve[ID] = false;
-				if ((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on') && (save_link.onclick != ''))
-				{
-					var discard_msg = confirm(get_lang("Your message has not been sent. Discard your message?"), "");
-					if (!discard_msg)
-					{
-						Element("border_id_"+ID).onclick = function () { alternate_border(ID);};
-						return;
+			var save_link = Element("save_message_options_"+ID);
+			if (openTab.toPreserve[ID] == undefined)
+				openTab.toPreserve[ID] = false;
+			if ((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on') && (save_link.onclick != ''))
+			{
+				var discard_msg = confirm(get_lang("Your message has not been sent. Discard your message?"), "");
+				if (!discard_msg)
+				{
+					Element("border_id_"+ID).onclick = function () { alternate_border(ID);};
+					return;
+				}
+				else
+				{
+					if (openTab.imapBox[ID] && openTab.imapUid[ID] && !openTab.toPreserve[ID]){
+						delete_msgs(openTab.imapBox[ID], openTab.imapUid[ID].toString(), 0)
+							openTab.toPreserve[ID] = false;
 					}
-					else
-					{
-						if (openTab.imapBox[ID] && !openTab.toPreserve[ID]){
-							delete_msgs(openTab.imapBox[ID], openTab.imapUid[ID].toString(), 0)
-							delete(openTab.imapBox[ID]);
-							openTab.toPreserve[ID] = false;
-							}
-							// Element('to_'+ID).focus(); It crash on IE
-					}
-				}
+					delete(openTab.imapBox[ID]);
+					// Element('to_'+ID).focus(); It crash on IE 
+				}
+			}
 		}
 	}
@@ -273,4 +260,5 @@
 	content = Element('content_id_' + ID);
 	content.parentNode.removeChild(content);
+	resizeWindow();
 	return true;
 }
Index: /branches/2.2/expressoMail1_2/js/messages_proxy.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/messages_proxy.js	(revision 1969)
+++ /branches/2.2/expressoMail1_2/js/messages_proxy.js	(revision 3018)
@@ -90,5 +90,5 @@
 	
 	messages_proxy.prototype.is_local_folder = function(folder) {
-		if(folder.indexOf("local_")==-1)
+		if(typeof(folder) == "undefined" || folder.indexOf("local_")==-1)
 			return false;
 		return true;
@@ -179,6 +179,5 @@
 	messages_proxy.prototype.proxy_move_messages = function (folder, msgs_number, border_ID, new_folder, new_folder_name) {
 		if (! folder || folder == 'null')
-			folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : get_current_folder();
-
+			folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder());
 		if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas não locais...
 			if (folder == new_folder){
Index: /branches/2.2/expressoMail1_2/js/filters.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/filters.js	(revision 810)
+++ /branches/2.2/expressoMail1_2/js/filters.js	(revision 3018)
@@ -1,3 +1,3 @@
-var rules_limit = 300;
+var rules_limit = 3000;
 
 	function cfilterSh(){
@@ -67,14 +67,15 @@
 
 		this.showWindow(form);
-		filter.load_rules();
-		this.list_rules();			
-	
+		if ( filter.rulest.length > 0 ) 
+			this.list_rules(); 
+		else 
+			filter.load_rules(this.list_rules); 
 	}
 
 	cfilterSh.prototype.list_rules = function(){
-		if(filter.rulest.length == 0)
-			setTimeout("filters.mount_list()",2500);
-		else
-			this.mount_list();
+			if(filter.criticalError) 
+				return false; 
+			else 
+				filters.mount_list(); 
 	}
 
Index: /branches/2.2/expressoMail1_2/js/common_functions.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/common_functions.js	(revision 1899)
+++ /branches/2.2/expressoMail1_2/js/common_functions.js	(revision 3018)
@@ -35,11 +35,13 @@
 function resizeWindow(){
 
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);	
-
-	var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
-	var defaultHeight = screenHeight - offset;
+	var divScrollMain = Element("divScrollMain_"+numBox); 
+	var table_message = Element("table_message"); 
+	var content_folders = Element("content_folders"); 
+	var clientHeight = ((window.innerHeight ? window.innerHeight : document.body.offsetHeight) - 8); 
+	var clientWidth = window.innerWidth ? window.innerWidth : document.body.offsetWidth;
+
+	if(divScrollMain){ 
+		divScrollMain.style.height = (clientHeight - (findPosY(divScrollMain) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight))) + "px"; 
+	} 
 
 	if(typeof(BordersArray) != 'undefined') {
@@ -48,18 +50,20 @@
 			var div = Element("content_id_"+BordersArray[i].sequence);
 
-			// This comented code cause/avoid (!?) Firefox to stuck some request
-			if(div)
-//				div.setAttribute("style","height: "+parseInt(defaultHeight - 90)+"px;");
-				div.style.height = defaultHeight - 90;
-			if(div_scroll)
-//				div_scroll.setAttribute("style","height: "+parseInt(defaultHeight - 130)+"px;");
-				div_scroll.style.height = defaultHeight - 130;
-		}
-	}
-
-	if(Element('content_folders'))
-		Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150);
-	if(Element("divScrollMain_"+numBox))
-		Element("divScrollMain_"+numBox).style.height 	= defaultHeight - (is_ie ? 111 : 110);
+			if(div){ 
+				div.style.height = (clientHeight - (findPosY(div) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+2)) + "px"; 
+				 div.style.width = (clientWidth - (findPosX(div)+10)) + "px"; 
+			} 
+			if(div_scroll){ 
+				div_scroll.style.height = (clientHeight - (findPosY(div_scroll) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+5)) + "px"; 
+				div_scroll.style.width = (clientWidth - (findPosX(div_scroll)+15)) + "px"; 
+			} 
+		} 
+	} 
+
+	if(content_folders){ 
+		var search_div = Element("search_div"); 
+		var contentFoldersY = findPosY(content_folders); 
+		content_folders.style.height = (clientHeight - (contentFoldersY + (contentFoldersY > findPosY(search_div) ? 0 : (search_div.clientHeight ? search_div.clientHeight : search_div.offsetHeight) + 5))) + "px"; 
+	} 
 }
 // END: FUNCTION RESIZE WINDOW
@@ -90,4 +94,6 @@
 // Translate words and phrases using user language from eGroupware.
 function get_lang(_key) {
+	if (typeof(_key) == 'undefined') 
+		return false; 
 	var key = _key.toLowerCase();
 	if(array_lang[key])
@@ -116,4 +122,5 @@
 	remove_className(tr_message, 'tr_msg_unread');
 	remove_className(tr_message, 'selected_msg');
+	Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>"; 
 	connector.purgeCache();
 	return true;
@@ -131,4 +138,5 @@
 	remove_className(tr_message, 'selected_msg');
 	add_className(tr_message, 'tr_msg_unread');
+	Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>"; 
 }
 
@@ -215,5 +223,5 @@
 	}
 	if(new_file_name)
-		params = "&newfilename="+new_file_name;
+		params = "&newfilename="+escape(new_file_name);
 	if(encoding)
 		params += "&encoding="+encoding;
@@ -862,4 +870,23 @@
 	}
 }
+
+function borkb(size){ 
+	kbyte = 1024; 
+	mbyte = kbyte*1024; 
+	gbyte = mbyte*1024; 
+	if (!size) 
+		size = 0; 
+	if (size < kbyte) 
+		return size + ' B'; 
+	else if (size < mbyte) 
+		return parseInt(size/kbyte) + ' KB'; 
+	else if (size < gbyte) 
+		if (size/mbyte > 100) 
+			return (size/mbyte).toFixed(0) + ' MB'; 
+		else 
+			return (size/mbyte).toFixed(1) + ' MB'; 
+	else 
+		return parseInt(size/gbyte).toFixed(1) + ' GB'; 
+} 
 
 function validate_date(date){
Index: /branches/2.2/expressoMail1_2/js/main.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/main.js	(revision 1989)
+++ /branches/2.2/expressoMail1_2/js/main.js	(revision 3018)
@@ -59,4 +59,5 @@
 		cExecute ("$this.db_functions.get_dropdown_contacts", save_contacts); //Save contacts needs preferences.
 		cExecute ("$this.imap_functions.get_folders_list&onload=true", update_menu);
+		cExecute ("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", handler_draw_box);
 		
 	}
@@ -320,6 +321,8 @@
 
 		
-		if(Element("border_id_" + id_msg_read)) 
-			alternate_border(id_msg_read);		
+		if(Element("border_id_" + id_msg_read)) {
+			alternate_border(id_msg_read);	
+			resizeWindow(); 	
+		}
 		else {
 			var border_id = create_border(msg_info.subject, id_msg_read);
@@ -393,10 +396,15 @@
 		if (box.childNodes.length == 0)
 		{
-			td_info = document.createElement("H3");
-			td_info.setAttribute("height", "25%");
+		        var tr_info = document.createElement("TR"); 
+                	var td_info = document.createElement("TD"); 
+                        td_info.setAttribute("colspan", "10"); 
 			td_info.setAttribute("background", "#FFF");
-			td_info.setAttribute("id", "msg_info");
+			tr_info.setAttribute("id", "msg_info");
 			td_info.align = "center";
-			td_info.innerHTML = get_lang("This mail box is empty");
+		        td_info.style.padding = "25px";                  
+               		td_info.style.fontWeight = "bold"; 
+                        td_info.style.fontSize = "11pt";   
+			td_info.innerHTML = get_lang("This mail box is empty");i
+			tr_info.appendChild(td_info); 
 			box.appendChild(td_info);
 		}
@@ -410,9 +418,15 @@
 			var box = Element("tbody_box");
 			table_element.appendChild(box);
-			
+			if (data[0].msg_folder != current_folder) // Bad request 
+                        	return false;
+
 			for (var i=0; i<data.length; i++){
-				var new_msg = this.make_tr_message(data[i], current_folder);				
-				_dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true);
-				eval(data[i].command);
+				var existent = document.getElementById(data[i].msg_number); 
+				if (!existent) 
+				{ 
+					var new_msg = this.make_tr_message(data[i], current_folder);                             
+					_dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true); 
+					eval(data[i].command); 
+				} 
 			}
 			if (! typeof(data.msgs_to_delete) == 'undefined')
@@ -633,6 +647,5 @@
 function move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,show_success_msg){
 	if (! folder || folder == 'null')
-		folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : get_current_folder();
-
+		folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder());
 	if(openTab.type[currentTab] == 1)
 		return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name);
@@ -1334,5 +1347,5 @@
 
 	// IM Module Enabled
-	if( window.parent.loadscript )
+	if( window.parent.loadscript && loadscript.autoStatusIM ) 
 	{
 		config_events( body.contentWindow.document, "onkeypress", loadscript.autoStatusIM );	
@@ -1429,4 +1442,5 @@
 
 function send_message_return(data, ID){
+    watch_changes_in_msg(ID); 
 
     var sign = false;
@@ -1702,4 +1716,5 @@
 function return_save(data,border_id,folder_name,folder_id,message_id)
 {
+	Element("send_button_"+border_id).style.visibility="visible"; 
 	var handler_delete_msg = function(data){ refresh(preferences.alert_new_msg); };
 
@@ -1839,5 +1854,4 @@
 		save_link.className = 'message_options_inactive';
 		watch_changes_in_msg(border_id);
-		Element("send_button_"+border_id).style.visibility="visible";
 		write_msg(get_lang('Your message was save as draft in folder %1.', lang_folder(folder_name)));
 	}		
@@ -1858,5 +1872,5 @@
 		sendButton.style.visibility="hidden";
 
-	if (openTab.imapBox[border_id]) //Gets the imap folder
+	if (openTab.imapBox[border_id] && openTab.type[border_id] != 6 && openTab.type[border_id] != 7) //Gets the imap folder 
 		var folder_id = openTab.imapBox[border_id];
 	else
@@ -2159,13 +2173,16 @@
 		if(!verify_session(data))
 			return;
-		if (get_current_folder() == 'INBOX'+cyrus_delimiter+trashfolder){
-			draw_paging(0);
-			kill_current_box();
-		}
 		tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder).alter({caption: get_lang("Trash")});
 		tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder)._refresh();
 		update_quota(get_current_folder());
-		if (data)
+		if (data){
 			write_msg(get_lang('Your Trash folder was empty.'));
+			if (get_current_folder() == 'INBOX'+cyrus_delimiter+trashfolder){
+				draw_paging(0);
+				kill_current_box();
+				Element('tot_m').innerHTML = 0;
+				Element('new_m').innerHTML = 0;
+			}
+		}
 		else
 			write_msg(get_lang('ERROR emptying your Trash folder.'));
@@ -2386,5 +2403,5 @@
 	else{
 		if(data == 'Post-Content-Length')
-			write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',Element('upload_max_filesize').value));
+			write_msg(get_lang('The size of this message has exceeded  the limit (%1B).', preferences.max_attachment_size ? preferences.max_attachment_size : Element('upload_max_filesize').value));
 		else {	/*
 			* @author Rommel Cysne (rommel.cysne@serpro.gov.br)
Index: /branches/2.2/expressoMail1_2/js/connector.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/connector.js	(revision 1965)
+++ /branches/2.2/expressoMail1_2/js/connector.js	(revision 3018)
@@ -340,4 +340,20 @@
 								if ( typeof data == 'undefined' )
 									data = oxmlhttp.responseText;
+								// Verify user session 
+								if(data && data.nosession){ 
+									// If hold session is setted, dont reload the page ... 
+									if(hold_session) { 
+										if(typeof(write_msg) == "function" && typeof(get_lang) == "function") 
+											write_msg(get_lang("your session could not be verified.")); 
+										else 
+											alert("your session could not be verified."); 
+									} 
+									else 
+										window.location.reload(); 
+
+									delete _thisObject.requests[id]; 
+									_thisObject.requests[id] = null; 
+									return false; 
+								} 
 								if(debug_controller) {
 									document.getElementById("debug_controller").innerHTML += oxmlhttp.responseText;
Index: /branches/2.2/expressoMail1_2/js/search.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/search.js	(revision 1969)
+++ /branches/2.2/expressoMail1_2/js/search.js	(revision 3018)
@@ -203,146 +203,54 @@
 		ttree.make_tree(folders,"div_folders_search","_folders_tree_search","","","","");
 	}
-	
-	//This func returns the most recent date
-	function date_comp(a,b)
-	{
-		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);
-		data2 = data2[0].substr(0, data2[0].indexOf('--'))
-		with ( data2 )
-			data2 = Date.UTC(substr(6), substr(3, 2), substr(0, 2));
-		return data2 - data1;
-	}
-	function date_comp_reverse(a,b)
-	{
-		return date_comp(b,a);
-	}
-	
-	function box_comp(a,b)
-	{
-	var compare = [];
-	compare[0] = a.substr(0, a.indexOf('--'));
-	compare[0] = compare[0].toLowerCase();
-	var temp=compare[0];
-	compare[1] = b.substr(0, b.indexOf('--'))
-	compare[1] = compare[1].toLowerCase();
-	compare.sort();
-	if (temp != compare[0])
-		return +1;
-	else
-		return -1;
-	}
-	function box_comp_reverse(a,b)
-	{
-		return box_comp(b,a);
-	}
-
-	function who_comp(a,b)
-	{
-	var compare = [];
-	compare[0] = a.substr(a.indexOf('--')+2);
-	compare[0] = compare[0].toLowerCase();
-	var temp=compare[0];
-	compare[1] = b.substr(b.indexOf('--')+2);
-	compare[1] = compare[1].toLowerCase();
-	compare.sort();
-	if (temp != compare[0])
-		return +1;
-	else
-		return -1;
-	}
-	function who_comp_reverse(a,b)
-	{
-		return who_comp(b,a);
-	}
-
-	function subject_comp(a,b)
-	{
-	var compare = [];
-	compare[0] = a.substr(a.indexOf('--')+2);
-	compare[0] = compare[0].substr(compare[0].indexOf('--')+2);
-	compare[0] = compare[0].toLowerCase();
-	var temp=compare[0];
-	compare[1] = b.substr(b.indexOf('--')+2);
-	compare[1] = compare[1].substr(compare[1].indexOf('--')+2);
-	compare[1] = compare[1].toLowerCase();
-	compare.sort();
-	if (temp != compare[0])
-		return +1;
-	else
-		return -1;
-	}
-	function subject_comp_reverse(a,b)
-	{
-		return subject_comp(b,a);
-	}
-
-	function size_comp(a,b)
-	{
-		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('--'))
-		var size_a = parseInt(data1.substr(0,data1.indexOf(' ')));
-		if (data1.match("k"))
-			size_a = size_a * 1024;
-		else
-			if (data1.match("m"))
-				size_a = size_a * 1048576;
-		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('--'))
-		var size_b = parseInt(data2.substr(0,data2.indexOf(' ')));
-		if (data2.match("k"))
-			size_b = size_b * 1024;
-		else
-			if (data2.match("m"))
-				size_b = size_b * 1048576;
-		return size_b - size_a;
-	}
-	function size_comp_reverse(a,b)
-	{
-		return size_comp(b,a);
-	}
 
 	// Form resultado
 	searchE.prototype.mount_result = function(data,sort_type){
-		var nw_array = new Array;
-		var var_tmp = data.substr(2, data.length - 4);
-		var_tmp  = var_tmp.split("####");
+		if (data == undefined)
+			return;
 		var cont = parseInt(0);
+
+                //This func returns the comparison between criterias 
+                var date_comp = function(a,b){ return a.udate > b.udate;}; 
+                var date_comp_reverse = function(a,b){ return date_comp(b,a);}; 
+                var box_comp = function(a,b){   return a.boxname > b.boxname; } 
+                var box_comp_reverse = function(a,b){   return box_comp(b,a); } 
+                var who_comp = function(a,b){ return a.from > b.from; } 
+                var who_comp_reverse = function(a,b){ return who_comp(b,a); } 
+                var subject_comp = function(a,b){ return a.subject > b.subject; } 
+                var subject_comp_reverse = function(a,b){ return subject_comp(b,a); } 
+                var size_comp = function(a,b){ return a.size > b.size; } 
+                var size_comp_reverse = function(a,b){ return size_comp(b,a); }
+
 		switch (sort_type)
 		{
 			case 'SORTDATE':
-				var_tmp.sort(date_comp);
+				data.sort(date_comp);
 				break;
 			case 'SORTDATE_REVERSE':
-				var_tmp.sort(date_comp_reverse);
+				data.sort(date_comp_reverse);
 				break;
 			case 'SORTBOX':
-				var_tmp.sort(box_comp);
+				data.sort(box_comp);
 				break;
 			case 'SORTBOX_REVERSE':
-                                var_tmp.sort(box_comp_reverse);
+                                data.sort(box_comp_reverse);
                                 break;
 			case 'SORTSUBJECT':
-				var_tmp.sort(subject_comp);
+				data.sort(subject_comp);
 				break;
 			case 'SORTSUBJECT_REVERSE':
-                                var_tmp.sort(subject_comp_reverse);
+                                data.sort(subject_comp_reverse);
 				break;
 			case 'SORTWHO':
-				var_tmp.sort(who_comp);
+				data.sort(who_comp);
 				break;
 			case 'SORTWHO_REVERSE':
-                                var_tmp.sort(who_comp_reverse);
+                                data.sort(who_comp_reverse);
 				break;
 			case 'SORTSIZE':
-				var_tmp.sort(size_comp);
+				data.sort(size_comp);
 				break;
 			case 'SORTSIZE_REVERSE':
-				var_tmp.sort(size_comp_reverse);
+				data.sort(size_comp_reverse);
 				break;
 			default:
@@ -350,13 +258,8 @@
 		}
 
-		for(var i=0; i < var_tmp.length; i++){
-			if(var_tmp[i] != "")
-			{
-				nw_array[cont] = var_tmp[i];
-				cont++;
-			}
-		}
-
-                if( (preferences.search_result_number != '65536') && (nw_array.length > 0) && (nw_array.length >= preferences.search_result_number) ){
+		if(data.length > 0 && showMsg) 
+	                        write_msg(data.length + " "+ get_lang('results found')); 
+                /* This code was lost on merge 
+		if( (preferences.search_result_number != '65536') && (nw_array.length > 0) && (nw_array.length >= preferences.search_result_number) ){
                     nw_array.length = preferences.search_result_number;
                     write_msg(get_lang("More than %1 results. Please, try to refine your search.",preferences.search_result_number));
@@ -365,4 +268,5 @@
                         write_msg(nw_array.length + " "+ get_lang('results found'));
                 }
+		*/
 
 		numBox++;
@@ -386,28 +290,11 @@
 		tbody.id    = "tbody_box_" + numBox;
 
-		for( var i=0; i < nw_array.length; i++){
+		for( var i=0; i < data.length; i++){
 			var tr = document.createElement("TR");
 			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);
-				aux1 = aux1[0].split("--");
-				nw_array[i] = nw_array[i].substr(0, nw_array[i].indexOf(aux1[0])-2);
-				var aux = [];
-				aux[0] = nw_array[i].substr(0, nw_array[i].indexOf('--'));
-				nw_array[i] = nw_array[i].substr(nw_array[i].indexOf('--')+2);
-				aux[1] = nw_array[i].substr(0, nw_array[i].indexOf('--'));
-				aux[2] = nw_array[i].substr(nw_array[i].indexOf('--')+2);
-				aux = aux.concat(aux1);
-			}
-			else
-			{
-				var aux = nw_array[i].split("--");
-			}
-
-			var mailbox = aux[0];
-			var uid_msg = aux[6];
-			var subject = aux[2];
+			var aux = data[i]; 
+			var mailbox = aux.boxname; 
+			var uid_msg = aux.uid; 
+			var subject = aux.subject; 
 			tr.id = uid_msg+"_s"+global_search;
 
@@ -416,5 +303,5 @@
 			tr.name = mailbox;
 
-			if (aux[5].match("U"))
+			if (aux.flag.match("U"))
 				add_className(tr,'tr_msg_unread');
 			add_className(tr, i%2 != 0 ? 'tr_msg_read2' : 'tr_msg_read');
@@ -432,7 +319,7 @@
 				{
 					td.style.width = "2%";
-					if (aux[5].match('T'))
+					if (aux.flag.match('T'))
 					{
-						attachNum = parseInt(aux[5].substr(aux[5].indexOf('T')+1));
+						attachNum = parseInt(aux.flag.substr(aux.flag.indexOf('T')+1));
 						td1 = "<img src='templates/"+template+"/images/clip.gif' title='"+attachNum +' '+ get_lang('attachment(s)')+"'>";
 					}
@@ -444,8 +331,8 @@
 					td.style.width = "1%";
 					td.id = "td_message_answered_"+uid_msg;
-					if (aux[5].match('X'))
+					if (aux.flag.match('X'))
 						td1 = '<img src=templates/'+template+'/images/forwarded.gif title=Forwarded>';
 					else
-						if (aux[5].match('A'))
+						if (aux.flag.match('A'))
 							td1 = '<img src=templates/'+template+'/images/answered.gif>';
 						else
@@ -456,5 +343,5 @@
 					td.style.width = "1%";
 					td.id = "td_message_important_"+uid_msg;
-					if (aux[5].match("F"))
+					if (aux.flag.match("F"))
 					{
 						add_className(tr, 'flagged_msg');
@@ -474,5 +361,5 @@
 					td.style.width = "14%";
 					td.onclick = _onclick;
-					var nm_box = aux[0].split(cyrus_delimiter);
+					var nm_box = aux.boxname.split(cyrus_delimiter);
 					var td1 = nm_box.pop();
 					td.setAttribute("NoWrap","true");
@@ -493,11 +380,11 @@
 				if( j == 6)
 				{
-					if (aux[1].length > 29)
-						aux[1] = aux[1].substr(0,29) + "...";
+					if (aux.from.length > 29)
+						aux.from = aux.from.substr(0,29) + "...";
 					td.style.width = "20%";
 					td.onclick = _onclick;
 					td.setAttribute("NoWrap","true");
                                         td.style.overflow = "hidden";
-					var td1  =  '<div style="width:100%;overflow:hidden">'+aux[1]+"</div>";
+					var td1  =  '<div style="width:100%;overflow:hidden">'+aux.from+"</div>";
 				}
 				if( j == 7)
@@ -505,12 +392,12 @@
 					var subject_encode = url_encode(subject);
 					if (! subject_encode)
-						aux[2] = get_lang("no subject") + "...";
-					if (aux[2].length > 70)
-						aux[2] = aux[2].substr(0,70) + "...";
+						aux.subject = get_lang("no subject") + "...";
+					if (aux.subject.length > 70)
+						aux.subject = aux.subject.substr(0,70) + "...";
 					td.style.width = "35%";
 					td.onclick = _onclick;
                                         td.setAttribute("NoWrap","true");
                                         td.style.overflow = "hidden";
-					var td1  = aux[2];
+					var td1  = aux.subject;
 
 				}
@@ -520,5 +407,6 @@
 					td.align = "center";
 					td.onclick = _onclick;
-					var td1  = aux[3];
+					var _dat = new Date(aux.udate*1000); 
+                                        var td1 = _dat.getDate()+"/"+(_dat.getMonth()+1)+"/"+_dat.getFullYear(); 
 				}
 				if( j == 9)
@@ -527,11 +415,11 @@
 					td.align = "center";
 					td.onclick = _onclick;
-					var td1  = aux[4];
+					var td1  = borkb(aux.size);
 				}
 				if (j == 10)
 				{
-					if (aux[5].match("U"))
+					if (aux.flag.match("U"))
 						add_className(tr, 'tr_msg_unread');
-					if (aux[5].match("F"))
+					if (aux.flag.match("F"))
 						add_className(tr, 'flagged_msg');
 					var td1 = '';
@@ -550,21 +438,7 @@
 
 	var content_search =  Element('content_id_search_' + numBox);
-	// BEGIN MAKE THE SCROLL HEIGHT		
-	var defaultWidth = document.body.offsetWidth - 31;
-	var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-	if(!menuHidden)
-		defaultWidth -= Element("folderscol").offsetWidth;			
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;		
 	var div_scroll_result = document.createElement("DIV");
 	div_scroll_result.id = "divScrollMain_"+numBox;
-	div_scroll_result.style.height = document.body.clientHeight - offset - 120;
-	content_search.style.height = document.body.clientHeight - offset - 80;
 	div_scroll_result.style.overflow = "auto";
-	div_scroll_result.style.width = defaultWidth - (is_ie ? 7 : 0);
-	// END MAKE THE SCROLL HEIGHT		
-		
 	
 		if(is_ie)
@@ -711,4 +585,5 @@
 			content_search.appendChild(div_scroll_result);
 		}
+		resizeWindow(); 
 	}
 
@@ -923,5 +798,4 @@
 		var handler = function(data){
 			var tmp;
-			var countTmp= new Array();
 
                         var dataTemp = data.split('=sumResults=');
@@ -934,17 +808,12 @@
 				if (tmp!=false) {
 					var tmp2 = tmp.substr(2, data.length - 4);
-					countTmp = tmp.split('####');
-				}
-			}
-//			if((data == "none") && (countTmp.length==0)){alert(get_lang("None result was found."));}
-//			if (preferences.search_result_number == '65536' || (data != 'many results' && countTmp.length < preferences.search_result_number))
-//                        {
-//                            EsearchE.mount_result((data=='none')?tmp:(countTmp.length==0)?data:data+tmp);
-//                        }
-//                        else if (data == 'many results' || countTmp.length >= preferences.search_result_number)
-//                        {
-//                            alert(get_lang("More than %1 results. Please, try to refine your search.",preferences.search_result_number));
-//                        }
-
+	                                } 
+	                        } 
+	                        if((data == "none") || (data.length==0)){alert(get_lang("None result was found."));} 
+	                        else if(data.length > 1000){alert(get_lang("More than %1 results. Please, try to refine your search.",1000));}
+			else if(data == "many results"){alert(get_lang("More than %1 results. Please, try to refine your search.",50));} 
+			else{EsearchE.mount_result(data);}
+
+			/* Lost code on merge
                         if ((sumResults == "none") && (countTmp.length==0)){
                             alert(get_lang("None result was found."));
@@ -953,5 +822,5 @@
                         {
                             EsearchE.mount_result((sumResults=='none')?tmp:(countTmp.length==0)?data:data+tmp);
-                        }
+                        }*/
 
 		}
Index: /branches/2.2/expressoMail1_2/js/local_messages.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/local_messages.js	(revision 1982)
+++ /branches/2.2/expressoMail1_2/js/local_messages.js	(revision 3018)
@@ -119,5 +119,6 @@
 
 	local_messages.prototype.create_objects = function() {
-		if(this.dbGears == null)
+		if(window.google){
+		if (this.dbGears == null)
 			this.dbGears = google.gears.factory.create('beta.database');
 		if(this.localServer == null)
@@ -125,4 +126,5 @@
 		if(this.store == null)
 			this.store = this.localServer.createStore('test-store');
+		}
 	}
 
Index: /branches/2.2/expressoMail1_2/js/filter.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/filter.js	(revision 1546)
+++ /branches/2.2/expressoMail1_2/js/filter.js	(revision 3018)
@@ -11,4 +11,5 @@
 	function cfilter(){
 
+		this.criticalError = false;
 		this.mode_in   = "";
 		this.rulest		 = new Array;
@@ -41,14 +42,21 @@
 
 	
-	cfilter.prototype.load_rules = function()
+	cfilter.prototype.load_rules = function(posHandler, param)
 	{
 		var _this = this;
 		var cont1 = parseInt(0);
 		var cont2 = parseInt(0);
-				
+	
 		if( _this.rulest.length == 0 )
 		{
 			var handler_sieve = function(data)
 			{
+				if (data.toString().indexOf('Error:') == 0) 
+				{
+					_this.criticalError = true;
+					alert(get_lang('The filters service is out of service, try again later...'));
+				}
+				else
+				try{
 				if(data.rule.length > 0){
 					for(var i=0 ; i < data.rule.length; i++)
@@ -64,4 +72,11 @@
 				_this.out_officeR = _this.out_officeR ? trim(_this.out_officeR.toString().replace("\n","")) : "";
 				if(data.mode.length > 0){_this.mode_in = data.mode[0];}
+				}
+				catch(e){
+					_this.criticalError = true;
+					alert(get_lang('The filters service is out of service, try again later...'));
+				}
+				if (typeof(posHandler) == 'function')  
+					posHandler(param);  
 			}
 			if(Element('form_status') != null)
@@ -381,35 +396,37 @@
 		this.reload_rules();
 	}
-	
-	cfilter.prototype.new_rule = function(email){
-
-		if(this.email_deny.length > 0){
-			for(var i=0 ; i < this.email_deny.length; i++){
-				if(this.email_deny[i] == email){
-					alert(get_lang("Sender blocked")+"!");
-					return false;
-				}
-			}
-		}
-
-		// Verifica Email
-		var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i
-    	if(!emailReg.test(email)){
-			alert(get_lang("Inform a valid e-mail!"));
-			return false;
-		}
-
-		this.load_rules();
-		if(confirm(get_lang("Do you want to block this e-mail?"))){
-			new_r = "&&ENABLED&&" + email + "&&&&&&discard&&&&0&&&&&&0";
-//			setTimeout("filter.e_newrule('" + new_r + "')",2000);		
-			if (filter.e_newrule(new_r)){
-				this.email_deny.push(email);
-				write_msg(get_lang("The sender was blocked"));							
-			}else
-				write_msg(get_lang("You have reached the maximum number of rules"));
-		}
-	}
-	
+
+cfilter.prototype.new_rule = function(email){
+
+	var createFilter = function (param){ 
+		if (filter.criticalError){ 
+			alert(get_lang('The filters service is out of service, try again later...')); 
+			return false; 
+		} 
+		if(filter.rulest.length > 0){ 
+			var blockedReg = new RegExp('#rule&&[0-9]+&&ENABLED&&'+param+'&&&&&&discard&&&&0&&&&&&0'); 
+			for(var i=0 ; i < filter.rulest.length; i++){ 
+				if(blockedReg.test(filter.rulest[i])){ 
+					alert(get_lang("Sender blocked")+"!"); 
+					return false; 
+				} 
+			} 
+		}                        
+		if(confirm(get_lang("Do you want to block this e-mail?"))){ 
+			new_r = "&&ENABLED&&" + param + "&&&&&&discard&&&&0&&&&&&0"; 
+			//setTimeout("filter.e_newrule('" + new_r + "')",2000);          
+			if (filter.e_newrule(new_r)){ 
+				filter.email_deny.push(new_r); 
+				write_msg(get_lang("The sender was blocked"));                                                   
+			}else 
+				write_msg(get_lang("You have reached the maximum number of rules")); 
+		} 
+	}; 
+	if ( filter.rulest.length > 0 ) 
+		createFilter(email); 
+	else 
+		this.load_rules( createFilter, email ); 
+}
+
 	cfilter.prototype.e_newrule = function(nw_rule)
 	{
@@ -747,5 +764,6 @@
 		var args   = "$this.ScriptS.rec_rules";
 		var params = "arfilter="+aux_rul;
-		cExecute(args,h_filter,params);
+		if(!_this.criticalError)
+			cExecute(args,h_filter,params);
 	}
 
Index: /branches/2.2/expressoMail1_2/js/draw_api.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/draw_api.js	(revision 1969)
+++ /branches/2.2/expressoMail1_2/js/draw_api.js	(revision 3018)
@@ -436,5 +436,4 @@
 			}
 			folders = data;
-			cExecute ("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", handler_draw_box);
 		}
 }
@@ -726,6 +725,4 @@
 	var _divScroll = document.getElementById("divScrollMain_"+numBox);
 
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
 
 	if(!_divScroll){		
@@ -742,14 +739,4 @@
 		_divScroll.style.width	="99.3%";
 	}
-	// Inicio: Redimensiona DIV SCROLL
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);		
-	var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
-	var defaultHeight = screenHeight - offset;		
-	_divScroll.style.height 	= defaultHeight - 110;
-	Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150);
-	// Fim: Redimensiona DIV SCROLL
 	_divScroll.appendChild(table_element);
 	openTab.content_id[numBox].appendChild(_divScroll);
@@ -758,10 +745,15 @@
 
 		if (headers_msgs.num_msgs == 0){
-			td_info = document.createElement("H3");
-			td_info.setAttribute("height", "25%");
+		        var tr_info = document.createElement("TR"); 
+               		var td_info = document.createElement("TD"); 
+                        td_info.setAttribute("colspan", "10"); 
 			td_info.setAttribute("background", "#FFF");
-			td_info.setAttribute("id", "msg_info");
+			tr_info.setAttribute("id", "msg_info");
 			td_info.align = "center";
+			td_info.style.padding = "25px"; 
+			td_info.style.fontWeight = "bold"; 
+                        td_info.style.fontSize = "11pt"; 
 			td_info.innerHTML = get_lang("This mail box is empty");
+			tr_info.appendChild(td_info); 
 			tbody_element.appendChild(td_info);
 		}
@@ -788,4 +780,8 @@
 	draw_footer_box(headers_msgs.num_msgs);	
 	Element('main_table').style.display = '';
+	if(is_ie6)      // Stupid Fixing on IE6. 
+		setTimeout("resizeWindow()",1); 
+	else 
+		resizeWindow(); 
 	if(debug) {
 		var _eTime = new Date();
@@ -954,4 +950,16 @@
 		_img_sent.src 	 = "templates/"+template+"/images/sent.gif";
 
+
+
+		var td_element25 = document.createElement("TD"); 
+		td_element25.className = "td_msg"; 
+		td_element25.setAttribute("width", "1%"); 
+		td_element25.id = "td_message_unseen_"+headers_msgs.msg_number; 
+		if ((headers_msgs.Unseen == 'U') || (headers_msgs.Recent == 'N')) 
+			td_element25.innerHTML = "<img src ='templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>"; 
+		else 
+			td_element25.innerHTML = "<img src ='templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>"; 
+
+
 		td_element3 = document.createElement("TD");
 		td_element3.className = "td_msg";
@@ -964,5 +972,5 @@
 		if (typeof(headers_msgs.from) == 'undefined')
 			return false;
-		if(headers_msgs.from.email.toLowerCase() == Element("user_email").value)
+		if( headers_msgs.from.email && headers_msgs.from.email.toLowerCase() == Element("user_email").value )
 		{ 
 			td_element3.onmouseover = function () {this.title=headers_msgs.to.email;};
@@ -970,5 +978,5 @@
 				td_element3.innerHTML += "<span style=\"color:red\">("+get_lang("Draft")+") </span>";
 			else{				
-				if(headers_msgs.to.email.toLowerCase() != Element("user_email").value)
+				if(headers_msgs.to.email != null && headers_msgs.to.email.toLowerCase() != Element("user_email").value) 
 					td_element24.innerHTML = "<img valign='center' src ='templates/"+template+"/images/sent.gif' title='"+get_lang('Sent')+"'>";
 			
@@ -1048,5 +1056,6 @@
 		tr_element.appendChild(td_element22);
 		tr_element.appendChild(td_element23);
-        tr_element.appendChild(td_element24);
+	        tr_element.appendChild(td_element24);
+		tr_element.appendChild(td_element25); 
 		tr_element.appendChild(td_element3);
 		tr_element.appendChild(td_element4);
@@ -1115,9 +1124,6 @@
 function draw_message(info_msg, ID){
 	var content = document.getElementById('content_id_' + ID);
-	var defaultWidth = document.body.offsetWidth - 37;
 	
 	var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-	if(!menuHidden)
-		defaultWidth -= Element("folderscol").offsetWidth;
 	 //////////////////////////////////////////////////////////////////////////////////////////////////////
 	//Make the next/previous buttom.
@@ -1239,5 +1245,5 @@
 	var tbody_message = document.createElement("TBODY");
 	table_message.border = "0";
-	table_message.width = defaultWidth ;
+	table_message.width = "100%"; 
 
 	//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1268,5 +1274,5 @@
 
 	td.innerHTML = _name.bold() + ', ' + info_msg.smalldate;
-	if (info_msg.attachments.length > 0)
+	if (info_msg.attachments && info_msg.attachments.length > 0) 
 		td.innerHTML += "&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+ID+"\").onclick()' src ='templates/"+template+"/images/clip.gif' title='"+info_msg.attachments.names+"'>";
 	
@@ -1296,11 +1302,7 @@
 	option_hide_more.id = 'option_hide_more_'+ID;
 	option_hide_more.onclick = function(){
-		var _height = Element("div_message_scroll_"+ID).style.height;
-		_height = parseInt(_height.replace("px",""));
-		var _offset = 35;
 		if (this.value == 'more_options'){
 			this.innerHTML = "<b><u>"+get_lang('Options')+"</u></b>";
 			this.value = 'hide_options';
-			Element("div_message_scroll_"+ID).style.height = (_height - _offset)+"px";
 			Element('table_message_others_options_'+ID).style.display = '';
 			Element('tr_other_options_'+ID).style.display = '';
@@ -1310,8 +1312,8 @@
 			this.innerHTML = get_lang('Options');
 			this.value = 'more_options';
-			Element("div_message_scroll_"+ID).style.height = (_height + _offset)+"px";
 			Element('table_message_others_options_'+ID).style.display = 'none';
 			Element('tr_other_options_'+ID).style.display = 'none';			
 		}
+		resizeWindow();
 	};
 	var option_mark = document.createElement('TD');
@@ -1510,5 +1512,5 @@
 	var table_message_others_options = document.createElement("TABLE");
 	table_message_others_options.id = 'table_message_others_options_' + ID;
-	table_message_others_options.width =  defaultWidth - 30;
+	table_message_others_options.width = "100%";
 	table_message_others_options.style.display = 'none';
 	table_message_others_options.className = "table_message";
@@ -1619,5 +1621,7 @@
 	}
 	else {
-		to.innerHTML += draw_plugin_cc(ID,toaddress_array[ID]);
+		toAdd = toaddress_array[ID].toString().replace("<","&lt;"); 
+                toAdd = toAdd.replace(">","&gt;"); 
+                to.innerHTML += draw_plugin_cc(ID,toAdd); 
 	}
 	to.className = "header_message_field";
@@ -1747,6 +1751,6 @@
 	tr5.appendChild(subject);
 	tbody_message_others_options.appendChild(tr5);
-	if (info_msg.attachments.length > 0){
-		var tr6 = document.createElement("TR");
+	if ( info_msg.attachments && info_msg.attachments.length > 0 ){	
+	var tr6 = document.createElement("TR");
 		tr6.className = "tr_message_header";
 		var td6 = document.createElement("TD");
@@ -1826,17 +1830,9 @@
 
 
-	// BEGIN MAKE THE SCROLL HEIGHT
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden')
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;
 	var div = document.createElement("DIV");
 	div.id = "div_message_scroll_"+ID;
 	div.style.background = 'WHITE';
-	div.style.height = document.body.clientHeight - offset - 125;
-	content.style.height = document.body.clientHeight - offset - 90;
 	div.style.overflow = "auto";
-	div.style.width = defaultWidth - (is_ie ? 5 : 0);
-	// END MAKE THE SCROLL HEIGHT
+	div.style.width = "100%"; 
 	table_message_others_options.appendChild(tbody_message_others_options);
 	var tr = document.createElement("TR");
@@ -1844,5 +1840,5 @@
 	td.colSpan = '2';
 	div.appendChild(table_message_others_options);
-	var imgTag = info_msg.body.match(/(<img[^>]*src[^=]*=['"][^'"]*["'][^>]*>)|(<td[^>]*background[^=]*=['"][^'"]*["'][^>]*>)/gi);
+	var imgTag = info_msg.body.match(/(<img[^>]*src[^>=]*=['"]?[^'">]*["']?[^>]*>)|(<[^>]*(style[^=>]*=['"][^>]*background(-image)?:[^:;>]*url\()[^>]*>)/gi);
 	var newBody = info_msg.body;
 	if(!info_msg.showImg && imgTag)
@@ -1859,4 +1855,9 @@
 				for (var i = 0; i < domains.length; i++)
 				{
+					if (imgTag[j].match(/cid:([\w\d]){5,}/) || imgTag[j].match(/src=\"\.\/inc\/show_embedded_attach\.php/g))  
+					{
+						forbidden = false;
+						continue;
+					}
 					imgSource = imgTag[j].match(/=['"](http:\/\/)+[^'"\/]*/);
 					if (imgSource && imgSource.toString().substr(5).match(domains[i]))
@@ -1894,5 +1895,40 @@
 	newBody = newBody.replace("<body","<span");
 	newBody = newBody.replace("<BODY","<span");
-	div.innerHTML+= "<span id='body_"+ID+"'>"+newBody+"</span><br><br>";
+	while ( ( /<span[^>]*><span[^>]*>/ig ).test( newBody ) ) 
+		newBody = newBody.replace( /(<span[^>]*>)<span[^>]*>/ig, '$1' ); 
+
+	var _body = document.createElement( 'div' ); 
+	_body.id = 'body_' + ID; 
+	_body.innerHTML = newBody; 
+
+	var _elements = _body.getElementsByTagName( '*' ); 
+	for( var i = 0; i < _elements.length; i++ ) 
+		if ( _elements[ i ].attributes && _elements[ i ].attributes.getNamedItem( 'id' ) ) 
+			_elements[ i ].attributes.removeNamedItem( 'id' ); 
+
+	div.appendChild( _body ); 
+
+	function mailto( link ) 
+	{ 
+		var mail = link.href.substr( 7 ); 
+		link.onclick = function( ) 
+		{ 
+			new_message_to( mail ); 
+			return false; 
+		}; 
+	} 
+	var links = div.getElementsByTagName( 'a' ); 
+	for ( var i = 0; i < links.length; i++ ){ 
+		try{ 
+			if ( links.item( i ).href.indexOf( 'mailto:' ) === 0 ){                          
+				mailto( links.item( i ) ); 
+			} 
+			else{ 
+				if ( links.item( i ).href.indexOf( 'javascript:' ) !== 0 ) 
+					links.item( i ).setAttribute( 'target', '_blank' ); 
+			} 
+		}catch(e){ 
+		} 
+	} 	
 	//////////////////////////////////////////////////////////////////////////////////////////////////////	
 	//Make the thumbs of the message.
@@ -1942,4 +1978,5 @@
 	table_message.appendChild(tbody_message);
 	content.appendChild(table_message);
+	resizeWindow(); 
 	var msg_number = document.createElement('INPUT');
 	msg_number.id = "msg_number_" + ID;
@@ -2481,17 +2518,8 @@
 	tr5.appendChild(td_body);
 	tbody_message.appendChild(tr5);
-// BEGIN MAKE THE SCROLL HEIGHT
-    var defaultWidth = document.body.clientWidth - (is_ie ? 200 : 195);
-	var _bar = document.getElementById("toolbar");
-	var _offset = 0;
-	if(_bar.style.visibility != 'hidden') 
-		_offset = _bar.offsetHeight ? _bar.offsetHeight :  _bar.clientHeight;		
-	var _div = document.createElement("DIV");
+   	var _div = document.createElement("DIV");
 	_div.id = "div_message_scroll_"+ID;
-	_div.style.height = document.body.clientHeight - _offset - 105;
-	content.style.height = document.body.clientHeight - _offset - 80;
 	_div.style.overflow = "auto";
-	_div.style.width = defaultWidth;
-	// END MAKE THE SCROLL HEIGHT
+	_div.style.width = "100%"; 
 
 	// Hide the contac tips and re-position the pallete color.
@@ -2512,4 +2540,5 @@
 	if(!expresso_offline)
 		draw_from_field(sel_from,tr1_1);
+	resizeWindow(); 
 	return ID;
 }
Index: /branches/2.2/expressoMail1_2/js/DropDownContacts.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/DropDownContacts.js	(revision 804)
+++ /branches/2.2/expressoMail1_2/js/DropDownContacts.js	(revision 3018)
@@ -81,4 +81,5 @@
 	for (var i=0; i<match_contacts.length; i++)
 	{
+		match_contacts[i] = unescape(match_contacts[i]); 
 		var aux = match_contacts[i].split("");
 		for(var j in aux){
Index: /branches/2.2/expressoMail1_2/js/TreeShow.js
===================================================================
--- /branches/2.2/expressoMail1_2/js/TreeShow.js	(revision 1558)
+++ /branches/2.2/expressoMail1_2/js/TreeShow.js	(revision 3018)
@@ -147,4 +147,6 @@
 
 		var aux   = ttree.FOLDER.split(cyrus_delimiter);
+		var delimExp = new RegExp(cyrus_delimiter,"g"); 
+	        newp = newp.replace(delimExp,'_'); 
 		var newp2 = "";
 		if( aux[0] == "root"){
Index: /branches/2.2/doc-expressolivre/debian/arqs-conf/header.inc.php
===================================================================
--- /branches/2.2/doc-expressolivre/debian/arqs-conf/header.inc.php	(revision 1358)
+++ /branches/2.2/doc-expressolivre/debian/arqs-conf/header.inc.php	(revision 3018)
@@ -18,5 +18,5 @@
 	* the absolute path to fit your site, and you should be up and running.    *
 	\**************************************************************************/
-
+	ob_start(); 
 	define('PHPGW_SERVER_ROOT','/var/www/expresso');
 	define('PHPGW_INCLUDE_ROOT','/var/www/expresso');
@@ -127,15 +127,7 @@
 	{
 		include(PHPGW_API_INC . '/functions.inc.php');
-		include(PHPGW_API_INC . '/xml_functions.inc.php');
-		include(PHPGW_API_INC . '/soap_functions.inc.php');
 	}
 	$connection_id = $GLOBALS['phpgw']->session->sessionid;
 	if (!strlen($connection_id) != 32){
-		if (!isset($_SESSION['connection_db_info']))
-		{
-		$GLOBALS['phpgw']->db->query("select trim(sessionid), ip, browser from phpgw_access_log where account_id <> 0 and lo = 0 and sessionid='{$GLOBALS['phpgw']->session->sessionid}' limit 1",__LINE__,__FILE__);
-		$GLOBALS['phpgw']->db->next_record( );
-		$_SESSION['connection_db_info']['user_auth'] = $GLOBALS['phpgw']->db->row( );
-		}
 		include("header.session.inc.php");
 	}
Index: /branches/2.2/doc-expressolivre/debian/expressoInstallDebian-lenny.sh
===================================================================
--- /branches/2.2/doc-expressolivre/debian/expressoInstallDebian-lenny.sh	(revision 1331)
+++ /branches/2.2/doc-expressolivre/debian/expressoInstallDebian-lenny.sh	(revision 3018)
@@ -3,13 +3,13 @@
 # Criado por JoÃ£o Alfredo Knopik Junior <jakjr@celepar.pr.gov.br>
 # ColaboraÃ§Ãµes:
-#	"William Fernando Merlotto" <william@prognus.com.br>
-#	"Alexandre Felipe Muller de Souza" <amuller@celepar.pr.gov.br>
+#       "William Fernando Merlotto" <william@prognus.com.br>
+#       "Alexandre Felipe Muller de Souza" <amuller@celepar.pr.gov.br>
 
 set -e # Para caso de erro
 
 if [ $UID != 0 ]; then {
-	echo "Este script deve ser executado como superusuario, root ou sudo";
-	exit 1;
-	}
+        echo "Este script deve ser executado como superusuario, root ou sudo";
+        exit 1;
+        }
 fi
 
@@ -49,5 +49,5 @@
 dialog --backtitle "$BACKTITLE" --cr-wrap --msgbox \
 "A instalaÃ§Ã£o dos pacotes necessÃ¡rios para o ExpressoLivre comeÃ§arÃ¡ agora." 10 65 &&
-#.....................................................................	    
+#.....................................................................
 
 apt-get install -y apache2-mpm-prefork libapache2-mod-php5 apache2-utils php5 php5-common php5-dev php5-gd php5-imap php5-ldap php5-pgsql php5-cgi php5-cli slapd ldap-utils db4.2-util cyrus-admin-2.2 cyrus-clients-2.2 cyrus-common-2.2 cyrus-doc-2.2 cyrus-imapd-2.2 libcyrus-imap-perl22 postfix postfix-ldap libsasl2-2 libsasl2-modules sasl2-bin nmap vim libmail-imapclient-perl libparse-recdescent-perl libterm-readkey-perl libterm-readline-perl-perl zip unzip graphviz lsb-base openssl ssl-cert || { echo "ImpossÃ­vel continuar, erro no nome dos pacotes"; exit 1; }
@@ -65,10 +65,11 @@
 #apache2-ssl-certificate;
 
-a2enmod rewrite;
+a2enmod rewrite
+a2enmod ssl
 
 cp -r -p ../../../expresso/ /var/www/
-cp ./arqs-conf/etc/apache2/apache2.conf /etc/apache2/
-cp ./arqs-conf/etc/apache2/ports.conf /etc/apache2/
-cp ./arqs-conf/etc/apache2/sites-available/default /etc/apache2/sites-available/
+cp ./arqs-conf/etc/apache2/apache2.conf.lenny /etc/apache2/apache2.conf
+cp ./arqs-conf/etc/apache2/sites-available/default.lenny /etc/apache2/sites-available/expresso
+cp ./arqs-conf/etc/apache2/ports.conf.lenny /etc/apache2/ports.conf
 cp -r -p ./arqs-conf/etc/apache2/ssl/ /etc/apache2/
 
@@ -76,4 +77,10 @@
 mkdir /php_sessions/ || { echo "DiretÃ³rio jÃ¡ existe. [OK]"; }
 chmod -R 777 /php_sessions/
+
+a2ensite expresso
+a2dissite default
+
+# Linha adicionada para resolver alguns warnings quando "apache2ctl configtest"
+HOST=`hostname` ; mv /etc/hosts /etc/hosts.ori ; echo 127.0.0.1 $DOMAIN localhost $HOST  > /etc/hosts ; cat /etc/hosts.ori >> /etc/hosts ; rm /etc/hosts.ori
 
 /etc/init.d/apache2 restart
@@ -86,6 +93,5 @@
 rm -rf /var/lib/ldap
 mkdir /var/lib/ldap
-cp ./arqs-conf/etc/ldap/DB_CONFIG /var/lib/ldap/
-chown -R openldap. /var/lib/ldap/
+chown -R openldap:openldap /var/lib/ldap/
 /etc/init.d/slapd start
 /etc/init.d/slapd stop
@@ -101,4 +107,5 @@
 /etc/init.d/slapd start
 rm /tmp/expresso.ldif
+
 ############################################################################################
 # CYRUS
@@ -126,5 +133,4 @@
 /etc/init.d/postfix restart
 postmap /etc/postfix/expresso-dominios
-echo "127.0.0.1		$DOMAIN" >> /etc/hosts
 
 sleep 10
@@ -134,9 +140,9 @@
 mkdir /home/expressolivre || { echo "DiretÃ³rio jÃ¡ existe. [OK]"; }
 cp ./arqs-conf/home/expressolivre/* /home/expressolivre/
-chown -R www-data.www-data /home/expressolivre/
+chown -R www-data:www-data /home/expressolivre/
 ############################################################################################
 # HEADER_INC_PHP
 sed -e "s/HEADER_PWD/$HEADER_PWD/g" ./arqs-conf/header.inc.php > /var/www/expresso/header.inc.php
-chown www-data.www-data /var/www/expresso/header.inc.php
+chown www-data:www-data /var/www/expresso/header.inc.php
 
 ############################################################################################
@@ -179,7 +185,7 @@
 echo Acerta permissoes das pastas crls e temp em /var/www/expresso/security:
 chown www-data:www-data /var/www/expresso/security/temp
-chown www-data:www-data /var/www/expresso/logs 
+chown www-data:www-data /var/www/expresso/logs
 chown -R www-data:www-data /var/www/expresso/security/crls
-chown www-data.www-data /var/www/expresso/security/crl_admin/crl_admin.py
+chown www-data:www-data /var/www/expresso/security/crl_admin/crl_admin.py
 chmod 755 /var/www/expresso/security/temp
 chmod 755 /var/www/expresso/security/crls
