<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
  require_once "init.php";

  list($listingRecords, $listingMetaData) = getRecords(array(
    'tableName'   => 'listings',
    'joinTable'   => 'homepages',
    'perPage'     => '10',
	'orderBy'     => 'price',

  ));
  
  list($listingRecords, $listingDetails) = getRecords(array(
    'tableName'   => 'listings',
    'joinTable'   => 'homepages',
    'perPage'     => '10',
	'orderBy'     => 'price',

  ));

?>
<!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>Villa Connect</title>
</head>

<link rel="stylesheet" type="text/css" href="../css/sitelayout.css" />
<link rel="stylesheet" type="text/css" href="../css/villaconnstyle.css" />
<link rel="stylesheet" type="text/css" href="../css/sitenavstyle.css" />

<script type="text/javascript" src="../js/chrome.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../js/pluginpage.js"></script>
<script type="text/javascript" src="../js/jquery.pngFix.pack.js"></script>


<script type="text/javascript">
	$(document).ready(function(){
		$(document).pngFix();
	});
</script>


<body>
<div id="outer">
  <div align="center">
  <div id="main">
    <table width="990" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="990" height="160" align="left" valign="top"><table width="990" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="460"></td>
            <td width="500" align="right"><table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="75">&nbsp;</td>
                </tr>
                <tr>
                  <td align="left"><table border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="50"><img src="../images/phone.png" width="50" height="34" /></td>
                        <td width="5"></td>
                        <td><h1>+34 667 539 440</h1></td>
                      </tr>
                  </table></td>
                </tr>
                <tr>
                  <td height="5"></td>
                </tr>
                <tr>
                  <td align="left"><table border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="50"><img src="../images/mail.png" width="50" height="34" /></td>
                        <td width="5"></td>
                        <td><h3><a href="mailto:info@villaconnectspain.com" class="two">info@villaconnectspain.com</a></h3></td>
                      </tr>
                  </table></td>
                </tr>
            </table></td>
            <td width="30">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td width="990" height="40" align="left" valign="top" class="navbackstyle"><!-- #BeginLibraryItem "/Library/navigation.lbi" --><table width="990" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="35">&nbsp;</td>
            <td width="110"><table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="30"><a href="#"><img src="../images/spain-flag.gif" width="30" height="32" /></a></td>
                <td width="10"></td>
                <td width="30"><a href="#"><img src="../images/german-flag.gif" width="30" height="32" /></a></td>
                <td width="10"></td>
                <td width="30"><a href="#"><img src="../images/uk-flag.gif" width="30" height="32" /></a></td>
              </tr>
            </table></td>
            <td width="810"><div class="chromestyle" id="chromemenu">
                    <ul>
                      <li><a href="../index.php">Homepage</a></li>
                      <li><a href="../villa_connect_spain_buying_your_home.php">Buying Your home</a></li>
                      <li><a href="../villa_connect_spain_contact_us.php">Contact us</a></li>
                    </ul>
                    </div>
                    
                    <!--1st drop down menu -->                                                   
                <div id="dropmenu1" class="dropmenudiv" style="width: 180px;">
                      <a href="#">Sub menu item</a>
                      <a href="#">Sub menu item</a>
                      <a href="#">Sub menu item</a>
                      <a href="#">Sub menu item</a>
                      <a href="#">Sub menu item</a>                  </div>
                    
                    
                <script type="text/javascript">

cssdropdown.startchrome("chromemenu")

</script></td>
            <td width="35">&nbsp;</td>
          </tr>
        </table><!-- #EndLibraryItem --></td>
      </tr>
      <tr>
        <td width="990" align="left" valign="top" class="sitebackstyle"><table width="990" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="35">&nbsp;</td>
            <td width="920" align="left" valign="top"><table width="920" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="920" height="30">&nbsp;</td>
              </tr>
              <tr>
                <td width="920" align="left" valign="top"><table width="920" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="290" align="left" valign="top"><table width="290" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td class="searchboxstyle"><!-- #BeginLibraryItem "/Library/property_search.lbi" --><form method="post" action="listings.php"><table width="290" height="320" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="30">&nbsp;</td>
                              <td width="230" align="left" valign="top"><table width="230" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="230" height="50"><h1>Property Search</h1></td>
                                  </tr>
                                <tr>
                                  <td width="230"><h5>Area</h5></td>
                                  </tr>
                                <tr>
                                  <td width="230"><select name="area" class="formstyle" id="area">
                                    <option value="" selected="selected">Any Area</option>
                                    <option>Javea</option>
                                    <option>Moraira</option>
                                    <option>Rural Valleys</option>
                                    </select></td>
                                  </tr>
                                <tr>
                                  <td width="230"><h5>Property Type</h5></td>
                                  </tr>
                                <tr>
                                  <td width="230"><select name="property_type" class="formstyle" id="property_type">
                                    <option value="" selected="selected">Any Type</option>
                                    <option>Detached Villa</option>
                                    <option>Finca</option>
                                    <option>Semi-detached House</option>
                                    <option>Apartment</option>
                                    <option>Plot</option>
                                    <option>Other</option>
                                    </select></td>
                                  </tr>
                                <tr>
                                  <td width="230"><h5>Bedrooms</h5></td>
                                  </tr>
                                <tr>
                                  <td width="230"><select name="bedrooms_min" class="formstyle" id="bedrooms_min">
      <option value="" selected="selected">Any</option>
      <option value="1">1+</option>
      <option value="2">2+</option>
      <option value="3">3+</option>
      <option value="4">4+</option>
      <option value="5">5+</option>
      <option value="6">6+</option>
                                  </select>
                                    </select></td>
                                  </tr>
                                <tr>
                                  <td><table width="230" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td width="105"><h5>Price min</h5></td>
                                      <td width="20">&nbsp;</td>
                                      <td width="105"><h5>Price max</h5></td>
                                      </tr>
                                    <tr>
                                      <td width="105"><select name="price_min" class="formstyle2">
      <option value="0" selected="selected">Any</option>
      <option value="90000">90,000</option>
      <option value="100000">100,000</option>
      <option value="200000">200,000</option>
      <option value="300000">300,000</option>
      <option value="400000">400,000</option>
      <option value="500000">500,000</option>
      <option value="600000">600,000</option>
      <option value="700000">700,000</option>
      <option value="800000">800,000</option>
      <option value="900000">900,000</option>
      <option value="1000000">1,000,000</option>
      <option value="2000000">2,000,000</option>
                                                                      </select></td>
                                      <td width="20">&nbsp;</td>
                                      <td width="105">
      <select name="price_max" class="formstyle2">
      <option value="" selected="selected">Any</option>
      <option value="200000">200,000</option>
      <option value="300000">300,000</option>
      <option value="400000">400,000</option>
      <option value="500000">500,000</option>
      <option value="600000">600,000</option>
      <option value="700000">700,000</option>
      <option value="800000">800,000</option>
      <option value="900000">900,000</option>
      <option value="1000000">1,000,000</option>
      <option value="2000000">2,000,000</option>
      <option value="">No Maximum</option>
      </select></td>
                                      </tr>
                                    </table></td>
                                  </tr>
                                <tr>
                                  <td width="230"><h5>Ref Number</h5></td>
                                  </tr>
                                <tr>
                                  <td width="230"><input name="reference_number" type="text" class="formstyle" id="reference_number" /></td>
                                  </tr>
                                <tr>
                                  <td width="230" height="5"></td>
                                </tr>
                                <tr>
                                  <td width="230" align="center"><input name="button" type="submit" class="butstyle1" id="button" value="Submit" /></td>
                                  </tr>
                                </table></td>
                              <td width="30">&nbsp;</td>
                              </tr>
                            </table></form><!-- #EndLibraryItem --></td>
                      </tr>
                      <tr>
                        <td width="290" height="30">&nbsp;</td>
                      </tr>
                      <tr>
                        <td width="290" align="left" valign="top" class="serviceboxstyle"><!-- #BeginLibraryItem "/Library/what_next.lbi" --><table width="290" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="30">&nbsp;</td>
                            <td width="230" align="left" valign="top"><table width="230" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="230" height="50"><h4>What Next</h4></td>
                              </tr>
                              <tr>
                                <td align="left" valign="top" class="whitetext"><p>If you would like more information about the areas, a specific property or just general guidance, please send us an <a href="mailto:info@villaconnectspain.com" class="three">email</a> or give us a call.</p>
                                    <p>See our <a href="../villa_connect_spain_contact_us.php" class="three">contact page</a> for details.</p>
                                  <p>&nbsp;</p></td>
                              </tr>
                              </table></td>
                            <td width="30">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="3" class="serviceboxbotstyle">&nbsp;</td>
                            </tr>
                        </table><!-- #EndLibraryItem --></td>
                        </tr>
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td width="290"><img src="../images/botlogo.gif" alt="Villa Connect Logo" width="290" height="116" /></td>
                        </tr>
                      </table></td>
                    <td width="30" height="290">&nbsp;</td>
                    <td width="600" align="left" valign="top"><table width="600" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="600" height="50" align="left" valign="top" class="featuredtopstyle2"><table width="600" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="30" height="50">&nbsp;</td>
                            <td width="270" height="50"><h2><?php echo $listingMetaData['totalRecords']; ?> Records Found</h2></td>
                            <td width="270" align="right"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                              <tr>
                                <td width="98" class="whitetext"><strong class="whitetextlg">Page <?php echo $listingDetails['page'] ?> of <?php echo $listingDetails['totalPages'] ?></strong></td>
                                <td width="8"></td>
                                <td width="21"><!-- START PAGINATION CODE -->
                                    <?php if ($listingMetaData['prevPage']): ?>
                                    <a href="<?php echo $listingMetaData['prevPageLink'] ?>"><img src="../images/prev-arrow.gif" width="21" height="17" border="0" /></a>
                                    <?php else: ?>
                                    <img src="../images/prev-arrow.gif" width="21" height="17" />
                                    <?php endif ?>
                                </td>
                                <td width="122" align="center" class="whitetextlg"><?php  
    if (@!$_GET['page']): $current_page = "1"; 
    else: $current_page = $_GET['page'];    
  endif;  ?>
                                    <?php foreach (range(1,$listingMetaData['totalPages']) as $page): ?>
                                    <?php if ($page == $current_page): ?>
                                    <strong><?php echo $page; ?></strong>
                                    <?php else: ?>
                                    <a href="?<?php echo http_build_query(array_merge($_REQUEST, array( 'page' => $page ))) ?>" class="whitetextlg"><?php echo $page; ?></a>
                                    <?php endif ?>
                                    <?php endforeach; ?></td>
                                <td width="21"><?php if ($listingMetaData['nextPage']): ?>
                                    <a href="<?php echo $listingMetaData['nextPageLink'] ?>"><img src="../images/fwd-arrow.gif" width="21" height="17" /></a>
                                    <?php else: ?>
                                    <img src="../images/fwd-arrow.gif" width="21" height="17" />
                                    <?php endif ?>
                                    <!-- /END PAGINATION CODE --></td>
                              </tr>
                            </table></td>
                            <td width="30" height="50">&nbsp;</td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td width="600" class="featuredstyle"><table width="600" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="14"></td>
                            <td width="572"> <table width="572" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="572" height="15"><br/>                             </tr>
                              <!-- show listings -->
                              <?php foreach ($listingRecords as $listing): ?>
                              <tr>
                                <td width="572" align="left" valign="top" class="resboxstyle"><table width="560" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="200" align="left" valign="top">
                                          <?php foreach ($listing['uploads'] as $upload): ?>
        <?php if ($upload['hasThumbnail']): ?>
          <a href="<?php echo $listing['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt="<?php echo $upload['info1'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" border="0" class="image_border" /></a><br/>
          <?php break /* only show one image */ ?>
        <?php endif; ?>
      <?php endforeach ?>

      <?php if (!$listing['uploads']): /* if no uploads show this: */ ?>
<table cellspacing="0" cellpadding="0" width="200" class="noPhoto" style="height: 134px">
         <tr><td bgcolor="#EEEEEE" align="center"><b>Photo<br/>Not<br/>Available</b></td></tr>
        </table><br /><br />
         <?php endif; ?> 
                                    <td width="30">&nbsp;</td>
                                    <td width="330" align="left" valign="top"><table width="280" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="280" align="left" valign="top"><table width="330" border="0" cellpadding="2" cellspacing="0">
                                          <tr>
                                            <td colspan="3" bgcolor="#83BE24" class="whitetextlg">&nbsp;<b><?php echo $listing['property_type'] ?></b></td>
                                            <td colspan="2" align="right" bgcolor="#83BE24" class="whitetextlg"><b><?php echo number_format($listing['price']) ?>€</b>&nbsp;</td>
                                            </tr>
                                          <tr>
                                            <td width="72" class="greytext"><strong>Town:&nbsp; </strong></td>
                                            <td width="111" class="greytext"><?php echo $listing['town'] ?></td>
                                            <td width="15">&nbsp;</td>
                                            <td width="89" class="greytext"><strong>Build&nbsp;Size&nbsp;m<sup>2</sup>:&nbsp;</strong></td>
                                            <td width="43" class="greytext"><?php echo $listing['house_size_m'] ?></td>
                                          </tr>
                                          <tr>
                                            <td class="greytext"><strong>Bedrooms:&nbsp;</strong></td>
                                            <td class="greytext"><?php echo $listing['bedrooms'] ?></td>
                                            <td>&nbsp;</td>
                                            <td class="greytext"><strong>Bathrooms:&nbsp;</strong></td>
                                            <td class="greytext"><?php echo $listing['bathrooms'] ?></td>
                                          </tr>
                                          <tr>
                                            <td colspan="5"><span class="greytext"><?php echo $listing['summary'] ?></span></td>
                                            </tr>
                                          <tr>
                                            <td colspan="2" class="greytext"><strong>For more Information</strong></td>
                                            <td>&nbsp;</td>
                                            <td colspan="2"><a href="<?php echo $listing['_link'] ?>" class="one">Click Here</a></td>
                                            </tr>

                                        </table></td>
                                      </tr>
                                      <tr>
                                        <td width="280" align="left" valign="top"><table width="280" border="0" cellspacing="0" cellpadding="0">
                                        </table></td>
                                      </tr>
                                      </table></td>
                                  </tr>
                                </table>
                                  
                                  <!-- /show listings -->
<!-- show errors -->
	<?php if ($listingDetails['invalidPageNum']): ?>  
Results page '<?php echo $listingDetails['page']?>' not found, <a href="<?php echo $listingDetails['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/>
  <br/>
	<?php elseif (!$listingRecords): ?>
  No listings were found!<br/><br/>
	<?php endif ?>
							<!-- /show errors --></td>
                              </tr><tr><td height="8"></td>
                              </tr><?php endforeach ?>
                              <tr>
                                <td width="572"><table width="570" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td height="15" colspan="4"></td>
                                    </tr>
                                  <tr>
                                    <td width="15" height="50">&nbsp;</td>
                                    <td width="270" height="50"><h6><?php echo $listingMetaData['totalRecords']; ?> Records Found</h6></td>
                                    <td width="270" align="right"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                      <tr>
                                        <td width="98"><strong class="greentextlg">Page <?php echo $listingDetails['page'] ?> of <?php echo $listingDetails['totalPages'] ?></strong></td>
                                        <td width="8"></td>
                                        <td width="21"><!-- START PAGINATION CODE -->
                                            <?php if ($listingMetaData['prevPage']): ?>
                                            <a href="<?php echo $listingMetaData['prevPageLink'] ?>"><img src="../images/prev-arrow2.gif" width="21" height="17" border="0" /></a>
                                            <?php else: ?>
                                            <img src="../images/prev-arrow2.gif" width="21" height="17" />
                                            <?php endif ?>
                                        </td>
                                        <td width="122" align="center" class="greentextlg"><?php  
    if (@!$_GET['page']): $current_page = "1"; 
    else: $current_page = $_GET['page'];    
  endif;  ?>
                                            <?php foreach (range(1,$listingMetaData['totalPages']) as $page): ?>
                                            <?php if ($page == $current_page): ?>
                                            <strong><?php echo $page; ?></strong>
                                            <?php else: ?>
                                            <a href="?<?php echo http_build_query(array_merge($_REQUEST, array( 'page' => $page ))) ?>" class="greentextlg"><?php echo $page; ?></a>
                                            <?php endif ?>
                                            <?php endforeach; ?></td>
                                        <td width="21"><?php if ($listingMetaData['nextPage']): ?>
                                            <a href="<?php echo $listingMetaData['nextPageLink'] ?>"><img src="../images/fwd-arrow2.gif" width="21" height="17" /></a>
                                            <?php else: ?>
                                            <img src="../images/fwd-arrow2.gif" width="21" height="17" />
                                            <?php endif ?>
                                            <!-- /END PAGINATION CODE --></td>
                                      </tr>
                                    </table></td>
                                    <td width="15" height="50">&nbsp;</td>
                                    </tr>
                                  </table></td>
                              </tr>
                              </table></td>
                            <td width="14"></td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td width="600" height="15" class="featuredbotstyle"></td>
                      </tr>
                    </table></td>
                    </tr>
                  </table></td>
              </tr>
              </table></td>
            <td width="35">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td width="990" height="40" align="left" valign="top" class="sitebotstyle">&nbsp;</td>
      </tr>
      <tr>
        <td width="990" height="30">&nbsp;</td>
      </tr>
    </table>
  
    <table width="100%" border="0" cellpadding="0" cellspacing="0" background="../images/footerpt.gif">
      <tr>
        <td align="center"><table width="990" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="990" height="41" align="center" class="footerstyle"><table width="920" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="460" align="left"><a href="http://www.webvision.es" target="_blank" class="three">Website by Webvision</a></td>
                    <td width="460" align="right" class="bluetext"><div align="right" class="whitetext">
                        <div align="right"><strong>Copyright &copy; Villa Connect 2011</strong></div>
                    </div></td>
                  </tr>
              </table></td>
            </tr>
        </table></td>
      </tr>
    </table>
  </div></div>
</div>
</body>
</html>
