Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 6108)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 6109)
@@ -1407,7 +1407,11 @@
 }
 
+function html_entities(string) {
+		return String(string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
+}
+
 // Passar o parâmetro offset para esta função
 function make_tr_message(headers_msgs, msg_folder, offsetToGMT){
-
+		headers_msgs.subject = html_entities(headers_msgs.subject);
 		if (typeof offsetToGMT == 'undefined')
 		{
@@ -1699,7 +1703,6 @@
 					var fail = false;
 					$.each(data, function(index, value) {
-						if(typeof value != 'object'){
+						if(typeof value != 'object' || !(value['id'])){
 							fail = true;
-							alert(value);
 						}
 					});
@@ -1716,4 +1719,5 @@
 						$('#td_message_followup_' + messageClickedId + ', ' + 
 						'tr[role="'+messageClickedId+'_'+msg_folder+'"] #td_message_followup_search_' + messageClickedId).find(".flag-edited").css("background", "#CCCCCC");
+						alert("Não foi possível sinalizar esta mensagem. \nDetalhes do erro: mensagem não contém o atributo message-id."); 
 					}
 				});
@@ -2909,5 +2913,5 @@
 	var subject = document.createElement("TD");
 	subject.id = "subject_"+ID;
-	subject.innerHTML = info_msg.subject;
+	subject.innerHTML = html_entities(info_msg.subject); 
 	subject.className = "header_message_field";
 	if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){
@@ -3012,5 +3016,5 @@
 		//TODO Mudar quando API abstrair atualizações no cache
 		DataLayer.remove('labeled', false);
-		DataLayer.get('labeled');
+		//DataLayer.get('labeled');
 		var labels = DataLayer.get("labeled", {filter: [
 				'AND',
@@ -3039,6 +3043,6 @@
 				var id_labeled = $(event.target).attr("id");
 				//TODO Mudar quando API abstrair atualizações no cache
-				DataLayer.remove('labeled', false);
-				DataLayer.get('labeled');
+				//DataLayer.remove('labeled', false);
+				//DataLayer.get('labeled');
 				DataLayer.remove('labeled', id_labeled);
 				DataLayer.commit(false, false, function(){
@@ -3471,4 +3475,53 @@
 	return mySplit( term ).pop();
 }
+
+function input_binds(input, ID){
+	var mySource = new Array();
+	var myArray = contacts.split(",");
+	for(var i in myArray){
+		var teste = myArray[i].split(";");
+		if(teste.length > 1)
+			mySource.push({name : teste[0], email: teste[1], value : (teste[0] +" - "+teste[1])});
+		else
+			mySource.push({name : "", email: teste[0], value :teste[0]});
+	}
+	input.bind( "keydown", function( event ) {
+		if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
+			event.preventDefault();
+		}
+		if((event.keyCode) == 120){
+			emQuickSearch($(this).val(), "."+$(this).parents("tr:first").attr('class').split("-")[0], ID, undefined, true);
+		}
+	}).autocomplete({
+		minLength: 0,			
+		source: function( request, response ) {
+			response( $.ui.autocomplete.filter(
+				mySource, extractLast( request.term ) ) );
+		},
+		focus: function() {
+			return false;
+		},
+		select: function( event, ui ) {
+			var terms = mySplit( this.value );
+			terms.pop();
+			terms.push( (ui.item.name != "" ? "\""+ui.item.name+"\" " : "") + (ui.item.email ? "<"+ui.item.email+">" : ""));
+			terms.push( "" );
+			this.value = terms.join( ", " );
+			return false;
+		}
+	}).data( "autocomplete" )._renderItem = function( ul, item ) {
+		ul.css({"max-height" : "115px", "overflow-y" : "auto"});
+		if( $(ul).find("li").length > 10 ){
+			return;
+		}
+		return $( "<li></li>" )
+			.data( "item.autocomplete", item )
+			.append( "<a>" + item.name + " - " + item.email + "</a>" )
+			.appendTo( ul );
+	};
+	input.parents("tr:first").find("button").button().click(function(){
+		emQuickSearch($(this).parents("tr:first").find("textarea").val(), "."+$(this).parents("tr:first").attr('class').split("-")[0], ID, undefined, true);
+	});
+}
 		
 function draw_new_message(border_ID){
@@ -3539,54 +3592,5 @@
 	} 
 	
-	var input_binds = function(input){
-		var mySource = new Array();
-		var myArray = contacts.split(",");
-		for(var i in myArray){
-			var teste = myArray[i].split(";");
-			if(teste.length > 1)
-				mySource.push({name : teste[0], email: teste[1], value : (teste[0] +" - "+teste[1])});
-			else
-				mySource.push({name : "", email: teste[0], value :teste[0]});
-		}
-		input.bind( "keydown", function( event ) {
-			if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
-				event.preventDefault();
-			}
-			if((event.keyCode) == 120){
-				emQuickSearch($(this).val(), "."+$(this).parents("tr:first").attr('class').split("-")[0], ID, undefined, true);
-			}
-		}).autocomplete({
-			minLength: 0,			
-			source: function( request, response ) {
-				response( $.ui.autocomplete.filter(
-					mySource, extractLast( request.term ) ) );
-			},
-			focus: function() {
-				return false;
-			},
-			select: function( event, ui ) {
-				var terms = mySplit( this.value );
-				terms.pop();
-				terms.push( (ui.item.name != "" ? "\""+ui.item.name+"\" " : "") + (ui.item.email ? "<"+ui.item.email+">" : ""));
-				terms.push( "" );
-				this.value = terms.join( ", " );
-				return false;
-			}
-		}).data( "autocomplete" )._renderItem = function( ul, item ) {
-			ul.css({"max-height" : "115px", "overflow-y" : "auto"});
-			if( $(ul).find("li").length > 10 ){
-				return;
-			}
-			return $( "<li></li>" )
-				.data( "item.autocomplete", item )
-				.append( "<a>" + item.name + " - " + item.email + "</a>" )
-				.appendTo( ul );
-		};
-		input.parents("tr:first").find("button").button().click(function(){
-			emQuickSearch($(this).parents("tr:first").find("textarea").val(), "."+$(this).parents("tr:first").attr('class').split("-")[0], ID, undefined, true);
-		});
-	}
-	
-	input_binds(content.find('[name="input_to"]').css({"max-height" : "115px", "overflow-y" : "auto"}).addClass("elastic").elastic().unbind('blur').focus());	
+	input_binds(content.find('[name="input_to"]').css({"max-height" : "115px", "overflow-y" : "auto"}).addClass("elastic").elastic().unbind('blur').focus(), ID);	
 	
 	//Botão TextoRico/TextoSimples
@@ -3704,9 +3708,4 @@
 				setTimeout(function() {
                     $('#attDisposition'+ID).val('attachment');
-					if(!data.fileInput){
-						data.fileInput = fileUploadMSG.find("input:file");
-						
-						//fileUploadMSG.find("input:file").trigger("change.undefined");
-					}
 					data.submit();
 				}, 3000);
