<div class="huge_box">
<div class="huge_box_header">
<div class="title">News</div>
</div>

<div class="huge_box_content">

<?php

if (isset($_GET['pg'])) {
	$pg = $_GET['pg'];
} else {
	$pg = 0;	
}
$displaying = 10;
$pagination = " LIMIT " . $pg . ", " . $displaying;
$currentpage = floor($pg / $displaying) + 1;


$res = mysql_query ("SELECT * FROM news ORDER BY Date DESC ");
$nr = mysql_num_rows ($res);
$numresults = $nr;
$totalpages = floor(($nr - 1) / $displaying) + 1;

$res = mysql_query ("SELECT * FROM news ORDER BY Date DESC ");

$nr = mysql_num_rows ($res);
while ($nr>0) {
	$row = mysql_fetch_array ($res);
	extract ($row);
	?>
    <div class="date" id="news_<?php echo $Id; ?>"><?php echo formatDate($Date); ?></div>
    <div class="title" style="padding:0px 10px;"><?php echo $Title; ?></div>
	<div class="description"><?php if ($Content!=NULL) echo $Content; else echo $Description; ?></div>	
	<?php
    $nr--;	
}
?>

</div>

<div class="huge_box_footer">
<?php if ($totalpages > 0) { ?>
	<div class="pagination">
	<?php if ($currentpage>2) { ?>
    	<a href="?page=news<? if ($search!= '') echo "&searchbox=".$search; ?>&pg=0" title="first">&nbsp;&lt;&lt;&nbsp;</a>
	<?php } ?>
	<?php if ($currentpage>1) { ?>
    	<a href="?page=news<? if ($search!= '') echo "&searchbox=".$search; ?>&pg=<?php echo $pg - $displaying; ?>" title="prev">&nbsp;&lt;&nbsp;</a>
	<?php } ?>
&nbsp;&nbsp;<?php echo $currentpage."/".$totalpages; ?>&nbsp;&nbsp;
	<?php if ($currentpage<$totalpages) { ?>
    	<a href="?page=news<? if ($search!= '') echo "&searchbox=".$search; ?>&pg=<?php echo ($currentpage) * $displaying; ?>" target="_self" title="next">&nbsp;&gt;&nbsp;</a>
    <?php } ?>
	<?php if ($currentpage<$totalpages-1) { ?>
    	<a href="?page=news<? if ($search!= '') echo "&searchbox=".$search; ?>&pg=<?php echo ($totalpages - 1) * $displaying; ?>" target="_self" title="last">&nbsp;&gt;&gt;&nbsp;</a>
    <?php } ?>
	</div>
<?php } ?>
<div class="results">Total results: <?php echo $numresults; ?>.</div>
</div>

</div>
