<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

  // load viewer library
  $libraryPath = 'builder/lib/viewer_functions.php';
  $dirsToCheck = array('/home/webster/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($top_menuRecords, $top_menuMetaData) = getRecords(array(
    'tableName'   => 'top_menu',
    'loadUploads' => '0',
  ));
  
    // load records
  list($recent_news_articlesRecords, $recent_news_articlesMetaData) = getRecords(array(
    'tableName'   => 'recent_news_articles',
    'where'       => whereRecordNumberInUrl(), 
//    'limit'       => '1',
  ));
  $recent_news_articlesRecord = @$recent_news_articlesRecords[0]; // get first record 
  
  // load records
  list($newsArchivesRecords, $newsArchivesMetaData) = getRecords(array(
    'tableName'   => 'recent_news_articles',
    'where'       => whereRecordNumberInUrl(), 
//    'limit'       => '1',
  ));
  $newsArchivesRecord = @$newsArchivesRecords[0]; // get first record 
 
?>
<!DOCTYPE html PUBLIC "~//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml/DTD/xhtmll-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/webster.css" />
<!--[if lte IE 6]><link rel="stylesheet" href="css/iefix.css" /><![endif]-->

<title>Webster Memorial Trophy Competition</title>

</head>
<body>
<div id="outercontainer">
<div id="header">
<h1><a href="http://webstertrophy.ca/">The Webster Memorial Trophy Competition</a></h1>
<div id="menu">
<?php include "includes/topMenu.inc" ?>
</div>
</div>
<div id="innercontainer">
<div id="sidebar">
<?php if ($top_menuRecords['num']='2'): ?>

<?php
  list($recent_news_articlesRecords, $recent_news_articlesMetaData) = getRecords(array(
    'tableName'   => 'recent_news_articles',
    'where'	=>	'datediff(publishDate, curdate()) > -365',
  ));
?>
 <ul>
 	<li>
 		<?php foreach ($recent_news_articlesRecords as $record): ?>
 		<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br /><br />
    		<?php endforeach; ?>
 	</li>
 </ul>
 
 <?php else: ?>
<?php $top_menuRecords['num']='3' ?>
<?php
  list($newsArchivesRecords, $newsArchivesMetaData) = getRecords(array(
    'tableName'   => 'recent_news_articles',
    'where'	=>	'datediff(publishDate, curdate()) < -365',
  ));
?>
 <ul>
 	<li>
 		<?php foreach ($newsArchivesRecords as $record): ?>
 		<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br /><br />
    		<?php endforeach; ?>
 	</li>
 </ul>
 <?php endif ?>

</div>
<div id="main">

<?php if ($top_menuRecords['num']='2'): ?>

<h2><?php echo $recent_news_articlesRecord['title'] ?></h2>
<i>Published <?php echo date("D jS, M Y", strtotime($recent_news_articlesRecord['publishDate'])) ?></i>
<p><?php echo $recent_news_articlesRecord['content'] ?></p>

<?php else: ?>
<!-- ++++++++++++++++++++++++++++++++++++ -->
<?php $top_menuRecords['num']='3' ?>
<h2><?php echo $newsArchivesRecord['title'] ?></h2>
<i>Published <?php echo date("D jS, M Y", strtotime($newsArchivesRecord['publishDate'])) ?></i>
<p><?php echo $newsArchivesRecord['content'] ?></p>


<?php endif ?>

<br />
<center><a href="#top">back to top</a></center>
</div>
</div>

<div id="innercontainerbottom">&nbsp;</div>
<div id="footer">In memory of John Webster</div>
<div id="hundredyears">100 years of flight</div>
<div id="spike">&nbsp;</div>
</div>
<div id="plane">&nbsp;</div>

</body>
</html>