var $j = jQuery.noConflict();
$j(document).ready(function() { $j(".tooltip").simpletooltip(); });
(function($j){ $j.fn.simpletooltip = function(){
    return this.each(function() {
        var text = $j(this).attr("alt");
        $j(this).attr("alt", "");
        if(text != undefined) {
            $j(this).hover(function(e){
                var tipX = e.pageX;
                var tipY = e.pageY + 20;
                $j(this).attr("alt", ""); 
                $j("body").append("<div id='simpleTooltip' style='position: absolute; z-index: 9999; display: none;'><h3>" + text + "</h3><div style=\"display: none;\" class=\"body\"></div><div style=\"display: none;\" class=\"url\"></div></div>");
                if($j.browser.msie) var tipWidth = $j("#simpleTooltip").outerWidth(true)
                else var tipWidth = $j("#simpleTooltip").width()
                $j("#simpleTooltip").width(tipWidth);
                $j("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
            }, function(){
                $j("#simpleTooltip").remove();
                $j(this).attr("alt", text);
            });
            $j(this).mousemove(function(e){
                var tipX = e.pageX;
                var tipY = e.pageY + 20;
                var tipWidth = $j("#simpleTooltip").outerWidth(true);
                var tipHeight = $j("#simpleTooltip").outerHeight(true);
                if(tipX + tipWidth > $j(window).scrollLeft() + $j(window).width()) tipX = e.pageX - tipWidth;
                if($j(window).height()+$j(window).scrollTop() < tipY + tipHeight) tipY = e.pageY - tipHeight;
                $j("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
            });
        }
    });
}})(jQuery);
