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

$WUserID = $_REQUEST['uID'];

$gallery_query=mysql_query("SELECT DATE_FORMAT(modified_date, '%M %d, %Y') as mod_date, DATE_FORMAT(gallery_date, '%M %d, %Y') as create_date, Gallery_ID, Name, Description, Level, cover, mem_username FROM gallery LEFT JOIN members ON (mem_id=mem_userid) WHERE mem_id = '$WUserID' and Level='Public' ORDER BY modified_date desc") or die(mysql_error());
$gallery_TOTAL = mysql_num_rows($gallery_query);
if ($gallery_TOTAL >0) {
} else {
?>

<div id="top_panel" class="darkpink_row_back">
	<?php include ("panel_top_main.php"); ?>
</div>
<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">
        <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>
              Galleries</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>
        <tr>
          <td align="center"><div class="padding_10">Can't find an album to view.</div></td>
        </tr>
      </table></td>
  </tr>
</table>
<?php
	die;
}
?>
<div id="top_panel" class="darkpink_row_back">
	<?php include ("panel_top_main.php"); ?>
</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>
              Galleries</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>
        <tr class="lightgrey_10">
          <td align="center"><?=$gallery_TOTAL?>
            <?php if ($gallery_TOTAL > 1) echo "albums"; else echo "album"; ?></td>
        </tr>
        <tr>
          <td><table border="0" cellpadding="0" cellspacing="0" class="white_back_t_xb">
              <?php 
		  $cnt=1;
		$row=0;
		while ($gallery = mysql_fetch_object($gallery_query) ) {
		if($cnt%6==1)
		{
			echo"<tr>";
		 }
$galleryitem_query=mysql_query("SELECT * FROM galleryitem WHERE Gallery_ID = '$gallery->Gallery_ID'") or die(mysql_error());
$galleryitem_TOTAL = mysql_num_rows($galleryitem_query);
if ($gallery->cover!=0){
$cover_query=mysql_query("SELECT * FROM galleryitem WHERE Gallery_ID = '$gallery->Gallery_ID' and GalleryItem_ID='$gallery->cover' limit 1") or die(mysql_error());
$cover= mysql_fetch_object($cover_query);
$url = $SITE_MAIN_WWW_ROOT."/members/".$gallery->mem_username."/gallery/".md5($gallery->cover)."_medium.".$cover->ext;
} else {
$url = $SITE_WWW_ROOT."/images/spacer.gif";
}
?>
              <td align="center" valign="top"><div class="left padding_10" style="width:110px">
                    <span class="left img_b_p3"><div class="clippedImage" style="background-image: 
url(&quot;<?=$url?>&quot;);"><a href="#mgallery?tab=media&gid=<?=$gallery->Gallery_ID?>&uID=<?=$WUserID?>" onclick="javascript: callpage(this.href);" rel="subpage_link">&nbsp;</a></div></span>
                    <div class="left padding_lr_5" align="left"> <b> <a href="#mgallery?tab=media&gid=<?=$gallery->Gallery_ID?>&uID=<?=$WUserID?>" onclick="javascript: callpage(this.href);" rel="subpage_link">
                      <?=$gallery->Name?>
                      </a> </b> <br />
                      <span class="line_height20">
                      <?=$galleryitem_TOTAL?>
                      <?php if ($galleryitem_TOTAL > 1) echo "photos"; else echo "photo"; ?>
                      <br />
                      </span> <span class="lightgrey_10">
							 Updated
							 <br />
                      <?= $gallery->mod_date?>
                      <br />
                      Created
							 <br />
							<?= $gallery->create_date?>
                      <br />
                      </span> </div>
                  </div></td>
                <?php
		  if($cnt%6==0)
		  {
 			echo"</tr>";
			}
			$cnt++;
			$row++;
         	} ?>
            </table></td>
        </tr>
        <tr class="solid_line_separator">
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
