<?php get_header();?>
<?php
global $post;
setup_postdata( $post );
$summ = null;
?>
    <div class="content-wrapper">
    	<div class="container">
    		<div class="row-fluid">
				<?php if(is_active_sidebar('sidebar-1')){?>
					<div class="span9" id="main-content">
				<?php } else { ?>
					<div class="span12" id="main-content">
				<?php } ?>
				<?php while ( have_posts() ) : the_post();?>
						<!-- Controls -->   
						<?php if (get_field('type')=='slider') 
							{
								$gallery = get_field('slider');							
								?>
									<ul class="pg_paging_bp" style="float:right;">
										<li class="pg_previous_bp transition">
											<a href="#carousel-example-generic" data-slide="prev">
												<i class="icon-caret-left transition"></i>
											</a>
										</li>
										<li class="pg_next_bp transition">
											<a href="#carousel-example-generic" data-slide="next">
												<i class="icon-caret-right transition"></i>
											</a>
										</li>
									</ul>
									<h3><?php the_title()?></h3>
								<div id="carousel-example-generic" class="carousel slide single-carousel">
									  <!-- Indicators -->
									  <ol class="carousel-indicators" style="left:15px;">
									  <?php 
										$counter =0;
										foreach( $gallery as $image ) { 
											if($counter==0)
											 echo '<li data-target="#carousel-example-generic" data-slide-to="'.$counter.'" class="active"></li>';
											else
											 echo '<li data-target="#carousel-example-generic" data-slide-to="'.$counter.'"></li>';		
											$counter++;
										 }?>
									  </ol>
									  <!-- Wrapper for slides -->
									  <div class="carousel-inner stacked-carousel span8">
									   <?php 
										$counter =0;
										foreach( $gallery as $image ) { 
											if($counter==0)
												echo '<div class="item active">';
											else 
												echo '<div class="item">';		
											 $image = wp_get_attachment_image_src($image['image'], 'home2-featured');	
											echo  '<img src="'.$image[0].'" alt=""/>';	
											echo '</div>';
											$counter++;
										}?>								
									 </div>
								<?php
							}
							else if (get_field('type')=='video') 
							{					
								?>
								<h3><?php the_title()?></h3>
								<div id="carousel-example-generic" class="carousel slide single-carousel">
									<div class="carousel-inner stacked-carousel span8">
								<?php
								if (get_field('video_host')=='youtube') {
									$url = get_field('video_id');
									?>
									<iframe 
										id="ytplayer" 
										type="text/html" 
										width="570px" 
										height="320px" 
										src="//www.youtube.com/embed/<?php echo $url; ?>" 
										frameborder="0" 
										allowfullscreen>
									</iframe>
								<?php
								}
								elseif (get_field('video_host')=='vimeo') {
									$url = get_field('video_id');
								?>
									<iframe 
										src="//player.vimeo.com/video/<?php echo $url; ?>" 
										width="570px" 
										height="320px" 
										frameborder="0" 
										webkitallowfullscreen mozallowfullscreen allowfullscreen>
									</iframe> 

								<?php
								}
								else{
									$attachment_id = get_field('video_file');
									$url = wp_get_attachment_url( $attachment_id );
								?>
									<video width="100%" height="360" controls>
										<source src="<?php echo $url; ?>" type="video/mp4">
										<source src="<?php echo $url; ?>" type="video/ogg">
										<?php _e('Your browser does not support the video tag.','hybrid_lang');?>
									</video>
								<?php
								}
								?>
								</div>
								<?php
							}
							else {
									?>
									<h3><?php the_title()?></h3>
									<div id="carousel-example-generic" class="carousel slide single-carousel">
									  <!-- Wrapper for slides -->
									  <div class="carousel-inner stacked-carousel span8">
										<div class="item active">
										  <?php
											if(has_post_thumbnail())
											{							
											   $image = wp_get_attachment_image_src(  get_post_thumbnail_id($post->ID), 'home2-featured' ); 
												echo '<img src="'.$image[0].'" alt=""/>';
											}										
											else{
													echo '<div style="min-width:570px;height:320px; background:url('.get_template_directory_uri().'/img/cubes.png);"></div>';	
												}
											?>
										</div>					   
									  </div>
						  <?php
								}
								if (!get_field("live_demo")) {
									$summ = 2;
								}
							?>
						  <div id="project-summary" class="stacked-summary">
							<div class="summary-details<?php echo $summ;?>">
								<p class="post-categoty"><?php _e('Category:','hybrid_lang');?></p>
								<p class="post-title smaller-title black">
								<?php 
									$post_categories = wp_get_post_categories( $post->ID );								
									$categories = '';	
									foreach($post_categories as $c){
										$cat = get_category( $c );									
										$categories = $categories.' '.$cat->name;
									}
									echo $categories;
									?>
								</p>
							</div>
							<div class="summary-details<?php echo $summ;?>">
								<p class="post-categoty"><?php _e("Posted on:", "hybrid_lang");?></p>
								<p class="post-title smaller-title black"><?php echo get_the_date();?></p>
							</div>
							<div class="summary-details<?php echo $summ;?>">
								<p class="post-categoty"><?php _e("Tags:", "hybrid_lang");?></p>
								<p class="post-title smaller-title black">
								<?php if(get_the_tags()):?>		
											<?php
												$tags = get_the_tags();
												$c = sizeof($tags);											
												foreach ( $tags as $tag ) {
														$tag_link = get_tag_link( $tag->term_id );															
														$html = "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
														$html .= "{$tag->name}</a> ";
														$c--;
														if($c!=0)
															$html .= ", ";
														echo $html;													
													}
											?>										
										<?php endif;?>
								</p>
							</div>
							<?php if(!get_field("disable_blog_social_shares","options")) : ?>
								<div class="summary-details<?php echo $summ;?> share">    						
									<?php get_template_part('social','share');?>
								</div>			
							  <?php endif; ?>
							<?php if(get_field("live_demo")) { 
								echo '<div class="summary-details">';
								$live_demo = get_field("live_demo");
								echo '<a href="'.$live_demo.'"><p class="post-title capitalize text-center">live demo</p></a>							';
								echo '</div>';
							   }?>
						</div>
						</div>					
						<div id="col-container" class="single-post-content">
							<?php the_content();?>	
							<?php  wp_link_pages(array('before'=> '<div class="nav-links">','after'=> '</div>','separator'=> '  ',
														'next_or_number'   => '',
														'nextpagelink'     => __( 'Next','hybrid_lang' ),	'previouspagelink' => __( 'Previous','hybrid_lang' ),
														'pagelink'         => '%',	'echo' => 1
													));?>	
						</div>							
					<?php endwhile;	?>
					<?php	comments_template(); ?>						 
			</div><!--span9--> 		
				<?php if(is_active_sidebar('sidebar-1')):?>
					<div class="span3" id="blog-sidebar1">					
						<?php  if ( !function_exists('dynamic_sidebar') ||  !dynamic_sidebar('sidebar-1') ) ?>
					</div>
				<?php endif;?>
	    		
    		</div>
    	</div><!--container-->
    </div><!--.content-wrapper-->
<?php wp_reset_postdata(); ?>
<?php get_footer();?>