<link href="catalog/template/beststoreitems/css/forums.css" type="text/css" rel="stylesheet">
<link href="catalog/template/beststoreitems/css/page.css" type="text/css" rel="stylesheet">
<!--left-->
<div class="sidebar">
    <?php if(is_array($forums_cate_list)){?>
    <?php foreach($forums_cate_list as $fcl){?>
    <?php if(count($fcl['child'])>0){?>
		<div class="sub_menu">
	        <h3 class="forums_title"><?php echo $fcl['cate_name']?></h3>
	        <div class="clearfix menu_list">
	            <ul>
	               <?php foreach($fcl['child'] as $f){?>
	                <li><a href="index.php?controller=forums&action=topic_category&fcid=<?php echo $f['forums_category_id']?>" ><?php echo $f['cate_name']?></a></li>
	              <?php }?>
	            </ul>
	        </div>
	    </div>
   <?php }?>
   <?php }?>
   <?php }?>              
</div>
<!--left end-->
<script>
 function search_submit(){
 	 var keyword=document.getElementById("keyword").value;
 	 var forums_category_id=document.getElementById("forums_category_id").value;	
 	 window.location="https://www.beststoreitems.com/index.php?controller=forums&action=topic_search&keyword="+keyword+"&forums_category_id="+forums_category_id;	
 }
</script>
<!--right-->
<div class="sub_right">
	<div class="clearfix for_head">
    	<p class="ptx"><b>«</b>To post a new topic, please pick one of the categories from the left.</p>
    </div>
    <div class="commentbox">
        <div class="comment_contmian">
        	<div class="comment_search comment_search2">
            	<form action="index.php?controller=forums&action=topic_search" method="post">
                	<input type="text" name="keyword" id="keyword" class="seachKey" value="<?php echo !empty($keyword)?$keyword:'Search Post...'?>" onfocus="if (this.value=='Search Post...')this.value=''" onblur="if (this.value=='')this.value='Search Post...'">
                    <select name="forums_category_id" id="forums_category_id">
                        <option value="0">All</option>
                        <?php if(is_array($forums_cate_list)){?>
                        <?php foreach($forums_cate_list as $fcl){?>
                        <?php if(count($fcl['child'])>0){?>
                        <optgroup label="<?php echo $fcl['cate_name']?>">
                           <?php foreach($fcl['child'] as $f){?>
	                          <option value="<?php echo $f['forums_category_id']?>" <?php echo $f['forums_category_id']==$forums_category_id?'selected':''?>><?php echo $f['cate_name']?></option>
	                        <?php }?>
                        </optgroup>
                        <?php }?>
                        <?php }?>
                        <?php }?>
                    </select>
                    <input type="button" value="search" class="submit_search" onclick="search_submit();">
                </form>
            </div>
            <div class="comment_didt">
                <table class="comment_table">
                    <thead>
                        <tr>
                            <th class="col_title" colspan="2">Topics</th>
                            <th class="col_views">Views</th>
                            <th class="col_replies">Replies</th>
                            <th class="col_lastpost">Last Post</th>
                        </tr>
                    </thead>
                    <tbody>          
                     <?php if(is_array($topic_data)){?>
                        <?php foreach($topic_data as $k=>$td){?>
                        <tr <?php if($k%2!=0) echo 'style="background-color: #EFEFF9;"';?>>
                            <td class="col_pic"><a href="index.php?controller=forums&action=topic_threadid&ftid=<?php echo $td['forums_topics_id']?>"><img width="19" height="22" border="0" src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/common_pic.gif"></a></td>
                            <td class="col_title">
                                <img border="0" alt="sticky" style="vertical-align:text-top" title="sticky" src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/common_pic.png">
                                <a href="index.php?controller=forums&action=topic_threadid&ftid=<?php echo $td['forums_topics_id']?>"><?php echo $td['subject']?></a><br>
                                <span class="date"><b><?php echo $td['cate_name']?></b> started by: <?php echo $td['author']?>&nbsp;on <?php echo $td['date_added']?></span>
                            </td>
                            <td class="col_views"><?php echo $td['views']?></td>
                            <td class="col_replies"><?php echo $td['reply_times']?></td>
                            <td class="col_lastpost col_lastpost_left">
                                <p><?php echo $td['last_date']?></p>
                                <p class="by_p">by <?php echo $td['last_relier']?></p>
                            </td>
                        </tr>
                      <?php }?>
                      <?php }?>   
                    </tbody>
				</table>
            </div>
            <div class="hei20"></div>
            <!--page start-->
            <div class="page_wrapper">
               <form action="<?php echo $action; ?>" method="post" name="pageform" enctype="multipart/form-data">
		        <input type="hidden" name="page" value="1" />		
			    <script type="text/javascript">		
					 function SelectPage(page)		
					 {
					    document.pageform.page.value = page;
			
					 	document.pageform.submit();
			
						return false;
			
			         };
				</script>
                 <table width="100%">
    
			            <tr><td align="left"><?php echo $text_results; ?></td>
			    
			            <td align="right">
			    
			          <table cellspacing="0" cellpadding="0" class="page">
			    
			            <tr>
			    
			            <?php if ($page>1) { ?>
			    
			            <td id="page_box_previous"><a href="#" onclick="return SelectPage(<?php echo ($page-1); ?>);"><?php echo 'Previous'?></a></td>
			    
			            <?php };
			    
			            foreach ($pages as $pageentry) {   
			    
			                    if ( $pageentry['value'] > ($page + max(9-$page,4)) ) {?>
			    
			                               <td id="page_box_next"><a href="#" onclick="return SelectPage(<?php echo ($page+1); ?>);"><?php echo 'Next'?></a></td>
			    
			                    <?php 
			    
			                         break;
			    
			                     } ;
			    
			                    
			    
			                    if ( $pageentry['value'] < ($page - 4) ) {continue; }
			    
			                    ?>
			    
			                                              
			    
			                    <?php if ($pageentry['value'] == $page) { ?>
			    
			                    <td width="20" height="16" align="center" valign="middle"><b class="current_i"><font size="1"><?php $x = explode(" ",$pageentry['text']);echo $x[0]; ?></font></b></td>
			    
			                    <?php } else { ?>
			    
			                    <td id="page_box" >
			    
			                    <a href="#" onclick="return SelectPage(<?php echo $pageentry['value']; ?>);"><?php $x = explode(" ",$pageentry['text']);echo $x[0]; ?></a></td>
			    
			                    <?php } ?>   
			    
			            <?php } ?>
			            <td>Go to Page         
			                <select onchange="return SelectPage(this.value)" style="width:50px;">
			                    <?php foreach ($pages as $pageentry){?>
			                        <option value="<?php echo $pageentry['value']?>" <?php if ($pageentry['value'] == $page){echo 'selected';}?>><?php echo $pageentry['value']?></option>
			                    <?php };?>
			                </select>
			            </td>
			          </tr></table>
			    
			    </td></tr></table>
			    </form>
            </div>
            <!--page end-->
        </div>
    </div>
    <div class="clearfix for_head">
    	<p class="ptx"><b>«</b>To post a new topic, please pick one of the categories from the left.</p>
	</div>
    <p class="tips">Please note that Forums are not a sales or product support board. For support questions, please contact us via email or live chat for a guaranteed response. We make every effort to make the quickest replies.</p>
</div>
<!--right end-->
<script type="text/javascript">
	$(document).ready(function(){
		$(".newTopic").click(function(){
			$(".accordion").slideToggle("fast",function(){
				var top = $("#forBox").offset().top;
				$("html,body").animate({ scrollTop: top }, 300);
			});
		});
	});
			
	function showDiv(){
		document.getElementById('bg').style.display='block';
		document.getElementById('reportError').style.display='block';
	}
	function closeDiv(){
		document.getElementById('bg').style.display='none';
		document.getElementById('reportError').style.display='none';
	}
</script>  