<?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 = 'admin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/ryanlega/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."); }
  
 /* ------ GENERAL INFO -------- */  
  
   // load records
  list($general_informationRecords, $general_informationMetaData) = getRecords(array(
    'tableName'   => 'general_information',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $general_informationRecord = @$general_informationRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$general_informationRecord) {
    header("HTTP/1.0 404 Not Found");
    print "Record not found!";
    exit;
  }

/* ------ SLIDESHOW -------- */  

   // load records
  list($slideshowRecords, $slideshowMetaData) = getRecords(array(
    'tableName'   => 'slideshow',
    'where'       => whereRecordNumberInUrl(1),
    '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;
  }

 /* ------ WELCOME -------- */

  // load records
  list($welcomeRecords, $welcomeMetaData) = getRecords(array(
    'tableName'   => 'welcome',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $welcomeRecord = @$welcomeRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$welcomeRecord) {
    header("HTTP/1.0 404 Not Found");
    print "Record not found!";
    exit;
  }

 /* ------ FEATURED HOME -------- */
  
    // load records
  list($featured_homeRecords, $featured_homeMetaData) = getRecords(array(
    'tableName'   => 'featured_home',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $featured_homeRecord = @$featured_homeRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$featured_homeRecord) {
    header("HTTP/1.0 404 Not Found");
    print "Record not found!";
    exit;
  }

 /* ------ AVAILABLE HOMES LIST -------- */

  // load records
 list($available_homes_lotsRecords, $available_homes_lotsMetaData) = getRecords(array(
    'tableName'   => 'available_homes_lots',
  ));

?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Buy new homes for sale from new construction at affordable home prices from Ryan Legacy Buiders." />
<meta name="keywords" content="homes for sale, new homes, house for sale, new house, new construction, buy house, house prices, buy home, home sales, new home for sale, new homes for sale, new home builder" />
<meta name="author" content="Ryan Legacy Builders" />
<title>Ryan Legacy Builders</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen,projection" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="js/functions.js" type="text/javascript"></script>
<script type="text/javascript" src="js/coin-slider.js"></script>
</head>
<body class="home">
<?php include 'includes/header.php' ?>
<div id="wrapper">
  <div id="main_content">
  	<div class="content_box shadow">
      <div class="yellow_header transparent">
      	<h1>Available Homes/Lots</h1>
      </div>
      <div class="content_box_inner">
      	<a href="available.php">
      	<img src="images/search_map.png" align="Search All Properties. 35 minutes from D.C., 20 minutes from Columbia, 25 minutes from Baltimore" />
        </a>
      </div>
  </div><!-- content_box -->
  <div class="content_box_small shadow lefty">
      <div class="red_header transparent">
      	<h1>Homes</h1>
      </div>
      <div class="content_box_inner">
      <?php foreach ($available_homes_lotsRecords as $record): ?>
      <?php if ($record['house_lot'] == "Home"):  ?>
      	<div class="availble listing">
            <a class="listing_thumb" href="<?php echo $record['_link'] ?>" style="background-image:url(<?php foreach ($record['photos'] as $upload): ?><?php if ($upload['info1'] == 'yes'): ?><?php echo $upload['thumbUrlPath'] ?><?php break; ?><?php endif ?><?php endforeach; ?>"></a>
            <p class="price"><?php echo $record['price'] ?></p>
            <p class="address"><?php echo $record['street_address'] ?><br /> 
    <?php echo $record['city_state_zip'] ?></p>
        </div>
        <?php endif ?>
        <?php endforeach ?>
      </div><!-- content_box_inner -->
  </div><!-- content_box_small -->
    <div class="content_box_small shadow righty">
      <div class="red_header transparent">
      	<h1>Lots</h1>
      </div>
      <div class="content_box_inner">
      	 <?php foreach ($available_homes_lotsRecords as $record): ?>
      <?php if ($record['house_lot'] == "Lot"):  ?>
      	<div class="listing">
            <a class="listing_thumb" href="<?php echo $record['_link'] ?>" style="background-image:url(<?php foreach ($record['photos'] as $upload): ?><?php if ($upload['info1'] == 'yes'): ?><?php echo $upload['thumbUrlPath'] ?><?php break; ?><?php endif ?><?php endforeach; ?>"></a>
            <p class="price"><?php echo $record['price'] ?></p>
            <p class="address"><?php echo $record['street_address'] ?><br /> 
    <?php echo $record['city_state_zip'] ?></p>
        </div>
        <?php endif ?>
        <?php endforeach ?>
      </div><!-- content_box_inner -->
  </div><!-- content_box_small -->
  </div><!-- main_content -->
   <div id="left_sidebar" class="shadow">
    <?php include 'includes/nav.php' ?>
    <?php if ($welcomeRecord['welcome_message']): ?>
    <div class="yellow_header transparent">
      	<h1>Welcome To<br /><span>Ryan Legacy Builders</span></h1>
      </div>
      <div class="left_sidebar_content">
     <?php echo $welcomeRecord['welcome_message'] ?>
     </div><!-- left_sidebar_content -->
     <? endif ?>
  </div><!-- left_sidebar-->
</div><!-- wrapper -->
<?php include 'includes/footer.php' ?>
</body>
</html>