<div class="list half_width">
{foreach $ms_array as $ms}
    {if
    $ms@first ||
    (
    $ms_array[$ms@index]->get_ms_season()->get_mss_id() != $ms_array[$ms@index-1]->get_ms_season()->get_mss_id()
    )

    }
    {if !$ms@first &&
    $ms_array[$ms@index]->get_ms_season()->get_mss_id() != $ms_array[$ms@index-1]->get_ms_season()->get_mss_id()
    }
    </div>
    {/if}


    <span onclick="block_action('block_{$ms_array[$ms@index]->get_ms_season()->get_mss_id()}');" class="date_separator clickable">
        <div class="full full_block_{$ms_array[$ms@index]->get_ms_season()->get_mss_id()}">
            {nl2br($ms_array[$ms@index]->get_ms_season()->get_mss_text())}
        </div>
        <div class="short short_block_{$ms_array[$ms@index]->get_ms_season()->get_mss_id()}">
            {assign var=someVar value="\n"|explode:$ms_array[$ms@index]->get_ms_season()->get_mss_text()}
            {$someVar[0]}
        </div>
        <img src="/_image/open_folder.png">
    </span>
    <div id="block_{$ms_array[$ms@index]->get_ms_season()->get_mss_id()}" class="month_block">
    {/if}

    {if $ms->get_ms_training_mst_id() != null}
        <a>
            <div class="list_item training">
                <img src="/_image/training.png">
                <strong><span style="display: block;">Edzés</span></strong><br>
                {$ms->get_ms_training_mst_id()->get_mst_date()}<br>
                {$ms->get_ms_training_mst_id()->get_mst_count()}<br>
                {nl2br($ms->get_ms_training_mst_id()->get_mst_trainings())}
            </div>
        </a>
    {elseif $ms->get_ms_competition_msc_id() != null}
        <a>
            <div class="list_item competition">
                <img src="/_image/competition.png">
                <strong><span class="bold" style="display: block;">Verseny</span></strong><br>
                {$ms->get_ms_competition_msc_id()->get_msc_date()}<br>
                {$ms->get_ms_competition_msc_id()->get_msc_name()}<br>
                {$ms->get_ms_competition_msc_id()->get_msc_category()}<br>
                {$ms->get_ms_competition_msc_id()->get_msc_place()}<br>
                {if $ms->get_ms_competition_msc_id()->get_msc_matches() != null}
                    <span class="bold">Mérkőzések:</span><br>
                    {nl2br($ms->get_ms_competition_msc_id()->get_msc_matches())}
                {/if}
            </div>
        </a>
    {elseif $ms->get_ms_camp_msca_id() != null}
        <a>
            <div class="list_item camp">
                <img src="/_image/camp.png">
                <strong><span class="bold" style="display: block;">Edzőtábor</span></strong><br>
                {$ms->get_ms_camp_msca_id()->get_msca_date()}<br>
                {$ms->get_ms_camp_msca_id()->get_msca_place()}<br>
            </div>
        </a>
    {elseif $ms->get_ms_ranking_msr_id() != null}
        <a>
            <div class="list_item ranking">
                <img src="/_image/ranking.png">
                <strong><span class="bold" style="display: block;">Ranglista</span></strong><br>
                {$ms->get_ms_ranking_msr_id()->get_msr_date()}<br>
                {nl2br($ms->get_ms_ranking_msr_id()->get_msr_rankings())}
            </div>
        </a>
    {/if}


    {if $ms@last}
    </div>
    {/if}
{/foreach}

</div>

<script>

function open_block(block_id) {
    $("#"+block_id).slideDown("slow");
    $(".full_"+block_id).hide();
    $(".short_"+block_id).show();
    $(".short_"+block_id).css('display', 'inline-block');
}

function close_block(block_id) {
    $("#"+block_id).slideUp("slow");
    $(".full_"+block_id).show();
    $(".short_"+block_id).hide();
    $(".full_"+block_id).css('display', 'inline-block');
}

function block_action(block_id) {
    if ($("#"+block_id).is(':hidden')) {
        open_block(block_id);
    }
    else {
        close_block(block_id);
    }
}


$( document ).ready(function() {
    var divs = $( "div[class=month_block]" );
    $( ".list" ).find( divs ).hide();
    var div_list = $( ".list" ).find( divs );

    open_block(div_list[0].id);

});

</script>
