<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/heritage/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 record from 'homepage_introduction'
  list($homepage_random_imageRecords, $homepage_random_imageMetaData) = getRecords(array(
    'tableName'   => 'homepage_random_image',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $homepage_random_imageRecord = @$homepage_random_imageRecords[0]; // get first record

  list($product_categoriesRecords, $product_categoriesMetaData) = getRecords(array(
    'tableName'   => 'product_categories',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

  list($our_productsRecords, $our_productsMetaData) = getRecords(array(
    'tableName'   => 'our_products',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

?>
<!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=iso-8859-1">
<TITLE>Our Products</TITLE>
<LINK HREF="styles.css" REL="stylesheet" TYPE="text/css">
 </HEAD>

<BODY>
<TABLE WIDTH="1000" BORDER="0" ALIGN="CENTER" CELLPADDING="0" CELLSPACING="0">
  <tr>
    <td class="tdMasthead"><div align="center">
      <?php require_once('_include-masthead.php'); ?>
    </div></td>
  </tr>
  <TR>
    <TD CLASS="tdHomeMainImage"><TABLE WIDTH="1000" BORDER="0" align="center" CELLPADDING="0" CELLSPACING="0">
      <TR>
        <TD class = "titleLower"><?php 
  list($randomImageRecord, $randomImageMetaData) = getRecords(array( 
         'tableName'   =>  'homepage_random_image', 
	 'limit'       =>  1, 
	 'allowSearch' => false, 
       )); 
   
  $images = array(); 
   
  if ($randomImageRecord) { 
    $images = $randomImageRecord[0]['images']; 
  } 
?>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"><!--  
  
var image = new Array();  
 
<?php $counter = 0; ?> 
<?php foreach ($images as $image): ?> 
  image[<?php echo $counter++; ?>] = '<?php echo $image['urlPath'];?>' ;  
<?php endforeach ?> 
  
var index = Math.floor(Math.random() * image.length);  
document.write('<style type="text/css"> td.titleLower { background-image: url('+ image[index] +') } </style>');  
//-->  
</SCRIPT>
<img src="images/masthead-shadow.png" width="100%" height="50" /></TD>
      </TR>

      <TR>
        <TD></TD>
      </TR>
    </TABLE></TD>
  </TR>
  <TR>
    <TD CLASS="tdHomeMainContent"><TABLE WIDTH="1000" BORDER="0" CELLSPACING="0" CELLPADDING="0">
      
      <TR>
        <TD><?php require_once('_include-nav-products.php'); ?></TD>
        <TD><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
          <TR>
            <TD><IMG SRC="images/single-pixel.gif" WIDTH="20" HEIGHT="20"></TD>
            <TD><IMG SRC="images/single-pixel.gif" WIDTH="594" HEIGHT="20"></TD>
            <TD><IMG SRC="images/single-pixel.gif" WIDTH="20" HEIGHT="20"></TD>
          </TR>
          <TR>
            <TD><img src="images/single-pixel.gif" width="20" height="300" /></TD>
            <TD><h1>Our Products </h1>
			<p><a href="javascript:history.go(-1);">&laquo; Previous page</a></p>
    <?php foreach ($our_productsRecords as $record): ?>
      
      <h2><?php echo $record['category:label'] ?></h2> 
	  <p><strong><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?></a></strong></p>
    <?php endforeach ?>			  </TD>
            <TD rowspan="2">&nbsp;</TD>
          </TR>
          <TR>
            <TD>&nbsp;</TD>
            <TD><?php require_once('_include-footer.php'); ?></TD>
          </TR>
        </TABLE></TD>
        <TD><?php require_once('_include-right-column.php'); ?></TD>
      </TR>
      <TR>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD>
      </TR>
    </TABLE></TD>
  </TR>
</TABLE>
</BODY>
</HTML>
