<?php echo Wo_LoadPage('forum/headers/header'); 
$section = Wo_GetForumSec(array('id' => $wo['forum_data']['forum']['sections']));
?>
<div role="tabpanel" class="tab-pane active" id="forumdisplay">
	<div class="thraed-header-content wow_thread_head">
		<div class="col-md-9 no-padding-right no-padding-left">
			<h4 class="forum_title"><?php echo($wo['forum_data']['forum']['name']) ?></h4>
			<div class="clear"></div>
			<div>
				<span><?php echo($wo['forum_data']['forum']['description']) ?></span>
			</div>
		</div>
		<div class="col-md-3 no-padding-right no-padding-left text-right">
			<span class="btn-glossy">
				<a href="<?php echo Wo_SeoLink('index.php?link1=forumsadd&fid=' . $wo['forum_data']['forum']['id']) ?>" data-ajax="?link1=forumaddthred&fid=<?php echo $wo['forum_data']['forum']['id'];?>" class="btn btn-main btn-mat btn-mat-raised"><?php echo $wo['lang']['create_new_topic']; ?></a>
			</span>
		</div>
		<div class="clear"></div>
	</div>
	
		<hr>
		<div class="w-100">
			<?php if (count($wo['forum_data']['threads']) > 0): ?>
				<table class="table threads-table">
				<thead class="wow_forum_dis_thead">
					<tr>
				        <th><?php echo $wo['lang']['topic']; ?></th>
						<th><?php echo $wo['lang']['last_post']; ?></th>
				        <th class="text-center"><?php echo $wo['lang']['replies']; ?></th>
						<th class="text-center"><?php echo $wo['lang']['views']; ?></th>
					</tr>
				</thead>
				<tbody id="forum-threads">
				    <?php foreach ($wo['forum_data']['threads'] as $wo['thread']): ?>
				    	<?php echo Wo_LoadPage("forum/includes/post-list"); ?>
				    <?php endforeach; ?>
				</tbody>
			</table>
		    <?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,22A2,2 0 0,0 20,20V4C20,2.89 19.1,2 18,2H12V9L9.5,7.5L7,9V2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18Z" /></svg>' . $wo['lang']['no_threads_found'] .  '</div>'; ?>
			<?php endif; ?>
		</div>
	    <div class="posts_load">
	        <?php if (count($wo['forum_data']['threads']) >= 10): ?>
	        <div class="load-more">
	            <button class="btn btn-default text-center pointer forum-posts-load"  >
	            <i class="fa fa-arrow-down progress-icon" data-icon="arrow-down"></i> <?php echo $wo['lang']['load_more_posts'] ?></button>
	        </div>
	        <?php endif ?>
	    </div>  
	</div>
	<div class="clear"></div>
<?php echo Wo_LoadPage('forum/headers/footer'); ?>
<script>
	$(".forum-posts-load").click(function () {
	      $.ajax({
	         url: Wo_Ajax_Requests_File(),
	         type: 'GET',
	         dataType: 'json',
	         data: {
	         	f:"forum-posts-load",
	         	forum:<?php echo $_GET['fid']; ?>,
	         	offset:($(".topic-list").length > 0) ? $(".topic-list:last").attr('data-forum') : 0,
	         },
	         success:function(data){
	            if (data['status'] == 200) {
	                $(".threads-table tbody").append(data['html'])
	             }else{
	               $(".posts_load").remove()
	             }
	         }
	      });
	   	});

	var delay = (function(){
		var timer = 0;
		return function(callback, ms){
		  clearTimeout (timer);
		  timer = setTimeout(callback, ms);
		};
	})();

	$("#search-forum-threads").keyup(function(event) {
      delay(function(){
      if ($("#search-forum-threads").val().trim()) {
	      $.ajax({
	        url: Wo_Ajax_Requests_File(),
	        type: 'GET',
	        data: {	f:"forum-thread-search",
	        		keyword:$("#search-forum-threads").val(),
	        		fid:<?php echo($wo['forum_data']['forum']['id']) ?>
	        	},
	        dataType: "json",
	        success: function(data){
	          if (data['status'] == 200) {
	          	$("#forum-threads").html(data['html']);
	          }
	          else if(data['status'] == 404){
	         	 $("#forum-threads").html('<tr> <td colspan="5" class="text-center" style="padding:40px 40px;" >' + data['html'] + '</td></tr>');
	          }
	        }
	      })}
      }, 1000 );
  	});
</script>