/*
    Horizontal Drop-Down Menus
    Jon Parrott, 2010, Eyesore, Inc
    Requires Prototype and Scriptaculous
*/
Event.observe( document, 'dom:loaded', function(){
    var make_menu = function( selector ){
        $$(selector).each( function( elem ){

            elem.hide();
            elem.hide_timer = 0;

            elem.up().observe( 'mouseover', function(){
                if( this.hide_timer != 0 ){ clearTimeout( this.hide_timer ); }

                if( elem.getStyle('display') == 'none' ) this.appear({duration: 0.3});
            }.bind( elem ));

            elem.up().observe( 'mouseout', function(){
                this.hide_timer = window.setTimeout( function(){
                    this.fade({duration: 0.2});
                }.bind( this ), 300 );
            }.bind( elem ));

        });
    };

    make_menu( '.sub-menu' );
});

