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

