<?php

	require_once('initialize.php');
	require_once('PhotographManager.php');

	$photographManager = new PhotographManager($databaseConnection);

	$photographId = @$_REQUEST['photographId'];
	if ($photographId)
		$photographInfo = $photographManager->getPhotograph($photographId);
	else
		$photographInfo = null;

?>

<?php include('header.php'); ?>
<?php include('leftSide.php') ?>

						<td valign="top">

						<!-- Content -->
						<table border="0" cellspacing="5" cellpadding="5" width="100%">
							<tr>
								<td><font class="contentTitleText">Ski Club Photographs</font></td>
							</tr>

							<tr>
								<td align="center">


									<font class="normalFont">

										<?php if ($photographInfo) { ?>

											<!-- color border table -->
											<table bgcolor="#b5c2e4" border="0" cellspacing="0" cellpadding="0" width="200">
												<tr>
													<td>

														<table border="0" cellspacing="1" cellpadding="15" width="100%">
															<tr bgcolor="#FFFFFF">
																<td align='center' class="normalFont" valign='top'>
																	<?php
																		print " <img src='photographs/$photographInfo[filename]'>
																				<br><br>$photographInfo[comments]";
																	?>
																</td>
															</tr>
														</table>
													</td>
												</tr>
											</table>

										<?php } else { ?>

											<!-- color border table -->
											<table bgcolor="#b5c2e4" border="0" cellspacing="0" cellpadding="0" width="80%">
												<tr>
													<td>

														<table border="0" cellspacing="1" cellpadding="5" width="100%">
															<?php
																$photographsArray = $photographManager->getPhotographs();

																$index = 0;
																foreach ($photographsArray as $photograph)
																{
																	if ($index % 3 == 0)
																	{
																		$rowCount++;
																		if ($index != 0)
																			print "</tr>";

																		if ($index % 2 == 0)
																			$bgColor = "#FFFFFF";
																		else
																			$bgColor = "#e9e9f3";

																		print "<tr bgcolor='$bgColor'>";
																	}


																	print "<td align='center' class='normalFont' valign='top'>
																				<table border='0' cellspacing='1' cellpadding='5' width='33%'>
																					<tr>
																						<td align='center'><a href='photographs.php?photographId=$photograph[id]'><img src='photographs/$photograph[filename]' border='0' width='100' height='100'></a></td>
																					</tr>
																					<tr>
																						<td align='center'><a href='photographs.php?photographId=$photograph[id]'>$photograph[caption]</a></td>
																					</tr>
																				</table>
																			</td>";
																	$index++;
																}

																while ($index++ % 3 != 0)
																	print "<td align='center' bgcolor='$bgColor' width='33%'></td>";
																print "</tr>";

															?>
														</table>

													</td>
												</tr>
											</table>

										<?php } ?>

									</font>
								</td>
							</tr>
						</table>

						</td>

<?php include('footer.php'); ?>


