// mBubble, by Mark Willis. www.MarkWillis.co.uk 
// Extension of mFloat.

var MouseX = 0; var MouseY = 0; var mBOverit = 0;

var mFloatViewportWidth;
var mFloatViewportHeight;
function mBviewportScan()
{
if (typeof window.innerWidth != 'undefined')
{
	mFloatViewportWidth = window.innerWidth;
	mFloatViewportHeight = window.innerHeight;
}
// IE6
else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
{
	mFloatViewportWidth = document.documentElement.clientWidth;
	mFloatViewportHeight = document.documentElement.clientHeight;
}
// even older IE :O
else
{
	mFloatViewportWidth = document.getElementsByTagName('body')[0].clientWidth;
	mFloatViewportHeight = document.getElementsByTagName('body')[0].clientHeight;
}
}
mBviewportScan();

function mBTrackingMousePosition(e)
{
	// Thank you 'Marss' from Ukraine! :D
	e = e || window.event;
	if (e.pageX)
	{
		MouseX = e.pageX;
		MouseY = e.pageY;
		mBviewportScan();
		if(MouseX + 350 > mFloatViewportWidth){MouseX = MouseX - 300;}
		if(document.getElementById('mBubbleBlock').style.display == "block"){
			document.getElementById('mBubbleBlock').style.left = (MouseX + 10) + "px";
			document.getElementById('mBubbleBlock').style.top = (MouseY + 10) + "px";
		}
	}
	else
	{
		x = window.event.clientX+document.documentElement.scrollLeft;
		y = window.event.clientY+document.documentElement.scrollTop;
		mBviewportScan();
		if(x + 350 > mFloatViewportWidth){x = x - 300;}
		if(document.getElementById('mBubbleBlock').style.display == "block"){
			document.getElementById('mBubbleBlock').style.left = (x + 10) + "px";
			document.getElementById('mBubbleBlock').style.top = (y + 10) + "px";
		}
	}
	
}
document.onmousemove = mBTrackingMousePosition;

function showBubble(bubbleTITLE, bubbleCONTENT){
document.getElementById('mBubbleBlock').innerHTML = "<div class=\"mBubble-inside\"><b>" + bubbleTITLE + "</b><br />" + bubbleCONTENT + "</div>";
document.getElementById('mBubbleBlock').className = 'mBubble-on';
document.getElementById('mBubbleBlock').style.display = "block";
var x = 0; var y = 0;
if (MouseX)
	{
		x = MouseX;
		y = MouseY;
	}
else
	{
		x = window.event.clientX+document.documentElement.scrollLeft;
		y = window.event.clientY+document.documentElement.scrollTop;
	}
if(x + 350 > mFloatViewportWidth){x = x - 300;}
document.getElementById('mBubbleBlock').style.left = (x + 10) + "px";
document.getElementById('mBubbleBlock').style.top = (y + 10) + "px";
mBOverit = 1;
}

function clearBubble(){
document.getElementById('mBubbleBlock').innerHTML = '';
document.getElementById('mBubbleBlock').className = 'mBubble-off';
document.getElementById('mBubbleBlock').style.display = "none";
mBOverit = 0;
}
