<?
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" bgcolor="#EDEDED">
							<!--
							**************************
							**** BEGIN BODY TABLE ****
							**************************
							-->
							<script language="javascript">
							function rename_foler() {
								var agree=confirm("Are you sure you would like to rename this folder?");
								if (agree) {
									document.imgmgr.action = "actions.php?pmode=rename_folder";
									document.imgmgr.submit();
								}
								else {
									false
								}
							}
							function delete_folder() {
								var agree=confirm("Deleting this folder deletes all images it contains?");
								if (agree) {
									document.imgmgr.action = "actions.php?pmode=delete_folder";
									document.imgmgr.submit();
								}
								else {
									false
								}
							}
							function move_images() {
								var agree=confirm("Are you sure you would like to move the selected images?");
								if (agree) {
									document.imgmgr.action = "actions.php?pmode=move_images";
									document.imgmgr.submit();
								}
								else {
									false
								}
							}
							function delete_images() {
								var agree=confirm("Are you sure you would like to delete the selected images?");
								if (agree) {
									document.imgmgr.action = "actions.php?pmode=delete_images";
									document.imgmgr.submit();
								}
								else {
									false
								}
							}
							function copyit(theField) {
								var tempval=eval("document."+theField)
								tempval.focus()
								tempval.select()
								therange=tempval.createTextRange()
								therange.execCommand("Copy")
							}
							</script>
							<form name="imgmgr" method="post">
							<?
							$folder_result = mysql_query("SELECT folder_id,name,thumbnails FROM folders WHERE folder_id = '$fid' and mid = '$mid'", $db);
							$folder = mysql_fetch_object($folder_result);
							?>
							<table cellpadding="0" cellspacing="0" bgcolor="#ffffff">
								<tr>
									<td><a href="image.manager.php"><img src="./images/ButtonBack.gif" border="0" alt="Back To Folders"></a><img src="./images/HeaderImageManager2.gif"><?php if($folder->thumbnails == 1){?><a href="actions.php?pmode=thumbs&fid=<?php echo $fid . "&thumbs=0"; ?>"><img src="./images/HideThumbnails.gif" border="0" alt="Display File Names Only"></a><? } else { ?><a href="actions.php?pmode=thumbs&fid=<?php echo $fid . "&thumbs=1"; ?>"><img src="./images/ShowThumbnails.gif" border="0" alt="Display File Names Only"></a><? } ?></td>
								</tr>
								<tr>
									<td align="center" style="padding: 5px" bgcolor="#ffffff">
										<!--
										**************************
										*** BEGIN BODY CONTENT ***
										**************************
										-->
										<table width="100%" border="0" bgcolor="#ffffff">
											<?
												$cell = 0;
												$image_result = mysql_query("SELECT * FROM images WHERE fid = '$fid' and mid = '$mid'", $db);
												$image_count = mysql_num_rows($image_result);
												
													if($image_count != 0){
														echo "<tr><td align=\"center\"><font face=\"Verdana\" size=\"2\" color=\"#8C8E91\"><b>Click on an image for details</td></tr>";
													}
													else{
														echo "<tr><td align=\"center\"><table width=\"400\"><tr><td align=\"center\"><br><br><font face=\"Verdana\" size=\"2\" color=\"#8C8E91\"><b>You have no images in this folder. Click the \"Upload Images\" button to upload images.<br><br></td></tr></table></td></tr>";
													}
													if($mes == "uploaded"){
														echo "<tr><td align=\"center\"><font face=\"verdana\" size=\"1\" color=\"#ff0000\"><b>Your image(s) have been uploaded.</font></td></tr>";
													}
											?>
											<tr>
												<td>
													<table width="100%">
														<?php	
															if($folder->thumbnails == "1"){
																echo "<tr>";																
																while($image = mysql_fetch_object($image_result)){
																	
																	if($cell == 3){
																		echo "</tr><tr><td colspan=\"5\" height=\"3\"></td></tr><tr>";
																		$cell = 1;
																	}
																	else{
																		$cell++;
																	}
														?>
															<td style="border: 1px solid #B7B7B7" align="center" valign="top" width="150">
																<table cellpadding="0" cellspacing="0" width="150">
																	<tr>
																		<td align="center" style="padding: 3px;"><a href="image.details.php?img=<?php echo $image->image_id; ?>&fid=<? echo $fid; ?>"><img src="./usr/<?php echo $mid; ?>/i_<?php echo $image->filename; ?>" style="border: 1px solid #000000;"></a></td>
																	</tr>
																	<tr>
																		<td valign="middle"><font face="verdana" size="1" color="#6F6F6F"><input type="checkbox" name="<?php echo $image->image_id; ?>" value="1"> <a href="image.details.php?img=<?php echo $image->image_id; ?>" class="imgmgr"><?php echo $image->filename; ?></a></td>
																	</tr>
																</table>															
															</td>
														<?
															if($cell != 3){
																echo "<td>&nbsp;</td>";
															}
																
																}														
																	$cell_remainder = 3 - $cell;
																	if($cell_remainder != 0){
																		$cell_remainder = $cell_remainder + 1;
																		echo "<td colspan=\"$cell_remainder\">&nbsp;</td>";
																	}															
																	
																echo "</tr><tr><td colspan=\"5\" height=\"3\"></td></tr>";
															}
															else {
																while($image = mysql_fetch_object($image_result)){
														?>
														<tr>
															<td style="border: 1px solid #B7B7B7" align="center" valign="top">
																<table cellpadding="0" cellspacing="0" width="100%">
																	<tr>
																		<td align="left" width="54"><a href="image.details.php?img=<?php echo $image->image_id; ?>&fid=<? echo $fid; ?>"><img src="./usr/<? echo $mid . "/hta_" . $image->filename; ?>" border="0" style="border: 1px solid #000000"></a></td>
																		<td width="100%" valign="middle"><font face="Verdana" size="2" color="#8C8E91"><b><input type="checkbox" name="<?php echo $image->image_id; ?>" value="1"> <a href="image.details.php?img=<?php echo $image->image_id; ?>" class="imgmgr"><?php echo $image->filename; ?></td>
																	</tr>
																</table>															
															</td>
														</tr>
														<?
																}
															}
														?>
													</table>
												</td>
											</tr>
										</table>
									</td>
								</tr>
								<tr>
									<td><img src="./images/ImageListPageDiv.gif"></td>
								</tr>
								<tr>
									<td bgcolor="#EDEDED" style="padding: 5px" align="center"><font face="Verdana" size="2" color="#333333"><b>Options for this folder</td>
								</tr>
								<tr>
									<td bgcolor="#EDEDED" style="padding: 5px">
										<table width="100%">
											<tr>
												<td align="center">
													<table cellpadding="0" cellspacing="0" width="100%" style="border: 1px solid #083C58">
														<input type="hidden" name="fid" value="<?php echo $fid; ?>">
														<tr>
															<td bgcolor="#083C58" style="padding: 10px" align="center"><font face="Verdana" style="font-size: 11;" color="#ffffff"><b><?php echo $folder->name; ?></td>
															<td bgcolor="#F8F8F8" style="padding: 10px" align="right">
																<table cellpadding="0" cellspacing="0">
																	<tr>
																		<td><font face="Verdana" style="font-size: 11;" color="#083C58"><b>Rename Folder To </td>
																		<td>&nbsp;</td>
																		<td><input type="text" name="folder_name" maxlength="64" style="font-size: 10; width: 140;"></td>
																		<td>&nbsp;</td>
																		<td><a href="javascript:rename_foler();"><img src="./images/ButtonRename.gif" border="0"></a></td>
																		<td width="14">&nbsp;</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td>
													<table cellpadding="0" cellspacing="0" width="100%">
														<tr>
															<? if($image_count != 0){ ?>
															<td style="border: 1px solid #083C58; padding: 10px" bgcolor="#F8F8F8">
																<table cellpadding="0" cellspacing="0">
																	<tr>
																		<td colspan="3"><font face="Verdana" style="font-size: 11;" color="#083C58"><b>Move Selected Images To</td>
																	</tr>
																	<tr>
																		<td>
																		<select name="new_fid" style="font-size: 10;font-family: verdana; width: 160;">
																			<?php
																				$folder_result = mysql_query("SELECT folder_id,name FROM folders WHERE mid = '$mid'", $db);
																				while($folder = mysql_fetch_object($folder_result)){
																					echo "<option value=\"$folder->folder_id\">$folder->name</option>";
																				}
																			?>
																		</td>
																		<td>&nbsp;</td>
																		<td><a href="javascript:move_images();"><img src="./images/ButtonMove.gif" border="0"></td>
																	</tr>
																</table>
															</td>
															<td>&nbsp;</td>
															<? } ?>
															<td style="border: 1px solid #083C58; padding: 10px" align="center" bgcolor="#F8F8F8">
																<table cellpadding="0" cellspacing="0">
																	<? if($image_count != 0){ ?>
																	<tr>
																		<td align="right"><font face="Verdana" style="font-size: 11;" color="#083C58"><b>Delete Selected Images</td>
																		<td>&nbsp;</td>
																		<td><a href="javascript:delete_images();"><img src="./images/ButtonDelete.gif" border="0"></a></td>
																	</tr>
																	<tr>
																		<td colspan="3" height="2"></td>
																	</tr>
																	<? } ?>
																	<input type="hidden" name="fid" value="<?php echo $fid; ?>">
																	<tr>
																		<td align="right"><font face="Verdana" style="font-size: 11;" color="#083C58"><b>Delete This Folder</td>
																		<td>&nbsp;</td>
																		<td><a href="javascript:delete_folder();"><img type="image" src="./images/ButtonDeleteRed.gif" border="0"></a></td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
											
										</table>
									</td>
								</tr>
							</table>
							</form>
							<!--
							**************************
							***** 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);
?>