$(document).ready(function(){
    
    /**
     * functions for the drop down menu
     */
    
    $("#main_menu li ul li:last").addClass("beef");
    
    $("#main_menu li").hover(
        function(){
            $("ul", this).css("display", "block");
            $("ul", this)
            .hide()
            .slideDown("slow")
            
        },
        function(){
            //$("ul", this).css("display", "none");
            $("ul", this).fadeOut("slow");
        }
        
    );
    
    /**
     * lightbox
     */
    
    function removeLightbox() {
        $('#overlay, #lightbox')
        .fadeOut('slow', function() {
        $(this).remove();
        $('body').css('overflow-y', 'auto'); // show scrollbars!
        });
    }
    
    function positionLightboxImage() {
        var top = ($(window).height() - $('#lightbox').height()) / 2;
        var left = ($(window).width() - $('#lightbox').width()) / 2;
        $('#lightbox')
        .css({
        'top': top + $(document).scrollTop(),
        'left': left
        })
        .fadeIn();
    }
    
    $('a.lightbox').click(function(e) {
        // hide scrollbars!
        $('body').css('overflow-y', 'hidden');
        
        $('<div id="overlay"></div>')
        .css('top', $(document).scrollTop())
        .css('opacity', '0')
        .animate({'opacity': '0.85'}, 'slow')
        .appendTo('body');
        
        $('<div id="lightbox"></div>')
        .hide()
        .appendTo('body');
        
        $('<p>Click image to close</p><img />')
        .attr('src', $(this).attr('href'))
        .load(function() {
        positionLightboxImage();
        })
        .click(function() {
        removeLightbox();
        })
        .appendTo('#lightbox');
        
        return false;
    });
    
    
})
