<?php 
/**
 *
 * @author Designova (designova.net)
 * @theme next
 */
get_header();
global $smof_data;
while(have_posts()) : the_post();
//Anchor point and title
$next_newanchorpoint   = strtolower(preg_replace('/[^a-zA-Z0-9]/s', '', $post->post_title)); 

$next_new_title      = $next_newanchorpoint;
$next_templ_name     = get_post_meta( $post->ID, '_wp_page_template', true );
$next_filename       = preg_replace('"\.php$"', '', $next_templ_name); 


//Get Other Meta Items
$next_bg_color        =  get_post_meta($post->ID,'next_pagebg_color',true); 
$next_heading_color   =  get_post_meta($post->ID,'next_pagehead_color',true); 
$next_page_heading    =  $post->post_title;


//Failsafe BG color
if($next_bg_color !='')
{
  $next_bg_color= $next_bg_color;
}else 
{ 
  $next_bg_color ="#B5BABF"; 
}


if($next_heading_color == ''){$next_heading_color = '#FFF';}  
$next_text_color = '#FFF';
echo "<style>.blog-content p ,.blog-content{ color: ".$next_text_color."}</style>";
?>

<section id="<?php echo $next_new_title;?>" class="page-section navigation-fadeIn"  data-stellar-background-ratio="2" style="background:<?php echo $next_bg_color;?>">
      <section class="container">

        <div class="row">
          <article class="col-md-12 text-left">
            <h2 class="page-heading" style="color:<?php echo $next_heading_color; ?> "><?php echo $next_page_heading; ?></h2>
            <div class="liner"><span></span></div>
          </article>
        </div>
        <div class="row">
          <article class="col-md-12 text-left blog-content">
            <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>></div>
            <?php the_content();?>
          </article>
        </div>

        <?php if ('open' == $post->comment_status): ?>
        <section class="row add-top">
            <article class="col-md-12" >
               <div class="comments"> <?php comments_template(); ?> </div> 
            </article>
        </section> 
        <?php endif; ?>

    </section>         
</section>
<?php 
/*New Sub-Section Code*/
$group_data = get_post_meta($post->ID, 'gp',false );

$next_content_count  =   count($group_data);
$next_arraypo        =   $next_content_count-1;
 for($i=0;$i<=$next_arraypo;$i++)
  {
      if(isset($group_data[$i]['next_pagesubsection_title'])):
        $next_panel_point   = strtolower(preg_replace('/[^a-zA-Z]/s', '', $group_data[$i]['next_pagesubsection_title'])); 
      else:
        $next_panel_point   = ""; 
      endif;
    //Default fall back
     if(!isset($group_data[$i]['next_pagesubsection_bgcolor']) OR $group_data[$i]['next_pagesubsection_bgcolor'] =='')
     { $secbg_color="#202937"; }else{ $secbg_color = $group_data[$i]['next_pagesubsection_bgcolor']; }
  //Ensure its a subsection
if(isset($group_data[$i]['next_pagesubsection_content']) AND ($group_data[$i]['next_pagesubsection_content']!='')): 
 ?>
<section id="ne-<?php echo $next_panel_point;?>-panel" class="page-section-sub"   style="background:<?php echo $secbg_color;?>">
  <section class="container">

    <?php if(isset($group_data[$i]['next_pagesubsection_title']) AND ($group_data[$i]['next_pagesubsection_title'] !='')): ?>  
      <div class="row">
          <article class="text-left">
            <h2 class="page-heading page-heading-alt" style="color:<?php echo $group_data[$i]['next_pagesubsection_headcolor'];?> !important; "><?php echo $group_data[$i]['next_pagesubsection_title'];?> </h2>
            <div class="liner"><span></span></div>
          </article>
        </div>
      <div class="row add-top">
    <?php else: ?>
    <div class="row">
    <?php endif; ?>  




  <?php echo do_shortcode($group_data[$i]['next_pagesubsection_content']); ?>
  </section>
</section>
<?php
 endif;
 }
?>


<?php 
endwhile;
get_footer(); 
?>