
<?php $__env->startSection('css'); ?>
<style type="text/css">
	.item-large{
		width:100%;
	}
</style>

<?php if(!Auth::guest() && (Auth::user()->admin == 1 || Auth::user()->id == $media->user_id)): ?>
	<link rel="stylesheet" href="<?php echo URL::asset('assets/js/tagsinput/jquery.tagsinput.css'); ?>" />
<?php endif; ?>

<?php $__env->stopSection(); ?>

<?php $settings = Setting::first(); ?>

<?php $__env->startSection('outer-content'); ?>

	<?php if(isset($settings->random_bar_enabled) && $settings->random_bar_enabled == 1): ?>
	  <?php echo $__env->make('includes.random-bar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	<?php endif; ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


<?php $item = $media; ?>

<div class="container main_home_container single">

	<div class="single-left col-md-8 col-lg-8 col-sm-12">
		
		<div class="col-sm-12 item animated single-left" data-href="<?php echo URL::to('media') . '/' . $media->id; ?>">

			<?php echo $__env->make('includes.media_item', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

			<div style="clear:both"></div>

			<?php $media_url = URL::to('media') . '/' . $item->slug; ?>
		
			<div id="below_media">
				<div class="social-icons">
				    <ul class="socialcount socialcount-large" data-url="<?php echo $media_url; ?>" style="width:100%; position:relative; right:0px">
						<li class="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $media_url; ?>" target="_blank" title="<?php echo Lang::get('social.share_facebook'); ?>"><span class="fa fa-facebook"></span><span class="count"><?php echo Lang::get('social.like'); ?></span></a></li>
						<li class="twitter" data-share-text="<?php echo $media->title; ?>"><a href="https://twitter.com/intent/tweet?url=<?php echo $media_url; ?>&text=<?php echo $media->title; ?>" data-url="<?php echo $media_url; ?>" title="<?php echo Lang::get('social.share_twitter'); ?>"><span class="fa fa-twitter" data-url="<?php echo $media_url; ?>"></span><span class="count"><?php echo Lang::get('social.tweet'); ?></span></a></li>
						<li class="googleplus"><a href="https://plus.google.com/share?url=<?php echo $media_url; ?>" target="_blank" title="<?php echo Lang::get('social.share_google'); ?>"><span class="fa fa-google-plus"></span><span class="count"><?php echo Lang::get('social.plus_one'); ?></span></a></li>
						<li class="pinterest"><a href="//www.pinterest.com/pin/create/button/?url=<?php echo $media_url; ?>&media=<?php echo URL::to('/') . '/uploads/images/' . $media->pic_url; ?>&description=<?php echo $media->title; ?>" title="<?php echo Lang::get('social.pin_it'); ?>" target="_blank"><span class="fa fa-pinterest"></span><span class="count"><?php echo Lang::get('social.pin_it'); ?></span></a></li>
					</ul>
				</div>

				<?php if(!Auth::guest()): ?>
					<?php $flagged = MediaFlag::where('user_id', '=', Auth::user()->id)->where('media_id', '=', $media->id)->first(); ?>
					<div class="media-flag pull-right border-radius <?php if(isset($flagged->id)): ?> active <?php endif; ?>" data-id="<?php echo $media->id; ?>" style="margin-top:5px;"><i class="fa fa-flag"></i> <span class="media-flag-desc"><?php if(isset($flagged->id)): ?><?php echo Lang::get('media.flagged'); ?><?php else: ?><?php echo Lang::get('media.flag_this'); ?><?php endif; ?></span></div>
				<?php endif; ?>

				<?php if(isset($item->link_url) && $item->link_url != ''): ?>
					<a href="<?php echo $item->link_url; ?>" target="_blank" class="label label-success" style="margin-top:6px;"><i class="fa fa-globe"></i> <?php echo Lang::get('common.source'); ?></a>
				<?php endif; ?>

				<?php if(!Auth::guest() && (Auth::user()->admin == 1 || Auth::user()->id == $item->user_id)): ?>
				
				<div class="edit-delete">
					<a href="#_" data-href="<?php echo URL::to('media/delete') . '/' . $item->id; ?>" onclick="confirm_delete(this)" class="label label-danger"><i class="icon-trash"></i> <?php echo Lang::get('common.delete'); ?></a>
					<a href="#_" data-toggle="modal" data-target="#edit-modal" class="label label-warning"><i class="icon-edit"></i> <?php echo Lang::get('common.edit'); ?></a>
				</div>
				<?php endif; ?>
			</div>
		

			<div style="clear:both"></div>

			<h3 class="comment-type site active" data-comments="#current_comments"><?php echo Lang::get('comments.site_comments'); ?> (<span class="current_comment_count site_comments"><?php echo $media->comments()->get()->count(); ?></span>)</h3>
			<h3 class="comment-type facebook" data-comments="#facebook_comments"><?php echo Lang::get('comments.facebook_comments'); ?> (<span class="current_comment_count"><fb:comments-count href="<?php echo Request::url(); ?>"></fb:comments-count></span>)</h3>

			<div id="facebook_comments">
				<div class="fb-comments" data-href="<?php echo Request::url(); ?>" data-numposts="5" data-colorscheme="light"></div>
			</div>

			<div id="current_comments">

				<div class="comment-submit">
					<?php if(Auth::guest()): ?>
						<h2 style="padding-left:0px; text-align:center;"><?php echo Lang::get('comments.sign_in_to_comment', array('before_signin' => '<a href="' . URL::to("signin") . '">', 'after_signin' => '</a>', 'before_signup' => '<a href="' . URL::to("signup") . '">', 'after_signup' => '</a>')); ?></h2>
					<?php else: ?>
						<h5><?php echo Lang::get('comments.add_a_comment'); ?></h5>
						<img src="<?php echo URL::to('/'); ?>/uploads/avatars/<?php echo Auth::user()->avatar; ?>" class="user-avatar-small img-rounded" style="width:8.5%; margin-right:1.5%" /><textarea placeholder="<?php echo Lang::get('comments.write_comment_here'); ?>" class="form-control" style="border-width:2px; width:90%;" id="comment"></textarea>
						<div class="btn pull-right btn-color" style="margin-top:15px;" id="comment-submit"><?php echo Lang::get('comments.post_comment_btn'); ?></div><div style="clear:both"></div>
						<input type="hidden" name="media_id" id="media_id" value="<?php echo $media->id; ?>" />
					<?php endif; ?>
				</div>
				<div style="clear:both"></div><br />
				<div class="comment-loop">
				<?php foreach($media->comments()->orderBy('created_at', 'desc')->get() as $comment): ?>

					<div class="comment comment-<?php echo $comment->id; ?>">
						
						<?php if(!Auth::guest()): ?>
							<?php $user_vote = CommentVote::where('user_id', '=', Auth::user()->id)->where('comment_id', '=', $comment->id)->first(); ?>
						<?php endif; ?>

						<div class="comment_vote pull-left">
							<i class="fa fa-chevron-up vote-up <?php if(isset($user_vote->up) && $user_vote->up): ?> active <?php endif; ?>" data-commentid="<?php echo $comment->id; ?>"></i>
							<p><?php echo $comment->totalVotes(); ?></p>
							<i class="fa fa-chevron-down vote-down <?php if(isset($user_vote->down) && $user_vote->down == 1): ?> active <?php endif; ?>" data-commentid="<?php echo $comment->id; ?>"></i>
						</div>

						<?php if(!Auth::guest()): ?>
							
							<div class="flag_edit_delete_comment">
								<a class="flag_comment" data-id="<?php echo $comment->id; ?>"><i class="fa fa-flag"></i> + <span class="num_flags"><?php echo $comment->totalFlags(); ?></span></a><?php if(Auth::user()->id == $comment->user_id  || Auth::user()->admin == 1): ?><a class="edit_comment" data-id="<?php echo $comment->id; ?>"><i class="fa fa-edit"></i></a><a class="delete_comment" data-id="<?php echo $comment->id; ?>"><i class="fa fa-trash-o"></i></a><?php endif; ?>
							</div>

						<?php endif; ?>

						<div class="comment_container border-radius" data-id="<?php echo $comment->id; ?>">
							
							<a href="<?php echo URL::to('user') . '/' . $comment->user()->username; ?>"><img src="<?php echo URL::to('/'); ?>/uploads/avatars/<?php echo $comment->user()->avatar; ?>" class="user-avatar-small img-circle" /></a>
							<div class="comment_info">
								<p class="timeago" title="<?php echo date('F j, Y, g:i a', strtotime($comment->updated_at)); ?>"><?php echo date('F j, Y, g:i a', strtotime($comment->created_at)); ?></p>
								<h4><a href="<?php echo URL::to('user') . '/' . $comment->user()->username; ?>"><?php echo $comment->user()->username; ?></a> <?php echo Lang::get('comments.wrote'); ?>:</h4>
							</div>
							<p class="comment_data"><?php echo $comment->comment; ?></p>

						</div>
					</div>

				<?php endforeach; ?>
				</div>

			</div><!-- #current_comments -->

		</div>

	</div>


	<input type="hidden" id="user_media" name="user_media" value="<?php if(!Auth::guest() && Auth::user()->id == $media->user_id): ?><?php echo 'true'; ?><?php else: ?><?php echo 'false'; ?><?php endif; ?>" />
	<input type="hidden" id="user_id" name="user_id" value="<?php if(!Auth::guest()): ?><?php echo Auth::user()->id; ?><?php else: ?>0<?php endif; ?>" />
	<?php echo $__env->make('media.show-sidebar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

</div>


<script type="text/javascript" src="<?php echo URL::asset('assets/js/imgLiquid-min.js'); ?>"></script>
<?php echo $__env->make('media.show-javascript', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('javascript'); ?>
	<?php if(!Auth::guest() && (Auth::user()->admin == 1 || Auth::user()->id == $item->user_id)): ?>
		<?php echo $__env->make('media.show-edit-media', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	<?php endif; ?>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>