").html(t).find(e.selector):h(t)&&(t.data(d)||t.data(d,i('
').insertAfter(t).hide()),t=t.show().detach(),e.wrap.bind("onReset",function(){i(this).find(t).length&&t.hide().replaceAll(t.data(d)).data(d,!1)}));break;case"image":t=e.tpl.image.replace("{href}",s);break;case"swf":t='
"}h(t)&&t.parent().is(e.inner)||e.inner.append(t),r.trigger("beforeShow"),e.inner.css("overflow","yes"===a?"scroll":"no"===a?"hidden":a),r._setDimension(),r.reposition(),r.isOpen=!1,r.coming=null,r.bindEvents(),r.isOpened?c.prevMethod&&r.transitions[c.prevMethod]():i(".fancybox-wrap").not(e.wrap).stop(!0).trigger("onReset").remove(),r.transitions[r.isOpened?e.nextMethod:e.openMethod](),r._preloadImages()}},_setDimension:function(){var e,t,n,a,s,o,l,c,d,h,p,f,v,w,b,y=r.getViewport(),x=0,_=!1,k=!1,j=r.wrap,C=r.skin,I=r.inner,T=r.current,S=T.width,W=T.height,H=T.minWidth,L=T.minHeight,D=T.maxWidth,A=T.maxHeight,P=T.scrolling,B=T.scrollOutside?T.scrollbarWidth:0,M=T.margin,R=g(M[1]+M[3]),O=g(M[0]+M[2]);if(j.add(C).add(I).width("auto").height("auto").removeClass("fancybox-tmp"),e=g(C.outerWidth(!0)-C.width()),t=g(C.outerHeight(!0)-C.height()),n=R+e,a=O+t,s=u(S)?(y.w-n)*g(S)/100:S,o=u(W)?(y.h-a)*g(W)/100:W,"iframe"===T.type){if(w=T.content,T.autoHeight&&1===w.data("ready"))try{w[0].contentWindow.document.location&&(I.width(s).height(9999),b=w.contents().find("body"),B&&b.css("overflow-x","hidden"),o=b.outerHeight(!0))}catch(E){}}else(T.autoWidth||T.autoHeight)&&(I.addClass("fancybox-tmp"),T.autoWidth||I.width(s),T.autoHeight||I.height(o),T.autoWidth&&(s=I.width()),T.autoHeight&&(o=I.height()),I.removeClass("fancybox-tmp"));if(S=g(s),W=g(o),d=s/o,H=g(u(H)?g(H,"w")-n:H),D=g(u(D)?g(D,"w")-n:D),L=g(u(L)?g(L,"h")-a:L),A=g(u(A)?g(A,"h")-a:A),l=D,c=A,T.fitToView&&(D=Math.min(y.w-n,D),A=Math.min(y.h-a,A)),f=y.w-R,v=y.h-O,T.aspectRatio?(S>D&&(S=D,W=g(S/d)),W>A&&(W=A,S=g(W*d)),H>S&&(S=H,W=g(S/d)),L>W&&(W=L,S=g(W*d))):(S=Math.max(H,Math.min(S,D)),T.autoHeight&&"iframe"!==T.type&&(I.width(S),W=I.height()),W=Math.max(L,Math.min(W,A))),T.fitToView)if(I.width(S).height(W),j.width(S+e),h=j.width(),p=j.height(),T.aspectRatio)for(;(h>f||p>v)&&S>H&&W>L&&!(x++>19);)W=Math.max(L,Math.min(A,W-10)),S=g(W*d),H>S&&(S=H,W=g(S/d)),S>D&&(S=D,W=g(S/d)),I.width(S).height(W),j.width(S+e),h=j.width(),p=j.height();else S=Math.max(H,Math.min(S,S-(h-f))),W=Math.max(L,Math.min(W,W-(p-v)));B&&"auto"===P&&o>W&&f>S+e+B&&(S+=B),I.width(S).height(W),j.width(S+e),h=j.width(),p=j.height(),_=(h>f||p>v)&&S>H&&W>L,k=T.aspectRatio?l>S&&c>W&&s>S&&o>W:(l>S||c>W)&&(s>S||o>W),i.extend(T,{dim:{width:m(h),height:m(p)},origWidth:s,origHeight:o,canShrink:_,canExpand:k,wPadding:e,hPadding:t,wrapSpace:p-C.outerHeight(!0),skinSpace:C.height()-W}),!w&&T.autoHeight&&W>L&&A>W&&!k&&I.height("auto")},_getPosition:function(e){var t=r.current,i=r.getViewport(),n=t.margin,a=r.wrap.width()+n[1]+n[3],s=r.wrap.height()+n[0]+n[2],o={position:"absolute",top:n[0],left:n[3]};return t.autoCenter&&t.fixed&&!e&&s<=i.h&&a<=i.w?o.position="fixed":t.locked||(o.top+=i.y,o.left+=i.x),o.top=m(Math.max(o.top,o.top+(i.h-s)*t.topRatio)),o.left=m(Math.max(o.left,o.left+(i.w-a)*t.leftRatio)),o},_afterZoomIn:function(){var e=r.current;e&&(r.isOpen=r.isOpened=!0,r.wrap.css("overflow","visible").addClass("fancybox-opened"),r.update(),(e.closeClick||e.nextClick&&r.group.length>1)&&r.inner.css("cursor","pointer").bind("click.fb",function(t){i(t.target).is("a")||i(t.target).parent().is("a")||(t.preventDefault(),r[e.closeClick?"close":"next"]())}),e.closeBtn&&i(e.tpl.closeBtn).appendTo(r.skin).bind("click.fb",function(e){e.preventDefault(),r.close()}),e.arrows&&r.group.length>1&&((e.loop||e.index>0)&&i(e.tpl.prev).appendTo(r.outer).bind("click.fb",r.prev),(e.loop||e.index
').appendTo(r.coming?r.coming.parent:e.parent),this.fixed=!1,e.fixed&&r.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(e){var t=this;e=i.extend({},this.defaults,e),this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(e),this.fixed||(s.bind("resize.overlay",i.proxy(this.update,this)),this.update()),e.closeClick&&this.overlay.bind("click.overlay",function(e){return i(e.target).hasClass("fancybox-overlay")?(r.isActive?r.close():t.close(),!1):void 0}),this.overlay.css(e.css).show()},close:function(){var e,t;s.unbind("resize.overlay"),this.el.hasClass("fancybox-lock")&&(i(".fancybox-margin").removeClass("fancybox-margin"),e=s.scrollTop(),t=s.scrollLeft(),this.el.removeClass("fancybox-lock"),s.scrollTop(e).scrollLeft(t)),i(".fancybox-overlay").remove().hide(),i.extend(this,{overlay:null,fixed:!1})},update:function(){var e,i="100%";this.overlay.width(i).height("100%"),l?(e=Math.max(t.documentElement.offsetWidth,t.body.offsetWidth),o.width()>e&&(i=o.width())):o.width()>s.width()&&(i=o.width()),this.overlay.width(i).height(o.height())},onReady:function(e,t){var n=this.overlay;i(".fancybox-overlay").stop(!0,!0),n||this.create(e),e.locked&&this.fixed&&t.fixed&&(n||(this.margin=o.height()>s.height()?i("html").css("margin-right").replace("px",""):!1),t.locked=this.overlay.append(t.wrap),t.fixed=!1),e.showEarly===!0&&this.beforeShow.apply(this,arguments)},beforeShow:function(e,t){var n,a;t.locked&&(this.margin!==!1&&(i("*").filter(function(){return"fixed"===i(this).css("position")&&!i(this).hasClass("fancybox-overlay")&&!i(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin"),this.el.addClass("fancybox-margin")),n=s.scrollTop(),a=s.scrollLeft(),this.el.addClass("fancybox-lock"),s.scrollTop(n).scrollLeft(a)),this.open(e)},onUpdate:function(){this.fixed||this.update()},afterClose:function(e){this.overlay&&!r.coming&&this.overlay.fadeOut(e.speedOut,i.proxy(this.close,this))}},r.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(e){var t,n,a=r.current,s=a.title,o=e.type;if(i.isFunction(s)&&(s=s.call(a.element,a)),p(s)&&""!==i.trim(s)){switch(t=i('