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

<?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="content">
	
<div id="supercol-left">
	
    <?php
    
        global $post;
        $myposts = get_posts('post_type=page&post_parent=65&order=ASC&orderby=post_title&numberposts=1000');
//        $myposts = get_posts('post_type=page&post_parent=65&order=ASC&orderby=post_title&numberposts');
        $activePosts = array();
        $archivedPosts = array();

        foreach($myposts as $post) {
//          $relevance = (int)get_post_meta("$post->ID", 'project-relevance', true);
          $status = get_post_meta("$post->ID", 'project-status', true);
          if ($status == 'active') {
//            $activePosts[$relevance] = $post;
            $activePosts[] = $post;
          } else {
//            $archivedPosts[$relevance] = $post;
	    $archivedPosts[] = $post;
          }
        }
        
//        ksort($activePosts);
        echo '<h3 style="margin-left: 10px; margin-top: 10px;">Active Projects</h3>';
        echo '<div class="projects-rule"></div>';
        foreach ($activePosts as $post) {
    ?>
    
    <!--Project-->
	<div class="col-span-two">
		<a href="/projects/<?php echo $post->post_name; ?>/"><img class="project-page" src="<?php bloginfo('template_url'); ?>/gfx/icon_<?php echo $post->post_name; ?>_M.gif" alt="<?php echo $post->post_title; ?>" /></a>
	</div>
	<div class="col-span-projects projects">
		<h4><?php echo get_post_meta("$post->ID", 'project-category', true); ?></h4>
		<h1 id="<?php echo $post->post_name; ?>"><a href="/projects/<?php echo $post->post_name; ?>/"><?php the_title(); ?></a></h1>
		<p><?php echo get_post_meta("$post->ID", 'project-excerpt', true); ?></p>
		<p><a href="/projects/<?php echo $post->post_name; ?>/"><img src="<?php bloginfo('template_url'); ?>/gfx/btn_more_project.gif" alt="More about this project" /></a></p>
	</div>
	<div class="projects-rule"></div>
	
	<?php
          }

//          ksort($archivedPosts);
          echo '<h3 style="margin-left: 10px; margin-top: 10px;">Archived Projects</h3>';
          echo '<div class="projects-rule"></div>';
          foreach ($archivedPosts as $post) {
         ?>
	 <div class="col-span-two">
                <a href="/projects/<?php echo $post->post_name; ?>/"><img class="project-page" src="<?php bloginfo('template_url'); ?>/gfx/icon_<?php echo $post->post_name; ?>_M.gif" alt="<?php echo $post->post_title; ?>" /></a>
        </div>
        <div class="col-span-projects projects">
        	<h4><?php echo get_post_meta("$post->ID", 'project-category', true); ?></h4>
                <h1 id="<?php echo $post->post_name; ?>"><a href="/projects/<?php echo $post->post_name; ?>/"><?php the_title(); ?></a></h1>
		<p><?php echo get_post_meta("$post->ID", 'project-excerpt', true); ?></p>
		<p><a href="/projects/<?php echo $post->post_name; ?>/"><img src="<?php bloginfo('template_url'); ?>/gfx/btn_more_project.gif" alt="More about this project" /></a></p>
        </div>
        <div class="projects-rule"></div>
	<?php } ?>
</div><!--end supercol-left-->
	
<br clear="all" />	
</div><!--end content-->

<?php get_footer(); ?>
