<?php if ( is_home() || is_front_page() ) { ?>
<?php $hidefourbxsec = of_get_option('hidefourbxsec', '1'); ?>
<?php if($hidefourbxsec == ''){ ?>

<section id="pagearea">
  <div class="container">
    <div class="area_row">     
      <div class="box-equal-height">
        <?php
			$title_arr = array( esc_attr__('Organic Food','groceem-pro'), esc_attr__('100% Natural','groceem-pro'), esc_attr__('Fresh & Tasty','groceem-pro'));
			$boxArr = array();
			   if( of_get_option('box1',true) != '' ){
				$boxArr[] = of_get_option('box1',false);
			   }
			   if( of_get_option('box2',true) != '' ){
				$boxArr[] = of_get_option('box2',false);
			   }
			   if( of_get_option('box3',true) != '' ){
				$boxArr[] = of_get_option('box3',false);
			   }
			   if( of_get_option('box4',true) != '' ){
				$boxArr[] = of_get_option('box4',false);
			   }
			   if( of_get_option('box5',true) != '' ){
				$boxArr[] = of_get_option('box5',false);
			   }
			    if( of_get_option('box6',true) != '' ){
				$boxArr[] = of_get_option('box6',false);
			   }			   			  
			if (!array_filter($boxArr)) {
			for($fx=1; $fx<=3; $fx++) {
			?>
        <div class="top4box  box-color-<?php echo $fx; ?> <?php if($fx % 3 == 0) { echo "last_column"; } ?>">
          <div class="topboxbg">
            <div class="thumbbx-title">
              <div class="thumbbx"> <a href="#"><img src="<?php echo get_template_directory_uri(); ?>/images/services_icon<?php echo $fx; ?>.png" alt="" /></a> </div>
              <a href="#">
              <h4><?php echo $title_arr[$fx-1]; ?></h4>
              </a> </div>
            <!-- thumbbx-title -->
            <div class="clear"></div>
            <p>
              <?php _e('Curabitur ligula enim, pellen sitam etullamcorp molesti viverra nonelit Sed eleifend porttitor nulla.', 'groceem-pro') ?>
            </p>
            <?php if( of_get_option('readmorebutton',true) != '') { ?>
            <a class="pagemore hvr-float-shadow" href="#"><?php echo of_get_option('readmorebutton'); ?></a>
            <?php } ?>
          </div>
          <!-- <div class="pagecontent"> </div> topboxbg --> 
        </div>
        <?php 
			} 
			} else {			
				$box_column = array('no_column','one_column','two_column','three_column','four_column','five_column','six_column');
				$fx = 1;				
				$queryvar = new wp_query(array('post_type' => 'page', 'post__in' => $boxArr, 'posts_per_page' => 6, 'orderby' => 'post__in' ));				
				while( $queryvar->have_posts() ) : $queryvar->the_post(); ?>
        <div class="top4box  box-color-<?php echo $fx; ?> <?php echo $box_column[count($boxArr)]; ?> <?php if($fx % count($boxArr) == 0) { echo "last_column"; } ?>">
          <div class="topboxbg">
          
          <div class="thumbbx-title">
              <?php if( of_get_option('boximg'.$fx, true) != '') { ?>
            <div class="thumbbx"> <a href="<?php the_permalink(); ?>"><img alt="" src="<?php echo esc_url( of_get_option( 'boximg'.$fx, true )); ?>" / ></a> </div>
            <?php } ?>
              <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>
              </div>
            <!-- thumbbx-title -->   
              <div class="clear"></div>
              <p><?php echo wp_trim_words( get_the_content(), of_get_option('pageboxlength'), '' ); ?></p>
              <?php if( of_get_option('readmorebutton',true) != '') { ?>
              	<a class="pagemore hvr-float-shadow" href="<?php the_permalink(); ?>"><?php echo of_get_option('readmorebutton'); ?></a>
              <?php } ?>
            </div>
        </div>
        <?php 
			 $fx++; 
			 endwhile;
			 wp_reset_postdata();
			 }		
		 ?>
        <div class="clear"></div>
      </div>
      <!-- .row--> 
    </div>
    <!-- .box-equal-height--> 
  </div>
  <!-- .container --> 
</section>
<!-- #pagearea -->
<?php } ?>

<?php $hidesixbxsec = of_get_option('hidesixbxsec', '1'); ?>
<?php if($hidesixbxsec == ''){ ?>
<section id="section2-pagearea">
  <div class="container">
    <div class="area_row">
      <?php if( of_get_option('topboxtitle',true) != '') { ?>
      <h2 class="section_title"><?php echo of_get_option('topboxtitle'); ?> </h2>
      <?php } ?>
      <div class="box-equal-height">
      <?php
			$title_arr = array( esc_attr__('EGGS','groceem-pro'), esc_attr__('honey','groceem-pro'), esc_attr__('coconut','groceem-pro'), esc_attr__('vegies','groceem-pro'), esc_attr__('Fresh butter','groceem-pro'), esc_attr__('sweet corn','groceem-pro'));
			$boxArr = array();
			   if( of_get_option('sec2box1',true) != '' ){
				$boxArr[] = of_get_option('sec2box1',false);
			   }
			   if( of_get_option('sec2box2',true) != '' ){
				$boxArr[] = of_get_option('sec2box2',false);
			   }
			   if( of_get_option('sec2box3',true) != '' ){
				$boxArr[] = of_get_option('sec2box3',false);
			   }
			   if( of_get_option('sec2box4',true) != '' ){
				$boxArr[] = of_get_option('sec2box4',false);
			   }
			   if( of_get_option('sec2box5',true) != '' ){
				$boxArr[] = of_get_option('sec2box5',false);
			   }
			    if( of_get_option('sec2box6',true) != '' ){
				$boxArr[] = of_get_option('sec2box6',false);
			   }			   			  
			if (!array_filter($boxArr)) {
			for($fx=1; $fx<=6; $fx++) {
			?>
      <div class="top6box <?php if($fx % 6 == 0) { echo "last_column"; } ?>">
        <div class="top6boxbg">
          <div class="top6boxthumbbx"><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/images/family_farm_image<?php echo $fx; ?>.png" alt="" /></a> </div>
          <a href="#">
          <h6><?php echo $title_arr[$fx-1]; ?></h6>
          </a> </div>
      </div>
      <?php 
			} 
			} else {			
				$box_column = array('no_column','one_column','two_column','three_column','four_column','five_column','six_column');
				$fx = 1;				
				$queryvar = new wp_query(array('post_type' => 'page', 'post__in' => $boxArr, 'posts_per_page' => 6, 'orderby' => 'post__in' ));				
				while( $queryvar->have_posts() ) : $queryvar->the_post(); ?>
      <div class="top6box <?php echo $box_column[count($boxArr)]; ?>">
        <div class="top6boxbg">
          <?php if( of_get_option('sec2boximg'.$fx, true) != '') { ?>
          <div class="top6boxthumbbx"> <a href="<?php the_permalink(); ?>"><img alt="" src="<?php echo esc_url( of_get_option( 'sec2boximg'.$fx, true )); ?>" / ></a> </div>
          <?php } ?>
          <div class="pagecontent"> <a href="<?php the_permalink(); ?>">
            <h6>
              <?php the_title(); ?>
            </h6>
            </a> </div>
        </div>
      </div>
      <?php 
			 $fx++; 
			 endwhile;
			 wp_reset_postdata();
			 }		
		 ?>
      <div class="clear"></div>
    </div><!-- .row--> 
    </div><!-- .box-equal-height--> 
  </div><!-- .container --> 
</section>
<?php } ?>
<?php } ?>
