<style>
.wow_main_float_head.moviewatch:before {
    background: url(<?php echo $wo['movie']['cover']; ?>) center center no-repeat;
    background-size: cover;
}
</style>
<div class="page-margin">
	<div class="wow_main_float_head moviewatch">
		<div class="container">
			<?php if ($wo['config']['user_ads'] == 1): ?>
				<div id="sidebar-sticky-movies">
					<?php
					  $wo['sidebar-ad'] = Wo_GetAdsByType('movies');
					  if (!empty($wo['sidebar-ad'])) {
					  	echo Wo_LoadPage('ads/includes/movies-ad');
					  }
					?>
					<div class="clear"></div>
				</div>
		    <?php endif; ?>
			<h1><?php echo $wo['movie']['name']; ?></h1>
			<ul class="breadcrumb watch-film-top-nav hidden-xs">
				<li><a href="<?php echo $wo['site_url']; ?>"> <?php echo $wo['lang']['home']; ?></a></li>
				<li><a href="<?php echo Wo_SeoLink('index.php?link1=movies') ?>"><?php echo $wo['lang']['movies']; ?></a></li>
				<li><?php echo ucfirst($wo['movie']['genre']); ?></li>
				<li class="last-bread"><?php echo ucfirst($wo['movie']['name']); ?></li>
			</ul>
			<p><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><path fill="#ffc000" d="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z" /></svg> <?php echo round($wo['movie']['rating'],1); ?> <span class="middot">·</span> <?php echo $wo['movie']['duration']; ?> min <span class="middot">·</span> <?php echo strtoupper($wo['movie']['release']); ?></p>
		</div>
		<img class="wo_wtch_mv_pcrn pcrn3" src="<?php echo $wo['config']['theme_url'];?>/img/popcorn5.svg">
		<img class="wo_wtch_mv_pcrn pcrn4" src="<?php echo $wo['config']['theme_url'];?>/img/popcorn4.svg">
	</div>

	<div class="wow_main_blogs_bg"></div>

	<div class="wow_content wow_moviecontent">
		<div class="wow_movie_infos">
			<div class="mve_thmb">
				<span class="badge" title="<?php echo $wo['lang']['quality']; ?>"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M18,14.5V11A1,1 0 0,0 17,10H16C18.24,8.39 18.76,5.27 17.15,3C15.54,0.78 12.42,0.26 10.17,1.87C9.5,2.35 8.96,3 8.6,3.73C6.25,2.28 3.17,3 1.72,5.37C0.28,7.72 1,10.8 3.36,12.25C3.57,12.37 3.78,12.5 4,12.58V21A1,1 0 0,0 5,22H17A1,1 0 0,0 18,21V17.5L22,21.5V10.5L18,14.5M13,4A2,2 0 0,1 15,6A2,2 0 0,1 13,8A2,2 0 0,1 11,6A2,2 0 0,1 13,4M6,6A2,2 0 0,1 8,8A2,2 0 0,1 6,10A2,2 0 0,1 4,8A2,2 0 0,1 6,6Z"></path></svg> <?php echo strtoupper($wo['movie']['quality']); ?></span>
				<img alt="<?php echo $wo['movie']['name']; ?>" src="<?php echo $wo['movie']['cover']; ?>">
			</div>
			<div class="mve_nfo">
				<div class="played-film-details">
					<p class="about-film"><?php echo $wo['movie']['description']; ?></p>
					<?php if (strlen($wo['movie']['description']) > 650): ?>
					<div class="slide-film-desc">
						<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg> <span><?php echo $wo['lang']['more']; ?></span>
					</div>
					<?php endif; ?>
					<ul class="list-unstyled">
						<li>
							<p>
								<span class="m-mata-tag"><?php echo $wo['lang']['stars']; ?>:</span>
								<span class="main"><?php echo $wo['movie']['stars']; ?></span>
							</p>
						</li>
						<li>
							<p>
								<span class="m-mata-tag"><?php echo $wo['lang']['genre']; ?>:</span>
								<span class="main"><?php echo strtoupper($wo['movie']['genre']); ?></span>
							</p>
						</li>
						<li>
							<p>
								<span class="m-mata-tag"><?php echo $wo['lang']['producer']; ?>:</span>
								<span class="main"><?php echo strtoupper($wo['movie']['producer']); ?></span>
							</p>
						</li>
						<li>
							<p>
								<span class="m-mata-tag"><?php echo $wo['lang']['views']; ?>:</span>
								<span class="main"><?php echo strtoupper($wo['movie']['views']); ?></span>
							</p>
						</li>
						<li>
							<p>
								<span class="m-mata-tag"><?php echo $wo['lang']['share_to']; ?>:</span>
								<span class="main share-film">
									<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $wo['movie']['url']; ?>" target="_blank">
										<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="feather feather-facebook" fill="#337ab7"><path d="M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M18,5H15.5A3.5,3.5 0 0,0 12,8.5V11H10V14H12V21H15V14H18V11H15V9A1,1 0 0,1 16,8H18V5Z"></path></svg>
									</a>
									<a href="https://twitter.com/intent/tweet?text=<?php echo $wo['movie']['url']; ?>" target="_blank">
										<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="feather feather-twitter" fill="#55acee"><path d="M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M17.71,9.33C18.19,8.93 18.75,8.45 19,7.92C18.59,8.13 18.1,8.26 17.56,8.33C18.06,7.97 18.47,7.5 18.68,6.86C18.16,7.14 17.63,7.38 16.97,7.5C15.42,5.63 11.71,7.15 12.37,9.95C9.76,9.79 8.17,8.61 6.85,7.16C6.1,8.38 6.75,10.23 7.64,10.74C7.18,10.71 6.83,10.57 6.5,10.41C6.54,11.95 7.39,12.69 8.58,13.09C8.22,13.16 7.82,13.18 7.44,13.12C7.81,14.19 8.58,14.86 9.9,15C9,15.76 7.34,16.29 6,16.08C7.15,16.81 8.46,17.39 10.28,17.31C14.69,17.11 17.64,13.95 17.71,9.33Z"></path></svg>
									</a>
								</span>
							</p>
						</li>
					</ul>
				</div>
			</div>
		</div>

		<hr>

		<div class="watch_main_movie">
			<div class="played-film-description-wrapper">
				<div>
					<div class="film-player-wrapper">
						<?php if (!empty($wo['movie']['source'])): ?>
							<div class="video-js-responsive-container vjs-hd">
								<video class="plyrr-movie" preload="auto">
									<source src="<?php echo $wo['movie']['source']; ?>" type='video/mp4'>
									<source src="<?php echo $wo['movie']['source']; ?>" type='video/webm'>
								</video>
							</div>
							<script>
								var wovideo = '.plyrr-movie';
								var players = Plyr.setup(wovideo, {
									ratio: '16:9',
									fullscreen: {
										iosNative: true
									}
								});
							</script>
						<?php elseif(!empty($wo['movie']['iframe'])): ?>
							<div class="watch_player_movie">
								<iframe src="<?php echo $wo['movie']['iframe']; ?>" frameborder="0"></iframe>
							</div>
						<?php else: ?>
							<div class="video-js-responsive-container vjs-hd">
								<video class="plyrr-movie" preload="auto">
									<source src="<?php echo $wo['movie']['video']; ?>" type='video/mp4'>
									<source src="<?php echo $wo['movie']['video']; ?>" type='video/webm'>
								</video>
							</div>
							<script>
								var wovideo = '.plyrr-movie';
								var players = Plyr.setup(wovideo, {
									ratio: '16:9',
									fullscreen: {
										iosNative: true
									}
								});
							</script>
						<?php endif; ?>
					</div>

				</div>
			</div>
			<div class="related-movies-container">
				<div class="related-movies-wrapper">
					<div class="wo_page_hdng">
						<div class="wo_page_hdng_innr">
							<span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M18,9H16V7H18M18,13H16V11H18M18,17H16V15H18M8,9H6V7H8M8,13H6V11H8M8,17H6V15H8M18,3V5H16V3H8V5H6V3H4V21H6V19H8V21H16V19H18V21H20V3H18Z"></path></svg></span> <?php echo $wo['lang']['more_like_this']; ?>
						</div>
					</div>
					<?php if (count($wo['related-films']) > 0): ?>
						<div class="related-movies-carousel hidden">
							<?php foreach ($wo['related-films'] as $wo['filmInfo']): ?>
								<?php echo Wo_LoadPage('movies/includes/related-list'); ?>
							<?php endforeach; ?>
						</div>
					<?php else: ?>
						<?php echo '<div class="empty_state"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M18,9H16V7H18M18,13H16V11H18M18,17H16V15H18M8,9H6V7H8M8,13H6V11H8M8,17H6V15H8M18,3V5H16V3H8V5H6V3H4V21H6V19H8V21H16V19H18V21H20V3H18Z" /></svg>'. $wo['lang']['no_movies_found'] .' </div>';?>
					<?php endif; ?>
				</div>
				<div class="clear"></div>

					<div class="movies-com-wrapper">
						<div class="movies-com-top">
							<div class="wo_page_hdng">
								<div class="wo_page_hdng_innr">
									<span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9Z"></path></svg></span> <?php echo Wo_GetMovieCommentsCount($wo['movie']['id']); ?> <?php echo $wo['lang']['comments']; ?>
								</div>
							</div>
						</div>
						<?php if ($wo['loggedin'] == true) { ?>
						<div class="movies-com-box">
							<form  class="form">
								<div class="w100 wo_blogcomm_combo">
									<img class="avatar" src="<?php echo $wo['user']['avatar'];?>"/>
									<textarea id="movies-comment" name="text" class="form-control" placeholder="<?php echo $wo['lang']['write_comment'];?>"></textarea>
									<button id="add-movie-comment" class="btn pull-right btn-main" type="button" data-toggle="tooltip" title="<?php echo $wo['lang']['post']; ?>">
										<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>
									</button>
								</div>
								<div class="clear"></div>
							</form>
							<div class="clear"></div>
						</div>
					<?php } ?>
						<div class="movies-comlist-container">
							<?php
								foreach (Wo_GetMovieComments(array('movie_id'=> $wo['movie']['id'])) as $wo['comment']) {
									echo Wo_LoadPage('movies/includes/comments-list');
								}
							?>
						</div>
						<?php if (count(Wo_GetMovieComments(array('movie_id'=> $wo['movie']['id']))) >= 1): ?>
							<div class="load-more">
								<button class="btn btn-default text-center pointer load-more-movie-comments">
									<i class="fa fa-arrow-down progress-icon" data-icon="arrow-down"></i> <?php echo $wo['lang']['load_more'] ?>
								</button>
							</div>
						<?php endif; ?>
					</div>
			</div>
			<div class="clear"></div>
		</div>
	</div>
</div>

<div id="fb-root"></div>
<script>
$('.wow_main_blogs_bg').css('height', ($('.wow_main_float_head').height()) + 'px');

jQuery(document).ready(function($) {
  // $('video').mediaelementplayer({
  //   pluginPath: 'https://cdnjs.com/libraries/mediaelement-plugins/',
  //   shimScriptAccess: 'always',
  //   autoplay: true,
  //   features: ['playpause', 'fullscreen', 'current', 'progress', 'duration', 'speed', 'skipback', 'jumpforward', 'tracks', 'markers', 'volume', 'chromecast', 'contextmenu', 'flash'],
  //   success: function (media) {
  //       media.addEventListener('ended', function (e) { /* pass */}, false);
  //   },
  // });

  $(".load-more-movie-comments").click(function(event) {
    var self    = $(this);
    var last_id = 0;
    if ($("div[data-movies-comment]").length > 0) {
      last_id = $("div[data-movies-comment]").last().attr('data-movies-comment');
    }
    $.ajax({
      url: Wo_Ajax_Requests_File(),
      type: 'GET',
      dataType: 'json',
      data: {
        f:'movies',
        s:'load-comments',
        offset:last_id,
        m_id:<?php echo $wo['movie']['id']; ?>
      },
    }).done(function(data) {
      if (data.status == 200) {
        $(".movies-comlist-container").append(data.html);
      }
      else if(data.status == 404){
        self.text(data.html);
      }
    }).fail(function() {
      console.log("Something went wrong. Try again later");
    })
  });


$(document).ready(function(){
  $('.related-movies-carousel').removeClass('hidden').slick({
  infinite: false,
  slidesToShow: 4,
  variableWidth: true,
  slidesToScroll: 1,
  autoplay: false,
  centerMode: false,
  autoplaySpeed: 2000,
  <?php if($wo['language_type'] == 'rtl') { ?>
  rtl: true,
  <?php } ?>
  responsive: [
    {
      breakpoint: 1024,
      settings: {
        slidesToShow: 2
      }
    },
    {
      breakpoint: 600,
      settings: {
        slidesToShow: 2
      }
    },
    {
      breakpoint: 480,
      settings: {
        slidesToShow: 1
      }
    }
  ]
  });
});

  $('.slide-film-desc').click(function(event) {
  	if ($('.about-film').hasClass('unsetheight')) {
  		$('.slide-film-desc').find('span').html('<?php echo $wo['lang']['more']; ?>');
  	}
  	else{
  		$('.slide-film-desc').find('span').html('<?php echo $wo['lang']['less']; ?>');
  	}
	$('.about-film').toggleClass('unsetheight');
  });

  $("#movies-comment").focus(function(event) {
   $(this).css('height', '80px');
  });


  $(document).on('click', ".del-movies-comment",function() {
    var  self = $(this);
    $.ajax({
      type: "GET",
      url: Wo_Ajax_Requests_File(),
      data: {
      	f:'movies',
      	id: self.attr("id"),
        s:'del-movie-comment',
      	m_id:<?php echo $wo['movie']['id']; ?>
      },
      dataType:'json',
      success: function(data) {
         if(data['status'] == 200){
            $("div[data-movies-comment='"+ self.attr('id') +"']").slideUp(function(){
              $(".movies-com-top h4 span").text(data.comments);
              $(this).remove();
            })
         }
      }
    });
  });

  $(document).on('click', ".del-movies-commreplies",function() {
    var  self = $(this);
    $.ajax({
      type: "GET",
      url: Wo_Ajax_Requests_File(),
      data: {
      	f:'movies',
      	id:self.attr("id"),
      	s:'del-movie-commreplies',
        m_id:<?php echo $wo['movie']['id']; ?>
      },
      dataType:'json',
      success: function(data) {
         if(data['status'] == 200){
            $("div[data-movies-comment-reply='"+ self.attr('id') +"']").slideUp(function(){
              var comments = Number($(".movies-com-top h4 span").text());
              $(".movies-com-top h4 span").text(comments -= 1);
              $(this).remove();
            })
         }
      }
    });
  });

  $(document).on('click', ".reply-tomoviecomm-reply",function() {
    $('.movies-comment-reply-box').each(function(index, el) {
      $(el).addClass('hidden');
    });
    var  self = $(this);
    var name  = $("div[data-movies-comment-reply='"+self.attr('id')+"']").find('a b').text();
    $("div[data-movies-comment='"+self.attr('data-movies-commId')+"']").find('.movies-comment-reply-box').removeClass('hidden').find('textarea').val(name +": ");
  });

  $(document).on('click', ".reply-tomovie-comm",function() {
    $('.movies-comment-reply-box').each(function(index, el) {
      $(el).addClass('hidden');
    });
    var  self = $(this);
    $("div[data-movies-comment='"+self.attr('id')+"']").find('.movies-comment-reply-box').toggleClass('hidden').find('textarea').val('');

  });

  $("#add-movie-comment").click(function(event) {
    $.ajax({
      url: Wo_Ajax_Requests_File() + '?f=movies&s=add-movie-comm',
      type: 'POST',
      dataType: 'json',
      data: {text:$("#movies-comment").val(),movie:<?php echo $wo['movie']['id']; ?>},
    })
    .done(function(data) {
      if (data.status == 200) {
        $("#movies-comment").val('');
        $(".movies-comlist-container").prepend(data.html);
        $(".movies-com-top h4 span").text(data.comments);
      }
    })
    .fail(function() {
      console.log("Something went wrong. Try again later");
    })
  });

});


//functions
function Wo_AddMovieCommentLike(id){
  if (!id) {
    return false;
  }
  var comment_id = id;
  Wo_Delay(function(){
    $.ajax({
      url: Wo_Ajax_Requests_File() + '?f=movies&s=add-movie-commlikes',
      type: 'POST',
      dataType: 'json',
      data: {id:comment_id,m_id:<?php echo $wo['movie']['id']; ?>},
    }).done(function(data) {
      if (data.status == 200) {
        $("span[data-movies-comlikes='"+comment_id+"']").text(data.likes);
        $("span[data-movies-comdislikes='"+comment_id+"']").text(data.dislikes);
      }
    }).fail(function() {
      console.log("Something went wrong. Try again later");
    })
  },0);
}

function Wo_AddMovieCommentDisLike(id){
  if (!id) {
    return false;
  }
  var comment_id = id;
  Wo_Delay(function(){
    $.ajax({
      url: Wo_Ajax_Requests_File() + '?f=movies&s=add-movie-commdislikes',
      type: 'POST',
      dataType: 'json',
      data: {id:comment_id,m_id:<?php echo $wo['movie']['id']; ?>},
    }).done(function(data) {
      if (data.status == 200) {
        $("span[data-movies-comlikes='"+comment_id+"']").text(data.likes);
        $("span[data-movies-comdislikes='"+comment_id+"']").text(data.dislikes);
      }
    }).fail(function() {
      console.log("Something went wrong. Try again later");
    })
  },0);
}

function Wo_AddMovieCommReplyLike(id){
  if (!id) {
    return false;
  }
  var reply_id = id;
  Wo_Delay(function(){
    $.ajax({
      url: Wo_Ajax_Requests_File() + '?f=movies&s=add-movie-crlikes',
      type: 'POST',
      dataType: 'json',
      data: {id:reply_id,m_id:<?php echo $wo['movie']['id']; ?>},
    }).done(function(data) {
      if (data.status == 200) {
        $("span[data-movies-comrlikes='"+reply_id+"']").text(data.likes);
        $("span[data-movies-comrdislikes='"+reply_id+"']").text(data.dislikes);
      }
    }).fail(function() {
      console.log("Something went wrong. Try again later");
    })
  },0);

}

function Wo_AddMovieCommReplyDisLike(id){
  if (!id) {
    return false;
  }
  var reply_id = id;
  Wo_Delay(function(){
    $.ajax({
      url: Wo_Ajax_Requests_File() + '?f=movies&s=add-movie-crdislikes',
      type: 'POST',
      dataType: 'json',
      data: {id:reply_id,m_id:<?php echo $wo['movie']['id']; ?>},
    }).done(function(data) {
      if (data.status == 200) {
        $("span[data-movies-comrlikes='"+reply_id+"']").text(data.likes);
        $("span[data-movies-comrdislikes='"+reply_id+"']").text(data.dislikes);
      }
    }).fail(function() {
      console.log("Something went wrong. Try again later");
    })
  },0);

}

function Wo_RegisterMovieCommReply(id,event,self){
  if (event.keyCode==13&&event.shiftKey==0&&event&&id&&self) {
    var text = self.value;
    if (text.length >= 2) {
      $.ajax({
        url: Wo_Ajax_Requests_File() + '?f=movies&s=add-movie-commreply',
        type: 'POST',
        dataType: 'json',
        data: {c_id:id,text:text,m_id:<?php echo $wo['movie']['id']; ?>},
      }).done(function(data) {
        if (data.status == 200) {
          $("div[data-movies-comment='"+id+"']").find('.movies-comment-reply-cont').append(data.html);
          $(".movies-com-top h4 span").text(data.comments);
          self.value = '';
        }
      }).fail(function() {
        console.log("Something went wrong. Try again later");
      })
    }
  }

}
</script>
