settings = 
{
	tl: { radius: 10 },
	tr: { radius: 10 },
	bl: { radius: 10 },
	br: { radius: 10 },
	antiAlias: true,
	autoPad: false
} 

function showBalloon(x, y) 
{
	var balloonDivElement = document.getElementById("balloon");
	
	if (undefined != balloonDivElement) 
	{
		balloonDivElement.style.display = "block";

		balloonDivElement.style.filter = 'alpha(opacity=88)';
		balloonDivElement.style.opacity = .88;

		var cornersObj = new curvyCorners(settings, "content");
		cornersObj.applyCornersToAll();

		// make sure the balloon is always within the viewpoint
		var widthOfBalloon = balloonDivElement.style.width.substr(0, balloonDivElement.style.width.length - balloonDivElement.style.width.indexOf("px") + 1);
		var heightOfBalloon = balloonDivElement.offsetHeight;
		
		var text = new String(x);
		var left = text.substr(0, text.length - text.indexOf("px") + 1);
		var sum = Number(left) + Number(widthOfBalloon);
		
		while ((sum > YAHOO.util.Dom.getViewportWidth()) && (left > 0))
		{
			left = Number(left - 50);
			sum = Number(left) + Number(widthOfBalloon);
		}

		// position tooltip at y
		var balloonTip = YAHOO.util.Dom.getElementsByClassName("balloonTip", "div", balloonDivElement)[0];
		var top = YAHOO.util.Dom.getY(balloonTip);	

		text = new String(y);
		top = (text.substr(0, text.length - text.indexOf("px") + 1)) - heightOfBalloon;

		YAHOO.util.Dom.setX(balloonDivElement, left);
		YAHOO.util.Dom.setY(balloonDivElement, top + 7);

		YAHOO.util.Dom.setX(balloonTip, x + 15);
		YAHOO.util.Dom.setY(balloonTip, y - 17);
		
		YAHOO.util.Event.addListener("closeLink", "click", hideBalloon);
		YAHOO.util.Event.addListener("closeLink", "mouseover", function() { this.style.cursor = "pointer"; });
		YAHOO.util.Event.addListener("closeLink", "mouseout", function() { this.style.cursor = "default"; });
	}

	return false;
}

function hideBalloon() 
{
	var balloonDivElement = document.getElementById("balloon");
			
	if (undefined != balloonDivElement)
	{
		balloonDivElement.style.display = "none";
		
		while (balloonDivElement.firstChild)
			balloonDivElement.removeChild(balloonDivElement.firstChild);

		document.body.removeChild(balloonDivElement);
		document.onmousemove = null;
	}
}

function initMouseTracking() 
{
	document.onmousemove = mousemove;
}

function mousemove(e) 
{
	if (undefined == e)
	{
		var mouseX = event.clientX;
		var mouseY = event.clientY;
	}
	else
	{
		var mouseX = e.pageX;
		var mouseY = e.pageY;
	}
	
	var balloonDiv = document.getElementById("balloon");
	var balloonX = YAHOO.util.Dom.getX(balloonDiv);
	var balloonY = YAHOO.util.Dom.getY(balloonDiv);
	var balloonWidth = balloonDiv.offsetWidth;
	var balloonHeight = balloonDiv.offsetHeight;
	
//	alert(mouseX + " " + mouseY + " " + balloonX + " " + balloonY + " " + balloonDiv.offsetWidth + " " + balloonDiv.offsetHeight);

	// check if mouse cursor is within range of balloon
	if ( (mouseX  < balloonX) || (mouseX  > balloonX + balloonWidth) )
		hideBalloon();

	if ( (mouseY  < balloonY) || (mouseY  > balloonY + balloonHeight) )
		hideBalloon();
		
}