/*
* Tooltip script 
* powered by jQuery (http://www.jquery.com)
* 
* original script writen by Alen Grakalic (http://cssglobe.com)
* original script modified by Gerardo Contijoch (http://gerardocontijoch.wordpress.com)
*
* for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*/

function AddTooltip(object, tooltipContent) {
    /* CONFIG */
    var xOffset = 10;
    var yOffset = 20;
    var originalTitleAttrValue = "";
    /* END CONFIG */

    $(object).hover(function(e) {
        $("body").append("<div id='tooltip'>" + tooltipContent + "</div>");
        if (this.title) {
            originalTitleAttrValue = this.title;
            this.title = '';
        }
        $("#tooltip")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function() {
	    if (originalTitleAttrValue.length > 0) {
	        this.title = originalTitleAttrValue;
	    }
	    $("#tooltip").remove();
	});
	$(object).mousemove(function(e) {
	    $("#tooltip")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px");
	});
};
