<?php
/**
 * @denim
 * @since 0.1
 */
function denim_setup() {
    global $content_width;

	/* Set the $content_width for unknowns such as video embeds. */
	if ( !isset( $content_width ) )
            $content_width = 480;

    // custom editor style support
    add_editor_style( 'editor-style.css' );
    
    // This theme uses Featured Images (also known as post thumbnails)
    add_theme_support('post-thumbnails'); 
    //set_post_thumbnail_size( 150, 150 );

    // Add default posts and comments RSS feed links to head
    add_theme_support('automatic-feed-links');

    // language support - add your translation
    load_theme_textdomain('denim', get_template_directory() . '/languages');

    // This theme uses wp_nav_menu in one location.
    register_nav_menus(array(
        'primary' => __('Primary Navigation', 'denim')
        ));     

    // Add support for custom background
    add_theme_support( 'custom-background', array(
        'default-image' => get_stylesheet_directory_uri() . '/images/blue7.jpg',
        'default-color' => '5566cc',
    )); 

    // custom header image on top sidebar
    add_theme_support( 'custom-header' ); 
    $args = array(
	'default-image'          => get_stylesheet_directory_uri() . '/images/default-header.png',
	'random-default'         => false,
	'width'                  => 1000,
	'height'                 => 120,
	'flex-height'            => true,
	'flex-width'             => true,
	'default-text-color'     => '000000',
	'header-text'            => true,
	'uploads'                => true,
    );
    add_theme_support( 'custom-header', $args );
}
    add_action('after_setup_theme', 'denim_setup');

    // setup external font call for enqueues
function denim_font_url() {
	$font_url = '';
	/*
	 * Translators: If there are characters in your language that are not supported
	 * by Translation, translate this to 'off'. Do not translate into your own language.
	 */
	if ( 'off' !== _x( 'on', 'Tangerine font: on or off', 'denim' ) ) {
		$font_url = add_query_arg( 'family', urlencode( 'Tangerine:400,700' ), "//fonts.googleapis.com/css" );
	}

	return $font_url;
}
    // Register StyleSheet
function denim_styles() {
    // Add Tangerine font, used in the header and stylesheet.
    wp_enqueue_style( 'denim-tangerine', denim_font_url(), array(), null );
    // put main stylesheet into head
    wp_enqueue_style( 'denim-style', get_stylesheet_uri()
    );
   /*
    * Adds JavaScript to pages with the comment form to support
    * sites with threaded comments (when in use).
    */
    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
	wp_enqueue_script( 'comment-reply' );  
}
    add_action( 'wp_enqueue_scripts', 'denim_styles' );

    // add ie conditional html5 shim to header
function denim_add_ie_html5_shim () {
    echo '<!--[if lt IE 9]>';
    echo '<script src="js/html5.js"></script>';
    echo '<![endif]-->';
}
    add_action('wp_head', 'denim_add_ie_html5_shim');

    // add widgets
function denim_widgets_init() {
    register_sidebar( array(
        'name'         => 'Left Pocket Sidebar',
        'id'           => 'sidebar-1',
        'description'  => 'Widgets in this area display as left pocket.',
        'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h2>',
        'after_title'  => '</h2>',
    ) );
}
add_action( 'widgets_init', 'denim_widgets_init' );
?>