<?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;
  }

  
/* ------ AVAILABLE HOMES/LOTS -------- */

// load records
  list($available_homes_lotsRecords, $available_homes_lotsMetaData) = getRecords(array(
    'tableName'   => 'available_homes_lots',
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $available_homes_lotsRecord = @$available_homes_lotsRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$available_homes_lotsRecord) {
    header("HTTP/1.0 404 Not Found");
    print "Record not found!";
    exit;
  }

?>
<!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" />
<link rel="stylesheet" type="text/css" href="css/galleria.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>
<script src="js/galleria-1.2.3.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><?php echo $available_homes_lotsRecord['street_address'] ?></h1>
      </div>
      <div class="content_box_inner">
      <div class="detail_photos">
       <div id="gallery">
      <?php foreach ($available_homes_lotsRecord['photos'] as $upload): ?>
          <?php if ($upload['isImage']): ?>
            <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
          <?php endif ?>
        <?php endforeach ?>
        </div>
        <script>
            Galleria.loadTheme('js/galleria.classic.js');
            $("#gallery").galleria({
                width: 555,
                height: 400,
				 preload: 3,
    			imageCrop: 'height',
				thumbCrop: 'height',
				thumbFit: true,
				showCounter: false,
				thumbMargin: 0
            });
        </script>
      </div>
      <div class="main_details">
      <h4><?php echo $available_homes_lotsRecord['street_address'] ?></h4>
	  <p><span class="small_text">Starting at: </span><?php echo $available_homes_lotsRecord['price'] ?><br />
      </p>
      <p class="desc"><?php echo $available_homes_lotsRecord['short_description'] ?></p>
      </div>
      <div class="details">
      <?php echo $available_homes_lotsRecord['feature_list'] ?>
      </div>	
      </div>
  </div><!-- content_box -->
  </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>