Index: trunk/expressoMail1_2/js/jscode/draw_api_messages.js
===================================================================
--- trunk/expressoMail1_2/js/jscode/draw_api_messages.js	(revision 2701)
+++ trunk/expressoMail1_2/js/jscode/draw_api_messages.js	(revision 2705)
@@ -215,5 +215,5 @@
 
 
-function putSignature(ID,info_msg){
+function getSignature(ID,info_msg){
 			var tr_signature = document.createElement("TR");
 			var td_signature = document.createElement("TD");
@@ -241,5 +241,5 @@
 				var _offset = 130;
 				if (this.value == 'more_cert'){
-					//this.innerHTML += "<b><u>Mais InformaÃ¯Â¿ÅÃ¯Â¿Åes</u></b>";
+					//this.innerHTML += "<b><u>Mais Informacoes</u></b>";
 					this.value = 'hide_cert';
 					Element("div_message_scroll_"+ID).style.height = (_height + _offset)+"px";
@@ -249,5 +249,5 @@
 				}
 				else{
-					//this.innerHTML += "Mais InformaÃ¯Â¿ÅÃ¯Â¿Åes";
+					//this.innerHTML += "Mais Informacoes";
 					this.value = 'more_cert';
 					Element("div_message_scroll_"+ID).style.height = (_height - _offset)+"px";
@@ -267,5 +267,5 @@
 }
 
-function make_options_message(info_msg, ID,tbody_message){
+function make_options_message(info_msg, tbody_message){
 	var tr0 = document.createElement("TR");
 	tr0.className = "tr_message_header";
@@ -280,4 +280,5 @@
 
 	var folder_id = 0;
+	var ID = info_msg.msg_number + "_r";
 	folder_id = info_msg.original_ID ? info_msg.original_ID: info_msg.msg_number;
 	var folder = document.getElementById(folder_id);
@@ -333,5 +334,5 @@
 				this.value = 'hide_options';
 				Element("div_message_scroll_"+ID).style.height = (_height - _offset)+"px";
-				Element('table_message_others_options_'+ID).style.display = '';
+				Element('table_msg_details_'+ID).style.display = '';
 
 			}
@@ -340,5 +341,5 @@
 				this.value = 'more_options';
 				Element("div_message_scroll_"+ID).style.height = (_height + _offset)+"px";
-				Element('table_message_others_options_'+ID).style.display = 'none';
+				Element('table_msg_details_'+ID).style.display = 'none';
 			}
 		};
@@ -430,5 +431,5 @@
 		if (info_msg.signature && info_msg.signature.length > 0)
 		{
-			tbody_message_options.appendChild(putSignature(ID,info_msg));
+			tbody_message_options.appendChild(getSignature(ID,info_msg));
 		}
 
@@ -450,5 +451,5 @@
 				this.value = 'hide_options';
 				Element("div_message_scroll_"+ID).style.height = (_height - _offset)+"px";
-				Element('table_message_others_options_'+ID).style.display = '';
+				Element('table_msg_details_'+ID).style.display = '';
 			}
 			else{
@@ -456,5 +457,5 @@
 				this.value = 'more_options';
 				Element("div_message_scroll_"+ID).style.height = (_height + _offset)+"px";
-				Element('table_message_others_options_'+ID).style.display = 'none';
+				Element('table_msg_details_'+ID).style.display = 'none';
 			}
 		};
@@ -481,9 +482,8 @@
 	var tbody_message = document.createElement("TBODY");
 
-	if (!make_options_message(info_msg,ID,tbody_message))
+	if (!make_options_message(info_msg,tbody_message))
 		return;
 
-	var table_message_others_options = createAndSet("TABLE",['id','width','class'],['table_message_others_options_' + ID,defaultWidth - 30,'table_message']);
-	table_message_others_options.style.display = 'none';
+
 	var tbody_message_others_options = document.createElement("TBODY");
 	var tr1 = document.createElement("TR");
@@ -572,45 +572,7 @@
 	}
 
-	/*
-	 * @AUTHOR Rodrigo Souza dos Santos
-	 * @MODIFY-DATE 2008/09/11
-	 * @BRIEF Adding routine to create bcc field if there is one.
-	 */
 	if (info_msg.bcc)
 	{
-		var tr3 = document.createElement("tr");
-		tr3.className = "tr_message_header";
-		var td3 = document.createElement("td");
-		td3.innerHTML = get_lang("BCC") + " : ";
-		var cco = document.createElement("td");
-		cco.id = "cco_"+ID;
-
-		var cco_values = createAndSet("INPUT",['id', 'type', 'value'],["cco_values_"+ID,"hidden",info_msg.bcc]);
-		ccoaddress_array[ID] = info_msg.bcc.split(",");		
-		if (ccoaddress_array[ID].length > 1){
-			var div_ccoaddress = document.createElement("SPAN");
-			div_ccoaddress.id = "div_ccoaddress_"+ID;
-			var div_ccoaddress_full = createAndSet("SPAN",['id', 'style'],["div_ccoaddress_full_"+ID, "display:inline"]);
-			/*
-			 * The function below is ugly, doesn't possible use this.
-			 * The problem is that the code's function was written
-			 * on a hardcode concept.
-			 */
-			//cco.innerHTML = draw_plugin_cc(ID, ccoaddress_array[ID][0]);
-			cco.innerHTML = ccoaddress_array[ID][0];
-			div_ccoaddress.innerHTML += " (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+ID+"','cco');>"+get_lang('more')+"</a>)";
-			cco.appendChild(div_ccoaddress);
-		}
-		else{
-			/*
-			 * 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.
-			 */
-			//cco.innerHTML = draw_plugin_cc(ID, info_msg.cco);
-			cco.innerHTML = info_msg.bcc;
-		}
-		cco.className = "header_message_field";
-		tbody_message_others_options.appendChild(appendChilds(tr3,td3,cco,cco_values));
+		tbody_message_others_options.appendChild(getBcc(info_msg.bcc));
 	}
 
@@ -673,7 +635,7 @@
 			var link_attachment = document.createElement("A");
 			link_attachment.setAttribute("href", proxy_mensagens.link_anexo(info_msg,i));
-			//			link_attachment.setAttribute("href", "javascript:download_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"',"+i+",'"+info_msg.attachments[i].pid+"','"+info_msg.attachments[i].encoding+"')");
+			//link_attachment.setAttribute("href", "javascript:download_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"',"+i+",'"+info_msg.attachments[i].pid+"','"+info_msg.attachments[i].encoding+"')");
 			link_attachment.innerHTML = url_decode(info_msg.attachments[i].name);
-			link_attachment.innerHTML = borkb(info_msg.attachments[i].fsize);
+			link_attachment.innerHTML += "&nbsp;"+borkb(info_msg.attachments[i].fsize);
 
 			if((url_decode(info_msg.attachments[i].name).indexOf(".ics")!=-1) || (url_decode(info_msg.attachments[i].name).indexOf(".vcard")!=-1)){
@@ -708,6 +670,9 @@
 	div.style.width = defaultWidth - (is_ie ? 5 : 0);
 	// END MAKE THE SCROLL HEIGHT
-	table_message_others_options.appendChild(tbody_message_others_options);
-	div.appendChild(table_message_others_options);
+
+	var table_msg_details = createAndSet("TABLE",['id','width','class'],['table_msg_details_' + ID,defaultWidth - 30,'table_message']);
+	table_msg_details.style.display = 'none';
+	table_msg_details.appendChild(tbody_message_others_options);
+	div.appendChild(table_msg_details);
 
 	var tr = document.createElement("TR");
@@ -749,8 +714,35 @@
 				links.item( i ).setAttribute( 'target', '_blank' );
 		}
-	//////////////////////////////////////////////////////////////////////////////////////////////////////	
-	//Make the thumbs of the message.
+
+	if ((info_msg.thumbs)&&(info_msg.thumbs.length > 0)){
+		//////////////////////////////////////////////////////////////////////////////////////////////////////	
+		//Make the thumbs of the message.
+		//////////////////////////////////////////////////////////////////////////////////////////////////////
+		div.appendChild(getThumbs(info_msg.attachments, info_msg.thumbs, info_msg.msg_number, info_msg.msg_folder));
+	}
+
+	table_message.appendChild(tbody_message);
+	content.appendChild(table_message);
+	var msg_number = createAndSet("INPUT",['id','type','value'],["msg_number_" + ID, "hidden", info_msg.msg_number]);
+	content.appendChild(msg_number);
 	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	if ((info_msg.thumbs)&&(info_msg.thumbs.length > 0)){
+
+	//Exibe o cabecalho da mensagem totalmente aberto caso esteja setado nas preferencias do usuario
+	if (preferences.show_head_msg_full == 1)
+	{
+		option_hide_more.onclick();
+
+		if (Element('div_toaddress_'+ID) != null)
+		{
+			show_div_address_full(ID,'to');
+		}	
+		if (Element('div_ccaddress_'+ID) != null)
+		{
+			show_div_address_full(ID,'cc');
+		}
+	}
+
+}
+function getThumbs(attachments, thumbs, msg_number, msg_folder){
 		var table_message_thumbs = document.createElement("TABLE");
 		table_message_thumbs.width = "80%";
@@ -761,14 +753,14 @@
 		var td = document.createElement("TD");
 		td.setAttribute("colSpan","2");
-		td.id = "body_thumbs_"+ID;
-		td.innerHTML += "&nbsp;<font color='DARKBLUE' size='2'><b>"+info_msg.attachments.length+" "+get_lang("attachment")+(info_msg.attachments.length > 1 ? "s" : "")+" "+get_lang("in this message")+"</font></b>";
+		td.id = "body_thumbs_"+msg_number;
+		td.innerHTML += "&nbsp;<font color='DARKBLUE' size='2'><b>"+attachments.length+" "+get_lang("attachment")+(attachments.length > 1 ? "s" : "")+" "+get_lang("in this message")+"</font></b>";
 		var _link_attachments = '';
-		if(info_msg.thumbs.length > 1){
+		if(thumbs.length > 1){
 			_link_attachments 	= document.createElement("A");
 			_link_attachments.className = "message_options";
 			if(proxy_mensagens.is_local_folder(current_folder))
-				_link_attachments.setAttribute("href", "javascript:expresso_local_messages.download_all_local_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
+				_link_attachments.setAttribute("href", "javascript:expresso_local_messages.download_all_local_attachments('"+msg_folder+"','"+msg_number+"')");
 			else
-				_link_attachments.setAttribute("href", "javascript:download_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
+				_link_attachments.setAttribute("href", "javascript:download_all_attachments('"+msg_folder+"','"+msg_number+"')");
 			_link_attachments.innerHTML = get_lang('Download all atachments');
 		}
@@ -782,8 +774,8 @@
 		td.innerHTML += "<BR>";
 
-		for (var i=0; i<info_msg.thumbs.length; i++){
+		for (var i=0; i<thumbs.length; i++){
 			if ((i % 4) == 0)
 				td.innerHTML += "<BR>";
-			td.innerHTML += info_msg.thumbs[i];
+			td.innerHTML += thumbs[i];
 			td.innerHTML += "&nbsp;&nbsp;";
 		}
@@ -791,28 +783,47 @@
 		tbody_message_thumbs.appendChild(tr);
 		table_message_thumbs.appendChild(tbody_message_thumbs);
-		div.appendChild(table_message_thumbs);
-	}
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-	table_message.appendChild(tbody_message);
-	content.appendChild(table_message);
-	var msg_number = createAndSet("INPUT",['id','type','value'],["msg_number_" + ID, "hidden", info_msg.msg_number]);
-	content.appendChild(msg_number);
-	//////////////////////////////////////////////////////////////////////////////////////////////////////
-
-	//Exibe o cabecalho da mensagem totalmente aberto caso esteja setado nas preferencias do usuario
-	if (preferences.show_head_msg_full == 1)
-	{
-		option_hide_more.onclick();
-
-		if (Element('div_toaddress_'+ID) != null)
-		{
-			show_div_address_full(ID,'to');
-		}	
-		if (Element('div_ccaddress_'+ID) != null)
-		{
-			show_div_address_full(ID,'cc');
-		}
-	}
-
+		return table_message_thumbs;
+}
+
+function getBcc(bccField){
+	/*
+	 * @AUTHOR Rodrigo Souza dos Santos
+	 * @MODIFY-DATE 2008/09/11
+	 * @BRIEF Adding routine to create bcc (blind carbon copy) field if there is one.
+	 */
+	var tr3 = document.createElement("tr");
+	tr3.className = "tr_message_header";
+	var td3 = document.createElement("td");
+	td3.innerHTML = get_lang("BCC") + " : ";
+	var cco = document.createElement("td");
+	cco.id = "cco_"+ID;
+
+	var cco_values = createAndSet("INPUT",['id', 'type', 'value'],["cco_values_"+ID,"hidden",bccField]);
+	ccoaddress_array[ID] = bccField.split(",");		
+	if (ccoaddress_array[ID].length > 1){
+		var div_ccoaddress = document.createElement("SPAN");
+		div_ccoaddress.id = "div_ccoaddress_"+ID;
+		var div_ccoaddress_full = createAndSet("SPAN",['id', 'style'],["div_ccoaddress_full_"+ID, "display:inline"]);
+		/*
+		 * The function below is ugly, doesn't possible use this.
+		 * The problem is that the code's function was written
+		 * on a hardcode concept.
+		 */
+		//cco.innerHTML = draw_plugin_cc(ID, ccoaddress_array[ID][0]);
+		cco.innerHTML = ccoaddress_array[ID][0];
+		div_ccoaddress.innerHTML += " (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+ID+"','cco');>"+get_lang('more')+"</a>)";
+		cco.appendChild(div_ccoaddress);
+	}
+	else{
+		/*
+		 * 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.
+		 */
+		//cco.innerHTML = draw_plugin_cc(ID, info_msg.cco);
+		cco.innerHTML = bccField;
+	}
+	cco.className = "header_message_field";
+	return appendChilds(tr3,td3,cco,cco_values);
 }
 
