<?
session_start();
include('_db.connection.php');
include('check.access.php');
include('_public.setup.php');
?>

	<table cellpadding="0" cellspacing="0" width="780" border="0">
		<?php include("i.header.php"); ?>
		<tr>
			<td>
				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td valign="top">
							<!--
							**************************
							**** BEGIN BODY TABLE ****
							**************************
							-->
							<table cellpadding="0" cellspacing="0">
								<tr>
									<td><img src="./images/HeaderImageManager.gif"></td>
								</tr>
								<tr>
									<td align="center">
										<!--
										**************************
										*** BEGIN BODY CONTENT ***
										**************************
										-->
										<table width="90%" border="0">
											<tr>
												<td>
													<table width="100%" border="0">
														<tr>
															<td>&nbsp;</td>
															<td>&nbsp;</td>
															<td>&nbsp;</td>
														</tr>
														<tr>
														<?
														$cell = 0;
														$folder_result = mysql_query("SELECT * FROM folders WHERE mid = '$mid'", $db);
														$folder_count = mysql_num_rows($folder_result);
														while($folder = mysql_fetch_object($folder_result)){
															$jbl = MD5($fid);
															$image_result = mysql_query("SELECT image_id FROM images WHERE fid = '$folder->folder_id'", $db);
															$image_count = mysql_num_rows($image_result);
															//$image = mysql_fetch_object($image_result);
															
															if(strlen($folder->name) > 18){
																$trim_name = substr($folder->name, 0, 18) . "...";
															}
															else {
																$trim_name = $folder->name;
															}
															if($cell == 3){
																echo "\n</tr>\n<tr>\n<td colspan=\"3\">&nbsp;</td>\n</tr>\n<tr>\n<td width=\"33%\" align=\"center\"><a href=\"image.list.php?fid=" . $folder->folder_id . "\" class=\"folder_caption\"><img src=\"./images/FolderIcon.gif\" border=\"0\"><br><font face=\"Verdana\" style=\"font-size: 10; font-weight: bold;\" color=\"#083C58\">" . $trim_name . " (" . $image_count . ")</a></td>";
																$cell = 1;
															}
															else{
																echo "<td width=\"33%\" align=\"center\"><a href=\"image.list.php?fid=" . $folder->folder_id . "&jbl=" . $jbl . "\" class=\"folder_caption\"><img src=\"./images/FolderIcon.gif\" border=\"0\"><br><font face=\"Verdana\" style=\"font-size: 10; font-weight: bold;\" color=\"#083C58\">" . $trim_name . " (" . $image_count . ")</a></td>\n";
																$cell++;
															}
														}
														$cell_remainder = 3 - $cell;
														if($cell_remainder != 0){
															echo "<td colspan=\"$cell_remainder\">&nbsp;</td>";
														}
														
														if($folder_count == 0){
															echo "<tr><td colspan=\"3\" align=\"center\"><font face=\"Verdana\" size=\"2\" color=\"#8C8E91\"><b>Before you upload images you must make a folder to store them in.</td></tr>";
														}
														
														?>
														</tr>
														<tr>
															<td colspan="3">&nbsp;</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<table cellpadding="0" cellspacing="0" width="100%" style="border: 1px solid #083C58">
														<form action="actions.php?pmode=make_folder" method="post">
														<input type="hidden" name="return" value="image.manager.php">
														<tr>
															<td bgcolor="#083C58" style="padding: 10px" width="50%"><font face="Verdana" style="font-size: 11;" color="#ffffff"><i><b>Create folders to keep your images organized.</td>
															<td bgcolor="#F8F8F8" style="padding: 10px" width="50%">
																<table cellpadding="0" cellspacing="0">
																	<tr>
																		<td colspan="3"><font face="Verdana" style="font-size: 11;" color="#083C58"><b>New Folder Name</td>
																	</tr>
																	<tr>
																		<td><input type="text" name="folder_name" maxlength="64" style="font-size: 10; width: 140;"></td>
																		<td>&nbsp;</td>
																		<td><input type="image" src="./images/ButtonCreate.gif"></td>
																	</tr>
																</table>
															</td>
														</tr>
														</form>
													</table>
												</td>
											</tr>
											<tr>
												<td>&nbsp;</td>
											</tr>
										</table>
										<!--
										**************************
										**** END BODY CONTENT ****
										**************************
										-->
									</td>
								</tr>
							</table>
							<!--
							**************************
							***** END BODY TABLE *****
							**************************
							-->
						</td>
						<td valign="top"bgcolor="#295670"><img src="./images/IndexDropShadow.gif"></td>
						<td valign="top" bgcolor="#083C58">
							<?php include("i.member.rn.php"); ?>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td background="./images/Footer.gif"><img src="./images/Footer.gif" border="0"></td>
		</tr>
		<tr>
			<td>
				<?php include("i.footer.php"); ?>
			</td>
		</tr>
	</table>

<?
mysql_close($db);
print($close);
?>