<h2 class="cufon">Boxes</h2>

{if $link[2] == 'edit'}

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

		Content<br>
		<textarea name="text" class="poletxt redactor">{$smarty.post.text}</textarea><br>
                
		<input type="hidden" name="action" value="edit" />
		<input type="submit" value="Save" />

	</form><br>		
	
{elseif $link[2] == 'del'}
			
	<form action="" method="POST" id="del">
		<input type="checkbox" name="confirm"> &nbsp; Delete...<br><br>
		<input type="hidden" name="action" value="del" />
		<input type="submit" value="Delete" />
	</form>
	
{else}

	<form id="search" action="" method="POST">	
		Search<br>
		<input class="poletxt" type="text" name="text" style="width: 250px;" value="{$smarty.session.auth.search.page}">
		<input type="hidden" name="action" value="search" />
		<input type="submit" value="Search" />
		<input type="submit" name="clear" value="Clear" />
		<br><br>
	</form>
	
	{if $list.data}
	
	<table class="t1">			
	<tr>
		<th>Nr</th>
		<th>Title</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>
				{$v.title}
			</td><td style="text-align: center;">
				<a href="{$config.url}admin/boxes/edit/{$k}" title="edit"><img src="{$config.templateImagesDir}admin/edit.png" alt="edit" /></a>
				{if $v.static == 0}
					<a href="{$config.url}admin/boxes/del/{$k}" title="delete"><img src="{$config.templateImagesDir}admin/remove.png" alt="delete" /></a>
				{/if}
				{if $v.prev}
					<a href="{$config.url}admin/boxes/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/boxes/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>Page:
				
				{if $link[2] > 1}
					<a href="{$config.url}admin/boxes/{$link[2]-1}">prev</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/boxes/{$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/boxes/{$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/boxes/{$link[2]+1}">next</a>
				{/if}
				
				<br>
			{/if}	
	
	{else}
	
		No boxes.<br>
	
	{/if}

{/if}