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

