<link rel="stylesheet" type="text/css" href="../css/pagination.css" />
<div class="pagination_bar_style">
<?php 

	if($_SESSION['pagination']['current_page']=="")
	{
		$_SESSION['pagination']['current_page']=1;
	}

	$startFrom=$_SESSION['pagination']['current_page'];
	
	$decrementTill=$startFrom-6;
	if($decrementTill<=0)
	{
		$decrementTill=1;
	}					
	$incrementTill=$startFrom+6;

	if($incrementTill>$_SESSION['pagination']['pages'])
	{
		$incrementTill=$_SESSION['pagination']['pages'];
	}
					
	if($_SESSION['pagination']['current_page'] >7)
	{
?>
		<a href="?page=<?php echo '1'; ?>&items=<?php 
			if(isset($_GET['items']))
			{
				echo $_GET['items'];
			}
			else
			{
				echo $_SESSION['pagination']['limit'];
			} ?>" class="button_style">
			<div>
				First
			</div>
		</a>
		<a href="?page=<?php echo $prev = $decrementTill-1; ?>&items=<?php 
			if(isset($_GET['items']))
			{
				echo $_GET['items'];
			}
			else
			{
				echo $_SESSION['pagination']['limit'];
			} ?>" class="button_style">
			<div>
				Previous
			</div>
		</a>
<?php 
	}
?>
<?php

	if(isset($_SESSION['pagination']['pages']))
	{
		if($startFrom>1)					
		{
			for($i = $decrementTill; $i <= $startFrom-1; $i++)
			{
			?>
				<a href="?page=<?php echo $i; ?>&items=<?php 
					if(!isset($_GET['items']) OR $_GET['items'] == '')
					{
						echo $_SESSION['pagination']['limit'];
					}
					else
					{
						echo $_GET['items'];
					}?>"<?php
				if($_SESSION['pagination']['current_page'] == $i)
				{
					echo 'class="numbering_style_selected"';
				}
				else
				{
					echo 'class="numbering_style"';
				}
	?>>
					<div>
						<?php echo $i; ?>
					</div>
				</a>
	<?php
			}
			
			unset($i);
		}
		
		for($i = $startFrom; $i<= $incrementTill; $i++)
		{
			?>
						<a href="?page=<?php echo $i; ?>&items=<?php 
							if(!isset($_GET['items']) OR $_GET['items'] == '')
							{
								echo $_SESSION['pagination']['limit'];
							}
							else
							{
								echo $_GET['items'];
							}?>"<?php
						if($_SESSION['pagination']['current_page'] == $i)
						{
							echo 'class="numbering_style_selected"';
						}
						else
						{
							echo 'class="numbering_style"';
						}
			?>>
							<div>
								<?php echo $i; ?>
							</div>
						</a>
			<?php
					}
	}
?>
<?php 
	if($_SESSION['pagination']['current_page'] < $_SESSION['pagination']['pages']-6)
	{
?>
		<a href="?page=<?php echo $next = $incrementTill+1; ?>&items=<?php 
			if(isset($_GET['items']))
			{
				echo $_GET['items'];
			}
			else
			{
				echo $_SESSION['pagination']['limit'];
			} ?>" class="button_style">
			<div>
				Next
			</div>
		</a>
		<a href="?page=<?php echo $_SESSION['pagination']['pages']; ?>&items=<?php 
			if(isset($_GET['items']))
			{
				echo $_GET['items'];
			}
			else
			{
				echo $_SESSION['pagination']['limit'];
			} ?>" class="button_style">
			<div>
				Last
			</div>
		</a>
<?php 
	}
?>
</div>