<?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 = 'cms/lib/viewer_functions.php';
  $dirsToCheck = array('/home/purefiji/purefiji.com/','','../','../../','../../../');
  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($pagesRecords, $pagesMetaData) = getRecords(array(
    'tableName'   => 'pages',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $pagesRecord = @$pagesRecords[0]; // get first record

  // load breadcrumbs
  list($breadcrumbRecords, $selectedCategory) = getCategories(array(
    'tableName'           => 'pages',          // REQUIRED
    'categoryFormat'      => 'breadcrumb',           // showall, onelevel, twolevel, breadcrumb
  ));
  
  // load records
  list($website_settingsRecords, $website_settingsMetaData) = getRecords(array(
    'tableName'   => 'website_settings',
    'allowSearch' => '0',
    'limit'       => '1',
  ));
  $website_settingsRecord = @$website_settingsRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$pagesRecord) { dieWith404("Record not found!"); }
?>

<!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" />
<?php if ($pagesRecord['no_index'] ==1): ?>
<meta name="robots" content="noindex, nofollow" />
<?php endif ?>
<title><?php if ($pagesRecord['title']): ?><?php echo $pagesRecord['title'] ?> - <?php endif ?><?php echo $website_settingsRecord['site_name'] ?></title>
<?php if ($pagesRecord['meta_desc']): ?><meta name="description" content="<?php echo $pagesRecord['meta_desc'] ?>" /><?php endif ?>
<link rel="canonical" href="/<?php echo $pagesRecord['url'] ?>/" />
<link rel="stylesheet" href="/library/css/style.css" type="text/css" />
<link href="http://fonts.googleapis.com/css?family=Pinyon+Script" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="/library/js/script.js" type="text/javascript"></script>

</head>

<body class="fullbgd">
<div class="wrapper clearfix">
    <div class="main">
		<?php if ($pagesRecord['page_image']): ?>
        <?php foreach ($pagesRecord['page_image'] as $upload): ?>
        <div class="featureimage" style="background-image:url(<?php echo $upload['urlPath'] ?>);"></div>
        <?php break ?>
        <?php endforeach ?>
        <?php endif ?>
        <div class="breadcrumb"><a href="/">Home</a><?php foreach ( $breadcrumbRecords as $breadcrumb ): ?> &rsaquo; <?php if ( $breadcrumb['num'] != getLastNumberInUrl() ): ?><a href="/<?php echo strtolower($breadcrumb['url']); ?>/"><?php endif ?><?php echo $breadcrumb['name']; ?><?php if ( $breadcrumb['num'] != getLastNumberInUrl() ): ?></a><?php endif ?><?php endforeach ?></div>
        
        <div class="content">
            <?php if ($pagesRecord['heading']): ?>
            <h1 class="script"<?php if (!$pagesRecord['page_image']): ?> style="margin-top: 56px;"<?php endif ?>><?php echo $pagesRecord['heading'] ?></h1>
            <?php elseif ($pagesRecord['name']): ?>
            <h1 class="script"<?php if (!$pagesRecord['page_image']): ?> style="margin-top: 56px;"<?php endif ?>><?php echo $pagesRecord['name'] ?></h1>
			<?php endif ?>
            <!--<div class="imagecolumn"><img src="/library/img/layout/side-image.jpg" width="200" height="183" /></div>-->
            <?php if ($pagesRecord['content']): ?><?php echo $pagesRecord['content'] ?><?php endif ?>
            
			<?php  
            // Subcat navigation - First Level
            list($pagesRecords, $pagesMetaData) = getCategories(array(    
            'tableName'   => 'pages',  
            'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl()
            // 'debugSql' =>'true',
            ));  
            ?>  
            <?php $selectedCat=$pagesRecord['num']; ?>
            <?php $links = ''; ?> 
            <?php foreach ($pagesRecords as $record): ?><?php if ($record['depth'] == 0) { continue; } ?><?php if($record['hidden']==0 && $record['parentNum']==$selectedCat): ?><?php $navgridthumb='/library/img/layout/general-thumb.jpg'; ?><?php $maxCols=3; if (@++$count % $maxCols == 0): ?><?php $links .= '<div class="navgriditem last">'; ?><?php else: ?><?php $links .= '<div class="navgriditem">'; ?><?php endif; ?><?php foreach ($record['page_image'] as $upload): ?><?php $navgridthumb=$upload['thumbUrlPath']; ?><?php break ?><?php endforeach ?><?php $links .= '<div class="navgridthumb" style="background-image:url(' . $navgridthumb . ');"></div>'; ?><?php $links .= '<div class="navgridlink"><a href="/' . strtolower($record['url']) . '/">' . $record['name'] . '</a></div>'; ?><?php $links .= '</div>'; ?><?php endif; ?><?php endforeach; ?>   
			<?php if (!empty($links)): ?>
            <div class="navgrid"><?php echo $links; ?></div>
            <?php endif; ?>
            
            <?php if ($pagesRecord['youtube_video']): ?><div style="margin: 10px 0;"><iframe width="660" height="402" src="<?php echo $pagesRecord['youtube_video'] ?>" frameborder="0" allowfullscreen></iframe></div><?php endif ?>
            <?php if ($pagesRecord['additional_content']): ?><?php echo $pagesRecord['additional_content'] ?><?php endif ?>
            <?php if ($pagesRecord['blog_posts']): ?><?php include("library/inc/bloglist.php"); ?><?php endif ?>
            <?php if ($pagesRecord['contact_form']): ?><?php include("library/inc/form_contact.php"); ?><?php endif ?>
            <?php if ($pagesRecord['retailer_application_form']): ?><?php include("library/inc/form_retailer.php"); ?><?php endif ?>
            <?php if ($pagesRecord['booking_request_form']): ?><?php include("library/inc/form_spabooking.php"); ?><?php endif ?>
        </div>
    </div>
    <div class="side">
    	<div class="navsection1">
<?php include("library/inc/header.php"); ?>
        </div>
        <div class="navsection2">
            <!--<h2>Product Locator</h2>
            <ul>
            <li><a href="#">Find a Retail Store Near You</a></li>
            <li>Buy Online:<br />
			<a href="#">USA</a>, <a href="#">UK</a>, <a href="#">AU</a>, <a href="#">NZ</a>, <a href="#">FJ</a></li>
            </ul>-->
        
			<?php // Subcat Nav - Second Level
            list($pagesRecords, $pagesMetaData) = getCategories(array(    
            'tableName'   => 'pages',  
            'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl()
            'loadUploads' => '0',
            // 'debugSql' =>'true',
            ));  
            ?>  
            
            <?php $selectedCat=$pagesRecord['parentNum']; ?>
            <?php $thispagedepth=$pagesRecord['depth']; ?>
            
            <?php if ($pagesRecord['depth'] > 0): ?>
            <div class="sidebox subnav">
            <h2>In this Section:</h2>
            <ul>
            <?php foreach ($pagesRecords as $record): ?>      
            <?php if($record['hidden'] == 0 && $record['parentNum'] == $selectedCat && $record['depth'] == $thispagedepth && $record['_isSelectedBranch'] == 1): ?>
                <li><a class="selected" href="/<?php echo strtolower($record['url']); ?>/"><?php echo $record['name'] ?></a></li>
			<?php elseif($record['hidden'] == 0 && $record['parentNum'] == $selectedCat && $record['depth'] == $thispagedepth): ?>
                <li><a href="/<?php echo strtolower($record['url']); ?>/"><?php echo $record['name'] ?></a></li>
			<?php endif ?>      
            <?php endforeach; ?>
            </ul>
            </div>
            <?php endif ?>

        </div>
        <div class="navsection3">
<?php echo $website_settingsRecord['facebook_widget'] ?>
        </div>
    </div>
</div>
<?php include("library/inc/footer.php"); ?>
</body>
</html>
