Index: trunk/expressoAdmin1_2/js/jscode/managers.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/managers.js	(revision 64)
+++ trunk/expressoAdmin1_2/js/jscode/managers.js	(revision 180)
@@ -1,2 +1,3 @@
+countFiles = 1;
 function copy_manager(manager)
 {
@@ -15,34 +16,143 @@
 function add_input_context()
 {
+	var new_context_value = document.getElementById("ea_select_contexts").value;
+	children = document.getElementById("td_input_context").getElementsByTagName("input");
+	
+	for (var i=0; i<children.length; i++)
+	{
+		if (new_context_value.indexOf(children[i].value) != -1)
+		{
+			document.getElementById("ea_spam_warn").innerHTML = 'Context já adicionado ou redundante.'
+			setTimeout("document.getElementById(\"ea_spam_warn\").innerHTML = '&nbsp;'", 4000);
+			return;
+		}
+		
+		if (children[i].value.indexOf(new_context_value) != -1)
+		{
+			children[i].parentNode.parentNode.removeChild(children[i].parentNode);
+			--i;
+			document.getElementById("ea_spam_warn").innerHTML = 'Removido contexto(s) reduntate(s).'
+			setTimeout("document.getElementById(\"ea_spam_warn\").innerHTML = '&nbsp;'", 4000);
+		}
+	}
+
+	var div = document.createElement("DIV");
+	
 	var input = document.createElement("INPUT");
 	input.size = 60;
-	document.getElementById("td_input_context").appendChild(input);
+	input.disabled = true;
+	input.value = document.getElementById("ea_select_contexts").value;
+	
+	var span = document.createElement("SPAN");
+	span.innerHTML = " -";
+	span.style.cursor = "pointer";
+	span.onclick = function(){ this.parentNode.parentNode.removeChild(this.parentNode); };
+	
+	div.appendChild(input);
+	div.appendChild(span);
+	document.getElementById("td_input_context").appendChild(div);
 }
 
-function validade_managers_data()
+function validade_managers_data(type)
 {
-	var context = '';
-	var input_context_fields = document.getElementById('td_input_context').childNodes;	
+	var contexts = '';
+	var input_context_fields = document.getElementById('td_input_context').getElementsByTagName("input");
 	for (var i=0; i<input_context_fields.length; i++)
 	{
 		if ((input_context_fields[i].nodeName === 'INPUT') && (input_context_fields[i].value != ''))
 		{
-			context += input_context_fields[i].value + '%';
+			contexts += input_context_fields[i].value + '%';
 		}
 	}
-	context = context.substring(0,context.length-1);
-	document.managers_form.context.value = context;
 	
-	if(document.managers_form.manager_lid.value == '') {
-		alert('Campo "Manager LID" está vazio.');
-		document.managers_form.manager_lid.focus();
-		return;
+	//Salvo parao Post
+	document.managers_form.context.value = contexts.substring(0,contexts.length-1);
+	contexts = 	encodeURIComponent(contexts.substring(0,contexts.length-1));
+
+	var handler_validade = function(data)
+	{
+		if (data.status == 'false')
+		{
+			alert(data.msg);
+			return;
+		}
+		else
+		{
+			if (type == 'add')
+				cExecuteForm ("$this.manager.create", document.forms[0], handler_createsave_manager);
+			else
+				cExecuteForm ("$this.manager.save", document.forms[0], handler_createsave_manager);
+		}
+	};
+	
+	cExecute ('$this.manager.validate&contexts='+contexts+'&manager_lid='+document.managers_form.ea_select_manager.value+'&type='+type, handler_validade);
+}
+function handler_createsave_manager(data){
+	return_handler_createsave_manager(data);
+}
+function return_handler_createsave_manager(data)
+{
+	if (data.status == 'false')
+	{
+		alert(data.msg);
 	}
-	else if(document.managers_form.context.value == '') {
-		alert('Contexto está vazio.');
-		document.managers_form.context.focus();
-		return;
+	else
+	{
+		if (data.type == 'create')
+			alert('Gerente criado com êxito');
+		else
+			alert('Gerente salvo com êxito');
+	}
+	location.href="./index.php?menuaction=expressoAdmin1_2.uimanagers.list_managers";
+	return;
+}
+
+var searchTimeout;
+function search_manager(manager_lid)
+{
+	clearTimeout(searchTimeout);
+	
+	var spam = document.getElementById('ea_span_searching_manager');
+	if (manager_lid.length <= 3)
+		spam.innerHTML = 'Digite mais ' + (4 - manager_lid.length) + ' letras.';
+	else
+	{
+		spam.innerHTML = 'Procurando...';
+		searchTimeout = setTimeout("search_user('"+manager_lid+"')",750);
+	}
+}
+
+function search_user(search)
+{
+	var handler_search_manager = function(data)
+	{
+		var spam = document.getElementById('ea_span_searching_manager');
+		select_available_users = document.getElementById('ea_select_managers');
+		
+		if (data.status == 'false')
+		{
+			spam.innerHTML = data.msg;
+			// Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
+			select_available_users.innerHTML = '#';
+			select_available_users.outerHTML = select_available_users.outerHTML;
+			return;
+		}
+		
+		spam.innerHTML = '';
+		// Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio.
+		select_available_users.innerHTML = '#' + data;
+		select_available_users.outerHTML = select_available_users.outerHTML;
 	}
 	
-	document.managers_form.submit();
+	cExecute ('$this.ldap_functions.search_user&search='+search, handler_search_manager);
 }
+
+function select_all_acls(parent)
+{
+	var acls = document.getElementById(parent).getElementsByTagName("input");
+	for (var i=0; i<acls.length; i++)
+	{
+		acls[i].checked = true;
+	}
+
+}
Index: trunk/expressoAdmin1_2/js/jscode/expressoadmin.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/expressoadmin.js	(revision 64)
+++ trunk/expressoAdmin1_2/js/jscode/expressoadmin.js	(revision 180)
@@ -13,7 +13,10 @@
 	if (concatenateDomain == 'true')
 	{
+		// base_dn do LDAP Expresso
 		var ldap_context = document.forms[0].ldap_context.value.toLowerCase();
-	
+		
+		// OU selecionada
 		organization_context = document.forms[0].context.value.toLowerCase();
+		
 		select_orgs = document.getElementById('ea_combo_org_info');
 		for(var i=0; i<select_orgs.options.length; i++)
@@ -23,7 +26,10 @@
 				var x;
 				var context = '';
+				
+				// OU selecionada
 				select_context = select_orgs.options[i].value.toLowerCase();
+				
+				// Transformar os DN em User Friendly Naming format
 				organization_name = organization_context.split(",");
-			
 				for (x in organization_name)
 				{
@@ -35,6 +41,9 @@
 		domain_name = document.forms[0].defaultDomain.value;
 	
+		// Retira o base_dn do valor do dn e retorna o numero de caracteres.
 		x=context.indexOf(ldap_context,0);
+		// Obtenho a string, sem o base_dn
 		org_name_par = context.substring(0,(x-1));
+		// Obtenho o nome da organização: String entre pontos, anterior ao base_dn
 		org_name = org_name_par.split('.');
 		org_name = org_name[org_name.length-1];
Index: trunk/expressoAdmin1_2/js/jscode/maillists.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/maillists.js	(revision 86)
+++ trunk/expressoAdmin1_2/js/jscode/maillists.js	(revision 180)
@@ -368,7 +368,7 @@
 }
 
-function search_organization(key)
-{
-	var organizations = document.getElementById('ea_combo_org_info');
+function search_organization(key, element)
+{
+	var organizations = document.getElementById(element);
 	var RegExp_org = new RegExp("\\b"+key, "i");
 	
@@ -382,2 +382,32 @@
 	}
 }
+
+function emailSuggestion_maillist()
+{
+	var defaultDomain = document.forms[0].defaultDomain.value;
+	var base_dn = "." + dn2ufn(document.forms[0].ldap_context.value);
+	var selected_context = dn2ufn(document.forms[0].context.value.toLowerCase());
+
+	var uid = document.getElementById("ea_maillist_uid");
+	var mail= document.getElementById("ea_maillist_mail");
+	
+	var raw_selected_context = selected_context.replace(base_dn, "");
+	
+	var array_org_name = raw_selected_context.split('.');
+	var org_name = array_org_name[array_org_name.length-1];
+	
+	if (mail.value == "")
+		mail.value = uid.value + "@" + org_name + "." + defaultDomain;
+}
+
+function dn2ufn(dn)
+{
+	var ufn = '';
+	var array_dn = dn.split(",");
+	for (x in array_dn)
+	{
+		var tmp = array_dn[x].split("=");
+		ufn += tmp[1] + '.';
+	}
+	return ufn.substring(0,(ufn.length-1));
+}
