<?php
/**
 * @package WordPress
 * @subpackage Green Marinee
 */

$themecolors = array(
	'bg' => 'ffffff',
	'text' => '3f3f3f',
	'link' => '7da721',
	'border' => 'fcfef4',
	'url' => 'ace149',
);

$content_width = 475;

add_theme_support( 'print-style' );

register_sidebar( array(
	'name'          => __('Sidebar'),
	'id'            => 'sidebar',
	'before_widget' => '<span class="widget">',
	'after_widget'  => '</span><div class="line"></div>',
	'before_title'  => '<h3>',
	'after_title'   => '</h3>' )
);

add_theme_support( 'automatic-feed-links' );

add_custom_background();

/**
 * Enqueue scripts and styles
 */
function greenmarinee_scripts() {
	wp_enqueue_style( 'greenmarinee', get_stylesheet_uri() );

	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
		wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'greenmarinee_scripts' );

function greenmarinee_custom_background() {
	if ( '' != get_background_color() || '' != get_background_image() ) { ?>
		<style type="text/css">
			.topline, .container_right, .container_left, #content_bg, #footer { background: none; }
			#container { background: #fff; }
		<?php if ( '' != get_background_color() && '' == get_background_image() ) { ?>
			body { background-image: none; }
		<?php } ?>
		</style>
	<?php }
}
add_action( 'wp_head', 'greenmarinee_custom_background' );

function green_marinee_comment($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
	extract($args, EXTR_SKIP);
?>
<li <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
	<div id="div-comment-<?php comment_ID() ?>">
	<div class="comment-author vcard">
		<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
		<div class="comment_author">
			<span class="fn"><?php comment_author_link() ?></span> <?php _e('said','greenmarinee'); ?>,
		</div>
	</div>

	<?php if ($comment->comment_approved == '0') : ?>
	<em><?php _e('Your comment is awaiting moderation.','greenmarinee'); ?></em>
	<?php endif; ?>
	<br />

	<p class="metadate comment-meta commentmetadata"><?php _e('on','greenmarinee'); ?> <?php comment_date() ?> <?php _e('on','greenmarinee'); ?> <?php comment_time() ?></p>

	<?php comment_text() ?>

	<p class="replylink">
		<?php comment_reply_link(array_merge( $args, array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
	</p>
	</div>
<?php
}

/**
 * Filters wp_title to print a neat <title> tag based on what is being viewed.
 *
 * @since Green Marinee 1.0
 */
function green_marinee_wp_title( $title, $sep ) {
	global $page, $paged;

	if ( is_feed() )
		return $title;

	// Add the blog name
	$title .= get_bloginfo( 'name' );

	// Add the blog description for the home/front page.
	$site_description = get_bloginfo( 'description', 'display' );
	if ( $site_description && ( is_home() || is_front_page() ) )
		$title .= " $sep $site_description";

	// Add a page number if necessary:
	if ( $paged >= 2 || $page >= 2 )
		$title .= " $sep " . sprintf( __( 'Page %s', 'greenmarinee' ), max( $paged, $page ) );

	return $title;
}
add_filter( 'wp_title', 'green_marinee_wp_title', 10, 2 );