<?php

	require_once('top.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;

?>

								<td align="center">
									<font class="largeFont">
										<br><br>
										
										 <?php 
											if ($photographInfo)
												print $photographInfo['caption'];
											else
												print $websiteInfo['organizationName'] . "  Photographs";
										 ?>
										
										<br><br>
									</font>
									
									<font class="normalFont">
									
										<?php if ($photographInfo) { ?>

											<!-- color border table -->
											<table bgcolor="#226699" 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="#226699" 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 = "#EEEEEE";

																		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>	
								
<?php require_once('bottom.php'); ?>