<?

define("ITEMS",10);

class nav{

public static function start($all){
define("pgs",ceil($all/ITEMS));
if(isset($_GET['page'])){ define("pg",intval($_GET['page'])); }else{ define("pg",1); }
define("from",(pg-1)*ITEMS);
}

public static function l(){
return "LIMIT ".from.", ".ITEMS."";
}

public static function end($link='?'){
if(pgs>1){
if(pg<1)define("pg",1);
echo "<div class='pages'>Стр: ";
if(pg!=1)echo "<span class='page_end'><a href='".$link."page=1'>1</a></span>";else echo "<span class='action_page'>1</span>";
for($pgg=-3; $pgg<=3; $pgg++){
if(pg+$pgg>1 && pg+$pgg<pgs){
if($pgg==-3 && pg+$pgg>2)echo "<span class='page'>..</span>";
if($pgg!=0)
echo "<span class='page'><a href='".$link."page=".(pg+$pgg)."'>".(pg+$pgg)."</a></span>";
else 
echo "<span class='action_page'>".(pg+$pgg)."</span>";
if($pgg==3 && pg+$pgg<pgs-1)
echo "<span class='page'>..</span>";}
}
if(pg!=pgs)
echo "<span class='page_end'><a href=\"".$link."page=".(pgs)."\" >".pgs."</a></span>";
elseif(pgs>1)
echo "<span class='action_page'>".pgs."</span>";
echo "</div>";
}
}
}
?>