Index: sandbox/expresso/novos_templates/phpgwapi/inc/class.jscalendar.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.jscalendar.inc.php	(revision 2)
+++ sandbox/expresso/novos_templates/phpgwapi/inc/class.jscalendar.inc.php	(revision 773)
@@ -31,6 +31,6 @@
 			$this->jscalendar_url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/phpgwapi/js/'.$path;
 			$this->dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
-			if ($do_header && !strstr($GLOBALS['phpgw_info']['flags']['java_script'],'jscalendar'))
+			
+			if ($do_header && !strpos($GLOBALS['phpgw_info']['flags']['java_script'],'jscalendar'))
 			{
 				$GLOBALS['phpgw_info']['flags']['java_script'] .=
Index: sandbox/expresso/novos_templates/phpgwapi/inc/class.preferences.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.preferences.inc.php	(revision 54)
+++ sandbox/expresso/novos_templates/phpgwapi/inc/class.preferences.inc.php	(revision 773)
@@ -1116,5 +1116,5 @@
 			// is it possible to use Trash and Sent folders - i.e. using IMAP server
 			// if not - force settings to false
-			if (stristr($prefs['email']['mail_server_type'], 'imap') == False)
+			if (strpos($prefs['email']['mail_server_type'], 'imap') == False)
 			{
 				if (isset($prefs['email']['use_trash_folder']))
Index: sandbox/expresso/novos_templates/phpgwapi/inc/functions.inc.php
===================================================================
--- trunk/phpgwapi/inc/functions.inc.php	(revision 440)
+++ sandbox/expresso/novos_templates/phpgwapi/inc/functions.inc.php	(revision 773)
@@ -385,4 +385,8 @@
 		{
 			$GLOBALS['phpgw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+			preg_match('/(.*)\/(.*)/', PHPGW_APP_TPL, $matches);
+
+			if ($GLOBALS['phpgw_info']['flags']['currentapp'] != "jabberit_messenger")
+			$_SESSION['phpgw_info'][$GLOBALS['phpgw_info']['flags']['currentapp']]['user']['preferences']['common']['template_set'] = $matches[2];
 		}
 
Index: sandbox/expresso/novos_templates/phpgwapi/inc/class.common.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.common.inc.php	(revision 368)
+++ sandbox/expresso/novos_templates/phpgwapi/inc/class.common.inc.php	(revision 773)
@@ -736,18 +736,15 @@
 			while ($entry=$d->read())
 			{
-				if ($entry != 'CVS' && $entry != '.' && $entry != '..'
-					&& $entry != 'phpgw_website'
-					&& is_dir(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry))
-				{
+				if ($entry != '.' && $entry != '..' && is_dir(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry) && file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/head.inc.php'))
+				{
+					$list[$entry]['title'] = $entry;
 					$list[$entry]['name'] = $entry;
+
 					$f = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php';
 					if (file_exists ($f))
 					{
 						include($f);
-						$list[$entry]['title'] = 'Use '.$GLOBALS['phpgw_info']['template'][$entry]['title'].'interface';
-					}
-					else
-					{
-						$list[$entry]['title'] = $entry;
+						if ( defined( $entry.'_TEMPLATE_TITLE' ) )
+							$list[$entry]['title'] = utf8_decode( constant($entry.'_TEMPLATE_TITLE') );
 					}
 				}
Index: sandbox/expresso/novos_templates/phpgwapi/js/dftree/dftree.css
===================================================================
--- trunk/phpgwapi/js/dftree/dftree.css	(revision 2)
+++ sandbox/expresso/novos_templates/phpgwapi/js/dftree/dftree.css	(revision 773)
@@ -37,8 +37,10 @@
 /* link */
 .l {
-	padding: 0px 13px 0px 0px;
+	background-repeat: no-repeat;
+	background-position: left;
+	padding: 0 2em;
 	font-weight: bold;
 	font-size: 10px;
-	color: #666666;
+	color: #4a79b1;
 	text-decoration: none;
 	cursor: pointer;
@@ -54,8 +56,10 @@
 /* selected link */
 .sl {
-	padding: 0px 13px 0px 0px;
+	background-repeat: no-repeat;
+	background-position: left;
+        padding: 0 2em;	
 	font-weight: bold;
 	font-size: 10px;
-	color: #0000FF;
+	color: #fc6103;
 	text-decoration: none;
 	cursor: pointer;
Index: sandbox/expresso/novos_templates/phpgwapi/js/dftree/dftree.js
===================================================================
--- trunk/phpgwapi/js/dftree/dftree.js	(revision 709)
+++ sandbox/expresso/novos_templates/phpgwapi/js/dftree/dftree.js	(revision 773)
@@ -228,4 +228,6 @@
 		captionSpan.style.backgroundColor = 'white';
 		captionSpan.style.border = '1px solid black';
+		captionSpan.style.paddingTop = '0px';
+		captionSpan.style.paddingBottom = '0px';
 	}
 }
@@ -237,5 +239,7 @@
 		captionSpan = getObjectById("l"+this.id+this._myTree.name);
 		captionSpan.style.backgroundColor = '';
-		captionSpan.style.border = '1px solid #f7f7f7';
+		captionSpan.style.border = '0px';
+		captionSpan.style.paddingTop = '1px';
+		captionSpan.style.paddingBottom = '1px';
 	}
 }
@@ -326,5 +330,5 @@
 	spanL.onmouseover = function () { _this._onMouseOver(); };
 	spanL.onmouseout = function () { _this._onMouseOut(); };
-	spanL.style.border = '1px solid #f7f7f7';
+//	spanL.style.border = '1px solid #f7f7f7';
 	spanL.innerHTML = this.caption;
 	//spanL.style.border = '1px solid red';
Index: sandbox/expresso/novos_templates/phpgwapi/templates/celepar/head.inc.php
===================================================================
--- trunk/phpgwapi/templates/celepar/head.inc.php	(revision 12)
+++ sandbox/expresso/novos_templates/phpgwapi/templates/celepar/head.inc.php	(revision 773)
@@ -43,5 +43,5 @@
 		$pngfix_src = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/celepar/js/pngfix.js';
 		$pngfix ='<!-- This solves the Internet Explorer PNG-transparency bug, but only for IE 5.5 and higher --> 
-		<!--[if gte IE 5.5000]>
+		<!--[if lt IE 7]>
 		<script src="'.$pngfix_src.'" type="text/javascript">
 		</script>
Index: sandbox/expresso/novos_templates/phpgwapi/templates/celepar/navbar.inc.php
===================================================================
--- trunk/phpgwapi/templates/celepar/navbar.inc.php	(revision 549)
+++ sandbox/expresso/novos_templates/phpgwapi/templates/celepar/navbar.inc.php	(revision 773)
@@ -163,5 +163,5 @@
 				}			
 			
-				$app_icons .= '<td width="74px" height="40" valign="top" align="left" onclick="location.href=\''.$GLOBALS['phpgw_info']['navbar']['logout']['url'].'\'" style="cursor:pointer;cursor:hand;background-repeat:no-repeat;padding-left:20px;background-image:url('.$var['img_root'].'/back_app.png)">'.$icon.'</td>';
+				$app_icons .= '<td width="74px" height="40" valign="center" align="center" onclick="location.href=\''.$GLOBALS['phpgw_info']['navbar']['logout']['url'].'\'" style="cursor:pointer;cursor:hand;background-repeat:no-repeat;padding-bottom:20px;background-image:url('.$var['img_root'].'/back_app.png)">'.$icon.'</td>';
 			}			//			window.location.href=\''.$GLOBALS['phpgw_info']['navbar']['logout']['url'].'\'
 			
Index: sandbox/expresso/novos_templates/jabberit_messenger/js/load.js
===================================================================
--- trunk/jabberit_messenger/js/load.js	(revision 751)
+++ sandbox/expresso/novos_templates/jabberit_messenger/js/load.js	(revision 773)
@@ -42,9 +42,9 @@
 
 	var _window = new JITWindows(_xtools, _jabberit_content);
-	var _ldap	= new JITLdap( _conn, _xtools, _window);
+	var _ldap	= new JITLdap( _conn, _xtools, _window );
 
 	function addContacts()
 	{
-		_ldap.add();
+		_ldap.add(myWindow);
 	}
 
@@ -246,6 +246,4 @@
 	 			var msg	   	= ( arguments[1] ) ? arguments[1] : "";
 	 		
-//	 			alert("Mensagem Jabber : " + msg);
-	 			
 	 			// If Layer;
 	 			if( elementIframe = document.getElementById('iframe_applet_jabberit') )
Index: sandbox/expresso/novos_templates/jabberit_messenger/js/ldap.js
===================================================================
--- trunk/jabberit_messenger/js/ldap.js	(revision 697)
+++ sandbox/expresso/novos_templates/jabberit_messenger/js/ldap.js	(revision 773)
@@ -4,7 +4,13 @@
 	var _xtools;
 	var _window;
+	var _myWindow;
 
 	function _add_user()
 	{
+		if( arguments.length > 0 )
+		{
+			_myWindow = arguments[0];
+		}
+		
 		var _win_add = _window.load('add_user_im');
 			_win_add.title('.:: Adicionar Novos Contatos ::.');
@@ -51,11 +57,5 @@
 				_name.previousSibling.style.color = "#000";
 
-				if ( !_jid )
-				{
-					_status.innerHTML = 'Selecione uma organização no campo da esquerda e em<br/>'
-										+ ' seguida, no campo da direita, um membro da organização<br/>'
-										+ ' para adicionar como contato';
-				}
-				else
+				if ( _jid )
 				{
 					_name.value = _name.value.replace(/^( )*|( )*$/g, '');
@@ -98,18 +98,24 @@
 									{	
 										
+										var result;
 										_name.parentNode.style.display = 'none';
 										_name.parentNode.nextSibling.style.display = 'none';
 										_status.innerHTML = '<br/>Adicionando contato, aguarde....<br/>';
 				
-										_conn.go(
-											'$this.ujabber.AddNewContact',
-											function()
-											{
-												_status.innerHTML = '<br/>Contato adicionado !<br/>';
-												setTimeout('cleanStatusAddContactIM();',2500);
-											},
-											'uid='+_uid+'&name='+_name.value+'&group='+_group.value
-										);
-
+							 			if( elementIframe = document.getElementById('iframe_applet_jabberit') )
+							 			{
+											if( !is_ie )
+												result = elementIframe.contentDocument.applets[0].addContact( _uid, _name.value, _group.value );
+											else
+												result = elementIframe.contentWindow.document.applets[0].addContact( _uid, _name.value, _group.value );
+										}
+										else // If Pop-Up
+										{
+											result = _myWindow.document.applets[0].addContact( _uid, _name.value, _group.value );
+										}
+
+										_status.innerHTML = '<br/>Contato adicionado !<br/>';
+										setTimeout('cleanStatusAddContactIM();',2500);
+										
 										_name.value = '';
 										_group.value = '';
@@ -185,4 +191,6 @@
 				
 				var _name = document.getElementById('im_name');
+				var groups = "";
+				var data;
 
 				var first_name = document.getElementById(m).innerHTML;
@@ -195,19 +203,31 @@
 					_name.parentNode.nextSibling.nextSibling.innerHTML = '';
 				
-				_conn.go('$this.ujabber.getGroupsJabber',
-						function(data)
-						{
-							if( data = data.replace(/(^\s*)|(\s*$)/g,''))
-							{
-								var _group = document.getElementById('im_group');
-								var _groupOptions = '';
-
-								_group.setAttribute('selectBoxOptions', data);
-								if( document.getElementById('selectBox0') == null)
-									editS.create(document.getElementById('im_group'));
-							}
-							document.getElementById('__span_load_im_group').style.display = 'none';
-						});
-
+	 			// If Layer;
+	 			if( elementIframe = document.getElementById('iframe_applet_jabberit') )
+	 			{
+					if( !is_ie )
+						groups = elementIframe.contentDocument.applets[0].getGroupsToExpresso();
+					else
+						groups = elementIframe.contentWindow.document.applets[0].getGroupsToExpresso();
+				}
+				else // If Pop-Up
+				{
+					groups = _myWindow.document.applets[0].getGroupsToExpresso();
+				}
+		
+				if( typeof(groups) == 'object')
+				{
+					data = groups + ";";
+					data = data.substring(0,(data.length-2));
+				}
+				else			
+					data = groups.substring(0,(groups.length-1));
+				
+				document.getElementById('im_group').setAttribute('selectBoxOptions', data);
+				
+				if( document.getElementById('selectBox0') == null )
+					editS.create(document.getElementById('im_group'));
+
+				document.getElementById('__span_load_im_group').style.display = 'none';
 				document.getElementById('im_group').value = '';
 				document.getElementById('im_group').focus();
@@ -228,5 +248,4 @@
 				_member = _member.nextSibling;
 			}
-		
 		}
 
@@ -280,7 +299,7 @@
 	function LDAP()
 	{
-		_conn = arguments[0];
-		_xtools = arguments[1];
-		_window = arguments[2];
+		_conn		= arguments[0];
+		_xtools		= arguments[1];
+		_window		= arguments[2];
 	}
 
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/drag_area.js
===================================================================
--- trunk/expressoMail1_2/js/drag_area.js	(revision 689)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/drag_area.js	(revision 773)
@@ -23,5 +23,5 @@
 	this.div_dd.style.display ='none';
 	this.envelope = new Image();
-	this.envelope.src = "templates/default/images/envelope.png";
+	this.envelope.src = "templates/"+template+"/images/envelope.png";
 	document.body.appendChild(this.div_dd);
 	
@@ -216,12 +216,14 @@
 			if(new_folder_name == 'INBOX')
 				new_folder_name = get_lang("Inbox");
-			if (_dragArea.from_list) {
-				if (numBox != 0) 
+			if ( _dragArea.from_list )
+			{
+				if (numBox != 0)
 					move_search_msgs("content_id_search_" + numBox, new_folder, new_folder_name);
-				else 
+				else	
 					proxy_mensagens.proxy_move_messages("null", 'selected', 0, new_folder, new_folder_name);
 			}
-			else {
-				var msg_number = _dragArea.from_list ? _dragArea.msg_number : _dragArea.msg_number.replace('_r', '');
+			else
+			{
+				var msg_number = _dragArea.from_list ? _dragArea.msg_number : _dragArea.msg_number.replace('_r','');
 				proxy_mensagens.proxy_move_messages("null", msg_number, msg_number + "_r", new_folder, new_folder_name);
 			}
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/abas.js
===================================================================
--- trunk/expressoMail1_2/js/abas.js	(revision 667)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/abas.js	(revision 773)
@@ -14,5 +14,7 @@
 		return false; // Not possible to alternate
 	show_hide_span_paging(ID);
-	Element("footer_menu").style.display = (ID != "0" ? 'none' : '');
+	spanD = Element("span_D");
+	if (spanD)
+		spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none');
 	var len = BordersArray.length;
 	for (var i=0; i < len; i++)
@@ -80,4 +82,7 @@
 	 	numBox=ID;
  	}
+	else
+        	if (ID.match("search_"))
+                	numBox=ID.substr(7);
         currentTab=ID;
 	return ID;
@@ -86,5 +91,5 @@
 function create_border(borderTitle, id_value)
 {
-	var resize = false;	
+	var resize = false;
 	var offWidth = Element('border_blank').offsetWidth ? Element('border_blank').offsetWidth : Element('border_blank').clientWidth;
 	if (offWidth < 200) {
@@ -95,27 +100,13 @@
 		}
 	}
-	Element("footer_menu").style.display = 'none';
 	
 	if (! id_value) // Is new message?
 		var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1;
-	else{
-		if (Element("border_id_"+id_value)){ // It's opened already!
-			alternate_border(id_value);
-			return false;
-			}
-		
-		if (typeof(id_value) == 'string')
-			for (var bord = 1; bord <= 10; bord++)
-				if (openTab.imapUid[bord] == id_value.substr(0,id_value.length-2)){
-					alternate_border(bord); // It's opened already! (in a new message)
-					return false;
-				}
-
-		
+	else
+	{
+                if (Element("border_id_"+id_value)) // It's opened already!
+			return alternate_border(id_value);
 		var ID = id_value;
-		if (Element("border_id_"+id_value+"_r")) // Edit message? if yes treat like new in dragdrop case
-					var id_value = null;
-	}
-	
+	}
 	td = document.createElement("TD");
 	td.id="border_id_" + ID;
@@ -126,31 +117,28 @@
 	else
 		td.setAttribute("width", "200px");
-		
-	td.className = "menu";
+
 	td.setAttribute("align", "right");
 	td.onclick = function(){alternate_border(ID);};
 	td.setAttribute("noWrap","true");
-	var subject = borderTitle;
-	
+
 	borderTitle = borderTitle ?  borderTitle : id_value ? get_lang("No Subject") : "&nbsp;"	;
 	td.value = borderTitle;
-	if (borderTitle.length > 21){
+	if (borderTitle.length > 21)
 		borderTitle = borderTitle.substring(0,21) + "...";
-	}
-	
+
 	if (resize)
 		borderTitle = borderTitle.substring(0, resize*0.08);
-		
-	td.innerHTML = "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td id=font_border_id_" + ID+" class='font-menu' width=*>" + borderTitle + "</td><td width=1px><img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/default/images/close_button.gif'></td></tr></table>";
+
+	td.innerHTML = "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td id=font_border_id_" + ID+" class='font-menu' width=*>" + borderTitle + "</td><td width=1px><img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'></td></tr></table>";
 
 	bb = document.getElementById("border_blank");
 	parent_bb = bb.parentNode; //Pego o tbody
 	parent_bb.insertBefore(td, bb);
-	
-	if((typeof(id_value) == 'string') && id_value.match(/_r$/))	
+
+	if(! Element("border_id_"+id_value+"_r") ||((typeof(id_value) == 'string') && id_value.match(/_r$/)))
 		_dragArea.makeDragged(td, id_value,td.value);
 
 	BordersArray[BordersArray.length] = new setBorderAttributes(ID);
-	
+
 	var div = document.createElement("DIV");
 	div.id = "content_id_" + ID;
@@ -160,7 +148,7 @@
 	var bar = document.getElementById("toolbar");
 	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
+	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";
@@ -173,9 +161,7 @@
 
 		div.style.width = defaultWidth;
-//		div.style.width ="99.3%";
-	}
-	document.getElementById("exmail_main_body").appendChild(div);
+	}
+	Element("exmail_main_body").insertBefore(div,Element("footer_menu"));
 	alternate_border(ID);
-	
 	return ID;
 }
@@ -249,17 +235,10 @@
 
 	hold_session = false;
-	for (i=0;i<BordersArray.length;i++)
-	{
-		m = document.getElementById(BordersArray[i].border_id);
-		if ((m) && (m.className == 'menu-sel'))
-			border_selected = BordersArray[i].border_id;
-	}
-	
-	if ('border_id_' + ID == border_selected)
-	{
-		if (BordersArray[i-2].sequence == ID)
+	if (exist_className(Element('border_id_'+ID),'menu-sel'))
+	{
+		if (BordersArray[BordersArray.length-2].sequence == ID)
 			this.alternate_border(0);
 		else
-			this.alternate_border(BordersArray[i-2].sequence);
+			this.alternate_border(BordersArray[BordersArray.length-2].sequence);
 	}
 
@@ -267,20 +246,18 @@
 	border = Element('border_id_' + ID);
 	border.parentNode.removeChild(border);
+	var j=0;
+	var new_BordersArray = new Array();
+	for (i=0;i<BordersArray.length;i++)
+		if (document.getElementById(BordersArray[i].border_id) != null){
+			new_BordersArray[j] = BordersArray[i];
+			j++;
+		}
+	if(j == 1)
+		Element("footer_menu").style.display = '';
+	BordersArray = new_BordersArray;
+
 	// Remove Div Content
 	content = Element('content_id_' + ID);
 	content.parentNode.removeChild(content);
-	
-	var new_BordersArray = new Array();
-	j = 0;
-	for (i=0;i<BordersArray.length;i++)
-	{
-		if (Element(BordersArray[i].border_id) != null){
-			new_BordersArray[j] = BordersArray[i];
-			j++;	
-		}
-	}
-	if(j == 1)
-		Element("footer_menu").style.display = '';
-	BordersArray = new_BordersArray;
 	return true;
 }
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/InfoContact.js
===================================================================
--- trunk/expressoMail1_2/js/InfoContact.js	(revision 320)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/InfoContact.js	(revision 773)
@@ -11,5 +11,5 @@
 emInfoContact.prototype.createCard = function(){
 	var pic= new Image(); 
-	pic.src="./templates/default/images/card.gif"; 
+	pic.src="./templates/"+template+"/images/card.gif"; 
 	card = document.createElement("DIV");
 	card.id = "card_cc";
@@ -94,7 +94,7 @@
 		Element("card_cc_td").innerHTML = "<table cellpadding=0 cellspacing=0 border=0 height='100%' width='100%'><tr><td width='70' height='93' style='padding-top:5px;padding-left:6px' align='center' valign='center'>"+
 											"<img src='./inc/show_img.php?email="+data.email+"'></td><td style='padding-left:2px' align='left' valign='top'>"+
-											"<br><img align='center' src='templates/default/images/"+(data.type)+"_catalog.png'><font size=1 color=BLACK>&nbsp;<b>"+get_lang("Sender's Information")+"</b></font>"+
+											"<br><img align='center' src='templates/"+template+"/images/"+(data.type)+"_catalog.png'><font size=1 color=BLACK>&nbsp;<b>"+get_lang("Sender's Information")+"</b></font>"+
 											_this.verifyIM(data.uid,data.email)+
-											"<br><img align='center' src='templates/default/images/phone.gif'>&nbsp;<font  size=1  color=BLACK>"+(phoneUser ? phoneUser : get_lang("None") )+"</font>"+
+											"<br><img align='center' src='templates/"+template+"/images/phone.gif'>&nbsp;<font  size=1  color=BLACK>"+(phoneUser ? phoneUser : get_lang("None") )+"</font>"+
 											"</td></tr><tr><td valign='top' align='center' colspan='2'>"+
 											"<font size=1 color=BLACK>"+cn+"</font>"+
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/shortcut.js
===================================================================
--- trunk/expressoMail1_2/js/shortcut.js	(revision 689)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/shortcut.js	(revision 773)
@@ -249,5 +249,4 @@
 	{
 		var selected_shortcut_msgs = '';
-		var current_folder = get_current_folder();
 		var tbody_box = Element('tbody_box');
 		all_messages = Element('tbody_box').childNodes;
@@ -262,5 +261,5 @@
 		
 		selected_shortcut_msgs = selected_shortcut_msgs.substring(0,(selected_shortcut_msgs.length-1));
-		proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null');
+		delete_msgs(current_folder, selected_shortcut_msgs, 'null');
 	}
 	else
@@ -442,7 +441,7 @@
 			}
 		var scrollMain = Element('divScrollMain_0');
-		var selection_size = 30;
+		var selection_size = parseInt(preferences.line_height) + 10;
 		if (all_messages[mailPos].offsetTop <= scrollMain.scrollTop)
-			scrollMain.scrollTop -= selection_size;
+			scrollMain.scrollTop -= selection_size+10;
 		}
 			return true;
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/sharemailbox.js
===================================================================
--- trunk/expressoMail1_2/js/sharemailbox.js	(revision 197)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/sharemailbox.js	(revision 773)
@@ -145,7 +145,7 @@
 							"<td>"+
 								'<br><br><br><br><br><br>'+
-								'<img onClick="javascript:sharemailbox.add_user();" src="templates/default/images/arrow_left.png" style="vertical-align:middle;cursor:pointer;">' +
+								'<img onClick="javascript:sharemailbox.add_user();" src="templates/'+template+'/images/arrow_left.png" style="vertical-align:middle;cursor:pointer;">' +
 								'<br><br>'+
-								'<img onClick="javascript:sharemailbox.remove_user();" src="templates/default/images/arrow_right.png" style="vertical-align:middle;cursor:pointer;">' +
+								'<img onClick="javascript:sharemailbox.remove_user();" src="templates/'+template+'/images/arrow_right.png" style="vertical-align:middle;cursor:pointer;">' +
 							"</td>"+
 							
@@ -165,8 +165,8 @@
 									get_lang('Access right')+':'+
 								'</td></tr>'+
-								'<tr><td>'+get_lang('Read')+':</td><td><input id=\'em_input_readAcl\' onClick="return sharemailbox.setaclfromuser();" type="checkbox"><img title="'+get_lang("hlp_msg_read_acl")+'." src=\'./templates/default/images/ajuda.jpg\'></td></tr>'+
-								'<tr><td>'+get_lang('Exclusion')+':</td><td><input id=\'em_input_deleteAcl\' onClick="return sharemailbox.setaclfromuser();" type="checkbox"><img title="'+get_lang('hlp_msg_delmov_acl')+'." src=\'./templates/default/images/ajuda.jpg\'></td></tr>'+
-								'<tr><td>'+get_lang('Write')+':</td><td><input id=\'em_input_writeAcl\' onClick="return sharemailbox.setaclfromuser();" type="checkbox"><img title="'+get_lang('hlp_msg_addcreate_acl')+'." src=\'./templates/default/images/ajuda.jpg\'></td></tr>'+
-								'<tr><td>'+get_lang('Send')+':</td><td><input id=\'em_input_sendAcl\' onClick="return sharemailbox.setaclfromuser();" type="checkbox"><img title="'+get_lang('hlp_msg_sendlike_acl')+'." src=\'./templates/default/images/ajuda.jpg\'></td></tr></tbody></table>'+
+								'<tr><td>'+get_lang('Read')+':</td><td><input id=\'em_input_readAcl\' onClick="return sharemailbox.setaclfromuser();" type="checkbox"><img title="'+get_lang("hlp_msg_read_acl")+'." src=\'./templates/'+template+'/images/ajuda.jpg\'></td></tr>'+
+								'<tr><td>'+get_lang('Exclusion')+':</td><td><input id=\'em_input_deleteAcl\' onClick="return sharemailbox.setaclfromuser();" type="checkbox"><img title="'+get_lang('hlp_msg_delmov_acl')+'." src=\'./templates/'+template+'/images/ajuda.jpg\'></td></tr>'+
+								'<tr><td>'+get_lang('Write')+':</td><td><input id=\'em_input_writeAcl\' onClick="return sharemailbox.setaclfromuser();" type="checkbox"><img title="'+get_lang('hlp_msg_addcreate_acl')+'." src=\'./templates/'+template+'/images/ajuda.jpg\'></td></tr>'+
+								'<tr><td>'+get_lang('Send')+':</td><td><input id=\'em_input_sendAcl\' onClick="return sharemailbox.setaclfromuser();" type="checkbox"><img title="'+get_lang('hlp_msg_sendlike_acl')+'." src=\'./templates/'+template+'/images/ajuda.jpg\'></td></tr></tbody></table>'+
 							'</td></tr>'+
 			"</tbody></table>";
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/globals.js
===================================================================
--- trunk/expressoMail1_2/js/globals.js	(revision 427)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/globals.js	(revision 773)
@@ -22,14 +22,14 @@
 	'<tr><td align=left height=16px width="1%" nowrap class="table_top">&nbsp;'+
 	'<a href=# onclick="javascript:new_message(\'new\',\'null\')" align=left>'+
-	'<img src="templates/default/images/menu/createmail.gif">'+
+	'<img src="templates/'+template+'/images/menu/createmail.gif">'+
 	'&nbsp;Novo</a>&nbsp;&nbsp;'+
 	'<a href="#" onclick="javascript:wfolders.makeWindow(\'\', \'change_folder\')" align=left>'+
-	'<img src="templates/default/images/menu/editfolders.png">'+
+	'<img src="templates/'+template+'/images/menu/editfolders.png">'+
 	'&nbsp;Trocar Pasta</a>&nbsp;&nbsp'+	
 	'<a href="#" onclick="javascript:refresh();" align=left>'+
-	'<img src="templates/default/images/menu/checkmail.gif">'+
+	'<img src="templates/'+template+'/images/menu/checkmail.gif">'+
 	'&nbsp;Atualizar</a>&nbsp;&nbsp;'+
 	'<a id="link_tools" href="#" align=left>'+
-	'<img height="16px" src="templates/default/images/menu/tools.gif">'+
+	'<img height="16px" src="templates/'+template+'/images/menu/tools.gif">'+
 	'&nbsp;Ferramentas...</a>&nbsp;&nbsp;</td><td style="padding-left:17px" width="1%" id="content_quota" align=left nowrap></td><td width=* id="div_menu_c3" align="right"></td></tr></table>';
 
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 706)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/main.js	(revision 773)
@@ -79,5 +79,5 @@
 			var save_link = Element("save_message_options_"+border_id);
 			save_link.onclick = function onclick(event) { openTab.toPreserve[border_id] = true; save_msg(border_id); } ;
-			save_link.style.color = '#0000ff';
+			save_link.className = 'message_options';
 		};
 		
@@ -103,10 +103,16 @@
 }
 
-
-
-function show_msg(msg_info){	
+function show_msg_img(msg_info){
+       delete_border(msg_info.msg_number+"_r");
+       msg_info.showImg = true;
+       show_msg(msg_info);
+}
+
+function show_msg(msg_info){
 	if(!verify_session(msg_info))
 		return;
-	
+	if (typeof(msg_info) != 'object')
+		alert(get_lang("Error in show_msg param is not object"))
+
 	if (msg_info.status_get_msg_info == 'false')
 	{
@@ -140,5 +146,16 @@
 			var border_id = create_border(msg_info.subject, id_msg_read);
 			if(border_id)
+			{
+				openTab.type[border_id] = 2;
 				draw_message(msg_info,border_id);
+				var unseen_sort = document.getElementById('span_flag_UNSEEN').getAttribute('onclick');
+				unseen_sort = unseen_sort.toString();
+				if ( !(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'") < 0) )
+				{
+					var sort_type = sort_box_type;
+					sort_box_type = null;
+					sort_box('UNSEEN', sort_type);
+				}
+			}
 			else
 				return;
@@ -186,4 +203,16 @@
 		if(!verify_session(data))
 			return;
+		var box = Element("tbody_box");
+		if (box.childNodes.length == 0)
+		{
+			td_info = document.createElement("H3");
+			td_info.setAttribute("height", "25%");
+			td_info.setAttribute("background", "#FFF");
+			td_info.setAttribute("id", "msg_info");
+			td_info.align = "center";
+			td_info.innerHTML = get_lang("This mail box is empty");
+			box.appendChild(td_info);
+		}
+
 		if (data.length > 0){
 			var msg_info = document.getElementById('msg_info')
@@ -199,15 +228,16 @@
 				eval(data[i].command);
 			}
-			
-			for (var i=0; i<data.msgs_to_delete.length; i++){
-				var remove_msg = document.getElementById(data.msgs_to_delete[i]);
-				if (remove_msg)
-					remove_msg.parentNode.removeChild(remove_msg);
-			}
+			if (! typeof(data.msgs_to_delete) == 'undefined')
+				for (var i=0; i<data.msgs_to_delete.length; i++){
+					var remove_msg = document.getElementById(data.msgs_to_delete[i]);
+					if (remove_msg)
+						remove_msg.parentNode.removeChild(remove_msg);
+				}
+
 			if(parseInt(alert_new_msg) && data.new_msgs > 0)
 				alert(get_lang("You have %1 new", data['new_msgs'])+" "+(data['new_msgs'] > 1 ? get_lang("messages") : get_lang("message")) +"!");
 			if(data.new_msgs > 0){
 			Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + parseInt(data.new_msgs); //refresh tab title
-			update_quota(get_current_folder());
+			update_quota(current_folder);
 			}
 			 //if(data.new_msgs > 0 || data.msgs_to_delete.length > 0)
@@ -240,7 +270,19 @@
 }
 
-function delete_msgs2(folder, msgs_number, border_ID, show_success_msg) {
+function delete_msgs(folder, msgs_number, border_ID, show_success_msg)
+{
+	if (arguments.length < 4){
+		show_success_msg = true;
+	}
+
 	if (folder == 'null')
-		folder = get_current_folder();
+		folder = current_folder;
+
+	if(openTab.type[currentTab] == 1)
+		return move_search_msgs('content_id_'+currentTab);
+
+	if(currentTab.toString().indexOf("_r") != -1){
+			msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r"));
+	}
 
 	if ((parseInt(preferences.save_deleted_msg)) && (folder!='INBOX'+cyrus_delimiter+trashfolder)){
@@ -251,8 +293,11 @@
 	var handler_delete_msgs = function(data){
 		Element('chk_box_select_all_messages').checked = false;
-		mail_msg = Element("tbody_box");
+		if (currentTab)
+			mail_msg = Element("tbody_box_"+currentTab);
+		else
+			mail_msg = Element("tbody_box");
 		
 		if ( preferences.use_shortcuts == '1') {
-			var all_messages = Element('tbody_box').childNodes;
+			var all_messages = mail_msg.childNodes;
 
 			//Last msg is selected
@@ -275,15 +320,18 @@
 		}
 		if (show_success_msg) {
-			if (data.msgs_number.length == 1) 
+			if (data.msgs_number.length == 1)
 				write_msg(get_lang("The message was deleted."));
-			else 
+			else
 				write_msg(get_lang("The messages were deleted."));
 		}
 
-		if (data.border_ID != 'null'){
+		if (openTab.type[currentTab] > 1){
 			if (parseInt(preferences.delete_and_show_previous_message))
+			{
+				delete_border(currentTab,'false');
 				show_msg(data.previous_msg);
+			}
 			else
-				delete_border(data.border_ID,'false');
+				delete_border(currentTab,'false');
 		}
 		Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length;
@@ -298,8 +346,4 @@
 		write_msg(get_lang('No selected message.'));		
 }
-function delete_msgs(folder, msgs_number, border_ID)
-{ 
-	delete_msgs2(folder, msgs_number, border_ID, true);
-}
 
 
@@ -307,5 +351,5 @@
 	var selected_messages = '';
 	var temp_msg;
-	var main_list = Element("tbody_resultsearch_"+border_id.substr(18)).childNodes;	
+	var main_list = Element("tbody_box_"+currentTab.substr(7)).childNodes;
 	for (j = 0; j < main_list.length; j++)	{
 		var check_box = main_list[j].firstChild.firstChild; 
@@ -339,6 +383,7 @@
 			var tr = Element(selected_messages[i]);
 			tr.parentNode.removeChild(tr);
-		}			
-	}	
+		}
+		purgeCache();
+	}
 
 	if (selected_messages){
@@ -376,7 +421,6 @@
 
 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 : current_folder;
 	
 	var handler_move_msgs = function(data){
@@ -391,5 +435,5 @@
 				return false;
 			}else{
-				alert(data);
+				alert(get_lang('Error moving message.')+":\n"+data);
 				return false;
 			}
@@ -399,8 +443,26 @@
 			return false;
 		}
-		
+
+		mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild;
+		if (openTab.type[currentTab] > 1){
+			msg_to_delete = Element(msgs_number);
+			if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete)
+			{
+				if (msg_to_delete.previousSibling){
+					var previous_msg = msg_to_delete.previousSibling.id;
+					cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg);
+				}
+				else
+					delete_border(currentTab,'false');
+			}
+			else
+				delete_border(currentTab,'false');
+			if(msg_to_delete)
+				mail_msg.removeChild(msg_to_delete);
+			return;
+		}
+
 		Element('chk_box_select_all_messages').checked = false;
-		
-		mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild;
+
 		if (! mail_msg)
 				mail_msg = Element("tbody_box");
@@ -410,5 +472,5 @@
 		if( typeof(msgs_number) == 'string' )
 			all_search_msg = msgs_number.split(',');
-		else
+		else if( typeof(msgs_number) == 'number')
 			all_search_msg = msgs_number;
 
@@ -441,10 +503,4 @@
 		}
 		
-		if (show_success_msg) {
-			if (data.msgs_number.length == 1)
-				write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name));
-			else 
-				write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name));
-		}
 
 		if (data.msgs_number.length == 1)
@@ -453,5 +509,5 @@
 			write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name));
 		if (data.border_ID.indexOf('r') != -1){
-			if (parseInt(preferences.delete_and_show_previous_message) && folder == get_current_folder()){
+			if (parseInt(preferences.delete_and_show_previous_message) && folder == current_folder){
 				delete_border(data.border_ID,'false');
 				show_msg(data.previous_msg);
@@ -460,5 +516,5 @@
 				delete_border(data.border_ID,'false');
 		}
-		if(folder == get_current_folder())
+		if(folder == current_folder)
 			Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length;			
 		refresh();
@@ -496,17 +552,32 @@
 		var update_tree;
 
-
 		for (var i = 0; i < data.length; i++) {
 			msg_info = connector.unserialize(data[i]);
+
+			if ( folder == 'INBOX/Lixeira/tmpMoveToLocal' )
+				msg_info.msg_folder += (Date.parse(new Date));
+
 			temp = expresso_local_messages.insert_mail(msg_info, msg_info['header'],msg_info['array_attach'],folder_dest );
-			Element("check_box_message_" + msg_info.msg_number).checked = false;
+			if ( Element("check_box_message_" + msg_info.msg_number) )
+				Element("check_box_message_" + msg_info.msg_number).checked = false;
+
 			if(!temp)
 				sucess = false;
 			else
 				msgs_to_remove.push(msg_info.msg_number);//As mensagens arquivadas devem ser removidas, caso o usuï¿œrio tenha isso configurado.
+
+			if ( Element(msg_info.msg_number) )
+				remove_className(Element(msg_info.msg_number), 'selected_msg');
+
+			if ( tree_folders._selected.id.indexOf( 'local_' ) == 0 || folder.indexOf( 'INBOX/Lixeira/tmpMoveToLocal' ) == 0 )
+			{
+				openTab.imapBox[0] = '';
+				tree_folders.getNodeById( 'local_Inbox' )._select( );
+				change_folder('local_Inbox','Inbox')
+			}
 		}
 		
 		if (preferences.keep_archived_messages == 0) { //Remove as mensagens
-				delete_msgs2(folder,msgs_to_remove,'null',false);
+				delete_msgs(folder,msgs_to_remove,'null',false);
 		}
 		update_tree=(!has_local_messages_before) && expresso_local_messages.has_local_mails();
@@ -658,4 +729,5 @@
 			title = "Re: " + data.subject;
 			Element("subject_" + new_border_ID).value = "Re: " + data.subject;			
+			useOriginalAttachments(new_border_ID,border_ID);
 			var body = Element("body_" + new_border_ID);
 			body.contentWindow.document.open();
@@ -686,4 +758,5 @@
 			Element("subject_" + new_border_ID).value = "Re: " + data.subject;
 			Element("to_" + new_border_ID).value = data.to;
+			useOriginalAttachments(new_border_ID,border_ID);
 			block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour);
 			var body = Element("body_" + new_border_ID);
@@ -710,4 +783,73 @@
 			msg_reply_from.value = Element("msg_number_" + border_ID).value;
 			Element("content_id_" + new_border_ID).appendChild(msg_reply_from);
+
+			config_events(
+				body.contentWindow.document, "onkeyup",
+				function( e )
+				{
+					// Break the indentation to answer an email when the Enter key is pressed
+					if ( e.keyCode == 13 && !e.shiftKey )
+					{
+						// Hiding error that occurs in Internet Explorer
+						try
+						{
+							var selection = null, range = null;
+							var iframeWindow = body.contentWindow;
+							var iframeDocument = iframeWindow.document;
+							if( typeof iframeWindow.getSelection != 'undefined' )
+							{
+								selection = iframeWindow.getSelection( );
+								//if ( typeof selection.getRangeAt != 'undefined' )
+								//	range = selection.getRangeAt( 0 );
+								//else if ( typeof selection.baseNode != 'undefined' )
+								//{
+								//	range = iframeDocument.createRange( );
+								//	range.setStart( selection.baseNode, selection.baseOffset );
+								//	range.setEnd( selection.extentNode, selection.extentOffset );
+								//	if ( range.collapsed )
+								//	{
+								//		range.setStart( selection.extentNode, selection.extentOffset );
+								//		range.setEnd( selection.baseNode, selection.baseOffset );
+								//	}
+								//}
+								range = selection.getRangeAt( 0 );
+								if ( range.commonAncestorContainer != 'body' )
+								{
+									var indent = false;
+									var node = range.commonAncestorContainer.parentNode;
+									while ( node )
+									{
+										if ( node.nodeName.toLowerCase( ) == 'blockquote' )
+											indent = true;
+										node = node.parentNode;
+									}
+									if ( indent )
+									{
+										var rangecopy = range.cloneRange( );
+										rangecopy.collapse( true );
+										range.deleteContents( );
+
+										var newline = iframeDocument.createElement( 'br' );
+										rangecopy.insertNode( newline );
+
+										iframeWindow.focus( );
+
+										body.contentWindow.document.execCommand( 'outdent', false, '' );
+									}
+								}
+							}
+							else if ( typeof iframeDocument.selection != 'undefined' )
+							{
+								// @TODO: IE code
+							}
+						       	else
+						       	{
+								return false;
+							}
+						} catch(e){alert(e);}
+					}
+				}
+			);
+
 			break;
 		case "reply_to_all_without_history":
@@ -732,4 +874,5 @@
 				Element('space_link_' + new_border_ID).style.display='none';
 			}
+			useOriginalAttachments(new_border_ID,border_ID);
 			var body = Element("body_" + new_border_ID);
 			body.contentWindow.document.open();
@@ -776,4 +919,5 @@
 			}
 			document.getElementById("subject_" + new_border_ID).value = "Re: " + data.subject;
+			useOriginalAttachments(new_border_ID,border_ID);
 			block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour);
 			var body = document.getElementById("body_" + new_border_ID);
@@ -800,4 +944,73 @@
 			msg_reply_from.value = Element("msg_number_" + border_ID).value;
 			Element("content_id_" + new_border_ID).appendChild(msg_reply_from);
+
+			config_events(
+				body.contentWindow.document, "onkeyup",
+				function( e )
+				{
+					// Break the indentation to answer an email when the Enter key is pressed
+					if ( e.keyCode == 13 && !e.shiftKey )
+					{
+						// Hiding error that occurs in Internet Explorer
+						try
+						{
+							var selection = null, range = null;
+							var iframeWindow = body.contentWindow;
+							var iframeDocument = iframeWindow.document;
+							if( typeof iframeWindow.getSelection != 'undefined' )
+							{
+								selection = iframeWindow.getSelection( );
+								//if ( typeof selection.getRangeAt != 'undefined' )
+								//	range = selection.getRangeAt( 0 );
+								//else if ( typeof selection.baseNode != 'undefined' )
+								//{
+								//	range = iframeDocument.createRange( );
+								//	range.setStart( selection.baseNode, selection.baseOffset );
+								//	range.setEnd( selection.extentNode, selection.extentOffset );
+								//	if ( range.collapsed )
+								//	{
+								//		range.setStart( selection.extentNode, selection.extentOffset );
+								//		range.setEnd( selection.baseNode, selection.baseOffset );
+								//	}
+								//}
+								range = selection.getRangeAt( 0 );
+								if ( range.commonAncestorContainer != 'body' )
+								{
+									var indent = false;
+									var node = range.commonAncestorContainer.parentNode;
+									while ( node )
+									{
+										if ( node.nodeName.toLowerCase( ) == 'blockquote' )
+											indent = true;
+										node = node.parentNode;
+									}
+									if ( indent )
+									{
+										var rangecopy = range.cloneRange( );
+										rangecopy.collapse( true );
+										range.deleteContents( );
+
+										var newline = iframeDocument.createElement( 'br' );
+										rangecopy.insertNode( newline );
+
+										iframeWindow.focus( );
+
+										body.contentWindow.document.execCommand( 'outdent', false, '' );
+									}
+								}
+							}
+							else if ( typeof iframeDocument.selection != 'undefined' )
+							{
+								// @TODO: IE code
+							}
+						       	else
+						       	{
+								return false;
+							}
+						} catch(e){alert(e);}
+					}
+				}
+			);
+
 			break;
 		case "forward":
@@ -838,10 +1051,10 @@
 						tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("("));
 						a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'";
-						s_tmp = escape(connector.serialize(a_tmp));			
+						s_tmp = escape(connector.serialize(a_tmp));
 
 						divFiles.innerHTML += "<input style='border:0' type='CHECKBOX' name='forwarding_attachments[]' checked value=\""+s_tmp+"\"/>";
 						divFiles.innerHTML += "<link style='border:0' name='file_"+i+"' id='inputFile_"+border_ID+i+"'/>";
 						divFiles.appendChild(link_attachment);
-					}	
+					}
 				}
 			}
@@ -880,17 +1093,14 @@
 			}
 			var body = document.getElementById("body_" + new_border_ID);
-			body.contentWindow.document.open();
 			// Insert the signature automaticaly at message body if use_signature preference is set
 			if (preferences.use_signature == "1") {
-				body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>");
-			}
-			else {
-			body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>");
-			}
-			body.contentWindow.document.close();
-			body.contentWindow.document.designMode = "on";
+				config_events( body, 'onload', function( )
+				{
+					body.contentWindow.document.body.innerHTML += "<br>" + signature;
+				});
+			}
 			if (is_ie)
 				body.contentWindow.document.onkeypress = function(){if(body.contentWindow.event.keyCode == 13){changeEnterKey(body.contentWindow)}};
-			Element("to_" + new_border_ID).focus();			
+			Element("to_" + new_border_ID).focus();
 			break;
 		case "edit":
@@ -945,18 +1155,25 @@
 	}
 
+	// IM Module Enabled
+	if( window.parent.loadscript )
+	{
+		config_events( body.contentWindow.document, "onkeypress", loadscript.autoStatusIM );	
+	}
+
 	if (preferences.auto_save_draft == 1)
-    {
+	{
 		openTab.autosave_timer[new_border_ID] = false;
-		var save_link = document.getElementById("save_message_options"+new_border_ID);
-
-        function auto_sav()
-        {
-        	if (openTab.autosave_timer[new_border_ID])
-			clearTimeout(openTab.autosave_timer[new_border_ID]);
-
-	openTab.autosave_timer[new_border_ID] = setTimeout("save_msg("+new_border_ID+")", autosave_time);
-        }
-        config_events(body.contentWindow.document,'keypress', auto_sav);
-    }
+
+		config_events(body,'onload', function( )
+		{
+			config_events( body.contentWindow.document, 'keypress', function( )
+			{
+				if (openTab.autosave_timer[new_border_ID])
+					clearTimeout(openTab.autosave_timer[new_border_ID]);
+
+				openTab.autosave_timer[new_border_ID] = setTimeout("save_msg("+new_border_ID+")", autosave_time);
+			});
+		});
+	}
 
 	//BEGIN Tab event
@@ -988,7 +1205,50 @@
 		title = title.substring(0, parseInt(resize)*0.08);
 
-	Element("border_id_" + new_border_ID).innerHTML = "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td id=font_border_id_" + new_border_ID +" class='font-menu' width=*>" +title + "</td><td width=1px><img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + new_border_ID + "','false') src='templates/default/images/close_button.gif'></td></tr></table>";
+	Element("border_id_" + new_border_ID).innerHTML = "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td id=font_border_id_" + new_border_ID +" class='font-menu' width=*>" +title + "</td><td width=1px><img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + new_border_ID + "','false') src='templates/"+template+"/images/close_button.gif'></td></tr></table>";
 	return new_border_ID; //Preciso retornar o ID da nova mensagem.
 }
+
+function useOriginalAttachments(new_id_border,old_id_border)
+{
+	var divFiles = Element("divFiles_"+new_id_border);
+	if (Element("attachments_" + old_id_border)) {
+		var areaOldAttachments = document.createElement("DIV");
+		areaOldAttachments.id = "area_div_attachments_"+new_id_border;
+		divFiles.appendChild(areaOldAttachments);
+		var optAttachments = document.createElement("A");
+		optAttachments.setAttribute("href","javascript:void(0)");
+		optAttachments.tabIndex = -1;
+		optAttachments.innerHTML = get_lang("Original attachments: add")+"</br>";
+		areaOldAttachments.appendChild(optAttachments);
+		var divOriginalAttachments = document.createElement("DIV");
+		divOriginalAttachments.id = "div_attachments_"+new_id_border;
+		optAttachments.onclick = function(){
+			if(document.getElementById('div_attachments_'+new_id_border))
+			{
+				areaOldAttachments.removeChild(document.getElementById('div_attachments_'+new_id_border));
+				optAttachments.innerHTML = get_lang("Original attachments: add")+"</br>";
+			}
+			else
+			{
+				areaOldAttachments.appendChild(divOriginalAttachments);
+				optAttachments.innerHTML = get_lang("Original attachments: remove")+"</br>";
+			}
+			return false;};
+			var attachments = document.getElementById("attachments_" + old_id_border).childNodes;
+			for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){
+				var link_attachment = document.createElement("A");
+				link_attachment.setAttribute("href", attachments[i].href);
+				link_attachment.innerHTML = attachments[i].innerHTML;
+				var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", "");
+				var a_tmp = tmp.split(',');
+				tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("("));
+				a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'";
+				s_tmp = escape(connector.serialize(a_tmp));
+				divOriginalAttachments.innerHTML += "<input style='border:0' type='CHECKBOX' name='forwarding_attachments[]' checked value=\""+s_tmp+"\"/>";
+				divOriginalAttachments.appendChild(link_attachment);
+			}
+	}
+}
+
 
 // Change the tag <P> for the tag <BR> on IE
@@ -1047,7 +1307,10 @@
 
 function send_message(ID, folder, folder_name){
+	if ( document.getElementById('viewsource_rt_checkbox').checked == true )
+		document.getElementById('viewsource_rt_checkbox').click();
+
 	var save_link = Element("save_message_options_"+ID);
 	save_link.onclick = '';
-	save_link.style.color = '#999';
+	save_link.className = 'message_options_inactive';
 	
 	ID_tmp = ID;
@@ -1219,5 +1482,5 @@
 		var save_link = Element("save_message_options_"+border_id);
 		save_link.onclick = '';
-		save_link.style.color = '#999';
+		save_link.className = 'message_options_inactive';
 		watch_changes_in_msg(border_id);
 		Element("send_button_"+border_id).style.visibility="visible";
@@ -1227,4 +1490,10 @@
 
 function save_msg(border_id){
+	var rt_checkbox = Element('viewsource_rt_checkbox');
+	if (rt_checkbox == null)
+		return false;
+	if (rt_checkbox.checked == true)
+		rt_checkbox.click();
+
 	var sendButton = Element("send_button_"+border_id);
 	if (sendButton)
@@ -1373,5 +1642,5 @@
 	}
 	
-	var folder = get_current_folder();
+	var folder = current_folder;
 	if (msgs_to_set == 'get_selected_messages')
 		var msgs_to_set = this.get_selected_messages();
@@ -1393,13 +1662,16 @@
 		if (data.status && Element("td_message_answered_"+msg_number)) {	
 			if(flag == 'answered')
-				Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/default/images/answered.gif title=Respondida>';
+				Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/'+template+'/images/answered.gif title=Respondida>';
 			else if(flag == 'forwarded')
-				Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/default/images/forwarded.gif title=Encaminhada>';
-		}
-	}
-	cExecute ("$this.imap_functions.set_messages_flag&folder="+( msg_number_folder ?  msg_number_folder.value : get_current_folder() )+"&msgs_to_set="+msg_number+"&flag="+flag, handler_set_messages_flag);
+				Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/'+template+'/images/forwarded.gif title=Encaminhada>';
+		}
+	}
+	cExecute ("$this.imap_functions.set_messages_flag&folder="+( msg_number_folder ?  msg_number_folder.value : current_folder )+"&msgs_to_set="+msg_number+"&flag="+flag, handler_set_messages_flag);
 }
 
 function print_all(){
+	if (openTab.type[currentTab] == 2)
+		return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab);
+
 	var folder= Element('border_id_0').innerHTML;
 	var body = Element('divScrollMain_'+numBox).innerHTML;
@@ -1504,5 +1776,5 @@
 		if(!verify_session(data))
 			return;
-		if (get_current_folder() == 'INBOX'+cyrus_delimiter+trashfolder){
+		if (current_folder == 'INBOX'+cyrus_delimiter+trashfolder){
 			draw_paging(0);
 			kill_current_box();
@@ -1510,5 +1782,5 @@
 		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());
+		update_quota(current_folder);
 		if (data)
 			write_msg(get_lang('Your Trash folder was empty.'));
@@ -1522,5 +1794,8 @@
 
 function export_all_selected_msgs(){
-	
+	if (openTab.type[currentTab] > 1){
+		source_msg(currentTab,current_folder);
+		return;
+	}
 	var msgs_to_export = this.get_selected_messages();
 	
@@ -1535,5 +1810,5 @@
 	
 	if (msgs_to_export) {
-		cExecute ("$this.exporteml.makeAll", handler_export_all_selected_msgs, "folder="+get_current_folder()+"&msgs_to_export="+msgs_to_export);
+		cExecute ("$this.exporteml.makeAll", handler_export_all_selected_msgs, "folder="+current_folder+"&msgs_to_export="+msgs_to_export);
 		write_msg(get_lang('You must wait while the messages will be exported...'));
 	}
@@ -1587,5 +1862,5 @@
 function nospam(msgs_number, border_ID, folder){
 	if (folder == 'null')
-		folder = get_current_folder();
+		folder = current_folder;
 	var new_folder 	= 'INBOX';
 	var new_folder_name = get_lang('INBOX');
@@ -1609,5 +1884,5 @@
 function spam(folder, msgs_number, border_ID){
 	if (folder == 'null')
-		folder = get_current_folder();
+		folder = current_folder;
     var new_folder 		= 'INBOX'+cyrus_delimiter+'Spam';
 	var new_folder_name = 'Spam';
@@ -1706,12 +1981,20 @@
 			write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',Element('upload_max_filesize').value));
 		else {
-			write_msg(data);
-			arrayJSWin["import_window"].close();
-			if(openTab.imapBox[0] == wfolders_tree._selected.id){
-				openTab.imapBox[0] = '';
-				change_folder(wfolders_tree._selected.id, wfolders_tree._selected.caption);
-			}
-			else{
-				refresh();
+			if ( wfolders_tree._selected.id == 'local_Inbox' )
+			{
+				archive_msgs('INBOX/Lixeira/tmpMoveToLocal','local_Inbox',data);
+				cExecute('$this.imap_functions.delete_mailbox',function(){},'del_past=INBOX/Lixeira/tmpMoveToLocal');
+			}
+			else
+			{
+				write_msg(data);
+				arrayJSWin["import_window"].close();
+				if(openTab.imapBox[0] == wfolders_tree._selected.id){
+					openTab.imapBox[0] = '';
+					change_folder(wfolders_tree._selected.id, wfolders_tree._selected.caption);
+				}
+				else{
+					refresh();
+				}
 			}
 		}
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 710)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/draw_api.js	(revision 773)
@@ -21,9 +21,17 @@
 function draw_tree_folders(folders){
 	// Check if the tree folders alredy exist.
-
 	if (Element('dftree_tree_folders')){
 		var update_tree_folders = function(data){
 			build_quota(data);
+			var unseen_in_mailbox = 0;
+			var unseen_in_shared_folders = 0;
 			for (var i=0; i<data.length; i++){
+				if ( data[i].folder_unseen > 0 )
+				{
+					unseen_in_mailbox = parseInt( unseen_in_mailbox + data[ i ].folder_unseen );
+					if ( data[i].folder_id.indexOf( 'INBOX' ) !== 0 )
+						unseen_in_shared_folders = parseInt( unseen_in_shared_folders + data[ i ].folder_unseen );
+				}
+
 				var folder_unseen = Element('dftree_'+data[i].folder_id+'_unseen');
 				
@@ -43,5 +51,5 @@
 				}
 
-				if(data[i].folder_id == get_current_folder()){					
+				if(data[i].folder_id == current_folder){					
 					var old_new_m = isNaN(parseInt(Element('new_m').innerHTML)) ? parseInt(Element('new_m').firstChild.innerHTML) : parseInt(Element('new_m').innerHTML);
 //					if(!isNaN(old_new_m) && old_new_m < data[i].folder_unseen){
@@ -52,8 +60,25 @@
 				}
 			}
+
+			var display_unseen_in_mailbox = tree_folders.getNodeById( 'root' );
+			//if ( unseen_in_mailbox )
+			//	display_unseen_in_mailbox.alter({caption:'<font style=color:red>[</font><span id="dftree_root_unseen" style="color:red">' + unseen_in_mailbox +'</span><font style=color:red>]</font> ' + get_lang("My Folders")});
+			//else
+				display_unseen_in_mailbox.alter({caption:get_lang("My Folders")});
+			display_unseen_in_mailbox._refresh();
+
+			var display_unseen_in_shared_folders = tree_folders.getNodeById( 'user' );
+			if ( display_unseen_in_shared_folders )
+			{
+				if ( unseen_in_shared_folders )
+					display_unseen_in_shared_folders.alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">' + unseen_in_shared_folders +'</span><font style=color:red>]</font> ' + get_lang("Shared folders")});
+				else
+					display_unseen_in_shared_folders.alter({caption:get_lang("Shared folders")});
+				display_unseen_in_shared_folders._refresh();
+			}
 		}
 		cExecute ("$this.imap_functions.get_folders_list&folder="+current_folder, update_tree_folders);
-		
-		
+
+
 		/**
 		 * Pastas locais
@@ -106,7 +131,13 @@
 		tree_folders.add(n_root,'anything'); //Places the root; second argument can be anything.
 	
+		var unseen_in_mailbox = 0;
+		var unseen_in_shared_folders = 0;
 		for (var i=0; i<folders.length; i++){
 			if (folders[i].folder_unseen > 0)
 			{
+				unseen_in_mailbox = parseInt( unseen_in_mailbox + folders[ i ].folder_unseen );
+				if ( folders[i].folder_id.indexOf( 'INBOX' ) !== 0 )
+					unseen_in_shared_folders = parseInt( unseen_in_shared_folders + folders[ i ].folder_unseen );
+
 				var nn = new dNode({id:folders[i].folder_id, caption:lang_folder(folders[i].folder_name) + '<font style=color:red>&nbsp(</font><span id="dftree_'+folders[i].folder_id+'_unseen" style=color:red>'+folders[i].folder_unseen+'</span><font style=color:red>)</font>', onClick:"change_folder('"+folders[i].folder_id+"','"+folders[i].folder_name+"')", plusSign:folders[i].folder_hasChildren}); 
 				
@@ -169,9 +200,25 @@
 		}
 
-		
-		
 		tree_folders.draw(Element('content_folders'));
 		n_root.changeState();
-		tree_folders.getNodeById('INBOX')._select();		
+
+		var trash_span=document.getElementById('lINBOX/'+trashfolder+'tree_folders');
+		var draft_span=document.getElementById('lINBOX/'+draftsfolder+'tree_folders');
+		var sent_span=document.getElementById('lINBOX/'+sentfolder+'tree_folders');
+		var spam_span=document.getElementById('lINBOX/'+spamfolder+'tree_folders');
+
+		if (trash_span)
+			trash_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_trash.png)";
+
+		if (draft_span)
+			draft_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_draft.png)"
+
+		if (sent_span)
+			sent_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_sent.png)";
+
+		if (spam_span)
+			spam_span.style.backgroundImage="url(../phpgwapi/templates/"+template+"/images/foldertree_spam.png)";
+
+		tree_folders.getNodeById('INBOX')._select();
 		draw_paging(Element('tot_m').innerHTML);
 		// Draw right menu folders.
@@ -181,6 +228,23 @@
 			_dragArea.makeMenuBox(linkBox);
 		*/
-	}
-	
+
+		var display_unseen_in_mailbox = tree_folders.getNodeById( 'root' );
+		//if ( unseen_in_mailbox )
+		//	display_unseen_in_mailbox.alter({caption:'<font style=color:red>[</font><span id="dftree_root_unseen" style="color:red">' + unseen_in_mailbox +'</span><font style=color:red>]</font> ' + get_lang("My Folders")});
+		//else
+			display_unseen_in_mailbox.alter({caption:get_lang("My Folders")});
+		display_unseen_in_mailbox._refresh();
+
+		var display_unseen_in_shared_folders = tree_folders.getNodeById( 'user' );
+		if ( display_unseen_in_shared_folders )
+		{
+			if ( unseen_in_shared_folders )
+				display_unseen_in_shared_folders.alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">' + unseen_in_shared_folders +'</span><font style=color:red>]</font> ' + get_lang("Shared folders")});
+			else
+				display_unseen_in_shared_folders.alter({caption:get_lang("Shared folders")});
+			display_unseen_in_shared_folders._refresh();
+		}
+	}
+
 	var folder_create = "";
 	var nm1 = "";
@@ -222,5 +286,5 @@
 		if ( data && data.imap_error )
 		{
-			connector.newRequest('error.html', 'templates/default/error.html', 'GET',
+			connector.newRequest('error.html', 'templates/'+template+'/error.html', 'GET',
 				function(data)
 				{
@@ -236,5 +300,5 @@
 		if(data) {
 			build_quota(data);			
-			var f_unseen = Element('dftree_'+get_current_folder()+'_unseen');
+			var f_unseen = Element('dftree_'+current_folder+'_unseen');
 			if(f_unseen && f_unseen.innerHTML)
 				Element('new_m').innerHTML = '<font face="Verdana" size="1" color="RED">'+f_unseen.innerHTML+'</font>';
@@ -279,5 +343,5 @@
 
 function open_folder(folder, folder_name){
-	if (get_current_folder()!= folder) {
+	if (current_folder!= folder) {
 		current_folder = folder;
 		var handler_draw_box = function(data){
@@ -304,8 +368,8 @@
 	total_pages = 1;
 
-	if(last_folder != get_current_folder()){
+	if(last_folder != current_folder){
 		lastPage = 1;
 		current_page = 1;
-		last_folder = get_current_folder();
+		last_folder = current_folder;
   	}
 
@@ -415,4 +479,5 @@
 	openTab.content_id[numBox] = document.getElementById("content_id_"+numBox);	
 	openTab.imapBox[numBox] = msg_folder;
+	openTab.type[numBox] = 0;
 	
 	table_message_header_box = document.getElementById("table_message_header_box_"+numBox);
@@ -534,10 +599,9 @@
 	}
 	
-	if(is_ie) {
-		_divScroll.style.overflowY = "auto";								
-		_divScroll.style.overflowX = "hidden";
-		_divScroll.style.width	="100%";
-	}													
-	else{
+	_divScroll.style.overflowY = "auto";								
+	_divScroll.style.overflowX = "hidden";
+	_divScroll.style.width	="100%";
+	
+	if (is_mozilla){
 		_divScroll.style.overflow = "-moz-scrollbars-vertical";
 		_divScroll.style.width	="99.3%";
@@ -573,5 +637,6 @@
 				f_unseen++;
 			tr_element = this.make_tr_message(headers_msgs[i], msg_folder);
-			tbody_element.appendChild(tr_element);
+			if (tr_element)
+				tbody_element.appendChild(tr_element);
 			_dragArea.makeDragged(tr_element, headers_msgs[i].msg_number, headers_msgs[i].subject, true);
 	}
@@ -582,5 +647,6 @@
 	var tdFolders  =  Element("folderscol");
 	tdFolders.style.display = preferences.hide_folders == '1'  ? "none" : "";
-	alternate_border(numBox);
+	if ( !currentTab )
+		alternate_border(numBox);
 	draw_footer_box(headers_msgs.num_msgs);	
 	Element('main_table').style.display = '';
@@ -619,4 +685,5 @@
 	}
 }
+
 function change_tr_properties(tr_element, newUid, newSubject){
        var td_who = document.getElementById('td_who_'+tr_element.id);
@@ -644,4 +711,12 @@
 			add_className(tr_element, 'tr_msg_read');
 		}
+
+		if ((headers_msgs.Unseen == 'U') || (headers_msgs.Recent == 'N'))
+			add_className(tr_element, 'tr_msg_unread');
+		else
+			add_className(tr_element, 'tr_msg_read');
+		
+		if (headers_msgs.Flagged == 'F')
+			add_className(tr_element,'flagged_msg');
 
 		td_element1 = document.createElement("TD");
@@ -662,5 +737,6 @@
 		td_element2.setAttribute("width", "2%");
 		if (headers_msgs.attachment && headers_msgs.attachment.number_attachments > 0)
-			td_element2.innerHTML = "<img src ='templates/default/images/clip.gif' title='" + url_decode(headers_msgs.attachment.names) + "'>";
+			//td_element2.innerHTML = "<img src ='templates/"+template+"/images/clip.gif' title='" + url_decode(headers_msgs.attachment.names) + "'>";
+			td_element2.style.background = "url(templates/"+template+"/images/clip.gif) no-repeat center";
 			
 		td_element21 = document.createElement("TD");
@@ -669,5 +745,6 @@
 
 		if ((headers_msgs.Forwarded == 'F')  || (headers_msgs.Draft == 'X' && headers_msgs.Answered == 'A')){
-			td_element21.innerHTML += "<img src ='templates/default/images/forwarded.gif' title='"+get_lang('Forwarded')+"'>";
+			//td_element21.innerHTML += "<img src ='templates/"+template+"/images/forwarded.gif' title='"+get_lang('Forwarded')+"'>";
+			td_element21.style.background = "url(templates/"+template+"/images/forwarded.gif) no-repeat center";
 			headers_msgs.Draft = '' 
 			headers_msgs.Answered = '';
@@ -675,7 +752,9 @@
 		}
 		else if (headers_msgs.Draft == 'X')
-			td_element2.innerHTML += "<img src ='templates/default/images/draft.gif' title='"+get_lang('Draft')+"'>";
+			//td_element2.innerHTML += "<img src ='templates/"+template+"/images/draft.gif' title='"+get_lang('Draft')+"'>";
+			td_element2.style.background = "url(templates/"+template+"/images/draft.gif) no-repeat center";
 		else if (headers_msgs.Answered == 'A')
-			td_element21.innerHTML += "<img src ='templates/default/images/answered.gif' title='"+get_lang('Answered')+"'>";
+			//td_element21.innerHTML += "<img src ='templates/"+template+"/images/answered.gif' title='"+get_lang('Answered')+"'>";
+			td_element21.style.background = "url(templates/"+template+"/images/answered.gif) no-repeat center";
 
 		td_element22 = document.createElement("TD");
@@ -683,14 +762,11 @@
 		td_element22.id = "td_message_important_"+headers_msgs.msg_number;
 
-		// preload image
-		var _img_important = new Image();
-		_img_important.src = "templates/default/images/important.gif"
-		if (headers_msgs.Flagged == 'F' || (headers_msgs.Importance.toLowerCase().indexOf("high") != -1 && preferences.use_important_flag == 'True')){
-			td_element22.innerHTML += "<img src ='templates/default/images/important.gif' title='"+get_lang('Important')+"'>";
-			}
+		if (headers_msgs.Flagged == 'F' || (headers_msgs.Importance.toLowerCase().indexOf("high") != -1 && preferences.use_important_flag == 'True'))
+		{
+			td_element22.style.background = "url(templates/"+template+"/images/important.gif) no-repeat center";
+		}
 		else
 			td_element22.innerHTML += "&nbsp;&nbsp;&nbsp;";
-			
-			
+
 		td_element23 = document.createElement("TD");
 		td_element23.setAttribute("width", "1%");
@@ -699,5 +775,5 @@
 		// preload image
 		var _img_sent = new Image();
-		_img_sent.src 	 = "templates/default/images/sent.gif";
+		_img_sent.src 	 = "templates/"+template+"/images/sent.gif";
 
 		td_element3 = document.createElement("TD");
@@ -708,4 +784,6 @@
 		td_element3.innerHTML = '&nbsp;';
 		
+		if (typeof(headers_msgs.from) == 'undefined')
+			return false;
 		if(headers_msgs.from.email.toLowerCase() == Element("user_email").value)
 		{ 
@@ -715,5 +793,5 @@
 			else{				
 				if(headers_msgs.to.email.toLowerCase() != Element("user_email").value)
-					td_element23.innerHTML = "<img valign='center' src ='templates/default/images/sent.gif' title='"+get_lang('Sent')+"'>";
+					td_element23.innerHTML = "<img valign='center' src ='templates/"+template+"/images/sent.gif' title='"+get_lang('Sent')+"'>";
 			
 				if ((headers_msgs.to)&&(headers_msgs.to.name != null))
@@ -799,5 +877,5 @@
 	var message_header = Element("message_header_"+search);
 	var handler_draw_box = function(data){
-		draw_box(data, get_current_folder(),true);
+		draw_box(data, current_folder,true);
 		draw_paging(Element('tot_m').innerHTML);
 		//Mostrar as msgs nao lidas de acordo com o filtro de relevancia
@@ -825,5 +903,5 @@
 
 	proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort,search,sort_box_reverse,handler_draw_box);
-//	cExecute ("$this.imap_functions.get_range_msgs2&folder="+current_folder+"&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&search_box_type="+search+"&sort_box_type="+sort+"&sort_box_reverse="+sort_box_reverse+"", handler_draw_box);
+	cExecute ("$this.imap_functions.get_range_msgs2&folder="+current_folder+"&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type="+sort+"&search_box_type="+search+"&sort_box_reverse="+sort_box_reverse+"", handler_draw_box);
 	current_page = 1;
 	//Comentado para nao sobrepor o numero de msgs nao lidas ao utilizar os filtros
@@ -852,5 +930,5 @@
 	document.getElementById("message_header_SORTARRIVAL_"+numBox).innerHTML = get_lang("Date");
 	document.getElementById("message_header_SORTSIZE_"+numBox).innerHTML	= get_lang("Size");	
-	document.getElementById("message_header_"+(sort_box_type.lastIndexOf("SORT") != "-1" ? sort_box_type : "SORTARRIVAL")+"_"+numBox ).innerHTML = "<B>"+type_name+"</B><img src ='templates/default/images/arrow_"+(sort_box_reverse == 1 ? 'desc' : 'asc')+"endant.gif'>";
+	document.getElementById("message_header_"+(sort_box_type.lastIndexOf("SORT") != "-1" ? sort_box_type : "SORTARRIVAL")+"_"+numBox ).innerHTML = "<B>"+type_name+"</B><img src ='templates/"+template+"/images/arrow_"+(sort_box_reverse == 1 ? 'desc' : 'asc')+"endant.gif'>";
 }
 function draw_message(info_msg, ID){
@@ -870,5 +948,5 @@
 	var img_next_msg = document.createElement("IMG");
 	img_next_msg.id = 'msg_opt_next_' + ID;
-	img_next_msg.src = './templates/default/images/down.button.png';
+	img_next_msg.src = './templates/'+template+'/images/down.button.png';
 	img_next_msg.title = get_lang('Next');
 	img_next_msg.style.cursor = 'pointer';
@@ -897,5 +975,5 @@
 				msg_range_begin = (msg_range_end-(preferences.max_email_per_page)+1);
 				kill_current_box();
-				cExecute ('$this.imap_functions.get_range_msgs2&folder='+get_current_folder()+'&msg_range_begin='+msg_range_begin+'&msg_range_end='+msg_range_end+'&sort_box_reverse=1', function handler(data){draw_box(data, get_current_folder());}) */
+				cExecute ('$this.imap_functions.get_range_msgs2&folder='+current_folder+'&msg_range_begin='+msg_range_begin+'&msg_range_end='+msg_range_end+'&sort_box_reverse=1', function handler(data){draw_box(data, current_folder);}) */
 					delete_border(ID);
 			};
@@ -905,5 +983,5 @@
 	var img_previous_msg = document.createElement("IMG");
 	img_previous_msg.id = 'msg_opt_previous_' + ID;
-	img_previous_msg.src = './templates/default/images/up.button.png';
+	img_previous_msg.src = './templates/'+template+'/images/up.button.png';
 	img_previous_msg.title = get_lang('Previous');
 	img_previous_msg.style.cursor = 'pointer';
@@ -966,17 +1044,17 @@
 	td.innerHTML = _name.bold() + ', ' + info_msg.smalldate;
 	if (info_msg.attachments.length > 0)
-		td.innerHTML += "&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+ID+"\").onclick()' src ='templates/default/images/clip.gif' title='"+info_msg.attachments.names+"'>";
+		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+"'>";
 	
 	if (typeof(info_msg.signature) == 'string')
 	{	
 		if (info_msg.signature != "void")
-			td.innerHTML += '&nbsp;<img style="cursor:pointer" onclick="alert(\''+ get_lang("This message is signed, and you can trust.") + info_msg.signature +'\');" src="templates/default/images/signed.gif">';
+			td.innerHTML += '&nbsp;<img style="cursor:pointer" onclick="alert(\''+ get_lang("This message is signed, and you can trust.") + info_msg.signature +'\');" src="templates/'+template+'/images/signed.gif">';
 		else
-			td.innerHTML += "&nbsp;<img style='cursor:pointer' onclick='alert(\""+get_lang("This message is signed, but it is invalid. You should not trust on it.")+"\");' title='"+get_lang("Voided message")+"' src='templates/default/images/invalid.gif'>";
+			td.innerHTML += "&nbsp;<img style='cursor:pointer' onclick='alert(\""+get_lang("This message is signed, but it is invalid. You should not trust on it.")+"\");' title='"+get_lang("Voided message")+"' src='templates/"+template+"/images/invalid.gif'>";
 	}
 	
 	if (info_msg.DispositionNotificationTo)
 	{
-		td.innerHTML += '&nbsp;<img style="cursor:pointer" alt="'+ get_lang('Message with read notification') + '" title="'+ get_lang('Message with read notification') + '" src="templates/default/images/notification.gif">';
+		td.innerHTML += '&nbsp;<img style="cursor:pointer" alt="'+ get_lang('Message with read notification') + '" title="'+ get_lang('Message with read notification') + '" src="templates/'+template+'/images/notification.gif">';
 	}
 	
@@ -985,5 +1063,5 @@
 	{
 	var options = document.createElement("TD");
-	options.width = "100%";
+	options.width = "30%";
 	options.setAttribute("noWrap","true");
 	var option_hide_more = document.createElement("SPAN");
@@ -1012,26 +1090,25 @@
 		}
 	};
-
+	var option_mark = document.createElement('TD');
+	option_mark.align = "left";
+	option_mark.width = "50%";
+	var option_mark_as_unseen = '<span class="message_options" onclick="set_messages_flag(\'unseen\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Unseen")+'.\');">'+get_lang("Unseen")+'</span>, ';
+	var option_mark_as_important = '<span class="message_options" onclick="set_messages_flag(\'flagged\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Important")+'.\');">'+get_lang("Important")+'</span>, ';
+	var option_mark_as_normal = '<span class="message_options" onclick="set_messages_flag(\'unflagged\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Normal")+'.\');">'+get_lang("Normal")+'</span>';
+	option_mark.innerHTML = option_mark_as_unseen+option_mark_as_important+option_mark_as_normal;
 	option_hide_more.innerHTML = get_lang('Options');
 	options.appendChild(option_hide_more);
 	
 	var space0 = document.createElement("SPAN");
-	space0.innerHTML = '&nbsp;';
+	space0.innerHTML = '&nbsp;|&nbsp;';
 	var space1 = document.createElement("SPAN");
-	space1.innerHTML = '&nbsp;';
+	space1.innerHTML = '&nbsp;|&nbsp;';
 	var space2 = document.createElement("SPAN");
-	space2.innerHTML = '&nbsp;';
+	space2.innerHTML = '&nbsp;|&nbsp;';
 	var space3 = document.createElement("SPAN");
-	space3.innerHTML = '&nbsp;';
+	space3.innerHTML = '&nbsp;|&nbsp;';
 	var space4 = document.createElement("SPAN");
-	space4.innerHTML = '&nbsp;';
-
-	var option_print = document.createElement("SPAN");
-	option_print.id = 'msg_opt_print_'+ID;
-	option_print.className = 'message_options';
-	option_print.onclick = function(){print_msg(info_msg.msg_folder,info_msg.msg_number,ID);};
-	option_print.innerHTML = get_lang('Print');
-	options.appendChild(space0);
-	options.appendChild(option_print);
+	space4.innerHTML = '&nbsp;|&nbsp;';
+
 	var option_forward = document.createElement("SPAN");
 	option_forward.id = 'msg_opt_forward_'+ID;
@@ -1048,13 +1125,17 @@
 	options.appendChild(space2);
 	options.appendChild(option_reply);
-	var option_delete = document.createElement("SPAN");
-	option_delete.id = 'msg_opt_delete_'+ID;
-	option_delete.className = 'message_options';
-	option_delete.onclick = function(){proxy_mensagens.delete_msgs(info_msg.msg_folder, info_msg.msg_number, ID);};
-	option_delete.innerHTML = get_lang('Delete');
-	options.appendChild(space3);
-	options.appendChild(option_delete);
+	/* TODO, template == default ? what hell you're doing*/
+	if (template == "default"){
+		var option_delete = document.createElement("SPAN");
+		option_delete.id = 'msg_opt_delete_'+ID;
+		option_delete.className = 'message_options';
+		option_delete.onclick = function(){proxy_mensagens.delete_msgs(info_msg.msg_folder, info_msg.msg_number, ID);};
+		option_delete.innerHTML = get_lang('Delete');
+		options.appendChild(space3);
+		options.appendChild(option_delete);
+	}
 	
 	tr.appendChild(td);
+	tr.appendChild(option_mark);
 	tr.appendChild(options);
 	tr.appendChild(next_previous_msg_td);
@@ -1078,10 +1159,10 @@
 	
 	var option_move							= '<span class="message_options" onclick=wfolders.makeWindow("'+ID+'","move_to");>'+get_lang("Move")+'</span> | ';
-	var option_reply_to_all					= '<span class="message_options" onclick=new_message("reply_to_all_with_history","'+ID+'");>'+get_lang("Reply to all")+'</span> | ';
-	var option_reply_without_history		= '<span class="message_options" onclick=new_message("reply_without_history","'+ID+'");>'+get_lang("Reply without history")+'</span> | ';
-	var option_reply_to_all_without_history	= '<span class="message_options" onclick=new_message("reply_to_all_without_history","'+ID+'");>'+get_lang("Reply to all without history")+'</span> | ';
-	var option_source_msg					= '<span class="message_options" onclick=proxy_mensagens.proxy_source_msg("'+ID+'","'+url_encode(info_msg.msg_folder)+'");>'+get_lang("Message Font")+'</span>';	
-
-	div_other_options.innerHTML = option_mark_as + option_mark_as_unseen + option_mark_as_important + option_mark_as_normal + option_move + option_reply_to_all + option_reply_without_history + option_reply_to_all_without_history + option_source_msg;
+	var option_reply_to_all					= '<span onmouseover="this.className=\'message_options_active\'" onmouseout="this.className=\'message_options\'" class="message_options" onclick=new_message("reply_to_all_with_history","'+ID+'");>'+get_lang("Reply to all")+'</span> | ';
+	var option_reply_without_history		= '<span onmouseover="this.className=\'message_options_active\'" onmouseout="this.className=\'message_options\'" class="message_options" onclick=new_message("reply_without_history","'+ID+'");>'+get_lang("Reply without history")+'</span> | ';
+	var option_reply_to_all_without_history	= '<span onmouseover="this.className=\'message_options_active\'" onmouseout="this.className=\'message_options\'" class="message_options" onclick=new_message("reply_to_all_without_history","'+ID+'");>'+get_lang("Reply to all without history")+'</span> </div>';
+	var option_source_msg =""; //= '<span class="message_options" onclick=source_msg("'+ID+'","'+url_encode(info_msg.msg_folder)+'");>'+get_lang("Message Font")+'</span>';		
+
+	div_other_options.innerHTML = option_reply_to_all + option_reply_without_history + option_reply_to_all_without_history + option_source_msg;
 	if (use_spam_filter) {
 		if(info_msg.msg_folder == 'INBOX'+cyrus_delimiter+'Spam')
@@ -1183,5 +1264,4 @@
 	}
 	
-	
 	var from = document.createElement("TD");
 	from.id = "from_"+ID;
@@ -1196,5 +1276,5 @@
 	from_values.type = "HIDDEN";
 	from_values.value = info_msg.from.full; //Veio do IMAP, sem images nem links.
-	
+
 	var local_message = document.createElement("INPUT");
 	local_message.id = "is_local_"+ID;
@@ -1202,12 +1282,12 @@
 	local_message.type = "HIDDEN";
 	local_message.value = (info_msg.local_message)?"1":"0";
-	
+
 	tr1.appendChild(td1);
 	tr1.appendChild(from);
 	tr1.appendChild(from_values);
 	tr1.appendChild(local_message);
-	
-
-	
+
+
+
 	if (info_msg.reply_to){
 		var tr11 = document.createElement("TR");
@@ -1331,5 +1411,5 @@
 
 			/*
-			 * The function below is ugly, doesn't possible use its.
+			 * The function below is ugly, doesn't possible use this.
 			 * The problem is that the code's function was written
 			 * on a hardcode concept.
@@ -1342,5 +1422,5 @@
 		else{
 			/*
-			 * The function below is ugly, it is not possible to use them.
+			 * The function below is ugly, it is not possible to use this.
 			 * The problem is that the code's function was written
 			 * on a hardcode concept.
@@ -1371,5 +1451,4 @@
 	date_hour.type = "HIDDEN";
 	date_hour.value = info_msg.msg_hour
-	
 	date.className = "header_message_field";
 	tr4.appendChild(td4);
@@ -1390,5 +1469,4 @@
 	tr5.appendChild(subject);
 	tbody_message_others_options.appendChild(tr5);
-
 	if (info_msg.attachments.length > 0){
 		var tr6 = document.createElement("TR");
@@ -1428,4 +1506,5 @@
 			attachments.appendChild(zipped_attachments);
 		}
+
 		attachments.id = "attachments_" + ID;
 		for (var i=0; i<info_msg.attachments.length; i++){
@@ -1444,5 +1523,5 @@
 				//Link para importar calendário
 				var link_import_attachment = new Image();
-				link_import_attachment.src = "templates/default/images/new.png";
+				link_import_attachment.src = "templates/"+template+"/images/new.png";
 				link_import_attachment.setAttribute("onclick","javascript:import_calendar('"+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"&idx_file="+i+"&encoding="+info_msg.attachments[i].encoding+"');");
 				link_import_attachment.title = get_lang("Import to calendar");
@@ -1456,6 +1535,6 @@
 			}
 			else {
-			link_attachment.innerHTML += '<BR>';
-			attachments.appendChild(link_attachment);
+				link_attachment.innerHTML += '<BR>';
+				attachments.appendChild(link_attachment);
 			}
 		}
@@ -1469,11 +1548,11 @@
 	var bar = document.getElementById("toolbar");
 	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;		
+	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 - 80;
+	content.style.height = document.body.clientHeight - offset - 90;
 	div.style.overflow = "auto";
 	div.style.width = defaultWidth - (is_ie ? 5 : 0);
@@ -1484,4 +1563,37 @@
 	td.colSpan = '2';
 	div.appendChild(table_message_others_options);
+	var imgTag = info_msg.body.match(/(<img[^>]*src[^=]*=['"][^'"]*["'][^>]*>)|(<td[^>]*background[^=]*=['"][^'"]*["'][^>]*>)/gi);
+	var newBody = info_msg.body;
+	if(!info_msg.showImg && imgTag)
+	{
+		var domains = '';
+		var blocked = false;
+		var forbidden = true;
+		if (preferences.notification_domains != undefined && preferences.notification_domains != "")
+			domains = preferences.notification_domains.split(',');
+		for(var j = 0; j < imgTag.length; j++)
+		{
+			for (var i = 0; i < domains.length; i++)
+			{
+				imgSource = imgTag[j].match(/=['"](http:\/\/)+[^'"\/]*/);
+				if (imgSource && imgSource.toString().substr(5).match(domains[i]))
+					forbidden = false;
+			}
+			if (forbidden)
+			{
+				newBody = newBody.replace(imgTag[j],"<img src='templates/"+template+"/images/forbidden.png'>");
+				blocked=true;
+			}
+		}
+		if (blocked)
+		{
+			var showImgLink = document.createElement('DIV');
+			showImgLink.id="show_img_link";
+			showImgLink.onclick = function () { cExecute('$this.imap_functions.get_info_msg&msg_number='+info_msg.msg_number+'&msg_folder='+info_msg.msg_folder,show_msg_img); };
+			showImgLink.className="show_img_link";
+			showImgLink.innerHTML = get_lang("Show images from")+": "+info_msg.from.email;
+			td.appendChild(showImgLink);
+		}
+	}
 	td.appendChild(div);
 	tr.appendChild(td)
@@ -1491,12 +1603,12 @@
 	//////////////////////////////////////////////////////////////////////////////////////////////////////	
 	//Make the body message.
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
+	///////////////////////////////////////////////////////////////////////////////////////////////////////
 	var tr = document.createElement("TR");
 	tr.className = "tr_message_body";
 	var td = document.createElement("TD");
 	//td.setAttribute("colSpan","2");
-	info_msg.body = info_msg.body.replace("<body","<span");
-	info_msg.body = info_msg.body.replace("<BODY","<span");
-	div.innerHTML+= "<span id='body_"+ID+"'>"+info_msg.body+"</span><br><br>";
+	newBody = newBody.replace("<body","<span");
+	newBody = newBody.replace("<BODY","<span");
+	div.innerHTML+= "<span id='body_"+ID+"'>"+newBody+"</span><br><br>";
 	//////////////////////////////////////////////////////////////////////////////////////////////////////	
 	//Make the thumbs of the message.
@@ -1526,5 +1638,5 @@
 		}
 		
-		td.innerHTML +=	"<BR><img src='templates/default/images/menu/ktip.png'>"+get_lang("<b>Tip:</b> For faster save, click over the image with <u>right button</u>.");
+		td.innerHTML +=	"<BR><img src='templates/"+template+"/images/menu/ktip.png'>"+get_lang("<b>Tip:</b> For faster save, click over the image with <u>right button</u>.");
 		td.innerHTML += "<BR>";
 
@@ -1550,4 +1662,5 @@
 	//////////////////////////////////////////////////////////////////////////////////////////////////////
 }
+
 function draw_new_message(border_ID){
 	var ID = create_border("",border_ID);
@@ -1699,5 +1812,5 @@
 	
 	var img_search = document.createElement("IMG");
-	img_search.src = "./templates/default/images/search.gif";
+	img_search.src = "./templates/"+template+"/images/search.gif";
 	img_search.title = get_lang('Search') + " | " + get_lang('Use F9 Key as shortcut.');
 	img_search.onclick = function () {emQuickSearch(document.getElementById('to_'+ID).value, 'to', ID);};
@@ -1782,5 +1895,5 @@
 	td_cc.appendChild(input_cc);
 	var img_search = document.createElement("IMG");
-	img_search.src = "./templates/default/images/search.gif";
+	img_search.src = "./templates/"+template+"/images/search.gif";
 	img_search.onclick = function () {emQuickSearch(document.getElementById('cc_'+ID).value, 'cc', ID)}
 	img_search.title = get_lang('Search') + " | " + get_lang('Use F9 Key as shortcut.');
@@ -1865,5 +1978,5 @@
 	td_cco.appendChild(input_cco);
 	var img_search = document.createElement("IMG");
-	img_search.src = "./templates/default/images/search.gif";
+	img_search.src = "./templates/"+template+"/images/search.gif";
 	img_search.title = get_lang('Search') + " | " + get_lang('Use F9 Key as shortcut.');	
 	img_search.onclick = function () {emQuickSearch(document.getElementById('cco_'+ID).value, 'cco', ID);};
@@ -1962,4 +2075,5 @@
 		tbody_message.appendChild(trn);
 	}
+
 	var add_files = document.createElement("A");
 	add_files.setAttribute("href", "javascript:void(0)");
@@ -2006,8 +2120,6 @@
 	var _div = document.createElement("DIV");
 	_div.id = "div_message_scroll_"+ID;
-//	_div.style.background = 'WHITE';
 	_div.style.height = document.body.clientHeight - _offset - 105;
 	content.style.height = document.body.clientHeight - _offset - 80;
-	
 	_div.style.overflow = "auto";
 	_div.style.width = defaultWidth;
@@ -2179,5 +2291,5 @@
 	td21.height="15";
 	td22 = document.createElement("TD");	
-	td21.setAttribute("background","templates/default/images/dsunused.gif");
+	td21.setAttribute("background","templates/"+template+"/images/dsunused.gif");
 	table221 = document.createElement("TABLE");
 	tbody221 = document.createElement("TBODY");
@@ -2196,10 +2308,10 @@
 		else
 			write_msg(get_lang("Warning: Your Mailbox is almost full!"));
-		td221.setAttribute("background","templates/default/images/dsalert.gif");
+		td221.setAttribute("background","templates/"+template+"/images/dsalert.gif");
 	}
 	else if(value > 80)
-		td221.setAttribute("background","templates/default/images/dswarn.gif");
+		td221.setAttribute("background","templates/"+template+"/images/dswarn.gif");
 	else
-		td221.setAttribute("background","templates/default/images/dsused.gif");
+		td221.setAttribute("background","templates/"+template+"/images/dsused.gif");
 	
 	tr221.appendChild(td221);
@@ -2231,5 +2343,6 @@
 	for (var i=0; i<(headers_msgs.length); i++){
 		var tr = this.make_tr_message(headers_msgs[i], headers_msgs[i].msg_folder);
-		tbody.appendChild(tr);
+		if (tr)
+			tbody.appendChild(tr);
 	}
 }
@@ -2291,5 +2404,5 @@
 	td_element5.align = "center";
 	td_element5.innerHTML = "<B>"+get_lang("Date")+"</B>";	
-	td_element5.innerHTML += "<img src ='templates/default/images/arrow_descendant.gif'>";
+	td_element5.innerHTML += "<img src ='templates/"+template+"/images/arrow_descendant.gif'>";
 	td_element6 = document.createElement("TD");
 	td_element6.setAttribute("width", "10%");
@@ -2386,5 +2499,6 @@
 }
 	var idx_cc = 0;
-function draw_plugin_cc(ID, addrs)	{
+function draw_plugin_cc(ID, addrs)
+{
 	connector.loadScript("ccQuickAdd");
 
@@ -2416,5 +2530,5 @@
 	
 	var sm_envelope_img1 = '<img style="cursor:'+ (is_ie ? 'hand' : 'pointer') +'" title="' + get_lang("Add Contact") +
-	'" onclick="ccQuickAddOne.showList(\''+cc_data+'\')" src="./templates/default/images/user_card.png">';
+	'" onclick="ccQuickAddOne.showList(\''+cc_data+'\')" src="./templates/'+template+'/images/user_card.png">';
 	var to_addybook_add = "<SPAN id='insert_plugin_"+idx_cc+"_"+ID+"'>";
 	to_addybook_add += addrs;
@@ -2432,5 +2546,5 @@
 		dn_em.setAttribute("title",get_lang("Block Sender"));
 		dn_em.style.cursor = "pointer";		
-		dn_em.innerHTML = "<img align='top' onclick=filter.new_rule('"+email+"') src='./templates/default/images/deny.gif'>";
+		dn_em.innerHTML = "<img align='top' onclick=filter.new_rule('"+email+"') src='./templates/"+template+"/images/deny.gif'>";
 	return dn_em;
 	
@@ -2470,18 +2584,22 @@
 	}
 
-	span_options.innerHTML = 
-		'<span title="'+get_lang("Delete")+'" style="margin-left:8px" class="message_options" onclick=proxy_mensagens.delete_msgs(\'null\',\'selected\',\'null\')>'+get_lang("Delete")+'</span> | '+
-		'<span title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"\",\"move_to\")>'+get_lang("Move")+'</span> | '+
-   		'<span title="'+get_lang("Print")+'" class="message_options" onclick=print_all()>'+get_lang("Print")+'</span> | '+
-	   	'<span title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span> | ' + 
-	   	'<span title="'+get_lang("Import")+'" class="message_options" onclick="import_window()">'+get_lang("Import")+'</span>';
+	var change_font_color = 'onmouseover="var last_class = this.className;'+
+				'this.className=\'message_options_active\';'+
+				'this.onmouseout=function(){this.className=last_class;}"';
+
+	span_options.innerHTML =
+		'<span class="message_options_trash"><span ' + change_font_color + ' title="'+get_lang("Delete")+'" class="message_options" onclick=proxy_mensagens.delete_msgs(\'null\',\'selected\',\'null\')>'+get_lang("Delete")+'</span></span>'+
+		'<span class="message_options_move"><span ' + change_font_color + ' title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"\",\"move_to\")>'+get_lang("Move")+'</span></span>'+
+   		'<span class="message_options_print"><span ' + change_font_color + ' title="'+get_lang("Print")+'" class="message_options" onclick=print_all()>'+get_lang("Print")+'</span></span>'+
+		'<span class="message_options_export"><span ' + change_font_color + ' title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span></span>' +
+		'<span class="message_options_import"><span ' + change_font_color + ' title="'+get_lang("Import")+'" class="message_options" onclick="import_window()">'+get_lang("Import")+'</span></span>';
 	if(preferences.use_local_messages==1)
-		span_options.innerHTML += ' | <span title="'+get_lang("Archive")+'" class="message_options" onclick="archive_msgs(\''+folder+'\',null)">'+get_lang("Archive")+'</span>';
+		span_options.innerHTML += '&nbsp;<span ' + change_font_color + ' title="'+get_lang("Archive")+'" class="message_options" onclick="archive_msgs(\''+folder+'\',null)">'+get_lang("Archive")+'</span>';
 	if (use_spam_filter) {
-		if ( get_current_folder() == 'INBOX'+cyrus_delimiter+'Spam' )	{
-			span_options.innerHTML += ' | <span title="'+get_lang("Not Spam")+'" class="message_options" onclick="nospam(\'selected\',\'null\',\'null\')">'+get_lang("Not Spam")+'</span>';
+		if ( current_folder == 'INBOX'+cyrus_delimiter+'Spam' )	{
+			span_options.innerHTML += ' | <span ' + change_font_color + ' title="'+get_lang("Not Spam")+'" class="message_options" onclick="nospam(\'selected\',\'null\',\'null\')">'+get_lang("Not Spam")+'</span>';
 		}
 		else {
-			span_options.innerHTML += ' | <span title="'+get_lang("Mark as Spam")+'" class="message_options" onclick="spam(\'null\', \'selected\',\'null\')">'+get_lang("Mark as Spam")+'</span>';
+			span_options.innerHTML += ' | <span ' + change_font_color + ' title="'+get_lang("Mark as Spam")+'" class="message_options" onclick="spam(\'null\', \'selected\',\'null\')">'+get_lang("Mark as Spam")+'</span>';
 		}
 	}
@@ -2496,9 +2614,9 @@
 	span_D.innerHTML = 
    		 get_lang("List")+': '+
-   	'<span id="span_flag_SORTARRIVAL" style="'+(search_box_type == 'ALL' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("All")+'" class="message_options" onclick="if(\'ALL\' == \''+search_box_type+'\') return false;sort_box(\'ALL\',\''+sort_box_type+'\')">'+get_lang("All")+'</span>, '+
-   	'<span id="span_flag_UNSEEN" style="'+(search_box_type == 'UNSEEN' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("l_unseen")+'" class="message_options" onclick="if(\'UNSEEN\' == \''+search_box_type+'\') return false;sort_box(\'UNSEEN\',\''+sort_box_type+'\')">'+get_lang("l_unseen")+'</span>, '+
-  	'<span id="span_flag_SEEN" style="'+(search_box_type == 'SEEN' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("l_seen")+'" class="message_options" onclick="if(\'SEEN\' == \''+search_box_type+'\') return false;sort_box(\'SEEN\',\''+sort_box_type+'\')">'+get_lang("l_seen")+'</span>, '+
-   	'<span id="span_flag_ANSWERED" style="'+(search_box_type == 'ANSWERED' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("l_answered")+'" class="message_options" onclick="if(\'ANSWERED\' == \''+search_box_type+'\') return false;sort_box(\'ANSWERED\',\''+sort_box_type+'\')">'+get_lang("l_answered")+'</span>, '+
-   	'<span id="span_flag_FLAGGED" style="'+(search_box_type == 'FLAGGED' ? 'font-weight:bold;text-decoration:underline' : '')+'" title="'+get_lang("l_important")+'" class="message_options" onclick="if(\'FLAGGED\' == \''+search_box_type+'\') return false;sort_box(\'FLAGGED\',\''+sort_box_type+'\')">'+get_lang("l_important")+'</span>&nbsp;&nbsp;';
+   	'<span ' + change_font_color + ' id="span_flag_SORTARRIVAL" class="'+(search_box_type == 'ALL' ? 'message_options_over' : 'message_options')+'" title="'+get_lang("All")+'" onclick="if(\'ALL\' == \''+search_box_type+'\') return false;sort_box(\'ALL\',\''+sort_box_type+'\')">'+get_lang("All")+'</span>, '+
+   	'<span ' + change_font_color + ' id="span_flag_UNSEEN" class="'+(search_box_type == 'UNSEEN' ? 'message_options_over' : 'message_options')+'" title="'+get_lang("l_unseen")+'" onclick="if(\'UNSEEN\' == \''+search_box_type+'\') return false;sort_box(\'UNSEEN\',\''+sort_box_type+'\')">'+get_lang("l_unseen")+'</span>, '+
+  	'<span ' + change_font_color + ' id="span_flag_SEEN" class="'+(search_box_type == 'SEEN' ? 'message_options_over' : 'message_options')+'" title="'+get_lang("l_seen")+'" onclick="if(\'SEEN\' == \''+search_box_type+'\') return false;sort_box(\'SEEN\',\''+sort_box_type+'\')">'+get_lang("l_seen")+'</span>, '+
+   	'<span ' + change_font_color + ' id="span_flag_ANSWERED" class="'+(search_box_type == 'ANSWERED' ? 'message_options_over' : 'message_options')+'" title="'+get_lang("l_answered")+'" onclick="if(\'ANSWERED\' == \''+search_box_type+'\') return false;sort_box(\'ANSWERED\',\''+sort_box_type+'\')">'+get_lang("l_answered")+'</span>, '+
+   	'<span ' + change_font_color + ' id="span_flag_FLAGGED" class="'+(search_box_type == 'FLAGGED' ? 'message_options_over' : 'message_options')+'" title="'+get_lang("l_important")+'" onclick="if(\'FLAGGED\' == \''+search_box_type+'\') return false;sort_box(\'FLAGGED\',\''+sort_box_type+'\')">'+get_lang("l_important")+'</span>&nbsp;&nbsp;';
 	draw_paging(num_msgs);
 	Element("tot_m").innerHTML = num_msgs;	
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/doiMenuData.js
===================================================================
--- trunk/expressoMail1_2/js/doiMenuData.js	(revision 689)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/doiMenuData.js	(revision 773)
@@ -1,3 +1,3 @@
-_icon_dir="templates/default/images/menu/";
+_icon_dir="templates/"+template+"/images/menu/";
 
 function ConstructMenuTools(){
@@ -85,5 +85,5 @@
 		var _tr = document.createElement("TR");
 		var _td = document.createElement("TD");
-		_td.innerHTML = "<img height=\"16px\" src=\"templates/default/images/menu/"+item[2]+"\">&nbsp;"+item[1]+"&nbsp;";
+		_td.innerHTML = "<img height=\"16px\" src=\"templates/"+template+"/images/menu/"+item[2]+"\">&nbsp;"+item[1]+"&nbsp;";
 		_td.style.color = "DARKBLUE";
 		_td.style.cursor = "pointer";
@@ -152,11 +152,11 @@
 		var _sep = "<hr>";
 		var optionsMenu = new Array( 
-			_tab + get_lang("Mark as")+"&nbsp;"+get_lang('seen')+'|'+"proxy_mensagens.proxy_set_messages_flag('seen','get_selected_messages')",
-			_tab + get_lang("Mark as")+"&nbsp;"+get_lang('unseen')+'|'+"proxy_mensagens.proxy_set_messages_flag('unseen','get_selected_messages')",
-			_tab + get_lang("Mark as")+"&nbsp;"+get_lang('important')+'|'+"proxy_mensagens.proxy_set_messages_flag('flagged','get_selected_messages')",
-			_tab + get_lang("Mark as")+"&nbsp;"+get_lang('normal')+'|'+"proxy_mensagens.proxy_set_messages_flag('unflagged','get_selected_messages')",
+			_tab + get_lang("Mark as")+"&nbsp;"+get_lang('seen')+'|'+"set_messages_flag('seen','get_selected_messages')",
+			_tab + get_lang("Mark as")+"&nbsp;"+get_lang('unseen')+'|'+"set_messages_flag('unseen','get_selected_messages')",
+			_tab + get_lang("Mark as")+"&nbsp;"+get_lang('important')+'|'+"set_messages_flag('flagged','get_selected_messages')",
+			_tab + get_lang("Mark as")+"&nbsp;"+get_lang('normal')+'|'+"set_messages_flag('unflagged','get_selected_messages')",
 			_sep,
 			_tab + get_lang("Move to")+" ... |wfolders.makeWindow('', 'move_to')",
-			_tab + get_lang("Delete")+"|"+"proxy_mensagens.delete_msgs('null','selected','null')",
+			_tab + get_lang("Delete")+"|"+"delete_msgs('null','selected','null')",
 			_tab + get_lang("Export")+"|"+"export_all_selected_msgs()"
 		);
Index: sandbox/expresso/novos_templates/expressoMail1_2/js/rich_text_editor.js
===================================================================
--- trunk/expressoMail1_2/js/rich_text_editor.js	(revision 690)
+++ sandbox/expresso/novos_templates/expressoMail1_2/js/rich_text_editor.js	(revision 773)
@@ -34,6 +34,6 @@
 	}
 
-	document.getElementById('fontname').selectedIndex = 1;
-	document.getElementById('fontsize').selectedIndex = 1;
+	document.getElementById('fontname').selectedIndex = 3;
+	document.getElementById('fontsize').selectedIndex = 3;
 }
 
@@ -47,4 +47,12 @@
 		iframe.setAttribute("unselectable","on");
 		iframe.setAttribute("tabIndex","1");
+
+		config_events( iframe, 'onload', function( )
+		{
+			iframe.contentWindow.document.designMode = "on";
+			if ( iframe.contentWindow.document.documentElement )
+				iframe.contentWindow.document.documentElement.style.background = '#fff';
+		});
+
 		var checkbox = document.createElement("INPUT");
 		checkbox.id = 'viewsource_rt_checkbox';
@@ -170,5 +178,5 @@
 		img.className = 'imagebutton';
 		img.align = 'center';
-		img.src = './templates/default/images/'+buttons[i]+'.gif';
+		img.src = './templates/'+template+'/images/'+buttons[i]+'.gif';
 		img.title = get_lang(buttons[i]);
 		img.style.cursor = 'pointer';
@@ -352,7 +360,7 @@
 		form_table.innerHTML = get_lang('Select the table size')+':<br><br><table cellspacing="0"><tbody><tr><td align="center">'+
 								get_lang('Rows')+':</td><td></td><td align="center">'+get_lang('Cols')+':</td><td></td><td align="center">'+get_lang('Border')+':</td></tr>'+
-									'<tr><td align="right"><input type="text" readonly="true" id="rows" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/default/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'rows\');"></img><br><img src="templates/default/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'rows\');"></img></td>'+
-									'<td align="right"><input type="text" readonly="true" id="cols" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/default/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'cols\');"></img><br><img src="templates/default/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'cols\');"></img></td>'+
-									'<td align="right"><input type="text" readonly="true" id="border" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/default/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'border\');"></img><br><img src="templates/default/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'border\');"></img></td>'+
+									'<tr><td align="right"><input type="text" readonly="true" id="rows" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/'+template+'/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'rows\');"></img><br><img src="templates/'+template+'/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'rows\');"></img></td>'+
+									'<td align="right"><input type="text" readonly="true" id="cols" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/'+template+'/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'cols\');"></img><br><img src="templates/'+template+'/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'cols\');"></img></td>'+
+									'<td align="right"><input type="text" readonly="true" id="border" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/'+template+'/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'border\');"></img><br><img src="templates/'+template+'/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'border\');"></img></td>'+
 									'</tr></tbody></table>'+
 	  								'&nbsp;&nbsp;&nbsp;<input title="'+get_lang('Close')+'"  value="' + get_lang('Close') + '" type="button" onclick="win.close()">&nbsp;'+
Index: sandbox/expresso/novos_templates/expressoMail1_2/index.php
===================================================================
--- trunk/expressoMail1_2/index.php	(revision 689)
+++ sandbox/expresso/novos_templates/expressoMail1_2/index.php	(revision 773)
@@ -34,4 +34,8 @@
 	include('../header.inc.php');
 	$update_version = $GLOBALS['phpgw_info']['flags']['update_version'];
+	$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
+	echo '<link rel="stylesheet" type="text/css" href="templates/'.$_SESSION['phpgw_info']['expressoMail1_2']['user']['preferences']['common']['template_set'].'/main.css">';
+	echo '<link rel="stylesheet" type="text/css" href="../phpgwapi/js/dftree/dftree.css">';
+	echo "<script type='text/javascript'>var template = '".$_SESSION['phpgw_info']['expressoMail1_2']['user']['preferences']['common']['template_set']."';</script>";
 	echo "<script src='js/globals.js?".$update_version."' type='text/javascript'></script>";
 	echo "<script src='js/sniff_browser.js?".$update_version."' type='text/javascript'></script>";
@@ -41,6 +45,5 @@
 	//Enable/Disable VoIP Service -> Voip Server Config
 	$voip_enabled = false;
-	$voip_groups = array();
-	
+	$voip_groups = array();	
 	if($GLOBALS['phpgw_info']['server']['voip_groups']) {
 		$emailVoip = false;
@@ -71,5 +74,5 @@
 
 	$_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
-	$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
+//	$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
 	$_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
 	$_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null;
@@ -100,5 +103,5 @@
     		'use_shortcuts' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'] : "0",
     		'auto_save_draft'					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] : "0",
- 		'use_dynamic_contacts' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] : "0",
+		'use_dynamic_contacts' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] : "0",
 		'number_of_contacts' 					=> $current_config['expressoMail_Number_of_dynamic_contacts'] ? $current_config['expressoMail_Number_of_dynamic_contacts'] : "0",
 		'use_cache' 						=> $current_config['expressoMail_enable_cache'],
@@ -106,10 +109,10 @@
 		'remove_attachments_function'				=> $current_config['expressoMail_remove_attachments_function'],
 		'use_important_flag'					=> $current_config['expressoMail_enable_important_flag'],
-   		'use_local_messages'	 			=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'] : "0",			
+   		'use_local_messages'	 			=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'] : "0",
    		'keep_archived_messages'	 		=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_archived_messages'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_archived_messages'] : "0"
 
 
 
-    		
+
 	);
 
@@ -167,5 +170,5 @@
     var draftsfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'].'";
     var sentfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'].'";
-    var spamfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'].'";                      
+    var spamfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'].'";                 
     </script>';
 
@@ -175,8 +178,12 @@
 
 	$obj = createobject("expressoMail1_2.functions");
+	// este arquivo deve ser carregado antes que
+	// os demais pois nele contem a função get_lang
+	// que é utilizada em diversas partes
+	echo $obj -> getFilesJs("js/common_functions.js");
 	include("inc/load_lang.php");		
+
 	// INCLUDE these JS Files: 
 	echo $obj -> getFilesJs("js/abas.js," .
-							"js/common_functions.js," .
 							"js/doiMenuData.js," .
 							"js/drag_area.js," .
@@ -203,4 +210,5 @@
 		echo "<script>location.href='./preferences.php'</script>";
 	}	
+
 ?>
 
@@ -208,5 +216,4 @@
 <head>
 <title>ExpressoMail</title>
-<link rel="stylesheet" type="text/css" href="templates/default/main.css">
 <link rel="stylesheet" type="text/css" href="../phpgwapi/js/dftree/dftree.css">
 </head>
Index: sandbox/expresso/novos_templates/expressoMail1_2/templates/default/main.css
===================================================================
--- trunk/expressoMail1_2/templates/default/main.css	(revision 220)
+++ sandbox/expresso/novos_templates/expressoMail1_2/templates/default/main.css	(revision 773)
@@ -47,5 +47,18 @@
 	background-color: #5194d2;
 }
+.show_img_link{
+	width : 100%;
+	color: black;
+        font-weight: bold;
+	background-color: #ffc;
+	border-bottom:1px solid #cfcfcf;
+	cursor: pointer;		 
+	-moz-user-select: none;
+}
 /* end class msgs */
+
+.show_img_link:hover {
+	color: #000 !important;
+}
 
 .action_info_table {
@@ -357,4 +370,30 @@
 	color: blue;
 	white-space: nowrap;
+	/*padding:0 1.8;*/
+}
+.message_options_trash,
+.message_options_import,
+.message_options_export,
+.message_options_print,
+.message_options_move {
+        padding:0pt 1pt 1pt 8pt;
+}
+.message_options_inactive {
+         white-space: nowrap;
+        color: #999;
+}
+
+.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;
 }
 
@@ -423,2 +462,22 @@
 	height:15px !important;
 }
+
+
+
+.l {
+	background-image: url() !important;
+	padding: 0 13 0 0 !important;
+	font-weight: bold !important;
+	font-size: 10px !important;
+	color: #666 !important;
+	text-decoration: none !important;
+	font-family: sans-serif !important;
+}
+.sl {
+	background-image: url() !important; 
+	padding: 0 13 0 0 !important;
+	font-weight: bold !important;
+	font-size: 10px !important;
+	color: #0000FF !important;
+	font-family: sans-serif !important;
+}
Index: sandbox/expresso/novos_templates/expressoMail1_2/templates/default/error.html
===================================================================
--- trunk/expressoMail1_2/templates/default/error.html	(revision 446)
+++ sandbox/expresso/novos_templates/expressoMail1_2/templates/default/error.html	(revision 773)
