<?php
/*
Template Name: Projects - Detail
*/
?>

<?php get_header(); ?>

<div id="page-title">
	<h3 class="title">Projects</h2>
</div>

<div id="page-description">
	<p>The latest and greatest &mdash; what we’re working on at the Labs.</p>
</div>

<div id="page-tools">
	<form action="<?php bloginfo('url'); ?>" method="get" onchange="this.submit()">
	<p>
	<?php wp_dropdown_pages("child_of=65&show_option_none=Select a project"); ?>
	</p>
	</form>
</div>

<div id="content">

	
<div id="supercol-left">
    
    <?php if ( have_posts() ) : the_post(); ?>

	<div class="col-span-six projects">
		<img class="project" src="<?php bloginfo('template_url'); ?>/gfx/icon_<?php echo $post->post_name; ?>_M.gif" alt="<?php the_title(); ?>" />
		<h4><?php echo get_post_meta("$post->ID", 'project-category', true); ?></h4>
		<h1 id="<?php echo $post->post_name; ?>"><?php the_title(); ?></h1>
                <?php $saved_content = get_the_content(); ?>
	</div>

	<div class="col-span-six projects">
		<?php echo $saved_content; ?>
	</div><!--end colspan-six-->
	
	<?php endif; ?>

</div><!--end supercol-left-->

<div id="supercol-right">

<br/>
<a href="<?php echo get_post_meta("$post->ID", 'project-download-link', true); ?>"><img class="getitnow" src="<?php bloginfo('template_url'); ?>/gfx/btn_getitnow.gif" alt="Get It Now" /></a>

<div class="action-items">
        <h4><a href="<?php echo '/tag/'.get_post_meta("$post->ID", 'project-blog-tag', true);?>">Latest 
Updates</a>&nbsp;<a href="<?php echo '/tag/'.get_post_meta("$post->ID", 'project-blog-tag', true).'/feed';?>"><img 
src="<?php bloginfo('template_url');?>/gfx/livemarks16.png" alt="Latest News RSS 
Feed"/></a></h4><ul>
        <?php
	    $saved_post = $post;
            query_posts('tag='.get_post_meta("$post->ID", "project-blog-tag", true).'&orderby=date&order=DES&showposts=5');

             if ( have_posts() ) : while ( have_posts() ) : the_post();
        ?>
            <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> (<?php the_time('m.d.Y') ?>)</li>
	<?php endwhile; else: ?>
            <p>Sorry, no posts matched your criteria.</p>
        <?php endif; ?>
        </ul>
<div class="action-items-footer"></div>
</div>

<div class="action-items">
<h4><a href="<?php echo get_post_meta("$saved_post->ID", 'project-discussions-link', true);?>">Discussions</a>&nbsp;<a href="<?php echo get_post_meta("$saved_post->ID", 'project-discussions-feed', true);?>"><img src="<?php 
bloginfo('template_url');?>/gfx/livemarks16.png" alt="Discussions RSS
Feed"/></a></h4>
<?php
     require_once('simplepie.inc');
     $feed = new SimplePie(get_post_meta("$saved_post->ID", 'project-discussions-feed', true));
     $feed->handle_content_type();
     echo '<ul>';
     foreach ($feed->get_items(1,4) as $item) {
                        echo '<li>';
                        echo '<a href="'.$item->get_permalink().'">'.$item->get_title().'</a><br/>';
                        echo '<small>'.$item->get_date('j F Y | g:i a').'</small>';
                        echo '</li>';
     }
     echo '</ul>';
?>
<div class="action-items-footer"></div>
</div>

		


</div><!--end supercol-right-->
	
<br clear="all" />	
</div><!--end content-->

<?php get_footer(); ?>
