<?php
/**
 * The main template file for display single post page.
 *
 * Www.20script.ir
*/
$post_type = get_post_type();

if($post_type == 'gallery')
{
	include (TEMPLATEPATH . "/gallery.php");
	exit;
}

get_header(); 

?>
		<br class="clear"/>

		<!-- Begin content -->
		<div id="content_wrapper">
			
			<div class="inner">
			
				<!-- Begin main content -->
				<div class="inner_wrapper">
				
					<div class="sidebar_content">
					
<?php

if (have_posts()) : while (have_posts()) : the_post();

?>

						<!-- Begin each blog post -->
						<div class="post_wrapper">
						
							<div class="post_header_wrapper">
					    		<div class="post_header">
					    			<h2><?php the_title(); ?></h2>
					    		</div>
					    	</div>
						
							<a href="<?php the_permalink(); ?>" class="post_comment_number"><?php comments_number('0 دیدگاه', '1 دیدگاه', '% دیدگاه'); ?></a>
					    	<div class="post_detail">
					    		<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/clock.png" class="middle"/>&nbsp;<?php echo get_the_time('j F Y'); ?>&nbsp;
					    		<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/author.png" class="middle"/>&nbsp;<?php echo _e( 'Posted by', THEMEDOMAIN ); ?> <?php echo get_the_author(); ?>
					    	</div>
					    	
					    	<br class="clear"/>
						
							<?php
							$pp_blog_single_img = get_option('pp_blog_single_img');
							if(!empty($pp_blog_single_img))
							{
							
								if(has_post_thumbnail(get_the_ID(), 'home_ft'))
								{
								    $image_id = get_post_thumbnail_id(get_the_ID());
								    $image_thumb = wp_get_attachment_image_src($image_id, 'home_ft', true);
								}
							
								if(!empty($image_thumb))
								{
							?>
							
							<div class="post_img">
								<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
									<img src="<?php echo $image_thumb[0]; ?>" alt="" class=""/>
								</a>
							</div>
							
							<?php
								}
							}
							?>
							
							<div class="post_inner_wrapper">
							
							<?php 
								$pp_enable_rating = get_option('pp_enable_rating');
								
								if(!empty($pp_enable_rating))
								{
									echo do_shortcode('[ratings id="'.get_the_ID().'"]'); 
							?>
					        	<br/><br/>
					        <?php
					        	}
					        ?>
							<br class="clear"/>
							<?php
								the_content();
							?>
							
							</div>
							
						</div>
						<!-- End each blog post -->
						
						<div class="post_wrapper">
							
						<?php
							$pp_blog_display_social = get_option('pp_blog_display_social');
							
							if(!empty($pp_blog_display_social)):
						?>
						<ul class="social_media">
							<h5>به اشتراک بگزارید</h5><br/>

							<li>
								<a target="_blank" href="http://twitter.com/home?status=<?php the_title()?> <?php the_permalink()?>" title="Retweet">
									<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/social_black/twitter.png" alt=""/>
								</a>
							</li>
							<li>
								<a target="_blank" href="http://digg.com/submit?url=<?php the_permalink()?>&title=<?php the_title()?>" title="Digg it">
									<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/social_black/digg.png" alt=""/>
								</a>
							</li>
							<li>
								<a target="_blank" href="http://www.facebook.com/share.php?u=<?php the_permalink()?>&t=<?php the_title()?>" title="social_black to Facebook">
									<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/social_black/facebook.png" alt=""/>
								</a>
							</li>
							<li>
								<a target="_blank" href="http://www.stumbleupon.com/submit?url=<?php the_permalink()?>&title=<?php the_title()?>" title="Stumbleupon">
									<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/social_black/stumbleupon.png" alt=""/>
								</a>
							</li>
							<li>
								<a target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&bkmk=<?php the_permalink()?>&title=<?php the_title()?>&annotation=" title="Google Bookmark">
									<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/social_black/google.png" alt=""/>
								</a>
							</li>
							<li>
								<a target="_blank" href="<?php bloginfo('rss_url'); ?>" title="RSS">
									<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/social_black/rss.png" alt=""/>
								</a>
							</li>
						</ul>
						<?php
							endif; ?>
						
						<?php
							$pp_blog_display_author = get_option('pp_blog_display_author');
							
							if($pp_blog_display_author)
							{
						?>
						
						<div id="about_the_author">
							<div class="thumb"><?php echo get_avatar( get_the_author_meta('email'), '50' ); ?></div>
							<div class="description">
								<h5><?php _e( 'Written by', THEMEDOMAIN ); ?> <?php the_author_link(); ?></h5>
								<?php the_author_meta('description'); ?>
							</div>
						</div><br class="clear"/>
						
						<?php
							}
						?>
						
						<?php
							$pp_blog_display_related = get_option('pp_blog_display_related');
							
							if($pp_blog_display_related)
							{
						?>
						
						<?php
						//for use in the loop, list 5 post titles related to first tag on current post
						$tags = wp_get_post_tags($post->ID);
						if ($tags) {
						  $first_tag = $tags[0]->term_id;
						  $args=array(
						    'tag__in' => array($first_tag),
						    'post__not_in' => array($post->ID),
						    'showposts'=>3,
						    'caller_get_posts'=>1
						   );
						  $my_query = new WP_Query($args);
						  if( $my_query->have_posts() ) {
						  	echo '<br class="clear"/><h5 style="font-family:BKoodakBold;">مطالب مرتبط</h5><br class="clear"/>';
						 ?>
						  
						  <div class="related_posts">
						  
						 <?php
						 	global $have_related;
						    while ($my_query->have_posts()) : $my_query->the_post();
						    $have_related = TRUE; 
						 ?>
						    <div class="each_item">
						    	<?php
						    		if(has_post_thumbnail($post->ID, 'related_post'))
									{
										$image_id = get_post_thumbnail_id($post->ID);
										$image_url = wp_get_attachment_image_src($image_id, 'related_post', true);
						    	?>
						    		<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><img src="<?php echo $image_url[0]; ?>" alt="" class="frame"/>
						    		</a><br/>
						    	<?php
						    		}
						    	?>
						    	<div class="content">
						    		<strong class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></strong>
						    		<br/>
									<span class="post_attribute"><?php echo get_the_time('F j, Y', $post->ID); ?></span>
						      	</div>
							</div>
						  <?php
								endwhile;
								    
								wp_reset_query();
						  ?>
						    </div>
						    <br class="clear"/>
						<?php
						  }
						}
						?>
						
						<?php
							} //end if show related
						?>

						<?php comments_template( '' ); ?>
						<?php comment_form(); ?>
						

<?php wp_link_pages(); endwhile; endif; ?>

						</div>

						</div>
					
					<div class="sidebar_wrapper">
						<div class="sidebar">
							
							<div class="content">
							
								<ul class="sidebar_widget">
									<?php dynamic_sidebar('Single Post Sidebar'); ?>
								</ul>
								
							</div>
						
						</div>
						<br class="clear"/>
					
						<div class="sidebar_bottom"></div>
					</div>
					
				</div>
				<!-- End main content -->
				
				<br class="clear"/>
			</div>
			
			<div class="bottom"></div>
			
		</div>
		<!-- End content -->

				

<?php get_footer(); ?>