/*
 * jQuery Tools 1.2.2 - The missing UI library for the Web
 * 
 * [overlay, overlay.apple]
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 * File generated: Sun Jun 06 19:26:10 GMT 2010
 */
(function (a) {
    function t(d, b) {
        var c = this,
            i = d.add(c),
            o = a(window),
            k, f, m, g = a.tools.expose && (b.mask || b.expose),
            n = Math.random().toString().slice(10);
        if (g) {
            if (typeof g == "string") g = {
                color: g
            };
            g.closeOnClick = g.closeOnEsc = false
        }
        var p = b.target || d.attr("rel");
        f = p ? a(p) : d;
        if (!f.length) throw "Could not find Overlay: " + p;
        d && d.index(f) == -1 && d.click(function (e) {
            c.load(e);
            return e.preventDefault()
        });
        a.extend(c, {
            load: function (e) {
                if (c.isOpened()) return c;
                var h = q[b.effect];
                if (!h) throw 'Overlay: cannot find effect : "' + b.effect + '"';
                b.oneInstance && a.each(s, function () {
                    this.close(e)
                });
                e = e || a.Event();
                e.type = "onBeforeLoad";
                i.trigger(e);
                if (e.isDefaultPrevented()) return c;
                m = true;
                g && a(f).expose(g);
                var j = b.top,
                    r = b.left,
                    u = f.outerWidth({
                        margin: true
                    }),
                    v = f.outerHeight({
                        margin: true
                    });
                if (typeof j == "string") j = j == "center" ? Math.max((o.height() - v) / 2, 0) : parseInt(j, 10) / 100 * o.height();
                if (r == "center") r = Math.max((o.width() - u) / 2, 0);
                h[0].call(c, {
                    top: j,
                    left: r
                }, function () {
                    if (m) {
                        e.type = "onLoad";
                        i.trigger(e)
                    }
                });
                g && b.closeOnClick && a.mask.getMask().one("click", c.close);
                b.closeOnClick && a(document).bind("click." + n, function (l) {
                    a(l.target).parents(f).length || c.close(l)
                });
                b.closeOnEsc && a(document).bind("keydown." + n, function (l) {
                    l.keyCode == 27 && c.close(l)
                });
                return c
            }, close: function (e) {
                if (!c.isOpened()) return c;
                e = e || a.Event();
                e.type = "onBeforeClose";
                i.trigger(e);
                if (!e.isDefaultPrevented()) {
                    m = false;
                    q[b.effect][1].call(c, function () {
                        e.type = "onClose";
                        $("body").css('background','url(assets/site/images/background2.jpg) no-repeat top center #000');
                        i.trigger(e)
                    });
                    a(document).unbind("click." + n).unbind("keydown." + n);
                    g && a.mask.close();
                    return c
                }
            }, getOverlay: function () {
                return f
            }, getTrigger: function () {
                return d
            }, getClosers: function () {
                return k
            }, isOpened: function () {
                return m
            }, getConf: function () {
                return b
            }
        });
        a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function (e, h) {
            a.isFunction(b[h]) && a(c).bind(h, b[h]);
            c[h] = function (j) {
                a(c).bind(h, j);
                return c
            }
        });
        k = f.find(b.close || ".close");
        if (!k.length && !b.close) {
            k = a('<div class="close"></div>');
            f.prepend(k)
        }
        k.click(function (e) {
            c.close(e)
        });
        b.load && c.load()
    }
    a.tools = a.tools || {
        version: "1.2.2"
    };
    a.tools.overlay = {
        addEffect: function (d, b, c) {
            q[d] = [b, c]
        }, conf: {
            close: null,
            closeOnClick: true,
            closeOnEsc: true,
            closeSpeed: "fast",
            effect: "default",
            fixed: !a.browser.msie || a.browser.version > 6,
            left: "center",
            load: false,
            mask: null,
            oneInstance: true,
            speed: "normal",
            target: null,
            top: "10%"
        }
    };
    var s = [],
        q = {};
    a.tools.overlay.addEffect("default", function (d, b) {
        var c = this.getConf(),
            i = a(window);
        if (!c.fixed) {
            d.top += i.scrollTop();
            d.left += i.scrollLeft()
        }
        d.position = c.fixed ? "fixed" : "absolute";
        this.getOverlay().css(d).fadeIn(c.speed, b)
    }, function (d) {
        this.getOverlay().fadeOut(this.getConf().closeSpeed, d)
    });
    a.fn.overlay = function (d) {
        var b = this.data("overlay");
        if (b) return b;
        if (a.isFunction(d)) d = {
            onBeforeLoad: d
        };
        d = a.extend(true, {}, a.tools.overlay.conf, d);
        this.each(function () {
            b = new t(a(this), d);
            s.push(b);
            a(this).data("overlay", b)
        });
        return d.api ? b : this
    }
})(jQuery);
(function (i) {
    function j(b) {
        var d = b.offset();
        return {
            top: d.top + b.height() / 2,
            left: d.left + b.width() / 2
        }
    }
    var k = i.tools.overlay,
        f = i(window);
    i.extend(k.conf, {
        start: {
            top: null,
            left: null
        }, fadeInSpeed: "fast",
        zIndex: 9999
    });

    function n(b, d) {
        var a = this.getOverlay(),
            c = this.getConf(),
            g = this.getTrigger(),
            o = this,
            l = a.outerWidth({
                margin: true
            }),
            h = a.data("img");
        if (!h) {
            var e = a.css("backgroundImage");
            if (!e) throw "background-image CSS property not set for overlay";
            e = e.slice(e.indexOf("(") + 1, e.indexOf(")")).replace(/\"/g, "");
            a.css("backgroundImage", "none");
            h = i('<img src="' + e + '"/>');
            h.css({
                border: 0,
                display: "none"
            }).width(l);
            i("body").append(h);
            a.data("img", h)
        }
        e = c.start.top || Math.round(f.height() / 2);
        var m = c.start.left || Math.round(f.width() / 2);
        if (g) {
            g = j(g);
            e = g.top;
            m = g.left
        }
        h.css({
            position: "absolute",
            top: e,
            left: m,
            width: 0,
            zIndex: c.zIndex
        }).show();
        b.top += f.scrollTop();
        b.left += f.scrollLeft();
        b.position = "absolute";
        a.css(b);
        h.animate({
            top: a.css("top"),
            left: a.css("left"),
            width: l
        }, c.speed, function () {
            if (c.fixed) {
                b.top -= f.scrollTop();
                b.left -= f.scrollLeft();
                b.position = "fixed";
                h.add(a).css(b)
            }
            a.css("zIndex", c.zIndex + 1).fadeIn(c.fadeInSpeed, function () {
                o.isOpened() && !i(this).index(a) ? d.call() : a.hide()
            })
        })
    }
    function p(b) {
        var d = this.getOverlay().hide(),
            a = this.getConf(),
            c = this.getTrigger();
        d = d.data("img");
        var g = {
            top: a.start.top,
            left: a.start.left,
            width: 0
        };
        c && i.extend(g, j(c));
        a.fixed && d.css({
            position: "absolute"
        }).animate({
            top: "+=" + f.scrollTop(),
            left: "+=" + f.scrollLeft()
        }, 0);
        d.animate(g, a.closeSpeed, b)
    }
    k.addEffect("apple", n, p)
})(jQuery);
