<?php get_header(); ?>

<div id="hpmainbg">
    
    <div class="hpmain">
        
        <div class="hpmainleft">
			<?php $recent = new WP_Query('page_id='.get_theme_mod('hp_main')); while($recent->have_posts()) : $recent->the_post();?>
            <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
			<?php the_content_limit(600, ""); ?>
            <p><a rel="nofollow" class="more-link" href="<?php the_permalink() ?>"><?php _e("Read more", 'studiopress'); ?></a></p>
            <?php endwhile; ?>
        </div>
            
        <div class="hpmainright">
			<?php // start code which figures out whether to show image or video ?>
			<?php if(get_theme_mod('video') == 'Yes') { ?>
           		<?php echo get_custom_field('_video_code'); ?>
            <?php } else { ?>
                <img src="<?php bloginfo('template_url'); ?>/images/sample.jpg" alt="<?php bloginfo('name'); ?>" />
            <?php } ?>   
            <?php // end code ?>
         </div>
                                
	</div>
    
    <div class="clear"></div>
        		
</div>

<div class="clear"></div>

<div id="hpbottombg">

    <div id="hpbottom">
    
		<?php if(get_theme_mod('hp_bottom')) : ?>
		<h4><?php $featcat = cat_id_to_name(get_theme_mod('hp_bottom')); echo $featcat; ?></h4>
		<?php else: ?>
        <h4><?php _e("Recent Posts", 'studiopress'); ?></h4>
		<?php endif; ?>    
    
        <div class="hpbottom1">
        
			<?php $recent = new WP_Query("cat=".get_theme_mod('hp_bottom')."&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>

			<?php // start code which figures out whether to show image or video - if no custom field is used, will show nothing ?>
                <?php if(get_theme_mod('video_bottom') == 'Yes') { ?>
                    <div class="video"><?php echo get_custom_field('_video_code'); ?></div>
                <?php } elseif(get_post_meta($post->ID, "thumb", TRUE)) { ?>
                    <a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb-hpbottom" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", TRUE); ?>&amp;h=<?php echo get_theme_mod('hp_bottom_thumb_height'); ?>&amp;w=<?php echo get_theme_mod('hp_bottom_thumb_width'); ?>&amp;zc=1" alt="<?php the_title(); ?>" /></a>  
                <?php } ?>  
            <?php // end code ?>
                
			<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            <div class="excerpt">
				<?php the_content_limit(130, ""); ?>
            </div>
            <p><a rel="nofollow" href="<?php the_permalink() ?>"><?php _e("Continue reading", 'studiopress'); ?></a></p>
								
			<?php endwhile; ?>
                        
        </div>
        
        <div class="hpbottom2">
        
			<?php $recent = new WP_Query("cat=".get_theme_mod('hp_bottom')."&showposts=1&offset=1"); while($recent->have_posts()) : $recent->the_post();?>
            
			<?php // start code which figures out whether to show image or video - if no custom field is used, will show nothing ?>
                <?php if(get_theme_mod('video_bottom') == 'Yes') { ?>
                    <div class="video"><?php echo get_custom_field('_video_code'); ?></div>
                <?php } elseif(get_post_meta($post->ID, "thumb", TRUE)) { ?>
                    <a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb-hpbottom" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", TRUE); ?>&amp;h=<?php echo get_theme_mod('hp_bottom_thumb_height'); ?>&amp;w=<?php echo get_theme_mod('hp_bottom_thumb_width'); ?>&amp;zc=1" alt="<?php the_title(); ?>" /></a>  
                <?php } ?>  
            <?php // end code ?> 					
                
			<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            <div class="excerpt">
				<?php the_content_limit(130, ""); ?>
            </div>
            <p><a rel="nofollow" href="<?php the_permalink() ?>"><?php _e("Continue reading", 'studiopress'); ?></a></p>
								
			<?php endwhile; ?>
                    
        </div>
        
        <div class="hpbottom3">
        
			<?php $recent = new WP_Query("cat=".get_theme_mod('hp_bottom')."&showposts=1&offset=2"); while($recent->have_posts()) : $recent->the_post();?>		
            	
			<?php // start code which figures out whether to show image or video - if no custom field is used, will show nothing ?>
                <?php if(get_theme_mod('video_bottom') == 'Yes') { ?>
                    <div class="video"><?php echo get_custom_field('_video_code'); ?></div>
                <?php } elseif(get_post_meta($post->ID, "thumb", TRUE)) { ?>
                    <a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb-hpbottom" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", TRUE); ?>&amp;h=<?php echo get_theme_mod('hp_bottom_thumb_height'); ?>&amp;w=<?php echo get_theme_mod('hp_bottom_thumb_width'); ?>&amp;zc=1" alt="<?php the_title(); ?>" /></a>  
                <?php } ?>  
            <?php // end code ?> 				
                
			<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            <div class="excerpt">
				<?php the_content_limit(130, ""); ?>
            </div>
            <p><a rel="nofollow" href="<?php the_permalink() ?>"><?php _e("Continue reading", 'studiopress'); ?></a></p>
								
			<?php endwhile; ?>
                    
        </div>
        
        <div class="hpbottom4">
        
			<?php $recent = new WP_Query("cat=".get_theme_mod('hp_bottom')."&showposts=1&offset=3"); while($recent->have_posts()) : $recent->the_post();?>			
            
			<?php // start code which figures out whether to show image or video - if no custom field is used, will show nothing ?>
                <?php if(get_theme_mod('video_bottom') == 'Yes') { ?>
                    <div class="video"><?php echo get_custom_field('_video_code'); ?></div>
                <?php } elseif(get_post_meta($post->ID, "thumb", TRUE)) { ?>
                    <a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb-hpbottom" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", TRUE); ?>&amp;h=<?php echo get_theme_mod('hp_bottom_thumb_height'); ?>&amp;w=<?php echo get_theme_mod('hp_bottom_thumb_width'); ?>&amp;zc=1" alt="<?php the_title(); ?>" /></a>  
                <?php } ?>  
            <?php // end code ?>				
                
			<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
            <div class="excerpt">
				<?php the_content_limit(130, ""); ?>
            </div>
            <p><a rel="nofollow" href="<?php the_permalink() ?>"><?php _e("Continue reading", 'studiopress'); ?></a></p>
								
			<?php endwhile; ?>
                    
        </div>
        
	<div class="clear"></div>
	        
    </div>
    
</div>

<?php get_footer(); ?>