<?php
/**
 * Template Name: Full Width Page
 *
 * A custom page template for full width content
 *
 * The "Template Name:" bit above allows this to be selectable
 * from a dropdown menu on the edit page screen.
 *
 * @package WordPress
 * @subpackage ThinkPlace
 * @since ThinkPlace 1.0
 */
global $post;
$metadata		= get_post_custom($post->ID);
$ancestorPostId	= $post->ID;
if (! empty($post->ancestors)){
	$ancestorPostId	= $post->ancestors[ count($post->ancestors) -1];
}
get_header();
?>
		<div id="content" role="main">

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
			
			<div id="content_head">
				<div class='nav'>
					<?php if (empty($secondaryNav)) :?>
					<dl>
					<dt><?php echo get_the_title($ancestorPostId); ?></dt>
					<?php
					$navPages	= get_pages(array(
					    				'child_of' => $ancestorPostId,
									    'sort_order' => 'ASC',
									    'sort_column' => 'menu_order',
									    'hierarchical' => 0,
									    'parent' => $ancestorPostId
					));
					foreach ($navPages as $navPage){
						$navPageUrl	= get_page_link($navPage->ID);
						echo '<dd'.((get_the_ID() == $navPage->ID) ? ' class="selected"' : '').'><a href="'.$navPageUrl.'">'.$navPage->post_title.'</a></dd>';
					}
					?>
					</dl>
				<?php else : echo $secondaryNav; endif;?>
				</div>
				<div class='content'>
					<?php
						$breadcrumb = '<strong>'.get_the_title().'</strong>';

						foreach ($post->ancestors as $bc_ancestor_id){
							$breadcrumb	= '<a href="'.htmlentities(get_page_link( $bc_ancestor_id )).'">'.get_the_title($bc_ancestor_id).'</a> &gt; '.$breadcrumb;
						}
						$breadcrumb	= '<a href="'.home_url( '/' ).'">Home</a> &gt; '.$breadcrumb;


						echo '<span class="breadcrumb">'.$breadcrumb.'</span>';
					?>
					<h1 class="entry-title"><?php the_title(); ?></h1>
					<blockquote>
					<?php
						if ((isset($metadata[thinkplace::$prefix.'Overview'])) && (! empty($metadata[thinkplace::$prefix.'Overview'][0]) )){
								echo $metadata[thinkplace::$prefix.'Overview'][0];
						}
					?>
					</blockquote>
				</div>
				<div class="contact">
					<p>Need What We Do?</p>
					<p><strong>Give us a call on +61 (0)2 6282 8852</strong></p>
					<div class='decoration'></div>
					<hr />
				</div>
				<hr />
			</div><!-- #content_head -->
			
				
			<?php the_content(); ?>
			<?php edit_post_link( __( 'Edit', 'thinkplace' ), '<span class="edit-link">', '</span>' ); ?>
<?php endwhile; ?>
					
		</div><!-- #content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>