(function (a) { var b, c = this, d = c.document, e = a(d), f = a(c), g = 1.25, h = true, i = 3e4, j = false, k = navigator.userAgent.toLowerCase(), l = c.location.hash.replace(/#\//, ""), m = function () { var a = 3, c = d.createElement("div"), e = c.getElementsByTagName("i"); do { c.innerHTML = "<!--[if gt IE " + ++a + "]><i></i><![endif]-->" } while (e[0]); return a > 4 ? a : b } (), n = function () { return { html: d.documentElement, body: d.body, head: d.getElementsByTagName("head")[0], title: d.title} }, o = "data ready thumbnail loadstart loadfinish image play pause progress " + "fullscreen_enter fullscreen_exit idle_enter idle_exit rescale " + "lightbox_open lightbox_close lightbox_image", p = function () { var b = []; a.each(o.split(" "), function (a, c) { b.push(c); if (/_/.test(c)) { b.push(c.replace(/_/g, "")) } }); return b } (), q = function (b) { var c; if (typeof b !== "object") { return b } a.each(b, function (d, e) { if (/^[a-z]+_/.test(d)) { c = ""; a.each(d.split("_"), function (a, b) { c += a > 0 ? b.substr(0, 1).toUpperCase() + b.substr(1) : b }); b[c] = e; delete b[d] } }); return b }, r = function (b) { if (a.inArray(b, p) > -1) { return Galleria[b.toUpperCase()] } return b }, s = { trunk: {}, add: function (a, b, d, e) { e = e || false; this.clear(a); if (e) { var f = b; b = function () { f(); s.add(a, b, d) } } this.trunk[a] = c.setTimeout(b, d) }, clear: function (a) { var b = function (a) { c.clearTimeout(this.trunk[a]); delete this.trunk[a] }, d; if (!!a && a in this.trunk) { b.call(s, a) } else if (typeof a === "undefined") { for (d in this.trunk) { if (this.trunk.hasOwnProperty(d)) { b.call(s, d) } } } } }, t = [], u = [], v = false, w = false, x = [], y = function (b) { Galleria.theme = b; a.each(x, function (a, b) { b._init.call(b) }) }, z = function () { return { array: function (a) { return Array.prototype.slice.call(a, 0) }, create: function (a, b) { b = b || "div"; var c = d.createElement(b); c.className = a; return c }, getScriptPath: function (b) { b = b || a("script:last").attr("src"); var c = b.split("/"); if (c.length == 1) { return "" } c.pop(); return c.join("/") + "/" }, animate: function () { var b = function (a) { var b = "transition WebkitTransition MozTransition OTransition".split(" "), d; if (c.opera) { return false } for (d = 0; b[d]; d++) { if (typeof a[b[d]] !== "undefined") { return b[d] } } return false } ((d.body || d.documentElement).style); var e = { MozTransition: "transitionend", OTransition: "oTransitionEnd", WebkitTransition: "webkitTransitionEnd", transition: "transitionend"}[b]; var f = { _default: [.25, .1, .25, 1], galleria: [.645, .045, .355, 1], galleriaIn: [.55, .085, .68, .53], galleriaOut: [.25, .46, .45, .94], ease: [.25, 0, .25, 1], linear: [.25, .25, .75, .75], "ease-in": [.42, 0, 1, 1], "ease-out": [0, 0, .58, 1], "ease-in-out": [.42, 0, .58, 1] }; var g = function (b, c, d) { var e = {}; d = d || "transition"; a.each("webkit moz ms o".split(" "), function () { e["-" + this + "-" + d] = c }); b.css(e) }; var h = function (a) { g(a, "none", "transition"); if (Galleria.WEBKIT && Galleria.TOUCH) { g(a, "translate3d(0,0,0)", "transform"); if (a.data("revert")) { a.css(a.data("revert")); a.data("revert", null) } } }; var i, j, k, l, m, n, o; return function (d, p, q) { q = a.extend({ duration: 400, complete: function () { }, stop: false }, q); d = a(d); if (!q.duration) { d.css(p); q.complete.call(d[0]); return } if (!b) { d.animate(p, q); return } if (q.stop) { d.unbind(e); h(d) } i = false; a.each(p, function (a, b) { o = d.css(a); if (z.parseValue(o) != z.parseValue(b)) { i = true } d.css(a, o) }); if (!i) { c.setTimeout(function () { q.complete.call(d[0]) }, q.duration); return } j = []; k = q.easing in f ? f[q.easing] : f._default; l = " " + q.duration + "ms" + " cubic-bezier(" + k.join(",") + ")"; c.setTimeout(function () { d.one(e, function (a) { return function () { h(a); q.complete.call(a[0]) } } (d)); if (Galleria.WEBKIT && Galleria.TOUCH) { m = {}; n = [0, 0, 0]; a.each(["left", "top"], function (a, b) { if (b in p) { n[a] = z.parseValue(p[b]) - z.parseValue(d.css(b)) + "px"; m[b] = p[b]; delete p[b] } }); if (n[0] || n[1]) { d.data("revert", m); j.push("-webkit-transform" + l); g(d, "translate3d(" + n.join(",") + ")", "transform") } } a.each(p, function (a, b) { j.push(a + l) }); g(d, j.join(",")); d.css(p) }, 1) } } (), removeAlpha: function (a) { if (m < 9 && a) { var b = a.style, c = a.currentStyle, d = c && c.filter || b.filter || ""; if (/alpha/.test(d)) { b.filter = d.replace(/alpha\([^)]*\)/i, "") } } }, forceStyles: function (b, c) { b = a(b); if (b.attr("style")) { b.data("styles", b.attr("style")).removeAttr("style") } b.css(c) }, revertStyles: function () { a.each(z.array(arguments), function (b, c) { c = a(c); c.removeAttr("style"); c.attr("style", ""); if (c.data("styles")) { c.attr("style", c.data("styles")).data("styles", null) } }) }, moveOut: function (a) { z.forceStyles(a, { position: "absolute", left: -1e4 }) }, moveIn: function () { z.revertStyles.apply(z, z.array(arguments)) }, elem: function (b) { if (b instanceof a) { return { $: b, dom: b[0]} } else { return { $: a(b), dom: b} } }, hide: function (a, b, c) { c = c || function () { }; var d = z.elem(a), e = d.$; a = d.dom; if (!e.data("opacity")) { e.data("opacity", e.css("opacity")) } var f = { opacity: 0 }; if (b) { var g = m < 9 && a ? function () { z.removeAlpha(a); a.style.visibility = "hidden"; c.call(a) } : c; z.animate(a, f, { duration: b, complete: g, stop: true }) } else { if (m < 9 && a) { z.removeAlpha(a); a.style.visibility = "hidden" } else { e.css(f) } } }, show: function (a, b, c) { c = c || function () { }; var d = z.elem(a), e = d.$; a = d.dom; var f = parseFloat(e.data("opacity")) || 1, g = { opacity: f }; if (b) { if (m < 9) { e.css("opacity", 0); a.style.visibility = "visible" } var h = m < 9 && a ? function () { if (g.opacity == 1) { z.removeAlpha(a) } c.call(a) } : c; z.animate(a, g, { duration: b, complete: h, stop: true }) } else { if (m < 9 && g.opacity == 1 && a) { z.removeAlpha(a); a.style.visibility = "visible" } else { e.css(g) } } }, optimizeTouch: function () { var b, c, d, e, f = {}, g = function (b) { b.preventDefault(); f = a.extend({}, b, true) }, h = function () { this.evt = f }, i = function () { this.handler.call(b, this.evt) }; return function (f) { a(f).bind("touchend", function (f) { b = f.target; e = true; while (b.parentNode && b != f.currentTarget && e) { c = a(b).data("events"); d = a(b).data("fakes"); if (c && "click" in c) { e = false; f.preventDefault(); a(b).click(g).click(); c.click.pop(); a.each(c.click, h); a(b).data("fakes", c.click); delete c.click } else if (d) { e = false; f.preventDefault(); a.each(d, i) } b = b.parentNode } }) } } (), addTimer: function () { s.add.apply(s, z.array(arguments)); return this }, clearTimer: function () { s.clear.apply(s, z.array(arguments)); return this }, wait: function (b) { b = a.extend({ until: function () { return false }, success: function () { }, error: function () { Galleria.raise("Could not complete wait function.") }, timeout: 3e3 }, b); var d = z.timestamp(), e, f, g = function () { f = z.timestamp(); e = f - d; if (b.until(e)) { b.success(); return false } if (f >= d + b.timeout) { b.error(); return false } c.setTimeout(g, 10) }; c.setTimeout(g, 10) }, toggleQuality: function (a, b) { if (m !== 7 && m !== 8 || !a) { return } if (typeof b === "undefined") { b = a.style.msInterpolationMode === "nearest-neighbor" } a.style.msInterpolationMode = b ? "bicubic" : "nearest-neighbor" }, insertStyleTag: function (a) { var b = d.createElement("style"); n().head.appendChild(b); if (b.styleSheet) { b.styleSheet.cssText = a } else { var c = d.createTextNode(a); b.appendChild(c) } }, loadScript: function (b, c) { var d = false, e = a("<scr" + "ipt>").attr({ src: b, async: true }).get(0); e.onload = e.onreadystatechange = function () { if (!d && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) { d = true; e.onload = e.onreadystatechange = null; if (typeof c === "function") { c.call(this, this) } } }; n().head.appendChild(e) }, parseValue: function (a) { if (typeof a === "number") { return a } else if (typeof a === "string") { var b = a.match(/\-?\d|\./g); return b && b.constructor === Array ? b.join("") * 1 : 0 } else { return 0 } }, timestamp: function () { return (new Date).getTime() }, loadCSS: function (e, f, g) { var i, j = false, k; a("link[rel=stylesheet]").each(function () { if ((new RegExp(e)).test(this.href)) { i = this; return false } }); if (typeof f === "function") { g = f; f = b } g = g || function () { }; if (i) { g.call(i, i); return i } k = d.styleSheets.length; if (h) { e += "?" + z.timestamp() } if (a("#" + f).length) { a("#" + f).attr("href", e); k--; j = true } else { i = a("<link>").attr({ rel: "stylesheet", href: e, id: f }).get(0); c.setTimeout(function () { var b = a('link[rel="stylesheet"], style'); if (b.length) { b.get(0).parentNode.insertBefore(i, b[0]) } else { n().head.appendChild(i) } if (m) { if (k >= 31) { Galleria.raise("You have reached the browser stylesheet limit (31)", true); return } i.onreadystatechange = function (a) { if (!j && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) { j = true } } } else { if (!(new RegExp("file://", "i")).test(e)) { a.ajax({ url: e, success: function () { j = true }, error: function (a) { if (a.isRejected() && Galleria.WEBKIT) { j = true } } }) } else { j = true } } }, 10) } if (typeof g === "function") { z.wait({ until: function () { return j && d.styleSheets.length > k }, success: function () { c.setTimeout(function () { g.call(i, i) }, 100) }, error: function () { Galleria.raise("Theme CSS could not load", true) }, timeout: 1e4 }) } return i } } } (), A = function () { var b = function (b, c, d, e) { var f = this.getOptions("easing"), g = this.getStageWidth(), h = { left: g * (b.rewind ? -1 : 1) }, i = { left: 0 }; if (d) { h.opacity = 0; i.opacity = 1 } a(b.next).css(h); z.animate(b.next, i, { duration: b.speed, complete: function (a) { return function () { c(); a.css({ left: 0 }) } } (a(b.next).add(b.prev)), queue: false, easing: f }); if (e) { b.rewind = !b.rewind } if (b.prev) { h = { left: 0 }; i = { left: g * (b.rewind ? 1 : -1) }; if (d) { h.opacity = 1; i.opacity = 0 } a(b.prev).css(h); z.animate(b.prev, i, { duration: b.speed, queue: false, easing: f, complete: function () { a(this).css("opacity", 0) } }) } }; return { fade: function (b, c) { a(b.next).css("opacity", 0).show(); z.animate(b.next, { opacity: 1 }, { duration: b.speed, complete: c }); if (b.prev) { a(b.prev).css("opacity", 1).show(); z.animate(b.prev, { opacity: 0 }, { duration: b.speed }) } }, flash: function (b, c) { a(b.next).css("opacity", 0); if (b.prev) { z.animate(b.prev, { opacity: 0 }, { duration: b.speed / 2, complete: function () { z.animate(b.next, { opacity: 1 }, { duration: b.speed, complete: c }) } }) } else { z.animate(b.next, { opacity: 1 }, { duration: b.speed, complete: c }) } }, pulse: function (b, c) { if (b.prev) { a(b.prev).hide() } a(b.next).css("opacity", 0).show(); z.animate(b.next, { opacity: 1 }, { duration: b.speed, complete: c }) }, slide: function (a, c) { b.apply(this, z.array(arguments)) }, fadeslide: function (a, c) { b.apply(this, z.array(arguments).concat([true])) }, doorslide: function (a, c) { b.apply(this, z.array(arguments).concat([false, true])) } } } (); Galleria = function () { var d = this; this._theme = b; this._options = {}; this._playing = false; this._playtime = 5e3; this._active = null; this._queue = { length: 0 }; this._data = []; this._dom = {}; this._thumbnails = []; this._layers = []; this._initialized = false; this._firstrun = false; this._stageWidth = 0; this._stageHeight = 0; this._target = b; this._id = Math.random(); var g = "container stage images image-nav image-nav-left image-nav-right " + "info info-text info-title info-description info-copyright " + "thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right " + "loader counter tooltip", h = "current total"; a.each(g.split(" "), function (a, b) { d._dom[b] = z.create("galleria-" + b) }); a.each(h.split(" "), function (a, b) { d._dom[b] = z.create("galleria-" + b, "span") }); var i = this._keyboard = { keys: { UP: 38, DOWN: 40, LEFT: 37, RIGHT: 39, RETURN: 13, ESCAPE: 27, BACKSPACE: 8, SPACE: 32 }, map: {}, bound: false, press: function (a) { var b = a.keyCode || a.which; if (b in i.map && typeof i.map[b] === "function") { i.map[b].call(d, a) } }, attach: function (a) { var b, c; for (b in a) { if (a.hasOwnProperty(b)) { c = b.toUpperCase(); if (c in i.keys) { i.map[i.keys[c]] = a[b] } else { i.map[c] = a[b] } } } if (!i.bound) { i.bound = true; e.bind("keydown", i.press) } }, detach: function () { i.bound = false; i.map = {}; e.unbind("keydown", i.press) } }; var j = this._controls = { 0: b, 1: b, active: 0, swap: function () { j.active = j.active ? 0 : 1 }, getActive: function () { return j[j.active] }, getNext: function () { return j[1 - j.active] } }; var k = this._carousel = { next: d.$("thumb-nav-right"), prev: d.$("thumb-nav-left"), width: 0, current: 0, max: 0, hooks: [], update: function () { var b = 0, c = 0, e = [0]; a.each(d._thumbnails, function (d, f) { if (f.ready) { b += f.outerWidth || a(f.container).outerWidth(true); e[d + 1] = b; c = Math.max(c, f.outerHeight || a(f.container).outerHeight(true)) } }); d.$("thumbnails").css({ width: b, height: c }); k.max = b; k.hooks = e; k.width = d.$("thumbnails-list").width(); k.setClasses(); d.$("thumbnails-container").toggleClass("galleria-carousel", b > k.width); k.width = d.$("thumbnails-list").width() }, bindControls: function () { var a; k.next.bind("click", function (b) { b.preventDefault(); if (d._options.carouselSteps === "auto") { for (a = k.current; a < k.hooks.length; a++) { if (k.hooks[a] - k.hooks[k.current] > k.width) { k.set(a - 2); break } } } else { k.set(k.current + d._options.carouselSteps) } }); k.prev.bind("click", function (b) { b.preventDefault(); if (d._options.carouselSteps === "auto") { for (a = k.current; a >= 0; a--) { if (k.hooks[k.current] - k.hooks[a] > k.width) { k.set(a + 2); break } else if (a === 0) { k.set(0); break } } } else { k.set(k.current - d._options.carouselSteps) } }) }, set: function (a) { a = Math.max(a, 0); while (k.hooks[a - 1] + k.width >= k.max && a >= 0) { a-- } k.current = a; k.animate() }, getLast: function (a) { return (a || k.current) - 1 }, follow: function (a) { if (a === 0 || a === k.hooks.length - 2) { k.set(a); return } var b = k.current; while (k.hooks[b] - k.hooks[k.current] < k.width && b <= k.hooks.length) { b++ } if (a - 1 < k.current) { k.set(a - 1) } else if (a + 2 > b) { k.set(a - b + k.current + 2) } }, setClasses: function () { k.prev.toggleClass("disabled", !k.current); k.next.toggleClass("disabled", k.hooks[k.current] + k.width >= k.max) }, animate: function (a) { k.setClasses(); var b = k.hooks[k.current] * -1; if (isNaN(b)) { return } z.animate(d.get("thumbnails"), { left: b }, { duration: d._options.carouselSpeed, easing: d._options.easing, queue: false }) } }; var l = this._tooltip = { initialized: false, open: false, init: function () { l.initialized = true; var a = ".galleria-tooltip{padding:3px 8px;max-width:50%;background:#ffe;color:#000;z-index:3;position:absolute;font-size:11px;line-height:1.3" + "opacity:0;box-shadow:0 0 2px rgba(0,0,0,.4);-moz-box-shadow:0 0 2px rgba(0,0,0,.4);-webkit-box-shadow:0 0 2px rgba(0,0,0,.4);}"; z.insertStyleTag(a); d.$("tooltip").css("opacity", .8); z.hide(d.get("tooltip")) }, move: function (a) { var b = d.getMousePosition(a).x, c = d.getMousePosition(a).y, e = d.$("tooltip"), f = b, g = c, h = e.outerHeight(true) + 1, i = e.outerWidth(true), j = h + 15; var k = d.$("container").width() - i - 2, l = d.$("container").height() - h - 2; if (!isNaN(f) && !isNaN(g)) { f += 10; g -= 30; f = Math.max(0, Math.min(k, f)); g = Math.max(0, Math.min(l, g)); if (c < j) { g = j } e.css({ left: f, top: g }) } }, bind: function (b, c) { if (Galleria.TOUCH) { return } if (!l.initialized) { l.init() } var e = function (b, c) { l.define(b, c); a(b).hover(function () { z.clearTimer("switch_tooltip"); d.$("container").unbind("mousemove", l.move).bind("mousemove", l.move).trigger("mousemove"); l.show(b); Galleria.utils.addTimer("tooltip", function () { d.$("tooltip").stop().show().animate({ opacity: 1 }); l.open = true }, l.open ? 0 : 500) }, function () { d.$("container").unbind("mousemove", l.move); z.clearTimer("tooltip"); d.$("tooltip").stop().animate({ opacity: 0 }, 200, function () { d.$("tooltip").hide(); z.addTimer("switch_tooltip", function () { l.open = false }, 1e3) }) }) }; if (typeof c === "string") { e(b in d._dom ? d.get(b) : b, c) } else { a.each(b, function (a, b) { e(d.get(a), b) }) } }, show: function (b) { b = a(b in d._dom ? d.get(b) : b); var e = b.data("tt"), f = function (a) { c.setTimeout(function (a) { return function () { l.move(a) } } (a), 10); b.unbind("mouseup", f) }; e = typeof e === "function" ? e() : e; if (!e) { return } d.$("tooltip").html(e.replace(/\s/, " ")); b.bind("mouseup", f) }, define: function (b, c) { if (typeof c !== "function") { var e = c; c = function () { return e } } b = a(b in d._dom ? d.get(b) : b).data("tt", c); l.show(b) } }; var o = this._fullscreen = { scrolled: 0, crop: d._options.imageCrop, active: false, keymap: d._keyboard.map, enter: function (c) { o.active = true; z.hide(d.getActiveImage()); d.$("container").addClass("fullscreen"); o.scrolled = f.scrollTop(); z.forceStyles(d.get("container"), { position: "fixed", top: 0, left: 0, width: "100%", height: "100%", zIndex: 1e4 }); var e = { height: "100%", overflow: "hidden", margin: 0, padding: 0 }, g = d.getData(); z.forceStyles(n().html, e); z.forceStyles(n().body, e); o.keymap = a.extend({}, d._keyboard.map); d.attachKeyboard({ escape: d.exitFullscreen, right: d.next, left: d.prev }); if (d._options.fullscreenCrop !== b) { d._options.imageCrop = d._options.fullscreenCrop } if (g && g.big && g.image !== g.big) { var h = new Galleria.Picture, i = h.isCached(g.big), j = d.getIndex(), k = d._thumbnails[j]; d.trigger({ type: Galleria.LOADSTART, cached: i, rewind: false, index: j, imageTarget: d.getActiveImage(), thumbTarget: k }); h.load(g.big, function (b) { d._scaleImage(b, { complete: function (b) { d.trigger({ type: Galleria.LOADFINISH, cached: i, index: j, rewind: false, imageTarget: b.image, thumbTarget: k }); var c = d._controls.getActive().image; if (c) { a(c).width(b.image.width).height(b.image.height).attr("style", a(b.image).attr("style")).attr("src", b.image.src) } } }) }) } d.rescale(function () { z.addTimer("fullscreen_enter", function () { z.show(d.getActiveImage()); if (typeof c === "function") { c.call(d) } }, 100); d.trigger(Galleria.FULLSCREEN_ENTER) }); f.resize(function () { o.scale() }) }, scale: function () { d.rescale() }, exit: function (a) { o.active = false; z.hide(d.getActiveImage()); d.$("container").removeClass("fullscreen"); z.revertStyles(d.get("container"), n().html, n().body); c.scrollTo(0, o.scrolled); d.detachKeyboard(); d.attachKeyboard(o.keymap); if (d._options.fullscreenCrop !== b) { d._options.imageCrop = o.crop } d.rescale(function () { z.addTimer("fullscreen_exit", function () { z.show(d.getActiveImage()); if (typeof a === "function") { a.call(d) } }, 50); d.trigger(Galleria.FULLSCREEN_EXIT) }); f.unbind("resize", o.scale) } }; var p = this._idle = { trunk: [], bound: false, add: function (b, c) { if (!b) { return } if (!p.bound) { p.addEvent() } b = a(b); var d = {}, e; for (e in c) { if (c.hasOwnProperty(e)) { d[e] = b.css(e) } } b.data("idle", { from: d, to: c, complete: true, busy: false }); p.addTimer(); p.trunk.push(b) }, remove: function (b) { b = jQuery(b); a.each(p.trunk, function (a, c) { if (c.length && !c.not(b).length) { d._idle.show(b); d._idle.trunk.splice(a, 1) } }); if (!p.trunk.length) { p.removeEvent(); z.clearTimer("idle") } }, addEvent: function () { p.bound = true; d.$("container").bind("mousemove click", p.showAll) }, removeEvent: function () { p.bound = false; d.$("container").unbind("mousemove click", p.showAll) }, addTimer: function () { z.addTimer("idle", function () { d._idle.hide() }, d._options.idleTime) }, hide: function () { if (!d._options.idleMode) { return } d.trigger(Galleria.IDLE_ENTER); a.each(p.trunk, function (a, b) { var c = b.data("idle"); if (!c) { return } b.data("idle").complete = false; z.animate(b, c.to, { duration: d._options.idleSpeed }) }) }, showAll: function () { z.clearTimer("idle"); a.each(d._idle.trunk, function (a, b) { d._idle.show(b) }) }, show: function (b) { var c = b.data("idle"); if (!c.busy && !c.complete) { c.busy = true; d.trigger(Galleria.IDLE_EXIT); z.clearTimer("idle"); z.animate(b, c.from, { duration: d._options.idleSpeed / 2, complete: function () { a(this).data("idle").busy = false; a(this).data("idle").complete = true } }) } p.addTimer() } }; var q = this._lightbox = { width: 0, height: 0, initialized: false, active: null, image: null, elems: {}, keymap: false, init: function () { d.trigger(Galleria.LIGHTBOX_OPEN); if (q.initialized) { return } q.initialized = true; var b = "overlay box content shadow title info close prevholder prev nextholder next counter image", c = {}, e = d._options, f = "", g = "position:absolute;", h = "lightbox-", i = { overlay: "position:fixed;display:none;opacity:" + e.overlayOpacity + ";filter:alpha(opacity=" + e.overlayOpacity * 100 + ");top:0;left:0;width:100%;height:100%;background:" + e.overlayBackground + ";z-index:99990", box: "position:fixed;display:none;width:400px;height:400px;top:50%;left:50%;margin-top:-200px;margin-left:-200px;z-index:99991", shadow: g + "background:#000;width:100%;height:100%;", content: g + "background-color:#fff;top:10px;left:10px;right:10px;bottom:10px;overflow:hidden", info: g + "bottom:10px;left:10px;right:10px;color:#444;font:11px/13px arial,sans-serif;height:13px", close: g + "top:10px;right:10px;height:20px;width:20px;background:#fff;text-align:center;cursor:pointer;color:#444;font:16px/22px arial,sans-serif;z-index:99999", image: g + "top:10px;left:10px;right:10px;bottom:30px;overflow:hidden;display:block;", prevholder: g + "width:50%;top:0;bottom:40px;cursor:pointer;", nextholder: g + "width:50%;top:0;bottom:40px;right:-1px;cursor:pointer;", prev: g + "top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;left:20px;display:none;text-align:center;color:#000;font:bold 16px/36px arial,sans-serif", next: g + "top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;right:20px;left:auto;display:none;font:bold 16px/36px arial,sans-serif;text-align:center;color:#000", title: "float:left", counter: "float:right;margin-left:8px;" }, j = function (b) { return b.hover(function () { a(this).css("color", "#bbb") }, function () { a(this).css("color", "#444") }) }, k = {}; if (m === 8) { i.nextholder += "background:#000;filter:alpha(opacity=0);"; i.prevholder += "background:#000;filter:alpha(opacity=0);" } a.each(i, function (a, b) { f += ".galleria-" + h + a + "{" + b + "}" }); z.insertStyleTag(f); a.each(b.split(" "), function (a, b) { d.addElement("lightbox-" + b); c[b] = q.elems[b] = d.get("lightbox-" + b) }); q.image = new Galleria.Picture; a.each({ box: "shadow content close prevholder nextholder", info: "title counter", content: "info image", prevholder: "prev", nextholder: "next" }, function (b, c) { var d = []; a.each(c.split(" "), function (a, b) { d.push(h + b) }); k[h + b] = d }); d.append(k); a(c.image).append(q.image.container); a(n().body).append(c.overlay, c.box); z.optimizeTouch(c.box); j(a(c.close).bind("click", q.hide).html("&#215;")); a.each(["Prev", "Next"], function (b, d) { var e = a(c[d.toLowerCase()]).html(/v/.test(d) ? "&#8249; " : " &#8250;"), f = a(c[d.toLowerCase() + "holder"]); f.bind("click", function () { q["show" + d]() }); if (m < 8 || Galleria.TOUCH) { e.show(); return } f.hover(function () { e.show() }, function (a) { e.stop().fadeOut(200) }) }); a(c.overlay).bind("click", q.hide); if (Galleria.IPAD) { d._options.lightboxTransitionSpeed = 0 } }, rescale: function (b) { var c = Math.min(f.width() - 40, q.width), e = Math.min(f.height() - 60, q.height), g = Math.min(c / q.width, e / q.height), h = Math.round(q.width * g) + 40, i = Math.round(q.height * g) + 60, j = { width: h, height: i, "margin-top": Math.ceil(i / 2) * -1, "margin-left": Math.ceil(h / 2) * -1 }; if (b) { a(q.elems.box).css(j) } else { a(q.elems.box).animate(j, { duration: d._options.lightboxTransitionSpeed, easing: d._options.easing, complete: function () { var b = q.image, c = d._options.lightboxFadeSpeed; d.trigger({ type: Galleria.LIGHTBOX_IMAGE, imageTarget: b.image }); a(b.container).show(); z.show(b.image, c); z.show(q.elems.info, c) } }) } }, hide: function () { q.image.image = null; f.unbind("resize", q.rescale); a(q.elems.box).hide(); z.hide(q.elems.info); d.detachKeyboard(); d.attachKeyboard(q.keymap); q.keymap = false; z.hide(q.elems.overlay, 200, function () { a(this).hide().css("opacity", d._options.overlayOpacity); d.trigger(Galleria.LIGHTBOX_CLOSE) }) }, showNext: function () { q.show(d.getNext(q.active)) }, showPrev: function () { q.show(d.getPrev(q.active)) }, show: function (b) { q.active = b = typeof b === "number" ? b : d.getIndex(); if (!q.initialized) { q.init() } if (!q.keymap) { q.keymap = a.extend({}, d._keyboard.map); d.attachKeyboard({ escape: q.hide, right: q.showNext, left: q.showPrev }) } f.unbind("resize", q.rescale); var c = d.getData(b), e = d.getDataLength(); z.hide(q.elems.info); q.image.load(c.big || c.image, function (d) { q.width = d.original.width; q.height = d.original.height; a(d.image).css({ width: "100.5%", height: "100.5%", top: 0, zIndex: 99998 }); z.hide(d.image); q.elems.title.innerHTML = c.title || ""; q.elems.counter.innerHTML = b + 1 + " / " + e; f.resize(q.rescale); q.rescale() }); a(q.elems.overlay).show(); a(q.elems.box).show() } }; return this }; Galleria.prototype = { constructor: Galleria, init: function (c, d) { var e = this; d = q(d); this._original = { target: c, options: d, data: null }; this._target = this._dom.target = c.nodeName ? c : a(c).get(0); u.push(this); if (!this._target) { Galleria.raise("Target not found.", true); return } this._options = { autoplay: false, carousel: true, carouselFollow: true, carouselSpeed: 400, carouselSteps: "auto", clicknext: false, dataConfig: function (a) { return {} }, dataSelector: "img", dataSource: this._target, debug: b, dummy: b, easing: "galleria", extend: function (a) { }, fullscreenCrop: b, fullscreenDoubleTap: true, fullscreenTransition: b, height: "auto", idleMode: true, idleTime: 3e3, idleSpeed: 200, imageCrop: false, imageMargin: 0, imagePan: false, imagePanSmoothness: 12, imagePosition: "50%", imageTimeout: b, initialTransition: b, keepSource: false, layerFollow: true, lightbox: false, lightboxFadeSpeed: 200, lightboxTransitionSpeed: 200, linkSourceImages: true, maxScaleRatio: b, minScaleRatio: b, overlayOpacity: .85, overlayBackground: "#0b0b0b", pauseOnInteraction: true, popupLinks: false, preload: 2, queue: true, show: 0, showInfo: true, showCounter: true, showImagenav: true, swipe: true, thumbCrop: true, thumbEventType: "click", thumbFit: true, thumbMargin: 0, thumbQuality: "auto", thumbnails: true, touchTransition: b, transition: "fade", transitionInitial: b, transitionSpeed: 400, useCanvas: false, width: "auto" }; this._options.initialTransition = this._options.initialTransition || this._options.transitionInitial; if (d && d.debug === false) { h = false } if (d && typeof d.imageTimeout === "number") { i = d.imageTimeout } if (d && typeof d.dummy === "string") { j = d.dummy } a(this._target).children().hide(); if (typeof Galleria.theme === "object") { this._init() } else { x.push(this) } return this }, _init: function () { var b = this; if (this._initialized) { Galleria.raise("Init failed: Gallery instance already initialized."); return this } this._initialized = true; if (!Galleria.theme) { Galleria.raise("Init failed: No theme found."); return this } a.extend(true, this._options, Galleria.theme.defaults, this._original.options); (function (a) { if (!("getContext" in a)) { a = null; return } w = w || { elem: a, context: a.getContext("2d"), cache: {}, length: 0} })(d.createElement("canvas")); this.bind(Galleria.DATA, function () { this._original.data = this._data; this.get("total").innerHTML = this.getDataLength(); var d = this.$("container"); var e = { width: 0, height: 0 }; var f = function () { return b.$("stage").height() }; z.wait({ until: function () { a.each(["width", "height"], function (a, c) { if (b._options[c] && typeof b._options[c] === "number") { e[c] = b._options[c] } else { e[c] = Math.max(z.parseValue(d.css(c)), z.parseValue(b.$("target").css(c)), d[c](), b.$("target")[c]()) } d[c](e[c]) }); return f() && e.width && e.height > 10 }, success: function () { if (Galleria.WEBKIT) { c.setTimeout(function () { b._run() }, 1) } else { b._run() } }, error: function () { if (f()) { Galleria.raise("Could not extract sufficient width/height of the gallery container. Traced measures: width:" + e.width + "px, height: " + e.height + "px.", true) } else { Galleria.raise("Could not extract a stage height from the CSS. Traced height: " + f() + "px.", true) } }, timeout: 2e3 }) }); this.append({ "info-text": ["info-title", "info-description", "info-copyright"], info: ["info-text"], "image-nav": ["image-nav-right", "image-nav-left"], stage: ["images", "loader", "counter", "image-nav"], "thumbnails-list": ["thumbnails"], "thumbnails-container": ["thumb-nav-left", "thumbnails-list", "thumb-nav-right"], container: ["stage", "thumbnails-container", "info", "tooltip"] }); z.hide(this.$("counter").append(this.get("current"), " / ", this.get("total"))); this.setCounter("&#8211;"); z.hide(b.get("tooltip")); this.$("container").addClass(Galleria.TOUCH ? "touch" : "notouch"); a.each(new Array(2), function (c) { var d = new Galleria.Picture; a(d.container).css({ position: "absolute", top: 0, left: 0 }).prepend(b._layers[c] = a(z.create("galleria-layer")).css({ position: "absolute", top: 0, left: 0, right: 0, bottom: 0, zIndex: 2 })[0]); b.$("images").append(d.container); b._controls[c] = d }); this.$("images").css({ position: "relative", top: 0, left: 0, width: "100%", height: "100%" }); this.$("thumbnails, thumbnails-list").css({ overflow: "hidden", position: "relative" }); this.$("image-nav-right, image-nav-left").bind("click", function (a) { if (b._options.clicknext) { a.stopPropagation() } if (b._options.pauseOnInteraction) { b.pause() } var c = /right/.test(this.className) ? "next" : "prev"; b[c]() }); a.each(["info", "counter", "image-nav"], function (a, c) { if (b._options["show" + c.substr(0, 1).toUpperCase() + c.substr(1).replace(/-/, "")] === false) { z.moveOut(b.get(c.toLowerCase())) } }); this.load(); if (!this._options.keep_source && !m) { this._target.innerHTML = "" } if (this.get("errors")) { this.appendChild("target", "errors") } this.appendChild("target", "container"); if (this._options.carousel) { var e = 0, f = this._options.show; this.bind(Galleria.THUMBNAIL, function () { this.updateCarousel(); if (++e == this.getDataLength() && typeof f == "number" && f > 0) { this._carousel.follow(f) } }) } if (this._options.swipe) { (function (a) { var c = [0, 0], d = [0, 0], e = 30, f = 100, g = false, h = 0, i, j = { start: "touchstart", move: "touchmove", stop: "touchend" }, k = function (a) { return a.originalEvent.touches ? a.originalEvent.touches[0] : a }, l = function (a) { if (a.originalEvent.touches && a.originalEvent.touches.length > 1) { return } i = k(a); d = [i.pageX, i.pageY]; if (!c[0]) { c = d } if (Math.abs(c[0] - d[0]) > 10) { a.preventDefault() } }, m = function (i) { a.unbind(j.move, l); if (i.originalEvent.touches && i.originalEvent.touches.length || g) { g = !g; return } if (z.timestamp() - h < 1e3 && Math.abs(c[0] - d[0]) > e && Math.abs(c[1] - d[1]) < f) { i.preventDefault(); b[c[0] > d[0] ? "next" : "prev"]() } c = d = [0, 0] }; a.bind(j.start, function (b) { if (b.originalEvent.touches && b.originalEvent.touches.length > 1) { return } i = k(b); h = z.timestamp(); c = d = [i.pageX, i.pageY]; a.bind(j.move, l).one(j.stop, m) }) })(b.$("images")); if (this._options.fullscreenDoubleTap) { this.$("stage").bind("touchstart", function () { var a, c, d, e, f, g, h = function (a) { return a.originalEvent.touches ? a.originalEvent.touches[0] : a }; return function (i) { g = Galleria.utils.timestamp(); c = h(i).pageX; d = h(i).pageY; if (g - a < 500 && c - e < 20 && d - f < 20) { b.toggleFullscreen(); i.preventDefault(); b.$("stage").unbind("touchend", arguments.callee); return } a = g; e = c; f = d } } ()) } } z.optimizeTouch(this.get("container")); return this }, _createThumbnails: function () { this.get("total").innerHTML = this.getDataLength(); var b, e, f, g, h, i = this, j = this._options, k = function () { var a = i.$("thumbnails").find(".active"); if (!a.length) { return false } return a.find("img").attr("src") } (), l = typeof j.thumbnails === "string" ? j.thumbnails.toLowerCase() : null, m = function (a) { return d.defaultView && d.defaultView.getComputedStyle ? d.defaultView.getComputedStyle(f.container, null)[a] : h.css(a) }, n = function (b, c, d) { return function () { a(d).append(b); i.trigger({ type: Galleria.THUMBNAIL, thumbTarget: b, index: c }) } }, o = function (b) { if (j.pauseOnInteraction) { i.pause() } var c = a(b.currentTarget).data("index"); if (i.getIndex() !== c) { i.show(c) } b.preventDefault() }, p = function (b) { b.scale({ width: b.data.width, height: b.data.height, crop: j.thumbCrop, margin: j.thumbMargin, canvas: j.useCanvas, complete: function (b) { var c = ["left", "top"], d = ["Width", "Height"], e, f; a.each(d, function (d, g) { e = g.toLowerCase(); if ((j.thumbCrop !== true || j.thumbCrop === e) && j.thumbFit) { f = {}; f[e] = b[e]; a(b.container).css(f); f = {}; f[c[d]] = 0; a(b.image).css(f) } b["outer" + g] = a(b.container)["outer" + g](true) }); z.toggleQuality(b.image, j.thumbQuality === true || j.thumbQuality === "auto" && b.original.width < b.width * 3); i.trigger({ type: Galleria.THUMBNAIL, thumbTarget: b.image, index: b.data.order }) } }) }; this._thumbnails = []; this.$("thumbnails").empty(); for (b = 0; this._data[b]; b++) { g = this._data[b]; if (j.thumbnails === true) { f = new Galleria.Picture(b); e = g.thumb || g.image; this.$("thumbnails").append(f.container); h = a(f.container); f.data = { width: z.parseValue(m("width")), height: z.parseValue(m("height")), order: b }; if (j.thumbFit && j.thumbCrop !== true) { h.css({ width: 0, height: 0 }) } else { h.css({ width: f.data.width, height: f.data.height }) } f.load(e, p); if (j.preload === "all") { f.preload(g.image) } } else if (l === "empty" || l === "numbers") { f = { container: z.create("galleria-image"), image: z.create("img", "span"), ready: true }; if (l === "numbers") { a(f.image).text(b + 1) } this.$("thumbnails").append(f.container); c.setTimeout(n(f.image, b, f.container), 50 + b * 20) } else { f = { container: null, image: null} } a(f.container).add(j.keepSource && j.linkSourceImages ? g.original : null).data("index", b).bind(j.thumbEventType, o); if (k === e) { a(f.container).addClass("active") } this._thumbnails.push(f) } }, _run: function () { var d = this; d._createThumbnails(); z.wait({ until: function () { if (Galleria.OPERA) { d.$("stage").css("display", "inline-block") } d._stageWidth = d.$("stage").width(); d._stageHeight = d.$("stage").height(); return d._stageWidth && d._stageHeight > 50 }, success: function () { t.push(d); z.show(d.get("counter")); if (d._options.carousel) { d._carousel.bindControls() } if (d._options.autoplay) { d.pause(); if (typeof d._options.autoplay === "number") { d._playtime = d._options.autoplay } d.trigger(Galleria.PLAY); d._playing = true } if (d._firstrun) { if (typeof d._options.show === "number") { d.show(d._options.show) } return } d._firstrun = true; if (d._options.clicknext && !Galleria.TOUCH) { a.each(d._data, function (a, b) { delete b.link }); d.$("stage").css({ cursor: "pointer" }).bind("click", function (a) { if (d._options.pauseOnInteraction) { d.pause() } d.next() }) } if (Galleria.History) { Galleria.History.change(function (a) { if (isNaN(a)) { c.history.go(-1) } else { d.show(a, b, true) } }) } a.each(Galleria.ready.callbacks, function () { this.call(d, d._options) }); d.trigger(Galleria.READY); Galleria.theme.init.call(d, d._options); d._options.extend.call(d, d._options); if (/^[0-9]{1,4}$/.test(l) && Galleria.History) { d.show(l, b, true) } else if (d._data[d._options.show]) { d.show(d._options.show) } }, error: function () { Galleria.raise("Stage width or height is too small to show the gallery. Traced measures: width:" + d._stageWidth + "px, height: " + d._stageHeight + "px.", true) } }) }, load: function (b, c, d) { var e = this; this._data = []; this._thumbnails = []; this.$("thumbnails").empty(); if (typeof c === "function") { d = c; c = null } b = b || this._options.dataSource; c = c || this._options.dataSelector; d = d || this._options.dataConfig; if (/^function Object/.test(b.constructor)) { b = [b] } if (b.constructor === Array) { if (this.validate(b)) { this._data = b; this._parseData().trigger(Galleria.DATA) } else { Galleria.raise("Load failed: JSON Array not valid.") } return this } a(b).find(c).each(function (b, c) { c = a(c); var f = {}, g = c.parent(), h = g.attr("href"), i = g.attr("rel"); if (h) { f.image = f.big = h } if (i) { f.big = i } e._data.push(a.extend({ title: c.attr("title") || "", thumb: c.attr("src"), image: c.attr("src"), big: c.attr("src"), description: c.attr("alt") || "", copyright: c.attr("alt"), link: c.attr("longdesc"), original: c.get(0) }, f, d(c))) }); if (this.getDataLength()) { this.trigger(Galleria.DATA) } else { Galleria.raise("Load failed: no data found.") } return this }, _parseData: function () { var b = this; a.each(this._data, function (a, c) { if ("thumb" in c === false) { b._data[a].thumb = c.image } if (!"big" in c) { b._data[a].big = c.image } }); return this }, splice: function () { Array.prototype.splice.apply(this._data, z.array(arguments)); return this._parseData()._createThumbnails() }, push: function () { Array.prototype.push.apply(this._data, z.array(arguments)); return this._parseData()._createThumbnails() }, _getActive: function () { return this._controls.getActive() }, validate: function (a) { return true }, bind: function (a, b) { a = r(a); this.$("container").bind(a, this.proxy(b)); return this }, unbind: function (a) { a = r(a); this.$("container").unbind(a); return this }, trigger: function (b) { b = typeof b === "object" ? a.extend(b, { scope: this }) : { type: r(b), scope: this }; this.$("container").trigger(b); return this }, addIdleState: function (a, b) { this._idle.add.apply(this._idle, z.array(arguments)); return this }, removeIdleState: function (a) { this._idle.remove.apply(this._idle, z.array(arguments)); return this }, enterIdleMode: function () { this._idle.hide(); return this }, exitIdleMode: function () { this._idle.showAll(); return this }, enterFullscreen: function (a) { this._fullscreen.enter.apply(this, z.array(arguments)); return this }, exitFullscreen: function (a) { this._fullscreen.exit.apply(this, z.array(arguments)); return this }, toggleFullscreen: function (a) { this._fullscreen[this.isFullscreen() ? "exit" : "enter"].apply(this, z.array(arguments)); return this }, bindTooltip: function (a, b) { this._tooltip.bind.apply(this._tooltip, z.array(arguments)); return this }, defineTooltip: function (a, b) { this._tooltip.define.apply(this._tooltip, z.array(arguments)); return this }, refreshTooltip: function (a) { this._tooltip.show.apply(this._tooltip, z.array(arguments)); return this }, openLightbox: function () { this._lightbox.show.apply(this._lightbox, z.array(arguments)); return this }, closeLightbox: function () { this._lightbox.hide.apply(this._lightbox, z.array(arguments)); return this }, getActiveImage: function () { return this._getActive().image || b }, getActiveThumb: function () { return this._thumbnails[this._active].image || b }, getMousePosition: function (a) { return { x: a.pageX - this.$("container").offset().left, y: a.pageY - this.$("container").offset().top} }, addPan: function (b) { if (this._options.imageCrop === false) { return } b = a(b || this.getActiveImage()); var c = this, d = b.width() / 2, e = b.height() / 2, f = parseInt(b.css("left"), 10), g = parseInt(b.css("top"), 10), h = f || 0, i = g || 0, j = 0, k = 0, l = false, n = z.timestamp(), o = 0, p = 0, q = function (a, c, d) { if (a > 0) { p = Math.round(Math.max(a * -1, Math.min(0, c))); if (o !== p) { o = p; if (m === 8) { b.parent()["scroll" + d](p * -1) } else { var e = {}; e[d.toLowerCase()] = p; b.css(e) } } } }, r = function (a) { if (z.timestamp() - n < 50) { return } l = true; d = c.getMousePosition(a).x; e = c.getMousePosition(a).y }, s = function (a) { if (!l) { return } j = b.width() - c._stageWidth; k = b.height() - c._stageHeight; f = d / c._stageWidth * j * -1; g = e / c._stageHeight * k * -1; h += (f - h) / c._options.imagePanSmoothness; i += (g - i) / c._options.imagePanSmoothness; q(k, i, "Top"); q(j, h, "Left") }; if (m === 8) { b.parent().scrollTop(i * -1).scrollLeft(h * -1); b.css({ top: 0, left: 0 }) } this.$("stage").unbind("mousemove", r).bind("mousemove", r); z.addTimer("pan", s, 50, true); return this }, proxy: function (a, b) { if (typeof a !== "function") { return function () { } } b = b || this; return function () { return a.apply(b, z.array(arguments)) } }, removePan: function () { this.$("stage").unbind("mousemove"); z.clearTimer("pan"); return this }, addElement: function (b) { var c = this._dom; a.each(z.array(arguments), function (a, b) { c[b] = z.create("galleria-" + b) }); return this }, attachKeyboard: function (a) { this._keyboard.attach.apply(this._keyboard, z.array(arguments)); return this }, detachKeyboard: function () { this._keyboard.detach.apply(this._keyboard, z.array(arguments)); return this }, appendChild: function (a, b) { this.$(a).append(this.get(b) || b); return this }, prependChild: function (a, b) { this.$(a).prepend(this.get(b) || b); return this }, remove: function (a) { this.$(z.array(arguments).join(",")).remove(); return this }, append: function (a) { var b, c; for (b in a) { if (a.hasOwnProperty(b)) { if (a[b].constructor === Array) { for (c = 0; a[b][c]; c++) { this.appendChild(b, a[b][c]) } } else { this.appendChild(b, a[b]) } } } return this }, _scaleImage: function (b, c) { b = b || this._controls.getActive(); var d = this, e, f = function (b) { a(b.container).children(":first").css({ top: Math.max(0, z.parseValue(b.image.style.top)), left: Math.max(0, z.parseValue(b.image.style.left)), width: z.parseValue(b.image.width), height: z.parseValue(b.image.height) }) }; c = a.extend({ width: this._stageWidth, height: this._stageHeight, crop: this._options.imageCrop, max: this._options.maxScaleRatio, min: this._options.minScaleRatio, margin: this._options.imageMargin, position: this._options.imagePosition }, c); if (this._options.layerFollow && this._options.imageCrop !== true) { if (typeof c.complete == "function") { e = c.complete; c.complete = function () { e.call(b, b); f(b) } } else { c.complete = f } } else { a(b.container).children(":first").css({ top: 0, left: 0 }) } b.scale(c); return this }, updateCarousel: function () { this._carousel.update(); return this }, rescale: function (a, c, d) { var e = this; if (typeof a === "function") { d = a; a = b } var f = function () { e._stageWidth = a || e.$("stage").width(); e._stageHeight = c || e.$("stage").height(); e._scaleImage(); if (e._options.carousel) { e.updateCarousel() } e.trigger(Galleria.RESCALE); if (typeof d === "function") { d.call(e) } }; if (Galleria.WEBKIT && !a && !c) { z.addTimer("scale", f, 10) } else { f.call(e) } return this }, refreshImage: function () { this._scaleImage(); if (this._options.imagePan) { this.addPan() } return this }, show: function (a, b, c) { if (a === false || !this._options.queue && this._queue.stalled) { return } a = Math.max(0, Math.min(parseInt(a, 10), this.getDataLength() - 1)); b = typeof b !== "undefined" ? !!b : a < this.getIndex(); c = c || false; if (!c && Galleria.History) { Galleria.History.set(a.toString()); return } this._active = a; Array.prototype.push.call(this._queue, { index: a, rewind: b }); if (!this._queue.stalled) { this._show() } return this }, _show: function () { var d = this, e = this._queue[0], f = this.getData(e.index); if (!f) { return } var g = this.isFullscreen() && "big" in f ? f.big : f.image, h = this._controls.getActive(), i = this._controls.getNext(), j = i.isCached(g), k = this._thumbnails[e.index]; var l = function (b, e, f, g, h) { return function () { var i; d._queue.stalled = false; z.toggleQuality(e.image, d._options.imageQuality); d._layers[d._controls.active].innerHTML = ""; a(f.container).css({ zIndex: 0, opacity: 0 }).show(); a(e.container).css({ zIndex: 1 }).show(); d._controls.swap(); if (d._options.imagePan) { d.addPan(e.image) } if (b.link || d._options.lightbox) { a(e.image).css({ cursor: "pointer" }).bind("mouseup", function () { if (b.link) { if (d._options.popupLinks) { i = c.open(b.link, "_blank") } else { c.location.href = b.link } return } d.openLightbox() }) } Array.prototype.shift.call(d._queue); if (d._queue.length) { d._show() } d._playCheck(); d.trigger({ type: Galleria.IMAGE, index: g.index, imageTarget: e.image, thumbTarget: h.image }) } } (f, i, h, e, k); if (this._options.carousel && this._options.carouselFollow) { this._carousel.follow(e.index) } if (this._options.preload) { var m, n, o = this.getNext(), p; try { for (n = this._options.preload; n > 0; n--) { m = new Galleria.Picture; p = d.getData(o); m.preload(this.isFullscreen() && "big" in p ? p.big : p.image); o = d.getNext(o) } } catch (q) { } } z.show(i.container); a(d._thumbnails[e.index].container).addClass("active").siblings(".active").removeClass("active"); d.trigger({ type: Galleria.LOADSTART, cached: j, index: e.index, rewind: e.rewind, imageTarget: i.image, thumbTarget: k.image }); i.load(g, function (c) { a(d._layers[1 - d._controls.active]).html(f.layer || "").hide(); d._scaleImage(c, { complete: function (c) { if ("image" in h) { z.toggleQuality(h.image, false) } z.toggleQuality(c.image, false); d._queue.stalled = true; d.removePan(); d.setInfo(e.index); d.setCounter(e.index); if (f.layer) { a(d._layers[1 - d._controls.active]).show() } d.trigger({ type: Galleria.LOADFINISH, cached: j, index: e.index, rewind: e.rewind, imageTarget: c.image, thumbTarget: d._thumbnails[e.index].image }); var g = d._options.transition; a.each({ initial: h.image === null, touch: Galleria.TOUCH, fullscreen: d.isFullscreen() }, function (a, c) { if (c && d._options[a + "Transition"] !== b) { g = d._options[a + "Transition"]; return false } }); if (g in A === false) { l() } else { var i = { prev: h.container, next: c.container, rewind: e.rewind, speed: d._options.transitionSpeed || 400 }; A[g].call(d, i, l) } } }) }) }, getNext: function (a) { a = typeof a === "number" ? a : this.getIndex(); return a === this.getDataLength() - 1 ? 0 : a + 1 }, getPrev: function (a) { a = typeof a === "number" ? a : this.getIndex(); return a === 0 ? this.getDataLength() - 1 : a - 1 }, next: function () { if (this.getDataLength() > 1) { this.show(this.getNext(), false) } return this }, prev: function () { if (this.getDataLength() > 1) { this.show(this.getPrev(), true) } return this }, get: function (a) { return a in this._dom ? this._dom[a] : null }, getData: function (a) { return a in this._data ? this._data[a] : this._data[this._active] }, getDataLength: function () { return this._data.length }, getIndex: function () { return typeof this._active === "number" ? this._active : false }, getStageHeight: function () { return this._stageHeight }, getStageWidth: function () { return this._stageWidth }, getOptions: function (a) { return typeof a === "undefined" ? this._options : this._options[a] }, setOptions: function (b, c) { if (typeof b === "object") { a.extend(this._options, b) } else { this._options[b] = c } return this }, play: function (a) { this._playing = true; this._playtime = a || this._playtime; this._playCheck(); this.trigger(Galleria.PLAY); return this }, pause: function () { this._playing = false; this.trigger(Galleria.PAUSE); return this }, playToggle: function (a) { return this._playing ? this.pause() : this.play(a) }, isPlaying: function () { return this._playing }, isFullscreen: function () { return this._fullscreen.active }, _playCheck: function () { var a = this, b = 0, c = 20, d = z.timestamp(), e = "play" + this._id; if (this._playing) { z.clearTimer(e); var f = function () { b = z.timestamp() - d; if (b >= a._playtime && a._playing) { z.clearTimer(e); a.next(); return } if (a._playing) { a.trigger({ type: Galleria.PROGRESS, percent: Math.ceil(b / a._playtime * 100), seconds: Math.floor(b / 1e3), milliseconds: b }); z.addTimer(e, f, c) } }; z.addTimer(e, f, c) } }, setPlaytime: function (a) { this._playtime = a; return this }, setIndex: function (a) { this._active = a; return this }, setCounter: function (a) { if (typeof a === "number") { a++ } else if (typeof a === "undefined") { a = this.getIndex() + 1 } this.get("current").innerHTML = a; if (m) { var b = this.$("counter"), c = b.css("opacity"); if (parseInt(c, 10) === 1) { z.removeAlpha(b[0]) } else { this.$("counter").css("opacity", c) } } return this }, setInfo: function (b) { var c = this, d = this.getData(b); a.each(["title", "description", "copyright"], function (a, b) { var e = c.$("info-" + b); if (!!d[b]) { e[d[b].length ? "show" : "hide"]().html(d[b]) } else { e.empty().hide() } }); return this }, hasInfo: function (a) { var b = "title description copyright".split(" "), c; for (c = 0; b[c]; c++) { if (!!this.getData(a)[b[c]]) { return true } } return false }, jQuery: function (b) { var c = this, d = []; a.each(b.split(","), function (b, e) { e = a.trim(e); if (c.get(e)) { d.push(e) } }); var e = a(c.get(d.shift())); a.each(d, function (a, b) { e = e.add(c.get(b)) }); return e }, $: function (a) { return this.jQuery.apply(this, z.array(arguments)) } }; a.each(p, function (a, b) { var c = /_/.test(b) ? b.replace(/_/g, "") : b; Galleria[b.toUpperCase()] = "galleria." + c }); a.extend(Galleria, { IE9: m === 9, IE8: m === 8, IE7: m === 7, IE6: m === 6, IE: m, WEBKIT: /webkit/.test(k), SAFARI: /safari/.test(k), CHROME: /chrome/.test(k), QUIRK: m && d.compatMode && d.compatMode === "BackCompat", MAC: /mac/.test(navigator.platform.toLowerCase()), OPERA: !!c.opera, IPHONE: /iphone/.test(k), IPAD: /ipad/.test(k), ANDROID: /android/.test(k), TOUCH: "ontouchstart" in d }); Galleria.addTheme = function (b) { if (!b.name) { Galleria.raise("No theme name specified") } if (typeof b.defaults !== "object") { b.defaults = {} } else { b.defaults = q(b.defaults) } var c = false, d; if (typeof b.css === "string") { a("link").each(function (a, e) { d = new RegExp(b.css); if (d.test(e.href)) { c = true; y(b); return false } }); if (!c) { a("script").each(function (a, e) { d = new RegExp("galleria\\." + b.name.toLowerCase() + "\\."); if (d.test(e.src)) { c = e.src.replace(/[^\/]*$/, "") + b.css; z.addTimer("css", function () { z.loadCSS(c, "galleria-theme", function () { y(b) }) }, 1) } }) } if (!c) { Galleria.raise("No theme CSS loaded") } } else { y(b) } return b }; Galleria.loadTheme = function (d, e) { var f = false, g = t.length, h = c.setTimeout(function () { Galleria.raise("Theme at " + d + " could not load, check theme path.", true) }, 5e3); Galleria.theme = b; z.loadScript(d, function () { c.clearTimeout(h); if (g) { var b = []; a.each(Galleria.get(), function (c, d) { var f = a.extend(d._original.options, { data_source: d._data }, e); d.$("container").remove(); var g = new Galleria; g._id = d._id; g.init(d._original.target, f); b.push(g) }); t = b } }) }; Galleria.get = function (a) { if (!!u[a]) { return u[a] } else if (typeof a !== "number") { return u } else { Galleria.raise("Gallery index " + a + " not found") } }; Galleria.addTransition = function (a, b) { A[a] = b }; Galleria.utils = z; Galleria.log = function () { if ("console" in c && "log" in c.console) { return c.console.log } else { return function () { c.alert(z.array(arguments).join(", ")) } } } (); Galleria.ready = function (b) { a.each(t, function (a, c) { b.call(c, c._options) }); Galleria.ready.callbacks.push(b) }; Galleria.ready.callbacks = []; Galleria.raise = function (b, c) { var d = c ? "Fatal error" : "Error", e = this, f = function (b) { var e = '<div style="padding:4px;margin:0 0 2px;background:#' + (c ? "811" : "222") + '";>' + (c ? "<strong>" + d + ": </strong>" : "") + b + "</div>"; a.each(u, function () { var a = this.$("errors"), b = this.$("target"); if (!a.length) { b.css("position", "relative"); a = this.addElement("errors").appendChild("target", "errors").$("errors").css({ color: "#fff", position: "absolute", top: 0, left: 0, zIndex: 1e5 }) } a.append(e) }) }; if (h) { f(b); if (c) { throw new Error(d + ": " + b) } } else if (c) { if (v) { return } v = true; c = false; f("Image gallery could not load.") } }; Galleria.version = g; Galleria.requires = function (a, b) { b = b || "You need to upgrade Galleria to version " + a + " to use one or more components."; if (Galleria.version < a) { Galleria.raise(b, true) } }; Galleria.Picture = function (b) { this.id = b || null; this.image = null; this.container = z.create("galleria-image"); a(this.container).css({ overflow: "hidden", position: "relative" }); this.original = { width: 0, height: 0 }; this.ready = false; this.tid = null }; Galleria.Picture.prototype = { cache: {}, show: function () { z.show(this.image) }, hide: function () { z.moveOut(this.image) }, clear: function () { this.image = null }, isCached: function (a) { return !!this.cache[a] }, preload: function (b) { a(new Image).load(function (a, b) { return function () { b[a] = a } } (b, this.cache)).attr("src", b) }, load: function (b, d) { this.tid = c.setTimeout(function (a) { return function () { } } (b), i); this.image = new Image; var e = 0, f = false, g = a(this.container), h = a(this.image), k = function (b, d, e) { return function () { var f = function () { b.original = { height: this.height, width: this.width }; b.cache[e] = e; c.clearTimeout(b.tid); if (typeof d == "function") { c.setTimeout(function () { d.call(b, b) }, 1) } }; if (!this.width || !this.height) { c.setTimeout(function (b) { return function () { if (b.width && b.height) { f.call(b) } else { try { a("<img/>").attr("src", a(b).attr("src")).load(function () { f.call(this) }) } catch (c) { } } } } (this), 2) } else { f.call(this) } } } (this, d, b); g.find("img").remove(); h.css("display", "block").appendTo(this.container); z.hide(this.image); if (this.cache[b]) { this.image.src = b; k.call(this.image); return this.container } a(this.image).load(k).error(function () { if (!f) { f = true; c.setTimeout(function (a, b) { return function () { a.attr("src", b + "?" + z.timestamp()) } } (a(this), b), 50) } else { if (j) { a(this).attr("src", j) } else { Galleria.raise("Image not found: " + b) } } }).attr("src", b); return this.container }, scale: function (c) { c = a.extend({ width: 0, height: 0, min: b, max: b, margin: 0, complete: function () { }, position: "center", crop: false, canvas: false }, c); if (!this.image) { return this.container } var d, e, f = this, g = a(f.container), h; z.wait({ until: function () { d = c.width || g.width() || z.parseValue(g.css("width")); e = c.height || g.height() || z.parseValue(g.css("height")); return d && e }, success: function () { var b = (d - c.margin * 2) / f.original.width, g = (e - c.margin * 2) / f.original.height, i = { "true": Math.max(b, g), width: b, height: g, "false": Math.min(b, g) }, j = i[c.crop.toString()], k = ""; if (c.max) { j = Math.min(c.max, j) } if (c.min) { j = Math.max(c.min, j) } a.each(["width", "height"], function (b, c) { a(f.image)[c](f[c] = f.image[c] = Math.round(f.original[c] * j)) }); a(f.container).width(d).height(e); if (c.canvas && w) { w.elem.width = f.width; w.elem.height = f.height; k = f.image.src + ":" + f.width + "x" + f.height; f.image.src = w.cache[k] || function (a) { w.context.drawImage(f.image, 0, 0, f.original.width * j, f.original.height * j); try { h = w.elem.toDataURL(); w.length += h.length; w.cache[a] = h; return h } catch (b) { return f.image.src } } (k) } var l = {}, m = {}, n = function (b, c, d) { var e = 0; if (/\%/.test(b)) { var g = parseInt(b, 10) / 100, h = f.image[c] || a(f.image)[c](); e = Math.ceil(h * -1 * g + d * g) } else { e = z.parseValue(b) } return e }, o = { top: { top: 0 }, left: { left: 0 }, right: { left: "100%" }, bottom: { top: "100%"} }; a.each(c.position.toLowerCase().split(" "), function (a, b) { if (b === "center") { b = "50%" } l[a ? "top" : "left"] = b }); a.each(l, function (b, c) { if (o.hasOwnProperty(c)) { a.extend(m, o[c]) } }); l = l.top ? a.extend(l, m) : m; l = a.extend({ top: "50%", left: "50%" }, l); a(f.image).css({ position: "absolute", top: n(l.top, "height", e), left: n(l.left, "width", d) }); f.show(); f.ready = true; c.complete.call(f, f) }, error: function () { Galleria.raise("Could not scale image: " + f.image.src) }, timeout: 1e3 }); return this } }; a.extend(a.easing, { galleria: function (a, b, c, d, e) { if ((b /= e / 2) < 1) { return d / 2 * b * b * b + c } return d / 2 * ((b -= 2) * b * b + 2) + c }, galleriaIn: function (a, b, c, d, e) { return d * (b /= e) * b + c }, galleriaOut: function (a, b, c, d, e) { return -d * (b /= e) * (b - 2) + c } }); a.fn.galleria = function (b) { return this.each(function () { a(this).data("galleria", (new Galleria).init(this, b)) }) } })(jQuery)
