!function(t,n,e,i){"use strict";var o=function(){var t=e.body||e.documentElement;return t=t.style,""===t.WebkitTransition?"-webkit-":""===t.MozTransition?"-moz-":""===t.OTransition?"-o-":""===t.transition?"":!1},r=o()!==!1,a=function(t,n,e){var i={},r=o();i[r+"transform"]="translateX("+n+")",i[r+"transition"]=r+"transform "+e+"s linear",t.css(i)},u="ontouchstart"in n,c=n.navigator.pointerEnabled||n.navigator.msPointerEnabled,f=function(t){if(u)return!0;if(!c||"undefined"==typeof t||"undefined"==typeof t.pointerType)return!1;if("undefined"!=typeof t.MSPOINTER_TYPE_MOUSE){if(t.MSPOINTER_TYPE_MOUSE!==t.pointerType)return!0}else if("mouse"!==t.pointerType)return!0;return!1};t.fn.imageLightbox=function(o){var s=t.extend({selector:'id="imagelightbox"',allowedTypes:"png|jpg|jpeg||gif",animationSpeed:250,preloadNext:!0,enableKeyboard:!0,quitOnEnd:!1,quitOnImgClick:!1,quitOnDocClick:!0,quitOnEscKey:!0,onStart:!1,onEnd:!1,onLoadStart:!1,onLoadEnd:!1,previousTarget:function(){return this.previousTargetDefault()},previousTargetDefault:function(){var t=d.index(l)-1;if(0>t){if(s.quitOnEnd===!0)return I(),!1;t=d.length-1}l=d.eq(t)},nextTarget:function(){return this.nextTargetDefault()},nextTargetDefault:function(){var t=d.index(l)+1;if(t>=d.length){if(s.quitOnEnd===!0)return I(),!1;t=0}l=d.eq(t)}},o),d=t([]),l=t(),p=t(),g=0,h=0,v=0,m=!1,x=function(n){var e="a"===t(n).prop("tagName").toLowerCase()&&new RegExp(".("+s.allowedTypes+")$","i").test(t(n).attr("href")),o=t(n).attr("data-lightbox")!==i;return e||o},E=function(){if(!p.length)return!0;var e=.8*t(n).width(),i=.9*t(n).height(),o=new Image;o.src=p.attr("src"),o.onload=function(){if(g=o.width,h=o.height,g>e||h>i){var r=g/h>e/i?g/e:h/i;g/=r,h/=r}p.css({width:g+"px",height:h+"px",top:(t(n).height()-h)/2+"px",left:(t(n).width()-g)/2+"px"})}},y=function(n){if(m)return!1;if(n="undefined"==typeof n?!1:"left"===n?1:-1,p.length){var e={opacity:0};r?a(p,100*n-v+"px",s.animationSpeed/1e3):e.left=parseInt(p.css("left"))+100*n+"px",p.animate(e,s.animationSpeed,function(){b()}),v=0}m=!0,s.onLoadStart!==!1&&s.onLoadStart(),setTimeout(function(){var e=l.attr("href");e===i&&(e=l.attr("data-lightbox")),p=t("<img "+s.selector+" />").attr("src",e).load(function(){p.appendTo("body"),E();var e={opacity:1};if(p.css("opacity",0),r)a(p,-100*n+"px",0),setTimeout(function(){a(p,"0px",s.animationSpeed/1e3)},50);else{var i=parseInt(p.css("left"));e.left=i+"px",p.css("left",i-100*n+"px")}if(p.animate(e,s.animationSpeed,function(){m=!1,s.onLoadEnd!==!1&&s.onLoadEnd()}),s.preloadNext){var o=d.eq(d.index(l)+1);o.length||(o=d.eq(0)),t("<img />").attr("src",o.attr("href")).load()}}).error(function(){s.onLoadEnd!==!1&&s.onLoadEnd()});var o=0,u=0,h=0;p.on(c?"pointerup MSPointerUp":"click",function(t){if(t.preventDefault(),s.quitOnImgClick)return I(),!1;if(f(t.originalEvent))return!0;var n=(t.pageX||t.originalEvent.pageX)-t.target.offsetLeft;g/2>n?S():T()}).on("touchstart pointerdown MSPointerDown",function(t){return!f(t.originalEvent)||s.quitOnImgClick?!0:(r&&(h=parseInt(p.css("left"))),void(o=t.originalEvent.pageX||t.originalEvent.touches[0].pageX))}).on("touchmove pointermove MSPointerMove",function(t){return!f(t.originalEvent)||s.quitOnImgClick?!0:(t.preventDefault(),u=t.originalEvent.pageX||t.originalEvent.touches[0].pageX,v=o-u,void(r?a(p,-v+"px",0):p.css("left",h-v+"px")))}).on("touchend touchcancel pointerup pointercancel MSPointerUp MSPointerCancel",function(t){return!f(t.originalEvent)||s.quitOnImgClick?!0:void(Math.abs(v)>50?0>v?S():T():r?a(p,"0px",s.animationSpeed/1e3):p.animate({left:h+"px"},s.animationSpeed/2))})},s.animationSpeed+100)},S=function(){s.previousTarget()!==!1&&y("left")},T=function(){s.nextTarget()!==!1&&y("right")},b=function(){return p.length?(p.remove(),void(p=t())):!1},I=function(){return p.length?void p.animate({opacity:0},s.animationSpeed,function(){b(),m=!1,s.onEnd!==!1&&s.onEnd()}):!1};return t(n).on("resize",E),s.quitOnDocClick&&t(e).on(u?"touchend":"click",function(n){p.length&&!t(n.target).is(p)&&(n.preventDefault(),I())}),s.enableKeyboard&&t(e).on("keyup",function(t){return p.length?(t.preventDefault(),27===t.keyCode&&s.quitOnEscKey===!0&&I(),void(37===t.keyCode?S():39===t.keyCode&&T())):!0}),this.startImageLightbox=function(n){return x(this)?(n!==i&&n.preventDefault(),m?!1:(m=!1,s.onStart!==!1&&s.onStart(),l=t(this),void y())):!0},t(e).off("click",this.selector),t(e).on("click",this.selector,this.startImageLightbox),this.each(function(){return x(this)?void(d=d.add(t(this))):!0}),this.switchImageLightbox=function(t){var n=d.eq(t);if(n.length){var e=d.index(l);l=n,y(e>t?"left":"right")}return this},this.loadPreviousImage=function(){S()},this.loadNextImage=function(){T()},this.quitImageLightbox=function(){return I(),this},this.addImageLightbox=function(n){return n.each(function(){return x(this)?void(d=d.add(t(this))):!0}),n.click(this.startImageLightbox),this},this}}(jQuery,window,document);