<?php get_header(); ?>
<?php
    global $post;
    setup_postdata( $post );
	$summ = null;
	?>    
	 <div class="content-wrapper">
    	<div class="container">
    		<div class="row-fluid">    			
				<?php if (get_field('type')=='slider') 
					{
					?>
				<div class="span6">    				
    				<!-- Controls -->	
				  	<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>
					  <?php $images = get_field('slider');?>
					  <?php if($images):?>
    				<div id="carousel-example-generic" class="carousel slide" style="clear:left;">
					  <!-- Indicators -->
					  <ol class="carousel-indicators">
					  <?php $counter = 0;
							foreach($images 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++;
							endforeach;?>
					  </ol>
					  <!-- Wrapper for slides -->
					  <div class="carousel-inner">
						  <?php $counter = 0;
							foreach($images 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++;
							endforeach;?>	
					  </div>
					<?php endif; ?>	
					</div>
    			</div><!-- end of span 6-->
				<?php 
					}
				else if (get_field('type')=='video') 
						{					
							?>
						<div class="span6">    				
							<!-- Controls -->							
							<h3><?php the_title()?></h3>
							<div class="up-container" id="video-container">
							<?php
							if (get_field('video_host')=='youtube') {
								$url = get_field('video_id');
								?>
								<iframe 
									id="ytplayer" 
									type="text/html" 
									width="570px" 
									height="320px" 
									src="https://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="570px" height="320px" 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>
						</div>
							<?php
						}
						else {
								?>
							<div class="span6">    				
								<!-- Controls -->					
								<h3><?php the_title()?></h3>
								<div class="up-container" id="home2-img">
									<?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="width:570px;height:320px; background:url('.get_template_directory_uri().'/img/cubes.png);"></div>';												}
									?>
								</div>
							</div>
					  <?php
							}
						?>
    			<div class="span3">
    				<h3><?php _e('Details','hybrid_lang');?></h3>
    				<div id="introduction" class="single-workpost-desc">
						<?php the_content( );?>    										
    				</div>
    			</div>
    			<?php if (!get_field("live_demo")) {
								$summ = 2;
							} ?>
    			<div class="span3">
    				<h3><?php _e('Summary','hybrid_lang');?></h3>
    				<div id="project-summary" class="bordered-summary work-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 $cat = get_terms('works_category');
                                    $current_categories = get_the_terms(get_the_ID(),'works_category');
                                    $className = '';
                                    if( $current_categories)
                                    {
                                        foreach($current_categories as $cat)
                                        {
                                            $className = $className.' '.$cat->name;
                                        }
                                    }
                                    echo $className ; ?>
							</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('Author:','hybrid_lang') ?></p>
    						<p class="post-title smaller-title black"><?php echo get_the_author(); ?></p>
    					</div>
						<?php if(!get_field("disable_work_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>
    		<h3><?php _e('Recent projects','hybrid_lang');?></h3>
    		<div class="row-fluid">			
            <?php              
				 $args = array(
								'post_type' => 'work_post',
								'posts_per_page' => 4,	
								'order' => 'desc'
							);
                $the_query = new WP_Query($args);
                while ( $the_query->have_posts() ):
                        $the_query->the_post(); ?>
				<div class="span3 similar-proj">
							<div class="image-container">
								<a href="<?php the_permalink();?>" >
									<?php if(has_post_thumbnail()):?>
											<?php the_post_thumbnail('work_post_Slider');?>		
										<?php endif;?>
								<div class="image-hover">
											<!--<p><i class="icon-play icon-large"></i></p>-->
										</div>
								</div>
								<h4><?php the_title(); ?></h4>
								<p class="post-categoty capitalize">
								<?php $cat = get_terms('works_category');
                                    $current_categories = get_the_terms(get_the_ID(),'works_category');
                                    $className = '';
                                    if( $current_categories)
                                    {
                                        foreach($current_categories as $cat)
                                        {
                                            $className = $className.' '.$cat->name;
                                        }
                                    }
                                    echo $className ; ?>
								</p>
								</a>
						</div><!--END of span3-->
					<?php endwhile;?>	
				</div><!--END of rowfluid-->
    	</div><!--container-->
    </div><!--.content-wrapper-->
<?php get_footer(); ?>