﻿/*
	By André Rinas, www.andrerinas.de
	Documentation, www.simplelightbox.de
	Available for use under the MIT License
	1.16.1
*/

    if ($('div.gallery').length) {
        !function (t, e, a, n) { "use strict"; t.fn.simpleLightbox = function (n) { n = t.extend({ sourceAttr: "href", overlay: !0, spinner: !0, nav: !0, navText: ["&lsaquo;", "&rsaquo;"], captions: !0, captionDelay: 0, captionSelector: "img", captionType: "attr", captionsData: "title", captionPosition: "bottom", captionClass: "", close: !0, closeText: "×", swipeClose: !0, showCounter: !0, fileExt: "png|jpg|jpeg|gif", animationSlide: !0, animationSpeed: 250, preloading: !0, enableKeyboard: !0, loop: !0, rel: !1, docClose: !0, swipeTolerance: 50, className: "simple-lightbox", widthRatio: .8, heightRatio: .9, scaleImageToRatio: !1, disableRightClick: !1, disableScroll: !0, alertError: !0, alertErrorMessage: "Image not found, next image will be loaded", additionalHtml: !1, history: !0, throttleInterval: 0, doubleTapZoom: 2, maxZoom: 10 }, n); var i, o, s = "ontouchstart" in e, l = (e.navigator.pointerEnabled || e.navigator.msPointerEnabled, 0), r = 0, c = t(), d = function () { var t = a.body || a.documentElement; return "" === (t = t.style).WebkitTransition ? "-webkit-" : "" === t.MozTransition ? "-moz-" : "" === t.OTransition ? "-o-" : "" === t.transition && "" }, p = !1, h = [], u = n.rel && !1 !== n.rel ? (o = n.rel, t(this).filter(function () { return t(this).attr("rel") === o })) : this, f = 0, g = !1 !== (d = d()), m = "pushState" in history, v = !1, x = e.location, b = function () { return x.hash.substring(1) }, y = b(), T = function () { b(); var t = "pid=" + (D + 1), e = x.href.split("#")[0] + "#" + t; m ? history[v ? "replaceState" : "pushState"]("", a.title, e) : v ? x.replace(e) : x.hash = t, v = !0 }, w = function (t, e) { var a; return function () { var n = arguments; a || (t.apply(this, n), a = !0, setTimeout(function () { return a = !1 }, e)) } }, C = "simplelb", E = t("<div>").addClass("sl-overlay"), S = t("<button>").addClass("sl-close").html(n.closeText), I = t("<div>").addClass("sl-spinner").html("<div></div>"), M = t("<div>").addClass("sl-navigation").html('<button class="sl-prev">' + n.navText[0] + '</button><button class="sl-next">' + n.navText[1] + "</button>"), k = t("<div>").addClass("sl-counter").html('<span class="sl-current"></span>/<span class="sl-total"></span>'), q = !1, D = 0, R = 0, X = t("<div>").addClass("sl-caption " + n.captionClass + " pos-" + n.captionPosition), A = t("<div>").addClass("sl-image"), O = t("<div>").addClass("sl-wrapper").addClass(n.className), Y = function (e) { e.trigger(t.Event("show.simplelightbox")), n.disableScroll && (f = $("hide")), O.appendTo("body"), A.appendTo(O), n.overlay && E.appendTo(t("body")), q = !0, D = u.index(e), c = t("<img/>").hide().attr("src", e.attr(n.sourceAttr)).attr("data-scale", 1).attr("data-translate-x", 0).attr("data-translate-y", 0), -1 == h.indexOf(e.attr(n.sourceAttr)) && h.push(e.attr(n.sourceAttr)), A.html("").attr("style", ""), c.appendTo(A), F(), E.fadeIn("fast"), t(".sl-close").fadeIn("fast"), I.show(), M.fadeIn("fast"), t(".sl-wrapper .sl-counter .sl-current").text(D + 1), k.fadeIn("fast"), W(), n.preloading && N(), setTimeout(function () { e.trigger(t.Event("shown.simplelightbox")) }, n.animationSpeed) }, W = function (a) { if (c.length) { var o = new Image, s = e.innerWidth * n.widthRatio, l = e.innerHeight * n.heightRatio; o.src = c.attr("src"), c.data("scale", 1), c.data("translate-x", 0), c.data("translate-y", 0), H(0, 0, 1), t(o).on("error", function (e) { u.eq(D).trigger(t.Event("error.simplelightbox")), q = !1, p = !0, I.hide(); var i = 1 == a || -1 == a; R === D && i ? K() : (n.alertError && alert(n.alertErrorMessage), j(i ? a : 1)) }), o.onload = function () { void 0 !== a && u.eq(D).trigger(t.Event("changed.simplelightbox")).trigger(t.Event((1 === a ? "nextDone" : "prevDone") + ".simplelightbox")), n.history && (v ? i = setTimeout(T, 800) : T()), -1 == h.indexOf(c.attr("src")) && h.push(c.attr("src")); var r = o.width, d = o.height; if (n.scaleImageToRatio || r > s || d > l) { var m = r / d > s / l ? r / s : d / l; r /= m, d /= m } t(".sl-image").css({ top: (e.innerHeight - d) / 2 + "px", left: (e.innerWidth - r - f) / 2 + "px", width: r + "px", height: d + "px" }), I.hide(), c.fadeIn("fast"), p = !0; var x, b = "self" == n.captionSelector ? u.eq(D) : u.eq(D).find(n.captionSelector); if (x = "data" == n.captionType ? b.data(n.captionsData) : "text" == n.captionType ? b.html() : b.prop(n.captionsData), n.loop || (0 === D && t(".sl-prev").hide(), D >= u.length - 1 && t(".sl-next").hide(), D > 0 && t(".sl-prev").show(), D < u.length - 1 && t(".sl-next").show()), 1 == u.length && t(".sl-prev, .sl-next").hide(), 1 == a || -1 == a) { var y = { opacity: 1 }; n.animationSlide && (g ? (z(0, 100 * a + "px"), setTimeout(function () { z(n.animationSpeed / 1e3, "0px") }, 50)) : y.left = parseInt(t(".sl-image").css("left")) + 100 * a + "px"), t(".sl-image").animate(y, n.animationSpeed, function () { q = !1, P(x, r) }) } else q = !1, P(x, r); n.additionalHtml && 0 === t(".sl-additional-html").length && t("<div>").html(n.additionalHtml).addClass("sl-additional-html").appendTo(t(".sl-image")) } } }, P = function (e, a) { "" !== e && void 0 !== e && n.captions && X.html(e).css({ width: a + "px" }).hide().appendTo(t(".sl-image")).delay(n.captionDelay).fadeIn("fast") }, z = function (e, a) { var n = {}; n[d + "transform"] = "translateX(" + a + ")", n[d + "transition"] = d + "transform " + e + "s linear", t(".sl-image").css(n) }, H = function (t, e, a) { var n = {}; n[d + "transform"] = "translate(" + t + "," + e + ") scale(" + a + ")", c.css(n) }, L = function (t, e, a) { return t < e ? e : t > a ? a : t }, Z = function (t, e, a) { c.data("scale", t), c.data("translate-x", e), c.data("translate-y", a) }, F = function () { t(e).on("resize." + C, W), t(a).on("click." + C + " touchstart." + C, ".sl-close", function (t) { t.preventDefault(), p && K() }), n.history && setTimeout(function () { t(e).on("hashchange." + C, function () { p && b() === y && K() }) }, 40), M.on("click." + C, "button", w(function (e) { e.preventDefault(), l = 0, j(t(this).hasClass("sl-next") ? 1 : -1) }, n.throttleInterval)); var i, o, d, h, f, m, v, x, T, E, S, I, k, q, R, X, O, Y, P, F, N, $, B, Q, U, G, J, V = 0, _ = 0, tt = 0, et = 0, at = !1, nt = !1, it = 0, ot = !1, st = L(1, 1, n.maxZoom), lt = !1; A.on("touchstart." + C + " mousedown." + C, function (e) { if ("mousedown" == (e = e.originalEvent).type); else { if (J = e.touches.length, T = e.touches[0].clientX, E = e.touches[0].clientY, i = A.height(), o = A.width(), f = c.height(), m = c.width(), d = A.position().left, h = A.position().top, 1 === J) { if (lt) return c.addClass("sl-transition"), at ? (Z(0, 0, st = 1), H("0px", "0px", st), at = !1) : (st = n.doubleTapZoom, Z(0, 0, st), H("0px", "0px", st), t(".sl-caption").fadeOut(200), at = !0), setTimeout(function () { c.removeClass("sl-transition") }, 200), !1; lt = !0, setTimeout(function () { lt = !1 }, 300), v = parseFloat(c.data("translate-x")), x = parseFloat(c.data("translate-y")) } else 2 === J && (S = e.touches[1].clientX, I = e.touches[1].clientY, v = parseFloat(c.data("translate-x")), x = parseFloat(c.data("translate-y")), N = (T + S) / 2, $ = (E + I) / 2, k = Math.sqrt((T - S) * (T - S) + (E - I) * (E - I))); ot = !0 } return !!nt || (g && (it = parseInt(A.css("left"))), nt = !0, l = 0, r = 0, V = e.pageX || e.touches[0].pageX, tt = e.pageY || e.touches[0].pageY, !1) }).on("touchmove." + C + " mousemove." + C + " MSPointerMove", function (e) { if (!nt) return !0; if (e.preventDefault(), "touchmove" == (e = e.originalEvent).type) { if (!1 === ot) return !1; q = e.touches[0].clientX, R = e.touches[0].clientY, J = e.touches.length, 0, J > 1 ? (X = e.touches[1].clientX, O = e.touches[1].clientY, G = Math.sqrt((q - X) * (q - X) + (R - O) * (R - O)), null === k && (k = G), Math.abs(k - G) >= 1 && (F = L(G / k * st, 1, n.maxZoom), B = (m * F - o) / 2, Q = (f * F - i) / 2, U = F - st, Y = m * F <= o ? 0 : L(v - (N - d - o / 2 - v) / (F - U) * U, -1 * B, B), P = f * F <= i ? 0 : L(x - ($ - h - i / 2 - x) / (F - U) * U, -1 * Q, Q), H(Y + "px", P + "px", F), F > 1 && (at = !0, t(".sl-caption").fadeOut(200)), k = G, st = F, v = Y, x = P)) : (B = (m * (F = st) - o) / 2, Q = (f * F - i) / 2, Y = m * F <= o ? 0 : L(q - (T - v), -1 * B, B), P = f * F <= i ? 0 : L(R - (E - x), -1 * Q, Q), Math.abs(Y) === Math.abs(B) && (v = Y, T = q), Math.abs(P) === Math.abs(Q) && (x = P, E = R), Z(st, Y, P), H(Y + "px", P + "px", F)) } at || (_ = e.pageX || e.touches[0].pageX, et = e.pageY || e.touches[0].pageY, l = V - _, r = tt - et, n.animationSlide && (g ? z(0, -l + "px") : A.css("left", it - l + "px"))) }).on("touchend." + C + " mouseup." + C + " touchcancel." + C + " mouseleave." + C + " pointerup pointercancel MSPointerUp MSPointerCancel", function (e) { if (e = e.originalEvent, s && "touchend" == e.type && (0 === (J = e.touches.length) ? (Z(st, Y, P), 1 == st && (at = !1, t(".sl-caption").fadeIn(200)), k = null, ot = !1) : 1 === J ? (T = e.touches[0].clientX, E = e.touches[0].clientY) : J > 1 && (k = null)), nt) { nt = !1; var a = !0; n.loop || (0 === D && l < 0 && (a = !1), D >= u.length - 1 && l > 0 && (a = !1)), Math.abs(l) > n.swipeTolerance && a ? j(l > 0 ? 1 : -1) : n.animationSlide && (g ? z(n.animationSpeed / 1e3, "0px") : A.animate({ left: it + "px" }, n.animationSpeed / 2)), n.swipeClose && Math.abs(r) > 50 && Math.abs(l) < n.swipeTolerance && K() } }) }, N = function () { var e = D + 1 < 0 ? u.length - 1 : D + 1 >= u.length - 1 ? 0 : D + 1, a = D - 1 < 0 ? u.length - 1 : D - 1 >= u.length - 1 ? 0 : D - 1; t("<img />").attr("src", u.eq(e).attr(n.sourceAttr)).on("load", function () { -1 == h.indexOf(t(this).attr("src")) && h.push(t(this).attr("src")), u.eq(D).trigger(t.Event("nextImageLoaded.simplelightbox")) }), t("<img />").attr("src", u.eq(a).attr(n.sourceAttr)).on("load", function () { -1 == h.indexOf(t(this).attr("src")) && h.push(t(this).attr("src")), u.eq(D).trigger(t.Event("prevImageLoaded.simplelightbox")) }) }, j = function (e) { u.eq(D).trigger(t.Event("change.simplelightbox")).trigger(t.Event((1 === e ? "next" : "prev") + ".simplelightbox")); var a = D + e; if (!(q || (a < 0 || a >= u.length) && !1 === n.loop)) { D = a < 0 ? u.length - 1 : a > u.length - 1 ? 0 : a, t(".sl-wrapper .sl-counter .sl-current").text(D + 1); var i = { opacity: 0 }; n.animationSlide && (g ? z(n.animationSpeed / 1e3, -100 * e - l + "px") : i.left = parseInt(t(".sl-image").css("left")) + -100 * e + "px"), t(".sl-image").animate(i, n.animationSpeed, function () { setTimeout(function () { var a = u.eq(D); c.attr("src", a.attr(n.sourceAttr)), -1 == h.indexOf(a.attr(n.sourceAttr)) && I.show(), t(".sl-caption").remove(), W(e), n.preloading && N() }, 100) }) } }, K = function () { if (!q) { var o = u.eq(D), s = !1; o.trigger(t.Event("close.simplelightbox")), n.history && (m ? history.pushState("", a.title, x.pathname + x.search) : x.hash = "", clearTimeout(i)), t(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast", function () { n.disableScroll && $("show"), t(".sl-wrapper, .sl-overlay").remove(), M.off("click", "button"), t(a).off("click." + C, ".sl-close"), t(e).off("resize." + C), t(e).off("hashchange." + C), s || o.trigger(t.Event("closed.simplelightbox")), s = !0 }), c = t(), p = !1, q = !1 } }, $ = function (n) { var i = 0; if ("hide" == n) { var o = e.innerWidth; if (!o) { var s = a.documentElement.getBoundingClientRect(); o = s.right - Math.abs(s.left) } if (a.body.clientWidth < o) { var l = a.createElement("div"), r = parseInt(t("body").css("padding-right"), 10); l.className = "sl-scrollbar-measure", t("body").append(l), i = l.offsetWidth - l.clientWidth, t(a.body)[0].removeChild(l), t("body").data("padding", r), i > 0 && t("body").addClass("hidden-scroll").css({ "padding-right": r + i }) } } else t("body").removeClass("hidden-scroll").css({ "padding-right": t("body").data("padding") }); return i }; return n.close && S.appendTo(O), n.showCounter && u.length > 1 && (k.appendTo(O), k.find(".sl-total").text(u.length)), n.nav && M.appendTo(O), n.spinner && I.appendTo(O), u.on("click." + C, function (e) { if (function (e) { if (!n.fileExt) return !0; var a = t(e).attr(n.sourceAttr).match(/\.([0-9a-z]+)(?=[?#])|(\.)(?:[\w]+)$/gim); return a && "a" == t(e).prop("tagName").toLowerCase() && new RegExp(".(" + n.fileExt + ")$", "i").test(a) }(this)) { if (e.preventDefault(), q) return !1; var a = t(this); R = u.index(a), Y(a) } }), t(a).on("click." + C + " touchstart." + C, function (e) { p && n.docClose && 0 === t(e.target).closest(".sl-image").length && 0 === t(e.target).closest(".sl-navigation").length && K() }), n.disableRightClick && t(a).on("contextmenu", ".sl-image img", function (t) { return !1 }), n.enableKeyboard && t(a).on("keyup." + C, w(function (t) { l = 0; var e = t.keyCode; q && 27 == e && (c.attr("src", ""), q = !1, K()), p && (t.preventDefault(), 27 == e && K(), 37 != e && 39 != t.keyCode || j(39 == t.keyCode ? 1 : -1)) }, n.throttleInterval)), this.open = function (e) { e = e || t(this[0]), R = u.index(e), Y(e) }, this.next = function () { j(1) }, this.prev = function () { j(-1) }, this.close = function () { K() }, this.destroy = function () { t(a).off("click." + C).off("keyup." + C), K(), t(".sl-overlay, .sl-wrapper").remove(), this.off("click") }, this.refresh = function () { this.destroy(), t(this).simpleLightbox(n) }, this } }(jQuery, window, document);
    }