<?php

  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/smjohns/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }


  list($menuRecords, $menuMetaData) = getRecords(array(
    'tableName'   => 'menu',
  ));

?>
<?php

  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/smjohns/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records
  list($galleryRecords, $galleryMetaData) = getRecords(array(
    'tableName'   => 'gallery',
  ));
  
  $record = $galleryRecords[0]; //get the first record

   list($uploadRecords, $uploadMetaData)=getRecords(array( 
    'tableName'       =>      'uploads', 
    'allowSearch'     =>      false, 
    'where'			  =>	  "tableName='gallery' AND fieldName = 'photos' AND recordNum='".intval($record['num'])."'",
	'orderBy'   	  =>      "createdTime DESC",
    ));
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SM Johns and Son Construction</title>
<link href="css/smj-style.css" rel="stylesheet" type="text/css" />
<link href="css/cssnav.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>

<style type="text/css">
body {
	background-color: #818080;
	background-image: url(images/bkgd.jpg);
	background-repeat: repeat-x;
}
</style>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-21099710-4']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>

<body class="smj-style">
<div id="container">
<div id="header"></div>
<div id="sidebar1">
		<div id="cssnav">
		<ul>
		    <?php foreach ($menuRecords as $record): ?>
				<li><a href="<?php echo $record['button_url'] ?>"><?php echo $record['button_text'] ?></a></li>
			<?php endforeach; ?>
		</ul>
  	</div>
</div>
<div id="mainContent">
	<div id="content">
	
		<?php foreach ($galleryRecords as $record): ?>

      		<h2><?php echo $record['category'] ?><br/></h2>
      	
      	
      		<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
			<tr>
				   		
			<?php foreach ($record['photos'] as $upload): ?>
		
				<td>
				<?php if ($upload['hasThumbnail']): ?>
					<a href="<?php echo $upload['urlPath'] ?>" rel="lightbox[<?php echo $record['num'] ?>]" title="Description: <?php echo $upload['info1'] ?>">
					<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a>
					
					<?php elseif ($upload['isImage']): ?>
					<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />

				<?php endif ?>
		
				</td>
				<?php $maxCols=4; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>
			<?php endforeach ?>
			</tr>
			</table>
			<?php $count=0 ?>
			<hr>
			<?php endforeach ?>
			
	</div>
</div>
<div id="footer">
	<div id="textbox">
	  <p class="alignleft">SM Johns & Son Construction<br />717-465-6350</p>
	  <p class="alignright">1021 Anderson Ferry Rd<br />&nbsp &nbsp &nbsp Mount Joy, PA 17552</p><br />
	  <p align="center">&copy; <?= date("Y") ?>, SM Johns & Son Construction.  All Rights Reserved. </p>
	  <div style="clear: both;"></div>
	</div>
	
</div>
</div>
</body>
</html>