/**
 * Floater - Copyright 2006-2007 Thomas Peri
 * version 2007-10-08 - fixed IE strict bug
 */
var Floater = new (function()
{
	var container,
		divs = {},
		dx = 0,
		dy = 0,
		ie = (navigator.appVersion.toLowerCase().indexOf('msie') != -1),
		ieBody,
		started = false,
		visible = false,
		x = 0,
		y = 0;
	
	function start()
	{
		if (started)
		{
			return;
		}
		ieBody = (document.compatMode && document.compatMode != "BackCompat") ? 
			document.documentElement : document.body;
		container = document.createElement('div');
		var s = container.style;
			s.position = 'absolute';
			s.top = '0px';
			s.left = '0px';
		document.body.appendChild(container);

		document.onmousemove = function(e)
		{
			if (ie)
			{
				x = event.clientX + ieBody.scrollLeft;
				y = event.clientY + ieBody.scrollTop;
			}
			else
			{
				x = e.pageX;
				y = e.pageY;
			}
			update();
			return true;
		};

		started = true;
	}
	
	function update()
	{
		if (visible)
		{
			container.style.top = (y + dy) + 'px';
			container.style.left = (x + dx) + 'px';
		}
	}
	
	function hide(id)
	{
		visible = false;
		divs[id].style.display = 'none';
	}
	
	function show(id, x, y)
	{
		dx = x;
		dy = y;
		visible = true;
		update();
		divs[id].style.display = 'block';
	}
	
	this.add = function(id)
	{
		start();
	
		var div = divs[id] = divs[id] ? 
			divs[id] : document.getElementById(id);
		
		div.parentNode.removeChild(div);
		container.appendChild(div);
	};
	
	this.show = function(span, id, x, y)
	{
		x = x ? x : 0;
		y = y ? y : 0;
		
		if (started)
		{
			span.onmouseover = function()
			{
				show(id, x, y);
			};
			span.onmouseout = function()
			{
				hide(id);
			};
			show(id, x, y);
		}
	};
	
})();
