<?php
    
    thebuilders_ninzio_global_variables();

    $nz_rh_version      = (isset($GLOBALS['thebuilders_ninzio']['rh-version']) && !empty($GLOBALS['thebuilders_ninzio']['rh-version'])) ? $GLOBALS['thebuilders_ninzio']['rh-version'] : 'version1'; 
    $nz_header_version  = (isset($GLOBALS['thebuilders_ninzio']['header-version']) && !empty($GLOBALS['thebuilders_ninzio']['header-version'])) ? $GLOBALS['thebuilders_ninzio']['header-version'] : 'version1';

    $styles             = "";
    $styles_fp          = "";

    $styles_title       = "";
    $styles_breadcrumbs = "";

    $nz_blog_title             = (isset( $GLOBALS['thebuilders_ninzio']['blog-title']) && !empty($GLOBALS['thebuilders_ninzio']['blog-title'])) ? esc_attr($GLOBALS['thebuilders_ninzio']["blog-title"]) : "";
    $nz_text_color             = (isset( $GLOBALS['thebuilders_ninzio']['blog-text-color']) && !empty($GLOBALS['thebuilders_ninzio']['blog-text-color'])) ? $GLOBALS['thebuilders_ninzio']["blog-text-color"] : "";
    $nz_back_color             = (isset( $GLOBALS['thebuilders_ninzio']['blog-back']['background-color']) && !empty($GLOBALS['thebuilders_ninzio']['blog-back']['background-color'])) ? $GLOBALS['thebuilders_ninzio']["blog-back"]['background-color'] : "#f7f7f7";
    $nz_back_img               = (isset( $GLOBALS['thebuilders_ninzio']['blog-back']['background-image']) && !empty($GLOBALS['thebuilders_ninzio']['blog-back']['background-image'])) ? $GLOBALS['thebuilders_ninzio']['blog-back']["background-image"] : "";
    $nz_back_img_repeat        = (isset( $GLOBALS['thebuilders_ninzio']['blog-back']['background-repeat']) && !empty($GLOBALS['thebuilders_ninzio']['blog-back']['background-repeat'])) ? $GLOBALS['thebuilders_ninzio']['blog-back']['background-repeat'] : "no-repeat";
    $nz_back_img_position      = (isset( $GLOBALS['thebuilders_ninzio']['blog-back']['background-position']) && !empty($GLOBALS['thebuilders_ninzio']['blog-back']['background-position'])) ? $GLOBALS['thebuilders_ninzio']['blog-back']['background-position'] : "left top";
    $nz_back_img_attachment    = (isset( $GLOBALS['thebuilders_ninzio']['blog-back']['background-attachment']) && !empty($GLOBALS['thebuilders_ninzio']['blog-back']['background-attachment'])) ? $GLOBALS['thebuilders_ninzio']['blog-back']['background-attachment'] : "scroll";
    $nz_back_img_size          = (isset( $GLOBALS['thebuilders_ninzio']['blog-back']['background-size']) && !empty($GLOBALS['thebuilders_ninzio']['blog-back']['background-size'])) ? $GLOBALS['thebuilders_ninzio']['blog-back']['background-size'] : "auto";
    $nz_breadcrumbs_text_color = (isset( $GLOBALS['thebuilders_ninzio']['blog-breadcrumbs-text-color']) && !empty($GLOBALS['thebuilders_ninzio']['blog-breadcrumbs-text-color'])) ? $GLOBALS['thebuilders_ninzio']["blog-breadcrumbs-text-color"] : "#777777";
    $nz_blog_text_border_color = (isset( $GLOBALS['thebuilders_ninzio']['blog-text-border-color']['color']) && !empty($GLOBALS['thebuilders_ninzio']['blog-text-border-color']['color'])) ? thebuilders_ninzio_hex_to_rgba($GLOBALS['thebuilders_ninzio']["blog-text-border-color"]['color'],$GLOBALS['thebuilders_ninzio']["blog-text-border-color"]['alpha']) : "";
    $nz_parallax               = (isset( $GLOBALS['thebuilders_ninzio']['blog-parallax']) && $GLOBALS['thebuilders_ninzio']['blog-parallax'] == 1) ? "true" : "false";

    if (!empty($nz_back_color)) {$styles .= 'background-color:'.$nz_back_color.';';}
    if (!empty($nz_text_color)) {$styles .= 'color:'.$nz_text_color.';';}
    if (!empty($nz_back_img)) {

        if ($nz_parallax != "true" && $nz_back_img_attachment != "fixed") {
            $styles .= 'background-image:url('.$nz_back_img.');';
            $styles .= 'background-repeat:'.$nz_back_img_repeat.';';
            $styles .= 'background-position:'.$nz_back_img_position.';';
            if ($nz_back_img_size == "cover") {$styles .= '-webkit-background-size: cover;-moz-background-size: cover;background-size: cover;';}
        }

        if ($nz_parallax == "true" || $nz_back_img_attachment == "fixed") {

            $nz_back_img_repeat     = "no-repeat";
            $nz_back_img_size       = "cover";

            $styles_fp .= 'background-image:url('.$nz_back_img.');';
            $styles_fp .= 'background-repeat:'.$nz_back_img_repeat.';';
            $styles_fp .= 'background-position:'.$nz_back_img_position.';';
        }

        if ($nz_parallax == "true") {$nz_back_img_attachment = "scroll";}

    }

    if (!empty($nz_breadcrumbs_text_color)) {
        $styles_breadcrumbs .= 'color:'.$nz_breadcrumbs_text_color.';';
    }

    if ($nz_rh_version == "version2") {

        if (!empty($nz_blog_text_border_color)) {
            $styles_title .= 'box-shadow:inset 0 0 0 3px '.$nz_blog_text_border_color.';';
        }

    }

?>

<?php if ($nz_rh_version != "none"): ?>
    <header class="rich-header page-header <?php echo esc_attr($nz_rh_version); ?>" data-parallax="<?php echo esc_attr($nz_parallax); ?>" style="<?php echo esc_attr($styles); ?>">
        <?php if ($nz_parallax == "true"): ?>
            <div class="parallax-container" style="<?php echo esc_attr($styles_fp); ?>">&nbsp;</div>
        <?php endif ?>
        <?php if ($nz_back_img_attachment == "fixed"): ?>
            <div class="fixed-container" style="<?php echo esc_attr($styles_fp); ?>">&nbsp;</div>
        <?php endif ?>
        <div class="container nz-clearfix">
            <?php if ($nz_rh_version == "version1"): ?>
                <div class="rh-content">
                    <?php if (is_author() || is_archive() || is_day() || is_tag() || is_category() || is_month() || is_day() || is_year()): ?>
                        <h1 style="<?php echo esc_attr($styles_title); ?>">
                            <?php if (is_category()): ?>
                                <?php echo single_cat_title("", true); ?>
                            <?php elseif(is_tag()): ?>
                                <?php echo single_tag_title("", true); ?>
                            <?php elseif(is_day()): ?>
                                <?php echo get_the_date('F dS Y'); ?>
                            <?php elseif(is_month()): ?>
                                <?php echo get_the_date('Y, F'); ?>
                            <?php elseif(is_year()): ?>
                                <?php echo get_the_date('Y'); ?>
                            <?php elseif(is_author()): ?>
                                <?php $userdata = get_userdata($GLOBALS['author']); ?>
                                <?php echo esc_html__("Articles posted by", 'thebuilders'); ?> "<?php echo esc_attr($userdata->first_name)." ".esc_attr($userdata->last_name); ?>"
                            <?php else: ?>
                                <?php echo esc_html__("Posts", 'thebuilders'); ?>
                            <?php endif ?>
                        </h1>
                        <div style="<?php echo esc_attr($styles_breadcrumbs); ?>" class="nz-breadcrumbs nz-clearfix"><?php thebuilders_ninzio_breadcrumbs(); ?></div>
                    <?php else: ?>
                        <?php if (isset($GLOBALS['thebuilders_ninzio']['blog-title']) && !empty($GLOBALS['thebuilders_ninzio']['blog-title'])): ?>
                            <h1 style="<?php echo esc_attr($styles_title); ?>"><?php echo esc_attr($GLOBALS['thebuilders_ninzio']['blog-title']); ?></h1>
                        <?php else: ?>
                            <h1 style="<?php echo esc_attr($styles_title); ?>"><?php echo esc_html__("Posts", 'thebuilders'); ?></h1>
                        <?php endif ?>
                        <div style="<?php echo esc_attr($styles_breadcrumbs); ?>" class="nz-breadcrumbs nz-clearfix"><?php thebuilders_ninzio_breadcrumbs(); ?></div>
                    <?php endif; ?>
                </div>
            <?php elseif ($nz_rh_version == "version2"): ?>
                <div class="rh-content">
                    <?php if (is_author() || is_archive() || is_day() || is_tag() || is_category() || is_month() || is_day() || is_year()): ?>
                        <h1 style="<?php echo esc_attr($styles_title); ?>">
                            <?php if (is_category()): ?>
                                <?php echo single_cat_title("", true); ?>
                            <?php elseif(is_tag()): ?>
                                <?php echo single_tag_title("", true); ?>
                            <?php elseif(is_day()): ?>
                                <?php echo get_the_date('F dS Y'); ?>
                            <?php elseif(is_month()): ?>
                                <?php echo get_the_date('Y, F'); ?>
                            <?php elseif(is_year()): ?>
                                <?php echo get_the_date('Y'); ?>
                            <?php elseif(is_author()): ?>
                                <?php $userdata = get_userdata($GLOBALS['author']); ?>
                                <?php echo esc_html__("Articles posted by", 'thebuilders'); ?> "<?php echo esc_attr($userdata->display_name); ?>"
                            <?php else: ?>
                                <?php echo esc_html__("Posts", 'thebuilders'); ?>
                            <?php endif ?>
                        </h1>
                    <?php else: ?>
                        <?php if (isset($GLOBALS['thebuilders_ninzio']['blog-title']) && !empty($GLOBALS['thebuilders_ninzio']['blog-title'])): ?>
                            <h1 style="<?php echo esc_attr($styles_title); ?>"><?php echo esc_attr($GLOBALS['thebuilders_ninzio']['blog-title']); ?></h1>
                        <?php else: ?>
                            <h1 style="<?php echo esc_attr($styles_title); ?>"><?php echo esc_html__("Posts", 'thebuilders'); ?></h1>
                        <?php endif ?>
                    <?php endif; ?>                
                </div>
            <?php endif ?>
        </div>
    </header>
<?php endif ?>