<?php
/**
 * The template part for displaying the content head
 *
 * @package WordPress
 * @subpackage ThinkPlace
 * @since ThinkPlace 1.0
 */

global $metadata;
global $extraBodyClass;
$ancestorPostId	= $post->ID;
if (! empty($post->ancestors)){
	if ((! empty($extraBodyClass)) && (count($post->ancestors) > 1)){
		$ancestorPostId	= $post->ancestors[ 0 ];
	} else
	if (! empty($extraBodyClass)){
		$ancestorPostId	= $post->ID;
	} else {
		$ancestorPostId	= $post->ancestors[ count($post->ancestors) -1];
	}
}
?>
<div id="content_head">
	<div class='nav'>
		<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>
	</div>
	<div class='content'>
		<?php
			$breadcrumb = '<strong>'.get_the_title().'</strong>';
			
			foreach ($post->ancestors as $bc_ancestor_id){
				$breadcrumb	= '<a href="'.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>';
		?>
		<div class="contact">
			<p>Need What We Do?</p>
			<p>Give us a call on +61 (0)2 6282 8852</p>
			<div class='decoration'></div>
			<hr />
		</div>
		<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>
	<hr />
</div>