<?php
/*
*  Template Name: Default page with header image
*/
get_header(); ?>

    <?php if (have_posts()) : while (have_posts()) : the_post();
		$aPostCustom = get_post_custom( $post->ID );
    ?>
    <?php
        if ( !empty($aPostCustom['uni_default_page_header_bg'][0]) ) {
            $iContactAttachId = $aPostCustom['uni_default_page_header_bg'][0];
        }
        if ( !empty($iContactAttachId) ) {
            $aPageHeaderImage = wp_get_attachment_image_src( $iContactAttachId, 'full' );
            $sPageHeaderImage = $aPageHeaderImage[0];
        } else {
            $sPageHeaderImage = get_template_directory_uri().'/images/placeholders/pageheader-cart.jpg';
        }
    ?>

	<section class="uni-container">

		<div class="pageHeader" style="background-image: url(<?php echo esc_url( $sPageHeaderImage ); ?>);">
            <?php
            if ( !empty($aPostCustom['uni_default_page_header_title_color'][0]) ) {
                $sTitleColor = $aPostCustom['uni_default_page_header_title_color'][0];
            } else {
                $sTitleColor = '#ffffff';
            }

            echo '<h1>'.get_the_title().'</h1>';
            echo '<style>.pageHeader h1 {color:'.esc_attr( $sTitleColor ).';}</style>';
            ?>
		</div>

		<div class="wrapper">

			<div id="post-<?php the_ID(); ?>" <?php post_class('singlePostWrap clear') ?>>
		
		<?php the_content() ?>

			</div>

            <?php comments_template(); ?>

		</div>

	</section>

        <?php endwhile; endif; ?>

<?php get_footer(); ?>