(function($){$.fn.brTip=function(opts){opts=$.extend({fadeIn:'',fadeOut:'',toShow:100,toHide:500,opacity:0.8,top:-1,left:15,title:'Help',secondClass:'',box:null,delayToShow:null,delayToHide:null,txt:''},opts);function _clearTimes(){clearTimeout(opts.delayToShow);clearTimeout(opts.delayToHide)}function _create(){_clearTimes();if(!opts.box){opts.box=$('<div class="brTip-box"><div class="brTip-title">&nbsp;</div><div class="brTip-content">&nbsp;</div></div>').appendTo('body');opts.box.css('opacity',opts.opacity)}opts.box.addClass(opts.secondClass);opts.box.find('div.brTip-title').html(opts.title);opts.box.find('div.brTip-content').html(opts.txt);opts.delayToShow=setTimeout(function(){opts.box.fadeIn(opts.fadeIn)},opts.toShow)}function _hide(){opts.delayToHide=setTimeout(function(){opts.box.fadeOut(opts.fadeOut)},opts.toHide)}function _setPos(top,left){if(opts.box){opts.box.css({top:top+opts.top,left:left+opts.left})}else{setTimeout(function(){_setPos(top,left)},100)}}return this.each(function(){var self=$(this);self.mouseover(function(){opts.txt=self.attr('title');self.attr('title','');_create()}).mouseout(function(){self.attr('title',opts.txt);opts.txt='';_hide()}).mousemove(function(e){_setPos(e.pageY,e.pageX)}).focus(function(){self.trigger('mouseover');var pos=self.offset();_setPos(pos.top+(self.width()/2),pos.left+(self.height()/2))}).blur(function(){self.trigger('mouseout')})})}}(jQuery));
