/*!
 * jQuery clueTip plugin v1.2.4
 *
 * Date: Fri Nov 25 23:45:10 2011 EST
 * Requires: jQuery v1.3+
 *
 * Copyright 2011, Karl Swedberg
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 *
 * Examples can be found at http://plugins.learningjquery.com/cluetip/demo/
 *
*/
(function(b){b.cluetip={version:"1.2.4",template:'<div><div class="cluetip-outer"><h3 class="cluetip-title ui-widget-header ui-cluetip-header"></h3><div class="cluetip-inner ui-widget-content ui-cluetip-content"></div></div><div class="cluetip-extra"></div><div class="cluetip-arrows ui-state-default"></div></div>',setup:{insertionType:"appendTo",insertionElement:"body"},defaults:{multiple:false,width:275,height:"auto",cluezIndex:97,positionBy:"auto",topOffset:15,leftOffset:15,local:false,localPrefix:null,
localIdSuffix:null,hideLocal:true,attribute:"rel",titleAttribute:"title",splitTitle:"",escapeTitle:false,showTitle:true,cluetipClass:"default",hoverClass:"",waitImage:true,cursor:"help",arrows:false,dropShadow:true,dropShadowSteps:6,sticky:false,mouseOutClose:false,activation:"hover",clickThrough:true,tracking:false,delayedClose:0,closePosition:"top",closeText:"Close",truncate:0,fx:{open:"show",openSpeed:""},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(){return true},onShow:function(){},
onHide:function(){},ajaxCache:true,ajaxProcess:function(j){return j=j.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm,"").replace(/<(link|meta)[^>]+>/g,"")},ajaxSettings:{dataType:"html"},debug:false}};var z,fa=0,N=0;b.fn.attrProp=b.fn.prop||b.fn.attr;b.fn.cluetip=function(j,t){function O(P,q,g){g="";q=q.dropShadow&&q.dropShadowSteps?+q.dropShadowSteps:0;if(b.support.boxShadow){if(q)g="1px 1px "+q+"px rgba(0,0,0,0.5)";P.css(b.support.boxShadow,g);return false}g=P.find(".cluetip-drop-shadow");
if(q==g.length)return g;g.remove();g=[];for(var d=0;d<q;)g[d++]='<div style="top:'+d+"px;left:"+d+'px;"></div>';return g=b(g.join("")).css({position:"absolute",backgroundColor:"#000",zIndex:U-1,opacity:0.1}).addClass("cluetip-drop-shadow").prependTo(P)}var e,h,p,A,r,Q;if(typeof j=="object"){t=j;j=null}if(j=="destroy"){var R=this.data("cluetip");if(R){b(R.selector).remove();b.removeData(this,"title");b.removeData(this,"cluetip");b(document).unbind(".cluetip");return this.unbind(".cluetip")}}t=b.extend(true,
{},b.cluetip.defaults,t||{});fa++;R=b.cluetip.backCompat||!t.multiple?"cluetip":"cluetip-"+fa;var ba="#"+R,u=b.cluetip.backCompat?"#":".",V=b.cluetip.setup.insertionType,ka=b.cluetip.setup.insertionElement||"body";V=/appendTo|prependTo|insertBefore|insertAfter/.test(V)?V:"appendTo";e=b(ba);if(!e.length){e=b(b.cluetip.template)[V](ka).attr("id",R).css({position:"absolute",display:"none"});var U=+t.cluezIndex;p=e.find(u+"cluetip-outer").css({position:"relative",zIndex:U});h=e.find(u+"cluetip-inner");
A=e.find(u+"cluetip-title")}z=b("#cluetip-waitimage");z.length||(z=b("<div></div>").attr("id","cluetip-waitimage").css({position:"absolute"}));z.insertBefore(e).hide();var la=(parseInt(e.css("paddingLeft"),10)||0)+(parseInt(e.css("paddingRight"),10)||0);this.each(function(P){function q(){return false}var g=this,d=b(this),a=b.extend(true,{},t,b.metadata?d.metadata():b.meta?d.data():d.data("cluetip")||{}),H=false,I=false,ga=0,m=a[a.attribute]||d.attrProp(a.attribute)||d.attr(a.attribute),S=a.cluetipClass;
U=+a.cluezIndex;d.data("cluetip",{title:g.title,zIndex:U,selector:ba});if(!m&&!a.splitTitle&&!j)return true;if(a.local&&a.localPrefix)m=a.localPrefix+m;a.local&&a.hideLocal&&m&&b(m+":first").hide();var s=parseInt(a.topOffset,10),B=parseInt(a.leftOffset,10),C,ca,W=isNaN(parseInt(a.height,10))?"auto":/\D/g.test(a.height)?a.height:a.height+"px",X,v,w,J,Y,da=parseInt(a.width,10)||275,n=da+la+a.dropShadowSteps,E=this.offsetWidth,x,k,o,K,F,y=a.attribute!="title"?d.attrProp(a.titleAttribute)||"":"";if(a.splitTitle){F=
y.split(a.splitTitle);y=a.showTitle||F[0]===""?F.shift():""}if(a.escapeTitle)y=y.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;");var $=function(c){var f;if(a.onActivate(d)===false)return false;I=true;e=b(ba).css({position:"absolute"});p=e.find(u+"cluetip-outer");h=e.find(u+"cluetip-inner");A=e.find(u+"cluetip-title");r=e.find(u+"cluetip-arrows");e.removeClass().css({width:da});m==d.attr("href")&&d.css("cursor",a.cursor);a.hoverClass&&d.addClass(a.hoverClass);v=d.offset().top;x=d.offset().left;
E=d.innerWidth();if(c.type==focus){o=x+E/2+B;e.css({left:k});J=v+s}else{o=c.pageX;J=c.pageY}if(g.tagName.toLowerCase()!="area"){X=b(document).scrollTop();K=b(window).width()}if(a.positionBy=="fixed"){k=E+x+B;e.css({left:k})}else{k=E>x&&x>n||x+E+n+B>K?x-n-B:E+x+B;if(g.tagName.toLowerCase()=="area"||a.positionBy=="mouse"||E+n>K)if(o+20+n>K){e.addClass("cluetip-"+S);k=o-n-B>=0?o-n-B-parseInt(e.css("marginLeft"),10)+parseInt(h.css("marginRight"),10):o-n/2}else k=o+B;f=k<0?c.pageY+s:c.pageY;if(k<0||a.positionBy==
"bottomTop")k=o+n/2>K?K/2-n/2:Math.max(o-n/2,0)}r.css({zIndex:d.data("cluetip").zIndex+1});e.css({left:k,zIndex:d.data("cluetip").zIndex});ca=b(window).height();if(j){if(typeof j=="function")j=j.call(g);h.html(j);L(f)}else if(F){c=F.length;h.html(c?F[0]:"");if(c>1)for(var i=1;i<c;i++)h.append('<div class="split-body">'+F[i]+"</div>");L(f)}else if(!a.local&&m.indexOf("#")!==0)if(/\.(jpe?g|tiff?|gif|png)(?:\?.*)?$/i.test(m)){h.html('<img src="'+m+'" alt="'+y+'" />');L(f)}else{var l=a.ajaxSettings.beforeSend,
M=a.ajaxSettings.error,ha=a.ajaxSettings.success,ia=a.ajaxSettings.complete;c=b.extend(true,{},a.ajaxSettings,{cache:a.ajaxCache,url:m,beforeSend:function(D,G){l&&l.call(g,D,e,h,G);p.children().empty();a.waitImage&&z.css({top:J+20,left:o+20,zIndex:d.data("cluetip").zIndex-1}).show()},error:function(D,G){if(I)M?M.call(g,D,G,e,h):h.html("<i>sorry, the contents could not be loaded</i>")},success:function(D,G){H=a.ajaxProcess.call(g,D);if(b.isPlainObject(H)){y=H.title;H=H.content}if(I){ha&&ha.call(g,
D,G,e,h);h.html(H)}},complete:function(D,G){ia&&ia.call(g,D,G,e,h);var Z=h[0].getElementsByTagName("img");N=Z.length;for(var ea=0,ma=Z.length;ea<ma;ea++)Z[ea].complete&&N--;if(N&&!b.browser.opera)b(Z).bind("load error",function(){N--;if(N<1){z.hide();I&&L(f)}});else{z.hide();I&&L(f)}}});b.ajax(c)}else if(a.local){c=b(m+(/^#\S+$/.test(m)?"":":eq("+P+")")).clone(true).show();a.localIdSuffix&&c.attr("id",c[0].id+a.localIdSuffix);h.html(c);L(f)}},L=function(c){var f,i;f=y||a.showTitle&&"&nbsp;";var l=
"";i="";e.addClass("cluetip-"+S);if(a.truncate){var M=h.text().slice(0,a.truncate)+"...";h.html(M)}f?A.show().html(f):A.hide();if(a.sticky){f=b('<div class="cluetip-close"><a href="#">'+a.closeText+"</a></div>");a.closePosition=="bottom"?f.appendTo(h):a.closePosition=="title"?f.prependTo(A):f.prependTo(h);f.bind("click.cluetip",function(){T();return false});a.mouseOutClose?e.bind("mouseleave.cluetip",function(){T()}):e.unbind("mouseleave.cluetip")}p.css({zIndex:d.data("cluetip").zIndex,overflow:W==
"auto"?"visible":"auto",height:W});C=W=="auto"?Math.max(e.outerHeight(),e.height()):parseInt(W,10);w=v;Y=X+ca;if(a.positionBy=="fixed")w=v-a.dropShadowSteps+s;else if(k<o&&Math.max(k,0)+n>o||a.positionBy=="bottomTop")if(v+C+s>Y&&J-X>C+s){w=J-C-s;i="top"}else{w=J+s;i="bottom"}else w=v+C+s>Y?C>=ca?X:Y-C-s:d.css("display")=="block"||g.tagName.toLowerCase()=="area"||a.positionBy=="mouse"?c-s:v-a.dropShadowSteps;if(i==="")i=k<x?"left":"right";f=" clue-"+i+"-"+S+" cluetip-"+S;if(S=="rounded")f+=" ui-corner-all";
e.css({top:w+"px"}).attrProp({className:"cluetip ui-widget ui-widget-content ui-cluetip"+f});if(a.arrows){if(/(left|right)/.test(i)){i=e.height()-r.height();l=k>=0&&c>0?v-w-a.dropShadowSteps:0;l=i>l?l:i;l+="px"}r.css({top:l}).show()}else r.hide();(Q=O(e,a))&&Q.length&&Q.hide().css({height:C,width:da,zIndex:d.data("cluetip").zIndex-1}).show();e.hide()[a.fx.open](a.fx.openSpeed||0);b.fn.bgiframe&&e.bgiframe();if(a.delayedClose>0)ga=setTimeout(T,a.delayedClose);a.onShow.call(g,e,h)},aa=function(){I=
false;z.hide();if(!a.sticky||/click|toggle/.test(a.activation)){T();clearTimeout(ga)}a.hoverClass&&d.removeClass(a.hoverClass)},T=function(c){c=c&&c.data("cluetip")?c:d;var f=c.data("cluetip")&&c.data("cluetip").selector,i=b(f||"div.cluetip"),l=i.find(u+"cluetip-inner"),M=i.find(u+"cluetip-arrows");i.hide().removeClass();a.onHide.call(c[0],i,l);if(f){c.removeClass("cluetip-clicked");c.css("cursor","")}f&&y&&c.attrProp(a.titleAttribute,y);a.arrows&&M.css({top:""})};b(document).unbind("hideCluetip.cluetip").bind("hideCluetip.cluetip",
function(c){T(b(c.target))});if(/click|toggle/.test(a.activation))d.bind("click.cluetip",function(c){if(e.is(":hidden")||!d.is(".cluetip-clicked")){$(c);b(".cluetip-clicked").removeClass("cluetip-clicked");d.addClass("cluetip-clicked")}else aa(c);return false});else if(a.activation=="focus"){d.bind("focus.cluetip",function(c){d.attrProp("title","");$(c)});d.bind("blur.cluetip",function(c){d.attrProp("title",d.data("cluetip").title);aa(c)})}else{d[a.clickThrough?"unbind":"bind"]("click.cluetip",q);
var ja=function(c){if(a.tracking){var f=k-c.pageX,i=w?w-c.pageY:v-c.pageY;d.bind("mousemove.cluetip",function(l){e.css({left:l.pageX+f,top:l.pageY+i})})}};b.fn.hoverIntent&&a.hoverIntent?d.hoverIntent({sensitivity:a.hoverIntent.sensitivity,interval:a.hoverIntent.interval,over:function(c){$(c);ja(c)},timeout:a.hoverIntent.timeout,out:function(c){aa(c);d.unbind("mousemove.cluetip")}}):d.bind("mouseenter.cluetip",function(c){$(c);ja(c)}).bind("mouseleave.cluetip",function(c){aa(c);d.unbind("mousemove.cluetip")});
d.bind("mouseover.cluetip",function(){d.attrProp("title","")}).bind("mouseleave.cluetip",function(){d.attrProp("title",d.data("cluetip").title)})}});return this};(function(){b.support=b.support||{};for(var j=document.createElement("div").style,t=["boxShadow"],O=["moz","Moz","webkit","o"],e=0,h=t.length;e<h;e++){var p=t[e],A=p.charAt(0).toUpperCase()+p.slice(1);if(typeof j[p]!=="undefined")b.support[p]=p;else for(var r=0,Q=O.length;r<Q;r++)if(typeof j[O[r]+A]!=="undefined"){b.support[p]=O[r]+A;break}}})();
b.fn.cluetip.defaults=b.cluetip.defaults})(jQuery);(function(b){b.extend(true,b.fn.cluetip,{backCompat:true,template:'<div id="cluetip"><div id="cluetip-outer" class="cluetip-outer"><h3 id="cluetip-title" class="cluetip-title ui-widget-header ui-cluetip-header"></h3><div id="cluetip-inner" class="cluetip-inner ui-widget-content ui-cluetip-content"></div></div><div id="cluetip-extra"></div><div id="cluetip-arrows" class="cluetip-arrows"></div></div>'})})(jQuery);
