(function(d){var v=0;d.fn.extend({bubbletip:function(g,i){function m(){var f;if(!p){p=true;j&&c.stop(true,false);a.calculateOnShow&&h();if(a.positionAt.match(/^element|body$/i))if(a.deltaDirection.match(/^up|down$/i)){j||c.css("top",parseInt(b.top+b.delta)+"px");f={top:b.top+"px"}}else{j||c.css("left",parseInt(b.left+b.delta)+"px");f={left:b.left+"px"}}else if(a.deltaDirection.match(/^up|down$/i)){if(!j){b.mouseTop=e.pageY+b.top;c.css({top:parseInt(b.mouseTop+b.delta)+"px",left:parseInt(e.pageX-c.width()/2)+"px"})}f={top:b.mouseTop+"px"}}else{if(!j){b.mouseLeft=e.pageX+b.left;c.css({left:parseInt(b.mouseLeft+b.delta)+"px",top:parseInt(e.pageY-c.height()/2)+"px"})}f={left:b.left+"px"}}j=false;c.show();f=d.extend(f,{opacity:1});c.animate(f,a.animationDuration,a.animationEasing,function(){c.css("opacity","");p=true})}}function q(){var f;p=false;j=true;f=a.positionAt.match(/^element|body$/i)?a.deltaDirection.match(/^up|down$/i)?{top:parseInt(b.top-b.delta)+"px"}:{left:parseInt(b.left-b.delta)+"px"}:a.deltaDirection.match(/^up|down$/i)?{top:parseInt(b.mouseTop-b.delta)+"px"}:{left:parseInt(b.mouseLeft-b.delta)+"px"};f=d.extend(f,{opacity:0});c.animate(f,a.animationDuration,a.animationEasing,function(){c.hide();j=false})}function h(){if(a.positionAt.match(/^element$/i)){var f=a.positionAtElement.offset();if(a.deltaDirection.match(/^up$/i)){b.top=f.top+a.offsetTop-c.outerHeight();b.left=f.left+a.offsetLeft+(a.positionAtElement.outerWidth()-c.outerWidth())/2;b.delta=a.deltaPosition}else if(a.deltaDirection.match(/^down$/i)){b.top=f.top+a.positionAtElement.outerHeight()+a.offsetTop;b.left=f.left+a.offsetLeft+(a.positionAtElement.outerWidth()-c.outerWidth())/2;b.delta=-a.deltaPosition}else if(a.deltaDirection.match(/^left$/i)){b.top=f.top+a.offsetTop+(a.positionAtElement.outerHeight()-c.outerHeight())/2;b.left=f.left+a.offsetLeft-c.outerWidth();b.delta=a.deltaPosition}else if(a.deltaDirection.match(/^right$/i)){b.top=f.top+a.offsetTop+(a.positionAtElement.outerHeight()-c.outerHeight())/2;b.left=f.left+a.positionAtElement.outerWidth()+
a.offsetLeft;b.delta=-a.deltaPosition}}else if(a.positionAt.match(/^body$/i))if(a.deltaDirection.match(/^up|left$/i)){b.top=a.offsetTop;b.left=a.offsetLeft;b.delta=a.deltaPosition}else{if(a.deltaDirection.match(/^down$/i)){b.top=parseInt(a.offsetTop+c.outerHeight());b.left=a.offsetLeft}else{b.top=a.offsetTop;b.left=parseInt(a.offsetLeft+c.outerWidth())}b.delta=-a.deltaPosition}else if(a.positionAt.match(/^mouse$/i))if(a.deltaDirection.match(/^up|left$/i)){if(a.deltaDirection.match(/^up$/i)){b.top=-(a.offsetTop+c.outerHeight());b.left=a.offsetLeft}else if(a.deltaDirection.match(/^left$/i)){b.top=a.offsetTop;b.left=-(a.offsetLeft+c.outerWidth())}b.delta=a.deltaPosition}else{b.top=a.offsetTop;b.left=a.offsetLeft;b.delta=-a.deltaPosition}a.positionAt.match(/^element|body$/i)&&c.css({position:"absolute",top:b.top+"px",left:b.left+"px"})}if(d("table.bubbletip #"+d(g).get(0).id).length>0)return this;var n,k,a,b,l,s,p,j,c,o,t,u;n=d(this);k=d(g);o=v++;a={positionAt:"element",positionAtElement:n,offsetTop:0,offsetLeft:0,deltaPosition:30,deltaDirection:"up",animationDuration:250,animationEasing:"swing",bindShow:"mouseover",bindHide:"mouseout",delayShow:0,delayHide:500,calculateOnShow:false};if(i)a=d.extend(a,i);b={top:0,left:0,delta:0,mouseTop:0,mouseLeft:0,tipHeight:0,bindShow:(a.bindShow+" ").replace(/ +/g,".bubbletip"+o),bindHide:(a.bindHide+" ").replace(/ +/g,".bubbletip"+o)};s=l=null;j=p=false;n.data("bubbletip_tips")?n.data("bubbletip_tips",d.merge(n.data("bubbletip_tips"),[[k.get(0).id,o]])):n.data("bubbletip_tips",[[k.get(0).id,o]]);if(!a.positionAt.match(/^element|body|mouse$/i))a.positionAt="element";if(!a.deltaDirection.match(/^up|down|left|right$/i))a.deltaDirection="up";if(a.deltaDirection.match(/^up$/i))c=d('<table class="bubbletip" cellspacing="0" cellpadding="0"><tbody><tr><td class="bt-topleft"></td><td class="bt-top"></td><td class="bt-topright"></td></tr><tr><td class="bt-left"></td><td class="bt-content"></td><td class="bt-right"></td></tr><tr><td class="bt-bottomleft"></td><td><table class="bt-bottom" cellspacing="0" cellpadding="0"><tr><th></th><td><div></div></td><th></th></tr></table></td><td class="bt-bottomright"></td></tr></tbody></table>');else if(a.deltaDirection.match(/^down$/i))c=d('<table class="bubbletip" cellspacing="0" cellpadding="0"><tbody><tr><td class="bt-topleft"></td><td><table class="bt-top" cellspacing="0" cellpadding="0"><tr><th></th><td><div></div></td><th></th></tr></table></td><td class="bt-topright"></td></tr><tr><td class="bt-left"></td><td class="bt-content"></td><td class="bt-right"></td></tr><tr><td class="bt-bottomleft"></td><td class="bt-bottom"></td><td class="bt-bottomright"></td></tr></tbody></table>');else if(a.deltaDirection.match(/^left$/i))c=d('<table class="bubbletip" cellspacing="0" cellpadding="0"><tbody><tr><td class="bt-topleft"></td><td class="bt-top"></td><td class="bt-topright"></td></tr><tr><td class="bt-left"></td><td class="bt-content"></td><td class="bt-right-tail"><div class="bt-right"></div><div class="bt-right-tail"></div><div class="bt-right"></div></td></tr><tr><td class="bt-bottomleft"></td><td class="bt-bottom"></td><td class="bt-bottomright"></td></tr></tbody></table>');else if(a.deltaDirection.match(/^right$/i))c=d('<table class="bubbletip" cellspacing="0" cellpadding="0"><tbody><tr><td class="bt-topleft"></td><td class="bt-top"></td><td class="bt-topright"></td></tr><tr><td class="bt-left-tail"><div class="bt-left"></div><div class="bt-left-tail"></div><div class="bt-left"></div></td><td class="bt-content"></td><td class="bt-right"></td></tr><tr><td class="bt-bottomleft"></td><td class="bt-bottom"></td><td class="bt-bottomright"></td></tr></tbody></table>');c.appendTo("body");/msie/.test(navigator.userAgent.toLowerCase())&&!/opera/.test(navigator.userAgent.toLowerCase())&&d("*",c).each(function(){var f=d(this).css("background-image");if(f.match(/^url\(["']?(.*\.png)["']?\)$/i)){f=RegExp.$1;d(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod="+(d(this).css("backgroundRepeat")=="no-repeat"?"crop":"scale")+", src='"+f+"')"}).each(function(){var r=d(this).css("position");r!="absolute"&&r!="relative"&&d(this).css("position","relative")})}});d(".bt-content",c).append(k);k.show();if(a.deltaDirection.match(/^left|right$/i)){b.tipHeight=parseInt(k.height()/2);k.height()%2==1&&b.tipHeight++;b.tipHeight=b.tipHeight<20?1:b.tipHeight-20;a.deltaDirection.match(/^left$/i)?d("div.bt-right",c).css("height",b.tipHeight+"px"):d("div.bt-left",c).css("height",b.tipHeight+"px")}c.css("opacity",0);c.css({width:c.width(),height:c.height()});h();c.hide();d(window).bind("resize.bubbletip"+o,function(){var f=d(window).width(),r=d(window).height();if(!(f===t&&r===u)){t=f;u=r;s&&clearTimeout(s);s=setTimeout(function(){h()},250)}});d([c.get(0),this.get(0)]).bind(b.bindShow,function(){l&&clearTimeout(l);if(a.delayShow===0)m();else l=setTimeout(function(){m()},a.delayShow);return false}).bind(b.bindHide,function(){l&&clearTimeout(l);if(a.delayHide===0)q();else l=setTimeout(function(){q()},a.delayHide);return false});return this},removeBubbletip:function(g){var i,m=[],q=[],h;i=d.makeArray(d(this).data("bubbletip_tips"));h=d.makeArray(g);for(g=0;g<h.length;g++)m.push(d(h[g]).get(0).id);for(g=0;g<i.length;g++)if(m.length==0||d.inArray(i[g][0],m)>=0){for(h=d("#"+i[g][0]).get(0).parentNode;h.tagName.toLowerCase()!="table";)h=h.parentNode;d("#"+i[g][0]).appendTo("body").hide();d(h).remove();d(this).unbind(".bubbletip"+i[g][1]);d(window).unbind(".bubbletip"+i[g][1])}else q.push(i[g]);d(this).data("bubbletip_tips",q);return this}})})(jQuery);
