/*------------------------------------------------------------------------
 # author    JoomShaper http://www.joomshaper.com
 # copyright Copyright (C) 2010 JoomShaper.com. All Rights Reserved.
 # @license - Copyrighted Commercial Software
 # Websites: http://www.joomshaper.com - http://www.joomxpert.com
 # This file may not be redistributed in whole or significant part
 -------------------------------------------------------------------------*/
window.addEvent("domready", function () {
    var a = new Class({
        initialize: function (d, c) {
            this.height = c;
            this.active = false;
            this.current = false;
            this.previous = false;
            this.open = false;
            this.hider = false;
            this.fx = new Fx.Style(d, "height", {
                transition: Fx.Transitions.Quart.easeOut,
                wait: false
            });
            this.fxs = [];
            this.handles = d.getFirst().getChildren();
            this.blocks = [];
            this.handles.each(function (f, e) {
                this.handles[e].addEvents({
                    mouseenter: this.show.pass([e], this),
                    mouseleave: function (g) {
                        this.hider = this.hide.delay(5, this, [g])
                    }.pass([e], this)
                });
                this.blocks[e] = f.getElement("ul");
                if (this.blocks[e]) {
                    this.fxs[e] = new Fx.Style(this.blocks[e].setOpacity(0), "opacity", {
                        wait: false
                    })
                } else {
                    this.fxs[e] = false
                }
                if (this.fxs[e] && this.handles[e].hasClass("active")) {
                    this.active = e
                }
            }, this);
            if (this.active !== false) {
                this.show(this.active)
            }
        },
        show: function (d) {
            $clear(this.hider);
            this.previous = this.current;
            this.current = d;
            if (this.fxs[this.current]) {
                if (!this.open) {
                    this.open = true;
                    this.fx.start(this.height[1])
                }
                for (var c = 0; c < this.fxs.length; c++) {
                    if (this.fxs[c] && (c === this.current || c === this.previous)) {
                        this.fxs[c].start(c === this.current ? 1 : 0)
                    }
                }
                if (this.active !== false && this.active !== this.current) {
                    this.fxs[this.active].start(0)
                }
            } else {
                this.hide(d, true)
            }
        },
        hide: function (d, e) {
            if (e || (this.open && this.active === false)) {
                this.open = false;
                this.fx.start(this.height[0])
            }
            for (var c = 0; c < this.fxs.length; c++) {
                if (this.fxs[c]) {
                    this.fxs[c].set(0)
                }
            }
            if (this.active !== false && !e) {
                this.show(this.active)
            }
            this.previous = false;
            this.current = false
        }
    });
    var b = new a($("hornav_drop"), [30, 60])
});
