<div class="huge_box">
<div class="huge_box_header">
<div class="title">Notes</div>
</div>
<!-- Available NOTES 
Page Submitted (Page Title)
Page Accepted
Page status changed
Page rank (Daily, Weekly, Monthly)
Custom page notes
-->
<div class="huge_box_content">

<?php 

/////////////// NOTES

$userId = $_SESSION['id'];

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


if ($_SESSION['priv'] != 'Superadmin') {
	$addUserView = " WHERE n.Public = 1 OR n.Id IN (SELECT NoteId FROM user_note WHERE UserId = '$userId' ) ";
} else {
	$addUserView = ' ';
}

$res = mysql_query ("SELECT n.PageId, n.Date, n.Content, p.Title, n.Public, p.Verified FROM note AS n JOIN page AS p ON n.PageId=p.Id " . $addUserView . " ORDER BY n.Date DESC ");

$nr = mysql_num_rows ($res);
$numresults = mysql_num_rows ($res);
$totalpages = floor(($nr - 1) / $displaying) + 1;

$res = mysql_query ("SELECT n.PageId, n.Date, n.Content, p.Title, n.Public, p.Verified FROM note AS n JOIN page AS p ON n.PageId=p.Id " . $addUserView . " ORDER BY n.Date DESC " . $pagination );


$nr = mysql_num_rows ($res);
while ($nr>0) {
	$row = mysql_fetch_array ($res);
	extract ($row);
	?>
    <div class="date"><?php echo formatDate($Date); ?></div>
    <div class="title" style="padding:0px 10px">
    <?php if ($Verified == 1) { ?>
		<a href="?page=page&id=<?php echo $PageId; ?>#notes"><?php echo $Title; ?></a><?php } else { echo $Title; } ?></div>
	<div class="description"><?php echo $Content; ?></div>	
	<?php
    $nr--;	
}
?>

</div>

<div class="huge_box_footer">
<?php if ($totalpages > 0) { ?>
	<div class="pagination">
	<?php if ($currentpage>2) { ?>
    	<a href="?page=notes<? if ($search!= '') echo "&searchbox=".$search; ?>&pg=0" title="first">&nbsp;&lt;&lt;&nbsp;</a>
	<?php } ?>
	<?php if ($currentpage>1) { ?>
    	<a href="?page=notes<? 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=notes<? 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=notes<? 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>
