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

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

$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 FROM gallery WHERE mem_id = '$VUserID' AND Level='Public' ORDER BY modified_date desc") or die(mysql_error());
$gallery_TOTAL = mysql_num_rows($gallery_query);

$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$VUserID' and pic_private='N' order by pic_default asc, mod_date desc, pic_date desc") or die(mysql_error());
$photo_TOTAL = mysql_num_rows($photo_query);
?>


<table width="100%" border="0" cellspacing="0" cellpadding="0" 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 (<?=$gallery_TOTAL?>)</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 ($gallery_TOTAL > 0) { ?>
	<tr>
		<td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="white_back_t_xb">
				<tr>
					<td><?php if ($gallery_TOTAL > 0){ ?>
            <?php 
$h = 0;
while (($gallery = mysql_fetch_object($gallery_query)) && ($h<5)) {
$h++;
$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 = $CONST_LINK_ROOT."/members/".$WUsername."/gallery/".md5($gallery->cover)."_medium.".$cover->ext;
} else {
$url = $CONST_LINK_ROOT."/images/spacer.gif";
}
?>
            <div class="left p10" style="width:100px">
              <span class="left img_b_p3"><div class="clippedImage" style="background-image: 
url(&quot;<?=$url?>&quot;);"><a href="javascript: void(null)" title="<?=$gallery->Name?>" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/myprofile_gallery.php?VUserID=<?=$VUserID?>&VUserNAME=<?=$WUsername?>&gid=<?=$gallery->Gallery_ID?>&pid=<?=$gallery->cover?>'}, this.title, 'gallery'); return false;" rel="facebox">&nbsp;</a></div></span>
              <div class="left padding_lr_5"> <b> <a href="javascript: void(null)" title="<?=$gallery->Name?>" onclick="javascript: jQuery.facebox({ajax:'<?=$CONST_LINK_ROOT?>/myprofile_gallery.php?VUserID=<?=$VUserID?>&VUserNAME=<?=$WUsername?>&gid=<?=$gallery->Gallery_ID?>&pid=<?=$gallery->cover?>'}, this.title, 'gallery'); return false;" rel="facebox">
				<?=$gallery->Name?>
                </a> </b> <br />
                <span class="lightgrey_10">
                <?=$galleryitem_TOTAL?>
                <?php if ($galleryitem_TOTAL > 1) echo "photos"; else echo "photo"; ?>
                <br />
                Updated:
                 <br />
               <?= $gallery->mod_date?>
                <br />
                Created:
                 <br />
               <?= $gallery->create_date?>
                 </span> </div>
            </div>
            <?php } ?>
            <?php } ?>
					</td>
				</tr>
			</table></td>
	</tr>
<?php } else {?>
	<tr>
		<td>No photo yet for current!</td>
	</tr>
<?php }?>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td><div class="light_orang_h">
				<div style="background-color:#0000FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
				Profile Photos (<?=$photo_TOTAL?>)</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>
		<td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="white_back_t_xb">
				<tr>
					<td><?php if ($photo_TOTAL > 0){ ?>
                  <?php 
$h = 0;
while (($photo = mysql_fetch_object($photo_query)) && ($h<5)) {
$h++;
$url = $CONST_LINK_ROOT."/members/".$WUsername."/picture/".$photo->pic_picture."_medium.".$photo->ext;
?>
                  <div class="left p10">
                    <span class="left img_b_p3"><div class="clippedImage" style="background-image: 
url(&quot;<?=$url?>&quot;);">&nbsp;</div></span>
                  </div>
                  <?php } ?>
                  <?php } ?>
					</td>
				</tr>
			</table></td>
	</tr>
<?php } else {?>
	<tr>
		<td>No profile picture yet for current!</td>
	</tr>
<?php }?>
	<tr>
		<td>&nbsp;</td>
	</tr>
</table>
