<?php
/*
 * threeby theme functions and definitions
 */
    include_once (get_template_directory() . '/include/theme-options.php');

    // set width of external linked media players not defined
      global $content_width;
    if ( !isset( $content_width  ) ) {
        $content_width  = 640;
    }

    function threeby_setup() {

        // 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'); 

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

        // add tag support to pages
        register_taxonomy_for_object_type('post_tag', 'page');

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

        // This theme uses wp_nav_menu in one location.
        register_nav_menus(array(
            'primary' => __('Primary Navigation', 'threeby')
            ));     
        /**
         * customer background color and image support 
         */
        add_theme_support( 'custom-background' );
            $args = array(
                'default-color' => 'fafafb',
                'default-image' => '',
            );
        add_theme_support( 'custom-background', $args );

        /*
         * customer header image banner support 
         */
        add_theme_support( 'custom-header' );
            $args = array(
	        'width'              => 500,
	        'height'             => 254,
	        'default-image'      => get_template_directory_uri() . '/images/default-header.png',
                'flex-width'         => true,
                'flex-height'        => true,
                'random-default'     => false,
                'default-text-color' => 'ffffff',
	        'header-text'        => false,
	        'uploads'            => true,
        );
        add_theme_support( 'custom-header', $args );
    }
    add_action('after_setup_theme', 'threeby_setup');

function threeby_add_theme_scripts() {  
     /*
      * 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' );  

    // Loads default main stylesheet.
    wp_enqueue_style( 'style', get_stylesheet_uri() ); 

    // toggle reply comment form script
    wp_enqueue_script( 'threeby', get_template_directory_uri() . '/js/toggle.js', 
        array( 'jquery' ), '1.0', true
        );
}
    add_action( 'wp_enqueue_scripts', 'threeby_add_theme_scripts' );

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

    // font imported
    add_action( 'threeby', 'wpb_add_google_fonts', 5);
    function threeby_add_google_fonts() {
    echo "<link href='http://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>";
    }
    // custom footer credits
function threeby_footer_credits() {
    echo "<p><small><a href='http://www.tradesouthwest.com/'>Theme ThreeBy from Tradesouthwest</a></small></p>";
}
    add_action( 'threeby_footer_credits', 'threeby_footer_credits' );


    function threeby_widgets_init() {
        register_sidebar(array(
            'name' => __('Primary Left Side', 'threeby'),
            'id' => 'sidebar-left',
            'description' => __('The left-side widget area', 'threeby'),
            'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));

        register_sidebar(array(
            'name' => __('Primary Right Side', 'threeby'),
            'id' => 'sidebar-right',
            'description' => __('The right-side widget area', 'threeby'),
            'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));
        register_sidebar(array(
            'name' => __('Footer Middle Widget', 'threeby'),
            'id' => 'sidebar-footer',
            'description' => __('The middle footer widget area', 'threeby'),
            'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ));
    }
    add_action( 'widgets_init', 'threeby_widgets_init' );
?>