(function($) {
	$(document).ready(function() {
		$('a.i-need-info')
			.each(function(e) {
				var timer = null;
				var connectWith = $(this).find('div.message');
				$(this)
					.attr('title', '')
					.mouseover(function() {
						connectWith.fadeIn('fast').trigger('over', {target: this});
						$('div.message.floating:visible').not(connectWith).fadeOut('fast');
					});

				connectWith
					.bind('over', function (e, data) {
						$(this).css({
							top: $(data.target).offset().top - ($(this).height() / 2),
							left: $(data.target).offset().left - ($(this).width() / 2)
						});
					})
					.appendTo('body')
					.mouseout(function(e) {
						var self = this;
						timer = window.setTimeout(
							function() {
								$(self).fadeOut('fast')
							}
							, 1
						);
					})
					.mouseover(function() {
						window.clearTimeout(timer);
						$(this).show();
					});
			});

		$('body')
			.click(function(e) {
				if (!$(e.target).is('div.message.floating')) {
					$('div.message.floating').fadeOut('fast');
				}
			});
	});
})(jQuery);