<?
	include("include/common.php");
	if(!$loggedin){
		ob_start();
		header("Location: login.php");
	}
	include("include/header.php");
	include("include/accmenu.php");
	$del = $_REQUEST['del'];
	if($del){
		mysql_query("DELETE FROM gallery WHERE id='$del'");
		mysql_query("DELETE FROM gitem WHERE gid='$del'");
	}

	$limit = 10;
?>
	<h3>Manage Your Galleries</h3>
	<table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td>
			<b>Your Galleries</b><br>
			<hr>
<?
			$sql = "SELECT * FROM gallery WHERE user='$myuid'";
			$qr1 = mysql_query($sql);
			$rowcount = mysql_num_rows($qr1);
			$l = $pageno * $limit;
			$u = $l + $limit-1;
			$count = -1;
			$i = 1;
			$domCount = 0;
			while( $a = mysql_fetch_object($qr1) ){
				echo "<b>".$a->name."</b> - ";
				echo "<a href='view.php?id=".$a->id."'>view</a> | ";
				echo "<a href='gallery.php?del=".$a->id."'>delete</a><br>";
?>
				<div style='padding-left:30px;'>
					<b>Code:</b><Br>
					<small>Link to your gallery to share it with friends and family. Feel free to 
					use the code below to create the link.</small><br>
					<textarea rows="4" name="codesnip" cols="25" id="code" style="width: 400px">
<a href="<?=$siteurl?>/view.php?id=<?=$a->id?>">View My Gallery: <?=$a->name?></a>
					</textarea>
					<br><br>
					<b>Auction Code:</b><Br>
					<small>Use the following code to include your gallery in an online auction. A preview 
					appears below the code box.</small>
					<textarea rows="4" name="codesnip" cols="25" id="code" style="width: 400px">
<script language="javascript" src="<?=$siteurl?>/auction.php?id=<?=$a->id?>"></script>
					</textarea>
				</div>
				<hr>
<?
			}
?>
			<hr>
			<form method=POST action='addgallery.php'>
			<b>New Gallery</b><br>
			<p>
				To create a new gallery from your images which you can share with friends and family, or use to 
				display thumbnails in an online auction, select the images you wish to include above. After you upload 
				an image using the "Upload An Image" link in the top menu, it will appear in your images list on this 
				page. Check the box under each image you wish to include and then click below to create your gallery.
			</p>
			<p>
				Note: Auction galleries can contain a maximum of six images. If you select more than six images 
				above, some will not be included in the auction gallery. Normal galleries can contain an unlimited 
				number of images.
			</p>
			Gallery Name:
			<input type=text name=gname>
			<input type=submit name='Create Gallery'>
			</form>
		</td>
	</tr>
	</table>
<?	include("include/footer.php");	?>