function DetectCSSTransitions() {
    try {
        var a = document.createElement("div").style;
        a.setProperty("-webkit-transition", "inherit", null);
        a.setProperty("-moz-transition", "inherit", null);
        a.setProperty("-o-transition", "inherit", null);
        a.setProperty("-khtml-transition", "inherit", null);
        a.setProperty("transition", "inherit", null);
        return (a.getPropertyValue("-webkit-transition") == "inherit" || a.getPropertyValue("-moz-transition") == "inherit" || a.getPropertyValue("-o-transition") == "inherit" || a.getPropertyValue("-khtml-transition") == "inherit" || a.getPropertyValue("transition") == "inherit")
    } catch (b) {
        return false
    }
}
var PromoBucket = Class.create({
    duration: 0.5,
    initialize: function (b, a) {
        this.id = a;
        this.element = b;
        this.slide = b.down(".slide");
        this.icon = b.down("img");
        this.wrap = b.down(".wrap");
        this.header = b.down("h3");
        this.isOpen = false;
        this.listenForEvents()
    },
    listenForEvents: function () {
        this.eventListener = this.onMouseMove.bind(this);
        document.observe("mousemove", this.eventListener)
    },
    cancelEffects: function (a) {
        var a = Effect.Queues.get(a);
        a.each(function (b) {
            b.cancel()
        })
    },
    onMouseMove: function (a) {
        var b = a.findElement(".bucket");
        if (!b || b != this.element) {
            this.shouldClose = true;
            this.close()
        } else {
            this.shouldClose = false;
            this.open()
        }
    },
    open: function () {
        if (this.isOpen == false && this.opening !== true) {
            this.cancelEffects("promobuckets-slide-" + this.id);
            new Effect.Move(this.slide, {
                x: 0,
                y: (this.slide.hasClassName("oneliner") ? -154 : -130),
                mode: "absolute",
                queue: {
                    scope: "promobuckets-slide-" + this.id
                },
                beforeStart: this.willOpen.bind(this),
                afterFinish: this.didOpen.bind(this),
                duration: this.duration
            })
        }
    },
    willOpen: function () {
        this.opening = true;
        if (!AC.Detector.isIEStrict()) {
            this.cancelEffects("promobuckets-icon-" + this.id);
            new Effect.Opacity(this.icon, {
                from: this.icon.getStyle("opacity"),
                to: 0,
                queue: {
                    scope: "promobuckets-icon-" + this.id
                },
                duration: this.duration
            })
        }
        this.cancelEffects("promobuckets-wrap-" + this.id);
        new Effect.Opacity(this.wrap, {
            from: this.wrap.getStyle("opacity"),
            to: 0.99,
            queue: {
                scope: "promobuckets-wrap-" + this.id
            },
            duration: this.duration
        });
        this.cancelEffects("promobuckets-header-" + this.id);
        new Effect.Morph(this.header, {
            style: "margin-bottom: 8px;",
            queue: {
                scope: "promobuckets-header-" + this.id
            },
            duration: this.duration
        })
    },
    didOpen: function () {
        this.opening = false;
        this.isOpen = true;
        if (this.shouldClose) {
            this.close()
        }
    },
    close: function () {
        if (this.isOpen == true) {
            this.cancelEffects("promobuckets-slide-" + this.id);
            new Effect.Move(this.slide, {
                x: 0,
                y: 0,
                mode: "absolute",
                queue: {
                    scope: "promobuckets-slide-" + this.id
                },
                beforeStart: this.willClose.bind(this),
                afterFinish: this.didClose.bind(this),
                duration: this.duration
            })
        }
    },
    willClose: function () {
        this.isOpen = false;
        this.closing = true;
        if (!AC.Detector.isIEStrict()) {
            this.cancelEffects("promobuckets-icon-" + this.id);
            new Effect.Opacity(this.icon, {
                from: this.icon.getStyle("opacity"),
                to: 1,
                queue: {
                    scope: "promobuckets-icon-" + this.id
                },
                duration: this.duration
            })
        }
        this.cancelEffects("promobuckets-wrap-" + this.id);
        new Effect.Opacity(this.wrap, {
            from: this.wrap.getStyle("opacity"),
            to: 0,
            queue: {
                scope: "promobuckets-wrap-" + this.id
            },
            duration: this.duration
        });
        this.cancelEffects("promobuckets-header-" + this.id);
        new Effect.Morph(this.header, {
            style: "margin-bottom: 20px;",
            queue: {
                scope: "promobuckets-header-" + this.id
            },
            duration: this.duration
        })
    },
    didClose: function () {
        this.closing = false
    }
});
var TouchBucket = Class.create({
    duration: 0.5,
    initialize: function (b, a) {
        this.id = a;
        this.element = b;
        this.isOpen = false;
        this.listenForEvents()
    },
    listenForEvents: function () {
        this.eventListener = this.onClick.bind(this);
        document.observe("click", this.eventListener)
    },
    onClick: function (a) {
        var b = a.findElement(".bucket");
        if (!b || b != this.element) {
            this.close()
        } else {
            if (!this.isOpen) {
                a.stop();
                this.open()
            }
        }
    },
    open: function () {
        this.element.addClassName("open");
        this.isOpen = true
    },
    close: function () {
        this.element.removeClassName("open");
        this.isOpen = false
    }
});
Event.onDOMReady(function () {
    var a = $$(".bucket");
    if (DetectCSSTransitions() === false) {
        a.each(function (c, b) {
            new PromoBucket(c, b)
        })
    } else {
        a.each(function (c, b) {
            c.addClassName("transition");
            if (AC.Detector.isMobile() || AC.Detector.isiPad()) {
                new TouchBucket(c, b)
            }
        })
    }
});