String.prototype.ReplaceAll = function(stringToFind,stringToReplace){
var temp = this;
var index = temp.indexOf(stringToFind);
	while(index != -1){
		temp = temp.replace(stringToFind,stringToReplace);
		index = temp.indexOf(stringToFind);
	}
	return temp;
}

$(document).ready(function() {
  $("body").append("<div id='ToolTipDiv'></div>");
  $("a[title]").each(function() {
	if ($(this).attr('rel') == 'use_tooltip') {
		$(this).hover(function(e) {
		  $().mousemove(function(e) {
			var tipY = e.pageY + 16;
			var tipX = e.pageX + 16;
			$("#ToolTipDiv").css({'top': tipY, 'left': tipX});
		  });
		  $("#ToolTipDiv")
			.html($(this).attr('title').ReplaceAll('\\n','<br/>'))
			.stop(true,true)
			.fadeIn("fast");
		  $(this).removeAttr('title');
		}, function() {
		  $("#ToolTipDiv")
			.stop(true,true)
			.fadeOut("fast");
		  $(this).attr('title', $("#ToolTipDiv").html().ReplaceAll('<br/>','\\n'));
		});
	}
  });
});
