/*!
 * miniTip v1.4.2
 *
 * Updated: September 12, 2011
 * Requires: jQuery v1.3+
 *
 * (c) 2011, James Simpson
 * http://goldfirestudios.com
 *
 * Dual licensed under the MIT and GPL
 *
 * Documentation found at:
 * http://goldfirestudios.com/blog/81/miniTip-jQuery-Plugin
*/
(function(a){a.fn.miniTip=function(f){var i={title:"",content:false,delay:300,anchor:"n",event:"hover",fadeIn:200,fadeOut:200,aHide:true,maxW:"250px",offset:5,hide:false},h=a.extend(i,f);if(!a("#miniTip")[0]){a("body").append('<div id="miniTip"><div id="miniTip_t"></div><div id="miniTip_c"></div><div id="miniTip_a"></div></div>')}var e=a("#miniTip"),g=a("#miniTip_t"),b=a("#miniTip_c"),c=a("#miniTip_a");if(h.hide){e.stop(true,true).fadeOut(h.fadeOut);return false}return this.each(function(){var m=a(this);var d=h.content?h.content:m.attr("title");if(d!=""&&typeof d!="undefined"){window.delay=false;var n=false,o=true;if(!h.content){m.removeAttr("title")}if(h.event=="hover"){m.hover(function(){e.removeAttr("click");o=true;j()},function(){o=false;k()});if(!h.aHide){e.hover(function(){n=true},function(){n=false;setTimeout(function(){if(!o&&!e.attr("click")){k()}},20)})}}else{if(h.event=="click"){h.aHide=true;m.click(function(){e.attr("click","t");if(e.css("display")=="none"){j()}else{k()}return false});a("html").click(function(p){if(e.css("display")=="block"&&!a(p.target).closest("#miniTip").length){k()}})}}var j=function(){if(h.show){h.show.call(this)}b.html(d);if(h.title!=""){g.html(h.title).show()}else{g.hide()}c.removeAttr("class");e.hide().width("").width(e.width()).css("max-width",h.maxW);if(m.is("area")){var F,B=[],z=[],I=m.attr("coords").split(",");for(F=0;F<I.length;F++){B.push(I[F++]);z.push(I[F])}var t=parseInt(m.parent().offset().left,10)+parseInt((parseInt(B.sort(w)[0],10)+parseInt(B.sort(w)[B.length-1],10))/2,10),C=parseInt(m.parent().offset().top,10)+parseInt((parseInt(z.sort(w)[0],10)+parseInt(z.sort(w)[z.length-1],10))/2,10);function w(y,x){return y-x}}else{var C=parseInt(m.offset().top,10),t=parseInt(m.offset().left,10)}var G=parseInt(m.outerWidth(),10),q=parseInt(m.outerHeight(),10),D=e.outerWidth(),J=e.outerHeight(),E=Math.round(t+Math.round((G-D)/2)),p=Math.round(C+q+h.offset+8),u=(Math.round(D-16)/2)-parseInt(e.css("borderLeftWidth"),10),v=0,r=(t+G+D+h.offset+8)>parseInt(a(window).width(),10),H=(D+h.offset+8)>t,A=(J+h.offset+8)>C-a(window).scrollTop(),s=(C+q+J+h.offset+8)>parseInt(a(window).height()+a(window).scrollTop(),10),K=h.anchor;if(H||h.anchor=="e"&&!r){if(h.anchor=="w"||h.anchor=="e"){K="e";v=Math.round((J/2)-8-parseInt(e.css("borderRightWidth"),10));u=-8-parseInt(e.css("borderRightWidth"),10);E=t+G+h.offset+8;p=Math.round((C+q/2)-(J/2))}}else{if(r||h.anchor=="w"&&!H){if(h.anchor=="w"||h.anchor=="e"){K="w";v=Math.round((J/2)-8-parseInt(e.css("borderLeftWidth"),10));u=D-parseInt(e.css("borderLeftWidth"),10);E=t-D-h.offset-8;p=Math.round((C+q/2)-(J/2))}}}if(s||h.anchor=="n"&&!A){if(h.anchor=="n"||h.anchor=="s"){K="n";v=J-parseInt(e.css("borderTopWidth"),10);p=C-(J+h.offset+8)}}else{if(A||h.anchor=="s"&&!s){if(h.anchor=="n"||h.anchor=="s"){K="s";v=-8-parseInt(e.css("borderBottomWidth"),10);p=C+q+h.offset+8}}}if(h.anchor=="n"||h.anchor=="s"){if((D/2)>t){E=E<0?u+E:u;u=0}else{if((t+D/2)>parseInt(a(window).width(),10)){E-=u;u*=2}}}else{if(A){p=p+v;v=0}else{if(s){p-=v;v*=2}}}c.css({"margin-left":u+"px","margin-top":v+"px"}).attr("class",K);if(delay){clearTimeout(delay)}delay=setTimeout(function(){e.css({"margin-left":E+"px","margin-top":p+"px"}).stop(true,true).fadeIn(h.fadeIn)},h.delay)};var k=function(){if(!h.aHide&&!n||h.aHide){if(delay){clearTimeout(delay)}delay=setTimeout(function(){l()},h.delay)}};var l=function(){if(!h.aHide&&!n||h.aHide){e.stop(true,true).fadeOut(h.fadeOut);if(h.hide){h.hide.call(this)}}else{setTimeout(function(){k()},200)}}}})}})(jQuery);
