Index: sandbox/jabberit_messenger/trophy_expresso/xsl/contactsList.xsl
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/xsl/contactsList.xsl	(revision 2491)
+++ sandbox/jabberit_messenger/trophy_expresso/xsl/contactsList.xsl	(revision 2511)
@@ -3,12 +3,13 @@
 	<xsl:output method="html" omit-xml-declaration="yes"/>
 	
+	<xsl:param name="idUser"/>
+	<xsl:param name="full_name" />
 	<xsl:param name="path_jabberit" />
-	<xsl:param name="full_name" />
+	<xsl:param name="zIndex_" />
 	
 	<xsl:template match="contacts_list">
 		
 		<fieldset style="margin:2px; border:1px dotted #000000; height: 90px;">
-			<div style="margin:0px; width:60px; height:80px; background-image:url('{$path_jabberit}/templates/default/images/photo.png');"/>
-			
+			<div id="{$idUser}__photo" style="margin:0px; width:60px; height:80px; background-image:url('{$path_jabberit}/templates/default/images/photo.png');"/>
 			<div style="position: absolute; margin-top: -19px; margin-left: 75px; cursor: pointer;" onclick="loadIM.setPresence(this);">
 				<div id="statusJabberImg" style="background-image: url('{$path_jabberit}/templates/default/images/available.gif'); margin-left: 13px;width:15px; height:15px;"></div>
@@ -25,5 +26,5 @@
 		</fieldset>
 				
-		<div id="JabberIMRoster" style="margin-top:3px;overflow-y: auto; height: 267px;"></div>
+		<div id="JabberIMRoster" style="margin-top:3px;overflow-y: auto; height: 267px; z-index:{$zIndex_};"></div>
 		 
 	</xsl:template>
Index: sandbox/jabberit_messenger/trophy_expresso/xsl/chatBox.xsl
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/xsl/chatBox.xsl	(revision 2437)
+++ sandbox/jabberit_messenger/trophy_expresso/xsl/chatBox.xsl	(revision 2511)
@@ -13,6 +13,5 @@
 				<div style="margin:2px;">
 					<textarea id="{$jidTo}__sendBox" class="trophyimchatinput" style="padding-left: 78px; height:130px; width:360px;"></textarea>
-					<div style="position:relative;margin:-126px 0 0 3px;width:60px ;height:80px ;background-image:url('{$path_jabberit}templates/default/images/photo.png');"></div>
-					
+					<div id="{$jidTo}__photo" style="position:relative;margin:-126px 0 0 3px;width:60px ;height:80px ;background-image:url('{$path_jabberit}templates/default/images/photo.png');" />
 					<div style="margin: 5px;">
 						<input type="button" value="Send" onclick="TrophyIM.sendMessage('{$jidTo}')"/>
Index: sandbox/jabberit_messenger/trophy_expresso/inc/WebService.php
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/inc/WebService.php	(revision 2471)
+++ sandbox/jabberit_messenger/trophy_expresso/inc/WebService.php	(revision 2511)
@@ -12,4 +12,41 @@
 class WebService
 {
+	function __construct()
+	{
+		require_once("../../header.session.inc.php");		
+	}
+
+	public final function getPhoto($pUid)
+	{
+		require_once("class.LdapIM.inc.php");
+		
+		$ldap = new LdapIM();
+
+		$uid = $pUid;
+		if( strpos($pUid, "/") )
+			$uid = substr($pUid, 0, strpos($pUid, "/"));
+		
+		$photo = $ldap->getPhotoUser($uid, true);
+		
+		if ( !$photo )
+			$photo = $ldap->getPhotoUser($uid, false);
+	
+		if( $photo )
+			$photo = imagecreatefromstring($photo);
+		else
+			$photo = imagecreatefrompng("../templates/default/images/photo.png");
+
+		header("Content-Type: image/jpeg");
+		$width = imagesx($photo);
+		$height = imagesy($photo);
+		$twidth = 60;
+		$theight = 80;
+		$small_photo = imagecreatetruecolor ($twidth, $theight);
+		imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
+		imagejpeg($small_photo,'',100);
+
+		return;
+	}
+	
 	public final function getPhotoSession($pUid, $pOu)
 	{
@@ -17,6 +54,4 @@
 		if( strpos($pUid, "@") )
 			$uid = substr($pUid, 0, strpos($pUid, "@"));
-		
-		require_once("../../header.session.inc.php");
 		
 		if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]) )
@@ -40,14 +75,21 @@
 }
 
-// Php - fotos pelo php;
-if(trim($_REQUEST['phpPhoto']) != "")
+// Photo in Session
+if(trim($_REQUEST['photo_session']) != "")
 {
 	$obj	= new WebService();
-	$ou		= $_REQUEST['phpOu'];
-	$jid	= $_REQUEST['phpPhoto'];
+	$ou		= $_REQUEST['ou'];
+	$jid	= $_REQUEST['photo_session'];
 	
 	$obj->getPhotoSession($jid, $ou);
 }
 
+// Photo Ldap 
+if(trim($_REQUEST['photo_ldap']))
+{
+	$obj	= new WebService();
+	$jid	= $_REQUEST['photo_ldap'];
+	$obj->getPhoto($jid);
+}
 
 ?>
Index: sandbox/jabberit_messenger/trophy_expresso/inc/class.LdapIM.inc.php
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/inc/class.LdapIM.inc.php	(revision 2421)
+++ sandbox/jabberit_messenger/trophy_expresso/inc/class.LdapIM.inc.php	(revision 2511)
@@ -303,4 +303,59 @@
 	}
 
+	public final function getPhotoUser( $_uid, $ldapRoot )
+	{
+
+		$uid 	= substr($_uid, 0, strpos($_uid, "@"));
+		$host	= substr($_uid, (strpos($_uid, "@") + 1));
+		
+		if( $ldapRoot )
+		{
+			$this->ldapRoot();
+		}
+		else
+		{
+			$confHosts	= $this->hostsJabber;	
+
+			for( $i = 0; $i < count($confHosts); $i++ )
+			{
+				if( trim($host) === trim($confHosts[$i]['jabberName']) )
+				{
+					$this->ldap_host 	= $confHosts[$i]['serverLdap'];
+					$this->ldap_context = $confHosts[$i]['contextLdap'];
+					$this->ldap_user	= $confHosts[$i]['user'];
+					$this->ldap_org		= $confHosts[$i]['org'];
+					$this->ldap_pass	= $confHosts[$i]['password'];
+					$this->ldap 		= $this->ldapCatalog();
+				}
+			}				
+		}
+
+		if( $this->ldap )
+		{
+			$filter		= "(&(phpgwaccounttype=u)(uid=".$uid."))";
+			$justthese	= array($this->attribute, "uidNumber", "phpgwAccontVisible", "dn", "jpegPhoto");
+			$search		= ldap_search( $this->ldap, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1);
+			$entry		= ldap_get_entries( $this->ldap, $search );
+			
+			for( $i = 0 ; $i < $entry['count']; $i++ )
+			{
+				if( $entry[$i]['jpegphoto'][0] && $entry[$i]['phpgwaccountvisible'][0] != '-1' )
+				{
+					$filterPhoto	= "(objectclass=*)";
+					$photoLdap		= ldap_read($this->ldap, $entry[$i]['dn'], $filterPhoto, array("jpegPhoto"));
+					$firstEntry 	= ldap_first_entry($this->ldap, $photoLdap);
+					$photo			= ldap_get_values_len($this->ldap, $firstEntry, "jpegPhoto");
+
+					if( $this->ldap )
+						ldap_close($this->ldap);
+
+					return $photo[0];		
+				}
+			}
+		}
+
+		return false;
+	}
+
 	public final function getUsersLdapCatalog( $search, $uid = false, $pLdap = false )
 	{
Index: sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js	(revision 2491)
+++ sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js	(revision 2511)
@@ -167,5 +167,5 @@
 				_optionsItens.setAttribute("style", "margin: 20px 0px 0px -4px;");
 				_optionsItens.className		= "x-menu";
-				_optionsItens.style.zIndex	= '99999';
+				_optionsItens.style.zIndex	= '999999';
 				_optionsItens.innerHTML		= _itens;  
 										  
@@ -182,4 +182,17 @@
 	{
 		return document.getElementById( elementId );
+	}
+	
+	function getPhotoUser( jid )
+	{
+		var _divPhoto = getElement( jid + '__photo' );
+
+		if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 )
+		{
+			var _imgUser  = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date );
+				_imgUser += '&photo_ldap=' + jid;
+
+			_divPhoto.style.backgroundImage = 'url(' + _imgUser + ')';
+		}
 	}
 	
@@ -332,5 +345,5 @@
 				_optionsItens.setAttribute("style", "margin: -10px 0px 0px 20px;");
 				_optionsItens.className		= "x-menu";
-				_optionsItens.style.zIndex	= '99999';
+				_optionsItens.style.zIndex	= zIndex++;
 				_optionsItens.innerHTML		= _itens;  
 				_optionsItens.onmouseout	= function(){ showhidden.hiddenObject(false); };	
@@ -373,6 +386,8 @@
 		var paramListContact = 
 		{
+			'idUser'		: getUserCurrent().jid,
+			'full_name'		: (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")),
 			'path_jabberit' : path_jabberit,
-			'full_name'		: (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")) 
+			'zIndex_'		: zIndex++
 		};
 		
@@ -394,4 +409,7 @@
 		
 		_winBuild( winRosterDiv );
+
+		// Photo User
+		getPhotoUser(getUserCurrent().jid);
 	}
 
@@ -442,4 +460,5 @@
 				               ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'],
 				               ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'],
+				               ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />']				                
 				          ];
 			
@@ -477,10 +496,13 @@
 		if( arguments.length > 0 )
 		{
-			var _text	= arguments[0];
-			var _img	= arguments[1];
-			
-			getElement('statusJabberImg').setAttribute("style", "background-image: url('"+path_jabberit+"templates/default/images/"+_img+".gif'); margin-left: 13px;width:15px; height:15px;");
-			getElement('statusJabberText').innerHTML = _text;
-			getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat";
+			if( arguments[1] != 'status' )
+			{
+				var _text	= arguments[0];
+				var _img	= arguments[1];
+				
+				getElement('statusJabberImg').setAttribute("style", "background-image: url('"+path_jabberit+"templates/default/images/"+_img+".gif'); margin-left: 13px;width:15px; height:15px;");
+				getElement('statusJabberText').innerHTML = _text;
+				getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat";
+			}
 		}	
 	}
@@ -550,4 +572,5 @@
 	loadIM.prototype.addContact			= addContact;
 	loadIM.prototype.configEvents		= configEvents;
+	loadIM.prototype.getPhotoUser		= getPhotoUser;
 	loadIM.prototype.getUserCurrent		= getUserCurrent;
 	loadIM.prototype.getZIndex			= getZindex;
Index: sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js	(revision 2471)
+++ sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js	(revision 2511)
@@ -57,5 +57,5 @@
 								
 								var _img_path  = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date );
-									_img_path += '&phpPhoto=' + jid + '&phpOu=' + ou;
+									_img_path += '&photo_session=' + jid + '&ou=' + ou;
 								
 								_newUser.style.backgroundImage = 'url(' + _img_path + ')';
Index: sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js	(revision 2491)
+++ sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js	(revision 2511)
@@ -656,5 +656,8 @@
 				'path_jabberit' : path_jabberit
     	};
-    	
+
+    	titleWindow = barejid.toLowerCase();
+   		titleWindow = titleWindow.substring(0, titleWindow.indexOf('@'));
+
         if( TrophyIM.rosterObj.roster[barejid] )
         {
@@ -664,9 +667,4 @@
             }
         }
-        else
-        {
-        	titleWindow = barejid.toLowerCase();
-        	titleWindow = titleWindow.substring(0, titleWindow.indexOf('@'));
-        }	
 
     	var winChatBox = 
@@ -687,4 +685,7 @@
     	
     	_winBuild(winChatBox);
+
+    	// Photo User;
+   		loadIM.getPhotoUser(barejid);
 		
 		loadIM.configEvents( document.getElementById( barejid + '__sendBox'),
@@ -999,12 +1000,19 @@
 		for( var i = 0 ; i < users.length; i++ )
 		{
-			if( TrophyIM.rosterObj.roster[users[i]].contact.groups )
-			{
-				var groups = TrophyIM.rosterObj.roster[users[i]].contact.groups;
-				
-				if( groups.length > 0 )
+			if( TrophyIM.rosterObj.roster[users[i]].contact.jid != loadIM.getUserCurrent().jid )
+			{
+				if( TrophyIM.rosterObj.roster[users[i]].contact.groups )
 				{
-					for( var j = 0; j < groups.length; j++ )
-						addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element, j );
+					var groups = TrophyIM.rosterObj.roster[users[i]].contact.groups;
+					
+					if( groups.length > 0 )
+					{
+						for( var j = 0; j < groups.length; j++ )
+							addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element, j );
+					}
+					else
+					{
+						addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element, 0 );
+					}
 				}
 				else
@@ -1013,8 +1021,4 @@
 				}
 			}
-			else
-			{
-				addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element, 0 );
-			}
 		}	
 	},
@@ -1046,7 +1050,30 @@
      */
 
-	setPresence : function( show )
-	{
-		TrophyIM.connection.send($pres( ).c('show').t(show).tree());
+	setPresence : function( type )
+	{
+		if( type != 'status')
+		{
+			TrophyIM.connection.send($pres( ).c('show').t(type).tree());
+		}
+		else
+		{
+			var _show	= "available";
+			var _status	= "";
+			
+			if (( _status = prompt("Digite sua mensagem !") ))
+			{
+				for(var resource in TrophyIM.rosterObj.roster[loadIM.getUserCurrent().jid].presence )
+				{	
+					if ( TROPHYIM_RESOURCE === ("/" + resource) )
+						_show = TrophyIM.rosterObj.roster[loadIM.getUserCurrent().jid].presence[resource].show;
+				}
+
+				var _presence = $pres( );
+				_presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _show ) );
+				_presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( _status ) );
+				
+				TrophyIM.connection.send( _presence.tree() );
+			}
+		}
 	},
 	
@@ -1157,36 +1184,33 @@
 	this.addContact = function(jid, subscription, name, groups )
 	{
-    	if( jid != loadIM.getUserCurrent().jid )
-    	{ 
-    	 	if( subscription !== "remove" )
-	        {
-		    	var contact		= { jid:jid, subscription:subscription, name:name, groups:groups }
-		        var jid_lower	= jid.toLowerCase();
-		
-				if ( this.roster[jid_lower] )
+	 	if( subscription !== "remove" )
+        {
+	    	var contact		= { jid:jid, subscription:subscription, name:name, groups:groups }
+	        var jid_lower	= jid.toLowerCase();
+	
+			if ( this.roster[jid_lower] )
+			{
+	            this.roster[jid_lower]['contact'] = contact;
+	        }
+			else
+			{
+	            this.roster[jid_lower] = {contact:contact};
+	        }
+	
+			groups = groups ? groups : [''];
+	        
+			for ( var g = 0; g < groups.length; g++ )
+			{
+				if ( !this.groups[groups[g]] )
 				{
-		            this.roster[jid_lower]['contact'] = contact;
-		        }
-				else
-				{
-		            this.roster[jid_lower] = {contact:contact};
-		        }
-		
-				groups = groups ? groups : [''];
-		        
-				for ( var g = 0; g < groups.length; g++ )
-				{
-					if ( !this.groups[groups[g]] )
-					{
-		                this.groups[groups[g]] = {};
-		            }
-		            
-					this.groups[groups[g]][jid_lower] = jid_lower;
-		        }
+	                this.groups[groups[g]] = {};
+	            }
+	            
+				this.groups[groups[g]][jid_lower] = jid_lower;
 	        }
-        	else
-        	{
-        		this.removeContact(jid);
-        	}
+        }
+    	else
+    	{
+    		this.removeContact(jid);
     	}
     }
@@ -1314,35 +1338,27 @@
         var jid_lower = barejid.toLowerCase();
         
-        if( barejid != loadIM.getUserCurrent().jid )
-        {
-			if( show != 'unavailable')
-			{
-	            if (!this.roster[jid_lower])
-				{
-	                this.addContact(barejid, 'not-in-roster');
-	            }
-	            var presence =
-				{
-	                resource:resource, priority:priority, show:show, status:status
-	            }
-	            
-				if (!this.roster[jid_lower]['presence'])
-				{
-	                this.roster[jid_lower]['presence'] = {}
-	            }
-	            this.roster[jid_lower]['presence'][resource] = presence
-	        }
-			else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] && this.roster[jid_lower]['presence'][resource])
-			{
-	            delete this.roster[jid_lower]['presence'][resource];
-	        }
-	        
-			this.addChange(jid_lower);
-	        
-			if (TrophyIM.activeChats['divs'][jid_lower])
-			{
-	            TrophyIM.setTabPresence(jid_lower, TrophyIM.activeChats['divs'][jid_lower]['tab']);
-	        }
-        }
+		if( show != 'unavailable')
+		{
+            if (!this.roster[jid_lower])
+			{
+                this.addContact(barejid, 'not-in-roster');
+            }
+            var presence =
+			{
+                resource:resource, priority:priority, show:show, status:status
+            }
+            
+			if (!this.roster[jid_lower]['presence'])
+			{
+                this.roster[jid_lower]['presence'] = {}
+            }
+            this.roster[jid_lower]['presence'][resource] = presence
+        }
+		else if (this.roster[jid_lower] && this.roster[jid_lower]['presence'] && this.roster[jid_lower]['presence'][resource])
+		{
+            delete this.roster[jid_lower]['presence'][resource];
+        }
+        
+		this.addChange(jid_lower);
     }
 
