<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['forums_category_id']==$forums_cate_id?'id="hoved"':''?>><?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">
        	<a class="newTopic"><b>&laquo;</b>Post a new topic</a>
            <span class="mix">(in <?php echo $currently_forums_cate_info['cate_name']?>)</span>
        </p>
        <div class="min"><?php echo $currently_forums_cate_info['cate_name']?></div>
    </div>
    <div class="commentbox">
    	<h3 class="comment_title"><?php echo $currently_forums_cate_info['cate_name']?></h3>
        <div class="comment_contmian">
           <?php if(empty($product_info_data)){?>
        	<div class="comment_search">
            	<form action="index.php?controller=forums&action=topic_search" method="post">
                	<input type="text" name="keyword" id="keyword" class="seachKey" value="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['cate_name']?></option>
	                        <?php }?>
                        </optgroup>
                        <?php }?>
                        <?php }?>
                        <?php }?>
                    </select>
                    <input type="button" value="search" class="submit_search" onclick="search_submit();">
                </form>
            </div>
            <?php }else{?>
            <div class="comment_product comment_product_1">
            	<a class="commmet_pic" href="/index.php?controller=product&product_id=<?php echo $product_info_data['product_id']?>"><img src="<?php echo $product_info_data['thumb']?>"></a>
                <div class="commmet_detail">
                    <h4><a href="/index.php?controller=product&product_id=<?php echo $product_info_data['product_id']?>"><?php echo $product_info_data['name']?> </a></h4>
                    <div style="line-height:140%">
                        <p class="sales">Sales Price: <span class="price"><?php echo $product_info_data['price']?></span></p>
                        <p class="item">Item Number: <?php echo $product_info_data['product_id']?></p>
                        <p class="comment_cart">
                            <a target="_blank" href="/index.php?controller=product&product_id=<?php echo $product_info_data['product_id']?>"><img src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/topic_addtocart.gif"></a>
                            <a rel="nofollow" class="tempView" target="_blank" href="/index.php?controller=product&product_id=<?php echo $product_info_data['product_id']?>">View Product Details </a>
                        </p>
                    </div>
                </div>
            </div>
            <?php }?>
            <div class="comment_didt">
                <table class="comment_table">
                    <thead>
                        <tr>
                            <th colspan="2" class="col_title">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']?>">
	                               <?php if($td['thumb']=='0'){?>
	                                 <img width="19" height="22" border="0" src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/common_pic.gif">	                                 
	                              <?php }else{?>
	                                 <img width="30" height="30" border="0" src="<?php echo $td['thumb']?>">
	                              <?php }?>
	                            </a>
                            </td>
                            <td class="col_title">
                                <img border="0"  style="vertical-align:text-top" 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" id="forBox">
    	<p class="ptx">
        	<a class="newTopic"><b>&laquo;</b>Post a new topic</a>
        </p>
	</div>
	<script type="text/javascript">
		function check_login_form(){  			
		  var email=document.getElementById("login_email").value;		
		  var password=document.getElementById("login_password").value;		
			  if(email==''||password==''){
			  	     alert("No match for email address and/or password.");				  
			  }
              else{
			    	document.getElementById('UserLogin').submit();
			  }	
		}
		function submit_topic(){
			var subject=document.getElementById("subject").value;		
		    var content=document.getElementById("topic_content").value;		
			  if(subject==''||content==''){
			  	     alert("Subject and Message not empty");				  
			  }
              else{
			    	document.getElementById('add_topic').submit();
			  }	
		}
	</script>
	<?php if($customer_id==0){?>
    <div class="commentbox loginbox">
            <h3 class="comment_title">beststoreitems Account Sign In</h3>
            <form id="UserLogin" action="index.php?controller=account_login" method="post" onsubmit="check_login_form();return false;" enctype="multipart/form-data">
                <div class="comment_contmian login_contect">
                	<p class="intro">Please sign-in to post or reply to topic.</p>
                	<p class="eu">
                        <label class="lbleft">Email Address or Member ID:</label>
                        <input type="text" id="login_email" name="email" value="" class="lbright">
                    </p>
                    <p class="psd">
                        <label class="lbleft">Password:</label>
                        <input type="password" id="login_password" value="" name="password" class="lbright">
                    </p>
                    <input type="hidden" name="from" value="<?php echo $from?>" />	
                    <p class="login">
                        <label class="lbleft"></label>
                        <input type="submit" value="Sign in" class="signIn">
                    </p>
                    <p class="des">
                        <strong>Forgot password?</strong> 
                        Reset password to your account, <a href="">click here</a>.
                    </p>
                </div>
            </form>
    </div>
    <?php }elseif ($customer_id==1){?>
    <div class="accordion commentbox" style="display:none;">
    	<h3 class="comment_title">Post a new topic</h3>
        <div class="comment_contmian reply_content">
        	<form action="index.php?controller=forums&action=topic_category" id="add_topic" method="post" onsubmit="submit_topic();return false;">
            	<input type="hidden" name="product_id" value="<?php echo $product_id?>">
            	<input type="hidden" name="from" value="<?php echo $from?>" />	
        	    <p>Subject:</p>
                <input maxlength="50" title="Enter Subject. This is a required field" class="txt_title" value="" name="subject" id="subject">
                <div class="tips"><span style="color: #F66907;">* 50</span> characters max</div>
                <p>Message:</p>
                <div class="editbox">
                	<textarea title="Enter Message. This is a required field" class="txt_title" id="topic_content" name="content" maxlength="5000" style="height: 150px"></textarea>
                    <div class="tips"><span style="color: #F66907;">* 5000</span> characters max</div>	
                </div>
                <input type="hidden" name="forums_category_id" value="<?php echo $forums_cate_id?>" />	
                <div class="desbox">
                
                    <!--reportError begin-->
                    <div id="bg" class="bg" style="display:none;"></div>
                    <div id="reportError" class="mydiv" style="display:none;">
                            <div id="reportbox">
                                <div class="reportTitle">
                                    <h4>beststoreitems FORUM'S USAGE TERMS AND CONDITIONS</h4>
                                    <a id="close" onclick="javascript:closeDiv()">close</a>
                                </div>
                                <div id="reportMian">
                                	<div class="popContent">
                                    	<span>beststoreitems Forums are not a sales or product support board. For sales or specific product related questions, please send us a message. For after-sales support inquiries, please send us a message or submit a support incident to receive the fastest response.</span>
                                        <span>All postings not relating to product information or discussion will be forwarded to appropriate department accordingly and will be removed from our forum.</span>
                                        <span>No posting of any unsolicited advertising, promotional materials, or any other forms of solicitation. This includes any kind of references to other gadgets and/or electronics vendors, and price comparison web sites, appearing anywhere in the posts (including but not limited to subjects, contents, editorial comments and usernames).</span>
                                        <span>No pornography, obscenities, and defamatory postings are allowed anywhere on DX forum. Postings of this kind will be removed immediately, and a violation will be issued to the person responsible for the posting (several violations will result in blocking of your access to the forum).</span>
                                        <span>All users' IP will be recorded but real e-mail address is not required when posting on the forum. No usernames that contain obscene words, derogatory or racist remarks, or references to sexual acts or sexual anatomy are allowed on DX.com. Postings containing any usernames with obscene words, derogatory or racist remarks will be removed immediately.</span>
                                	</div> 
                                </div>          
                            </div>
                    </div>
                    <!--reportError end-->
                    <div class="clearfix">                        
                        <div class="popButton">
                            <input  type="submit" class="postMessage" value="Post Message">
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <?php }?>
    <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>  