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