Index: /branches/2.1/expressoMail1_2/templates/classic/index.tpl
===================================================================
--- /branches/2.1/expressoMail1_2/templates/classic/index.tpl	(revision 2538)
+++ /branches/2.1/expressoMail1_2/templates/classic/index.tpl	(revision 2625)
@@ -70,5 +70,5 @@
 						<tbody id="border_tbody">
 							<tr id="border_tr">
-								<td nowrap class="menu" onClick="alternate_border(0);"  id="border_id_0">&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">0</span> / <span id="tot_m">0</span>]</font>
+								<td nowrap class="menu" onClick="alternate_border(0);resizeWindow();"  id="border_id_0">&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">[<span id="new_m">0</span> / <span id="tot_m">0</span>]</font>
 								</td>
 								<td nowrap id="border_blank" class="last_menu" width="100%">&nbsp;</td>								
Index: /branches/2.1/expressoMail1_2/templates/default/index.tpl
===================================================================
--- /branches/2.1/expressoMail1_2/templates/default/index.tpl	(revision 2538)
+++ /branches/2.1/expressoMail1_2/templates/default/index.tpl	(revision 2625)
@@ -97,5 +97,5 @@
 				<tbody id="border_tbody">
 					<tr id="border_tr">
-						<td nowrap class="menu" onClick="alternate_border(0);"  id="border_id_0">
+						<td nowrap class="menu" onClick="alternate_border(0);resizeWindow();"  id="border_id_0">
 							&nbsp;{lang_inbox}&nbsp;<font face="Verdana" size="1" color="#505050">[
 							<span id="new_m">0</span> / 
Index: /branches/2.1/expressoMail1_2/js/abas.js
===================================================================
--- /branches/2.1/expressoMail1_2/js/abas.js	(revision 2203)
+++ /branches/2.1/expressoMail1_2/js/abas.js	(revision 2625)
@@ -125,5 +125,5 @@
 
 	td.setAttribute("align", "right");
-	td.onclick = function(){alternate_border(ID);};
+	td.onclick = function(){alternate_border(ID);resizeWindow()};
 	td.setAttribute("noWrap","true");
         td.alt = borderTitle;
@@ -153,20 +153,5 @@
 	div.style.display='';
 
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden')
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;
-
-	div.style.height = document.body.clientHeight - offset - (is_ie ? 76 : 86);
 	div.style.overflow = "hidden";
-
-	if(!is_ie) {
-		var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-		var defaultWidth = document.body.clientWidth - 27;
-		if(!menuHidden)
-			defaultWidth -= Element("folderscol").offsetWidth;
-
-		div.style.width = defaultWidth;
-	}
 	Element("exmail_main_body").insertBefore(div,Element("footer_menu"));
 	alternate_border(ID);
@@ -274,4 +259,5 @@
 	content = Element('content_id_' + ID);
 	content.parentNode.removeChild(content);
+	resizeWindow();
 	return true;
 }
Index: /branches/2.1/expressoMail1_2/js/common_functions.js
===================================================================
--- /branches/2.1/expressoMail1_2/js/common_functions.js	(revision 2401)
+++ /branches/2.1/expressoMail1_2/js/common_functions.js	(revision 2625)
@@ -1,3 +1,2 @@
-// BEGIN: FUNCTION RESIZE WINDOW
 if (!expresso_offline) {
 	var _showBar = showBar;
@@ -32,14 +31,15 @@
     }
 }
-
+// BEGIN: FUNCTION RESIZE WINDOW
 function resizeWindow(){
-
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);	
-
-	var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
-	var defaultHeight = screenHeight - offset;
+	var divScrollMain = Element("divScrollMain_"+numBox);
+	var table_message = Element("table_message");
+	var content_folders = Element("content_folders");
+	var clientHeight = ((window.innerHeight ? window.innerHeight : document.body.offsetHeight) - 8);
+	var clientWidth = ((window.innerWidth ? window.innerWidth : document.body.offsetWidth));	
+
+	if(divScrollMain){
+		divScrollMain.style.height = (clientHeight - (findPosY(divScrollMain) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight))) + "px";
+	}
 
 	if(typeof(BordersArray) != 'undefined') {
@@ -47,19 +47,20 @@
 			var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence);
 			var div = Element("content_id_"+BordersArray[i].sequence);
-
-			// This comented code cause/avoid (!?) Firefox to stuck some request
-			if(div)
-//				div.setAttribute("style","height: "+parseInt(defaultHeight - 90)+"px;");
-				div.style.height = defaultHeight - 90;
-			if(div_scroll)
-//				div_scroll.setAttribute("style","height: "+parseInt(defaultHeight - 130)+"px;");
-				div_scroll.style.height = defaultHeight - 130;
-		}
-	}
-
-	if(Element('content_folders'))
-		Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150);
-	if(Element("divScrollMain_"+numBox))
-		Element("divScrollMain_"+numBox).style.height 	= defaultHeight - (is_ie ? 111 : 110);
+			if(div){
+				div.style.height = (clientHeight - (findPosY(div) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+2)) + "px";
+				div.style.width = (clientWidth - (findPosX(div)+10)) + "px";
+			}
+			if(div_scroll){
+				div_scroll.style.height = (clientHeight - (findPosY(div_scroll) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+5)) + "px";
+				div_scroll.style.width = (clientWidth - (findPosX(div_scroll)+10)) + "px";
+			}
+		}
+	}
+
+	if(content_folders){
+		var search_div = Element("search_div");
+		var contentFoldersY = findPosY(content_folders);
+		content_folders.style.height = (clientHeight - (contentFoldersY + (contentFoldersY > findPosY(search_div) ? 0 : (search_div.clientHeight ? search_div.clientHeight : search_div.offsetHeight) + 5))) + "px";
+	}
 }
 // END: FUNCTION RESIZE WINDOW
Index: /branches/2.1/expressoMail1_2/js/main.js
===================================================================
--- /branches/2.1/expressoMail1_2/js/main.js	(revision 2524)
+++ /branches/2.1/expressoMail1_2/js/main.js	(revision 2625)
@@ -318,6 +318,8 @@
 
 		
-		if(Element("border_id_" + id_msg_read)) 
-			alternate_border(id_msg_read);		
+		if(Element("border_id_" + id_msg_read)){ 
+			alternate_border(id_msg_read);
+			resizeWindow();
+		}
 		else {
 			var border_id = create_border(msg_info.subject, id_msg_read);
Index: /branches/2.1/expressoMail1_2/js/search.js
===================================================================
--- /branches/2.1/expressoMail1_2/js/search.js	(revision 1970)
+++ /branches/2.1/expressoMail1_2/js/search.js	(revision 2625)
@@ -549,21 +549,7 @@
 
 	var content_search =  Element('content_id_search_' + numBox);
-	// BEGIN MAKE THE SCROLL HEIGHT		
-	var defaultWidth = document.body.offsetWidth - 31;
-	var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-	if(!menuHidden)
-		defaultWidth -= Element("folderscol").offsetWidth;			
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;		
 	var div_scroll_result = document.createElement("DIV");
 	div_scroll_result.id = "divScrollMain_"+numBox;
-	div_scroll_result.style.height = document.body.clientHeight - offset - 120;
-	content_search.style.height = document.body.clientHeight - offset - 80;
 	div_scroll_result.style.overflow = "auto";
-	div_scroll_result.style.width = defaultWidth - (is_ie ? 7 : 0);
-	// END MAKE THE SCROLL HEIGHT		
-		
 	
 		if(is_ie)
@@ -710,4 +696,5 @@
 			content_search.appendChild(div_scroll_result);
 		}
+		resizeWindow();
 	}
 
Index: /branches/2.1/expressoMail1_2/js/draw_api.js
===================================================================
--- /branches/2.1/expressoMail1_2/js/draw_api.js	(revision 2524)
+++ /branches/2.1/expressoMail1_2/js/draw_api.js	(revision 2625)
@@ -698,7 +698,4 @@
 	var _divScroll = document.getElementById("divScrollMain_"+numBox);
 
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
-
 	if(!_divScroll){		
 		_divScroll = document.createElement("DIV");
@@ -714,14 +711,4 @@
 		_divScroll.style.width	="99.3%";
 	}
-	// Inicio: Redimensiona DIV SCROLL
-	var bar = Element("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden') 
-		offset = (bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight);		
-	var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
-	var defaultHeight = screenHeight - offset;		
-	_divScroll.style.height 	= defaultHeight - 110;
-	Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150);
-	// Fim: Redimensiona DIV SCROLL
 	_divScroll.appendChild(table_element);
 	openTab.content_id[numBox].appendChild(_divScroll);
@@ -765,4 +752,8 @@
 	draw_footer_box(headers_msgs.num_msgs);	
 	Element('main_table').style.display = '';
+	if(is_ie6)	// Stupid Fixing on IE6.
+		setTimeout("resizeWindow()",1);
+	else
+		resizeWindow();
 	if(debug) {
 		var _eTime = new Date();
@@ -1092,9 +1083,5 @@
 function draw_message(info_msg, ID){
 	var content = document.getElementById('content_id_' + ID);
-	var defaultWidth = document.body.offsetWidth - 37;
-	
 	var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
-	if(!menuHidden)
-		defaultWidth -= Element("folderscol").offsetWidth;
 	 //////////////////////////////////////////////////////////////////////////////////////////////////////
 	//Make the next/previous buttom.
@@ -1216,5 +1203,4 @@
 	var tbody_message = document.createElement("TBODY");
 	table_message.border = "0";
-	table_message.width = defaultWidth ;
 
 	//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1487,5 +1473,4 @@
 	var table_message_others_options = document.createElement("TABLE");
 	table_message_others_options.id = 'table_message_others_options_' + ID;
-	table_message_others_options.width =  defaultWidth - 30;
 	table_message_others_options.style.display = 'none';
 	table_message_others_options.className = "table_message";
@@ -1803,17 +1788,8 @@
 
 
-	// BEGIN MAKE THE SCROLL HEIGHT
-	var bar = document.getElementById("toolbar");
-	var offset = 0;
-	if(bar.style.visibility != 'hidden')
-		offset = bar.offsetHeight ? bar.offsetHeight :  bar.clientHeight;
 	var div = document.createElement("DIV");
 	div.id = "div_message_scroll_"+ID;
 	div.style.background = 'WHITE';
-	div.style.height = document.body.clientHeight - offset - 125;
-	content.style.height = document.body.clientHeight - offset - 90;
 	div.style.overflow = "auto";
-	div.style.width = defaultWidth - (is_ie ? 5 : 0);
-	// END MAKE THE SCROLL HEIGHT
 	table_message_others_options.appendChild(tbody_message_others_options);
 	var tr = document.createElement("TR");
@@ -1942,4 +1918,5 @@
 	table_message.appendChild(tbody_message);
 	content.appendChild(table_message);
+	resizeWindow();
 	var msg_number = document.createElement('INPUT');
 	msg_number.id = "msg_number_" + ID;
@@ -2512,4 +2489,6 @@
 	if(!expresso_offline)
 		draw_from_field(sel_from,tr1_1);
+
+	resizeWindow();
 	return ID;
 }
