Index: trunk/jabberit_messenger/js/makeW.js
===================================================================
--- trunk/jabberit_messenger/js/makeW.js	(revision 2226)
+++ trunk/jabberit_messenger/js/makeW.js	(revision 2925)
@@ -5,8 +5,10 @@
 	var path		= path_jabberit;
 	
+	var _dialogs = [ ];
+	
 	function build(pObj)
 	{
 		var _window = getElement( pObj.id_window + '__parent');
-		Xtools = new JITXtools(path);		
+		Xtools = new JITXtools(path);	
 		
 		if( _window == null )
@@ -30,8 +32,16 @@
 				_window.setAttribute("leftOld", pObj.left + "px" );
 			
+			if( pObj.leftOld )
+				_window.setAttribute("leftOld", pObj.leftOld + "px" );
+			
 			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 )
 			{
@@ -39,8 +49,12 @@
 				dragDrop.set( pObj.id_window );
 			}
+			
 		}
 		else
 		{
-			load(pObj.id_window, "display");
+	    	if ( pObj.barejid && loadscript.windowPOPUP( pObj.barejid ) )
+	    		return false;
+
+	    	load(pObj.id_window, "display");
 		}
 	}
@@ -53,25 +67,23 @@
 	function load( pId, pVisible )
 	{
-		var winM = document.getElementById( pId + '__parent')
+		var _window = document.getElementById( pId + '__parent')
 		
-		if( winM != null )
+		if( _window != null )
 		{
 			if ( pVisible == "display" )
 			{
-				if(winM.getAttribute("leftOld") != "-1500px")
-					winM.style.left = winM.getAttribute("leftOld");
-				else
-					winM.style.left = "70px";
-			}	
+				if( _window.style.left == "-1500px" )
+					_window.style.left = _window.getAttribute("leftOld");
+			}
 			
 			if ( pVisible == "hidden")
 			{
-				winM.setAttribute("leftOld" , winM.style.left );
-				winM.style.left = "-1500px";
+				_window.setAttribute("leftOld" , _window.style.left );
+				_window.style.left = "-1500px";
 			}
 			
 			if( pVisible == "remove" )
 			{
-				document.body.removeChild( winM );
+				document.body.removeChild( _window );
 			}
 		}
@@ -82,19 +94,28 @@
 		if( arguments.length > 0 )
 		{
+			var pId = null;
 			if( arguments.length == 1 )
 			{
-				JSLoader.load([path + "js/dragdrop.js"]);
-				JSLoader.load([path + "templates/default/css/button.css"])
-
 				var obj = arguments[0];
-	
-				setTimeout(function(){ build(obj);}, 200);
+				pId = obj.id_window
+				build(obj);
 			}
-
+			
 			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 ];
+			};
+		} );
 	}
 
@@ -108,8 +129,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: trunk/jabberit_messenger/js/load.js
===================================================================
--- trunk/jabberit_messenger/js/load.js	(revision 2810)
+++ trunk/jabberit_messenger/js/load.js	(revision 2925)
@@ -436,42 +436,39 @@
 		winBuild(_win_preferences);
 
-		var _preferences = function()
-		{
-			// Element openWindowJabberit
-			var value1 = flagOpenIM.split(':');
-			var element1 = document.getElementById(value1[0]);
-			var valueSelect1 = value1[1];
-			
-			for(var i = 0; i < element1.options.length; i++)
-				if( element1.options[i].value == valueSelect1 )
-					element1.options[i].selected = true;
-
-			
-			// Element openWindowJabberitPopUp
-			var value2 = flagOpenPopup.split(':');
-			var element2 = document.getElementById(value2[0]);
-			var valueSelect2 = value2[1];
+		// Element openWindowJabberit
+		var value1			= flagOpenIM.split(':');
+		var element1		= document.getElementById(value1[0]);
+		var valueSelect1	= value1[1];
+		
+		for(var i = 0; i < element1.options.length; i++)
+			if( element1.options[i].value == valueSelect1 )
+				element1.options[i].selected = true;
+
+		
+		// Element openWindowJabberitPopUp
+		var value2			= flagOpenPopup.split(':');
+		var element2		= document.getElementById(value2[0]);
+		var valueSelect2	= value2[1];
+			
+		for(var i = 0; i < element2.options.length; i++)
+			if( element2.options[i].value == valueSelect2 )
+				element2.options[i].selected = true;
 				
-			for(var i = 0; i < element2.options.length; i++)
-				if( element2.options[i].value == valueSelect2 )
-					element2.options[i].selected = true;
-					
-			// Element flagAwayIM
-			var value3 = flagAwayIM.split(':');
-			var element3 = document.getElementById(value3[0]);
-			element3.value = value3[1];
-			
-			
-			var _pButtons = {
-					'lang1' : jabberitGetLang('Save'),
-					'lang2' : jabberitGetLang('Close'),
-					'onclickClose' : 'winBuild("jabberit_preferences","remove");',
-					'onclickSubmit' : 'javascript:loadscript.setPrefe();'
-			}; 
-			
-			document.getElementById('buttons_preferences_jabberit').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);
-		}
-
-		setTimeout(function(){ _preferences();}, 220);
+		// Element flagAwayIM
+		var value3		= flagAwayIM.split(':');
+		var element3	= document.getElementById(value3[0]);
+		element3.value	= value3[1];
+		
+		
+		var _pButtons =
+		{
+			'lang1' : jabberitGetLang('Save'),
+			'lang2' : jabberitGetLang('Close'),
+			'onclickClose' : 'winBuild("jabberit_preferences","remove");',
+			'onclickSubmit' : 'javascript:loadscript.setPrefe();'
+		}; 
+		
+		document.getElementById('buttons_preferences_jabberit').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons);
+		
 	}
 
@@ -583,5 +580,6 @@
 							height		 : sizeW.h,
 							top		 	 : 60,
-							left		 : pLeft,
+							left 		 : -1500,
+							leftOld		 : 50,
 							draggable	 : true,
 							visible	 	 : "display",
@@ -592,4 +590,5 @@
 							content		 : ""
 		};
+		
 	}
 	
Index: trunk/jabberit_messenger/js/dragdrop.js
===================================================================
--- trunk/jabberit_messenger/js/dragdrop.js	(revision 1566)
+++ trunk/jabberit_messenger/js/dragdrop.js	(revision 2925)
@@ -8,24 +8,33 @@
 	function _configEvent(pObj, pEvent, pHandler)
 	{
-		if ( typeof pObj == 'object' )
-		{
-			if ( pEvent.substring(0, 2) == 'on' )
-				pEvent = pEvent.substring(2, pEvent.length);
-	
-			if ( arguments.length == 3 )
+		try
+		{
+			if (typeof pObj == 'object')
 			{
-				if ( pObj.addEventListener )
-					pObj.addEventListener(pEvent, pHandler, false);
-				else if ( pObj.attachEvent )
-					pObj.attachEvent('on' + pEvent, pHandler);
+				if (pEvent.substring(0, 2) == 'on') 
+					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 != 'undefined') 
+							pObj.removeEventListener(pEvent, pHandler, false);
+						else 
+							if (pObj.detachEvent) 
+								pObj.detachEvent('on' + pEvent, pHandler);
+					}
+				}
 			}
-			else if ( arguments.length == 4 )
-			{
-				if ( pObj.removeEventListener && pObj.removeEventListener != 'undefined')
-					pObj.removeEventListener(pEvent, pHandler, false);
-				else if ( pObj.detachEvent )
-					pObj.detachEvent('on' + pEvent, pHandler);
-			}
-		}
+		}
+		catch(e){}
 	}
 
