/// <reference path="../jquery-1.3.1-vsdoc.js" />
/*!
Slimbox v2.02 - The ultimate lightweight Lightbox clone for jQuery
(c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
MIT-style license.
*/
/* Modified by Josh Bowdoin - Athletic.net - 11/13/2009 */

(function(a) {
    var l = a(window), c, d, h = -1, r, n, o, z, A, g, i, B = !window.XMLHttpRequest, C = window.opera && document.compatMode == "CSS1Compat" && a.browser.version >= 9.3, D = document.documentElement, q, s, E, j = {}, F = new Image, G = new Image, k, f, m, y, t, u, p, v, H, I; a(function() {
        a("body").append(a([k = a('<div id="lbOverlay" />')[0], f = a('<div id="lbCenter" />')[0], p = a('<div id="lbBottomContainer" />')[0]]).css("display", "none")); a(f).append('<div id="sbAblocker"></div>'); q = a("#sbAblocker"); a(f).append('<table id="sbAcontainer" cellspacing="0px"><tr><td id="sbAthumbs"><div></div></td><td id="sbAphoto"><div id="sbAtitle"></div></td><td id="sbAtags"><a id="lbCloseLink" href="#">CLOSE</a><div id="lbNumber" /><b>In this photo:</b><div id="tags">Jacob Bowdoin<br />Jacob Bowdoin<br />Jacob Bowdoin<br />Jacob Bowdoin<br /></div></td></tr></table>');
        s = a("#tags"); E = a("#sbAtitle"); a("#lbCloseLink").add(k).click(J); I = a("#lbNumber"); m = a('<div id="lbImage" />').appendTo("#sbAphoto").append(y = a('<div style="position: relative;" />').append([t = a('<a id="lbPrevLink" href="#" />').click(K)[0], u = a('<a id="lbNextLink" href="#" />').click(L)[0]])[0])[0]; v = a('<div id="lbBottom" />').appendTo(p).append([H = a('<div id="lbCaption" />')[0], a('<div style="clear: both;" />')[0]])[0]
    }); a.slimbox = function(b, e, M) {
        c = a.extend({ loop: false, overlayOpacity: 0.8, overlayFadeDuration: 400,
            resizeDuration: 400, resizeEasing: "swing", initialWidth: 250, initialHeight: 250, imageFadeDuration: 400, captionAnimationDuration: 400, counterText: "Image {x} of {y}", closeKeys: [27, 88, 67], previousKeys: [37, 80], nextKeys: [39, 78], onClose: false
        }, M); if (typeof b == "string") { b = [[b, e]]; e = 0 } A = l.scrollTop() + (C ? D.clientHeight : l.height()) / 2; g = c.initialWidth; i = c.initialHeight; a(f).css({ top: Math.max(0, A - i / 2), width: g, height: i, marginLeft: -g / 2 }).show(); if (z = B || k.currentStyle && k.currentStyle.position != "fixed") k.style.position =
"absolute"; a(k).css("opacity", c.overlayOpacity).fadeIn(c.overlayFadeDuration); q.css({ height: i, width: g }); N(); O(1); d = b; c.loop = c.loop && d.length > 1; setTimeout("sbAloadThumbs();", 20); return w(e)
    }; function N() { var b = l.scrollLeft(), e = C ? D.clientWidth : l.width(); a([f, p]).css("left", b + e / 2); z && a(k).css({ left: b, top: l.scrollTop(), width: e, height: l.height() }) } function O(b) {
        a("object").add(B ? "select" : "embed").each(function(M, x) { b && a.data(x, "slimbox", x.style.visibility); x.style.visibility = b ? "hidden" : a.data(x, "slimbox") });
        var e = b ? "bind" : "unbind"; l[e]("scroll resize", N); a(document)[e]("keydown", Q)
    } function Q(b) { b = b.keyCode; var e = a.inArray; return e(b, c.closeKeys) >= 0 ? J() : e(b, c.nextKeys) >= 0 ? L() : e(b, c.previousKeys) >= 0 ? K() : false } function K() { return w(n) } function L() { return w(o) } function w(b) { if (b >= 0) { h = b; r = d[h][0] + "?imgmax=" + slimboxMax; n = (h || (c.loop ? d.length : 0)) - 1; o = (h + 1) % d.length || (c.loop ? 0 : -1); P(); a("#sbAthumbs").add(s).css({ visibility: "hidden" }); q.show(); j = new Image; j.onload = R; j.src = r } return false } function R() {
        q.hide();
        a(m).css({ backgroundImage: 'url("' + r + '")', visibility: "hidden", display: "" }); a(y).width(j.width); a([y, t, u]).height(j.height); a(H).html(d[h][1][0] || ""); a(s).html(d[h][1][1] || ""); a(E).width(j.width).html(d[h][1][2] || ""); a(I).html((d.length > 1 && c.counterText || "").replace(/{x}/, h + 1).replace(/{y}/, d.length)); if (n >= 0) F.src = d[n][0] + "?imgmax=" + slimboxMax; if (o >= 0) G.src = d[o][0] + "?imgmax=" + slimboxMax; g = m.offsetWidth + a("#sbAthumbs").width() + a("#sbAtags").width() + 8; i = m.offsetHeight + 17; a("#sbAthumbs div, sbAtags div").height(i);
        var b = 10; f.offsetHeight != i && a(f).animate({ height: i, top: b }, c.resizeDuration, c.resizeEasing); f.offsetWidth != g && a(f).animate({ width: g, marginLeft: -g / 2 }, c.resizeDuration, c.resizeEasing); a(f).queue(function() { a(p).css({ width: g, top: b + i, marginLeft: -g / 2, visibility: "hidden", display: "" }); a(m).css({ display: "none", visibility: "", opacity: "" }).fadeIn(c.imageFadeDuration, S) }); a("#sbAthumbs").add(s).css({ visibility: "visible" }); q.css({ height: i, width: g })
    } sbAloadThumbs = function() {
        var b = ""; a.each(d, function() {
            b += '<img src="' +
this[0] + '?imgmax=64&crop=1" /><br />'
        }); a("#sbAthumbs div").html(b)
    }; a("#sbAthumbs div img").live("click", function() { w(a("#sbAthumbs div img").index(a(this))) }); function S() { n >= 0 && a(t).show(); o >= 0 && a(u).show(); a(v).css("marginTop", -v.offsetHeight).animate({ marginTop: 0 }, c.captionAnimationDuration); p.style.visibility = "" } function P() { j.onload = null; j.src = F.src = G.src = r; a([f, m, v]).stop(true); a([t, u, m, p]).hide() } function J() {
        if (h >= 0) { P(); h = n = o = -1; a(f).hide(); a(k).stop().fadeOut(c.overlayFadeDuration, O) } a("#sbAthumbs div").empty();
        c.onClose && slimboxANETClose(); return false
    } 
})(jQuery);