﻿(function ($) {
    $.fn.tooltip2 = function (options) {

        var opts = $.extend({}, $.fn.tooltip2.defaults, options);

        $(this).focus(function () {

            $(".tooltip2_Outer").remove();

            var tooltipText = "";

            var controlContainer = $(this).closest('.controlContainer');

            if (controlContainer.length == 1) {
                tooltipText = controlContainer.find('.hiddenTooltipContent').html();
            }

            if (tooltipText != "") {

                block = document.createElement("div");
                block.className = "tooltip2_Outer";
                document.body.appendChild(block);

                $(block).html("<div class=\"tooltip2_Inner\">" + tooltipText + "</div>");

                var o = $(this).offset();
                $(block).css('top', o.top);
                $(block).css('left', o.left + $(this).outerWidth() + 10);

                $(block).fadeIn();
            }
        });

        $(this).blur(function () {
            $(".tooltip2_Outer").css('display', 'none');
        });

    };

    $.fn.tooltip2.defaults = {
        notmuchhere:'1'
    };
})(jQuery);
