<h2 class="cufon">Advertisements</h2>
	
{if $link[2] == 'edit'}

	<form id="edit" action="" method="POST">		
                Title<br/>
                <b>{$smarty.post.title}</b><br/><br/>
                
                <input type="checkbox" name="active" value="1" {if $smarty.post.active}checked="checked"{/if}/> Active<br/><br/>
                
		Content<br/>
		<textarea name="text" class="poletxt" style="width: 500px; height: 250px;">{$smarty.post.text}</textarea><br/>
                
		<input type="hidden" name="action" value="edit" />
		<input type="submit" value="Save" />

	</form><br>
        
{else}
	
	{if $list.data}
	
	<table class="t1">			
	<tr>
		<th>Nr</th>
		<th>Title</th>
                <th>Active</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;">
                                {if $v.active}Yes{else}No{/if}
			</td><td style="text-align: center;">
				<a href="{$config.url}admin/adverts/edit/{$k}" title="edit"><img src="{$config.templateImagesDir}admin/edit.png" alt="edit" /></a>
			</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/pages/{$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/adverts/{$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/adverts/{$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/adverts/{$link[2]+1}">next</a>
				{/if}
				
				<br>
			{/if}	
	
	{else}
	
		No adverts.<br>
	
	{/if}

{/if}