<?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('/usr/local/pem/vhosts/101974/webspace/httpdocs/','','../','../../','../../../');
  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($snippetsRecords, $snippetsMetaData) = getRecords(array(
    'tableName'   => 'snippets',
    'allowSearch' => '0',
    'limit'       => '1',
  ));
  $snippetsRecord = @$snippetsRecords[0]; // get first record
  
  // load records
  list($page_contentRecords, $page_contentMetaData) = getRecords(array(
    'tableName'   => 'page_content',
    'where'       => 'num = 4',
    'limit'       => '1',
  ));
  $page_contentRecord = @$page_contentRecords[0]; // get first record

  // load records
  list($listingsRecords, $listingsMetaData) = getRecords(array(
    'tableName'   => 'listings',
	'where' => 'category="For Sale"',
  ));
    
?>
<!doctype html>
<html>
<head>
<title><?php echo $snippetsRecord['seo_title'] ?> | <?php echo $page_contentRecord['seo_title'] ?></title>
<meta charset="utf-8" />
<meta name="keywords" content="<?php echo $page_contentRecord['seo_keywords'] ?>" />
<meta name="description" content="<?php echo $page_contentRecord['seo_description'] ?>" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<?php include("_insertHeaderCode.php"); ?>   

</head>
<body>
<?php include("_insertTop.php"); ?>   
<div id="wrapper" class="clearfix">
			<div id="maincol" class="mainContent">
            <!--<div class="secondNavigation"><a href="#">For Sale</a>  |  <a href="#">Hints & Tips</a></div> -->
                <?php foreach ($listingsRecords as $record): ?>
                <div class="propertySummary">
                <div class="propertyImage">
                  <!-- STEP 2a: Display Uploads for field 'hero_shot' (Paste this anywhere inside STEP2 to display uploads) -->
                    <!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
                    <?php foreach ($record['hero_shot'] as $upload): ?>
                      <?php if ($upload['hasThumbnail']): ?>
                        <img src="<?php echo $upload['thumbUrlPath'] ?>" >
            
                      <?php elseif ($upload['isImage']): ?>
                        <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
            
                      <?php else: ?>
                        <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
            
                      <?php endif ?>
                    <?php endforeach ?>
                  <!-- STEP2a: /Display Uploads -->
                </div>
                <div class="propertyDetail">
                <h3><?php echo $record['title'] ?></h3>
                <h2><?php echo $record['street_address'] ?>, <?php echo $record['suburb'] ?></h2>
                <div class="summaryBar">
                <?php if ($record['price']): ?>
                    <span class="green">Price: </span>
					<?php
					$number = $record['price'];
					setlocale(LC_MONETARY, 'en_US');
					echo money_format('%(#10.2n', $number) . "\n";
					?>
                <?php endif ?>
                <?php if ($record['auction']): ?>
                    <span class="green">Auction:</span> <?php echo date("D, jS M: g:i a", strtotime($record['auction_date'])) ?> | 
                <?php endif ?>
                    <span style="text-align:right; float:right;">
                    Beds: <?php echo $record['beds'] ?> <span class="green">| </span>
                    Baths: <?php echo $record['baths'] ?> <span class="green">| </span> 
                    Cars: <?php echo $record['cars'] ?>
                    </span>
                </div>
                  <?php echo $record['description'] ?>
                 <div class="summaryBar">
                 <a href="<?php echo $record['_link'] ?>">View Property Details</a>
                 </div>
                
                </div>
                <div class="clearfix"></div>
            
            
                
                </div>




                
                <?php endforeach ?>

				<?php if (!$listingsRecords): ?>
                  <div class="summaryBar" style="text-align:center;">There are currently no records available.  Please come back soon</div>
                <?php endif ?>
			</div>
</div>
<?php include("_insertBottom.php"); ?>   
