Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 7198)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 7221)
@@ -4132,5 +4132,5 @@
 					box.find(".box-loading").remove();
 				else{
-					box.find(".box-loading").removeClass("box-loading").addClass("box-info");
+                    box.find(".box-loading").removeClass("box-loading").addClass("box-info");
 					box.addClass("box-"+value).removeClass("invalid-email-box");
 					loadGroupBox(data.collection, ".box-"+value);
@@ -4153,12 +4153,13 @@
 	
 	if(personal){
-		REST.get("/"+ (shared ? "shared" : "") +"contact/"+value, {}, function(data){
+		REST.get("/"+ (shared ? "shared" : "") +"personalContact/"+value, {}, function(data){
 			if(!data.error){
 				if(data.collection.error)
 					box.find(".box-loading").remove();
 				else{
+                    var item = normalizeContact(data.collection.itens[0].data);
 					box.find(".box-loading").removeClass("box-loading").addClass("box-info");
 					box.addClass("box-"+value).removeClass("invalid-email-box");
-					loadExtraLDAPBox(data.collection.data, ".box-"+value);
+					loadExtraLDAPBox(item, ".box-"+value);
 					box.unbind("dblclick").bind("dblclick", function(e){
 						new $.Zebra_Dialog(get_lang("Impossible editing this contact, but it's possible to remove it"), {
@@ -4168,9 +4169,7 @@
 							'auto_close': 3000
 						});
-					}).find(".box-input").val("\""+data.collection.data[0].value+"\" <"+data.collection.data[1].value+">");
-					var emailBoxValue = data.collection.data[0].value.length > 18 ? data.collection.data[0].value.substring(0, 15)+"...": data.collection.data[0].value;
-					emailBoxValue = emailBoxValue.length > 2 ? emailBoxValue : data.collection.data[1].value.substr(0,data.collection.data[1].value.indexOf('@'));
-					emailBoxValue = emailBoxValue > 18 ? emailBoxValue.substr(0,15) + "..." : emailBoxValue;
-					box.find(".email-box-value").html(emailBoxValue);
+					}).find(".box-input").val("\""+item.name+"\" <"+item.email+">");
+
+					box.find(".email-box-value").html(normalizeBoxName(item.name, item.value));
 				}
 			}else{
@@ -4186,7 +4185,8 @@
 				box.find(".box-loading").remove();
 			else{
+                var item = normalizeContact(data.collection.itens[0].data);
 				box.find(".box-loading").removeClass("box-loading").addClass("box-info");
 				box.addClass("box-"+value).removeClass("invalid-email-box");
-				loadExtraLDAPBox(data.collection.itens[0].data, ".box-"+value);
+				loadExtraLDAPBox(item, ".box-"+value);
 				box.unbind("dblclick").bind("dblclick", function(e){
 					new $.Zebra_Dialog(get_lang("Impossible editing this contact, but it's possible to remove it"), {
@@ -4196,11 +4196,9 @@
 						'auto_close': 3000
 					});
-				}).find(".box-input").val("\""+data.collection.itens[0].data[0].value+"\" <"+data.collection.itens[0].data[1].value+">");
-				var emailBoxValue = data.collection.itens[0].data[0].value.length > 18 ? data.collection.itens[0].data[0].value.substring(0, 15)+"...": data.collection.itens[0].data[0].value;
-				emailBoxValue = emailBoxValue.length > 2 ? emailBoxValue : data.collection.itens[0].data[1].value.substr(0,data.collection.itens[0].data[1].indexOf('@'));
-				emailBoxValue = emailBoxValue > 18 ? emailBoxValue.substr(0,15) + "..." : emailBoxValue;
-				box.find(".email-box-value").html(emailBoxValue);
-				if(data.collection.itens[0].data[3].value == "TRUE"){
-					box.removeClass("invalid-email-box").addClass("out-office-box");
+				}).find(".box-input").val("\""+item.name+"\" <"+item.email+">");
+
+                box.find(".email-box-value").html(normalizeBoxName(item.name, item.value));
+				if(item.vacationActive == "TRUE"){
+					box.addClass("out-office-box");
 				}
 			}
@@ -4210,4 +4208,37 @@
 	});
 }
+
+function normalizeBoxName(name, mail){
+    var emailBoxValue = name.length > 18 ? name.substring(0, 15)+"...": name;
+    emailBoxValue = emailBoxValue.length > 2 ? emailBoxValue : email.substr(0,email.indexOf('@'));
+    emailBoxValue = emailBoxValue > 18 ? emailBoxValue.substr(0,15) + "..." : emailBoxValue;
+
+    return emailBoxValue;
+}
+
+function normalizeContact(data){
+    var item = {};
+    $.each(data, function(j, e){
+       item[e.name] = e.value;
+    });
+
+    return item;
+}
+
+function normalizeContacts(data){
+    var decoded = [];
+
+    if(!$.isArray(data)){data = [data];}
+
+    for(var i = 0; i < data.length; i++){
+        var item = {};
+        $.each(data[i].data, function(j, e){
+            item[e.name] = e.value;
+        });
+        decoded.push(item);
+    }
+    return decoded;
+}
+
 
 //FUNÇÃO QUE "SETA" OS BINDS DOS CAMPOS PARA - CC - CCO
@@ -4265,5 +4296,5 @@
 						if(item.typel == "/groups" && $(ul).find(".dynamic-recent").length)
 							self._renderItem( ul, {name:"", value:"", type:"linha"} );
-						if(item.typel == "/contacts" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length))
+						if(item.typel == "/personalContact" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length))
 							self._renderItem( ul, {name:"", value:"", type:"linha"} );	
 						currentType = item.typel;
@@ -4325,5 +4356,5 @@
 				event.preventDefault();
 				$(this).val("");
-				if(ui.item.typel == "/contacts")
+				if(ui.item.typel == "/personalContact")
 					draw_email_box(""+ui.item.id, $(this), true, (ui.item.type.substring(0,7) == "/shared" ? true : false));
 				else if(ui.item.typel == "/groups")
