
<!-- 레이어팝업 : 기시검색 -->
<section class="common_layer common_search" id="search_article">
	<div class="dim_area"></div>
	<div class="layer_box">
		<h2>컨텐츠 검색</h2>
		<button type="button" class="btn_close_layer" onclick="search_article_close();"><img src="/img/admin/btn_layer_close.gif" alt="레이어 팝업 닫기"></button>
			<fieldset>
				<p class="guide">컨텐츠를 검색해주세요.</p>
				<div class="input_box in_btn">
					<input type="text" id="article_keyword" name="article_keyword" placeholder="검색어 입력" onkeypress="if( event.keyCode==13 ){search_article();}">
					<a href="javascript:search_article();" class="btn">검색하기</a>
				</div>
				<!-- 검색결과 -->
                <div class="result" id="result"></div>
			</fieldset>
	</div>
</section>



<script type="text/javascript">
// 기사 검색
function search_article(){
	var article_keyword = $("#article_keyword").val();
	var sort = $(":input:radio[name=sort]:checked").val();
	var category1 = '';
	var category2 = '';
	var category3 = '';
	if($("#rank1").length > 0) {
		var rank1 = $("#rank1").val();
		if($("#category1_"+rank1).length > 0)	category1 = $("#category1_"+rank1).val();
		if($("#category2_"+rank1).length > 0)	category2 = $("#category2_"+rank1).val();
		if($("#category3_"+rank1).length > 0)	category3 = $("#category3_"+rank1).val();
	}

	if(article_keyword == '') {
		alert("검색어를 입력해주세요");
		return false;
	}

	var form_data = {
		"content_type"			: "<?=$content_type?>",
		"article_keyword"		: article_keyword,
		"sort"					: sort,
		"category1"				: category1,
		"category2"				: category2,
		"category3"				: category3
	};
	$.ajax({
		url: '/admin/search/search_article_list',
		async : false,
		type : 'POST',
		dataType : 'HTML',
		data : form_data,
		success: function (rtnHtml) {
			if(rtnHtml=='') return false;
			$("#result").show();
			$("#result").html(rtnHtml);
		},
		error: function(jqXHR, exception) {
			console.log(jqXHR);
		}
	});
}

function search_article_close(){
	$("#result").hide();
	commonLayerClose('search_article');
}


// 프로그램 선택
function select_article(idx, name, img, share_cnt, review_cnt, comment_cnt, hit_cnt, column_name, sub_title, head_title, editor_name, like_count, content_name, content_type, video_url, editor_idx, press_name){
	var key = $("#key").val();
	$("#title"+key).val(name);
	$("#content_idx"+key).val(idx);
	$("#content"+key).val('');

	var html = '';
	if(img!='') {
		html = '<img src="'+img+'" width="200">';
	}

	$("#img_view"+key).html(html);
	$("#img"+key).val(img);
	$("#article_keyword").val("");
	$("#result").hide();

	if($("#hit_count"+key).length > 0) 		$("#hit_count"+key).val(hit_cnt);
	if($("#share_count"+key).length > 0) 	$("#share_count"+key).val(share_cnt);
	if($("#review_count"+key).length > 0) 	$("#review_count"+key).val(review_cnt);
	if($("#comment_count"+key).length > 0) 	$("#comment_count"+key).val(comment_cnt);
	if($("#column_name"+key).length > 0) 	$("#column_name"+key).val(column_name);
	if($("#sub_title"+key).length > 0) 		$("#sub_title"+key).val(sub_title);
	if($("#head_title"+key).length > 0) 	$("#head_title"+key).val(head_title);
	if($("#editor_name"+key).length > 0) 	$("#editor_name"+key).val(editor_name);
	if($("#like_count"+key).length > 0) 	$("#like_count"+key).val(like_count);
	if($("#content_name"+key).length > 0) 	$("#content_name"+key).val(content_name);
	if($("#content_type"+key).length > 0) 	$("#content_type"+key).val(content_type);
	if($("#video_url"+key).length > 0) 		$("#video_url"+key).val(video_url);
	if($("#category3"+key).length > 0) 		$("#category3"+key).val(editor_idx).prop("selected", true);
	if($("#press_name"+key).length > 0) 	$("#press_name"+key).val(press_name);


	commonLayerClose('search_article');
}
</script>

