!function(){var moduleFactory=function($){var module=this;$.require().stylesheet("fancybox/thumbs").done(function(){var exports=function(){var F=$.fancybox;F.helpers.thumbs={wrap:null,list:null,width:0,source:function(el){var img=$(el).find("img");return img.length?img.attr("src"):el.href},init:function(opts){var list,that=this,thumbWidth=opts.width||50,thumbHeight=opts.height||50,thumbSource=opts.source||this.source;list="";for(var n=0;n<F.group.length;n++)list+='<li><a style="width:'+thumbWidth+"px;height:"+thumbHeight+'px;" href="javascript:'+$.globalNamespace+".fancybox.jumpto("+n+');"></a></li>';
this.wrap=$('<div id="fancybox-thumbs"></div>').addClass(opts.position||"bottom").appendTo("body"),this.list=$("<ul>"+list+"</ul>").appendTo(this.wrap),$.each(F.group,function(i){$("<img />").load(function(){var widthRatio,heightRatio,parent,width=this.width,height=this.height;that.list&&width&&height&&(widthRatio=width/thumbWidth,heightRatio=height/thumbHeight,parent=that.list.children().eq(i).find("a"),widthRatio>=1&&heightRatio>=1&&(widthRatio>heightRatio?(width=Math.floor(width/heightRatio),height=thumbHeight):(width=thumbWidth,height=Math.floor(height/widthRatio))),$(this).css({width:width,height:height,top:Math.floor(thumbHeight/2-height/2),left:Math.floor(thumbWidth/2-width/2)}),parent.width(thumbWidth).height(thumbHeight),$(this).hide().appendTo(parent).fadeIn(300))
}).attr("src",thumbSource(this))}),this.width=this.list.children().eq(0).outerWidth(),this.list.width(this.width*(F.group.length+1)).css("left",Math.floor(.5*$(window).width()-(F.current.index*this.width+.5*this.width)))},update:function(){this.list&&this.list.stop(!0).animate({left:Math.floor(.5*$(window).width()-(F.current.index*this.width+.5*this.width))},150)},beforeLoad:function(opts){return F.group.length<2?(F.coming.helpers.thumbs=!1,void 0):(F.coming.margin["top"===opts.position?0:2]=opts.height+30,void 0)
},afterShow:function(opts){this.list?this.update(opts):this.init(opts),this.list.children().removeClass("active").eq(F.current.index).addClass("active")},onUpdate:function(){this.update()},beforeClose:function(){this.wrap&&this.wrap.remove(),this.wrap=null,this.list=null,this.width=0}}};exports(),module.resolveWith(exports)})};dispatch("fancybox/thumbs").containing(moduleFactory).to("Foundry/2.1 Modules")}();