<?php /*
Template Name: Subpages
*/ ?>

<?php get_header(); ?>

<?php if (have_posts()) : ?>

	<?php while (have_posts()) : the_post(); ?>
	    
	    <div <?php post_class(); ?>>
	
	    	<h2 class="post-title"><?php the_title(); ?></h2>
	    	
	    	<?php if((function_exists('has_post_thumbnail')) && (has_post_thumbnail())) : ?>
				
			<div class="post-image"><?php the_post_thumbnail('dl-large', array('alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?><span class="overlay3"><img src="<?php echo TS_IMG; ?>overlay3.png" alt="<?php the_title(); ?>" width="580" height="320"/></span></div>
			
			<?php elseif(get_post_meta($post->ID, 'image_value', true)) : ?>
			
			<div class="post-image"><img src="<?php bloginfo('template_url'); ?>/lib/scripts/thumb.php?src=<?php echo ts_image(get_post_meta($post->ID, "image_value", true)); ?>&amp;w=560&amp;h=300&amp;zc=1&amp;q=95" alt="<?php the_title(); ?>" width="560" height="300"/><span class="overlay3"><img src="<?php echo TS_IMG; ?>overlay3.png" alt="<?php the_title(); ?>" width="580" height="320"/></span></div>
			
			<?php endif; // endif post thumbnail ?>
	
	    	<?php the_content(); ?>
	    	
	    	<?php edit_post_link(__('Edit Page',TS_DOMAIN), '<p class="clear">', '</p>'); ?>
	    
	    </div><!-- end post -->
	    
	    <?php include( TEMPLATEPATH . '/lib/inc/gallery.php'); ?>
	    
	    <div class="subpages clearfix">
	
			<?php $pages = get_pages('sort_column=menu_order&child_of='.$post->ID.'&parent='.$post->ID.'&exclude='.get_post_meta($post->ID, "teasers_ex_value", true)); $i = 1;
			    foreach($pages as $page) : ?>
			    
			    <?php if($i==1) : ?><div class="content-space"></div><?php endif; ?>
			
			    <div class="box clearfix <?php if($i%2==0) : ?>box-alt<?php endif; ?>">
			
			    	<a href="<?php echo get_page_link($page->ID); ?>">
			    	
			    		<?php if((function_exists('has_post_thumbnail')) && (get_the_post_thumbnail($page->ID, 'dl-thumb'))) : ?>
						
						<?php echo get_the_post_thumbnail($page->ID, 'dl-thumb', array('alt' => ''.$page->post_title.'', 'title' => ''.$page->post_title.'')); ?>
					
						<?php elseif(get_post_meta($page->ID, 'image_value', true)) : ?>
					
						<img src="<?php bloginfo('template_url'); ?>/lib/scripts/thumb.php?src=<?php echo ts_image(get_post_meta($page->ID, "image_value", true)); ?>&amp;w=260&amp;h=140&amp;zc=1&amp;q=95" alt="<?php echo $page->post_title; ?>" width="260" height="140"/>
						
						<?php else : ?>
						
			    		<img src="<?php echo TS_IMG; ?>subpages-default.jpg" alt="<?php echo $page->post_title ?>" width="260" height="140"/>
					
						<?php endif; // endif post thumbnail ?>
			    		<span class="overlay4"></span>
			    	</a>
			    	<h3><a href="<?php echo get_page_link($page->ID) ?>" rel="bookmark" title="<?php echo $page->post_title ?>"><?php echo $page->post_title ?></a></h3>
			    	
			    </div><!-- end post -->
			    
			<?php $i++; endforeach; ?>
		
		</div>
	    
	    <?php if(!ts_get_option('ts_comments_pages')) comments_template('', true); ?>
	
	<?php endwhile; ?>
	
	<?php else : ?>
	
	<div class="post">

	    <h3><?php _e('Error 404, no posts found!',TS_DOMAIN); ?></h3>
	    <p><?php _e('Sorry, no posts matched your criteria.',TS_DOMAIN); ?></p>
	    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
	
	</div>

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