(function($){
$.cluetip={version:"1.0.4"};
var _1,_2,_3,_4,_5,_6,_7,_8;
$.fn.cluetip=function(js,_9){
if(typeof js=="object"){
_9=js;
js=null;
}
if(js=="destroy"){
return this.unbind(".cluetip");
}
return this.each(function(_a){
var _b=this,_c=$(this);
var _d=$.extend(true,{},$.fn.cluetip.defaults,_9||{},$.metadata?_c.metadata():$.meta?_c.data():{});
var _e=false;
var _f=+_d.cluezIndex;
_c.data("thisInfo",{title:_b.title,zIndex:_f});
var _10=false,_11=0;
if(!$("#cluetip").length){
$(["<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(""))[_4e](_4f).hide();
_1=$("#cluetip").css({position:"absolute"});
_3=$("#cluetip-outer").css({position:"relative",zIndex:_f});
_2=$("#cluetip-inner");
_4=$("#cluetip-title");
_5=$("#cluetip-arrows");
_6=$("<div id=\"cluetip-waitimage\"></div>").css({position:"absolute"}).insertBefore(_1).hide();
}
var _12=(_d.dropShadow)?+_d.dropShadowSteps:0;
if(!_7){
_7=$([]);
for(var i=0;i<_12;i++){
_7=_7.add($("<div></div>").css({zIndex:_f-1,opacity:0.1,top:1+i,left:1+i}));
}
_7.css({position:"absolute",backgroundColor:"#000"}).prependTo(_1);
}
var _13=_c.attr(_d.attribute),_14=_d.cluetipClass;
if(!_13&&!_d.splitTitle&&!js){
return true;
}
if(_d.local&&_d.localPrefix){
_13=_d.localPrefix+_13;
}
if(_d.local&&_d.hideLocal){
$(_13+":first").hide();
}
var _15=parseInt(_d.topOffset,10),_16=parseInt(_d.leftOffset,10);
var _17,_18,_19=isNaN(parseInt(_d.height,10))?"auto":(/\D/g).test(_d.height)?_d.height:_d.height+"px";
var _1a,_1b,_1c,_1d,_1e,_1f;
var _20=parseInt(_d.width,10)||275,_21=_20+(parseInt(_1.css("paddingLeft"),10)||0)+(parseInt(_1.css("paddingRight"),10)||0)+_12,_22=this.offsetWidth,_23,_24,_25,_26,_27;
var _28;
var _29=(_d.attribute!="title")?_c.attr(_d.titleAttribute):"";
if(_d.splitTitle){
if(_29==undefined){
_29="";
}
_28=_29.split(_d.splitTitle);
_29=_28.shift();
}
if(_d.escapeTitle){
_29=_29.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;");
}
var _2a;
function _2b(){
return false;
};
var _2c=function(_2d){
if(!_d.onActivate(_c)){
return false;
}
_10=true;
_1.removeClass().css({width:_20});
if(_13==_c.attr("href")){
_c.css("cursor",_d.cursor);
}
if(_d.hoverClass){
_c.addClass(_d.hoverClass);
}
_1b=_1c=_c.offset().top;
_23=_c.offset().left;
_26=_2d.pageX;
_1e=_2d.pageY;
if(_b.tagName.toLowerCase()!="area"){
_1a=$(document).scrollTop();
_27=$(window).width();
}
if(_d.positionBy=="fixed"){
_24=_22+_23+_16;
_1.css({left:_24});
}else{
_24=(_22>_23&&_23>_21)||_23+_22+_21+_16>_27?_23-_21-_16:_22+_23+_16;
if(_b.tagName.toLowerCase()=="area"||_d.positionBy=="mouse"||_22+_21>_27){
if(_26+20+_21>_27){
_1.addClass(" cluetip-"+_14);
_24=(_26-_21-_16)>=0?_26-_21-_16-parseInt(_1.css("marginLeft"),10)+parseInt(_2.css("marginRight"),10):_26-(_21/2);
}else{
_24=_26+_16;
}
}
var pY=_24<0?_2d.pageY+_15:_2d.pageY;
_1.css({left:(_24>0&&_d.positionBy!="bottomTop")?_24:(_26+(_21/2)>_27)?_27/2-_21/2:Math.max(_26-(_21/2),0),zIndex:_c.data("thisInfo").zIndex});
_5.css({zIndex:_c.data("thisInfo").zIndex+1});
}
_18=$(window).height();
if(js){
if(typeof js=="function"){
js=js(_b);
}
_2.html(js);
_2e(pY);
}else{
if(_28){
var tpl=_28.length;
_2.html(_28[0]);
if(tpl>1){
for(var i=1;i<tpl;i++){
_2.append("<div class=\"split-body\">"+_28[i]+"</div>");
}
}
_2e(pY);
}else{
if(!_d.local&&_13.indexOf("#")!=0){
if(/\.(jpe?g|tiff?|gif|png)$/i.test(_13)){
_2.html("<img src=\""+_13+"\" alt=\""+_29+"\" />");
_2e(pY);
}else{
if(_e&&_d.ajaxCache){
_2.html(_e);
_2e(pY);
}else{
var _2f=_d.ajaxSettings.beforeSend,_30=_d.ajaxSettings.error,_31=_d.ajaxSettings.success,_32=_d.ajaxSettings.complete;
var _33={cache:false,url:_13,beforeSend:function(xhr){
if(_2f){
_2f.call(_b,xhr,_1,_2);
}
_3.children().empty();
if(_d.waitImage){
_6.css({top:_1e+20,left:_26+20,zIndex:_c.data("thisInfo").zIndex-1}).show();
}
},error:function(xhr,_34){
if(_10){
if(_30){
_30.call(_b,xhr,_34,_1,_2);
}else{
_2.html("<i>sorry, the contents could not be loaded</i>");
}
}
},success:function(_35,_36){
_e=_d.ajaxProcess.call(_b,_35);
if(_10){
if(_31){
_31.call(_b,_35,_36,_1,_2);
}
_2.html(_e);
}
},complete:function(xhr,_37){
if(_32){
_32.call(_b,xhr,_37,_1,_2);
}
_8=$("#cluetip-inner img").length;
if(_8&&!$.browser.opera){
$("#cluetip-inner img").bind("load error",function(){
_8--;
if(_8<1){
_6.hide();
if(_10){
_2e(pY);
}
}
});
}else{
_6.hide();
if(_10){
_2e(pY);
}
}
}};
var _38=$.extend(true,{},_d.ajaxSettings,_33);
$.ajax(_38);
}
}
}else{
if(_d.local){
var _39=$(_13+(/#\S+$/.test(_13)?"":":eq("+_a+")")).clone(true).show();
_2.html(_39);
_2e(pY);
}
}
}
}
};
var _2e=function(bpY){
_1.addClass("cluetip-"+_14);
if(_d.truncate){
var _3a=_2.text().slice(0,_d.truncate)+"...";
_2.html(_3a);
}
function _3b(){
};
_29?_4.show().html(_29):(_d.showTitle)?_4.show().html("&nbsp;"):_4.hide();
if(_d.sticky){
var _3c=$("<div id=\"cluetip-close\"><a href=\"#\">"+_d.closeText+"</a></div>");
(_d.closePosition=="bottom")?_3c.appendTo(_2):(_d.closePosition=="title")?_3c.prependTo(_4):_3c.prependTo(_2);
_3c.bind("click.cluetip",function(){
_3d();
return false;
});
if(_d.mouseOutClose){
_1.bind("mouseleave.cluetip",function(){
_3d();
});
}else{
_1.unbind("mouseleave.cluetip");
}
}
var _3e="";
_3.css({zIndex:_c.data("thisInfo").zIndex,overflow:_19=="auto"?"visible":"auto",height:_19});
_17=_19=="auto"?Math.max(_1.outerHeight(),_1.height()):parseInt(_19,10);
_1d=_1c;
_1f=_1a+_18;
if(_d.positionBy=="fixed"){
_1d=_1c-_d.dropShadowSteps+_15;
}else{
if((_24<_26&&Math.max(_24,0)+_21>_26)||_d.positionBy=="bottomTop"){
if(_1c+_17+_15>_1f&&_1e-_1a>_17+_15){
_1d=_1e-_17-_15;
_3e="top";
}else{
_1d=_1e+_15;
_3e="bottom";
}
}else{
if(_1c+_17+_15>_1f){
_1d=(_17>=_18)?_1a:_1f-_17-_15;
}else{
if(_c.css("display")=="block"||_b.tagName.toLowerCase()=="area"||_d.positionBy=="mouse"){
_1d=bpY-_15;
}else{
_1d=_1c-_d.dropShadowSteps;
}
}
}
}
if(_3e==""){
_24<_23?_3e="left":_3e="right";
}
_1.css({top:_1d+"px"}).removeClass().addClass("clue-"+_3e+"-"+_14).addClass(" cluetip-"+_14);
if(_d.arrows){
var bgY=(_1c-_1d-_d.dropShadowSteps);
_5.css({top:(/(left|right)/.test(_3e)&&_24>=0&&bgY>0)?bgY+"px":/(left|right)/.test(_3e)?0:""}).show();
}else{
_5.hide();
}
_7.hide();
_1.hide()[_d.fx.open](_d.fx.open!="show"&&_d.fx.openSpeed);
if(_d.dropShadow){
_7.css({height:_17,width:_20,zIndex:_c.data("thisInfo").zIndex-1}).show();
}
if($.fn.bgiframe){
_1.bgiframe();
}
if(_d.delayedClose>0){
_11=setTimeout(_3d,_d.delayedClose);
}
_d.onShow.call(_b,_1,_2);
};
var _3f=function(_40){
_10=false;
_6.hide();
if(!_d.sticky||(/click|toggle/).test(_d.activation)){
_3d();
clearTimeout(_11);
}
if(_d.hoverClass){
_c.removeClass(_d.hoverClass);
}
};
var _3d=function(){
_3.parent().hide().removeClass();
_d.onHide.call(_b,_1,_2);
_c.removeClass("cluetip-clicked");
if(_29){
_c.attr(_d.titleAttribute,_29);
}
_c.css("cursor","");
if(_d.arrows){
_5.css({top:""});
}
};
$(document).bind("hideCluetip",function(e){
_3d();
});
if((/click|toggle/).test(_d.activation)){
_c.bind("click.cluetip",function(_41){
if(_1.is(":hidden")||!_c.is(".cluetip-clicked")){
_2c(_41);
$(".cluetip-clicked").removeClass("cluetip-clicked");
_c.addClass("cluetip-clicked");
}else{
_3f(_41);
}
this.blur();
return false;
});
}else{
if(_d.activation=="focus"){
_c.bind("focus.cluetip",function(_42){
_2c(_42);
});
_c.bind("blur.cluetip",function(_43){
_3f(_43);
});
}else{
_c[_d.clickThrough?"unbind":"bind"]("click",_2b);
var _44=function(evt){
if(_d.tracking==true){
var _45=_24-evt.pageX;
var _46=_1d?_1d-evt.pageY:_1c-evt.pageY;
_c.bind("mousemove.cluetip",function(evt){
_1.css({left:evt.pageX+_45,top:evt.pageY+_46});
});
}
};
if($.fn.hoverIntent&&_d.hoverIntent){
_c.hoverIntent({sensitivity:_d.hoverIntent.sensitivity,interval:_d.hoverIntent.interval,over:function(_47){
_2c(_47);
_44(_47);
},timeout:_d.hoverIntent.timeout,out:function(_48){
_3f(_48);
_c.unbind("mousemove.cluetip");
}});
}else{
_c.bind("mouseenter.cluetip",function(_49){
_2c(_49);
_44(_49);
}).bind("mouseleave.cluetip",function(_4a){
_3f(_4a);
_c.unbind("mousemove.cluetip");
});
}
_c.bind("mouseenter.cluetip",function(_4b){
_c.attr("title","");
}).bind("mouseleave.cluetip",function(_4c){
_c.attr("title",_c.data("thisInfo").title);
});
}
}
});
};
$.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:true,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(ct,ci){
},onHide:function(ct,ci){
},ajaxCache:true,ajaxProcess:function(_4d){
_4d=_4d.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm,"").replace(/<(link|meta)[^>]+>/g,"");
return _4d;
},ajaxSettings:{dataType:"html"},debug:false};
var _4e="appendTo",_4f="body";
$.cluetip.setup=function(_50){
if(_50&&_50.insertionType&&(_50.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){
_4e=_50.insertionType;
}
if(_50&&_50.insertionElement){
_4f=_50.insertionElement;
}
};
})(jQuery);
