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