function toggle_resources(current_element){
    $('#community_content div h3.current_resource').removeClass().addClass('resource');
    $('#community_content #'+current_element+' h3').removeClass().addClass('current_resource');
}

$(document).ready(function(){
    var location_str = location.href;
    var current_page = location_str.replace(/.+[\/]([^\/]+)$/,'$1');
    
    
    switch(current_page){
        case 'parents_place.php'            : $('#community_body').css('background-image','url(./images/bodies/community_body-parents_place.jpg)'); break;
        case 'schools_and_groups.php'       : $('#community_body').css('background-image','url(./images/bodies/community_body-schools_and_groups.jpg)'); break;
        case 'kids_corner.php'              : $('#community_body').css('background-image','url(./images/bodies/community_body-kids_corner.jpg)'); break;
        case 'grants_and_fundraising.php'   : $('#community_body').css('background-image','url(./images/bodies/community_body-grants_and_fundraising.jpg)'); break;
        case 'index.php'                    : $('#community_body').css('background-image','url(./images/bodies/community_body-grants_and_fundraising.jpg)'); break;

        // Phil added these to fix the red/blue folder problem
        case 'resources.php'                : $('#community_body').css('background-image','url(./images/bodies/community_body-schools_and_groups.jpg)'); break;
        case 'cows_calcium_and_cheese.php'  : $('#community_body').css('background-image','url(./images/bodies/community_body-schools_and_groups.jpg)'); break;
        case 'girl_scouts.php'              : $('#community_body').css('background-image','url(./images/bodies/community_body-schools_and_groups.jpg)'); break;
        case 'all-star_chef.php'            : $('#community_body').css('background-image','url(./images/bodies/community_body-schools_and_groups.jpg)'); break;
        case 'free_posters.php'             : $('#community_body').css('background-image','url(./images/bodies/community_body-schools_and_groups.jpg)'); break;
        case 'free_plays.php'               : $('#community_body').css('background-image','url(./images/bodies/community_body-schools_and_groups.jpg)'); break;
        
        case ''                             : $('#community_body').css('background-image','url(./images/bodies/community_body-grants_and_fundraising.jpg)'); break;
        default                             : current_page = '/pages/community_and_you/' ? $('#community_body').css('background-image','url(./images/bodies/community_body-index.jpg)') : $('#community_body').css('background-image','url(./images/bodies/community_body-schools_and_groups.jpg)'); break;
    }
    
    


    $('#community_background').after('<div id="community_footer"></div>');

    $('#folders a[href="schools_and_groups.php"]').bind('mouseover',function(event){ 
        $('#community_menu').removeClass().addClass('showing'); 
        event.stopPropagation(); 
    }); 
    $('#community_folder').bind('mouseover',function(event){ 
        $('#community_menu').removeClass().addClass('hiding'); 
    }); 
        
    function toggle_below(object){
        if($(object).is(':hidden')){ $(object).crossFadeIn('slow'); }
        else{ $(object).crossFadeOut('slow'); }
    }
    
    $('.toggle_below:not([view])').hide();      
    $('div[toggle]').css({'width':'62px','height':'20px','display':'block','overflow':'hidden','background-image':'url(/pages/community_and_you/images/open.gif)','background-repeat':'no-repeat','cursor':'pointer'})
        .toggle(
        function(event){ 
            $(this).css({'background-image':'url(/pages/community_and_you/images/close.gif)'});
            toggle_below('#'+$(this).attr('toggle')); 
        },
        function(event){ 
            $(this).css({'background-image':'url(/pages/community_and_you/images/open.gif)'});
            toggle_below('#'+$(this).attr('toggle'));
        }
    );
});
