<div class="buttons">
	<div class="buttons">
		<a href="/admin/create/camp" class="addbutton add-big">Új tábor létrehozása</a>
		<a href="/admin/camp_types" class="addbutton add-big">Tábor típusok</a>
		<a href="/admin/camp_shirt_type" class="addbutton add-big">Pólók</a>
		<a href="/admin/camp_user" class="addbutton add-big">Táborvezetők</a>
		<a href="/admin/camp_details" class="addbutton add-big">Turnus lista</a>
	</div>
</div>
<div class="list full_width">
	{foreach $camp_array as $camp}
		{if 
		$camp@first ||
		(
		$camp_array[$camp@index]->get_camp_to()|substr:5:2 != $camp_array[$camp@index-1]->get_camp_to()|substr:5:2 
		)
		
		}
		{if !$camp@first && 
		$camp_array[$camp@index]->get_camp_to()|substr:5:2 != $camp_array[$camp@index-1]->get_camp_to()|substr:5:2
		}
		</div>
		{/if}
		<span onclick="block_action('block_{$camp->get_camp_to()|substr:0:4}{$camp->get_camp_to()|substr:5:2}');" class="date_separator clickable">{$camp_array[$camp@index]->get_camp_to()|substr:0:4}. 
			{$months[$camp_array[$camp@index]->get_camp_to()|substr:5:2]}
			<img src="/_image/open_folder.png">
		</span>
		<div id="block_{$camp->get_camp_to()|substr:0:4}{$camp->get_camp_to()|substr:5:2}" class="month_block">
		{/if}
		<a href="/admin/camps/{$camp->get_camp_id()}">
			<div class="list_item" {if $camp->has_pending_apply() || $camp->has_deleted_apply()}style="background-color: #ff9205;"{/if}>
				<img src="/_image/camp.png">
				{$camp->get_camp_from()|substr:0:4}.
				{$months[$camp->get_camp_from()|date_format:"%m"]} {$camp->get_camp_from()|date_format:"%e"}. - 
				{if $camp->get_camp_from()|date_format:"%m" != $camp->get_camp_to()|date_format:"%m"}
					{$months[$camp->get_camp_to()|date_format:"%m"]}.
				{/if}
				{$camp->get_camp_to()|date_format:"%e"}., {$camp->get_camp_type()->get_ct_name()}


				({$camp->get_camp_city()})

				{if $camp->has_pending_apply()}
				<span class="pending">[{$camp->has_pending_apply()} új jelentkezés]</span>
				{/if}
				{if $camp->has_deleted_apply()}
				<span class="pending">[{$camp->has_deleted_apply()} törölt jelentkezés]</span>
				{/if}
			</div>
		</a>
		{if $camp@last}
		</div>
		{/if}
	{/foreach}

</div>

<script>

function open_block(block_id) {
	$("#"+block_id).slideDown("slow");
}

function close_block(block_id) {
	$("#"+block_id).slideUp("slow");
}

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);
	//alert(div_list.length);
	for (var i = 0; i <= div_list.length - 1; i++) {
		open_block(div_list[i].id);
	}
	
});


</script>