// JavaScript Document
/*!
Slimbox v1.69 - The ultimate lightweight Lightbox clone
(c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
MIT-style license.
*/

var Slimbox = (function () { var f = window, ie6 = Browser.Engine.trident4, options, images, activeImage = -1, activeURL, prevImage, nextImage, compatibleOverlay, middle, centerWidth, centerHeight, preload = {}, preloadPrev = new Image(), preloadNext = new Image(), myAnchor, overlay, center, image, sizer, prevLink, nextLink, bottomContainer, bottom, caption, number, fxOverlay, fxResize, fxImage, fxBottom; f.addEvent("domready", function () { $(document.body).adopt($$(overlay = new Element("div", { id: "lbOverlay", events: { click: close} }), center = new Element("div", { id: "lbCenter" }), bottomContainer = new Element("div", { id: "lbBottomContainer" })).setStyle("display", "none")); image = new Element("div", { id: "lbImage" }).injectInside(center).adopt(sizer = new Element("div", { styles: { position: "relative"} })); myAnchor = new Element("a", { id: "lbDownLink", href: "", target: "_blank" }); if (window.location.href.indexOf('/ger')) { myAnchor.className = 'ger-full' } else if (window.location.href.indexOf('/eng')) { myAnchor.className = 'eng-full' } else if (window.location.href.indexOf('/rus')) { myAnchor.className = 'rus-full' } else { myAnchor.className = 'cze-full' } bottom = new Element("div", { id: "lbBottom" }).injectInside(bottomContainer).adopt(myAnchor, new Element("a", { id: "lbCloseLink", href: "#", events: { click: close} }), caption = new Element("div", { id: "lbCaption" }), number = new Element("div", { id: "lbNumber" }), new Element("div", { styles: { clear: "both"} }), prevLink = new Element("a", { id: "lbPrevLink", href: "#", events: { click: previous} }), nextLink = new Element("a", { id: "lbNextLink", href: "#", events: { click: next} })) }); function position() { var a = f.getScroll(), size = f.getSize(); $$(center, bottomContainer).setStyle("left", a.x + (size.x / 2)); if (compatibleOverlay) overlay.setStyles({ left: a.x, top: a.y, width: size.x, height: size.y }) } function setup(c) { ["object", "iframe", ie6 ? "select" : "embed"].forEach2(function (b) { Array.forEach2(document.getElementsByTagName(b), function (a) { if (c) a._slimbox = a.style.visibility; a.style.visibility = c ? "hidden" : a._slimbox }) }); overlay.style.display = c ? "" : "none"; var d = c ? "addEvent" : "removeEvent"; f[d]("scroll", position)[d]("resize", position); document[d]("keydown", keyDown) } function keyDown(a) { var b = a.code; return options.closeKeys.contains(b) ? close() : options.nextKeys.contains(b) ? next() : options.previousKeys.contains(b) ? previous() : false } function previous() { return changeImage(prevImage) } function next() { return changeImage(nextImage) } function changeImage(a) { if (a >= 0) { activeImage = a; activeURL = images[a][0]; prevImage = (activeImage || (options.loop ? images.length : 0)) - 1; nextImage = ((activeImage + 1) % images.length) || (options.loop ? 0 : -1); stop(); center.className = "lbLoading"; preload = new Image(); preload.onload = animateBox; preload.src = activeURL; myAnchor.href = activeURL.replace("&FormatID=2", "") } return false } var g = true; function animateBox() { center.className = ""; fxImage.set(0); image.setStyles({ backgroundImage: "url(" + activeURL + ")", display: "" }); sizer.setStyle("width", preload.width); $$(sizer, prevLink, nextLink).setStyle("height", preload.height); caption.set("html", images[activeImage][1] || ""); number.set("html", (((images.length > 1) && options.counterText) || "").replace(/{x}/, activeImage + 1).replace(/{y}/, images.length)); if (prevImage >= 0) preloadPrev.src = images[prevImage][0]; if (nextImage >= 0) preloadNext.src = images[nextImage][0]; centerWidth = image.offsetWidth; centerHeight = image.offsetHeight; var a = Math.max(0, middle - (centerHeight / 2)), fn; if (center.offsetHeight != centerHeight) { fxResize.start({ height: centerHeight, top: a }) } if (center.offsetWidth != centerWidth) { fxResize.start({ width: centerWidth, marginLeft: -centerWidth / 2 }) } fn = function () { bottomContainer.setStyles({ width: centerWidth, top: a + centerHeight, marginLeft: -centerWidth / 2, display: "" }); fxImage.start(1) }; if (fxResize.check(fn)) fn() } function animateCaption() { if (prevImage >= 0) prevLink.style.display = ""; if (nextImage >= 0) nextLink.style.display = "" } function stop() { preload.onload = $empty; preload.src = preloadPrev.src = preloadNext.src = activeURL; fxResize.cancel(); fxImage.cancel(); fxBottom.cancel(); $$(prevLink, nextLink, image, bottomContainer).setStyle("display", "none") } function close() { if (activeImage >= 0) { stop(); activeImage = prevImage = nextImage = -1; center.style.display = "none"; fxOverlay.cancel().chain(setup).start(0) } return false } Element.implement({ slimbox: function (a, b) { $$(this).slimbox(a, b); return this } }); Elements.implement({ slimbox: function (b, c, d) { c = c || function (a) { return [a.href, a.title] }; d = d || function () { return true }; var e = this; e.removeEvents("click").addEvent("click", function () { var a = e.filter(d, this); return Slimbox.open(a.map(c), a.indexOf(this), b) }); return e } }); return { open: function (a, b, c) { options = $extend({ loop: false, overlayOpacity: 0.8, overlayFadeDuration: 0, resizeDuration: 400, resizeTransition: false, initialWidth: 250, initialHeight: 250, imageFadeDuration: 800, captionAnimationDuration: 0, counterText: "Image {x} of {y}", closeKeys: [27, 88, 67], previousKeys: [37, 80], nextKeys: [39, 78] }, c || {}); fxOverlay = new Fx.Tween(overlay, { property: "opacity", duration: options.overlayFadeDuration }); fxResize = new Fx.Morph(center, $extend({ duration: options.resizeDuration, link: "chain" }, options.resizeTransition ? { transition: options.resizeTransition} : {})); fxImage = new Fx.Tween(image, { property: "opacity", duration: options.imageFadeDuration, onComplete: animateCaption }); fxBottom = new Fx.Tween(bottom, { property: "margin-top" }); if (typeof a == "string") { a = [[a, b]]; b = 0 } middle = f.getScrollTop() + (f.getHeight() / 2); centerWidth = options.initialWidth; centerHeight = options.initialHeight; center.setStyles({ top: Math.max(0, middle - (centerHeight / 2)), width: centerWidth, height: centerHeight, marginLeft: -centerWidth / 2, display: "" }); compatibleOverlay = ie6 || (overlay.currentStyle && (overlay.currentStyle.position != "fixed")); if (compatibleOverlay) overlay.style.position = "absolute"; fxOverlay.set(0).start(options.overlayOpacity); position(); setup(1); images = a; options.loop = options.loop && (images.length > 1); return changeImage(b) } } })(); Slimbox.scanPage = function () { $$(document.links).filter(function (a) { return a.rel && a.rel.test(/^lightbox/i) }).slimbox({}, null, function (a) { return (this == a) || ((this.rel.length > 8) && (this.rel == a.rel)) }) }; window.addEvent("domready", Slimbox.scanPage);
