jQuery(function($) {

    $('.box_main .textblock')
        .each(function(){
            $(this).addClass('hide_me');
        });

    $('.box_main h2')
        .bind('click', function(){

            var curr_block = $(this).next();
            var display = curr_block.css('display');
            var index = $('.box_main h2').index(this);

            if(display == 'none') {

                $(this).addClass('open');

                if($('.box_main .textblock:not(:eq('+index+'))').length > 0) {

                    $('.box_main .textblock:not(:eq('+index+'))')
                        .slideUp('slow', function(){
                            curr_block
                                .slideDown('slow');
                        })
                        .prev()
                        .removeClass('open');
                }
                else {
                    curr_block.slideDown('slow');
                }
            }
            else {
                $(this).removeClass('open');
                curr_block.slideUp('slow');
            }
        });
});