<?php
global $options;
foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
$dateformat = get_option('date_format');
$timeformat = get_option('time_format');
?>

<?php get_header(); ?>

<?php
// post custom fields 
$template = get_post_meta($post->ID, 'wpzoom_post_template', true);
$videolocation = get_post_meta($post->ID, 'wpzoom_post_embed_location', true);
$videocode = get_post_meta($post->ID, 'wpzoom_post_embed_code', true);
$skin = strtolower(get_post_meta($post->ID, 'wpzoom_post_embed_skin', true));
$video_hd = get_post_meta($post->ID, 'wpzoom_post_embed_hd', true);
unset($img); if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail() ) { // Calling Featured Image to use it as preview 
$thumbURL = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '' );
$img = $thumbURL[0];  }
else {
	unset($img);
	if ($wpzoom_cf_use == 'Yes')   {  $img = get_post_meta($post->ID, $wpzoom_cf_photo, true);   }
else  {
	if (!$img) { $img = catch_that_image($post->ID);  }
	} 
}
?>
	
<?php wp_reset_query(); if (have_posts()) : while (have_posts()) : the_post(); ?>
	
<?php if ($videolocation == 'Yes') { ?>
  
	<div class="video_big">
		<?php if (strlen($videocode) > 1) { // Do we embed a video from a website?
			$videocode = preg_replace("/(width\s*=\s*[\"\'])[0-9]+([\"\'])/i", "$1 940 $2", $videocode);
			$videocode = preg_replace("/(height\s*=\s*[\"\'])[0-9]+([\"\'])/i", "$1 518 $2", $videocode);
			$videocode = str_replace("<embed","<param name='wmode' value='transparent'></param><embed",$videocode);
			$videocode = str_replace("<embed","<embed wmode='transparent' ",$videocode); 
			echo "$videocode"; }
		elseif  (strlen($videocode) < 1) { 
			unset($videocode); $videocode = get_post_meta($post->ID, 'wpzoom_post_embed_self', true); 
			if (strlen($videocode) > 1) { // Let's embed a self-hosted video!
			?>
				<div id='video_<?php echo the_ID() ; ?>'>Video</div>
				<script type='text/javascript'>
				  jwplayer('video_<?php echo the_ID();  ?>').setup({
					'file': '<?php echo "$videocode"; ?>',
					'skin': '<?php bloginfo('template_directory'); ?>/js/skins/<?php echo "$skin/$skin.zip"; ?>',
					'image' : '<?php echo "$img"; ?>',
					'width': '920',
					'height': '518',
					<?php if (strlen($video_hd) > 1) { ?>'plugins': {
					   'hd-1': {
						   'file': '<?php echo "$video_hd"; ?>'
					   }
					}, <?php } ?>
					'modes': [
						{type: 'html5'},
						{type: 'flash', src: '<?php bloginfo('template_directory'); ?>/js/player.swf'}
					]
				  });
				</script>
			<?php } 
		} ?>
	</div>

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

<div id="main">
	<div class="wrap">
  
 		<div class="content<?php 
		  if ($template == 'Sidebar on the left') {echo " side-left";}
		  if ($template == 'Full Width (no sidebar)') {echo " full-width";} 
		  ?>">
			<div class="post">
				<h1 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
				
				<?php if (strlen($wpzoom_ad_content_imgpath) > 1 && $wpzoom_ad_content_select == 'Yes' && $wpzoom_ad_content_pos == 'Before') { echo '<div class="banner">'.stripslashes($wpzoom_ad_content_imgpath)."</div>"; }?>
				
				<?php if ($wpzoom_single_meta == 'Show') { ?>
				<div class="meta">
					<?php if ($wpzoom_singlepost_author == 'Show') { ?><span class="author"><?php the_author_posts_link(); ?></span><?php } ?>	
					<?php if ($wpzoom_singlepost_date == 'Show') { ?><span class="date"><?php the_time("$dateformat $timeformat"); ?></span><?php } ?> 
					<?php if ($wpzoom_singlepost_comm == 'Show') { ?><span class="comments"><?php comments_popup_link( __('0 comments', 'wpzoom'), __('1 comment', 'wpzoom'), __('% comments', 'wpzoom'), '', __('Comments are Disabled', 'wpzoom')); ?></span>  <?php } ?>
					<?php if ($wpzoom_singlepost_tags == 'Show') { ?><?php the_tags('<span class="tags">', ', ', '</span>'); ?> <?php } ?>

					<?php edit_post_link( __('Edit', 'wpzoom'), '<span>', '</span>'); ?>		
				</div>
				<?php } ?>
					
				<div class="entry">
					
					<?php the_content(); ?>
				
					<?php wp_link_pages(array('before' => '<p class="pages"><strong>'.__('Pages', 'wpzoom').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
					
	 
					<div class="clear"></div>
					
					<?php if (strlen($wpzoom_ad_content_imgpath) > 1 && $wpzoom_ad_content_select == 'Yes' && $wpzoom_ad_content_pos == 'After') { echo '<div class="banner">'.stripslashes($wpzoom_ad_content_imgpath)."</div>"; }?>
		  
				</div><!-- / .entry -->
				
				<div class="share_box">
					<span><?php _e('Share This:', 'wpzoom'); ?></span>
					<div class="share_btn"><g:plusone size="medium"></g:plusone></div><div class="share_btn"><a href="http://twitter.com/share" data-url="<?php the_permalink() ?>" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>
					<div class="share_btn"><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=1000&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe></div>
					<div class="clear"></div>
				</div>
				
				<div id="comments">
					<?php comments_template(); ?>  
				</div>
				
				<?php if ($wpzoom_singlepost_next == 'Show') { ?>
					<div class="prevnext">
					
					<?php
					$previous_post = get_previous_post();
					$next_post = get_next_post();
					?>
			  
						<?php if ($previous_post != NULL) { ?>
						<div class="previous">
							<a href="<?php echo get_permalink($previous_post->ID); ?>" title="<?php echo $previous_post->post_title; ?>">&larr; <?php echo $previous_post->post_title; ?></a>
							
						</div>
						<?php } ?>
						
						
						<?php if ($next_post != NULL) { ?>
						<div class="next">
							<a href="<?php echo get_permalink($next_post->ID); ?>" title="<?php echo $next_post->post_title; ?>"><?php echo $next_post->post_title; ?> &rarr;</a> 
						</div>
						<?php } ?>
					</div><!-- /.nextprev -->
				<?php } ?>	
				
				<?php endwhile; else: ?>
				<p><?php _e('Sorry, no posts matched your criteria', 'wpzoom');?>.</p>
				<?php endif; ?>

				<div class="clear"></div>          
			</div><!-- / .post -->
		 
 		<?php if ($template != 'Full Width (no sidebar)') { ?>
			<?php get_sidebar(); ?>
 		<?php } ?>
		
		</div><!-- / .content -->
 		<div class="clear"></div>
 
<?php get_footer(); ?>