function ShowNavigator($a, $offset, $q, $path, &$out)
{
//shows navigator [prev] 1 2 3 4 … [next]
//$a - count of elements in the array, which is being navigated
//$offset - current offset in array (showing elements [$offset ... $offset+$q])
//$q - quantity of items per page
//$path - link to the page (f.e: "index.php?categoryID=1&")
if ($a > $q) //if all elements couldn't be placed on the page
{
//[prev]
if ($offset>0) $out .= "[COLOR="Red"]<a class=no_underline [/COLOR]href=\"".$path."offset=".($offset-$q)."\"><< ".STRING_PREVIOUS."</a> ";
//digital links
$k = $offset / $q;
//not more than 4 links to the left
$min = $k - 5;
if ($min < 0) { $min = 0; }
else {
if ($min >= 1)
{ //link on the 1st page
$out .= "[COLOR="Red"]<a class=no_underline [/COLOR]href=\"".$path."offset=0\">1</a> ";
if ($min != 1) { $out .= "... "; };
}
}
for ($i = $min; $i<$k; $i++)
{
$m = $i*$q + $q;
if ($m > $a) $m = $a;
$out .= "<a [COLOR="Red"]class=no_underline[/COLOR] href=\"".$path."offset=".($i*$q)."\">".($i+1)."</a> ";
}
//# of current page
if (strcmp($offset, "show_all"))
{
$min = $offset+$q;
if ($min > $a) $min = $a;
$out .= "[COLOR="Red"]<font class=faq>[/COLOR]<b>".($k+1)."</b></font> ";
}
else
{
$min = $q;
if ($min > $a) $min = $a;
$out .= "<a [COLOR="Red"]class=no_underline [/COLOR]href=\"".$path."offset=0\">1</a> ";
}
//not more than 5 links to the right
$min = $k + 6;
if ($min > $a/$q) { $min = $a/$q; };
for ($i = $k+1; $i<$min; $i++)
{
$m = $i*$q+$q;
if ($m > $a) $m = $a;
$out .= "<a [COLOR="Red"]class=no_underline [/COLOR]href=\"".$path."offset=".($i*$q)."\">".($i+1)."</a> ";
}
if ($min*$q < $a) { //the last link
if ($min*$q < $a-$q) $out .= " ... ";
$out .= "<a class=no_underline href=\"".$path."offset=".($a-$a%$q)."\">".(floor($a/$q)+1)."</a> ";
}
//[next]
if (strcmp($offset, "show_all"))
if ($offset<$a-$q) $out .= "<a [COLOR="Red"]class=no_underline[/COLOR] href=\"".$path."offset=".($offset+$q)."\">".STRING_NEXT." >></a> ";
//[show all]
if (strcmp($offset, "show_all"))
$out .= " | <a [COLOR="Red"]class=no_underline [/COLOR]href=\"".$path."show_all=yes\">".STRING_SHOWALL."</a>";
else
$out .= " | <B>".STRING_SHOWALL."</B>";
}
}