(function($) {
	var id = "altTip",		// Tip id
		$this,				// Target elem
		opts = {
			addClass: null
		};

	$.fn.jAltTip = function(options) {
		$.extend(opts, options);

		$this = this;

		if (!$("#" + id).length)
			// Tip html create
			$("<div>")
				.attr("id", id)
				.css({
					position: "absolute",
					display: "none"
				})
				.appendTo("body");

		var elem = $("#" + id)
			margin = 10,
			opacity = 0.8;

		if (opts.addClass)
			elem.addClass(opts.addClass);
		else
			elem.css({
				backgroundColor: "#888"
			})

		// Event setter
		$($this)
			.hover(function(e) {
				elem.css({
						top: e.pageY + margin + "px", left: e.pageX + margin + "px",
						opacity: opacity, padding: "10px"
					})
					.html($(this).attr("alt") ? $(this).attr("alt")
								: $(this).attr("title") ? $(this).attr("title") :
										$(this).html())
					.fadeIn(100);
			}, function(e) {
				elem
					.fadeOut(100);
			})
			.mousemove(function(e) {
				elem.css({
						top: e.pageY + margin + "px", left: e.pageX + margin + "px"
					})
			});
	}
})(jQuery);

