<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * For example, it puts together the home page when no home.php file exists.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package Serpentsoft
 * @subpackage Adams_News
 * @since Adams News 1.0
 */

get_header(); ?>

<!-- Slider -->
<?php $home_page_items_count = 0;

if( serpentsoft_get_data('serpentsoft_slider_main') ) {
    $slider_no_posts = serpentsoft_get_data('serpentsoft_slider_no_of_posts');
    if( !is_numeric($slider_no_posts) || $slider_no_posts < 0 ) { $slider_no_posts = 6; }

    $cat_id = serpentsoft_get_data('lst_serpentsoft_slider_categories');

if( $cat_id != 0 ){ $wp_query = new WP_Query(array('post_type' => 'post', 'cat' => $cat_id, 'posts_per_page' => $slider_no_posts, 'post_status' => 'publish')); }
else{ $wp_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $slider_no_posts, 'post_status' => 'publish')); }

if( $wp_query->have_posts() ) :
    $home_page_items_count++; ?>
        
<section class="pic-slider">
    <h2 class="hidden">Slider Section</h2>

    <div class="row-fluid modern-items-list">
        <div id="mainSlider1" class="flexslider large">
            <ul class="slides">
            <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
                <li>
                    <article class="fold-item span12">
                        <div class="clearfix">
                        <?php serpentsoft_post_featured_image('large', $post->ID); ?>

                            <div class="description visible-part">
                                <div class="title">
                                    <div class="post-date">
                                        <div class="date">
                                            <span class="month"><?php echo get_the_date('M'); ?></span>
                                            <span class="day"><?php echo get_the_date('d'); ?></span>
                                            <span class="month"><?php echo get_the_date('Y'); ?></span>
                                            <hr />
                                            <span class="time"><?php the_time('h:i A'); ?></span>
                                        </div>
                                    </div>

                                    <h3><?php the_title(); ?></h3>

                                    <div class="post-meta">
                                        <span><i class="bo-icon-pencil bo-icon-white"></i><?php the_author(); ?></span>
                                        <span><i class="bo-icon-comment bo-icon-white"></i><?php comments_number(); ?></span>
                                        <span><i class="bo-icon-eye-open bo-icon-white"></i><?php echo serpentsoft_get_post_views($post->ID); ?></span>
                                    </div>
                                    
                                    <?php echo serpentsoft_draw_large_stars($post->ID); ?>
                                </div>

                                <div class="text"><?php serpentsoft_slider_GetTheExcerpt(); ?></div>
                            </div>

                            <a href="<?php the_permalink(); ?>" class="more" title="<?php the_title(); ?>"></a>
                        </div>
                    </article>
                </li>
            <?php endwhile; ?>
            </ul>
        </div>

        <div id="mainSlider1-carousel" class="flexslider large carousel">
            <ul class="slides">
            <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
                <li><?php serpentsoft_post_featured_image( 'small', $post->ID ); ?></li>
            <?php endwhile; ?>
            </ul>
        </div>
        
        <script type="text/javascript">
            //<![CDATA[
            jQuery(document).ready(function() {
               "use strict";
               var is_exist = jQuery('#mainSlider1').length > 0 ? jQuery('#mainSlider1').length : 0;
               var is_car_exist = jQuery('#mainSlider1-carousel').length > 0 ? jQuery('#mainSlider1-carousel').length : 0;

               if (is_exist > 0) {
                    if (is_car_exist > 0) {
                        var x_animation_style = "<?php echo serpentsoft_get_data('serpentsoft_slider_main_animation_style'); ?>";
                        var x_animation_speed = <?php echo serpentsoft_get_data('serpentsoft_slider_main_animation_speed'); ?>;
                        var x_reverse = <?php if(! serpentsoft_get_data('serpentsoft_slider_main_reverse_slides')) { echo 0; } else { echo 1; } ?>;

                        var x_auto_play = false;
                        var x_animation_loop = true;
                        var x_pause_on_hover = true;
                        var x_slides_transition_speed = 7000;
						
                        var x_auto_play = <?php if(! serpentsoft_get_data('serpentsoft_slider_main_auto_slide')) { echo 0; } else { echo 1; } ?>;
                        
                        if(x_auto_play === 1){
                            x_slides_transition_speed = <?php echo serpentsoft_get_data('serpentsoft_slider_main_transition_speed'); ?>;
                            x_animation_loop = <?php if(! serpentsoft_get_data('serpentsoft_slider_main_animation_loop')) { echo 0; } else { echo 1; } ?>;
                            x_pause_on_hover = <?php if(! serpentsoft_get_data('serpentsoft_slider_main_pause_on_hover')) { echo 0; } else { echo 1; } ?>;
                        }
                        
                        /* SyntaxHighlighter.all(); */
                        
                        // The slider being synced must be initialized first
                        jQuery('#mainSlider1-carousel').flexslider({
                            slideshow: x_auto_play,      //both           //Boolean: Animate slider automatically

                            animationLoop: x_animation_loop, //both            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
                            pauseOnHover: x_pause_on_hover,  //both          //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
                            slideshowSpeed: x_slides_transition_speed, //both          //Integer: Set the speed of the slideshow cycling, in milliseconds

                            animation: "slide",   //static
                            reverse: false,       //static          //{NEW} Boolean: Reverse the animation direction
                            animationSpeed: x_animation_speed,  //both          //Integer: Set the speed of animations, in milliseconds

                            easing: "swing",      //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
                            controlNav: false,
                            itemWidth: 97,
                            itemMargin: 5,
                            asNavFor: '#mainSlider1'
                        });
                    }
                    jQuery('#mainSlider1').flexslider({
                        slideshow: x_auto_play,      //both           //Boolean: Animate slider automatically

                        animationLoop: x_animation_loop, //both            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
                        pauseOnHover: x_pause_on_hover,  //both          //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
                        slideshowSpeed: x_slides_transition_speed, //both          //Integer: Set the speed of the slideshow cycling, in milliseconds

                        animation: x_animation_style,   //only here //String: Select your animation type, "fade" or "slide"
                        reverse: x_reverse,        //only here        //{NEW} Boolean: Reverse the animation direction
                        animationSpeed: x_animation_speed,  //both          //Integer: Set the speed of animations, in milliseconds

                        easing: "swing",      //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
                        controlNav: false,
                        sync: "#mainSlider1-carousel"
                    });
                }
            });
            //]]>
        </script>
    </div>

</section>


<?php endif; /* have_posts */?>
<?php } /* Main Slider Switch */ ?>
                
<!-- Build Home Categories & Ads -->
<?php serpentsoft_build_homepage(); ?>

<!-- Create a Blog Page if Home Page is Blank -->
<?php if( $home_page_items_count <= 0 ){
    $wp_query = new WP_Query(array('post_type' => 'post', 'paged' => get_query_var('paged'), 'post_status' => 'publish')); ?>
    
<article class="article-container" itemscope itemtype="http://schema.org/Article" role="main">
<div class="row-fluid">

    <?php if ( $wp_query->have_posts() ) { ?>
        
    <div class="article-content">
        <header>
            
        </header>

        <span class="clearfix"></span>
			
    <!-- Blog Category -->
    <div class="blog">
        
        <ul class="media-list">
        <?php while ( $wp_query->have_posts() ) : $wp_query->the_post();
            get_template_part('loop', 'blog');
        endwhile; ?>
        </ul>

        <div class="row-fluid paging-footer"><?php serpentsoft_bootstrap_pagination(); ?></div>

        </div><!-- Blog -->

        </div> <!-- article-content -->
		
    <?php } else{ ?>
        
    <div class="article-content">
        <header>
            <?php serpentsoft_single_breadcrumb(); ?>

            <h1 itemprop="headline"><?php _e( 'No Posts Found', 'serpentsoft' ); ?></h1>

            <div class="post-info"></div>

        </header>

        <span class="clearfix"></span>

        <!-- Blog -->

        <div class="blog">
            <p><?php printf( __( 'Apologies, but this category ( %s ) have no posts.', 'serpentsoft' ), '<b>' . single_cat_title( '', false ) . '</b>' ); ?></p>
        </div>
    </div>
        
    <?php } ?>
</div>
    
</article>
    
<?php } /* if home page have no categories */ ?>

<!-- Closing Span6 Main Content -->

<?php get_footer(); ?>