$( function() {
    var textTimer = false;
    
    $( '.preview-icon' ).on( 'mouseover', function() {
        var $self = $( this );
        var $text = $( '.noun' ).first(); 
        var newText = $self.data( 'text' );
        
        if( newText == $text.text() ) {
            return;
        }
        
        fadeTextTo( newText );
        
        clearTimeout( textTimer );
        
        textTimer = setTimeout( function() {
            fadeTextTo( 'resources' );
        }, 5000 );
    });
        
    function fadeTextTo( newText ) {
        $( '.noun' ).hide( 'drop', { direction: 'down' }, function() { $( this ).remove(); } );
        $( '<span style="display:none;">'+newText+'</span>' )
            .addClass( 'noun' )
            .appendTo( '#nounContainer' ).show( 'drop', { direction: 'up' } );
    }
});
;

