function theme_pagination($urlRoot, $currentPage, $perPage, $totalArticles) {
	if ($totalArticles > $perPage) {
		echo '
			<div class="pageList">
				<b>Pages:</b>
				<ul>';
			
		$lastPage=floor(($totalArticles-1)/$perPage);
		
		if ($lastPage>0) {
			echo '
					<li><a href="', $urlRoot, '">First</a></li>';
			if ($currentPage > 0) {
				echo '
					<li><a
						href="', $urlRoot, '?', $currentPage-1, '"
						class="iconography"
						title="Previous page"
						rel="previous"
					>&#x25C0;</a></li>';
			}
		}
		
		if ($lastPage>9) {
			$counter=($currentpage<6) ? 0 : $currentPage-5;	
			$endPage=$counter+10;
			if ($endPage>$lastPage) $endPage=$lastPage;
		} else {
			$counter=0;
			$endPage=$lastPage;
		}
	
		while ($counter<=$endPage) {
			$noAnchor=($counter==$currentPage);
			echo '
					<li>',(
						$noAnchor ? '<span>' : '<a href="'.$urlRoot.'?'.$counter.'">'
					),++$counter,(
						$noAnchor ? '</span>' : '</a>'
					), '</li>';
		}
		
		if ($lastPage>0) {
			if ($currentPage<$lastPage) {
				echo '
					<li><a
						href="', $urlRoot, '?', $currentPage+1, '"
						class="iconography"
						title="Next page"
						rel="next"
					>&#x25B6;</a></li>';
			}
			echo '
					<li><a href="', $urlRoot, '/', $lastPage, '">Last</a></li>
				</ul>
			<!-- .pageList --></div>';
		}
	}
}