<?php
if(!defined('AUTHACCESS')){echo "Not Allowed";exit();}

if ($total_item_count > $thumbs_per_page) {

	$numofpages = ceil($total_item_count/$thumbs_per_page);

		$pgn_totalPages = $numofpages;

		echo '<div class="pagination_container">';


		if($pgn_currentPage < 4) {
			$startpage = 1;
		}
		else {
			$startpage = $pgn_currentPage - 3;

		}
		$xend = $startpage + 10;
		$xend+1;
		if($xend > $numofpages) {
			
			$xend = $numofpages + 1;
		}

		
		if(!array_key_exists("page", $clean_req)) {
			$pgn_currentPage=1;
		}

		for ($i=$startpage;$i<$xend;$i++) {

			if ($i == $pgn_currentPage) {

				if (!empty($words)) {
					$s_wds = implode("-",$words);
					echo "<a class=\"pgn_links_current\" href=\"$site_directory/search/$media_type/" . $checkfeed . "/$s_wds". "/$i$theme\">$i</a>";
				}else{
					echo "<a class=\"pgn_links_current\" href=\"$site_directory/$media_type/" . $checkfeed . "/$i$theme\">$i</a>";
				}
				
			} else {
				if (!empty($words)) {
					$s_wds = implode("-",$words);
					echo "<a class=\"pgn_links\" href=\"$site_directory/search/$media_type/" . $checkfeed . "/$s_wds". "/$i$theme\">$i</a>";
				}else{

					echo "<a class=\"pgn_links\" href=\"$site_directory/$media_type/" . $checkfeed . "/$i$theme\">$i</a>";
				}

			}
		}



		echo "</div>";
}








?>
