<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
  require_once "---removed---cmsAdmin/lib/viewer_functions.php";

  list($developmentsRecords, $developmentsMetaData) = getRecords(array(
    'tableName'   => 'developments',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  
  $developmentsRecord = @$developmentsRecords[0]; // get first record
  
  
  //house types FILTERS houses types based on what development they belong to
  
   $escapedTypes = mysql_real_escape_string( @$developmentsRecord['title'] ); 
   list($house_typesRecords, $house_typesMetaData) = getRecords(array(
    'tableName'   => 'house_types',
    'where'       => " development = '$escapedTypes' ",
  ));
  
  
  //estate agents - This is where the issue is
  
	list($estate_agentsRecords, $estate_agentsMetaData) = getRecords(array(
	 'tableName'   => 'estate_agents', 	 
	 // this is where i need to add a filter to display only the estate agents who are selling property from this development
	 
	    ));
		
?>



<!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=iso-8859-1" />
<title>Tracey Brothers - Fermanagh's Leading Construction Firm</title>
<script type="text/javascript" src="../swfobject.js"></script>
<link href="../stylesheet.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" type="text/css" href="../cssverticalmenu.css" />

<script type="text/javascript" src="../cssverticalmenu.js"></script>
</head>

<body>
<div id="background"></div>
<div id="site_wrapper">

  <?php require_once('../includes/header.htm'); ?>
    <div id="main_wrapper">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="25%" valign="top" scope="col">
	  <?php require_once('../includes/menu.htm'); ?></td>
    <td width="100%" valign="top" scope="col"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td scope="col"><h1><?php echo $developmentsRecord['title'] ?></h1></td>
        <td width="105" scope="col"><?php require_once('../includes/page_tools.htm'); ?></td>
      </tr>
    </table>
      <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
    
	<br />
	  <div id="thumbnail_holder">




	   <!-- STEP 2a: Display Uploads for field 'album'  -->
	  	  <script Language=Javascript>	

function changeImageInfo(imageURL,title, id, opacStart, opacEnd, millisec)
		
{document.big_image.src = imageURL;}

</script>
		
       <table width="345" border="0" align="right" cellpadding="0" cellspacing="0">
  <tr>
    <th scope="col">
	
	
 <?php foreach ($developmentsRecord['album'] as $upload): ?>
         <?php if ($upload['hasThumbnail']): ?>
            <a href="#" onmouseover="changeImageInfo('<?php echo $upload['thumbUrlPath2'] ?>');return false"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" border="0" class="news_image" /></a>

             <?php endif ?>
        <?php endforeach ?>	
	
	</th>
  </tr>
</table>
<br clear="all"/>
		
		
		 <img src="<?php echo $upload['thumbUrlPath2'] ?>" name="big_image" width="330" height="224" border="0" class="float_image_right" id="big_image" />
		
		
      <!-- STEP2a: /Display Uploads -->
	  </div>
   <?php echo $developmentsRecord['content'] ?><br />
   <br />
   <strong>Completion Date</strong><br />   
   <?php echo $developmentsRecord['completion_date'] ?>   <br/>
      <br/>


     


      <!-- STEP 2a: Display Uploads for field 'logo' (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 ($developmentsRecord['logo'] as $upload): ?>
          <?php if ($upload['hasThumbnail']): ?>
            <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

          <?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 -->


   <br  clear="all" />
   <br  clear="all" />
    

	  
	  
	    <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
    <h1>House Types in this Development <br />
      <br />
    </h1>
	 <?php foreach ($house_typesRecords as $record): ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td height="25" colspan="2" background="../graphics/purple_bar_fade.jpg" class="white_text" scope="col"><strong><?php echo $record['title'] ?></strong></td>
        </tr>
      <tr>
        <td width="25%" scope="col"> 
		
		<!-- STEP 2a: Display Uploads for field 'pdf_download' (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 --><!-- STEP2a: /Display Uploads -->			</td>
        <td width="75%" rowspan="3" valign="top" scope="col">
		
		
          		<?php echo $record['content'] ?></td>
      </tr>
      <tr>
        <td scope="col"><?php foreach ($record['images'] as $upload): ?>
          <?php if ($upload['hasThumbnail']): ?>
          <img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" class="image_border" /><br/>
          <?php elseif ($upload['isImage']): ?>
          <img src="<?php echo $upload['urlPath'] ?>" alt="" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" class="image_border" /><br/>
          <?php else: ?>
          <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
          <?php endif ?>
          <?php endforeach ?></td>
        </tr>
      <tr>
        <td scope="col"><?php foreach ($record['pdf_download'] as $upload): ?>
          <?php if ($upload['hasThumbnail']): ?>
          <img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" class="image_border" /><br/>
          <?php elseif ($upload['isImage']): ?>
          <img src="<?php echo $upload['urlPath'] ?>" alt="" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" class="image_border" /><br/>
          <?php else: ?>
          <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
          <?php endif ?>
          <?php endforeach ?></td>
        </tr>
    </table>
    
      
      
      
    </p><?php endforeach; ?>

    <?php if (!$house_typesRecords): ?>
      No records were found!<br/>
      <br/>
    <?php endif ?>
  <!-- /STEP2: Display Records -->

	  <br />
	  <br />
	   <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
    <h1> Estate Agents for this Development </h1>
    <p class="image_border">THIS SECTION SHOULD ONLY DISPLAY THE ESTATE AGENTS I HAVE SELECTED FROM THE MULTI SELECT DROP DOWN MENU IN THE DEVELOPMENTS TABLE IN THE ADMIN SECTION AT PRESENT IT IS DISPLAYING ALL RECORDS </p>
    <p>
      <?php foreach ($estate_agentsRecords as $record): ?>
      </p>
    <table width="100%" border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td width="25%" scope="col">    <div align="left">
          <!-- STEP 2a: Display Uploads for field 'logo' (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['logo'] as $upload): ?>
          <?php if ($upload['hasThumbnail']): ?>
          <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
          
          <?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 ?>
        </div>
          <!-- STEP2a: /Display Uploads --></td>
        <td width="35%" valign="top" scope="col"><strong><?php echo $record['title'] ?></strong></td>
        <td width="40%" valign="top" scope="col"><a href="<?php echo $record['link'] ?>" target="_blank"><?php echo $record['link'] ?></a><br />
          Tel - <?php echo $record['telephone'] ?></td>
        </tr>
    </table>
    <?php endforeach; ?>

    <?php if (!$estate_agentsRecords): ?>
      No records were found!<br/>
      <br/>
    <?php endif ?>
  <!-- /STEP2: Display Records -->

	  
	  
	  
	  </td>
  </tr>
  <tr>
    <td colspan="2" valign="top" scope="col">&nbsp;</td>
  </tr>
</table>
  </div><br clear="all"/>
    
  <?php require_once('../includes/footer.htm'); ?>

  <br clear="all"/>

</div>

</body>
</html>
