<?php $thisPage="home"; ?>
<?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 */
  require_once "/the/path/to/my/database/viewer_functions.php";

  list($listingsRecords, $listingsMetaData) = getRecords(array(
    'tableName'   => 'listings',
	'orderBy'     => 'featured',
	'where'		  => 'featured = 1',
	'perPage'     => '50',
	

  ));
    list($regionsRecords, $selectedCategory) = getCategories(array( 
    'tableName'   => 'regions', 
  )); 
  $regionsByNum = array_combine(array_pluck($regionsRecords, 'num'), $regionsRecords); 

?>


<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  require_once "/the/path/to/my/database/viewer_functions.php";

  list($home_pageRecords, $home_pageMetaData) = getRecords(array(
    'tableName'   => 'home_page',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $home_pageRecord = @$home_pageRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$home_pageRecord) {
    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=UTF-8" />
<title><?php echo $home_pageRecord['page_title'] ?></title>
<meta name="keywords" content="<?php echo $home_pageRecord['meta_keywords'] ?>" />
<meta name="description" content="<?php echo $home_pageRecord['meta_description'] ?>" />

<?php include("inc/css-js.php"); ?>

<script type="text/javascript">
$(document).ready(function() {	

	//Show Banner
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity

	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
			
	//Toggle Teaser
	$("a.collapse").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
	});
	
});//Close Function
</script>
<style type="text/css">
<!--
.style1 {
	color: #4E1415;
	font-weight: bold;
}
-->
</style>
</head>

<body class="body-bg">
<div class="wrapper">
<!--Header Start-->
<div class="header-container">
	<?php include("inc/header-fr.php"); ?>
</div>
<!--Header End-->
<!--content Start-->
<div class="content-container">
  <div class="content">

  <div id="main" class="container">
      
	<div class="main_image">
     <?php foreach ($listingsRecords as $record): ?>
     <?php if ($record['featured']): ?> 
        <?php foreach ($record['photos'] as $upload): ?>
		<img src="<?php echo $upload['urlPath'] ?>"  title="<?php echo $upload['info1'] ?>" />
        <?php break; ?>
                <?php endforeach ?>
		<div style="display: block;" class="desc">
			<a href="#" class="collapse">Close Me!</a>
			<div style="opacity: 0.85;" class="block">
				<h2><?php echo $record['title'] ?></h2>
				<small><?php echo $regionsByNum[$record['city_town']]['name'] ?>  | Chambres: <?php echo $record['bedrooms'] ?> | Salle de bains: <?php echo $record['bathrooms'] ?> | $<?php echo $record['price'] ?></small>
				
				<p><?php echo $record['summary_fr'] ?> </p>
				<p><a href="listing-fr.php?<?php echo $record['num'] ?>" >&rarr;Plus d'info</a></p>
			</div>
		</div>
        <?php break; ?>
        <?php endif ?> 
        <?php endforeach ?>
	</div>
	<div class="image_thumb">
		<ul>
        <?php foreach ($listingsRecords as $record): ?>
        <?php if ($record['featured']): ?> 
        <?php foreach ($record['photos'] as $upload): ?>
			<li>
			  <a href="<?php echo $upload['urlPath'] ?>"  title="<?php echo $upload['info2'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>"width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="<?php echo $upload['info2'] ?>" /></a>
                <?php break; ?>
                <?php endforeach ?>
				<div class="block">
					<h2><?php echo $record['title'] ?></h2>
					<small><?php echo $regionsByNum[$record['city_town']]['name'] ?>  | $<?php echo $record['price'] ?><br />
Chambres: <?php echo $record['bedrooms'] ?> | Salle de bains: <?php echo $record['bathrooms'] ?></small>
					<p><?php echo $record['summary_fr'] ?> </p><p><a href="<?php echo $record['_link'] ?>" >&rarr;Plus d'info</a></p>
				</div>
			</li>
            <?php endif ?> 
            <?php endforeach ?>
		  </ul>
	</div>
    <div style="clear:both;"></div>
    <div class="featured-banner"><img src="images/featured-banner-fr.png" alt="En vedette" /></div>
</div>


    <div class="content-container2">
    <div class="content-left">
        <h1><?php echo $home_pageRecord['title_fr'] ?></h1>
      <div class="subtitle"><?php echo $home_pageRecord['sub_title_fr'] ?></div>
        <?php echo $home_pageRecord['content_fr'] ?>
        
      <h5><?php echo $home_pageRecord['open_houses_title_fr'] ?></h5>
        <p><?php echo $home_pageRecord['open_houses_text_fr'] ?></p>
        <?php foreach ($listingsRecords as $record): ?>
        <?php if ($record['open_house']): ?> 
        <div class="product2">
        <?php foreach ($record['photos'] as $upload): ?>
  <div class="product-thumb2">
  <div class="<?php echo $record['sold'] ?>"></div><div class="<?php echo $record['open_house'] ? "yes" : "no"; ?>"></div>
  <a href="listing-fr.php?<?php echo $record['num'] ?>" ><img src="<?php echo $upload['thumbUrlPath2'] ?>"width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt='' /></a></div>
  <?php break; ?>
  <?php endforeach ?>
  <div class="product-description2">
    <h2><?php echo $record['title'] ?></h2>
    <h3><?php echo $regionsByNum[$record['city_town']]['name'] ?>  | $<?php echo $record['price'] ?> |  MLS#: <?php echo $record['mls'] ?><br />
      <span class="style1"><?php echo $record['open_house_start'] ?></span></h3>
    <p><?php echo $record['summary'] ?></p>
  </div>
  <div class="product-button2">

  <a href="listing-fr.php?<?php echo $record['num'] ?>"><img src="images/learn-more-fr.jpg" alt="Learn More" title="Learn More" /></a>  </div>
  <div style="clear:both;"></div>
</div>
<?php endif ?> 
<?php endforeach ?>
    </div>
    <div class="content-right">
    <?php include("inc/side-bar-fr.php"); ?>
    </div>
    <div style="clear:both;"></div>
  </div>
  
</div></div>
<!--Content End-->
<!--Footer Start-->
<div class="footer-container">
	<?php include("inc/footer-fr.php"); ?>
</div>

<!--Footer End-->
</div>
</body>
</html>
