<div class="fullpage-contents-wrap">
	<div class="page-container">
		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
			<div class="portfolio-contents">
				<?php if (have_posts()) : ?>
					<?php while (have_posts()) : the_post(); ?>
						
						<h1 class="entry-title"><?php the_title(); ?></h1>
						<div class="entry-content clearfix">
						<?php
						if ( !post_password_required() ) {
						the_content();
						}
						?>
						</div>
					<?php endwhile; else: ?>
				<?php endif; ?>
			</div>
<?php
if ( post_password_required() ) {
	
	echo '<div id="password-protected">';

	if (DEMO_STATUS) { echo '<p><h2>DEMO Password is 1234</h2></p>'; }
	echo get_the_password_form();
	echo '</div>';
	
	} else {
?>				
<div class="portfolio-columns-wrap clearfix">
	<ul class="portfolio-<?php echo $column_type; ?>">
		<?php
		if ($portfolio_category=="All the items") {
			query_posts( array( 'post_type' => 'mtheme_portfolio', 'orderby' => 'menu_order', 'order' => 'ASC', 'paged' => $paged , 'posts_per_page' => $portfolio_perpage) );
			} else {
			query_posts( array( 'post_type' => 'mtheme_portfolio', 'orderby' => 'menu_order', 'order' => 'ASC', 'types' => $portfolio_category , 'paged' => $paged , 'posts_per_page' => $portfolio_perpage) );
		}
		if (have_posts()) : while (have_posts()) : the_post();
		$custom = get_post_custom(get_the_ID());
		$portfolio_cats = get_the_terms( get_the_ID(), 'types' );
		$video_url="";
		$thumbnail="";
		$link_url="";
		if ( isset($custom["video"][0]) ) { $video_url=$custom["video"][0]; }
		if ( isset($custom["thumbnail"][0]) ) { $thumbnail=$custom["thumbnail"][0]; }
		if ( isset($custom["custom_link"][0]) ) { $link_url=$custom["custom_link"][0]; }
		$portfolio_thumb_header=$custom["portfolio_page_header"][0];
		
		if ($portfolio_column_count>$columns) $portfolio_column_count=1;
		$protected="";
		$iconclass="column-portfolio-icon";
		if ( post_password_required() ) { $protected=" portfolio-protected"; $iconclass=""; }
		?>
		<li class="portfolio-col-<?php echo $portfolio_column_count++; echo $protected; ?>">
			<?php
			if ( $custom["video"][0]<>"" ) {
				$p_class="fadethumbnail-play";
			} elseif ( $custom["custom_link"][0]<>"" ) {
				$p_class="fadethumbnail-link";
			} else {
				$p_class="fadethumbnail-view";
			}
			?>
				<?php
				// If Password is set
				if ($portfolio_thumb_header !="Slideshow") {
					if ( post_password_required() ) {
						echo '<a class="portfolio-image-link portfolio-columns" title="'.get_the_title().'" href="'.get_permalink().'" >';
						echo '<span class="'.$iconclass.' portfolio-image-icon"></span>';
						} else {
						// For no password protected portfolio items
						if ($portfolio_link=="Lightbox" || $custom["custom_link"][0]<>"") {
							if ( $custom["video"][0]<>"" ) {
								echo activate_lightbox (
									$lightbox_type="prettyPhoto",
									$ID=$post->ID,
									$link=$video_url,
									$mediatype="video",
									$title=$post->post_title,
									$class="portfolio-image-link portfolio-columns",
									$navigation="prettyPhoto[portfolio]"
									);
								echo '<span class="'.$iconclass.' portfolio-video-icon"></span>';
								} elseif ( $custom["custom_link"][0]<>"" ) {
									echo '<a class="portfolio-image-link portfolio-columns" title="'.get_the_title().'" href="'.$custom["custom_link"][0].'" >';
									echo '<span class="'.$iconclass.' portfolio-link-icon"></span>';
	
								} else {
								echo activate_lightbox (
									$lightbox_type="prettyPhoto",
									$ID=$post->ID,
									$link=featured_image_link($post->ID),
									$mediatype="image",
									$title=$post->post_title,
									$class="portfolio-image-link portfolio-columns",
									$navigation="prettyPhoto[portfolio]"
									);
								echo '<span class="'.$iconclass.' portfolio-image-icon"></span>';
							}
						} else {
							echo '<a class="portfolio-image-link portfolio-columns" title="'.get_the_title().'" href="'.get_permalink().'" >';
							echo '<span class="'.$iconclass.' portfolio-image-icon"></span>';
						}
					}
				}
				?>
				<?php
				// Show Image
				if ( ! post_password_required() ) {
					if ($thumbnail<>"") {
						echo '<img src="'.$thumbnail.'" class="preload-image displayed-image" alt="thumbnail" />';
					} else {
						
						if ($portfolio_thumb_header=="Slideshow") {

							$flexi_slideshow = do_shortcode('[flexislideshow lightbox=true lboxtitle=true imagesize="'.$portfolioImage_type.'"]');
							echo $flexi_slideshow;
							
						} else {
						
							echo display_post_image (
								$post->ID,
								$have_image_url="",
								$link=false,
								$type=$portfolioImage_type,
								$post_title=get_the_title(),
								$class="preload-image displayed-image"
							);
						}
					}
				}
				?>
				<?php if ($portfolio_thumb_header !="Slideshow") { ?>	
				</a>
				<?php } ?>
				<div class="work-details">
					<h4><a href="<?php if ($link_url<>"") { echo $link_url; } else { the_permalink(); } ?>" rel="bookmark" title="<?php echo get_the_title(); ?>"><?php the_title(); ?></a></h4>
					<p class="entry-content work-description"><?php echo $custom["description"][0];?></p>
				</div>
		</li>
		<?php endwhile; ?>
		<?php endif;?>
 
	</ul>
	<?php require ( MTHEME_INCLUDES . '/navigation.php' ); ?>
</div>

<?php
}
?>
	</div>
	</div>
</div>