
		var mouse_x = 0;
		var mouse_y = 0;
		
		var initial_right	= 20;
		var initial_top		= 160;
		
		function webim_action( action )
		{
						var message = "";
						var msgid 	= 0;
						var to			= 0;
						
						if( document.frm_message.message ) message	= document.frm_message.message.value;
						if( document.frm_message.to ) to = document.frm_message.to.value;
						if( document.frm_message.msgid ) msgid = document.frm_message.msgid.value;						

				if( action == "send-message" )
				{	
						webim_output( '', '&action=send-message&msgid='+msgid+'&to='+to+'&message='+message );						
						webim_hide();
				}
				else if( action == "close-message" )
				{						
						webim_output( '', '&action=close-message&msgid='+msgid );
						webim_hide();
				}
				else if( action == "ignore-message" )
				{
						var userid	= document.frm_message.to.value;
						
						webim_output( '', '&action=ignore-message&userid='+userid+'&msgid='+msgid );
						webim_hide();
				}
		}
		
		function webim_hide()
		{
				document.getElementById("webim-container").style.visibility = "hidden";
				document.getElementById("webim-container").innerHTML = "";
		}
		
		function webim_show( dialog, opts )
		{
				var html_output = webim_output( dialog, opts );				
				
				/*if( dialog == "new-message" )
				{
						document.getElementById("webim-container").style.left = mouse_x - 10;
						document.getElementById("webim-container").style.top = mouse_y - 10;
				} else {
						document.getElementById("webim-container").style.right = initial_right;
						document.getElementById("webim-container").style.top = initial_top;
				}*/
				
				document.getElementById("webim-container").innerHTML = html_output;
				document.getElementById("webim-container").style.visibility = 'visible';
		}
		
		function webim_output( dialog, opts )
		{
				var engine = "/web-im/web-im.php?";
				if( dialog != "" && dialog != null && dialog != undefined ) engine += "dialog="+dialog;
				if( opts != "" && opts != null && opts != undefined ) engine += "&" + opts;
				
				if(	window.XMLHttpRequest ) // Firefox
				{
						objXml 	= new XMLHttpRequest();
						objXml.open("GET", engine, false);
						objXml.send(null);
					  data 		= objXml.responseText;
				}
				else if(window.ActiveXObject) // Internet Explorer
				{
						objXml 	= new ActiveXObject("Microsoft.XMLHTTP");
						
						objXml.open("GET", engine, true);
						objXml.onreadystatechange=function() {
						   	if (objXml.readyState==4) {
						   	   data = objXml.responseText;
						  	}
						 }						
						objXml.send();
				}
				
				return data;
		}
		
		
		
		function track_mouse( e ){
		  
		  var doc_ref = "";
		  
		  if( e ){   
		    mouse_x = e.pageX;
		    mouse_y = e.pageY;
		  }
		  else
		  {
		    mouse_x = event.clientX;
		    mouse_y = event.clientY;
		
		    if( document.documentElement && document.documentElement.clientWidth) // Donc DOCTYPE
		      doc_ref = document.documentElement;
		    else
		      doc_ref = document.body;
		      
		    mouse_x += doc_ref.scrollLeft;
		    mouse_y += doc_ref.scrollTop;
		  }
		}

		document.onmousemove = track_mouse;		
		document.write( '<div id="webim-container" class="webim-container"></div>' );