<? if($selfhelp != -1){ global $vis_language; global $vis_forward; 
$clear_search = isset($operation['vis_forward']) ? 'vis_quick_insert_search_clear_forward' : (($location == 0) ? 'vis_quick_insert_search_clear_new_form' : 'vis_quick_insert_search_clear');?>
<div id="article_lists">
<section class="panel panel-default pos-rlt clearfix">
	<button type="button" class="close pull-right m-r-sm m-t-xs" data-dismiss="alert" onclick="<?php echo $clear_search.'('. $location.')'; ?>">&times;</button>
	
	<div class="panel-heading b-b b-light">
	  <div class="clear">
		<div class="row">
			<div class="col-md-6">
			  <span class="pull-left m-r-sm"><label><? echo $vis_language['TXTARTICLESUGGESTIONS']; ?></label></span>
			</div>
		</div>
	  </div>
	</div>	
	<div class="panel-collapse">
		<ul class="nav text-left text-sm article_suggestion_result"> 
	<? $position = isset($operation['vis_forward']) ? 'vis_forward_attachments' : (($location == 0) ? 'vis_new_ticket_attachments' : 'vis_reply_attachments');
	if($selfhelp != -1){
	for($i=0; $i<count($selfhelp); $i++) { if($selfhelp[$i]['is_enabled'] == 1) {  ?>		
		<li>
            <a href="javascript:void(0);" onclick="show_links(<? echo $i;?>);" class="link dept_nav vis_art_list" style="outline:0;"><i class="vh vh-file-text text-black"></i> <?= $selfhelp[$i]['article_title'];?></a>		
            <span class="pull-right m-r article_linkss" id="show_links_<? echo $i;?>" style="display:none;">
            <a href="javascript:void(0);" onclick="vis_quick_insert_selfhelp_searchs(<? echo $selfhelp[$i]['article_id'].','.$location;?>);add_quick_attachments('<?= $position ?>',<?php echo $selfhelp[$i]['article_id']; ?>,<?php echo $location?>);"  class="link m-l-xs"><?= $vis_language['TXTADDARTICLE']?></a>
            <?php if($selfhelp[$i]['category_status']!=2){ ?>&nbsp;|&nbsp;
            <a href="javascript:void(0);" onclick="vis_quick_insert_article_urls(<? echo $selfhelp[$i]['article_id'].','.$location;?>);" class="link"><?= $vis_language['TXTADDURL']; ?></a>
			<?php }?>
            </span>
        </li>
        <? } } }
	else{	?>
		<li><a href="javascript:void(0);" class="dept_nav"><?= $vis_language['TXTNOMATCHFOUND'];?></a></</li>		
	<? } ?>
		</ul>
	</div>
	</div>
</section>
<script type="text/javascript">
	function show_links(i)
	{
        $(".article_linkss").css("display",'none');
		if(document.getElementById('show_links_'+i).style.display == "none")
			document.getElementById('show_links_'+i).style.display = "block";	
		else
			document.getElementById('show_links_'+i).style.display = "none";	
	}
	function add_quick_attachments(position, article_id, vis_ticketid){
		var vis_attachments	= 'vis_attachments';
		var vis_formname = '';
		if(position == 'vis_reply_attachments')
		{
			vis_formname = '#vis_ticket_post_form_'+vis_ticketid;
		}
		if(position == 'vis_forward_attachments')
		{
			vis_attachments	= 'vis_fattachments';
			vis_formname = '#vis_ticket_forward_form_'+vis_ticketid;
		}
		if(position == 'vis_new_ticket_attachments')
		{
			vis_formname = '#vis_new_ticket_form';
		}
		
		$.post( 'index.php?vis_tmpst=new Date().getTime()', { 'vis_module': 'selfhelp', 'vis_operation': 'add_quick_attachments', 'vis_article_id': article_id, 'vis_ticket_action': 1, 'vis_ticket_id': vis_ticketid, 'attachment_ids' : $(vis_formname+" "+"#"+vis_attachments).val() }, function( data ) {
				$(vis_formname+" "+"#vis_ticket_post_" + vis_ticketid).append("");
				$(vis_formname+" "+"#"+vis_attachments).val(data.vis_attachment_ids);
				$(vis_formname+" "+"#"+position).html(data.vis_attachment_html);
			}, "json");
	}
	function vis_quick_insert_selfhelp_searchs(article_id, location){		
		$.ajax({
			url: 'index.php?vis_tmpst=new Date().getTime()',
			data: { 'vis_module': "selfhelp", 'vis_operation': "add_quick_article", 'vis_as_val':1, 'vis_article_id':article_id },
			type: "POST",
			success: function(data) {			
                <? if($operation['vis_signature']==1){ ?>
				    $('#vis_ticket_post_'+location).redactor('code.set', data+'<br/>'+$('#vis_ticket_post_'+location).redactor('code.get'));
                <? }else{ ?>
                    $('#vis_ticket_post_'+location).redactor('code.set', data+'<br/>'+$('#vis_ticket_post_'+location).redactor('code.get'));
                <? } ?>
			}
		});
		//document.getElementById('article_list').style.display = "none";	
	}
	function vis_quick_insert_article_urls(article_id, location){		
		$.ajax({
			url: 'index.php?vis_tmpst=new Date().getTime()',
			data: { 'vis_module': "selfhelp", 'vis_operation': "add_quick_url", 'vis_as_val':1, 'vis_article_id':article_id },
			type: "POST",
			success: function(data) {	
                <? if($operation['vis_signature']==1){ ?>
				   $('#vis_ticket_post_'+location).redactor('code.set', data+'<br/>'+$('#vis_ticket_post_'+location).redactor('code.get'));
                <? }else{ ?>
                   $('#vis_ticket_post_'+location).redactor('code.set', data+'<br/>'+$('#vis_ticket_post_'+location).redactor('code.get'));
                <? } ?>
			}
		});
		//document.getElementById('article_list').style.display = "none";	
	}
</script>
<? } ?>
