﻿//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <http://mad4milk.net> & the MooTools team <http://mootools.net/developers>, MIT Style License.

MooTools.More = { version: "1.2.3.1" }; Fx.Elements = new Class({ Extends: Fx.CSS, initialize: function(b, a) { this.elements = this.subject = $$(b); this.parent(a); }, compute: function(g, h, j) {
    var c = {};
    for (var d in g) { var a = g[d], e = h[d], f = c[d] = {}; for (var b in a) { f[b] = this.parent(a[b], e[b], j); } } return c;
}, set: function(b) {
    for (var c in b) {
        var a = b[c]; for (var d in a) {
            this.render(this.elements[c], d, a[d], this.options.unit);
        } 
    } return this;
}, start: function(c) {
    if (!this.check(c)) { return this; } var h = {}, j = {}; for (var d in c) {
        var f = c[d], a = h[d] = {}, g = j[d] = {}; for (var b in f) {
            var e = this.prepare(this.elements[d], b, f[b]);
            a[b] = e.from; g[b] = e.to;
        } 
    } return this.parent(h, j);
} 
}); var Accordion = Fx.Accordion = new Class({ Extends: Fx.Elements, options: { display: 0, show: false, height: true, width: false, opacity: true, fixedHeight: false, fixedWidth: false, wait: false, alwaysHide: false, trigger: "click", initialDisplayFx: true }, initialize: function() {
    var c = Array.link(arguments, { container: Element.type, options: Object.type, togglers: $defined, elements: $defined });
    this.parent(c.elements, c.options); this.togglers = $$(c.togglers); this.container = document.id(c.container); this.previous = -1; if (this.options.alwaysHide) {
        this.options.wait = true;
    } if ($chk(this.options.show)) { this.options.display = false; this.previous = this.options.show; } if (this.options.start) {
        this.options.display = false; this.options.show = false;
    } this.effects = {}; if (this.options.opacity) { this.effects.opacity = "fullOpacity"; } if (this.options.width) {
        this.effects.width = this.options.fixedWidth ? "fullWidth" : "offsetWidth";
    } if (this.options.height) { this.effects.height = this.options.fixedHeight ? "fullHeight" : "scrollHeight"; } for (var b = 0, a = this.togglers.length; b < a; b++) {
        this.addSection(this.togglers[b], this.elements[b]);
    } this.elements.each(function(e, d) {
        if (this.options.show === d) { this.fireEvent("active", [this.togglers[d], e]); } else {
            for (var f in this.effects) {
                e.setStyle(f, 0);
            } 
        } 
    }, this); if ($chk(this.options.display)) { this.display(this.options.display, this.options.initialDisplayFx); } 
}, addSection: function(d, b) {
    d = document.id(d);
    b = document.id(b); var e = this.togglers.contains(d); this.togglers.include(d); this.elements.include(b); var a = this.togglers.indexOf(d); d.addEvent(this.options.trigger, this.display.bind(this, a));
    if (this.options.height) { b.setStyles({ "padding-top": 0, "border-top": "none", "padding-bottom": 0, "border-bottom": "none" }); } if (this.options.width) {
        b.setStyles({ "padding-left": 0, "border-left": "none", "padding-right": 0, "border-right": "none" });
    } b.fullOpacity = 1; if (this.options.fixedWidth) { b.fullWidth = this.options.fixedWidth; } if (this.options.fixedHeight) { b.fullHeight = this.options.fixedHeight; } b.setStyle("overflow", "hidden");
    if (!e) { for (var c in this.effects) { b.setStyle(c, 0); } } return this;
}, display: function(a, b) {
    b = $pick(b, true); a = ($type(a) == "element") ? this.elements.indexOf(a) : a;
    if ((this.timer && this.options.wait) || (a === this.previous && !this.options.alwaysHide)) { return this; } this.previous = a; var c = {}; this.elements.each(function(f, e) {
        c[e] = {};
        var d = (e != a) || (this.options.alwaysHide && (f.offsetHeight > 0)); this.fireEvent(d ? "background" : "active", [this.togglers[e], f]); for (var g in this.effects) {
            c[e][g] = d ? 0 : f[this.effects[g]];
        } 
    }, this); return b ? this.start(c) : this.set(c);
} 
}); Fx.Slide = new Class({ Extends: Fx, options: { mode: "vertical" }, initialize: function(b, a) {
    this.addEvent("complete", function() {
        this.open = (this.wrapper["offset" + this.layout.capitalize()] != 0);
        if (this.open && Browser.Engine.webkit419) { this.element.dispose().inject(this.wrapper); } 
    }, true); this.element = this.subject = document.id(b); this.parent(a); var c = this.element.retrieve("wrapper");
    this.wrapper = c || new Element("div", { styles: $extend(this.element.getStyles("margin", "position"), { overflow: "hidden" }) }).wraps(this.element); this.element.store("wrapper", this.wrapper).setStyle("margin", 0);
    this.now = []; this.open = true;
}, vertical: function() { this.margin = "margin-top"; this.layout = "height"; this.offset = this.element.offsetHeight; }, horizontal: function() {
    this.margin = "margin-left";
    this.layout = "width"; this.offset = this.element.offsetWidth;
}, set: function(a) {
    this.element.setStyle(this.margin, a[0]); this.wrapper.setStyle(this.layout, a[1]);
    return this;
}, compute: function(c, b, a) { return [0, 1].map(function(d) { return Fx.compute(c[d], b[d], a); }); }, start: function(b, e) {
    if (!this.check(b, e)) {
        return this;
    } this[e || this.options.mode](); var d = this.element.getStyle(this.margin).toInt(); var c = this.wrapper.getStyle(this.layout).toInt(); var a = [[d, c], [0, this.offset]];
    var g = [[d, c], [-this.offset, 0]]; var f; switch (b) { case "in": f = a; break; case "out": f = g; break; case "toggle": f = (c == 0) ? a : g; } return this.parent(f[0], f[1]);
}, slideIn: function(a) {
    return this.start("in", a);
}, slideOut: function(a) { return this.start("out", a); }, hide: function(a) { this[a || this.options.mode](); this.open = false; return this.set([-this.offset, 0]); }, show: function(a) {
    this[a || this.options.mode]();
    this.open = true; return this.set([0, this.offset]);
}, toggle: function(a) { return this.start("toggle", a); } 
}); Element.Properties.slide = { set: function(b) {
    var a = this.retrieve("slide");
    if (a) { a.cancel(); } return this.eliminate("slide").store("slide:options", $extend({ link: "cancel" }, b));
}, get: function(a) {
    if (a || !this.retrieve("slide")) {
        if (a || !this.retrieve("slide:options")) {
            this.set("slide", a);
        } this.store("slide", new Fx.Slide(this, this.retrieve("slide:options")));
    } return this.retrieve("slide");
} 
}; Element.implement({ slide: function(d, e) {
    d = d || "toggle";
    var b = this.get("slide"), a; switch (d) {
        case "hide": b.hide(e); break; case "show": b.show(e); break; case "toggle": var c = this.retrieve("slide:flag", b.open); b[c ? "slideOut" : "slideIn"](e);
            this.store("slide:flag", !c); a = true; break; default: b.start(d, e);
    } if (!a) { this.eliminate("slide:flag"); } return this;
} 
});