/*
 * jQuery clueTip plugin
 * Version 0.9.6  (02/02/2008)
 * @requires jQuery v1.1.1+
 * @requires Dimensions plugin 
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
(function($){var H,$cluetipInner,$cluetipOuter,$cluetipTitle,$cluetipArrows,$dropShadow,imgCount;$.fn.cluetip=function(F){var G=$.extend({},$.fn.cluetip.defaults,F);if(F&&F.ajaxSettings){$.extend(G.ajaxSettings,F.ajaxSettings);delete F.ajaxSettings}if(F&&F.hoverIntent){$.extend(G.hoverIntent,F.hoverIntent);delete F.hoverIntent}if(F&&F.fx){$.extend(G.fx,F.fx);delete F.fx}return this.each(function(h){var j=false;var k=parseInt(G.cluezIndex,10)-1;var l=false,closeOnDelay=0;if(!H){$cluetipInner=$('<div id="cluetip-inner"></div>');$cluetipTitle=$('<h3 id="cluetip-title"></h3>');$cluetipOuter=$('<div id="cluetip-outer"></div>').append($cluetipInner).prepend($cluetipTitle);H=$('<div id="cluetip"></div>').css({zIndex:G.cluezIndex}).append($cluetipOuter).append('<div id="cluetip-extra"></div>')[I](insertionElement).hide();$('<div id="cluetip-waitimage"></div>').css({position:'absolute',zIndex:k-1}).insertBefore('#cluetip').hide();H.css({position:'absolute',zIndex:k});$cluetipOuter.css({position:'relative',zIndex:k+1});$cluetipArrows=$('<div id="cluetip-arrows" class="cluetip-arrows"></div>').css({zIndex:k+1}).appendTo('#cluetip')}var m=(G.dropShadow)?+G.dropShadowSteps:0;if(!$dropShadow){$dropShadow=$([]);for(var i=0;i<m;i++){$dropShadow=$dropShadow.add($('<div></div>').css({zIndex:k-i-1,opacity:0.1,top:1+i,left:1+i}))}$dropShadow.css({position:'absolute',backgroundColor:'#000'}).prependTo(H)}var n=$(this);var o=n.attr(G.attribute),ctClass=G.cluetipClass;if(!o&&!G.splitTitle){return true}if(G.local&&G.hideLocal){$(o+':first').hide()}var p=parseInt(G.topOffset,10),lOffset=parseInt(G.leftOffset,10);var q,wHeight;var r=(isNaN(parseInt(G.height,10)))?'auto':((/\D/g).test(G.height))?G.height:G.height+'px';var s,linkTop,posY,tipY,mouseY,baseline;var t=(isNaN(parseInt(G.width,10)))?275:parseInt(G.width,10);var u=t+(parseInt(H.css('paddingLeft'))||0)+(parseInt(H.css('paddingRight'))||0)+m;var v=this.offsetWidth;var w,posX,tipX,mouseX,winWidth;var x;var y=(G.attribute!='title')?n.attr(G.titleAttribute):'';if(G.splitTitle){if(y==undefined){y=''}x=y.split(G.splitTitle);y=x.shift()}var z;var A=function(b){if(!G.onActivate(n)){return false}l=true;H.removeClass().css({width:t});if(o==n.attr('href')){n.css('cursor',G.cursor)}n.attr('title','');if(G.hoverClass){n.addClass(G.hoverClass)}linkTop=posY=n.offset().top;w=n.offset().left;mouseX=b.pageX;mouseY=b.pageY;if(n[0].tagName.toLowerCase()!='area'){s=$(document).scrollTop();winWidth=$(window).width()}if(G.positionBy=='fixed'){posX=v+w+lOffset;H.css({left:posX})}else{posX=((v>w&&w>u)||w+v+u+lOffset>winWidth)?w-u-lOffset:v+w+lOffset;if(n[0].tagName.toLowerCase()=='area'||G.positionBy=='mouse'||v+u>winWidth){if(mouseX+20+u>winWidth){H.addClass(' cluetip-'+ctClass);posX=(mouseX-u-lOffset)>=0?mouseX-u-lOffset-parseInt(H.css('marginLeft'),10)+parseInt($cluetipInner.css('marginRight'),10):mouseX-(u/2)}else{posX=mouseX+lOffset}}var c=(posX<0)?b.pageY+p:b.pageY;H.css({left:(posX>0&&G.positionBy!='bottomTop')?posX:(mouseX+(u/2)>winWidth)?winWidth/2-u/2:Math.max(mouseX-(u/2),0)})}wHeight=$(window).height();if(x){var d=x.length;for(var i=0;i<d;i++){if(i==0){$cluetipInner.html(x[i])}else{$cluetipInner.append('<div class="split-body">'+x[i]+'</div>')}}B(c)}else if(!G.local&&o.indexOf('#')!=0){if(j&&G.ajaxCache){$cluetipInner.html(j);B(c)}else{var e=G.ajaxSettings;e.url=o;e.beforeSend=function(){$cluetipOuter.children().empty();if(G.waitImage){$('#cluetip-waitimage').css({top:mouseY+20,left:mouseX+20}).show()}};e.error=function(){if(l){$cluetipInner.html('<i>sorry, the contents could not be loaded</i>')}};e.success=function(a){j=G.ajaxProcess(a);if(l){$cluetipInner.html(j)}};e.complete=function(){imgCount=$('#cluetip-inner img').length;if(imgCount){$('#cluetip-inner img').load(function(){imgCount--;if(imgCount<1){$('#cluetip-waitimage').hide();if(l){B(c)}}})}else{$('#cluetip-waitimage').hide();if(l){B(c)}}};$.ajax(e)}}else if(G.local){var f=$(o+':first');var g=($.fn.wrapInner)?f.wrapInner('<div></div>').children().clone(true):f.html();if($.fn.wrapInner){$cluetipInner.empty().append(g)}else{$cluetipInner.html(g)}B(c)}};var B=function(a){H.addClass('cluetip-'+ctClass);if(G.truncate){var b=$cluetipInner.text().slice(0,G.truncate)+'...';$cluetipInner.html(b)}function doNothing(){};if(y){$cluetipTitle.show().html(y)}else{if(G.showTitle){$cluetipTitle.show().html('&nbsp;')}else{$cluetipTitle.hide()}}if(G.sticky){var c=$('<div id="cluetip-close"><a href="#">'+G.closeText+'</a></div>');if(G.closePosition=='bottom'){c.appendTo($cluetipInner)}else{if(G.closePosition=='title'){c.prependTo($cluetipTitle)}else{c.prependTo($cluetipInner)}}c.click(function(){D();return false});if(G.mouseOutClose){if($.fn.hoverIntent&&G.hoverIntent){H.hoverIntent({over:doNothing,timeout:G.hoverIntent.timeout,out:function(){c.trigger('click')}})}else{H.hover(doNothing,function(){c.trigger('click')})}}else{H.unbind('mouseout')}}var d='';$cluetipOuter.css({overflow:(r=='auto')?'visible':'auto',height:r});q=(r=='auto')?H.outerHeight():parseInt(r,10);tipY=posY;baseline=s+wHeight;if(G.positionBy=='fixed'){tipY=posY-G.dropShadowSteps+p}else if((posX<mouseX&&Math.max(posX,0)+u>mouseX)||G.positionBy=='bottomTop'){if(posY+q+p>baseline&&mouseY-s>q+p){tipY=mouseY-q-p;d='top'}else{tipY=mouseY+p;d='bottom'}}else if(posY+q+p>baseline){tipY=(q>=wHeight)?s:baseline-q-p}else if(n.css('display')=='block'||n[0].tagName.toLowerCase()=='area'||G.positionBy=="mouse"){tipY=a-p}else{tipY=posY-G.dropShadowSteps}if(d==''){d=(posX<w)?'left':'right'}H.css({top:tipY+'px'}).removeClass().addClass('clue-'+d+'-'+ctClass).addClass(' cluetip-'+ctClass);if(G.arrows){var e=(posY-tipY-G.dropShadowSteps);$cluetipArrows.css({top:(/(left|right)/.test(d)&&posX>=0&&e>0)?e+'px':(/(left|right)/.test(d))?0:''}).show()}else{$cluetipArrows.hide()}$dropShadow.hide();H.hide()[G.fx.open](G.fx.open!='show'&&G.fx.openSpeed);if(G.dropShadow){$dropShadow.css({height:q,width:t}).show()}if($.fn.bgiframe){H.bgiframe()}if(G.delayedClose>0){closeOnDelay=setTimeout(D,G.delayedClose)}G.onShow(H,$cluetipInner)};var C=function(){l=false;$('#cluetip-waitimage').hide();if(!G.sticky||(/click|toggle/).test(G.activation)){D();clearTimeout(closeOnDelay)};if(G.hoverClass){n.removeClass(G.hoverClass)}$('.cluetip-clicked').removeClass('cluetip-clicked')};var D=function(){$cluetipOuter.parent().hide().removeClass().end().children().empty();if(y){n.attr('title',y)}n.css('cursor','');if(G.arrows){$cluetipArrows.css({top:''})}};if((/click|toggle/).test(G.activation)){n.click(function(a){if(H.is(':hidden')||!n.is('.cluetip-clicked')){A(a);$('.cluetip-clicked').removeClass('cluetip-clicked');n.addClass('cluetip-clicked')}else{C(a)}this.blur();return false})}else if(G.activation=='focus'){n.focus(function(a){A(a)});n.blur(function(a){C(a)})}else{n.click(function(){if(n.attr('href')&&n.attr('href')==o&&!G.clickThrough){return false}});var E=function(b){if(G.tracking==true){var c=posX-b.pageX;var d=(tipY)?tipY-b.pageY:posY-b.pageY;n.mousemove(function(a){H.css({left:a.pageX+c,top:a.pageY+d})})}};if($.fn.hoverIntent&&G.hoverIntent){n.mouseover(function(){n.attr('title','')}).hoverIntent({sensitivity:G.hoverIntent.sensitivity,interval:G.hoverIntent.interval,over:function(a){A(a);E(a)},timeout:G.hoverIntent.timeout,out:function(a){C(a);n.unbind('mousemove')}})}else{n.hover(function(a){A(a);E(a)},function(a){C(a);n.unbind('mousemove')})}}})};$.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(e){return true},onShow:function(a,c){},ajaxCache:true,ajaxProcess:function(a){a=a.replace(/<s(cript|tyle)(.|\s)*?\/s(cript|tyle)>/g,'').replace(/<(link|title)(.|\s)*?\/(link|title)>/g,'');return a},ajaxSettings:{dataType:'html'}};var I='appendTo',insertionElement='body';$.cluetip={};$.cluetip.setup=function(a){if(a&&a.insertionType&&(a.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){I=a.insertionType}if(a&&a.insertionElement){insertionElement=a.insertionElement}}})(jQuery);