// code to format the tooltip content correctly
var currentImgArea = null;
var currentSuffix = '';
function showPointCoordinates(x,y,label,isBarArea,imgArea)
{
	if(imgArea) currentImgArea = imgArea;
	//currentImgArea.onmouseout = "";
	var suffix = currentImgArea.parentNode.name;
	i = suffix.indexOf('_');
	currentSuffix = suffix.substring(i);
	var d = document.getElementById('t1'+currentSuffix);
	var d2 = document.getElementById('t2'+currentSuffix);
	$('#t1'+currentSuffix).show();
	$('#t2'+currentSuffix).show();
	$('#t2'+currentSuffix).trigger('mouseenter');
	//$('#img'+currentSuffix).mouseout(function(){return;});
	//$('#img'+currentSuffix).mouseover(function(){return;});
	//$('#msg'+currentSuffix).append("showing "+currentSuffix+" boxes <br/>");
	var coords = currentImgArea.coords.split(",");
	if(isBarArea)
	{
		_width = parseFloat(coords[2]) - parseFloat(coords[0]);
		_height = parseFloat(coords[3]) - parseFloat(coords[1]);
		_left = parseFloat(coords[0]);
		_top = parseFloat(coords[1]);
	}
	else
	{
		_radius = parseFloat(coords[2]);
		_width = _radius;
		_height = _width;
		_left = parseFloat(coords[0])-_radius/2+1;
		_top = parseFloat(coords[1])-_radius/2+2;
		d2.style.backgroundColor = 'yellow';
		d2.style.border = "0pt";		
	}
	d2.style.width = _width+"px";
	d2.style.height = _height+"px";
	d2.style.left = _left+"px";
	d2.style.top = _top+"px";
	//alert(d2.style.top);
	d.innerHTML = label+'<br/>'+x+', '+y;
	d.style.left = _left;
	d.style.top = _top+2*_height;
}

function hidePointCoordinates()
{
	return;
	/*
	var d = document.getElementById('t1'+currentSuffix);
	if(d !== null)
	{
		if(d.style.visibility == 'visible' || d.style.visibility == 'show') d.style.visibility = 'hidden';
	}
	var d2 = document.getElementById('t2'+currentSuffix);
	if(d2 !== null)
	{
		if(d2.style.visibility == 'visible' || d2.style.visibility == 'show') d2.style.visibility = 'hidden';
	}
	*/
	//if ( $('#t1'+currentSuffix).is(":visible") ) 
	$('#t1'+currentSuffix).hide();
	//if ( $('#t2'+currentSuffix).is(":visible") ) 
	$('#t2'+currentSuffix).hide();
	if(currentImgArea !== null)
	{
		currentImgArea.onmouseout = hidePointCoordinates;
	}
}

function hoverIn(x,y,label,isBarArea)
{
	imgArea = $(this);
	if(imgArea) currentImgArea = imgArea;
	var suffix = currentImgArea.parentNode.name;
	i = suffix.indexOf('_');
	currentSuffix = suffix.substring(i);
	$('#t1'+currentSuffix).show();
	$('#t2'+currentSuffix).show();
	var coords = currentImgArea.coords.split(",");
	if(isBarArea)
	{
		_width = parseFloat(coords[2]) - parseFloat(coords[0]);
		_height = parseFloat(coords[3]) - parseFloat(coords[1]);
		_left = parseFloat(coords[0]);
		_top = parseFloat(coords[1]);
		//alert(left);
	}
	else
	{
		_radius = parseFloat(coords[2]);
		_width = _radius;
		_height = _width;
		_left = parseFloat(coords[0])-_radius/2+1;
		_top = parseFloat(coords[1])-_radius/2+2;
		d2.style.backgroundColor = 'yellow';
		d2.style.border = "0pt";		
	}
	$('#t2'+currentSuffix).width(_width);
	$('#t2'+currentSuffix).height( _height);
	$('#t2'+currentSuffix).css('left',_left);
	$('#t2'+currentSuffix).css('top',_top);
	//alert(d2.style.top);
	$('#t1'+currentSuffix).html(label+'<br/>'+x+', '+y);
	$('#t2'+currentSuffix).css('left',_left);
	$('#t1'+currentSuffix).css('top',_top+2*_height);
}

function hoverOut()
{
	$('#t1'+currentSuffix).hide();
	$('#t2'+currentSuffix).hide();
}
