<?php /*** The loop that displays posts.***/ 

$get_meta = get_post_custom($post->ID);
$showdate = weblusive_get_option('blog_show_date'); 
$showcomments = weblusive_get_option('blog_show_comments'); 
$showcategory = weblusive_get_option('blog_show_category'); 
$showrmtext = weblusive_get_option('blog_show_rmtext'); 
?>

<?php if ( ! have_posts() ) : ?>
	<div id="post-0" class="post error404 not-found">
		<h1 class="entry-title"><?php _e( 'Not Found', 'Wecare' ); ?></h1>
		<div class="entry-content">
			<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'Wecare' ); ?></p>
			<?php get_search_form(); ?>
		</div><!-- .entry-content -->
	</div><!-- #post-0 -->
<?php else:?>
	<?php while ( have_posts() ) : the_post(); 
		$get_meta = get_post_custom($post->ID);
		
		$mediatype = isset($get_meta["_blog_mediatype"]) ? $get_meta["_blog_mediatype"][0] : 'image';
		$videoId = isset($get_meta["_blog_video"]) ? $get_meta["_blog_video"][0] : ''; 
		$autoplay =  isset($get_meta["_blog_videoap"]) ? $get_meta["_blog_videoap"][0] : '0';
		$thumbnail = get_the_post_thumbnail($post->ID, 'blog-list');
		?>
		<div id="post-<?php the_ID();?>" <?php post_class('blog-box image-post'); ?>>			
				<?php if($mediatype== 'image' && !empty($thumbnail)):?>
					<a href="<?php the_permalink()?>"><?php the_post_thumbnail('blog-list'); ?></a>
				<?php elseif ( $mediatype == "youtube" && $videoId):?>
					<iframe width="270" height="193" src="http://www.youtube.com/embed/<?php echo $videoId?>?autoplay=<?php echo $autoplay?>" class="vid iframe-youtube"></iframe>
				<?php elseif ( $mediatype == "vimeo" && $videoId):?>
					<iframe width="270" height="190" src="http://player.vimeo.com/video/<?php echo $videoId?>?autoplay=<?php echo $autoplay?>" class="vid iframe-vimeo"></iframe>
				<?php elseif ( $mediatype == "dailymotion" && $videoId):?>
					<iframe width="270" height="190" src="http://www.dailymotion.com/embed/video/<?php echo $videoId?>?autoplay=<?php echo $autoplay?>" class="vid dailymotion-vimeo"></iframe>
				<?php elseif ( $mediatype == "veoh" && $videoId):?>
					<iframe width="270" height="190" src="http://www.veoh.com/static/swf/veoh/SPL.swf?videoAutoPlay=<?php echo $autoplay?>&permalinkId=<?php echo $videoId?>" class="vid iframe-veoh"></iframe>
				<?php elseif ( $mediatype == "bliptv" && $videoId):?>
					<iframe width="270" height="190" src="http://a.blip.tv/scripts/shoggplayer.html#file=http://blip.tv/rss/flash/<?php echo $videoId?>?autoplay=<?php echo $autoplay?>" class="vid iframe-bliptv"></iframe>
				<?php elseif ( $mediatype == "viddler" && $videoId):?>
					<iframe width="270" height="10" src="http://www.viddler.com/embed/<?php echo $videoId?>e/?f=1&offset=0&autoplay=<?php echo $autoplay?>" class="vid iframe-viddler"></iframe>
				<?php elseif($mediatype== 'slider' && !empty($thumbnail)):?>
					<div class="flexslider">
						<ul class="slides">
						<?php 
						$argsThumb = array(
							'order'          => 'ASC',
							'post_type'      => 'attachment',
							'post_parent'    => $post->ID,
							'post_mime_type' => 'image',
							'post_status'    => null,
							//'exclude' => get_post_thumbnail_id()
						);
						$attachments = get_posts($argsThumb);
						if ($attachments) {
							foreach ($attachments as $attachment) {
								echo '<li><img src="'.wp_get_attachment_url($attachment->ID, 'full', false, false).'" alt="'.get_post_meta($attachment->ID, '_wp_attachment_image_alt', true).'" /></li>';
							}
						}?>
						</ul>
					</div>
				<?php endif?>
                    <div class="blog-text">
                        <h4><?php the_title()?></h4>
                        <div class="border"></div>
                        <div class="post-meta">
                            <?php if( 'open' == $post->comment_status && $showcomments) : ?>  
                            <div class="post-comment">
                                <?php comments_popup_link( __( '0 Comments', 'Wecare' ), __( '1 Comment', 'Wecare' ), __( '% Comments', 'Wecare' )); ?> 
                            </div>
                            <?php endif?>
                            <?php if($showcategory): ?>
                            <div class="post-user">
                                <a href="#"><?php the_author() ?></a>
                            </div>
                            <?php endif?>
                            <?php if($showdate): ?>
                            <div class="post-date">
                                <?php echo get_the_time('M d, Y'); ?>
                            </div>
                            <?php endif; ?>
                            <div class="clear"></div>
                        </div>
                        <div class="post-text">
                            <p><?php echo do_shortcode(get_the_excerpt()); ?></p>
                        </div>
			<a class="read_more" href="<?php the_permalink()?>"><?php echo (isset($showrmtext)&& !empty($showrmtext)) ? $showrmtext : 'Read More';?></a>
                    </div>
		</div>
        <div class="clear"></div>
	<?php endwhile;?>
<?php endif; ?>
<?php if ( $wp_query->max_num_pages > 1 ): ?>
	<div class="pagination-list blog-pagination">
		<?php include(Wecare_PLUGINS . '/wp-pagenavi.php' ); wp_pagenavi(); ?> 
		<div class="clear"></div>
	</div>
<?php endif?>	
<div class="clear"></div>