(function($) { $.fn.extend ({ tooltip_close:function() { $("#tool_outer").fadeOut(); return false; } }); $.fn.tooltip = function(settings) { // define defaults and override with options, if available // by extending the default settings, we don't modify the argument settings = jQuery.extend({ width: 500, container_id: "", filename: "", variables: {}, x_offset:0, y_offset:0, height: 300 }, settings); var display_tip = false; var tool_animation_running = false; if ($("$tool_outer").length == 0) { $("
").css({ "position":"absolute", "z-index":"100" }).hide().appendTo("body"); } return this.each(function(i) { $this = $(this); $(this).attr("sub_title", $this.attr("title")); $this.attr("title", ""); data = $this.attr("title"); $("#tool_outer").bind("mouseout", function(e) { if (!tool_animation_running) { } $("#tool_outer").hide(); }) $this.bind("mouseover", function(e) { $("#tool_outer").attr({"href":$(this).attr("href")}); $(this).attr("id", "link_"+i); tt = $("#tool_outer"); if (settings.filename == "") { data = $(this).attr("sub_title"); if (data == "" || data == undefined) { return false; } tt.html(data); } else { $.post(settings.filename, settings.variables, function(data) { tt.html(data); }) } x = e.pageX; y = e.pageY; //alert($(this).offset().left+", page = "+x); x = $(this).parent().parent().offset().left; y = $(this).parent().parent().offset().top; tool_height = tt.height(); tool_bottom = y+tool_height +10; y -= tool_height; //x -= 20; y += settings.y_offset; x += settings.x_offset; /*if (tool_bottom > $(document).height()) { y -= tool_height; } tool_width = tt.width(); tool_right = x+tool_width+10; if (tool_right > $(window).width()) { x -= tool_width; }*/ tt.css({ "left":x+"px", "top":y+"px" }) if (!tool_animation_running) { tool_animation_running = true; } tt.show(); $("#tool_outer .close_bttn").each(function() { $(this).attr("border", "0").wrap($("")) }) $("#tool_outer").bind("click", function(e) { href = $(this).attr("href"); window.location = href; }) }); }); } })(jQuery);