
	function IM_showMessage(id, from, msg) {
		var el = addElement(id, '<font color="red">' + from + ': </font>' + msg.substr(0,350) + '...');
		el.style.display = 'none';
		position(el, 265, 120);
		Effect.Appear(el.id, { duration : 1.0 });
		setTimeout(IM_hideMessage, 5000, el);
	}
	
	function IM_hideMessage(el) {
		Effect.SwitchOff(el.id);
	}
	
	function position(el, width, height) {
		var size = getWindowSize();
		el.style.position = 'absolute';
		el.style.left = size[0] - width + 'px';
		el.style.top = size[1] - height + 'px';
	}
	
	function getWindowSize() {
		var viewportwidth;
		 var viewportheight;
		 
		 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		 
		 if (typeof window.innerWidth != 'undefined')
		 {
		      viewportwidth = window.innerWidth,
		      viewportheight = window.innerHeight
		 }
		 
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		
		 else if (typeof document.documentElement != 'undefined'
		     && typeof document.documentElement.clientWidth !=
		     'undefined' && document.documentElement.clientWidth != 0)
		 {
		       viewportwidth = document.documentElement.clientWidth,
		       viewportheight = document.documentElement.clientHeight
		 }
		 
		 // older versions of IE
		 
		 else
		 {
		       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		       viewportheight = document.getElementsByTagName('body')[0].clientHeight
		 }
		 return new Array(viewportwidth, viewportheight);
	}
	
	function addElement(id, content) {
	  var container = document.getElementById('msg-container');
	  var div = document.createElement('div');
	  div.setAttribute('id',id);
	  div.setAttribute('class','im-message');
	  div.innerHTML = '<br/><div class="content">' + content + '</div>';
	  container.appendChild(div);
	  return document.getElementById(id);
	}
	
	function removeElement(id) {
	  var container = document.getElementById('msg-container');
	  var div = document.getElementById(id);
	  container.removeChild(div);
	}