var imagePath = "/i/tooltiparrow.gif";
var enabletip=false;

function addwarning()
{
	$("a.addToolTip").each(function(idx) {
		$(this).attr("tooltiptext", $(this).attr("title"));
		$(this).removeAttr("title");

		$(this).mouseover(function() {
			ddrivetip($(this).attr("tooltiptext"));
		});
		$(this).mouseout(function() {
			hideddrivetip();
		});
	});
}

function positiontip(e)
{
	 if(!enabletip)
		return;

	tp = $("#ToolTipPointer");
	offset = tp.parent().offset();
	tp.show();
	tp.css('top',  (e.pageY-5-offset.top)+"px");
	tp.css('left', (e.pageX-12-offset.left)+"px");

	tt = $("#theToolTip");
	offset = tt.parent().offset();
	tt.show();
	tt.css('top',  (e.pageY+18-offset.top)+"px");
	tt.css('left', (e.pageX-30-offset.left)+"px");

	tp.css("visibility","visible");
	tt.css("visibility","visible");
}

function ddrivetip(thetext, thewidth, thecolor)
{
	if(enabletip)
		return false;
	
	enabletip=true;
	$("#theToolTip").html(thetext);

	return false;
}

function hideddrivetip()
{
	enabletip=false;

	$("#theToolTip").hide();
	$("#ToolTipPointer").hide();
}

$(function() {
	$('body').append('<div id="theToolTip"></div>','<img id="ToolTipPointer" src="'+imagePath+'">');
	
	$(document).mousemove(function(e) {
		positiontip(e);
	}); 

	addwarning();
});

