Index: /trunk/instant_messenger/js/connector.js
===================================================================
--- /trunk/instant_messenger/js/connector.js	(revision 151)
+++ /trunk/instant_messenger/js/connector.js	(revision 235)
@@ -1,4 +1,6 @@
 function Connector()
 {
+	this.__HTTP__ = [];
+	this.__THREADS__ = [];
 }
 
@@ -7,23 +9,24 @@
 	{
 		// connection
-		var __HTTP__ = null;
-		var __THREADS__ = [];
+		//var __HTTP__ = null;
+		//var __THREADS__ = [];
 		var index = 0;
 		var rtlen = 0;
 		var ie = false; // ie don't has stream
-		function makeConnection()
-		{
-			if ( __HTTP__ == null )
-				__HTTP__ = xhr();
+		var __this__ = this;
+		function makeConnection(pThread)
+		{
+			//if ( __this__.__HTTP__ === false )
+				__this__.__HTTP__[pThread] = xhr();
 		}
 		function setPost(pThread)
 		{
-			__THREADS__[pThread].__METHOD__ = 'POST';
+			__this__.__THREADS__[pThread].__METHOD__ = 'POST';
 			return true;
 		}
-		// this set __THREADS__[?].__TYPE__ to 4 for request or 3 for stream
+		// this set __this__.__THREADS__[?].__TYPE__ to 4 for request or 3 for stream
 		function setStream(pThread)
 		{
-			__THREADS__[pThread].__TYPE__ = ( !ie ) ? 3 : 4;
+			__this__.__THREADS__[pThread].__TYPE__ = ( !ie ) ? 3 : 4;
 			return true;
 		}
@@ -81,42 +84,53 @@
 		}
 
-		var __HANDLER__ = function()
+		function __HANDLER__()
 		{
 			try
 			{
-				if ( ie && __HTTP__.readyState != 4 )
+				if ( ie && __this__.__HTTP__[arguments[0]].readyState != 4 )
 					return false;
 
-				var threadId = __HTTP__.getResponseHeader('ThreadId');
+				//var threadId = __this__.__HTTP__[arguments[0]].getResponseHeader('ThreadId');
+				var threadId = arguments[0];
+
 				if ( !threadId )
 					return false;
 
-				var type = __THREADS__[threadId].__TYPE__;
-				if ( __HTTP__.readyState == 3 || __HTTP__.readyState == 4 )
-				{
-					if ( !ie && __HTTP__.readyState == 3 && __THREADS__[threadId].__HANDLER__.stream )
-					{
-						var data = trim(__HTTP__.responseText.substr(index));
-						rtlen = __HTTP__.responseText.length;
+				if ( __this__.__HTTP__[threadId].readyState == 3 || __this__.__HTTP__[threadId].readyState == 4 )
+				{
+					if ( !ie && __this__.__HTTP__[threadId].readyState == 3 && __this__.__THREADS__[threadId].__HANDLER__.stream )
+					{
+						var data = trim(__this__.__HTTP__[threadId].responseText.substr(index));
+						rtlen = __this__.__HTTP__[threadId].responseText.length;
 						if ( index < rtlen && data.length )
 						{
-							__THREADS__[threadId].__HANDLER__.stream(data);
+							__this__.__THREADS__[threadId].__HANDLER__.stream(data);
 							index = rtlen;
 						}
 					}
-					if ( __THREADS__[threadId].__HANDLER__.request && __HTTP__.readyState == 4 )
-					{
-						switch ( __HTTP__.status )
+					if ( __this__.__THREADS__[threadId].__HANDLER__.request && __this__.__HTTP__[threadId].readyState == 4 )
+					{
+						switch ( __this__.__HTTP__[threadId].status )
 						{
 							case 200:
-								var data = ( __THREADS__[threadId].__MODE__ == 'XML' ) ?
-									__HTTP__.responseXML :
-									__HTTP__.responseText;
-
-								if ( ie && __THREADS__[threadId].__HANDLER__.stream )
-									__THREADS__[threadId].__HANDLER__.stream(data);
-
-								if ( __THREADS__[threadId].__HANDLER__.request )
-									__THREADS__[threadId].__HANDLER__.request(data);
+								var stream = false;
+								var request = false;
+								var data = ( __this__.__THREADS__[threadId].__MODE__ == 'XML' ) ?
+									__this__.__HTTP__[threadId].responseXML :
+									__this__.__HTTP__[threadId].responseText;
+
+								if ( ie && __this__.__THREADS__[threadId].__HANDLER__.stream )
+									stream = __this__.__THREADS__[threadId].__HANDLER__.stream;
+
+								if ( __this__.__THREADS__[threadId].__HANDLER__.request )
+									request = __this__.__THREADS__[threadId].__HANDLER__.request;
+
+								delete __this__.__THREADS__[threadId];
+
+								if ( stream )
+									stream(data);
+
+								if ( request )
+									request(data);
 
 								break; // [case : status 200]
@@ -128,13 +142,13 @@
 					}
 				}
-				if ( __HTTP__.readyState == 4 )
-				{
-					delete __THREADS__[threadId];
-				}
+				//if ( __this__.__HTTP__.readyState == 4 )
+				//{
+				//	delete __this__.__THREADS__[threadId];
+				//}
 			}
 			catch(e)
 			{
 				//alert("__HANDLER__\n" + threadId + "\n " + e + "\n ErroR: " + e.description);
-				//delete __THREADS__[threadId];
+				//delete __this__.__THREADS__[threadId];
 			}
 		};
@@ -144,8 +158,8 @@
 			return {'error':'#0 - invalid params'};
 
-		if ( __THREADS__[arguments[0]] )
+		if ( __this__.__THREADS__[arguments[0]] )
 			return {'error':'#2 - request is running'};
 
-		__THREADS__[arguments[0]] = {
+		__this__.__THREADS__[arguments[0]] = {
 			'__HANDLER__' : arguments[1],
 			'__METHOD__'  : 'GET',  // __METHOD__ = [GET | POST]
@@ -154,9 +168,9 @@
 		};
 
-		makeConnection();
+		makeConnection(arguments[0]);
 
 		if ( !verifyUserHandler(arguments[0], arguments[1]) )
 		{
-			delete __THREADS__[arguments[0]];
+			//delete __this__.__THREADS__[arguments[0]];
 			return {'error':'#1 - invalid handler'};
 		}
@@ -165,24 +179,28 @@
 			setPost(arguments[0]);
 
-		if ( __HTTP__ != null )
+		if ( __this__.__HTTP__[arguments[0]] != null )
 		{
 			try
 			{
 				var __TARGET__ = path_im + 'controller.php?act=' + arguments[0];
+
+				//alert("__METHOD__: " + __this__.__THREADS__[arguments[0]].__METHOD__ + "\n__TARGET__: " + __TARGET__)
+
 				var __SEND__ = null;
-				__HTTP__.open(__THREADS__[arguments[0]].__METHOD__, __TARGET__, true);
-				if ( __THREADS__[arguments[0]].__METHOD__ == 'POST' )
-				{
-					__HTTP__.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
-					__HTTP__.setRequestHeader('Cache-Control',  'no-store, no-cache, must-revalidate');
-					__HTTP__.setRequestHeader('Cache-Control', 'post-check=0, pre-check=0');
-					__HTTP__.setRequestHeader('Pragma', 'no-cache');
+				__this__.__HTTP__[arguments[0]].open(__this__.__THREADS__[arguments[0]].__METHOD__, __TARGET__, true);
+				if ( __this__.__THREADS__[arguments[0]].__METHOD__ == 'POST' )
+				{
+					__this__.__HTTP__[arguments[0]].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
+					__this__.__HTTP__[arguments[0]].setRequestHeader('Cache-Control',  'no-store, no-cache, must-revalidate');
+					__this__.__HTTP__[arguments[0]].setRequestHeader('Cache-Control', 'post-check=0, pre-check=0');
+					__this__.__HTTP__[arguments[0]].setRequestHeader('Pragma', 'no-cache');
 					__SEND__ = arguments[2];
 				}
-				//__HTTP__.setRequestHeader('ThreadId', arguments[0]);
-				//__HTTP__.setRequestHeader('Connection', 'close');
-				//__HTTP__.setRequestHeader('Keep-Alive', '0');
-				__HTTP__.onreadystatechange = __HANDLER__;
-				__HTTP__.send(__SEND__);
+				//__this__.__HTTP__.setRequestHeader('ThreadId', arguments[0]);
+				//__this__.__HTTP__.setRequestHeader('Connection', 'close');
+				//__this__.__HTTP__.setRequestHeader('Keep-Alive', '0');
+				var tst = arguments[0];
+				__this__.__HTTP__[arguments[0]].onreadystatechange = function(){__HANDLER__(tst)};
+				__this__.__HTTP__[arguments[0]].send(__SEND__);
 			}
 			catch(e)
Index: /trunk/instant_messenger/js/client.js
===================================================================
--- /trunk/instant_messenger/js/client.js	(revision 227)
+++ /trunk/instant_messenger/js/client.js	(revision 235)
@@ -32,5 +32,4 @@
 			im.statusFlag = 'unavailable';					
 
-			//im_window.visible('_contacts_im_','block');
 		}
 		else if ( data.lastIndexOf('>') == data.length - 1)
@@ -65,5 +64,4 @@
 				{
 					jabber.doIt(nodeName, node);
-					//node = nextSibling;
 				}
 				node = node.nextSibling;
@@ -82,2 +80,8 @@
 	setTimeout("con.go('$this.Ujabber.getContacts', {'request':"+contacts+"})", 3000);
 }
+window.onbeforeunload = function(){con.__HTTP__['$this.Ujabber.listen'].abort();}
+/*window.onbeforeunload = function(){con.__HTTP__['$this.Ujabber.getContacts'].abort();}
+window.onbeforeunload = function(){con.__HTTP__['$this.Ujabber.getVcard'].abort();}
+window.onbeforeunload = function(){con.__HTTP__['$this.ldap_im.photo_ldap'].abort();}
+window.onbeforeunload = function(){con.__HTTP__['$this.Ujabber.setStatus'].abort();}
+window.onbeforeunload = function(){con.__HTTP__['$this.Ujabber.setPresence'].abort();}*/
Index: /trunk/instant_messenger/js/templates.js
===================================================================
--- /trunk/instant_messenger/js/templates.js	(revision 164)
+++ /trunk/instant_messenger/js/templates.js	(revision 235)
@@ -26,5 +26,4 @@
 		im_window.elementC('add_user_im').innerHTML  = this.xtools.parse(XmlDoc,'add_user.xsl');
 		im.ldap();
-		//im_window.visible('add_user_im','block');
 	},
 
@@ -53,22 +52,28 @@
 	"fast_menu" : function()
 	{
-		var XmlDoc = "<fast_menu>" +	
-						"<lang1>Online</lang1>" +
-						"<lang2>Ausente</lang2>" +
-						"<lang3>Ocupado</lang3>" +
-						"<lang4>Offline</lang4>" +
-						"<lang5>Mensagem</lang5>" +
-						"<img1>"+path_im+"templates/default/images/available.gif</img1>" +
-						"<img2>"+path_im+"templates/default/images/away.gif</img2>" +
-						"<img3>"+path_im+"templates/default/images/dnd.gif</img3>" +
-						"<img4>"+path_im+"templates/default/images/unavailable.gif</img4>" +
-						"<img5>"+path_im+"templates/default/images/icon_edit.gif</img5>" +																		
-					 "</fast_menu>";
-
-		menu_action.menu('fast_menu_im', this.xtools.parse(XmlDoc,'fast_menu.xsl'));
-		document.getElementById('fast_menu_im').style.top = document.getElementById('fast_menu_im').offsetTop + 60;
-		document.getElementById('fast_menu_im').style.left = document.getElementById('fast_menu_im').offsetLeft + 5;
-		document.getElementById('fast_menu_im').style.zIndex = this.zValue++;
-		document.getElementById('fast_menu_im').style.position = "absolute";
+		if( document.getElementById('_contacts_im_' + '_window_master') != null )
+		{
+			var XmlDoc = "<fast_menu>" +	
+							"<lang1>Online</lang1>" +
+							"<lang2>Ausente</lang2>" +
+							"<lang3>Ocupado</lang3>" +
+							"<lang4>Offline</lang4>" +
+							"<lang5>Mensagem</lang5>" +
+							"<img1>"+path_im+"templates/default/images/available.gif</img1>" +
+							"<img2>"+path_im+"templates/default/images/away.gif</img2>" +
+							"<img3>"+path_im+"templates/default/images/dnd.gif</img3>" +
+							"<img4>"+path_im+"templates/default/images/unavailable.gif</img4>" +
+							"<img5>"+path_im+"templates/default/images/icon_edit.gif</img5>" +																		
+						 "</fast_menu>";
+	
+			menu_action.menu('fast_menu_im', this.xtools.parse(XmlDoc,'fast_menu.xsl'));
+			document.getElementById('fast_menu_im').style.top = document.getElementById('fast_menu_im').offsetTop + 60;
+			document.getElementById('fast_menu_im').style.left = document.getElementById('fast_menu_im').offsetLeft + 5;
+			document.getElementById('fast_menu_im').style.zIndex = this.zValue++;
+			document.getElementById('fast_menu_im').style.position = "absolute";
+		}
+		else
+			alert('Aguarde carregando lista de contatos ....');
+					
 	},
 	
@@ -91,5 +96,4 @@
 		im_window.elementC('my_settings_im').innerHTML = this.xtools.parse(XmlDoc,'mysettings.xsl');
 		im.get_preferences();
-		//im_window.visible('my_settings_im','block');
 	},
 	
Index: /trunk/instant_messenger/js/load.js
===================================================================
--- /trunk/instant_messenger/js/load.js	(revision 227)
+++ /trunk/instant_messenger/js/load.js	(revision 235)
@@ -1,7 +1,7 @@
 	var focusFlag = true;
 	
-	window.document.onblur	= windowBlur;
-	window.document.onclick	= windowFocus;
-	window.document.onmouseover	= awayTimer;
+	//window.document.onblur	= windowBlur;
+	//window.document.onclick	= windowFocus;
+	//window.document.onmouseover	= awayTimer;
 	
 	var window_title = document.title;
@@ -25,5 +25,8 @@
 	function load_im_contacts()
 	{
-		im_window.load('_contacts_im_','instant_messenger_content', '<title>Expresso Messenger</title>', 'window.xsl','',true,true,false);
+		if( document.getElementById('_contacts_im_' + '_window_master') != null )
+			im_window.load('_contacts_im_','instant_messenger_content', '<title>Expresso Messenger</title>', 'window.xsl','',true,true,false);
+		else
+			alert('Aguarde carregando lista de contatos ....');			
 	}
 	
@@ -46,5 +49,5 @@
 	function awayTimer()
 	{
-		if( _awayTimer_ )
+		/*if( _awayTimer_ )
 		{
 			clearTimeout(_awayTimer_);
@@ -52,5 +55,5 @@
 				im.presence('available');
 		}
-		_awayTimer_ = setTimeout("im.set_timeOut()", parseInt(im.timeOut_im) * 60000 );
+		_awayTimer_ = setTimeout("im.set_timeOut()", parseInt(im.timeOut_im) * 60000 );*/
 	}
 
