(function(b) { var a; a = b.fn.galleria = function(e) { if (!a.hasCSS()) { return false } b.historyInit(a.onPageLoad); var j = { insert: ".galleria_container", history: true, clickNext: true, onImage: function(l, k, i) { }, onThumb: function(i) { } }; var f = b.extend(j, e); for (var h in f) { if (h) { b.galleria[h] = f[h] } } var d = (b(f.insert).is(f.insert)) ? b(f.insert) : jQuery(document.createElement("div")).insertBefore(this); var c = b(document.createElement("div")).addClass("galleria_wrapper"); var g = b(document.createElement("span")).addClass("caption"); d.addClass("galleria_container").append(c).append(g); return this.each(function() { b(this).addClass("galleria"); b(this).children("li").each(function(q) { var m = b(this); var k = b.meta ? b.extend({}, f, m.data()) : f; k.clickNext = b(this).is(":only-child") ? false : k.clickNext; var p = b(this).find("a").is("a") ? b(this).find("a") : false; var l = b(this).children("img").css("display", "none"); var r = p ? p.attr("href") : l.attr("src"); var o = p ? p.attr("title") : l.attr("title"); var n = new Image(); if (k.history && (window.location.hash && window.location.hash.replace(/\#/, "") == r)) { m.siblings(".active").removeClass("active"); m.addClass("active") } b(n).load(function() { b(this).attr("alt", l.attr("alt")); var t = p ? p.find("img").addClass("thumb noscale").css("display", "none") : l.clone(true).addClass("thumb").css("display", "none"); if (p) { p.replaceWith(t) } if (!t.hasClass("noscale")) { var i = Math.ceil(l.width() / l.height() * m.height()); var s = Math.ceil(l.height() / l.width() * m.width()); if (i < s) { t.css({ height: "auto", width: m.width(), marginTop: -(s - m.height()) / 2 }) } else { t.css({ width: "auto", height: m.height(), marginLeft: -(i - m.width()) / 2 }) } } else { window.setTimeout(function() { t.css({ marginLeft: -(t.width() - m.width()) / 2, marginTop: -(t.height() - m.height()) / 2 }) }, 1) } t.attr("rel", r); t.attr("title", o); t.click(function() { b.galleria.activate(r) }); t.hover(function() { b(this).addClass("hover") }, function() { b(this).removeClass("hover") }); m.hover(function() { m.addClass("hover") }, function() { m.removeClass("hover") }); m.prepend(t); t.css("display", "block"); k.onThumb(jQuery(t)); if (m.hasClass("active")) { b.galleria.activate(r) } l.remove() }).error(function() { m.html('<span class="error" style="color:red">Error loading image: ' + r + "</span>") }).attr("src", r) }) }) }; a.nextSelector = function(c) { return b(c).is(":last-child") ? b(c).siblings(":first-child") : b(c).next() }; a.previousSelector = function(c) { return b(c).is(":first-child") ? b(c).siblings(":last-child") : b(c).prev() }; a.hasCSS = function() { b("body").append(b(document.createElement("div")).attr("id", "css_test").css({ width: "1px", height: "1px", display: "none" })); var c = (b("#css_test").width() != 1) ? false : true; b("#css_test").remove(); return c }; a.onPageLoad = function(f) { var d = b(".galleria_wrapper"); var e = b('.galleria img[rel="' + f + '"]'); if (f) { if (b.galleria.history) { window.location = window.location.href.replace(/\#.*/, "") + "#" + f } e.parents("li").siblings(".active").removeClass("active"); e.parents("li").addClass("active"); var c = b(new Image()).attr("src", f).addClass("replaced"); d.empty().append(c); d.siblings(".caption").text(e.attr("title")); b.galleria.onImage(c, d.siblings(".caption"), e); if (b.galleria.clickNext) { c.css("cursor", "pointer").click(function() { b.galleria.next() }) } } else { d.siblings().andSelf().empty(); b(".galleria li.active").removeClass("active") } b.galleria.current = f }; b.extend({ galleria: { current: "", onImage: function() { }, activate: function(c) { if (b.galleria.history) { b.historyLoad(c) } else { a.onPageLoad(c) } }, next: function() { var c = b(a.nextSelector(b('.galleria img[rel="' + b.galleria.current + '"]').parents("li"))).find("img").attr("rel"); b.galleria.activate(c) }, prev: function() { var c = b(a.previousSelector(b('.galleria img[rel="' + b.galleria.current + '"]').parents("li"))).find("img").attr("rel"); b.galleria.activate(c) } } }) })(jQuery); jQuery.extend({ historyCurrentHash: undefined, historyCallback: undefined, historyInit: function(d) { jQuery.historyCallback = d; var c = location.hash; jQuery.historyCurrentHash = c; if (jQuery.browser.msie) { if (jQuery.historyCurrentHash === "") { jQuery.historyCurrentHash = "#" } $("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>'); var a = $("#jQuery_history")[0]; var b = a.contentWindow.document; b.open(); b.close(); b.location.hash = c } else { if ($.browser.safari) { jQuery.historyBackStack = []; jQuery.historyBackStack.length = history.length; jQuery.historyForwardStack = []; jQuery.isFirst = true } } jQuery.historyCallback(c.replace(/^#/, "")); setInterval(jQuery.historyCheck, 100) }, historyAddHistory: function(a) { jQuery.historyBackStack.push(a); jQuery.historyForwardStack.length = 0; this.isFirst = true }, historyCheck: function() { if (jQuery.browser.msie) { var a = $("#jQuery_history")[0]; var d = a.contentDocument || a.contentWindow.document; var f = d.location.hash; if (f != jQuery.historyCurrentHash) { location.hash = f; jQuery.historyCurrentHash = f; jQuery.historyCallback(f.replace(/^#/, "")) } } else { if ($.browser.safari) { if (!jQuery.dontCheck) { var b = history.length - jQuery.historyBackStack.length; if (b) { jQuery.isFirst = false; var c; if (b < 0) { for (c = 0; c < Math.abs(b); c++) { jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop()) } } else { for (c = 0; c < b; c++) { jQuery.historyBackStack.push(jQuery.historyForwardStack.shift()) } } var e = jQuery.historyBackStack[jQuery.historyBackStack.length - 1]; if (e !== undefined) { jQuery.historyCurrentHash = location.hash; jQuery.historyCallback(e) } } else { if (jQuery.historyBackStack[jQuery.historyBackStack.length - 1] === undefined && !jQuery.isFirst) { if (document.URL.indexOf("#") >= 0) { jQuery.historyCallback(document.URL.split("#")[1]) } else { f = location.hash; jQuery.historyCallback("") } jQuery.isFirst = true } } } } else { f = location.hash; if (f != jQuery.historyCurrentHash) { jQuery.historyCurrentHash = f; jQuery.historyCallback(f.replace(/^#/, "")) } } } }, historyLoad: function(d) { var e; if (jQuery.browser.safari) { e = d } else { e = "#" + d; location.hash = e } jQuery.historyCurrentHash = e; if (jQuery.browser.msie) { var a = $("#jQuery_history")[0]; var c = a.contentWindow.document; c.open(); c.close(); c.location.hash = e; jQuery.historyCallback(d) } else { if (jQuery.browser.safari) { jQuery.dontCheck = true; this.historyAddHistory(d); var b = function() { jQuery.dontCheck = false }; window.setTimeout(b, 200); jQuery.historyCallback(d); location.hash = e } else { jQuery.historyCallback(d) } } } });
