Index: sandbox/jabberit_messenger/trophy_expresso/xsl/chatBox.xsl
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/xsl/chatBox.xsl	(revision 2725)
+++ sandbox/jabberit_messenger/trophy_expresso/xsl/chatBox.xsl	(revision 2787)
@@ -2,5 +2,6 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 	<xsl:output method="html" omit-xml-declaration="yes"/>
-	
+
+	<xsl:param name="enabledPopUp" />	
 	<xsl:param name="idChatBox" />
 	<xsl:param name="jidTo" />
@@ -17,5 +18,8 @@
 						<div id="{$jidTo}__photo" style="width:60px ;height:80px ;background-image:url('{$path_jabberit}templates/default/images/photo.png');" />
 						<div style="margin: 7px 5px 5px 10px;">
-							<input type="button" value="Send" onclick="TrophyIM.sendMessage('{$jidTo}')"/>
+							<input type="button" value="Send"/>
+						</div>
+						<div id="{$jidTo}__popUp" onclick="loadscript.windowPOPUP('{$jidTo}', true );" style="display:{$enabledPopUp}; cursor:pointer;padding-left:16px; font-size:10px ;height:14px; width:50px; background:url('{$path_jabberit}templates/default/images/icon_up.png') no-repeat;">
+							PopUp
 						</div>
 					</div>
Index: sandbox/jabberit_messenger/trophy_expresso/js/makeW.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/makeW.js	(revision 2750)
+++ sandbox/jabberit_messenger/trophy_expresso/js/makeW.js	(revision 2787)
@@ -4,4 +4,6 @@
 	var dragDrop	= null;
 	var path		= path_jabberit;
+	
+	var _dialogs = [ ];
 	
 	function build(pObj)
@@ -35,5 +37,10 @@
 			window.document.body.insertBefore( _window, document.body.lastChild );
 			
-			getElement(pObj.id_window + '__content').innerHTML = pObj.content; 
+			if ( pObj.content.constructor == String )
+				getElement(pObj.id_window + '__content').innerHTML = pObj.content;
+			else
+				getElement(pObj.id_window + '__content').appendChild( pObj.content );
+			
+			_dialogs[ pObj.id_window ] = getElement(pObj.id_window + '__content').firstChild;
 			
 			if( pObj.draggable )
@@ -45,5 +52,8 @@
 		else
 		{
-			load(pObj.id_window, "display");
+	    	if ( pObj.barejid && loadscript.windowPOPUP( pObj.barejid ) )
+	    		return false;
+
+	    	load(pObj.id_window, "display");
 		}
 	}
@@ -83,7 +93,9 @@
 		if( arguments.length > 0 )
 		{
+			var pId = null;
 			if( arguments.length == 1 )
 			{
 				var obj = arguments[0];
+				pId = obj.id_window
 				build(obj);
 			}
@@ -91,7 +103,18 @@
 			if( arguments.length == 2 )
 			{
-				load(arguments[0], arguments[1]);
+				load( ( pId = arguments[0] ), arguments[1]);
 			}	
 		}
+
+		return ( new function( )
+		{
+			this.content = function( )
+			{
+				if ( arguments.length )
+					getElement( pId + '__content').appendChild( _dialogs[ pId ] );
+
+				return _dialogs[ obj.id_window ];
+			};
+		} );
 	}
 
@@ -105,8 +128,9 @@
 	{	
 		if( arguments.length == 1 )
-			_win = new bWindow( arguments[0] );
+			return bWindow( arguments[0] );
 		
 		if( arguments.length == 2 )
-			_win = new bWindow( arguments[0], arguments[1]);	
+			return bWindow( arguments[0], arguments[1]);	
 	}
+	return false;
 }
Index: sandbox/jabberit_messenger/trophy_expresso/js/xtools.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/xtools.js	(revision 2670)
+++ sandbox/jabberit_messenger/trophy_expresso/js/xtools.js	(revision 2787)
@@ -91,5 +91,5 @@
 				for (var i in params )
 					if ( params[ i ] && params[ i ].constructor != Function )
-						xslProc.setParameter(null, i, params[i]);
+						xslProc.setParameter(null, String( i ), String( params[i] ) );
 			}
 
@@ -113,5 +113,8 @@
 				var params = arguments[2];
 				for (var i in params )
-					 xslProc.addParameter(i, params[i], '');
+					if ( params[ i ] && params[ i ].constructor != Function )
+					{
+						xslProc.addParameter( String( i ), String( params[i] ), '');
+					}
 			}
 
Index: sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js	(revision 2750)
+++ sandbox/jabberit_messenger/trophy_expresso/js/trophyim.js	(revision 2787)
@@ -252,6 +252,6 @@
 			
 			//Load other .js scripts needed
-			//document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/strophe.min.js'));
-			document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/strophe.js'));
+			document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/strophe.min.js'));
+			//document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/strophe.js'));
 			document.getElementsByTagName('head')[0].appendChild(DOMObjects.getScript(path_jabberit + 'js/json2.js')); //Keep this script last
 			
@@ -652,5 +652,5 @@
         var elems	= msg.getElementsByTagName('body');
         var delay	= ( msg.getElementsByTagName('delay') ) ? msg.getElementsByTagName('delay') : null;
-        var stamp	= ( delay[0] != null ) ? messageDate(delay[0].getAttribute('stamp')) :  dtNow;
+        var stamp	= ( delay[0] != null ) ? "<font style='color:red;'>" + messageDate(delay[0].getAttribute('stamp')) + "</font>" :  dtNow;
 
 		var barejid		= Strophe.getBareJidFromJid(from);
@@ -702,10 +702,9 @@
 	    	        };
 					
-					TrophyIM.makeChat(from); //Make sure we have a chat window
-					TrophyIM.addMessage( message, jid_lower );
+					TrophyIM.addMessage( TrophyIM.makeChat( from ), jid_lower, message );
 				}
 			}
 		}
-		// Message without body are "content message", this mean state is not active
+		//Message without body are "content message", this mean state is not active
 		else
 		{
@@ -773,7 +772,8 @@
     	var barejid		= Strophe.getBareJidFromJid(fulljid);
     	var titleWindow	= "";
-    	
+
     	var paramsChatBox =
     	{
+    			'enabledPopUp'	: ( ( loadscript.getIsIE() ) ? "none" : "block" ),
     			'idChatBox' 	: barejid + "__chatBox",
     			'jidTo'			: barejid,
@@ -802,7 +802,38 @@
         	TrophyIM.posWindow.left	= 400;
         
+        var _content = document.createElement( 'div' );
+        _content.innerHTML = loadscript.parse( "chat_box", "chatBox.xsl", paramsChatBox);
+        _content = _content.firstChild;
+        
+        var _messages = _content.firstChild.firstChild;
+        var _textarea = _content.getElementsByTagName( 'textarea' ).item( 0 );
+        var _send = _content.getElementsByTagName( 'input' ).item( 0 );
+
+        function _send_message( )
+        {
+        	if ( ! TrophyIM.sendMessage( barejid, _textarea.value ) )
+        		return false;
+
+        	// Add Message in chatBox;
+    		TrophyIM.addMessage( _messages, barejid, {
+    			contact : "<font style='font-weight:bold; color:red;'>" + "Eu" + "</font>",
+    			msg : "<br/>" + _textarea.value
+    		} );
+
+        	_textarea.value = '';
+        	_textarea.focus( );
+        }
+
+        loadscript.configEvents( _send, 'onclick', _send_message );
+		loadscript.configEvents( _textarea, 'onkeyup', function( e )
+		{
+			if ( e.keyCode == 13 )
+				_send_message( );
+		} );
+        
     	var winChatBox = 
     	{
    			 id_window		: "window_chat_area_" + barejid,
+   			 barejid		: barejid,
 			 width			: 387,
 			 height			: 375,
@@ -815,26 +846,18 @@
 			 title			: titleWindow,
 			 closeAction	: "hidden",
-			 content		: loadscript.parse("chat_box","chatBox.xsl", paramsChatBox)	
+			 content		: _content	
     	}
     	
-    	_winBuild(winChatBox);
+   		_win = _winBuild(winChatBox);
 
     	// Notification New Message
-    	loadscript.notification();
+    	loadscript.notification(barejid);
     	
     	// Photo User;
    		loadscript.getPhotoUser(barejid);
-		
-		loadscript.configEvents( document.getElementById( barejid + '__sendBox'),
-			'onkeyup', function(e)
-			{
-				if( e.keyCode == 13 )
-				{
-					TrophyIM.sendMessage( barejid );
-					document.getElementById( barejid + '__sendBox').value = '';
-					return false;
-				}
-			}
-		);
+   		
+   		_textarea.focus( );
+   		
+   		return ( _messages = _win.content( ).firstChild );
     },
 
@@ -867,9 +890,7 @@
      */
 	
-    addMessage : function(msg, jid)
+    addMessage : function(chatBox, jid, msg)
     {
-    	var chatBox		= document.getElementById(jid + "__chatBox");
     	var messageDiv	= document.createElement("div");
-    	
 		messageDiv.style.margin = "3px 0px 1em 3px";
     	messageDiv.innerHTML	= msg.contact + " : " + msg.msg ;
@@ -1394,5 +1415,4 @@
     },
 
-
 	/** Function SetAutorization
 	 * 
@@ -1517,29 +1537,21 @@
      */
      
-    sendMessage : function()
+    sendMessage : function( _jidTo, _message )
     {
-
-    	if( arguments.length > 0 )
-    	{
-    		var jidTo = arguments[0];
-    		var message_input = document.getElementById(jidTo + "__sendBox").value;
-            
-    		if( ( message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "" )
-    		{
-	    		// Send Message
-	    		TrophyIM.connection.send($msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}).c('body').t(message_input).tree());
-	    		
-	    		var message = 
-	    		{
-	    				contact : "<font style='font-weight:bold; color:red;'>" + "Eu" + "</font>",
-	    				msg : "<br/>" + message_input
-	    		}
-	    		
-	    		// Add Message in chatBox;
-	    		TrophyIM.addMessage( message, jidTo);
-				document.getElementById(jidTo + "__sendBox").value = "";
-				document.getElementById(jidTo + "__sendBox").focus();
-    		}
-    	}
+		_message = _message.replace(/^\s+|\s+$|^\n|\n$/g,"");
+        
+		if( _message != "" )
+		{
+    		// Send Message
+    		TrophyIM.connection.send(
+    			$msg( {
+    				to: _jidTo, from: TrophyIM.connection.jid,
+    				type: 'chat'
+    			} ).c('body').t( _message ).tree()
+    		);
+    		return true;
+		}
+		
+		return false;
     }
 };
Index: sandbox/jabberit_messenger/trophy_expresso/js/jscode/loadIM.js
===================================================================
--- sandbox/jabberit_messenger/trophy_expresso/js/jscode/loadIM.js	(revision 2754)
+++ sandbox/jabberit_messenger/trophy_expresso/js/jscode/loadIM.js	(revision 2787)
@@ -15,6 +15,27 @@
 	var Xtools				= null;
 	var zIndex				= 9001;
-	var windowPopUp			= null;
-	
+	var windowPopUp			= [];
+	
+	// Sniffer Browser
+	var agt	= navigator.userAgent.toLowerCase();
+    var is_major = parseInt(navigator.appVersion);
+    var is_minor = parseFloat(navigator.appVersion);    
+    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
+                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
+                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
+    var is_gecko = (agt.indexOf('gecko') != -1);
+    var is_gecko1_5 = (agt.indexOf('firefox/1.5') != -1 || agt.indexOf('firefox/2') != -1 || agt.indexOf('iceweasel/2') != -1);
+    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
+    var is_ie3    = (is_ie && (is_major < 4));
+    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
+    var is_ie4up  = (is_ie && (is_major >= 4));
+    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
+    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
+    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
+    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
+    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
+    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);    
+    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
+
 	// Images
 	var add_user = new Image();
@@ -68,4 +89,13 @@
 						TrophyIM.rosterClick(jid);
 			}
+			
+			setTimeout(function()
+			{
+				window.document.oncontextmenu = function()
+				{
+					return true;
+				};
+				
+			},500);
 		}
 	}
@@ -223,10 +253,20 @@
 		{
 			if ( pEvent.substring(0, 2) == 'on' )
-				pEvent = pEvent.substring(2, pEvent.length);
-
-			if ( pObj.addEventListener )
-				pObj.addEventListener(pEvent, pHandler, false);
-			else if ( pObj.attachEvent )
-				pObj.attachEvent('on' + pEvent, pHandler);
+				pEvent = pEvent.substring(2, pEvent.length );
+
+			if ( arguments.length == 3 )
+			{
+				if ( pObj.addEventListener )
+					pObj.addEventListener(pEvent, pHandler, false );
+				else if ( pObj.attachEvent )
+					pObj.attachEvent( 'on' + pEvent, pHandler );
+			}
+			else if ( arguments.length == 4 )
+			{
+				if ( pObj.removeEventListener )
+					pObj.removeEventListener( pEvent, pHandler, false );
+				else if ( pObj.detachEvent )
+					pObj.detachEvent( 'on' + pEvent, pHandler );
+			}
 		}
 	}
@@ -281,6 +321,13 @@
 	}
 	
+	function getIsIE()
+	{
+		return is_ie;
+	}
+	
 	function getPhotoUser( jid )
 	{
+		try
+		{
 		var _divPhoto = getElement( jid + '__photo' );
 
@@ -292,4 +339,7 @@
 			_divPhoto.style.backgroundImage = 'url(' + _imgUser + ')';
 		}
+		}
+		catch(e)
+		{}
 	}
 	
@@ -452,7 +502,15 @@
 	function notificationNewMessage()
 	{
-		var oldTitle 	= document.title; 
+		var _doc		= document;
+		var _id			= arguments[0];
+		var _win_name	= _id.replace( /\W/g, '' ); 
+		
+		if ( windowPOPUP( _id ) )
+		{
+			_doc = windowPopUp[_win_name].document;
+		}
+		
+		var oldTitle 	= _doc.title; 
 		var newTitle 	= "## NOVA MENSAGEM ##"; 
-		var idWindow	= arguments[1];
 
 		if( timeoutId == null )
@@ -460,18 +518,18 @@
 			timeoutId = setInterval(function()
 			{
-				document.title = ( document.title == newTitle ) ? oldTitle : newTitle;
+				_doc.title = ( _doc.title == newTitle ) ? oldTitle : newTitle;
 			}, 1000);
 			
-			configEvents( window.document, 'onclick', function()
+			configEvents( _doc, 'onclick', function()
 			{ 
 				clearInterval(timeoutId);
-				document.title	= oldTitle;
+				_doc.title	= oldTitle;
 				timeoutId		= null;
 			});
 			
-			configEvents( window.document, 'onkeypress', function()
+			configEvents( _doc, 'onkeypress', function()
 			{ 
 				clearInterval(timeoutId);
-				document.title	= oldTitle;
+				_doc.title	= oldTitle;
 				timeoutId		= null;
 			});
@@ -524,14 +582,4 @@
 				
 			window.document.body.appendChild(_optionsItens);
-			
-			
-			setTimeout(function()
-			{
-				window.document.oncontextmenu = function()
-				{
-					return true;
-				};
-				
-			},500);
 		}
 	}
@@ -682,42 +730,48 @@
 	function rosterDiv()
 	{
-		var _popUp = (_preferencesIM[1]).split(":");
-		 
-		var paramListContact = 
-		{
-			'idUser'		: Base64.decode(getUserCurrent().jid),
-			'full_name'		: (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")),
-			'path_jabberit' : path_jabberit,
-			'zIndex_'		: zIndex++
-		};
-
-		var winRosterDiv = 
-		{
-			 id_window		: "window_Roster_im",
-			 width			: 250,
-			 height			: 410,
-			 top			: 50,
-			 left			: -1500,
-			 leftOld		: 50,
-			 draggable		: true,
-			 visible		: "display",
-			 resizable		: true,
-			 zindex			: zIndex++,
-			 title			: "Expresso Messenger - Contatos",
-			 closeAction	: "hidden",
-			 content		: Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact)	
-		};
-		
-		if( _preferencesIM[0] == "openWindowJabberit:false" )
-		{
-			winRosterDiv.left		= 50;
-			winRosterDiv.leftOld	= -1500;
-		}
-			
-		_winBuild( winRosterDiv );
-		
-		// Photo User
-		getPhotoUser(Base64.decode(getUserCurrent().jid));
-		
+		var _rosterDiv = function()
+		{
+			var _popUp	= (_preferencesIM[1]).split(":");
+			var _idUser	= Base64.decode(getUserCurrent().jid);
+			
+			var paramListContact = 
+			{
+				'idUser'		: _idUser,
+				'full_name'		: (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")),
+				'path_jabberit' : path_jabberit,
+				'zIndex_'		: zIndex++
+			};
+	
+			var winRosterDiv = 
+			{
+				 id_window		: "window_Roster_im",
+				 width			: 250,
+				 height			: 410,
+				 top			: 50,
+				 left			: -1500,
+				 leftOld		: 50,
+				 draggable		: true,
+				 visible		: "display",
+				 resizable		: true,
+				 zindex			: zIndex++,
+				 title			: "Expresso Messenger - Contatos",
+				 closeAction	: "hidden",
+				 content		: Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact)	
+			};
+			
+			if( _preferencesIM[0] == "openWindowJabberit:false" )
+			{
+				winRosterDiv.left		= 50;
+				winRosterDiv.leftOld	= -1500;
+			}
+				
+			_winBuild( winRosterDiv );
+			
+			// Photo User
+			getPhotoUser(_idUser);
+			
+		}
+		
+		setTimeout( function(){ _rosterDiv(); }, 500 );
 	}
 
@@ -1014,4 +1068,69 @@
 	}
 
+	var _stylesheets = [ ];
+	var _links = document.getElementsByTagName( 'link' );
+	
+	for ( var i = 0; i < _links.length; i++ )
+		if ( _links.item( i ).type && _links.item( i ).type.toLowerCase( ) == 'text/css' )
+			_stylesheets[ _stylesheets.length ] = _links.item( i );  
+	
+	function windowPOPUP()
+	{
+		var _id = arguments[0];
+		var _win_name = _id.replace( /\W/g, '' ); 
+
+		if ( arguments.length == 1 )
+		{
+			if ( windowPopUp[_win_name] )
+				return true;
+			else
+				return false;
+		}
+		
+		if( arguments.length == 2 )
+		{	
+			if( !windowPopUp[_win_name] )
+			{
+				windowPopUp[_win_name] = window.open( '', _win_name + '__popup', 'height=355,width=380,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,titlebar=no');
+				var tmp = windowPopUp[_win_name].document;
+				
+				tmp.write('<html><head>');
+				tmp.write('</head><body>');
+				tmp.write('</body></html>');
+				tmp.close();
+				
+				for ( var i = 0; i < _stylesheets.length; i++ )
+					tmp.documentElement.getElementsByTagName( 'head' ).item(0).appendChild( _stylesheets[ i ].cloneNode( true ) );
+
+				var divPOP = getElement( _id + "__popUp" );
+					divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_down.png') no-repeat";
+					divPOP.innerHTML = "PopIn";
+					
+				function _close( )
+				{
+					windowPopUp[_win_name].close();
+					configEvents( divPOP ,'onclick', _close, true );
+				}
+					
+				configEvents( divPOP ,'onclick', _close );
+
+				var _content = tmp.documentElement.getElementsByTagName( 'body' ).item(0).appendChild( getElement(_id + '__chatBox' ).parentNode );
+
+				_content.firstChild.scrollTop = _content.firstChild.scrollHeight;
+
+				configEvents( windowPopUp[_win_name] ,'onbeforeunload', function()
+				{
+					delete windowPopUp[_win_name];
+					divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_up.png') no-repeat";
+					divPOP.innerHTML = "PopOut";
+					divPOP.onclick	= function(){ loadscript.windowPOPUP( _id , true ); };
+					_winBuild( 'window_chat_area_' + _id, "display" ).content( true );
+				});
+
+				_winBuild( 'window_chat_area_' + _id, 'hidden' );
+			}
+		}
+	}
+	
 	function loadIM()
 	{
@@ -1085,4 +1204,5 @@
 	loadIM.prototype.clrAllContacts		= clrAllContacts;
 	loadIM.prototype.configEvents		= configEvents;
+	loadIM.prototype.getIsIE			= getIsIE;
 	loadIM.prototype.getPhotoUser		= getPhotoUser;
 	loadIM.prototype.getStatusMessage	= getStatusMessage;
@@ -1111,4 +1231,5 @@
 	loadIM.prototype.renameGroup		= renameGroup;
 	loadIM.prototype.rosterDiv			= rosterDiv;
+	loadIM.prototype.windowPOPUP		= windowPOPUP;
 	
 	window.LoadIM = loadIM;
