<?php /** The Template for displaying all single posts. **/

get_header(); 
$get_meta = get_post_custom($post->ID);
$weblusive_sidebar_pos = weblusive_get_option('sidebar_pos');
$sidebar = weblusive_get_option('sidebar_archive');
get_template_part( 'library/includes/page-head' ); 

$showdate = weblusive_get_option('blog_show_date'); 
$showcomments = weblusive_get_option('blog_show_comments'); 
$showcategory = weblusive_get_option('blog_show_category'); 
?>
<div class="banner">
    <div class="inner-banner">
        <?php if (!weblusive_get_option('hide_titles')):?>
            <div class="note"><?php the_title(); ?></div>
       <?php endif?>
       <?php if (!weblusive_get_option('hide_breadcrumbs')):?>
            <div class="site-map">
                <?php _e('You are here:', 'Wecare');?>
                <?php if(class_exists('the_breadcrumb')){ $albc = new the_breadcrumb; } ?>
            </div>
        <?php endif?>
	<div class="clear"></div>
    </div>
</div>
<!-- Container -->
<div class="wrapper dark">
    <?php if ($weblusive_sidebar_pos == 'left') get_sidebar($sidebar); ?>
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
		<div class="column9">
			<?php 
				$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');
			?>
			<article id="post-<?php the_ID();?>" <?php post_class('blog-single'); ?>>		
				<div class="single-post-media">
					<?php if($mediatype== 'image' && !empty($thumbnail)):?>
					<a class="blog-image" href="<?php the_permalink()?>"><?php the_post_thumbnail('blog-list'); ?></a>
					<?php elseif ( $mediatype == "youtube" && $videoId):?>
					<iframe width="740" height="300" 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="740" height="300" 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="740" height="300" 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="740" height="300" 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="740" height="300" 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="740" height="300" 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>
				<div class="box-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="single-post-text">
						<?php the_content()?>
					</div>
					<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'Wecare' ), 'after' => '</div>' ) ); ?>
				</div>
		</article>
		<div class="comments-section">
			<?php if( 'open' == $post->comment_status) comments_template(); ?>
			<?php $test = false; if ($test) {comment_form();} ?>
		</div>	
    <?php endwhile; ?>	
	</div>
	<?php if ($weblusive_sidebar_pos == 'right') get_sidebar($sidebar); ?>
	  <div class="clear"></div>
</div>
<?php get_footer(); ?>