<?php
/**
 * Sample implementation of the Custom Header feature
 * http://codex.wordpress.org/Custom_Headers
 *
 * @package Vertigo
 * @since Vertigo 1.0
 */

/**
 * Setup the WordPress core custom header feature.
 *
 * @uses vertigo_header_style()
 * @uses vertigo_admin_header_style()
 * @uses vertigo_admin_header_image()
 *
 * @package Vertigo
 */
function vertigo_custom_header_setup() {
	$vertigo_options = vertigo_get_theme_options();

	add_theme_support( 'custom-header', apply_filters( 'vertigo_custom_header_args', array(
		'default-text-color'     => $vertigo_options['accent_color'],
		'width'                  => 960,
		'height'                 => 240,
		'flex-height'            => true,
		'wp-head-callback'       => 'vertigo_header_style',
		'admin-head-callback'    => 'vertigo_admin_header_style',
	) ) );
}
add_action( 'after_setup_theme', 'vertigo_custom_header_setup' );

if ( ! function_exists( 'vertigo_header_style' ) ) :
/**
 * Styles the header image and text displayed on the blog
 *
 * @see vertigo_custom_header_setup().
 *
 * @since Vertigo 1.0
 */
function vertigo_header_style() {
	$header_image = get_header_image();

	// If no custom options for text are set, let's bail
	if ( HEADER_TEXTCOLOR == get_header_textcolor() && empty( $header_image ) )
		return;
	// If we get this far, we have custom styles. Let's do this.
	?>
	<style type="text/css">
	<?php
		// Do we have a custom header image?
		if ( ! empty( $header_image ) ) :
	?>
		#branding {
			background: url(<?php header_image(); ?>);
			height: 130px; /* 240 - 110 for top padding */
			width: 960px;
		}
	<?php
		endif;

		// Has the text been hidden?
		if ( 'blank' == get_header_textcolor() ) :
	?>
		#site-title,
		#site-description {
 	 		position: absolute !important;
			clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
			clip: rect(1px, 1px, 1px, 1px);
		}

	<?php
		// If the user has set a custom color for the text use that
		else :
	?>
		#site-title a {
			color: #<?php echo get_header_textcolor(); ?> !important;
		}
	<?php endif; ?>

	</style>
	<?php
}
endif; // vertigo_header_style

if ( ! function_exists( 'vertigo_admin_header_style' ) ) :
/**
 * Styles the header image displayed on the Appearance > Header admin panel.
 *
 * @see vertigo_custom_header_setup().
 *
 * @since Vertigo 1.0
 */
function vertigo_admin_header_style() {
	$vertigo_options = vertigo_get_theme_options();
?>
	<style type="text/css">
	.appearance_page_custom-header #headimg {
		background-color: #000;
		<?php if ( '' == get_header_image() )
			echo 'background-image: url( ' . get_template_directory_uri() . '/images/header-bg.png ) !important;';
		?>
		background-position: 50% 0;
		background-repeat: no-repeat;
		border: none;
		height: 130px!important;
		padding: 110px 0 0;
		width: 940px;
	}
	#headimg h1 {
		font-size: 36px;
		font-weight: normal;
		line-height: 54px!important;
		margin: 0;
		text-align: center;
	}
	#headimg h1 a {
		color: #<?php echo $vertigo_options['accent_color']; ?>;
		line-height: 1.5em!important;
		margin: 0;
		padding: 0;
		text-decoration: none;
	}
	#headimg h1 a:hover {
		color: #<?php echo $vertigo_options['accent_color']; ?>;
		text-decoration: underline;
	}
	#desc {
		color: #fff!important;
		font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
		font-size: 13px;
		margin: 0 auto;
		padding: 15px 0 0px 120px;
		text-align: center;
		width: 500px;
	}
	<?php
		// If the user has set a custom color for the text use that
		if ( HEADER_TEXTCOLOR != get_header_textcolor() ) :
	?>
		#site-title a {
			color: #<?php echo get_header_textcolor(); ?>;
		}
	<?php endif; ?>
	</style>
<?php
}
endif; // vertigo_admin_header_style