$(document).ready(function()
{       
    $('block').hide().parent().children('a').click(function()
    {
        //one open at a time...
        if($(this).parent().hasClass('sub-block'))
        {
            var $as = $(this).parent().children('a');
            var $index = $as.index($(this));
            $as.each(function()
            {
                if($(this).next().is(':visible'))
                {
                    if($as.index($(this))!==$index)
                    {
                        $(this).next().slideToggle(500);
                    }
                }
            });
        }
        else
        {
            if($(this).next().hasClass('sub-block'))
            {
                $(this).next().children('div:visible').slideToggle(500);
            }
            $(this).parent().siblings().has('div:visible').children('div').slideToggle(500);
        }
        
        var $toggle = $(this).next().slideToggle(500);
        if($toggle.children('img').size()>0)
        {
            var $delay = 0;
            $toggle.children('img').each(function()
            {
                $(this).hide().delay($delay).fadeIn(800);
                $delay += 500;
            });
        }
        return false;
    });
    
    $('first').eq(0).slideToggle(500);
});