<h2 class="cufon">Photo Galleries</h2>

{if $link[2] == 'add'}
		
	<form id="add" action="" method="POST">		
		
		Gallery name<br>
		<input type="text" name="name" value="{$smarty.post.name}" class="poletxt" style="width: 500px;"><br><br>	
	
		<input type="hidden" name="action" value="add" />
		<input type="submit" value="Add" />

	</form>		
	
{elseif $link[2] == 'edit'}

	<form id="edit" action="" method="POST">		
		
		Gallery name<br>
		<input type="text" name="name" value="{$smarty.post.name}" class="poletxt" style="width: 500px;"><br><br>	
	
		<input type="hidden" name="action" value="edit" />
		<input type="submit" value="Save" />

	</form>
	
	<br><h2 class="cufon" style="margin: 0 0 10px;">Pictures in the Gallery</h2>
	
	<a href="{$config.url}admin/photos/{$link[3]}">Go to the pictures (click)</a><br><br>

	
{elseif $link[2] == 'del'}
			
	{if $block}
		There are pictures in the gallery. Remove them firs. <a href="{$config.url}admin/photos/{$link[3]}">Click here to go to the pictures</a>.		
	{else}		
		<form action="" method="POST" id="del">
			<input type="checkbox" name="confirm"> &nbsp; Remove this...<br><br>
			<input type="hidden" name="action" value="del" />
			<input type="submit" value="Usuń" />
		</form>
	{/if}
	
{else}
	
	{if $list.data}
	
	<table class="t1">			
	<tr>
		<th>No</th>
		<th>Name</th>
		<th>Options</th>
	</tr>
	
	{assign var='i' value=1}
	{foreach from=$list.data key=k item=v}
		
		<tr>
			<td style="text-align: center;">
				{$i+$link[2]*$config.perpage-$config.perpage}
			</td><td>
				<a href="{$config.url}admin/photos/{$k}" title="Modify pictures in the gallery">
					{$v.name}
				</a>
			</td>
			<td style="text-align: center;">
				<a href="{$config.url}admin/galleries/edit/{$k}" title="edit"><img src="{$config.templateImagesDir}admin/edit.png" alt="edit" /></a>
				<a href="{$config.url}admin/photos/{$k}" title="pictures"><img src="{$config.templateImagesDir}admin/images.png" alt="pictures" /></a>
				{if !$v.static}
                                    <a href="{$config.url}admin/galleries/del/{$k}" title="remove"><img src="{$config.templateImagesDir}admin/remove.png" alt="remove" /></a>
                                {/if}
				{if $v.prev}
					<a href="{$config.url}admin/galleries/swap/{$v.order}/{$v.prev}" title="up"><img src="{$config.templateImagesDir}admin/up.png" alt="up" /></a>
				{/if}
				{if $v.next}
					<a href="{$config.url}admin/galleries/swap/{$v.order}/{$v.next}" title="down"><img src="{$config.templateImagesDir}admin/down.png" alt="down" /></a>
				{/if}				
			</td>
		</tr>
		{assign var='i' value=$i+1}
			
	{/foreach}
	
	</table>
	
			{if $list.pages > 1}
				
				<br>Strona:
				
				{if $link[2] > 1}
					<a href="{$config.url}admin/galleries/{$link[2]-1}">previuos</a>
				{/if}
			
				{if $list.pages < 8}
				
					{section name=loop start=1 loop=$list.pages+1} 
					
						{if $smarty.section.loop.index == $link[2]}
							<span style="color: green; font-size: 20px;">{$smarty.section.loop.index}</span>&nbsp;
						{else}
							<span><a style="text-decoration: none;" href="{$config.url}admin/galleries/{$smarty.section.loop.index}">{$smarty.section.loop.index}</a></span>&nbsp;
						{/if}
					
					{/section}
					
				{else}
				
					{if $link[2] < 4}
						{assign var=sta value=1}
						{assign var=sto value=8}
						{assign var=tail value=' ...'}
					{elseif $link[2]+3 > $list.pages}
						{assign var=sta value=$list.pages-7+1}
						{assign var=sto value=$list.pages+1}
						{assign var=head value='... '}
					{else}
						{assign var=head value='... '}
						{assign var=sta value=$link[2]-3}
						{assign var=sto value=$link[2]+3+1}
						{assign var=tail value=' ...'}
					{/if}
					
					{$head}
					
					{section name=loop start=$sta loop=$sto} 
					
						{if $smarty.section.loop.index == $link[2]}
							<span style="color: green; font-size: 20px;">{$smarty.section.loop.index}</span>&nbsp;
						{else}
							<span><a style="text-decoration: none;" href="{$config.url}admin/galleries/{$smarty.section.loop.index}">{$smarty.section.loop.index}</a></span>&nbsp;
						{/if}
					
					{/section}
					
					{$tail}					
					
				{/if}
				
				{if $link[2] < $list.pages}
					<a href="{$config.url}admin/galleries/{$link[2]+1}">next</a>
				{/if}
				
				<br>
			{/if}	
	
	{else}
	
		No galleries.<br>
	
	{/if}
	
	<br>
	
	<form id="search" action="{$config.url}admin/galleries/add" method="GET">
		<input type="submit" value="Add Gallery" />
	</form>

{/if}