jQuery(document).ready(function($) {
    
    /* Gallery */
    var speed = 200,
        fadeSpeed = 100,
        resetFadesTimeout = undefined;
    
    $('dt').hover(
        function(){
            var current = this,
                next = $(current).next(),
                parent = $(this).parent();
            
            // clear the timeout which resets fades
            clearTimeout(resetFadesTimeout);
            
            // Fade out all, but this one
            $('dt').each(function(){
                $(this).fadeTo(fadeSpeed, (current == this) ? 1 : 0.5)
            });
            
            setTimeout(function(){ 
            	$(parent).find('dd').hide();
            	next.fadeIn(speed);
            }, speed);
        },
        function(){
            $(this).next().fadeOut(speed);
            
            resetFadesTimeout = setTimeout(function(){
                $('dt').each(function(){
                    $(this).fadeTo(fadeSpeed, 1)
                });
            }, speed);
        }
    );
    
});
