<?php 

get_header(); 

function sp_read_more_from($position) {
	?>
		<strong><a href="<?php echo get_category_link(get_theme_mod($position)); ?>" rel="bookmark"><?php _e("Read More Posts From", 'studiopress'); echo " ". cat_id_to_name(get_theme_mod($position)); ?> &raquo;</a></strong>
	<?php
}

function sp_post_thumb($post, $position) {
	if( get_post_meta($post->ID, "thumb", true) ): 
?>
	<a href="<?php the_permalink() ?>" rel="bookmark">
		<img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&amp;h=<?php echo get_theme_mod($position.'_thumb_height'); ?>&amp;w=<?php echo get_theme_mod($position.'_thumb_width'); ?>&amp;zc=1" alt="<?php the_title(); ?>" />
	</a>	
<?php
	else:
		// You might want to show a default image?
	endif; 
}
?>

<div id="content">

	<div id="contentleft">
    
		<?php if(get_theme_mod('tabber') == 'Yes') { ?>
                    
            <div class="hptabber">
                <?php include(TEMPLATEPATH."/tabber.php");?>
            </div>	
            
        <?php } else { ?>
        <?php } ?>  
        
		<div class="clear"></div>
        
		<?php if(get_theme_mod('468_ad_home') == 'Yes') { ?>
            <div class="adblock">
                <?php echo stripslashes (get_theme_mod('468_code_home')); ?>
            </div>
        <?php } else { ?>
        <?php } ?> 
        
        <div class="hpfeatured">
        
			<h3><?php echo cat_id_to_name(get_theme_mod('featured_main')); ?></h3>
                        
				<?php $recent = new WP_Query("cat=".get_theme_mod('featured_main')."&showposts=".get_theme_mod('featured_main_num')); while($recent->have_posts()) : $recent->the_post();?>
				<?php sp_post_thumb($post, 'featured_main'); ?>					
                
				<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
				<?php the_content_limit(315, ""); ?>
                
                <a href="<?php the_permalink() ?>">[<?php _e("Continue reading: ", 'studiopress'); the_title(); ?>]</a>
				
				<hr/>
				
				<?php endwhile; ?>
				
				<?php sp_read_more_from('featured_main'); ?>
                        
        </div>
                        
		<div class="homeleft">
        
            <div class="homeblock">
            
			<h3><?php echo cat_id_to_name(get_theme_mod('featured_top_left')); ?></h3>
                
				<?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')."&showposts=".get_theme_mod('featured_top_left_num')); while($recent->have_posts()) : $recent->the_post();?>
				<?php sp_post_thumb($post, 'featured_top_left'); ?>					
                
				<p><strong><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></strong></p>
				<?php the_content_limit(80, ""); ?>
				
				<hr/>
				
				<?php endwhile; ?>
				
				<?php sp_read_more_from('featured_top_left'); ?>
                                
            </div>
                                
        </div>
        
		<div class="homeright">
        
            <div class="homeblock">
            
			<h3><?php echo cat_id_to_name(get_theme_mod('featured_top_right')); ?></h3>
                
				<?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_right')."&showposts=".get_theme_mod('featured_top_right_num')); while($recent->have_posts()) : $recent->the_post();?>
				<?php sp_post_thumb($post, 'featured_top_right'); ?>					
                
				<p><strong><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></strong></p>
				<?php the_content_limit(80, ""); ?>
				
				<hr/>
				
				<?php endwhile; ?>
				
				<?php sp_read_more_from('featured_top_right'); ?>
                                
            </div>
            
                                
        </div>
        	
	</div>
			
	<?php include(TEMPLATEPATH."/sidebar.php");?>

</div>

<!-- The main column ends  -->

<?php get_footer(); ?>