<?php get_header(); 

$fwp = get_post_meta($post->ID, '_nectar_portfolio_item_layout', true);
if(empty($fwp)) $fwp = 'false';

$hidden_featured_media = get_post_meta($post->ID, '_nectar_hide_featured', true);
$hidden_project_title = get_post_meta($post->ID, '_nectar_hide_title', true);

global $post;

$bg = get_post_meta($post->ID, '_nectar_header_bg', true);
$bg_color = get_post_meta($post->ID, '_nectar_header_bg_color', true);
$bg_type = get_post_meta($post->ID, '_nectar_slider_bg_type', true); 
if(empty($bg_type)) $bg_type = 'image_bg'; 

$featured_src =  (has_post_thumbnail( $post->ID )) ? wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full') : array('empty') ;
$full_width_portfolio = (!empty($fwp) && $fwp == 'enabled') ? 'id="full_width_portfolio" data-featured-img="'. $featured_src[0] .'"' : 'data-featured-img="'. $featured_src[0] .'"';

$options = get_nectar_theme_options(); 
$single_nav_pos = (!empty($options['portfolio_single_nav'])) ? $options['portfolio_single_nav'] : 'in_header';
$subtitle = get_post_meta($post->ID, '_nectar_header_subtitle', true);

$project_social_style = (!empty($options['portfolio_social_style'])) ? $options['portfolio_social_style'] : 'default';
?>

<div <?php echo $full_width_portfolio; if(!empty($bg) && $fwp != 'enabled' || !empty($bg_color) && $fwp != 'enabled') echo ' data-project-header-bg="true"'?> >
	  		
	  	<?php nectar_page_header($post->ID); 
			
			if(empty($bg) && empty($bg_color) && $bg_type != 'video_bg') {?>
	  		
				<div class="row project-title">
					<div class="container">
						<div class="title-wrap">
						<div class="col span_12 section-title <?php if(empty($options['portfolio_social']) || $options['portfolio_social'] == 0 || empty($options['portfolio_date']) || $options['portfolio_date'] == 0 ) echo 'no-date'?>">
							
							<h1><?php the_title(); ?></h1>
							<?php if(!empty($subtitle)) { ?> <span class="subheader"><?php echo $subtitle; ?></span> <?php } ?>

							<?php if($single_nav_pos == 'in_header') project_single_controls(); ?>
					 
						</div> 
					</div>
				</div> 
			
			</div><!--/row-->
			
		<?php } //project header ?>
		
	<div class="container-wrap" data-nav-pos="<?php echo $single_nav_pos; ?>">
		
		<div class="container main-content"> 
			
			<?php 

			$enable_gallery_slider = get_post_meta( get_the_ID(), '_nectar_gallery_slider', true ); ?>
			
			<div class="row <?php if(!empty($enable_gallery_slider) && $enable_gallery_slider == 'on') echo 'gallery-slider'; ?>">
				
				<?php if(have_posts()) : while(have_posts()) : the_post(); 
				
					if ( function_exists( 'yoast_breadcrumb' ) ){ yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } 
				?>
					
					<div class="post-area col <?php if($fwp != 'enabled') { echo 'span_9'; } else { echo 'span_12'; } ?>">
						
						<?php 

	 						if(!post_password_required()) {
							 
								$video_embed = get_post_meta($post->ID, '_nectar_video_embed', true);
								$video_m4v = get_post_meta($post->ID, '_nectar_video_m4v', true);
								$video_ogv = get_post_meta($post->ID, '_nectar_video_ogv', true); 
								$video_poster = get_post_meta($post->ID, '_nectar_video_poster', true); 
						
								//Gallery
								  
								if(class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'second-slide') || !empty($enable_gallery_slider) && $enable_gallery_slider == 'on'){
									
									if ( floatval(get_bloginfo('version')) < "3.6" ) {

									}
									else {
										
										if(!empty($enable_gallery_slider) && $enable_gallery_slider == 'on') { $gallery_ids = grab_ids_from_gallery(); ?>
									
										<div class="flex-gallery"> 
											 <ul class="slides">
											 	<?php 
												foreach( $gallery_ids as $image_id ) {
												     echo '<li>' . wp_get_attachment_image($image_id, '', false) . '</li>';
												} ?>
									    	</ul>
								   	  </div><!--/gallery-->
								   	  	
								   	 <?php }	
										
									}
									
								}
								
								//Video
								else if( !empty($video_embed) && $hidden_featured_media != 'on' || !empty($video_m4v) && $hidden_featured_media != 'on' ){
									
												
									//video embed
									if( !empty( $video_embed ) ) {
										
							             echo '<div class="video">' . do_shortcode($video_embed) . '</div>';
										
							        } 
							        //self hosted video pre 3-6
							        else if( !empty($video_m4v) && floatval(get_bloginfo('version')) < "3.6") {
							        	
							        	 echo '<div class="video">'; 
							            	 nectar_video($post->ID); 
										 echo '</div>'; 
										 
							        } 
							        //self hosted video post 3-6
							        else if(floatval(get_bloginfo('version')) >= "3.6"){
						
							        	if(!empty($video_m4v) || !empty($video_ogv)) {
							        		
											$video_output = '[video ';
											
											if(!empty($video_m4v)) { $video_output .= 'mp4="'. $video_m4v .'" '; }
											if(!empty($video_ogv)) { $video_output .= 'ogv="'. $video_ogv .'"'; }
											
											$video_output .= ' poster="'.$video_poster.'" height="720" width="1280"]';
											
							        		echo '<div class="video">' . do_shortcode($video_output) . '</div>';	
							        	}
							        }
									
								}
								
								//Regular Featured Img
								else if($hidden_featured_media != 'on') {
									 
									if (has_post_thumbnail()) { 
										echo get_the_post_thumbnail($post->ID, 'full', array('title' => '')); 
									} 
									
								}
						
							}
					?>
						
						<?php
							//extra content 
							$options = get_nectar_theme_options(); 
							if(!post_password_required()) {
								
								$portfolio_extra_content = get_post_meta($post->ID, '_nectar_portfolio_extra_content', true);
								
								if(!empty($portfolio_extra_content)){
									echo '<div id="portfolio-extra">';
									
									$extra_content = shortcode_empty_paragraph_fix(apply_filters( 'the_content', $portfolio_extra_content ));
									echo do_shortcode($extra_content);
									
									echo '</div>';
								}
							} else if($fwp == 'enabled') {
								the_content(); 
							}
						
						

				        $theme_skin = (!empty($options['theme-skin']) && $options['theme-skin'] == 'ascend') ? 'ascend' : 'default';

						if(comments_open() && $theme_skin != 'ascend') { ?>
						
							<div class="comments-section">
				   			   <?php comments_template(); ?>
							</div>
						
						<?php } ?>  
						
					</div><!--/post-area-->
					
					
					<?php if($fwp != 'enabled') { ?>
					<div id="sidebar" class="col span_3 col_last" data-follow-on-scroll="<?php echo (!empty($options['portfolio_sidebar_follow']) && $options['portfolio_sidebar_follow'] == 1) ? 1 : 0; ?>">
									
						<div id="sidebar-inner">
							
							<div id="project-meta" data-sharing="<?php echo ( !empty($options['portfolio_social']) && $options['portfolio_social'] == 1 ) ? '1' : '0'; ?>">

									
									<ul class="project-sharing"> 


								<?php
									// portfolio social sharting icons
									if( !empty($options['portfolio_social']) && $options['portfolio_social'] == 1 && $project_social_style != 'fixed_bottom_right') {
										
										echo '<li class="meta-share-count"><a href="#"><i class="icon-default-style steadysets-icon-share"></i><span class="share-count-total">0</span> <span class="plural">'. __('Shares','salient') . '</span> <span class="singular">'. __('Share','salient') .'</span></a> <div class="nectar-social">';
										
										
										//facebook
										if(!empty($options['portfolio-facebook-sharing']) && $options['portfolio-facebook-sharing'] == 1) { 
											echo "<a class='facebook-share nectar-sharing' href='#' title='".__('Share this', 'salient')."'> <i class='fa fa-facebook'></i> <span class='count'></span></a>";
										}
										//twitter
										if(!empty($options['portfolio-twitter-sharing']) && $options['portfolio-twitter-sharing'] == 1) {
											echo "<a class='twitter-share nectar-sharing' href='#' title='".__('Tweet this', 'salient')."'> <i class='fa fa-twitter'></i> <span class='count'></span></a>";
										}
										//google plus
										if(!empty($options['portfolio-google-plus-sharing']) && $options['portfolio-google-plus-sharing'] == 1) {
											echo "<a class='google-plus-share nectar-sharing-alt' href='#' title='".__('Share this', 'salient')."'> <i class='fa fa-google-plus'></i> <span class='count'>0</span></a>";
										}
										
										//linkedIn
										if(!empty($options['portfolio-linkedin-sharing']) && $options['portfolio-linkedin-sharing'] == 1) {
											echo "<a class='linkedin-share nectar-sharing' href='#' title='".__('Share this', 'salient')."'> <i class='fa fa-linkedin'></i> <span class='count'> </span></a>";
										}
										//pinterest
										if(!empty($options['portfolio-pinterest-sharing']) && $options['portfolio-pinterest-sharing'] == 1) {
											echo "<a class='pinterest-share nectar-sharing' href='#' title='".__('Pin this', 'salient')."'> <i class='fa fa-pinterest'></i> <span class='count'></span></a>";
										}
										
										echo '</div></li>';

									}

									echo '<li><span class="n-shortcode">'.nectar_love('return').'</span></li>';
									

									if(!empty($options['portfolio_date']) && $options['portfolio_date'] == 1) {
									   if( empty($options['portfolio_social']) || $options['portfolio_social'] == 0 || $project_social_style == 'fixed_bottom_right' ) { ?>

											<li class="project-date">
												<?php the_time('F d, Y'); ?>
											</li>
									   <?php } 
								    
										}
									?>
								</ul><!--sharing-->

								<div class="clear"></div>
							</div><!--project-meta-->
							
							<?php the_content(); ?>
							
							
							<?php 
							$project_attrs = get_the_terms( $post->ID, 'project-attributes' );
							 if (!empty($project_attrs)){ ?>
								<ul class="project-attrs checks">
									<?php 
									foreach($project_attrs as $attr){
										echo '<li>' . $attr->name . '</li>';
									}	 
									?>
								</ul>
							<?php } ?>
						
			
						</div>
						
					</div><!--/sidebar-->
					
				<?php } 
				
				endwhile; endif; ?>
				
			</div>


			<?php if(comments_open() && $theme_skin == 'ascend') { ?>
						
				<div class="comments-section row">
	   			   <?php comments_template(); ?>
				</div>
			
			<?php } ?>  

		</div><!--/container-->

		<?php if($single_nav_pos == 'after_project' || $single_nav_pos == 'after_project_2') { 
			echo '<div class="bottom_controls"> <div class="container">';  
			project_single_controls();
			echo '</div></div>';  
		} ?>

	
	</div><!--/container-wrap-->

</div><!--/if portfolio fullwidth-->


<?php if($project_social_style == 'fixed_bottom_right') { ?>
	<div class="nectar-social-sharing-fixed"> 

		<?php
			// portfolio social sharting icons
			if( !empty($options['portfolio_social']) && $options['portfolio_social'] == 1) {
				
				echo '<a href="#"><i class="icon-default-style steadysets-icon-share"></i></a> <div class="nectar-social">';
				
				
				//facebook
				if(!empty($options['portfolio-facebook-sharing']) && $options['portfolio-facebook-sharing'] == 1) { 
					echo "<a class='facebook-share nectar-sharing' href='#' title='".__('Share this', 'salient')."'> <i class='fa fa-facebook'></i> </a>";
				}
				//twitter
				if(!empty($options['portfolio-twitter-sharing']) && $options['portfolio-twitter-sharing'] == 1) {
					echo "<a class='twitter-share nectar-sharing' href='#' title='".__('Tweet this', 'salient')."'> <i class='fa fa-twitter'></i> </a>";
				}
				//google plus
				if(!empty($options['portfolio-google-plus-sharing']) && $options['portfolio-google-plus-sharing'] == 1) {
					echo "<a class='google-plus-share nectar-sharing-alt' href='#' title='".__('Share this', 'salient')."'> <i class='fa fa-google-plus'></i> </a>";
				}
				
				//linkedIn
				if(!empty($options['portfolio-linkedin-sharing']) && $options['portfolio-linkedin-sharing'] == 1) {
					echo "<a class='linkedin-share nectar-sharing' href='#' title='".__('Share this', 'salient')."'> <i class='fa fa-linkedin'></i> </a>";
				}
				//pinterest
				if(!empty($options['portfolio-pinterest-sharing']) && $options['portfolio-pinterest-sharing'] == 1) {
					echo "<a class='pinterest-share nectar-sharing' href='#' title='".__('Pin this', 'salient')."'> <i class='fa fa-pinterest'></i> </a>";
				}
				
				echo '</div>';

			}	
			?>
		</div><!--sharing-->

	<?php } ?>

	
<?php get_footer(); ?>