function BuildPageButtons($Cur_Page, $TotalPages, $Main_Link, $File)
{
    $Cur_Page = ValidatePageNumber($Cur_Page, $TotalPages);
    $PageText = "";
    if ($Cur_Page == 1) {
        $PageText .= "<div class = \"pnav\"><ul><li><a class=\"prev-first-off\"><img src=\"images/pixel.gif\" height=\"1\" width=\"1\" /></a></li><li><a class=\"prev-off\"><img src=\"images/pixel.gif\" height=\"1\" width=\"1\" /></a></li>";
    } else {
        $ActionRewind = $Main_Link . "&page=1";
        $ActionBack = $Main_Link . "&page=" . ($Cur_Page - 1);
        $PageText .= "<div class = \"pnav\"><ul><li><a class=\"prev-first\" onclick=\"showResult('" . $ActionRewind . "', '" . $File . "')\"><img src=\"images/pixel.gif\" height=\"1\" width=\"1\" /></a></li><li><a class=\"prev\" onclick=\"showResult('" . $ActionBack . "', '" . $File . "')\"><img src=\"images/pixel.gif\" height=\"1\" width=\"1\" /></a></li>";
    }
    for ($I = 0; $I < $TotalPages; $I++) {
        if ($I + 1 == $Cur_Page) {
            $PageText .= "<li><a class=\"sel\">" . ($I + 1) . "</a></li>";
        } else {
            if ($I <= 8 or $I + 1 == $TotalPages) {
                $ActionClick = $Main_Link . "&page=" . ($I + 1);
                $PageText .= "<li><a class=\"p\" onclick=\"showResult('" . $ActionClick . "', '" . $File . "')\">" . ($I + 1) . "</a></li>";
            }
        }
    }
    if ($Cur_Page >= $TotalPages) {
        $PageText .= "<li><a class=\"next-off\"><img src=\"images/pixel.gif\" height=\"1\" width=\"1\" /></a></li><li><a class=\"next-last-off\"><img src=\"images/pixel.gif\" height=\"1\" width=\"1\" /></a></li></ul></div>";
    } else {
        $ActionFastforward = $Main_Link . "&page=" . $TotalPages;
        $ActionForward = $Main_Link . "&page=" . ($Cur_Page + 1);
        $PageText .= "<li><a class=\"next\" onclick=\"showResult('" . $ActionForward . "', '" . $File . "')\"><img src=\"images/pixel.gif\" height=\"1\" width=\"1\" /></a></li><li><a class=\"next-last\" onclick=\"showResult('" . $ActionFastforward . "', '" . $File . "')\"><img src=\"images/pixel.gif\" height=\"1\" width=\"1\" /></a></li></ul></div>";
    }
    return $PageText;
}
                if ($OrderSort == "ASC") {
                    $OrderOppositeSort[$OrderBy] = "DESC";
                    $arrow = "down";
                } else {
                    $OrderOppositeSort[$OrderBy] = "ASC";
                    $arrow = "up";
                }
                $OrderSymbol[$OrderBy] = "<span class=\"sort " . $arrow . "\"></span>";
                $OrderSuffix[$OrderBy] = "rating";
            }
        } else {
            $OrderBy = 2;
        }
        $TotalPages = ceil($TotalItems / $config["results_per_page_items"]);
        if (isset($_GET["page"])) {
            $PageNo = ValidatePageNumber((int) $_GET["page"], $TotalPages);
        } else {
            $PageNo = 1;
        }
        ?>
<span class="csearch-results-info"><?php 
        echo $TotalItems, " ", $lang["results_for"];
        ?>
 <em><?php 
        echo stripslashes($SearchQuery);
        ?>
</em> <?php 
        echo $lang["in_realm"], " ", REALM_NAME;
        ?>
:</span><br />
<div id="big-results" style="clear: both;">