<?php get_header(); ?>
	<?php
		// Check and get Sidebar Class
		$sidebar = get_post_meta($post->ID,'post-option-sidebar-template',true);
		$sidebar_class = '';
		if( $sidebar == "left-sidebar" || $sidebar == "right-sidebar"){
			$sidebar_class = "sidebar-included " . $sidebar;
		}else if( $sidebar == "both-sidebar" ){
			$sidebar_class = "both-sidebar-included";
		}

	?>
	<div class="content-wrapper <?php echo $sidebar_class; ?>"> 
		
		<?php
			$left_sidebar = get_post_meta( $post->ID , "post-option-choose-left-sidebar", true);
			$right_sidebar = get_post_meta( $post->ID , "post-option-choose-right-sidebar", true);		
			
			get_sidebar('left');			
		?>
		
		<div class='gdl-page-item'>

		<?php 
			if ( have_posts() ){
				while (have_posts()){
					the_post();

					if( get_option(THEME_SHORT_NAME.'_use_portfolio_as') == 'portfolio style' ){
						echo '<div class="sixteen columns mt0">';	
						
						echo '<div class="single-port-nav">';
						previous_post_link('<div class="single-port-prev-nav"><div class="left-arrow"></div>%link</div>');
						next_post_link('<div class="single-port-next-nav">%link<div class="right-arrow"></div></div>');
						echo '</div>';
						echo '<div class="clear"></div>';
						
						// Inside Thumbnail
						if( $sidebar == "left-sidebar" || $sidebar == "right-sidebar" ){
							$item_size = "630x250";
						}else if( $sidebar == "both-sidebar" ){
							$item_size = "450x180";
						}else{
							$item_size = "930x375";
						} 
						
						$inside_thumbnail_type = get_post_meta($post->ID, 'post-option-inside-thumbnail-types', true);
						
						switch($inside_thumbnail_type){
						
							case "Image" : 
							
								$thumbnail_id = get_post_meta($post->ID,'post-option-inside-thumbnial-image', true);
								$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
								$thumbnail_full = wp_get_attachment_image_src( $thumbnail_id , 'full' );
								if( !empty($thumbnail) ){
									echo '<div class="single-port-thumbnail-image">';
									echo '<a href="' . $thumbnail_full[0] . '" data-rel="prettyPhoto" title="' . get_the_title() . '" ><img src="' . $thumbnail[0] .'" alt=""/></a>'; 
									echo '</div>';
								}
								break;			
								
							case "Video" : 
							
								$video_link = get_post_meta($post->ID,'post-option-inside-thumbnail-video', true);
								echo '<div class="single-port-thumbnail-video">';
								echo get_video($video_link, gdl_get_width($item_size), gdl_get_height($item_size));
								echo '</div>';							
								break;
								
							case "Slider" : 
							
								$slider_xml = get_post_meta( $post->ID, 'post-option-inside-thumbnail-xml', true); 
								$slider_xml_dom = new DOMDocument();
								$slider_xml_dom->loadXML($slider_xml);
								
								echo '<div class="single-port-thumbnail-slider">';
								echo print_flex_slider($slider_xml_dom->documentElement, $item_size);
								echo '</div>';					
								break;
						}
						
						echo "<div class='clear'></div>";
						
						echo "</div>"; // sixteen-columns
						
						// Portfolio Information
						echo '<div class="four columns mt0">';
						echo '<div class="single-port-info">';
						
						$client_name = get_post_meta($post->ID, 'post-option-clients-name', true);
						if(!empty($client_name)){
							$client_head = get_option(THEME_SHORT_NAME . '_translator_client', 'Client');
							echo '<div class="single-port-client"><span class="head">' . $client_head . ':</span>' . $client_name . '</div>';
						}
						
						echo '<div class="single-port-date"><span class="head">Date:</span>';
						echo get_the_time('F d, Y') . '</div>';
						
						$portfolio_tag = get_the_term_list( $post->ID, 'portfolio-tag', '', ', ' , '' );
						if(!empty($portfolio_tag)){
						echo '<div class="single-port-tag"><span class="head">Tag:</span>';
						echo $portfolio_tag;
						echo '</div>';
						}
						
						$website_link = get_post_meta( $post->ID, 'post-option-website-url', true); 
						if(!empty($website_link)){
							$visit_site_head = $client_head = get_option(THEME_SHORT_NAME . '_translator_visit_website', 'Visit Website');
							echo '<div class="single-port-visit-website"><a href="' . $website_link . '">' . $visit_site_head . '</a></div>';
						}
						
						echo '</div>';
						echo '</div>';
						
						// Single header
						echo '<div class="twelve columns mt0">';
						echo '<div class="single-port-title post-title-color gdl-title gdl-divider">';
						echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a></div>';
						echo "<div class='single-port-content'>";
						echo the_content();
						echo "</div>";
						
						// Include Social Shares
						if(get_post_meta($post->ID, 'post-option-social-enabled', true) == "Yes"){
							echo "<div class='social-share-title gdl-link-title gdl-title'>";
							echo get_option(THEME_SHORT_NAME.'_translator_social_shares', 'Social Share');
							echo "</div>";
							include_social_shares();
							echo "<div class='clear'></div>";
						}		
						
						echo "<div class='mt30'></div>";
						echo "</div>";
						
					}else{
					
						echo '<div class="sixteen columns mt0">';	
						
						// Single header
						echo '<div class="single-thumbnail-title post-title-color gdl-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></div>';
						echo '<div class="single-thumbnail-info post-info-color gdl-divider">';
						echo '<div class="single-thumbnail-date">' . get_the_time('M d, Y') . '</div>';
						echo '<div class="single-thumbnail-author"> by ' . get_the_author_link() . '</div>';
						the_tags('<div class="single-thumbnail-tag"></div>');
						
						echo '<div class="single-thumbnail-comment">';
						comments_popup_link('0 Comment','1 Comment','% Comments','','Comments are off');
						echo '</div>';
						echo '<div class="clear"></div>';
						echo '</div>';
						
						// Inside Thumbnail
						if( $sidebar == "left-sidebar" || $sidebar == "right-sidebar" ){
							$item_size = "630x200";
						}else if( $sidebar == "both-sidebar" ){
							$item_size = "450x140";
						}else{
							$item_size = "930x300";
						} 
						
						$inside_thumbnail_type = get_post_meta($post->ID, 'post-option-inside-thumbnail-types', true);
						
						switch($inside_thumbnail_type){
						
							case "Image" : 
							
								$thumbnail_id = get_post_meta($post->ID,'post-option-inside-thumbnial-image', true);
								$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
								$thumbnail_full = wp_get_attachment_image_src( $thumbnail_id , 'full' );
								if( !empty($thumbnail) ){
									echo '<div class="blog-thumbnail-image">';
									echo '<a href="' . $thumbnail_full[0] . '" data-rel="prettyPhoto"><img src="' . $thumbnail[0] .'" alt=""/></a>'; 
									echo '</div>';
								}
								break;
								
							case "Video" : 
							
								$video_link = get_post_meta($post->ID,'post-option-inside-thumbnail-video', true);
								echo '<div class="blog-thumbnail-video">';
								echo get_video($video_link, gdl_get_width($item_size), gdl_get_height($item_size));
								echo '</div>';							
								break;
								
							case "Slider" : 
							
								$slider_xml = get_post_meta( $post->ID, 'post-option-inside-thumbnail-xml', true); 
								$slider_xml_dom = new DOMDocument();
								$slider_xml_dom->loadXML($slider_xml);
								
								echo '<div class="blog-thumbnail-slider">';
								echo print_flex_slider($slider_xml_dom->documentElement, $item_size);
								echo '</div>';					
								break;
						}
						
						echo "<div class='clear'></div>";
						
						echo "<div class='single-content'>";
						echo the_content();
						echo "</div>";
						
						// About Author
						if(get_post_meta($post->ID, 'post-option-author-info-enabled', true) == "Yes"){
							echo "<div class='about-author-wrapper'>";
							echo "<div class='about-author-avartar'>" . get_avatar( get_the_author_meta('ID'), 90 ) . "</div>";
							echo "<div class='about-author-info'>";
							echo "<div class='about-author-title gdl-link-title gdl-title'>About the author</div>";
							echo get_the_author_meta('description');
							echo "</div>";
							echo "<div class='clear'></div>";
							echo "</div>";
						}
						
						// Include Social Shares
						if(get_post_meta($post->ID, 'post-option-social-enabled', true) == "Yes"){
							echo "<div class='social-share-title gdl-link-title gdl-title'>";
							echo get_option(THEME_SHORT_NAME.'_translator_social_shares', 'Social Share');
							echo "</div>";
							include_social_shares();
							echo "<div class='clear'></div>";
						}
					
						echo '<div class="comment-wrapper">';
						comments_template(); 
						echo '</div>';
						
						echo "</div>"; // sixteen-columns					
					
					}
					
				}
			}
		?>
			
		</div> <!-- gdl-page-item -->
		
		<?php 	
			get_sidebar('right');
		?>
		
		<div class="clear"></div>
		
	</div> <!-- content-wrapper -->

<?php get_footer(); ?>