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