<?php
/**
 * Main index.php
 * @author jason.xie@victheme.com
 */
?>
<?php get_header(); ?>

  <div id="maincontent" class="area clearfix animated in fadeInLeft startblank">
    <div class="container-fluid">
      <div class="row">

        <div id="content"
             class="region
			      <?php if (VTCore_Zeus_Utility::getSidebar('teaser')) {
               echo VTCore_Zeus_Utility::getColumnSize('content');
             } ?>
			      with-sidebar-<?php echo VTCore_Zeus_Utility::getSidebar('teaser'); ?>"
          >

          <?php

          // Build the loop if we got valid content
          if (have_posts()) {

            // Build the sticky posts
            $sticky = get_option('sticky_posts', array());
            rsort($sticky);

            if (!empty($sticky) && is_home()) {

              query_posts(array(
                  'post__in' => $sticky,
                  'ignore_sticky_posts' => FALSE
                ));

              while (have_posts()) {
                the_post();
                setup_postdata($post);

                get_template_part('templates/content/teaser', get_post_format());
              }

              wp_reset_postdata();
              wp_reset_query();
            }


            // Build the main loop
            if (is_numeric($paged)) {
              $wp_query->set('paged', $paged);
            }

            if (!empty($sticky)) {
              $wp_query->set('post__not_in', $sticky);
              $wp_query->get_posts();
            }

            while ($wp_query->have_posts()) {
              the_post();
              setup_postdata($post);

              get_template_part('templates/content/teaser', get_post_format());
            }

            wp_reset_postdata();


            // Retrieves Pager
            $pager = VTCore_Zeus_Utility::getPager($wp_query, FALSE, 'main');
            if (!empty($pager)) {
              echo '<div class="pagination pagination-left">' . $pager . '</div>';
            }
          }

          // Throw page not found if we got no valid posts
          else {
            get_template_part('templates/content/empty');
          }

          ?>
        </div>


        <?php
        // Build sidebar.
        if (VTCore_Zeus_Utility::getSidebar('teaser') == 'right'
          || VTCore_Zeus_Utility::getSidebar('teaser') == 'left'
        ) {
          get_sidebar('sidebar');
        }
        ?>


      </div>
    </div>
  </div>

<?php get_footer(); ?>