<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  require_once "/home/luxurychartergroup/luxurychartergroup.com/cms/lib/viewer_functions.php";

  list($destinationsRecords, $destinationsMetaData) = getRecords(array(
    'tableName'   => 'destinations',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
	'useSeoUrls'	=> true,
  ));
  $destinationsRecord = @$destinationsRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$destinationsRecord) {
    header("HTTP/1.0 404 Not Found");
    print "Record not found!";
    exit;
  }
  
  $destNum = $destinationsRecord['num']; 
  $destNum = implode(',', explode("	", trim($destNum)));
  if (!$destNum) { $destNum = 1; } // default num 
  list($yachtsRecords, $yachtsMetaData) = getRecords(array(
    'tableName'   => 'yachts',
    'limit'       => '5',
    'allowSearch' => '0',
	'where'		  => "destinations IN ($destNum)",  
	'useSeoUrls'	=> true,
	//'debugSql' =>'true',
  ));
  
  list($settingsRecords, $settingsMetaData) = getRecords(array(
    'tableName'   => 'settings',
    'limit'       => '1',
	// 'debugSql' =>'true',
  ));
  $settingsRecord = @$settingsRecords[0]; // get first record

?>

<!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 $destinationsRecord['title'] ?> - <?php echo $settingsRecord['title'] ?></title>
<meta name="description" content="Description here" />
<link rel="canonical" href="<?php echo $settingsRecord['web'] ?>/<?php echo $destinationsRecord['_link'] ?>" />
<link rel="stylesheet" type="text/css" href="/library/css/style.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/library/slimbox/slimbox2.css" />
<script type="text/javascript" src="/library/js/scripts.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript" src="/library/slimbox/slimbox2.js"></script>
</head>
<body>
<div class="wrapper">
	
	<div class="navbar">
		<? include("library/inc/navbar.php"); ?>
	</div>
	<div class="topbar">
		<div class="banner">
			<?php if ($destinationsRecord['banner_image']): ?>  
				<?php foreach ($destinationsRecord['banner_image'] as $upload): ?>
					<img src="<?php echo $upload['urlPath'] ?>" width="649" height="220" alt="<?php echo $destinationsRecord['name'] ?>" />
				<?php endforeach ?>
			<?php else: ?>
				<?php foreach ($settingsRecord['default_banner'] as $upload): ?>
					<img src="<?php echo $upload['urlPath'] ?>" width="649" height="220" alt="<?php echo $destinationsRecord['name'] ?>" />
				<?php endforeach ?>
			<?php endif ?>
		</div>
		<div class="logo"><img src="/library/img/logo.png" alt="<?php echo $settingsRecord['title'] ?>" width="300" height="220" /></div>
	</div>
	<div class="content">
		<div class="maincol">
			<h1><?php echo $destinationsRecord['heading'] ?></h1>
            
			<?php if ($destinationsRecord['intro']): ?><div class="intro"><?php echo $destinationsRecord['intro'] ?></div><?php endif ?>
			
			<div class="gallery">
			<?php foreach ($destinationsRecord['gallery_images'] as $upload): ?>
				<a href="<?php echo $upload['urlPath'] ?>" title="<?php echo $upload['info1'] ?>" rel="lightbox-gallery"><img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo $upload['info1'] ?>" class="imglarge" /></a>
				<?php break ?>
			<?php endforeach ?>	
			
			<?php $count = 0; ?> 
			<?php foreach ($destinationsRecord['gallery_images'] as $upload): ?>
				<?php $count++; ?> 
				<?php if ($count>1): ?> 
					<a href="<?php echo $upload['urlPath'] ?>" title="<?php echo $upload['info1'] ?>" rel="lightbox-gallery"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="<?php echo $upload['info1'] ?>" class="imgsmall <?php $maxCols=3; if (@++$count2 % $maxCols == 0): ?>last<?php endif; ?>" /></a>
				<?php endif ?>
			<?php endforeach ?>
			<div class="clear"></div>
			</div>
			
			<?php if ($destinationsRecord['content_1']): ?><div><?php echo $destinationsRecord['content_1'] ?></div><?php endif ?>
			
			<?php foreach ($destinationsRecord['map_images'] as $upload): ?>
				<a href="<?php echo $upload['urlPath'] ?>" title="<?php echo $upload['info1'] ?>" rel="lightbox-gallery"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="<?php echo $upload['info1'] ?>" /></a>
			<?php endforeach ?>
            
            <?php if ($destinationsRecord['content_2']): ?><div><?php echo $destinationsRecord['content_2'] ?></div><?php endif ?>
            
            <p><b>View all <a href="/destination-yachts.php/<?php echo strtolower($destinationsRecord['name']) ?>-<?php echo $destinationsRecord['num'] ?>/">charter yachts in <?php echo $destinationsRecord['name'] ?></a>.</b></p>
			
</div>
		<div class="sidecol">
			<? include("library/inc/searchbox.php"); ?>

                
			<?php if ($yachtsRecords): ?>
            <div class="block">
            	<h2>yachts available in <?php echo $destinationsRecord['name'] ?></h2>
                <?php foreach ($yachtsRecords as $record): ?>
                    <div class="relatedYachts">
                    <?php if ($record['banner_image']): ?><?php foreach ($record['banner_image'] as $upload): ?><a href="/<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="<?php echo $record['yacht_name'] ?>" /></a><?php endforeach ?>
                    <?php else: ?><a href="/<?php echo $record['_link'] ?>"><img src="/library/img/default-image-banner-small.jpg" width="290" height="90" alt="<?php echo $record['yacht_name'] ?>" /></a>
                    <?php endif ?>
                    <br /><a href="/<?php echo $record['_link'] ?>"><?php echo $record['yacht_name'] ?></a> - 
                    <span>
					<?php if ($record['yacht_length']): ?><?php echo $record['yacht_length'] ?>m (<?php echo round($record['yacht_length'] * 3.2808399); ?>')<?php endif ?>
					<?php if ($record['guests_night']): ?> <?php echo $record['guests_night'] ?> Guests</span><?php endif ?>
                    </div>
                <?php endforeach ?>
                
                <div class="moreYachts"><a href="/destination-yachts.php/<?php echo strtolower($destinationsRecord['name']) ?>-<?php echo $destinationsRecord['num'] ?>/">View all yachts in <?php echo $destinationsRecord['name'] ?></a></div>
            </div>
            <?php endif ?>
				
			
            
			<div class="enquire">
				<h2>enquire about <?php echo $destinationsRecord['name'] ?></h2>
				<? include("library/inc/enquiry_destination.php"); ?>
			</div>
		</div>
		<div class="clear"></div>
	</div>
	<div class="footer">
		<? include("library/inc/footer.php"); ?>
	</div>
	<div class="copyright">
		<? include("library/inc/copyright.php"); ?>
	</div>
</div>
</body>
</html>
