<?php
include("includes/site_info.php");
include_once __INCLUDE_CLASS_PATH."/class.Picture.php";
$picture = new Picture();

$VUserID = $_REQUEST['VUserID'];
$WUsername = $_REQUEST['VUserNAME'];

if ($_REQUEST['aid']) { $aid = $_REQUEST['aid']; }
else { $aid = 0; }

$articleitem_query=mysql_query("SELECT *, UNIX_TIMESTAMP(art_datetime) as artdate FROM articles WHERE art_userid = '$VUserID' AND art_approved='Y' AND art_id='$aid' AND art_private='N'") or die(mysql_error());
$articleitem_TOTAL = mysql_num_rows($articleitem_query);

?>

<div class="pop_box">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="5" class="white_back_t_xb">
					<?php if ($articleitem_TOTAL > 0){ 
		while ($article = mysql_fetch_object($articleitem_query) ) {
		$prev_id = mysql_fetch_object(mysql_query("SELECT * FROM articles WHERE art_userid = '$VUserID' AND art_approved='Y' AND art_datetime < '$article->art_datetime' AND art_private='N' ORDER BY art_datetime DESC LIMIT 1"));
		$next_id = mysql_fetch_object(mysql_query("SELECT * FROM articles WHERE art_userid = '$VUserID' AND art_approved='Y' AND art_datetime > '$article->art_datetime' AND art_private='N' ORDER BY art_datetime ASC LIMIT 1"));
	
?>
					<?php if ($prev_id || $next_id) { ?>
					<tr class="lightgrey_10">
						<td align="center"><?php if ($prev_id) { ?>
							<div class="left button"> <a href="javascript: void(null)" title="<?=$prev_id->art_title?>" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/myprofile_note.php?VUserID=<?=$VUserID?>&aid=<?=$prev_id->art_id?>'}, this.title, 'note'); return false;" rel="facebox" >Previous</a> </div>
							<?php }?>
							<?php if ($next_id) { ?>
							<div class="right button"> <a href="javascript: void(null)" title="<?=$next_id->art_title?>" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/myprofile_note.php?VUserID=<?=$VUserID?>&aid=<?=$next_id->art_id?>'}, this.title, 'note'); return false;" rel="facebox">Next</a> </div>
							<?php }?>
						</td>
					</tr>
					<tr>
						<td align="center">&nbsp;</td>
					</tr>
					<?php }?>
					<tr class="solid_line_separator clear">
						<td><div align="center" class="padding_10 style_left">
								<?php 
							if(file_exists($SITE_ROOT."/members/".$WUsername."/article/".$article->art_picture."_med.".$article->art_ext)){ $image=$CONST_LINK_ROOT."/members/".$WUsername."/article/".$article->art_picture."_med.".$article->art_ext; $class="img_b_p3";}  else {$image="$CONST_LINK_ROOT/images/spacer.gif"; $class="";}
			?>
								<div class="left padding_lr_5" align="left"><span class="lightgrey_10">
									<?php if ($article->artdate) echo date("d M'y h:ia",$article->artdate); ?>
									</span><br />
									<br />
									<span class="line_height20"> <a title="<?=$article->art_title?>" href="javascript: void(null)" rel="facebox" onclick="javascript: jQuery.facebox({ajax:'showpic.php?app=article&pic=<?=$article->art_id?>'}, '<?=$article->art_title?>');"><img src="<?=$image?>" border="0" align="left" title="<?=$article->art_title?>" class="<?=$class?>"/></a>
									<?=nl2br(htmlspecialchars_decode($article->art_message,ENT_QUOTES));?>
									</span> </div>
							</div></td>
					</tr>
					<?php } 
		  } else {
?>
					<tr class="solid_line_separator">
						<td align="center"><div class="padding_10">Can't find a note to view.</div></td>
					</tr>
					<?php
	die;
}
?>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</table></td>
		</tr>
	</table>
</div>
