<?php
include("includes/site_info.php");
include('session_handler.inc');

$WUserID = $_SESSION['Sess_UserId'];
$WUsername = $_SESSION['Sess_UserName'];

$photo_query=mysql_query("SELECT *, DATE_FORMAT(pic_date, '%M %d, %Y') as pic_date, DATE_FORMAT(mod_date, '%M %d, %Y') as mod_date FROM pictures WHERE pic_userid = '$WUserID' order by pic_default asc, pic_id desc") or die(mysql_error());
$photo_TOTAL = mysql_num_rows($photo_query);

?>

<div id="top_panel" class="grey_row_back">
  <?php include ("panel_top.php"); ?>
</div>
<?php 
	foreach($_GET as $field=>$data) {
	if ($field=="done") {
		echo'<div id="msg_content_done">Wow, Your request was done!</div>';
	}
	elseif ($field=="error") {
		echo'<div id="msg_content_error">Ops! Database Error, please try again!</div>';
	}
}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><div id="msg_content" style="display:none"></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="5" class="white_back_t_xb">
        <tr>
          <td><div class="light_orang_h">
              <div style="background-color:#FF0000; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
              Profile Photos </div>
            <div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
            <div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
        </tr>
<?php if ($photo_TOTAL > 0){ ?>
	<tr class="lightgrey_10">
          <td align="center"><?=$photo_TOTAL?>
            <?php if ($photo_TOTAL > 1) echo "photos"; else echo "photo"; ?> | <a title="Add Photo" href="#caddpphoto?tab=media" onclick="javascript: callpage(this.href);">Add Photo</a> | <a href="#cmedia" onclick="javascript: callpage(this.href);">Back to Media</a> | <a href="#ceditpphotos?tab=media" onclick="javascript: callpage(this.href);" rel="subpage_link">Edit</a> | <a href="#ceditpdelete?tab=media" rel="subpage_link" onclick="javascript: callpage(this.href);">Delete</a></td>
        </tr>
        <tr>
          <td>
            <table border="0" cellpadding="5" cellspacing="0" class="white_back_t_xb">
              <?php 
 		$cnt=1;
		$row=0;
	while ($photo = mysql_fetch_object($photo_query) ) {
		if($cnt%5==1)
		{
			echo"<tr>";
		 }
          ?>
              <td><div class="img_b_p3"><a href="#cpropic?tab=media&pid=<?=$photo->pic_id?>" onclick="javascript: callpage(this.href);" rel="subpage_link"><img src="<?=$SITE_MAIN_WWW_ROOT?>/members/<?=$WUsername?>/picture/<?=$photo->pic_picture?>_small.<?=$photo->ext?>" border="0"></a></div>
                  </td>
                <?php
		  if($cnt%5==0)
		  {
 			echo"</tr>";
			}
			$cnt++;
			$row++;
         	} ?>
            </table>
          </td>
        </tr>
            <?php } else {?>
	<tr class="lightgrey_10">
          <td align="center"><?=$photo_TOTAL?>
            <?php if ($photo_TOTAL > 1) echo "photos"; else echo "photo"; ?> | <a title="Add Photo" href="#caddpphoto?tab=media" onclick="javascript: callpage(this.href);">Add Photo</a> | <a href="#cmedia" onclick="javascript: callpage(this.href);">Back to Media</a></td>
        </tr>
        <tr>
          <td>            <div class="padding_10" align="center">Can't find a photo to view.</div>
</td>
        </tr>            <?php } ?>
        <tr class="solid_line_separator">
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
