/*
(function(c){c.tools=c.tools||{};c.tools.overlay={version:"1.1.2",addEffect:function(e,f,g){b[e]=[f,g]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var b={};c.tools.overlay.addEffect("default",function(e){this.getOverlay().fadeIn(this.getConf().speed,e)},function(e){this.getOverlay().fadeOut(this.getConf().closeSpeed,e)});var d=[];function a(g,k){var o=this,m=c(this),n=c(window),j,i,h,e=k.expose&&c.tools.expose.version;var f=k.target||g.attr("rel");i=f?c(f):null||g;if(!i.length){throw"Could not find Overlay: "+f}if(g&&g.index(i)==-1){g.click(function(p){o.load(p);return p.preventDefault()})}c.each(k,function(p,q){if(c.isFunction(q)){m.bind(p,q)}});c.extend(o,{load:function(u){if(o.isOpened()){return o}var r=b[k.effect];if(!r){throw'Overlay: cannot find effect : "'+k.effect+'"'}if(k.oneInstance){c.each(d,function(){this.close(u)})}u=u||c.Event();u.type="onBeforeLoad";m.trigger(u);if(u.isDefaultPrevented()){return o}h=true;if(e){i.expose().load(u)}var t=k.top;var s=k.left;var p=i.outerWidth({margin:true});var q=i.outerHeight({margin:true});if(typeof t=="string"){t=t=="center"?Math.max((n.height()-q)/2,0):parseInt(t,10)/100*n.height()}if(s=="center"){s=Math.max((n.width()-p)/2,0)}if(!k.absolute){t+=n.scrollTop();s+=n.scrollLeft()}i.css({top:t,left:s,position:"absolute"});u.type="onStart";m.trigger(u);r[0].call(o,function(){if(h){u.type="onLoad";m.trigger(u)}});if(k.closeOnClick){c(document).bind("click.overlay",function(w){if(!o.isOpened()){return}var v=c(w.target);if(v.parents(i).length>1){return}c.each(d,function(){this.close(w)})})}if(k.closeOnEsc){c(document).unbind("keydown.overlay").bind("keydown.overlay",function(v){if(v.keyCode==27){c.each(d,function(){this.close(v)})}})}return o},close:function(q){if(!o.isOpened()){return o}q=q||c.Event();q.type="onBeforeClose";m.trigger(q);if(q.isDefaultPrevented()){return}h=false;b[k.effect][1].call(o,function(){q.type="onClose";m.trigger(q)});var p=true;c.each(d,function(){if(this.isOpened()){p=false}});if(p){c(document).unbind("click.overlay").unbind("keydown.overlay")}return o},getContent:function(){return i},getOverlay:function(){return i},getTrigger:function(){return g},getClosers:function(){return j},isOpened:function(){return h},getConf:function(){return k},bind:function(p,q){m.bind(p,q);return o},unbind:function(p){m.unbind(p);return o}});c.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(p,q){o[q]=function(r){return o.bind(q,r)}});if(e){if(typeof k.expose=="string"){k.expose={color:k.expose}}c.extend(k.expose,{api:true,closeOnClick:k.closeOnClick,closeOnEsc:false});var l=i.expose(k.expose);l.onBeforeClose(function(p){o.close(p)});o.onClose(function(p){l.close(p)})}j=i.find(k.close||".close");if(!j.length&&!k.close){j=c('<div class="close"></div>');i.prepend(j)}j.click(function(p){o.close(p)})}c.fn.overlay=function(e){var f=this.eq(typeof e=="number"?e:0).data("overlay");if(f){return f}if(c.isFunction(e)){e={onBeforeLoad:e}}var g=c.extend({},c.tools.overlay.conf);e=c.extend(true,g,e);this.each(function(){f=new a(c(this),e);d.push(f);c(this).data("overlay",f)});return e.api?f:this}})(jQuery);
(function(d){var b=d.tools.overlay;b.effects=b.effects||{};b.effects.apple={version:"1.0.1"};d.extend(b.conf,{start:{absolute:true,top:null,left:null},fadeInSpeed:"fast",zIndex:9999,backgorund-color:#666});function c(f){var g=f.offset();return[g.top+f.height()/2,g.left+f.width()/2]}var e=function(n){var k=this.getOverlay(),f=this.getConf(),i=this.getTrigger(),q=this,r=k.outerWidth({margin:true}),m=k.data("img");if(!m){var l=k.css("backgroundImage");if(!l){throw"background-image CSS property not set for overlay"}l=l.substring(l.indexOf("(")+1,l.indexOf(")")).replace(/\"/g,"");k.css("backgroundImage","none");m=d('<img src="'+l+'"/>');m.css({border:0,position:"absolute",display:"none"}).width(r);d("body").append(m);k.data("img",m)}var o=d(window),j=f.start.top||Math.round(o.height()/2),h=f.start.left||Math.round(o.width()/2);if(i){var g=c(i);j=g[0];h=g[1]}if(!f.start.absolute){j+=o.scrollTop();h+=o.scrollLeft()}m.css({top:j,left:h,width:0,zIndex:f.zIndex}).show();m.animate({top:k.css("top"),left:k.css("left"),width:r},f.speed,function(){k.css("zIndex",f.zIndex+1).fadeIn(f.fadeInSpeed,function(){if(q.isOpened()&&!d(this).index(k)){n.call()}else{k.hide()}})})};var a=function(f){var h=this.getOverlay(),i=this.getConf(),g=this.getTrigger(),l=i.start.top,k=i.start.left;h.hide();if(g){var j=c(g);l=j[0];k=j[1]}h.data("img").animate({top:l,left:k,width:0},i.closeSpeed,f)};b.addEffect("apple",e,a)})(jQuery);
*/

(function (c) {
    c.tools = c.tools || {};
    c.tools.overlay = {
        version: "1.1.2",
        addEffect: function (e, f, g) {
            b[e] = [f, g]
        },
        conf: {
            top: "10%",
            left: "center",
            absolute: false,
            speed: "normal",
            closeSpeed: "fast",
            effect: "default",
            close: null,
            oneInstance: true,
            closeOnClick: true,
            closeOnEsc: true,
            api: false,
            expose: null,
            target: null
        }
    };
    var b = {};
    c.tools.overlay.addEffect("default", function (e) {
        this.getOverlay().fadeIn(this.getConf().speed, e)
    }, function (e) {
        this.getOverlay().fadeOut(this.getConf().closeSpeed, e)
    });
    var d = [];

    function a(g, k) {
        var o = this,
            m = c(this),
            n = c(window),
            j, i, h, e = k.expose && c.tools.expose.version;
        var f = k.target || g.attr("rel");
        i = f ? c(f) : null || g;
        if (!i.length) {
            throw "Could not find Overlay: " + f
        }
        if (g && g.index(i) == -1) {
            g.click(function (p) {
                o.load(p);
                return p.preventDefault()
            })
        }
        c.each(k, function (p, q) {
            if (c.isFunction(q)) {
                m.bind(p, q)
            }
        });
        c.extend(o, {
            load: function (u) {
                if (o.isOpened()) {
                    return o
                }
                var r = b[k.effect];
                if (!r) {
                    throw 'Overlay: cannot find effect : "' + k.effect + '"'
                }
                if (k.oneInstance) {
                    c.each(d, function () {
                        this.close(u)
                    })
                }
                u = u || c.Event();
                u.type = "onBeforeLoad";
                m.trigger(u);
                if (u.isDefaultPrevented()) {
                    return o
                }
                h = true;
                if (e) {
                    i.expose().load(u)
                }
                var t = k.top;
                var s = k.left;
                var p = i.outerWidth({
                    margin: true
                });
                var q = i.outerHeight({
                    margin: true
                });
                if (typeof t == "string") {
                    t = t == "center" ? Math.max((n.height() - q) / 2, 0) : parseInt(t, 10) / 100 * n.height()
                }
                if (s == "center") {
                    s = Math.max((n.width() - p) / 2, 0)
                }
                if (!k.absolute) {
                    t += n.scrollTop();
                    s += n.scrollLeft()
                }
                i.css({
                    top: t,
                    left: s,
                    position: "absolute"
                });
                u.type = "onStart";
                m.trigger(u);
                r[0].call(o, function () {
                    if (h) {
                        u.type = "onLoad";
                        m.trigger(u)
                    }
                });
                if (k.closeOnClick) {
                    c(document).bind("click.overlay", function (w) {
                        if (!o.isOpened()) {
                            return
                        }
                        var v = c(w.target);
                        if (v.parents(i).length > 1) {
                            return
                        }
                        c.each(d, function () {
                            this.close(w)
                        })
                    })
                }
                if (k.closeOnEsc) {
                    c(document).unbind("keydown.overlay").bind("keydown.overlay", function (v) {
                        if (v.keyCode == 27) {
                            c.each(d, function () {
                                this.close(v)
                            })
                        }
                    })
                }
                return o
            },
            close: function (q) {
                if (!o.isOpened()) {
                    return o
                }
                q = q || c.Event();
                q.type = "onBeforeClose";
                m.trigger(q);
                if (q.isDefaultPrevented()) {
                    return
                }
                h = false;
                b[k.effect][1].call(o, function () {
                    q.type = "onClose";
                    m.trigger(q)
                });
                var p = true;
                c.each(d, function () {
                    if (this.isOpened()) {
                        p = false
                    }
                });
                if (p) {
                    c(document).unbind("click.overlay").unbind("keydown.overlay")
                }
                return o
            },
            getContent: function () {
                return i
            },
            getOverlay: function () {
                return i
            },
            getTrigger: function () {
                return g
            },
            getClosers: function () {
                return j
            },
            isOpened: function () {
                return h
            },
            getConf: function () {
                return k
            },
            bind: function (p, q) {
                m.bind(p, q);
                return o
            },
            unbind: function (p) {
                m.unbind(p);
                return o
            }
        });
        c.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function (p, q) {
            o[q] = function (r) {
                return o.bind(q, r)
            }
        });
        if (e) {
            if (typeof k.expose == "string") {
                k.expose = {
                    color: k.expose
                }
            }
            c.extend(k.expose, {
                api: true,
                closeOnClick: k.closeOnClick,
                closeOnEsc: false
            });
            var l = i.expose(k.expose);
            l.onBeforeClose(function (p) {
                o.close(p)
            });
            o.onClose(function (p) {
                l.close(p)
            })
        }
        j = i.find(k.close || ".close");
        if (!j.length && !k.close) {
            j = c('<div class="close"></div>');
            i.prepend(j)
        }
        j.click(function (p) {
            o.close(p)
        })
    }
    c.fn.overlay = function (e) {
        var f = this.eq(typeof e == "number" ? e : 0).data("overlay");
        if (f) {
            return f
        }
        if (c.isFunction(e)) {
            e = {
                onBeforeLoad: e
            }
        }
        var g = c.extend({}, c.tools.overlay.conf);
        e = c.extend(true, g, e);
        this.each(function () {
            f = new a(c(this), e);
            d.push(f);
            c(this).data("overlay", f)
        });
        return e.api ? f : this
    }
})(jQuery);
(function (d) {
    var b = d.tools.overlay;
    b.effects = b.effects || {};
    b.effects.apple = {
        version: "1.0.1"
    };
    d.extend(b.conf, {
        start: {
            absolute: true,
            top: null,
            left: null
        },
        fadeInSpeed: "fast",
        zIndex: 9999
	});
        
	function c(f){var g=f.offset();
        return [g.top + f.height() / 2, g.left + f.width() / 2]
    }
    var e = function (n) {
        var k = this.getOverlay(),
            f = this.getConf(),
            i = this.getTrigger(),
            q = this,
            r = k.outerWidth({
            margin: true
        }),
            m = k.data("img");
        if (!m) {
            var l = k.css("backgroundImage");
            if (!l) {
                throw "background-image CSS property not set for overlay"
            }
            l = l.substring(l.indexOf("(") + 1, l.indexOf(")")).replace(/\"/g, "");
            k.css("backgroundImage", "none");
            m = d('<img src="' + l + '"/>');
            m.css({
                border: 0,
                position: "absolute",
                display: "none"
            }).width(r);
            d("body").append(m);
            k.data("img", m)
        }
        var o = d(window),
            j = f.start.top || Math.round(o.height() / 2),
            h = f.start.left || Math.round(o.width() / 2);
        if (i) {
            var g = c(i);
            j = g[0];
            h = g[1]
        }
        if (!f.start.absolute) {
            j += o.scrollTop();
            h += o.scrollLeft()
        }
        m.css({
            top: j,
            left: h,
            width: 0,
            zIndex: f.zIndex
        }).show();
        m.animate({
            top: k.css("top"),
            left: k.css("left"),
            width: r
        }, f.speed, function () {
            k.css("zIndex", f.zIndex + 1).fadeIn(f.fadeInSpeed, function () {
                if (q.isOpened() && !d(this).index(k)) {
                    n.call()
                } else {
                    k.hide()
                }
            })
        })
    };
    var a = function (f) {
        var h = this.getOverlay(),
            i = this.getConf(),
            g = this.getTrigger(),
            l = i.start.top,
            k = i.start.left;
        h.hide();
        if (g) {
            var j = c(g);
            l = j[0];
            k = j[1]
        }
        h.data("img").animate({
            top: l,
            left: k,
            width: 0
        }, i.closeSpeed, f)
    }; b.addEffect("apple", e, a)
})(jQuery);
