(function(e){e.cluetip={version:"1.0.1"};var i,h,g,d,f,j,c;e.fn.cluetip=function(l,k){if(typeof l=="object"){k=l;l=null}return this.each(function(J){var s=this,v=e(this);var G=e.extend(true,{},e.fn.cluetip.defaults,k||{},e.metadata?v.metadata():e.meta?v.data():{});var o=false;var z=parseInt(G.cluezIndex,10)-1;var R=false,Q=0;if(!e("#cluetip").length){h=e('<div id="cluetip-inner"></div>');d=e('<h3 id="cluetip-title"></h3>');g=e('<div id="cluetip-outer"></div>').append(h).prepend(d);i=e('<div id="cluetip"></div>').css({zIndex:G.cluezIndex}).append(g).append('<div id="cluetip-extra"></div>')[b](a).hide();e('<div id="cluetip-waitimage"></div>').css({position:"absolute",zIndex:z-1}).insertBefore("#cluetip").hide();i.css({position:"absolute",zIndex:z});g.css({position:"relative",zIndex:z+1});f=e('<div id="cluetip-arrows" class="cluetip-arrows"></div>').css({zIndex:z+1}).appendTo("#cluetip")}var I=(G.dropShadow)?+G.dropShadowSteps:0;if(!j){j=e([]);for(var U=0;U<I;U++){j=j.add(e("<div></div>").css({zIndex:z-U-1,opacity:0.1,top:1+U,left:1+U}))}j.css({position:"absolute",backgroundColor:"#000"}).prependTo(i)}var E=v.attr(G.attribute),r=G.cluetipClass;if(!E&&!G.splitTitle&&!l){return true}if(G.local&&G.localPrefix){E=G.localPrefix+E}if(G.local&&G.hideLocal){e(E+":first").hide()}var F=parseInt(G.topOffset,10),B=parseInt(G.leftOffset,10);var A,S;var x=isNaN(parseInt(G.height,10))?"auto":(/\D/g).test(G.height)?G.height:G.height+"px";var m,t,K,X,M,T;var y=isNaN(parseInt(G.width,10))?275:parseInt(G.width,10);var V=y+(parseInt(i.css("paddingLeft"),10)||0)+(parseInt(i.css("paddingRight"),10)||0)+I;var C=this.offsetWidth;var u,L,Y,N,n;var P;var H=(G.attribute!="title")?v.attr(G.titleAttribute):"";if(G.splitTitle){if(H==undefined){H=""}P=H.split(G.splitTitle);H=P.shift()}if(G.escapeTitle){H=H.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;")}var q;var w=function(Z){if(!G.onActivate(v)){return false}R=true;i.removeClass().css({width:y});if(E==v.attr("href")){v.css("cursor",G.cursor)}v.attr("title","");if(G.hoverClass){v.addClass(G.hoverClass)}t=K=v.offset().top;u=v.offset().left;N=Z.pageX;M=Z.pageY;if(v[0].tagName.toLowerCase()!="area"){m=e(document).scrollTop();n=e(window).width()}if(G.positionBy=="fixed"){L=C+u+B;i.css({left:L})}else{L=(C>u&&u>V)||u+C+V+B>n?u-V-B:C+u+B;if(v[0].tagName.toLowerCase()=="area"||G.positionBy=="mouse"||C+V>n){if(N+20+V>n){i.addClass(" cluetip-"+r);L=(N-V-B)>=0?N-V-B-parseInt(i.css("marginLeft"),10)+parseInt(h.css("marginRight"),10):N-(V/2)}else{L=N+B}}var aa=L<0?Z.pageY+F:Z.pageY;i.css({left:(L>0&&G.positionBy!="bottomTop")?L:(N+(V/2)>n)?n/2-V/2:Math.max(N-(V/2),0)})}S=e(window).height();if(l){if(typeof l=="function"){l=l(v[0])}h.html(l);O(aa)}else{if(P){var ac=P.length;h.empty();for(var ab=0;ab<ac;ab++){if(ab==0){h.html(P[ab])}else{h.append('<div class="split-body">'+P[ab]+"</div>")}}O(aa)}else{if(!G.local&&E.indexOf("#")!=0){if(/\.(jpe?g|tiff?|gif|png)$/i.test(E)){h.html('<img src="'+E+'" alt="'+H+'" />');O(aa)}else{if(o&&G.ajaxCache){h.html(o);O(aa)}else{var ag=G.ajaxSettings.beforeSend,ad=G.ajaxSettings.error,ae=G.ajaxSettings.success,aj=G.ajaxSettings.complete;var ai={cache:false,url:E,beforeSend:function(ak){if(ag){ag.call(s,ak,i,h)}g.children().empty();if(G.waitImage){e("#cluetip-waitimage").css({top:M+20,left:N+20}).show()}},error:function(ak,al){if(R){if(ad){ad.call(s,ak,al,i,h)}else{h.html("<i>sorry, the contents could not be loaded</i>")}}},success:function(ak,al){o=G.ajaxProcess.call(s,ak);if(R){if(ae){ae.call(s,ak,al,i,h)}h.html(o)}},complete:function(ak,al){if(aj){aj.call(s,ak,al,i,h)}c=e("#cluetip-inner img").length;if(c&&!e.browser.opera){e("#cluetip-inner img").load(function(){c--;if(c<1){e("#cluetip-waitimage").hide();if(R){O(aa)}}})}else{e("#cluetip-waitimage").hide();if(R){O(aa)}}}};var af=e.extend(true,{},G.ajaxSettings,ai);e.ajax(af)}}}else{if(G.local){var ah=e(E+(/#\w+$/.test(E)?"":":eq("+J+")")).clone(true).show();h.html(ah);O(aa)}}}}};var O=function(ab){i.addClass("cluetip-"+r);if(G.truncate){var ac=h.text().slice(0,G.truncate)+"...";h.html(ac)}function Z(){}H?d.show().html(H):(G.showTitle)?d.show().html("&nbsp;"):d.hide();if(G.sticky){var aa=e('<div id="cluetip-close"><a href="#">'+G.closeText+"</a></div>");(G.closePosition=="bottom")?aa.appendTo(h):(G.closePosition=="title")?aa.prependTo(d):aa.prependTo(h);aa.bind("click.cluetip",function(){D();return false});if(G.mouseOutClose){if(e.fn.hoverIntent&&G.hoverIntent){i.hoverIntent({over:Z,timeout:G.hoverIntent.timeout,out:function(){aa.trigger("click")}})}else{i.hover(Z,function(){aa.trigger("click")})}}else{i.unbind("mouseout")}}var ad="";g.css({overflow:x=="auto"?"visible":"auto",height:x});A=x=="auto"?Math.max(i.outerHeight(),i.height()):parseInt(x,10);X=K;T=m+S;if(G.positionBy=="fixed"){X=K-G.dropShadowSteps+F}else{if((L<N&&Math.max(L,0)+V>N)||G.positionBy=="bottomTop"){if(K+A+F>T&&M-m>A+F){X=M-A-F;ad="top"}else{X=M+F;ad="bottom"}}else{if(K+A+F>T){X=(A>=S)?m:T-A-F}else{if(v.css("display")=="block"||v[0].tagName.toLowerCase()=="area"||G.positionBy=="mouse"){X=ab-F}else{X=K-G.dropShadowSteps}}}}if(ad==""){L<u?ad="left":ad="right"}i.css({top:X+"px"}).removeClass().addClass("clue-"+ad+"-"+r).addClass(" cluetip-"+r);if(G.arrows){var ae=(K-X-G.dropShadowSteps);f.css({top:(/(left|right)/.test(ad)&&L>=0&&ae>0)?ae+"px":/(left|right)/.test(ad)?0:""}).show()}else{f.hide()}j.hide();i.hide()[G.fx.open](G.fx.open!="show"&&G.fx.openSpeed);if(G.dropShadow){j.css({height:A,width:y}).show()}if(e.fn.bgiframe){i.bgiframe()}if(G.delayedClose>0){Q=setTimeout(D,G.delayedClose)}G.onShow.call(s,i,h)};var W=function(Z){R=false;e("#cluetip-waitimage").hide();if(!G.sticky||(/click|toggle/).test(G.activation)){D();clearTimeout(Q)}if(G.hoverClass){v.removeClass(G.hoverClass)}};var D=function(){g.parent().hide().removeClass();G.onHide.call(s,i,h);v.removeClass("cluetip-clicked");if(H){v.attr(G.titleAttribute,H)}v.css("cursor","");if(G.arrows){f.css({top:""})}};e(document).bind("hideCluetip",function(Z){D()});if((/click|toggle/).test(G.activation)){v.bind("click.cluetip",function(Z){if(i.is(":hidden")||!v.is(".cluetip-clicked")){w(Z);e(".cluetip-clicked").removeClass("cluetip-clicked");v.addClass("cluetip-clicked")}else{W(Z)}this.blur();return false})}else{if(G.activation=="focus"){v.bind("focus.cluetip",function(Z){w(Z)});v.bind("blur.cluetip",function(Z){W(Z)})}else{v.bind("click.cluetip",function(){if(v.attr("href")&&v.attr("href")==E&&!G.clickThrough){return false}});var p=function(Z){if(G.tracking==true){var ab=L-Z.pageX;var aa=X?X-Z.pageY:K-Z.pageY;v.bind("mousemove.cluetip",function(ac){i.css({left:ac.pageX+ab,top:ac.pageY+aa})})}};if(e.fn.hoverIntent&&G.hoverIntent){v.bind("mouseover.cluetip",function(){v.attr("title","")}).hoverIntent({sensitivity:G.hoverIntent.sensitivity,interval:G.hoverIntent.interval,over:function(Z){w(Z);p(Z)},timeout:G.hoverIntent.timeout,out:function(Z){W(Z);v.unbind("mousemove.cluetip")}})}else{v.bind("mouseenter.cluetip",function(Z){w(Z);p(Z)}).bind("mouseleave.cluetip",function(Z){W(Z);v.unbind("mousemove.cluetip")})}}}})};e.fn.cluetip.defaults={width:275,height:"auto",cluezIndex:97,positionBy:"auto",topOffset:15,leftOffset:15,local:false,localPrefix: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:false,tracking:false,delayedClose:0,closePosition:"top",closeText:"Close",truncate:0,fx:{open:"show",openSpeed:""},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(k){return true},onShow:function(l,k){},onHide:function(l,k){},ajaxCache:true,ajaxProcess:function(k){k=k.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm,"").replace(/<(link|meta)[^>]+>/g,"");return k},ajaxSettings:{dataType:"html"},debug:false};var b="appendTo",a="body";e.cluetip.setup=function(k){if(k&&k.insertionType&&(k.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){b=k.insertionType}if(k&&k.insertionElement){a=k.insertionElement}}})(jQuery);
