$(function() {
        
        // bottom tabs    
        $('.story').css('display');    
    	$('#bottomNav li a').click(function(e) {
		    e.preventDefault();
            
            var target = $(this).attr('href');
            if($('#tabbedWrapper').css('opacity') < 1) $('#tabbedWrapper').css('opacity', '1'); // preventing from clicking around simultaneously
            
            if($(this).attr('id').indexOf('on') < 0) {
                $(this).parents('#bottomNav').find('a').each(function() {                
                   if($(this).attr('id').indexOf('on') > -1) {
                       var test = $(this).attr('id').split('_');
                       $(this).attr('id', test[0]);
                    }
                });
                
                $('.tabbed').fadeOut(500);
                $('#tabbedWrapper').stop().fadeOut(500, function() {
                    $('#bottomNav li a').filter(function() {
                                            return $(this).attr('id') == target;})
                                        .attr('id', target + '_on');
                    
                    $('div.' + target).css('display', 'block');
                    if($('div.' + target).css('opacity') < 1) $('div.' + target).css('opacity', '1'); // preventing from clicking around simultaneously
                    $('#tabbedWrapper').fadeIn(500);
                });
            }
		});
        
        // selecting characters
        $('#select').find('a').click(function(e) {
                e.preventDefault();
                var target = $(this).parent().attr('class');
                if(!$(this).hasClass('active')) {
                        $(this).parents('#select').find('a').removeClass('active');
                        $(this).attr('class', 'active');
                        $('#desc').find('div').hide().fadeOut(100, function() {
                                $('#desc', '.tabbed').find('div#' + target).css('display', 'block').fadeIn(300);          
                        });
                }
        });
        
});