<?php
/**
 *
 *
 * Please browse readme.txt for credits and forking information
 *
 * @package financerecruitment
 */

/**
 * Set up the WordPress core custom header feature.
 *
 * @uses financerecruitment_header_style()
 */
function financerecruitment_custom_header_setup() {
	add_theme_support( 'custom-header', apply_filters( 'financerecruitment_custom_header_args', array(
		'default-image'          => '%s/images/headers/header-image.png',
		'default-text-color'     => 'fff',
		'width'                  => 1800,
		'height'                 => 848,
		'flex-height'            => true,
		'flex-width'	         => true,
		'wp-head-callback'       => 'financerecruitment_header_style',
	) ) );


	/*
	 * Default custom headers packaged with the theme.
	 * %s is a placeholder for the theme template directory URI.
	 */
	register_default_headers( array(
		'mountains' => array(
			'url'           => '%s/images/headers/header-image.png',
			'thumbnail_url' => '%s/images/headers/header-image_thumbnail.png',
			'description'   => _x( 'food', 'header image description', 'financerecruitment' )
		),		
	) );
}
add_action( 'after_setup_theme', 'financerecruitment_custom_header_setup' );

if ( ! function_exists( 'financerecruitment_header_style' ) ) :
/**
 * Styles the header image and text displayed on the blog
 *
 * @see financerecruitment_custom_header_setup().
 */
function financerecruitment_header_style() {
	$header_image = get_header_image();
	$header_text_color   = get_header_textcolor();
		
	// If no custom options for text are set, let's bail.
	if ( empty( $header_image ) && $header_text_color == get_theme_support( 'custom-header', 'default-text-color' ) ){
		return;
	}

	// If we get this far, we have custom styles.
	?>
	<style type="text/css" id="financerecruitment-header-css">
	<?php
		if ( ! empty( $header_image ) ) :
			$header_width = get_custom_header()->width;
			$header_height = get_custom_header()->height;
			$header_height1 = ($header_height / $header_width * 1600);
			$header_height2 = ($header_height / $header_width * 768);
			$header_height3 = ($header_height / $header_width * 360);
			
	?>
				.site-header {
					background: url(<?php header_image(); ?>) no-repeat scroll top;
					<?php if($header_height1 > 200){ ?>
						background-size: cover;
						background-position:top;
					<?php }else{ ?>
						background-size: cover;
					<?php } ?>
				}

				@media (min-width: 768px) and (max-width: 1024px){
					.site-header {
						<?php if($header_height2 > 170){ ?>
							background-size: cover;
							background-position:top;
						<?php }else{ ?>
							background-size: cover;
						<?php }	?>				
					}
				}

				@media (max-width: 767px) {
					.site-header {
						<?php if($header_height2 > 170){ ?>
							background-size: cover;
							background-position:top;
						<?php }else{ ?>
							background-size: cover;
						<?php }	?>				
					}
				}
				@media (max-width: 359px) {
					.site-header {
						<?php if($header_height3 > 80){ ?>
							background-size: cover;
							background-position:top;
						<?php }else{ ?>
							background-size: cover;
						<?php } ?>
						
					}
					
				}
  <?php else: ?>
		
	<?php endif; 

		// Has the text been hidden?
		if ( ! display_header_text() ) :

	?>
		.site-title,
		.site-description,
		.frontpage-site-title,
		.frontpage-site-description  {
			position: absolute;
			clip: rect(1px 1px 1px 1px); /* IE7 */
			clip: rect(1px, 1px, 1px, 1px);
			display:none;
		}
	<?php
		endif;
		if ( empty( $header_image ) ) :
	?>
		.site-header .home-link {
			min-height: 0;
		}
	<?php

		// If the user has set a custom color for the text, use that.

		else:
			
	?>

		.site-title,
		.site-description {
			color: #<?php echo esc_attr( $header_text_color ); ?>;
		}
		.site-title::after{
			background: #<?php echo esc_attr( $header_text_color ); ?>;
			content:"";       
		}
	<?php endif; ?>

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




