(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(k){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 s=false,r=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 j=(g.dropShadow)?+g.dropShadowSteps:0;if(!J){J=E([]);for(var v=0;v<j;v++){J=J.add(E("<div></div>").css({zIndex:Z-v-1,opacity:0.1,top:1+v,left:1+v}))}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,t;var X=isNaN(parseInt(g.height,10))?"auto":(/\D/g).test(g.height)?g.height:g.height+"px";var M,T,l,y,n,u;var Y=isNaN(parseInt(g.width,10))?275:parseInt(g.width,10);var w=Y+(parseInt(I.css("paddingLeft"),10)||0)+(parseInt(I.css("paddingRight"),10)||0)+j;var c=this.offsetWidth;var U,m,z,o,N;var q;var h=(g.attribute!="title")?V.attr(g.titleAttribute):"";if(g.splitTitle){if(h==undefined){h=""}q=h.split(g.splitTitle);h=q.shift()}if(g.escapeTitle){h=h.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;")}var Q;var W=function(Aa){if(!g.onActivate(V)){return false}s=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=l=V.offset().top;U=V.offset().left;o=Aa.pageX;n=Aa.pageY;if(V[0].tagName.toLowerCase()!="area"){M=E(document).scrollTop();N=E(window).width()}if(g.positionBy=="fixed"){m=c+U+b;I.css({left:m})}else{m=(c>U&&U>w)||U+c+w+b>N?U-w-b:c+U+b;if(V[0].tagName.toLowerCase()=="area"||g.positionBy=="mouse"||c+w>N){if(o+20+w>N){I.addClass(" cluetip-"+R);m=(o-w-b)>=0?o-w-b-parseInt(I.css("marginLeft"),10)+parseInt(H.css("marginRight"),10):o-(w/2)}else{m=o+b}}var Ab=m<0?Aa.pageY+f:Aa.pageY;I.css({left:(m>0&&g.positionBy!="bottomTop")?m:(o+(w/2)>N)?N/2-w/2:Math.max(o-(w/2),0)})}t=E(window).height();if(L){if(typeof L=="function"){L=L(V[0])}H.html(L);p(Ab)}else{if(q){var Ad=q.length;H.empty();for(var Ac=0;Ac<Ad;Ac++){if(Ac==0){H.html(q[Ac])}else{H.append('<div class="split-body">'+q[Ac]+"</div>")}}p(Ab)}else{if(!g.local&&e.indexOf("#")!=0){if(/\.(jpe?g|tiff?|gif|png)$/i.test(e)){H.html('<img src="'+e+'" alt="'+h+'" />');p(Ab)}else{if(O&&g.ajaxCache){H.html(O);p(Ab)}else{var Ah=g.ajaxSettings.beforeSend,Ae=g.ajaxSettings.error,Af=g.ajaxSettings.success,Ak=g.ajaxSettings.complete;var Aj={cache:false,url:e,beforeSend:function(i){if(Ah){Ah.call(S,i,I,H)}G.children().empty();if(g.waitImage){E("#cluetip-waitimage").css({top:n+20,left:o+20}).show()}},error:function(i,Al){if(s){if(Ae){Ae.call(S,i,Al,I,H)}else{H.html("<i>sorry, the contents could not be loaded</i>")}}},success:function(i,Al){O=g.ajaxProcess.call(S,i);if(s){if(Af){Af.call(S,i,Al,I,H)}H.html(O)}},complete:function(i,Al){if(Ak){Ak.call(S,i,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(s){p(Ab)}}})}else{E("#cluetip-waitimage").hide();if(s){p(Ab)}}}};var Ag=E.extend(true,{},g.ajaxSettings,Aj);E.ajax(Ag)}}}else{if(g.local){var Ai=E(e+(/#\w+$/.test(e)?"":":eq("+k+")")).clone(true).show();H.html(Ai);p(Ab)}}}}};var p=function(Ab){I.addClass("cluetip-"+R);if(g.truncate){var Ac=H.text().slice(0,g.truncate)+"...";H.html(Ac)}function i(){}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:i,timeout:g.hoverIntent.timeout,out:function(){Aa.trigger("click")}})}else{I.hover(i,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);y=l;u=M+t;if(g.positionBy=="fixed"){y=l-g.dropShadowSteps+f}else{if((m<o&&Math.max(m,0)+w>o)||g.positionBy=="bottomTop"){if(l+a+f>u&&n-M>a+f){y=n-a-f;Ad="top"}else{y=n+f;Ad="bottom"}}else{if(l+a+f>u){y=(a>=t)?M:u-a-f}else{if(V.css("display")=="block"||V[0].tagName.toLowerCase()=="area"||g.positionBy=="mouse"){y=Ab-f}else{y=l-g.dropShadowSteps}}}}if(Ad==""){m<U?Ad="left":Ad="right"}I.css({top:y+"px"}).removeClass().addClass("clue-"+Ad+"-"+R).addClass(" cluetip-"+R);if(g.arrows){var Ae=(l-y-g.dropShadowSteps);F.css({top:(/(left|right)/.test(Ad)&&m>=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){r=setTimeout(d,g.delayedClose)}g.onShow.call(S,I,H)};var x=function(i){s=false;E("#cluetip-waitimage").hide();if(!g.sticky||(/click|toggle/).test(g.activation)){d();clearTimeout(r)}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(i){d()});if((/click|toggle/).test(g.activation)){V.bind("click.cluetip",function(i){if(I.is(":hidden")||!V.is(".cluetip-clicked")){W(i);E(".cluetip-clicked").removeClass("cluetip-clicked");V.addClass("cluetip-clicked")}else{x(i)}this.blur();return false})}else{if(g.activation=="focus"){V.bind("focus.cluetip",function(i){W(i)});V.bind("blur.cluetip",function(i){x(i)})}else{V.bind("click.cluetip",function(){if(V.attr("href")&&V.attr("href")==e&&!g.clickThrough){return false}});var P=function(i){if(g.tracking==true){var Ab=m-i.pageX;var Aa=y?y-i.pageY:l-i.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(i){W(i);P(i)},timeout:g.hoverIntent.timeout,out:function(i){x(i);V.unbind("mousemove.cluetip")}})}else{V.bind("mouseenter.cluetip",function(i){W(i);P(i)}).bind("mouseleave.cluetip",function(i){x(i);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);