(function($){var strImgDir=
'ressources/'
;var oImgZoomBox=$(
'<div>'
);var oImgClose=$(
'<img>'
).css({position:
'absolute'
,top:0,left:0,cursor:
'pointer'
,zIndex:103});$.fn.fancyzoom=function(userOptions){
var oOverlay=$(
'<div>'
).css({height:
'100%'
,width:
'100%'
,position:
'fixed'
,left:0,top:0,cursor:
"wait"
,zIndex:101});function openZoomBox(elLink,o){if(o.showoverlay){oOverlay.appendTo(
'body'
).click(function(){closeZoomBox(o);});}
pos=$(
'img'
,elLink).offset();o=$.extend(o,{dimOri:{width:$(
'img'
,elLink).outerWidth(),height:$(
'img'
,elLink).outerHeight(),left:pos.left,top:pos.top,
'opacity'
:0}});
oImgZoomBox.css({
'opacity'
:0}).appendTo(
'body'
);var iWidth=oImgZoomBox.outerWidth();var iHeight=oImgZoomBox.outerHeight();
dimBoxTarget=$.extend({},{width:iWidth,height:iHeight,
'opacity'
:1},__posCenter((iWidth+15),(iHeight+30)));
oImgClose.css({left:(iWidth-30+dimBoxTarget.left),top:dimBoxTarget.top});var $fctEnd=function(){
if($.fn.shadow&&!$.browser.msie){$(
'img:first'
,oImgZoomBox).shadow(o.shadowOpts);}
if(o.Speed>0&&!$.browser.msie){oImgClose.fadeIn(
'slow'
);$(
'div'
,oImgZoomBox).fadeIn(
'slow'
);}
else {oImgClose.show();$(
'div'
,oImgZoomBox).show();}};
$(
'div'
,oImgZoomBox).hide();if(o.Speed>0){oImgZoomBox.css({zIndex:102}).css(o.dimOri).animate(dimBoxTarget,o.Speed,$fctEnd).bind(
"contextmenu"
,function(){return (false)});}
else {oImgZoomBox.css(dimBoxTarget);$fctEnd();}}
function closeZoomBox(o){oImgClose.remove();if(o.Speed>0){oImgZoomBox.animate(o.dimOri,o.Speed,function(){$(this).empty().remove();});if(o.showoverlay){oOverlay.animate({
'opacity'
:0},o.Speed,function(){$(this).empty().remove();});}}else {oImgZoomBox.empty().remove();if(o.showoverlay){oOverlay.empty().remove();}}}
return this.each(function(){var $this=$(this);
var opts=$.extend($.fn.fancyzoom.defaultsOptions,userOptions||{},{dimOri:{},oImgZoomBoxProp:{position:
'absolute'
,left:0,top:0}});oOverlay.css({opacity:opts.overlay,background:opts.overlayColor});
if($(
'img'
,$this).size()===0){return;}
$this.click(function(){if(oLoading&&oLoading.is(
':visible'
)||timerLoadingImg){
if(oImgZoomBox&&$(
'img:first'
,oImgZoomBox).attr(
'src'
) !=$(this).attr(
'href'
)){__cancelLoading();}
else {
return false;}}
var o=$.extend({},opts,userOptions);if(oImgZoomBox&&oImgZoomBox.parent().size()>0){var imCurrent=$(
'img:first'
,oImgZoomBox);if($this.attr(
'href'
)==imCurrent.attr(
'src'
)){var imgTarget=$(
'img'
,$this);
pos=imgTarget.offset();o=$.extend(o,{dimOri:{width:imgTarget.outerWidth(),height:imgTarget.outerHeight(),left:pos.left,top:pos.top,
'opacity'
:0}});closeZoomBox(o);return false;}else {
oImgClose.remove();oImgZoomBox.empty().remove();}}
if(o.showoverlay&&oOverlay){oOverlay.empty().remove().css({
'opacity'
:o.overlay});}
oImgClose.attr(
'src'
,o.imgDir+
'closebox.png'
).appendTo(
'body'
).hide();if($.fn.ifixpng){$.ifixpng(o.imgDir+
'blank.gif'
);oImgClose.ifixpng(o.imgDir+
'blank.gif'
);}
oImgClose.unbind(
'click'
).click(function(){closeZoomBox(o);});
oImgZoomBox=$(
'<div>'
).empty().css(o.oImgZoomBoxProp);var strTitle=$(
'img'
,$this).attr(
'alt'
);if(strTitle){var oTitle=$(
'<div><center><table height=0 border="0" cellspacing=0 cellpadding=0><tr><td></td><td class="fancyTitle">'
+strTitle+
'</td><td></td></table></center></div>'
).css({marginTop:10,marginRight:15});var tdL=oTitle.find(
'td:first'
).css({
'background'
:
'url('
+o.imgDir+
'zoom-caption-l.png)'
,width:
'13px'
,height:
'26px'
});var tdR=oTitle.find(
'td:last'
).css({
'background'
:
'url('
+o.imgDir+
'zoom-caption-r.png)'
,width:
'13px'
,height:
'26px'
});var tdC=$(
'.fancyTitle'
,oTitle).css({
'background'
:
'url('
+o.imgDir+
'zoom-caption-fill.png)'
,
'padding'
:
'0px 20px'
,color:
'#FFF'
,
'font-size'
:
'14px'
});if($.fn.ifixpng){tdL.ifixpng(o.imgDir+
'blank.gif'
);tdR.ifixpng(o.imgDir+
'blank.gif'
);tdC.ifixpng(o.imgDir+
'blank.gif'
);}
oTitle.appendTo(oImgZoomBox);}
var oImgZoom=$(
'<img />'
).attr(
'src'
,$(this).attr(
'href'
)).css({zIndex:102,marginTop:15,marginRight:15}).click(function(){closeZoomBox(o);}).prependTo(oImgZoomBox);
var imgPreload=new Image();imgPreload.src=$(this).attr(
'href'
);var $fctEndLoading=function(){if(bCancelLoading){bCancelLoading=false;}
else {if(__getFileName(imgPreload.src)==__getFileName($(
'img:first'
,oImgZoomBox).attr(
'src'
))){openZoomBox($this,o);__stoploading();}}};if(imgPreload.complete){openZoomBox($this,o);
}
else {__displayLoading();imgPreload.onload=function(){
$fctEndLoading();};}
return false;});});
};
$.fn.fancyzoom.defaultsOptions={overlayColor:
'#000'
,overlay:0.6,showoverlay:true,Speed:400,shadowOpts:{color:
"#000"
,offset:4,opacity:0.2},imgDir:strImgDir};function __posCenter(iWidth,iHeight){var iLeft=($(window).width()-iWidth) / 2+$(window).scrollLeft();var iTop=($(window).height()-iHeight) / 2+$(window).scrollTop();iLeft=(iLeft<0)?0:iLeft;iTop=(iTop<0)?0:iTop;return {left:iLeft,top:iTop};}
var oLoading=null;var bCancelLoading=false;var timerLoadingImg=null;function __displayLoading(){if(!oLoading){oLoading=$(
'<div></div>'
).css({width:50,height:50,position:
'absolute'
,
'background'
:
'transparent'
,opacity:8/10,color:
'#FFF'
,padding:
'5px'
,
'font-size'
:
'10px'
});}
oLoading.appendTo(
'body'
).css(__posCenter(50,50)).html(
'<img src="'
+$.fn.fancyzoom.defaultsOptions.imgDir+
'blank.gif" />'
).click(function(){__cancelLoading();}).show();timerLoadingImg=setTimeout(__changeimageLoading,400);}
function __cancelLoading(){bCancelLoading=true;__stoploading();}
function __stoploading(){oLoading.hide().remove();if(timerLoadingImg){clearTimeout(timerLoadingImg);timerLoadingImg=null;}}
function __changeimageLoading(){if(!oLoading.is(
':visible'
)){timerLoadingImg=null;return;}
var $im=$(
'img'
,oLoading);
if(!$im.attr(
'src'
)||
/blank\.gif/.test($im.attr(
'src'
))){strImgSrc=$.fn.fancyzoom.defaultsOptions.imgDir+
"zoom-spin-1.png"
;}
else {tab=$im.attr(
'src'
).split(
/[- .]+/);iImg=parseInt(tab[2]);iImg=(iImg<12)?(iImg+1):1;strImgSrc=tab[0]+
"-"
+tab[1]+
"-"
+iImg+
"."
+tab[3];}
var pLoad=new Image();pLoad.src=strImgSrc;var $fct=function (){oLoading.css(__posCenter(50,50));$im.attr(
'src'
,strImgSrc);timerLoadingImg=setTimeout(__changeimageLoading,100);};
if(pLoad.complete){$fct();}
else{pLoad.onload=$fct;}}
function __getFileName(strPath){if(!strPath){return false;}
var tabPath=strPath.split(
'/'
);return ((tabPath.length<1)?strPath:tabPath[(tabPath.length-1)]);}})(jQuery);
