Index: trunk/instant_messenger/js/im_templates.js
===================================================================
--- trunk/instant_messenger/js/im_templates.js	(revision 32)
+++ trunk/instant_messenger/js/im_templates.js	(revision 33)
@@ -50,7 +50,8 @@
 							"<tr><td><b>"+IM.get_lang('Nickname')+".:</b></td><td><input id='text1' type='text' size='20' maxlength='20'></td></tr>"+
 							"<tr><td><b>"+IM.get_lang('Group')+".:</b></td><td><input id='text2' type='text' size='20' maxlength='20'></td></tr>"+
+							"<tr><td><input id='text3' type='hidden' size='30' maxlength='30'></td></tr>"+							
 							"<tr><td colspan='2'><input type='button' value='"+IM.get_lang('Add')+"' onclick='Preferences.Add_user(\"divAddUser_im\")'></td></tr>"+
 							"</table>"
-		_this.conf_form("divAddUser",500,285,form_add_user,":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
+		_this.conf_form("divAddUser",500,250,form_add_user,":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
 	}
 
@@ -94,32 +95,35 @@
 		var auth_user = "";
 		
-		auth_user = '<table border="0" cellpadding="0" cellspacing="0" width="99%">' +	
-					'<tr style="background-color:#cccccc;font-weight:bold;height:20px"><td>&nbsp;Contato</td><td align="center">Detalhes</td><td align="center">Aceitar S/N</td></tr>';	
-
-		for(var i=0 ; i < IM.array_users.length; i++){
-			if(IM.array_users[i].group == 'sem_grupo'){
-  	  	 		  auth_user += '<tr id="_cell_'+IM.array_users[i].jid+'">'+
-			  	               '<td><img src="' + img_not_authorized.src + '">' + decodeURI(IM.array_users[i].name).substr(0,decodeURI(IM.array_users[i].name).indexOf('@')) + '<span id="_span_not_' + IM.array_users[i].jid + '"></span></td>'+
-			  	  	 		   '<td align="center"><a href="javascript:void(0);" onclick=Preferences.Info_Contact("'+IM.array_users[i].jid+'")> ? </a></td>'+
-			  	  	 		   '<td align="center"><a href="javascript:void(0);" onclick=Preferences.updateLoad("'+IM.array_users[i].jid+'")> Sim </a>/<a href="javascript:void(0);" onclick=Preferences.Remove_Contact("'+IM.array_users[i].jid+'")> Não </a></td>'+
-			  	  	 		   '</tr>';
-				  count++;
+		if(!IM.array_prefe['ch_contacts'])
+		{
+			auth_user = '<table border="0" cellpadding="0" cellspacing="0" width="99%">' +	
+						'<tr style="background-color:#cccccc;font-weight:bold;height:20px"><td>&nbsp;Contato</td><td align="center">Detalhes</td><td align="center">Aceitar S/N</td></tr>';	
+	
+			for(var i=0 ; i < IM.array_users.length; i++){
+				if(IM.array_users[i].group == 'sem_grupo'){
+	  	  	 		  auth_user += '<tr id="_cell_'+IM.array_users[i].jid+'">'+
+				  	               '<td><img src="' + img_not_authorized.src + '">' + decodeURI(IM.array_users[i].name).substr(0,decodeURI(IM.array_users[i].name).indexOf('@')) + '<span id="_span_not_' + IM.array_users[i].jid + '"></span></td>'+
+				  	  	 		   '<td align="center"><a href="javascript:void(0);" onclick=Preferences.Info_Contact("'+IM.array_users[i].jid+'")> ? </a></td>'+
+				  	  	 		   '<td align="center"><a href="javascript:void(0);" onclick=Preferences.updateLoad("'+IM.array_users[i].jid+'")> Sim </a>/<a href="javascript:void(0);" onclick=Preferences.Remove_Contact("'+IM.array_users[i].jid+'")> Não </a></td>'+
+				  	  	 		   '</tr>';
+					  count++;
+				}
 			}
-		}
-
-		auth_user += '</table>';
-
-		if( count > 0 ){
-			var form_auth_user =  '<div style="margin-left:5px;margin-top:2px">' +
-								  '</br>'+
-								  '<b>O(s) contato(s) abaixo aguarda(m) sua autorização.' +
-								  '</br>Para adicionar este(s) novo(s) contato(s), basta dar um ' +
-								  'clique em cima do contato.' +
-								  '<p>Contato(s) :' + 
-								  '</b></br>' +
-								  '<div id="divChildrenFormAuthUser">';
-  			    form_auth_user += auth_user + '</div></div>';
-			_this.conf_form("divFormAuthUser",360,250,form_auth_user, ":: Contatos sem Cadastro - Expresso ::");
-		
+	
+			auth_user += '</table>';
+	
+			if( count > 0 ){
+				var form_auth_user =  '<div style="margin-left:5px;margin-top:2px">' +
+									  '</br>'+
+									  '<b>O(s) contato(s) abaixo aguarda(m) sua autorização.' +
+									  '</br>Para adicionar este(s) novo(s) contato(s), basta dar um ' +
+									  'clique em cima do contato.' +
+									  '<p>Contato(s) :' + 
+									  '</b></br>' +
+									  '<div id="divChildrenFormAuthUser">';
+	  			    form_auth_user += auth_user + '</div></div>';
+				_this.conf_form("divFormAuthUser",360,250,form_auth_user, ":: Contatos sem Cadastro - Expresso ::");
+			
+			}
 		}
 	}
@@ -370,31 +374,24 @@
 	Templates.prototype.yourPreferences = function()
 	{	
-		/*************
-		 Preferências 
-		 Marcação de tempo
-		 Exibir amigos desconectados
-		 Desativar aviso de novos contatos	
-		 Ativar aviso de mensagens recebidas 
-		 	- Aviso Normal
-		 	- Aviso Médio
-		 	- Aviso Chato
-		 Bloquear recebimento de mensagens 
-		 Cadastro de novos grupos;
-		/*************/
-							  
  	    var form_your_prefe = '<div style="margin-left:10px;margin-top:5px"><dl>' +
- 	    					  '<dt><input type="checkbox"> Mostar marcação de tempo </dt> ' +
- 	    					  '<dt><input type="checkbox"> Exibir amigos desconectados </dt> ' + 	    					  
- 	    					  '<dt><input type="checkbox"> Desativar aviso de novos contatos </dt> ' +
- 	    					  '<dt><input type="checkbox"> Cadastro de novos grupos </dt> ' +	 	    					   	    					   	    					  
- 	    					  '<dl></div>' +
- 	    					  '<div style="margin-top:10px;margin-left:15px"> Ativar aviso de mensagens recebidas </div>' +
- 	    					  '<div style="margin-left:20px;margin-top:5px">' +
- 	    					  		'<input type="radio" id="rd_normal" value="normal"> Modo Normal</br>' +	 	    					  
- 	    					  		'<input type="radio" id="rd_medio" value="alerta"> Modo com Alertas</br>' +	 	    					  
- 	    					  		'<input type="radio" id="rd_chato" value="chato"> Modo Chato' +
- 	    					  '</div>' ;
- 	    					   	    					   	
-		this.conf_form("divYourPrefe",340,200,form_your_prefe,":: " + IM.get_lang('Preferences') + " - Expresso ::");
+	 	    					  '<fieldset><legend>&nbsp;Opções&nbsp;:</legend>'+
+ 		    					  '<dt><input id="ch_time" type="checkbox"> Mostar marcação de tempo </dt> ' +
+ 	    						  '<dt><input id="ch_offline" type="checkbox"> Exibir amigos desconectados </dt> ' + 	    					  
+ 	    						  '<dt><input id="ch_contacts" type="checkbox"> Desativar aviso de novos contatos </dt> ' +
+ 	    						  '<dl></fieldset></div>' +
+ 	    					  '<div style="margin-left:10px;margin-top:5px">' +
+ 	    					  		'<fieldset><legend>&nbsp;Ativar aviso de mensagens recebidas&nbsp;:</legend>'+
+ 	    					  		'<input id="rd_nm" type="radio" name="rd_aviso"> Normal <i>(Função Indisponível)</i></br>' +	 	    					  
+ 	    					  		'<input id="rd_al" type="radio" name="rd_aviso"> Com Alertas <i>(Função Indisponível)</i></br>' +	 	    					  
+ 	    					  		'<input id="rd_ch" type="radio" name="rd_aviso"> Treme Tela <i>(Função Indisponível)</i>' +
+ 	    					  		'</fieldset>'+
+ 	    					  '</div>'+
+ 	    					  '<div style="margin-left:10px;margin-top:5px">'+
+ 	    					  	'<font style="size:8pt;color:red">* É necessário salvar as opções *</p>'+
+ 	    					  	'<input type="button" value="Salvar" onclick="javascript:Preferences.SetPreferences()">'+
+								'<input type="button" value="Cancelar" onclick="javascript:im_win.windowClose(\'divYourPrefe_im_window\')">'+ 	    					  	
+ 	    					  '</div>'; 
+
+		this.conf_form("divYourPrefe",345,230,form_your_prefe,":: " + IM.get_lang('Preferences') + " - Expresso ::");
 	}
 
Index: trunk/instant_messenger/js/im_preferences.js
===================================================================
--- trunk/instant_messenger/js/im_preferences.js	(revision 32)
+++ trunk/instant_messenger/js/im_preferences.js	(revision 33)
@@ -39,5 +39,4 @@
 	Preferences.prototype.SearchContacts = function()
 	{
-
 		var select_org = document.getElementById('ImSelOrg');
 		var select_contact = document.getElementById('ImSelAddContact');
@@ -63,5 +62,5 @@
 				for(var i in data){
 					if(data[i].cn != ""){
-						var options =  new Option(data[i].cn + " ( "+ data[i].mail + " )", data[i].mail, false, false);
+						var options =  new Option(data[i].cn + " ( "+ data[i].mail + " )", data[i].mail + ";" + data[i].uid, false, false);
 						select_contact[select_contact.length] = options;
 					}
@@ -81,7 +80,10 @@
 			for(var i=0; i < select.options.length; i++){
 				if(select.options[i].selected == true){
-					document.getElementById('text0').value = select.options[i].value;
-					document.getElementById('text1').value = select.options[i].value.substr(0,select.options[i].value.indexOf('@'));	
+					var email = select.options[i].value.substr(0,select.options[i].value.indexOf(';'));
+					var uid = select.options[i].value.substr((select.options[i].value.indexOf(';')+1),select.options[i].value.length);
+					document.getElementById('text0').value = email;
+					document.getElementById('text1').value = email.substr(0,email.indexOf('@'));	
 					document.getElementById('text2').focus(); 			
+					document.getElementById('text3').value = uid;
 				}
 			}
@@ -94,4 +96,6 @@
 		var text1 = document.getElementById('text1');
 		var text2 = document.getElementById('text2');
+		var text3 = (document.getElementById('text3') != null) ? document.getElementById('text3') : false ;
+		
 		var _this = this;
 		var jid   = text0.value;
@@ -116,5 +120,9 @@
 			else
 				subscription = "to";
-			cIM.cExecute("$this.Ujabber.AddNewContacts",handler_add_contact,"email="+text0.value+"&name="+name+"&group="+group+"&subscription="+subscription);
+			if(text3)
+				var email = text3.value + "@" + text0.value.substr((text0.value.indexOf('@')+1),text0.value.length);
+			else
+				var email = text0.value;
+			cIM.cExecute("$this.Ujabber.AddNewContacts",handler_add_contact,"email="+email+"&name="+name+"&group="+group+"&subscription="+subscription);
 		}else{
 			alert("Informe todos os campos!");
@@ -344,22 +352,23 @@
 		var pElement = "teste";
 		var uid = pJid.substr(0,pJid.indexOf('@'));
-		
 
 		var handler_ldap =  function(data){
-	
-			var form_details = '<table cellpadding="0" cellspacing="0" style="background-color:#cbdae4;width:80%;border:1px solid #809aa9">' +
-							   '<tr><td style="vertical-align:top;width:80%">' +
-							   '<div style="padding-bottom">' + 
-							   '<span><label>'+IM.get_lang('Name')+'</label></br>'+ data[0].cn + '</span></br></br>' +
-							   '<span><label>'+IM.get_lang('E-mail')+'</label></br>'+ data[0].mail + '</span></br>' +							    
-							   '</div></td>' +
-							   '<td style="vertical-align:top"><img id="' + pJid + '_avatar" src="' + img_photo.src + '" style="height:65px;width:60px;align:right">' +	
-							   '</td></tr>'+
-							   '</table>';	
-	
-			im_menu_action.menu(element, form_details);
-	
-			// Foto Ldap;
-			im_win.get_photo_ldap(pJid);
+
+			if(data){
+				var form_details = '<table cellpadding="0" cellspacing="0" style="background-color:#cbdae4;width:80%;border:1px solid #809aa9">' +
+								   '<tr><td style="vertical-align:top;width:80%">' +
+								   '<div style="padding-bottom">' + 
+								   '<span><label>'+IM.get_lang('Name')+'</label></br>'+ data[0].cn + '</span></br></br>' +
+								   '<span><label>'+IM.get_lang('E-mail')+'</label></br>'+ data[0].mail + '</span></br>' +							    
+								   '</div></td>' +
+								   '<td style="vertical-align:top"><img id="' + pJid + '_avatar" src="' + img_photo.src + '" style="height:65px;width:60px;align:right">' +	
+								   '</td></tr>'+
+								   '</table>';	
+		
+				im_menu_action.menu(element, form_details);
+		
+				// Foto Ldap;
+				im_win.get_photo_ldap(pJid);
+			}
 		}
 		cIM.cExecute("$this.ldap_im.info_user",handler_ldap,"uid="+uid);
@@ -395,7 +404,81 @@
 	Preferences.prototype.yourPreferences = function()
 	{
-
-		//Templates.yourPreferences();
-	
+		Templates.yourPreferences();
+		if( IM.array_prefe['sizeof'] > 0 ){
+			document.getElementById('ch_time').checked = eval(IM.array_prefe['ch_time']);
+			document.getElementById('ch_offline').checked = eval(IM.array_prefe['ch_offline']);
+			document.getElementById('ch_contacts').checked = eval(IM.array_prefe['ch_contacts']);
+			document.getElementById('rd_nm').checked = eval(IM.array_prefe['rd_nm']);
+			document.getElementById('rd_al').checked = eval(IM.array_prefe['rd_al']);
+			document.getElementById('rd_ch').checked = eval(IM.array_prefe['rd_ch']);												
+		}else{
+			this.GetPreferences();
+		}
+		
+	}
+	
+	Preferences.prototype.SetPreferences = function()
+	{
+		var EcheckBox = new Array();
+			EcheckBox[0] = 'ch_time';
+			EcheckBox[1] = 'ch_offline';
+			EcheckBox[2] = 'ch_contacts';
+		var Eradio = new Array()
+			Eradio[0] =	'rd_nm';
+			Eradio[1] = 'rd_al';
+			Eradio[2] =	'rd_ch';				
+		var preferences = '';
+		var _this = this;
+		
+		for(var i in EcheckBox){
+			if(document.getElementById(EcheckBox[i]).checked){
+				preferences += EcheckBox[i] + ':' + true + ';';
+				IM.array_prefe[EcheckBox[i]] = true;
+			}else{
+				preferences += EcheckBox[i] + ':' + false + ';';
+				IM.array_prefe[EcheckBox[i]] = false;				
+			}
+			IM.array_prefe['sizeof'] = i;
+		}
+		
+		for(var i in Eradio){
+			if(document.getElementById(Eradio[i]).checked){
+				preferences += Eradio[i] + ':' + true + ';';
+				IM.array_prefe[Eradio[i]] = true;				
+			}else{
+				preferences += Eradio[i] + ':' + false + ';';
+				IM.array_prefe[Eradio[i]] = false;				
+			}
+			IM.array_prefe['sizeof'] = IM.array_prefe['sizeof'] = i + 1;
+		}
+		
+		var handler_set_preferences = function(data)
+		{
+			if(data)
+				alert('Preferências cadastradas com sucesso!');
+			IM.ContactsOffline();				
+		}
+		cIM.cExecute("$this.db_im.set_preferences",handler_set_preferences,"preferences="+preferences);
+
+	}
+	
+	Preferences.prototype.GetPreferences = function()
+	{
+		var handler_get_preferences = function(data){
+			var opt =  data.split(";");
+			for(var i in opt){
+				if(opt[i] != ""){
+					var el = opt[i].split(":");
+					if(document.getElementById(el[0]) != null){
+						var id_el = document.getElementById(el[0]);
+							id_el.checked = eval(el[1]);
+					}
+					IM.array_prefe[el[0]] = eval(el[1]);
+					IM.array_prefe['sizeof'] = i;
+				}
+			}
+		}
+		cIM.cExecute("$this.db_im.get_preferences",handler_get_preferences);
+
 	}
 	
Index: trunk/instant_messenger/js/im_functions.js
===================================================================
--- trunk/instant_messenger/js/im_functions.js	(revision 32)
+++ trunk/instant_messenger/js/im_functions.js	(revision 33)
@@ -7,4 +7,6 @@
       this.array_users	  = new Array();
       this.vcard_user	  = new Array();
+      this.array_prefe	  = new Array();
+      	   this.array_prefe['ch_offline'] = true;	
       this.load_photo	  = false;
    }
@@ -67,11 +69,11 @@
       }
    }
-   /*
-	* Monta Lista de Contatos
-	*/
-	
-	IM.prototype.mount_list = function(pList)
-	{
-
+   
+  /*
+   * Manutenção 
+   */
+
+   IM.prototype.Manutencao = function()
+   {
 		// Manutencao
         //
@@ -81,5 +83,12 @@
 		//
 		//
-		
+	}
+
+   /*
+	* Monta Lista de Contatos
+	*/
+	
+	IM.prototype.mount_list = function(pList)
+	{
 		var _this = this;
 		var group = "";
@@ -95,4 +104,5 @@
 
 			var div_agroups = document.getElementById("all_groups");
+			var div_group = document.createElement('DIV');			
 			group = decodeURI(pList[i].group);
 			group = group.rm_space();
@@ -103,5 +113,4 @@
 
 				if(group != 'sem_grupo'){
-					var div_group = document.createElement('DIV');
 						div_group.id = group;
 						if(pList[i].subscription.rm_space() == "both")
@@ -111,5 +120,4 @@
 						div_agroups.appendChild(div_group);
 				}else{
-					var div_group = document.createElement('DIV');
 						div_group.id = group;
 						div_group.innerHTML += '<div id="'+pList[i].jid+'" onclick=Preferences.updateLoad("'+pList[i].jid+'") style="cursor:pointer;padding-left:32px;">'+
@@ -134,5 +142,33 @@
 			}
 		}
+	
+		// Contatos Offline;
+		_this.ContactsOffline();
+		
+		// Usuários Não Autorizados;		
 		setTimeout("Templates.Users_Not_Auth()",2500);
+
+	}
+	
+   /*
+	* Deixar contatos Offline
+	*/
+	
+	IM.prototype.ContactsOffline = function()
+	{
+		var _this = this;
+		var display = "block";
+		
+		if(!_this.array_prefe['ch_offline']){
+			display = "none";
+		}
+
+		for(var i = 1; i < _this.array_users.length; i++){
+			var div_child = document.getElementById(_this.array_users[i].jid);
+			var img_src = div_child.firstChild.src
+			if(img_src === img_offline.src){
+				div_child.style.display = display;
+			}
+		}
 	}
 
@@ -201,4 +237,5 @@
 			
 			im_win.get_photo_ldap(decodeURI(data['VCARD_JID']));
+			Preferences.GetPreferences();
 			_this.load_photo = true;
 		}
@@ -295,5 +332,5 @@
 					jid   	     = data[i].from;
 					body_message = data[i].body;
-					TimeStamp 	 = data[i].timestamp;
+					TimeStamp 	 = (_this.array_prefe['ch_time']) ? "[" + data[i].timestamp + "] " : " ";
 					
 					jid = jid.substr(0,jid.indexOf('/'));
@@ -312,5 +349,5 @@
 	                if ( window_message )
 	                {
-	                   window_message.innerHTML += '<strong>' + '['+ TimeStamp +'] ' + nickname + '</strong>&nbsp;' + IM.get_lang('speak') + ':<br/> ' + _this.emotions_icons(body_message) + '<br/><br/>';
+	                   window_message.innerHTML += '<strong>' + TimeStamp + nickname + '</strong>&nbsp;' + IM.get_lang('speak') + ':<br/> ' + _this.emotions_icons(body_message) + '<br/><br/>';
                        if ( windowItems[jid].state != WINDOW_STATE_REGULAR && windowItems[jid].state != WINDOW_STATE_MAXIMIZED )
                           im_win.showWindowItem(jid);
@@ -320,5 +357,5 @@
 	                   im_win.open_chat(jid);
 	                   window_message = document.getElementById(jid + '_chatMessages');
-	                   window_message.innerHTML += '<strong>' + '['+ TimeStamp +'] ' + nickname + '</strong>&nbsp;' + IM.get_lang('speak') + ':<br/> ' + _this.emotions_icons(body_message) + '<br/><br/>';
+	                   window_message.innerHTML += '<strong>' + TimeStamp + nickname + '</strong>&nbsp;' + IM.get_lang('speak') + ':<br/> ' + _this.emotions_icons(body_message) + '<br/><br/>';
 	                }
 				}
