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

$latest_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, cover, mem_userid, mem_username FROM gallery LEFT JOIN members ON (mem_id=mem_userid) WHERE Level='Public' and cover !=0 order by modified_date desc limit 10",$link) or die(mysql_error());
$latest_gallery_count = mysql_num_rows($latest_gallery_query);
?>
<div id="top_panel" class="darkpink_row_back">
	<?php include ("panel_top_main.php"); ?>
</div>

<script type="text/javascript">
jQuery.noConflict();

jQuery(document).ready(function(){
    jQuery("#search_media").submit(function(){
	 	jQuery('#loading').show();
	 	jQuery('#right_loading_m').show();
		
		var q = jQuery("#q").val();
		
		q=jQuery.trim(q);
		
		jQuery("#q").val(q);

		var str = jQuery(this).serialize();
	
		window.location.hash = "search?tab=media&" + str;
		window.location.reload(true);
/*		location.href="#search?tab=media&" + str;
		jQuery.get('search.php?'+str, function(data) {
 		jQuery('#loading').hide();	
	 	jQuery('#right_loading_m').hide();
		jQuery("#main_content").fadeIn('slow');
 		jQuery('#main_content').html(data);
		});
*/			
		return false;
    });
});

  </script>
<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>
							Search</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><form name="search_media" id="search_media" style="padding:0; margin:0; border:0;">
							<table width="100%" border="0" cellspacing="0" cellpadding="5">
								<tr>
									<td align="center"><input type="text" size="40" name="q" id="q" class="grey_12_xb"/>
										<label>
										<input name="type" type="radio" value="gallery" checked="checked" />
										Galleries</label>
										<input name="init" type="submit" class="button" id="init" value="Search"/></td>
								</tr>
							</table>
						</form></td>
				</tr>
				<?php
					if ($latest_gallery_count>0){ ?>
				<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>
							Latest 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><div class="left padding_5">
							<table border="0" cellpadding="0" cellspacing="0" class="white_back_t_xb">
								<?php 
		  $cnt=1;
		$row=0;
		while ($gallery = mysql_fetch_object($latest_gallery_query) ) {
		if($cnt%5==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_5 w146"> <span class="left img_b_p3">
											<div class="clippedImage2" style="background-image: 
url(&quot;<?=$url?>&quot;);"><a href="#mgallery?tab=media&gid=<?=$gallery->Gallery_ID?>&uID=<?=$gallery->mem_userid?>" onclick="javascript: callpage(this.href);" rel="subpage_link">&nbsp;</a></div>
											</span>
											<div class="left" align="left"> <b> <a href="#mgallery?tab=media&gid=<?=$gallery->Gallery_ID?>&uID=<?=$gallery->mem_userid?>" onclick="javascript: callpage(this.href);" rel="subpage_link">
												<?=ucwords($gallery->Name)?>
												</a> </b> <br />
												<span class="line_height20">
												<?=$galleryitem_TOTAL?>
												<?php if ($galleryitem_TOTAL > 1) echo "photos"; else echo "photo"; ?>
												</span> <br />
												<span class="lightgrey_10"> By
												<?=ucwords($gallery->mem_username)?>
												<br />
												Updated
												<?= $gallery->mod_date?>
												<br />
												Created
												<?= $gallery->create_date?>
												</span> </div>
										</div></td>
									<?php
		  if($cnt%5==0)
		  {
 			echo"</tr>";
			}
			$cnt++;
			$row++;
         	} ?>
							</table>
						</div></td>
				</tr>
				<?php
				}
				?>
			</table></td>
	</tr>
</table>
