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

