<?php
// Start the engine
require_once(TEMPLATEPATH.'/lib/init.php');

// Child theme library
require_once(CHILD_DIR.'/lib/custom-header.php');
require_once(CHILD_DIR.'/lib/style.php');
require_once(CHILD_DIR.'/lib/custom_shorts.php');
require_once(CHILD_DIR.'/lib/adsettings.php');
require_once(CHILD_DIR.'/lib/theme-guide.php');

// Child theme (do not remove)
define( 'CHILD_THEME_NAME', 'Lifestyle Theme');
define( 'CHILD_THEME_URL', 'http://www.studiopress.com/themes/lifestyle');
define( 'HOME_URL', get_home_url() );

// Add support for custom background
if ( function_exists('add_custom_background') ) {
	add_custom_background();
}

//* Add support for custom header
add_theme_support( 'custom-header', array(
	'default-text-color'     => '000000',
	'header-selector'        => '#title-area',
	'header-text'            => false,
	'height'                 => 100,
	'width'                  => 408,
) );

// Add topnav section
add_action('genesis_before_header', 'lifestyle_include_topnav'); 
function lifestyle_include_topnav() {
	if ( ! genesis_get_option( 'top_navbar_show', 'millionaire' ) )
	return;
    require(CHILD_DIR.'/lib/topnav.php');
}

// Add new image sizes
add_image_size( 'Portfolio', 202, 140, TRUE );
add_image_size( 'Homepage', 120, 120, TRUE );
add_image_size( 'Homepage Bottom', 120, 113, TRUE );
add_image_size( 'Homepage Feature', 90, 85, TRUE );
add_image_size( 'Square', 110, 110, TRUE);
add_image_size( 'Archive Image', 80, 80, TRUE );

// Force layout on homepage
add_filter('genesis_pre_get_option_site_layout', 'lifestyle_home_layout');
function lifestyle_home_layout($opt) {
	if ( is_home() )
    $opt = 'content-sidebar';
	return $opt;
} 

// Add Amazon Store after single post
add_action('genesis_after_post', 'lifestyle_include_amazon_store', 9); 
function lifestyle_include_amazon_store() {
    if ( is_single() ) {
	if ( ! genesis_get_option( 'amazon_show_posts', 'millionaire' ) )
		return;
    require(CHILD_DIR.'/lib/amz.php');
	}
}

// Add Adsense Block on Top SideBar
add_action('genesis_before_sidebar_widget_area', 'lifestyle_include_adsense300', 9); 
function lifestyle_include_adsense300() {
	if ( is_single() ) {
		if ( ! genesis_get_option( 'adsense_300_show', 'millionaire' ) )
			return;	
    require(CHILD_DIR.'/lib/adsense_300.php');
	}	
    if ( is_home() ) {
	  if ( ! genesis_get_option( 'adsense_300_show_home', 'millionaire' ) )
		return;
    require(CHILD_DIR.'/lib/adsense_300.php');
	}
}

// Add Adsense Block Above Posts
add_action('genesis_post_content', 'lifestyle_include_adsense468', 9); 
function lifestyle_include_adsense468() {
    if ( is_single() ) {
	if ( ! genesis_get_option( 'adsense_468_show', 'millionaire' ) )
		return;
    require(CHILD_DIR.'/lib/adsense_468.php');
	}
}

// Add Adsense Block Below Posts
add_action('genesis_after_post_content', 'lifestyle_include_adsense336', 9); 
function lifestyle_include_adsense336() {
    if ( is_single() ) {
	if ( ! genesis_get_option( 'adsense_336_show', 'millionaire' ) )
		return;
    require(CHILD_DIR.'/lib/adsense_336.php');
	}
}

// Add Ad Block On Archives
add_action('genesis_loop', 'lifestyle_include_adsense_archive', 9); 
function lifestyle_include_adsense_archive() {
    if ( is_archive() ) {
	if ( ! genesis_get_option( 'adsense_archive_show', 'millionaire' ) )
		return;
    require(CHILD_DIR.'/lib/adsense_archive.php');
	}
}

// Add Ad Block Below Archives
add_action('genesis_after_loop', 'lifestyle_include_adsense_archive_below', 9); 
function lifestyle_include_adsense_archive_below() {
    if ( is_archive() ) {
	if ( ! genesis_get_option( 'adsense_archive_show_below', 'millionaire' ) )
		return;
    require(CHILD_DIR.'/lib/adsense_archive.php');
	}
}

// Add two sidebars underneath the primary sidebar
add_action('genesis_after_sidebar_widget_area', 'lifestyle_include_bottom_sidebars'); 
function lifestyle_include_bottom_sidebars() {
    require(CHILD_DIR.'/sidebar-bottom.php');
}

/** This will make you a Millionaire :-) */
add_action( 'genesis_admin_menu', 'be_add_child_theme_settings' );
function be_add_child_theme_settings() {
global $_child_theme_settings;
$_child_theme_settings = new Premadethemes_Millionaire_Settings;	
}

// Customize the footer section
add_filter('genesis_footer_creds_text', 'lifestyle_footer_creds_text');
function lifestyle_footer_creds_text($creds) {
	$creds = '[footer_copyright] [footer_home_link] &middot; All Rights Reserved' . ' &middot; [footer_privacy_link] &middot; [footer_tos_link] &middot; [footer_pmniches_link]';
	return $creds;
} 

/** Add support for 3-column footer widgets */
add_theme_support( 'genesis-footer-widgets', 3 ); 

// Remove the post info function
remove_action( 'genesis_before_post_content', 'genesis_post_info' );

// Register widget areas
genesis_register_sidebar(array(
	'name'=>'Sidebar Bottom Left',
	'description' => 'This is the bottom left column in the sidebar.',
	'before_title'=>'<h4 class="widgettitle">','after_title'=>'</h4>'
));
genesis_register_sidebar(array(
	'name'=>'Sidebar Bottom Right',
	'description' => 'This is the bottom right column in the sidebar.',
	'before_title'=>'<h4 class="widgettitle">','after_title'=>'</h4>'
));
genesis_register_sidebar(array(
	'name'=>'Featured Top Left',
	'description' => 'This is the featured top left column of the homepage.',
	'before_title'=>'<h4 class="widgettitle">','after_title'=>'</h4>'
));
genesis_register_sidebar(array(
	'name'=>'Featured Top Right',
	'description' => 'This is the featured top right column of the homepage.',
	'before_title'=>'<h4 class="widgettitle">','after_title'=>'</h4>'
));
genesis_register_sidebar(array(
	'name'=>'Featured Bottom',
	'description' => 'This is the featured bottom section of the homepage.',
	'before_title'=>'<h4 class="widgettitle">','after_title'=>'</h4>'
));