var menuEffects = new Class({
    initialize: function(selector, options) {
        this.options = Object.extend({
            subElement: false,
            subElementSelector: 'a'
        }, options || {})
        this.selector = selector;
        this.currTimer = 400;
        $ES(selector + ' li ul').each(function(el) {
            el.setStyles({
                'display': 'block'
            });
            normalHeight = el.offsetHeight;
            el.setStyles({
                'opacity': '0'
            });
            elParent = $(el.parentNode);

            currentMenu = new Fx.Style(el, 'opacity');
            elParent.addEvents({
                'mouseover': function(submenu, myParent, targetValue) {
                    myParent.addClass('hover');
                    submenu.clearTimer();
                    submenu.custom(targetValue);
                } .pass([currentMenu, elParent, 1]),
                'mouseout': function(submenu, myParent, targetValue) {
                    myParent.removeClass('hover');
                    submenu.clearTimer();
                    submenu.custom(targetValue);
                } .pass([currentMenu, elParent, 0])
            })
        } .bind(this));
    }
});
function processMenuEffects() {
    var myMenus = new menuEffects('#mmenu', {
        subElement: true
    });
}
window.onDomReady(processMenuEffects);

window.addEvent('domready', function() {
    $$('a.fxbutton').each(function(el) {
        var img = el.getElement('img'), running = false;
        var fx2 = new Fx.Morph(img, { duration: 100, link: 'chain', onChainComplete: function() { running = false; } });
        var fx1 = new Fx.Morph(img, { duration: 200, link: 'chain', onComplete: function() {
            fx2.start({ 'top': '-7px' }).start({ 'top': '-4px' }).start({ 'top': '-6px' }).start({ 'top': '-4px' });
        }
        });
        el.addEvent('mouseenter', function() {
            if (!running) {
                fx1.start({ 'top': '-10px' }).start({ 'top': '-4px' });
                running = true;
            }
        });
    });
});

window.addEvent('domready', function() {
    $$('.btn').addEvents({
        'mouseover': function(e) { this.addClass('btn-hover') },
        'mouseout': function(e) { this.removeClass('btn-hover') },
        'mousedown': function(e) { this.addClass('btn-click') },
        'mouseup': function(e) { this.removeClass('btn-click') }
    })
});

function startGallery() {
    var myGallery = new gallery($('myGallery'), {
        timed: true,
        showArrows: false,
        showCarousel: false,
        showInfopane: false,
        delay: 3000
    });
};
window.addEvent('domready', startGallery);