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) {
        //[prev]
        if ($offset > 0) {
            $out .= "<a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=" . ($offset - $q)) . "\">&lt;&lt; " . translate("str_previous") . "</a> &nbsp;&nbsp;";
        }
        //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 .= "<a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=0") . "\">1</a> &nbsp;&nbsp;";
                if ($min != 1) {
                    $out .= "... &nbsp;";
                }
            }
        }
        for ($i = $min; $i < $k; $i++) {
            $m = $i * $q + $q;
            if ($m > $a) {
                $m = $a;
            }
            $out .= "<a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=" . $i * $q) . "\">" . ($i + 1) . "</a> &nbsp;&nbsp;";
        }
        //# of current page
        if (strcmp($offset, "show_all")) {
            $min = $offset + $q;
            if ($min > $a) {
                $min = $a;
            }
            $out .= "<font class=faq><b>" . ($k + 1) . "</b></font> &nbsp;&nbsp;";
        } else {
            $min = $q;
            if ($min > $a) {
                $min = $a;
            }
            $out .= "<a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=0") . "\">1</a> &nbsp;&nbsp;";
        }
        //not more than 5 links to the right
        $min = $k + 6;
        if ($min > ceil($a / $q)) {
            $min = ceil($a / $q);
        }
        for ($i = $k + 1; $i < $min; $i++) {
            $m = $i * $q + $q;
            if ($m > $a) {
                $m = $a;
            }
            $out .= "<a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=" . $i * $q) . "\">" . ($i + 1) . "</a> &nbsp;&nbsp;";
        }
        if ($min * $q < $a) {
            //the last link
            if ($min * $q < $a - $q) {
                $out .= " ... &nbsp;&nbsp;";
            }
            if (!($a % $q == 0)) {
                $out .= "<a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=" . ($a - $a % $q)) . "\">" . (floor($a / $q) + 1) . "</a> &nbsp;&nbsp;";
            } else {
                //$a is divided by $q
                $out .= "<a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=" . ($a - $q)) . "\">" . floor($a / $q) . "</a> &nbsp;&nbsp;";
            }
        }
        //[next]
        if (strcmp($offset, "show_all")) {
            if ($offset < $a - $q) {
                $out .= "<a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=" . ($offset + $q)) . "\">" . translate("str_next") . " &gt;&gt;</a> ";
            }
        }
        //[show all]
        if (SHOWALL_ALLOWED_RECORDS_NUM >= $a || !SystemSettings::is_hosted() && SystemSettings::is_backend()) {
            if (strcmp($offset, "show_all")) {
                $out .= " |&nbsp; <a class=no_underline href=\"" . xHtmlSetQuery($path . "&offset=&show_all=yes") . "\">" . translate("str_showall") . "</a>";
            } else {
                $out .= " |&nbsp; <B>" . translate("str_showall") . "</B>";
            }
        }
    }
}