<?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
  

	list($listingsRecords, $listingsMetaData) = getRecords(array(  
	'tableName' => 'listings',  
	'limit' => '1',  
	));  
	$listingsRecord = @$listingsRecords[0];  
	if (!$listingsRecord) { header("HTTP/1.0 404 Not Found"); print "Listing not found!"; exit; } 
	  
	list($agentsRecords, $agentsMetaData) = getRecords(array(  
	'tableName' => 'agents',  
	'where' => mysql_escapef('num = ?', $listingsRecord['agent']), 
	'allowSearch' => false, 
	'limit' => 1,  
	));  
	$agentsRecord = @$agentsRecords[0]; 
	if (!$agentsRecord) { header("HTTP/1.0 404 Not Found"); print "Agent not found!"; exit; } 


?>
<!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"); ?>   
<link rel="stylesheet" type="text/css" href="/assets/css/shadowbox.css">
<script type="text/javascript" src="/assets/js/shadowbox.js"></script>
<script type="text/javascript">
Shadowbox.init();
</script>
  <!-- STEP1: Map with single address: Put this in the <head> of your page, rename $record if needed -->
  <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  <script type="text/javascript">
    function initialize() {
      var latitude    = <?php echo floatval(@$listingsRecord['latitude']); ?>;
      var longitude   = <?php echo floatval(@$listingsRecord['longitude']); ?>;
      var mapCanvasId = 'map_canvas';
      if (latitude) {
        var mapOptions  = { mapTypeId: google.maps.MapTypeId.ROADMAP };
        var map         = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions);
        var latLng      = new google.maps.LatLng(latitude, longitude);
        var marker      = new google.maps.Marker({map: map, position: latLng });

        map.setCenter(latLng);
        map.setZoom(14);
      }
    }
  </script>
  <!-- /STEP1: Map with single address -->
</head>
<body  onload="initialize()">
<?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> -->
              <h1><?php echo $listingsRecord['street_address'] ?>, <?php echo $listingsRecord['suburb'] ?></h1>
                <div class="summaryBar">
                <?php if ($listingsRecord['price']): ?>
                    <span class="green">Price: </span>
					<?php
					$number = $listingsRecord['price'];
					setlocale(LC_MONETARY, 'en_US');
					echo money_format('%(#10.2n', $number) . "\n";
					?>
                <?php endif ?>
                <?php if ($listingsRecord['auction']): ?>
                    <span class="green">Auction:</span> <?php echo date("D, jS M: g:i a", strtotime($listingsRecord['auction_date'])) ?> | 
                <?php endif ?>
                    <span style="text-align:right; float:right;">
                    Beds: <?php echo $listingsRecord['beds'] ?> <span class="green">| </span>
                    Baths: <?php echo $listingsRecord['baths'] ?> <span class="green">| </span> 
                    Cars: <?php echo $listingsRecord['cars'] ?>
                    </span>
                </div>
                
                <div class="column">
                <?php echo $listingsRecord['description'] ?>
                    <div class="column">
                        <h2>Features</h2>
                            <ul><li><?php echo join('</li><li>', getListLabels('listings', 'features', $listingsRecord['features'])); ?></li></ul>
                    </div>
                    <div class="column">
                        <h2>Nearby</h2>
                            <ul><li><?php echo join('</li><li>', getListLabels('listings', 'proximity', $listingsRecord['proximity'])); ?></li></ul>
                    </div>

                <div class="clearfix"></div>
                <div class="summaryBar" style="text-align:center; margin-top:20px;">Contact Details</div>
                <img src="<?php echo qrCode(array( 'type' => 'contact', 'size' => '150','mode' => 'url', 'firstName' => $agentsRecord['first_name'], 'lastName' => $agentsRecord['surname'], 'address' => '460 Anzac Parade, Kingsford NSW 2032, Australia', 'phone' => $agentsRecord['phone'], 'email' => $agentsRecord['email'] )); ?>" alt="Add Contact" style="float:left; margin-right:20px;">
                <h3 style="margin:0;"><?php echo $agentsRecord['first_name'] ?> <?php echo $agentsRecord['surname'] ?></h3>
                <p>P] <?php echo $agentsRecord['phone'] ?><br />
                M] <?php echo $agentsRecord['mobile'] ?><br />
                E] <?php echo $agentsRecord['email'] ?></p>
                
                <p><strong>Office Details:</strong><br /><?php echo $snippetsRecord['street_address'] ?></p>
                

                </div>
                <div class="column">
                    <?php foreach ($listingsRecord['images'] as $upload): ?>
                        <a href="<?php echo $upload['urlPath'] ?>" rel="shadowbox[<?php echo $listingsRecord['num'] ?>]"/>
                        <img src="<?php echo $upload['urlPath'] ?>" width="100%" alt="<?php echo $listingsRecord['suburb'] ?>" />
                    <div class="summaryBar" style="text-align:center;">View Image Gallery</div></a>
					<?php break ?>
					<?php endforeach ?>
                    
                    <?php foreach ($listingsRecord['images'] as $upload): ?>
                        <a href="<?php echo $upload['urlPath'] ?>" rel="shadowbox[<?php echo $listingsRecord['num'] ?>]"/></a>
					<?php endforeach ?>
                    
                      <!-- STEP3: Map with single address: Put this where you want your map displayed, rename $record if needed -->
                      <?php if (@$listingsRecord['latitude']): ?>
                        <div id="map_canvas" style="width: 100%; height: 299px;"></div>
                      <?php endif ?>
                    
                      <?php if (!@$listingsRecord['latitude']): ?>
                        <div style="width: 299px; height: 100%; float: left;">
                          <div style="text-align: center; padding-top: 135px">
                            No map available!
                          </div>
                        </div>
                      <?php endif ?>
                      <!-- STEP3: /Map with single address -->
                </div>
                


			</div>
</div>
<?php include("_insertBottom.php"); ?>   
