<?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/colourp1/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($categoriesRecords, $categoriesMetaData) = getRecords(array( 
    'tableName'   => 'categories', 
  )); 
  
  $categoriesRecord = @$categoriesRecords[0]; // get first record 
   
  $title = ""; 
  foreach ($categoriesRecords as $category) { 
    if($category['num'] == @$_REQUEST['main_category']) { 
      $title = $category['title']; 
    } 
  } 
  // show error message if no matching record is found
  if (!$categoriesRecord) {
    header("HTTP/1.0 404 Not Found");
    print "Record not found!";
    exit;
  }

  list($product_subcategoriesRecords, $product_subcategoriesMetaData) = getRecords(array(
    'tableName'   => 'product_subcategories',
	'orderBy'     => 'title',
  ));

  list($product_detailsRecords, $product_detailsMetaData) = getRecords(array(
    'tableName'   => 'product_details',
  ));

  list($slideshowRecords, $slideshowMetaData) = getRecords(array(
    'tableName'   => 'slideshow',
    'limit'       => '1',
  ));
  $slideshowRecord = @$slideshowRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$slideshowRecord) {
    header("HTTP/1.0 404 Not Found");
    print "Record not found!";
    exit;
  }

?>
<!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>Search Results</TITLE>
<LINK HREF="styles.css" REL="stylesheet" TYPE="text/css">

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-22970572-1']);
  _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>
<TABLE WIDTH="1000" BORDER="0" ALIGN="CENTER" CELLPADDING="0" CELLSPACING="0">
  <TR>
    <TD COLSPAN="7" CLASS="tdWhite"><?php require_once('_include-masthead.php'); ?></TD>
  </TR>
  <TR>
    <TD CLASS="titleLower" COLSPAN="7" ALIGN="LEFT" VALIGN="TOP"><?php 
  list($randomImageRecord, $randomImageMetaData) = getRecords(array( 
         'tableName'   =>  'slideshow', 
	 '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><TABLE WIDTH="1000" HEIGHT="170" BORDER="0" CELLPADDING="0" CELLSPACING="0">
      <TR>
        <TD CLASS="tdLowerHeadlineCell"><H1>Search Results</H1></TD>
      </TR>
    </TABLE></TD>
  </TR>
  <TR>
    <TD CLASS="tdWhite"><IMG SRC="images/single-pixel.gif" WIDTH="20" HEIGHT="17"></TD>
    <TD CLASS="tdWhite"><IMG SRC="images/single-pixel.gif" WIDTH="176" HEIGHT="17"></TD>
    <TD CLASS="tdWhite"><IMG SRC="images/single-pixel.gif" WIDTH="20" HEIGHT="17"></TD>
    <TD CLASS="tdWhite"><IMG SRC="images/single-pixel.gif" WIDTH="499" HEIGHT="17"></TD>
    <TD CLASS="tdWhite"><IMG SRC="images/single-pixel.gif" WIDTH="20" HEIGHT="17"></TD>
    <TD CLASS="tdWhite"><IMG SRC="images/single-pixel.gif" WIDTH="245" HEIGHT="17"></TD>
    <TD CLASS="tdWhite"><IMG SRC="images/single-pixel.gif" WIDTH="20" HEIGHT="20"></TD>
  </TR>
  <TR>
    <TD CLASS="tdWhite">&nbsp;</TD>
    <TD CLASS="tdWhite"><?php require_once('_include-generic-nav.php'); ?></TD>
    <TD CLASS="tdWhite">&nbsp;</TD>
    <TD CLASS="tdWhite"><p class="pRule"><a href="javascript:history.go(-1);">&laquo;                 Previous page</a></p>
      <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
				<table width="498" border="0" cellpadding="0" cellspacing="0">
				  <tr>  
 <?php foreach ($product_detailsRecords as $record): ?>  
   <td>  
    <P><strong><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?>   &raquo;</a></strong></P>   </td>  
 
   <?php $maxCols=2; if (@++$count % $maxCols == 0): ?></tr>
				  
				  <tr><?php endif; ?>  
 <?php endforeach; ?><?php if (!$product_detailsRecords): ?><?php endif ?>   
 </tr>  
</table>
  <!-- /STEP2: Display Records --></TD>
    <TD CLASS="tdWhite">&nbsp;</TD>
    <TD COLSPAN="2" CLASS="tdWhite"><?php require_once('_include-right-column.php'); ?></TD>
  </TR>
  
  <TR>
    <TD CLASS="tdWhite">&nbsp;</TD>
    <TD COLSPAN="5" CLASS="tdWhiteRuleTop"><?php require_once('_include-footer.php'); ?></TD>
    <TD CLASS="tdWhite">&nbsp;</TD>
  </TR>
</TABLE>
</BODY>
</HTML>
