PageSourceSearch

https://cdn.womennews.co.kr/script/common.js

js womennews.co.kr collected 2026-10-02 04:11:47 UTC 117,080 bytes, 3,228 lines download raw bytes

1/* 
22018.07.10 JS 통합작업
3
4#########################################################
5* 합쳐지는 파일
6#########################################################
71. /script/bannerpop.js			9개
82. /script/resizePhoto.js		5개
93. /script/floating.banner.js	2개
104. /script/mosaic.js			6개
115. /script/newsAutoCall.js		2개
126. /script/common.js			8개
137. /script/app.js				49개
14
15=> /script/common.js 로 통합
16##########################################################
17*/
18
19/* ****************************************** */
20/* /script/bannerpop.js						  */
21/* ****************************************** */
22
23var adWrite={
24	// php 전달 변수
25	vars:{
26		separator : "|"
27		,editId : null												// 수정할 id
28		,box : '<div class="ad-map" />'					// 생성된 박스
29		,buttons : '<div class="ad-map-btns"><div class="btn-group-vertical"><button type="button" class="btn_com btn_com_0_699 adcmb_button adcmb_modify button secondary tiny" title="수정"><i class="icon-link"></i></button><button type="button" class="btn_com btn_com_35_699 adcmb_button adcmb_delete button tiny nd-gray" title="삭제"><i class="icon-trash-o"></i></button></div></div>'		//생선된 박스의 버튼들
30		,$textBox : null
31		,act : ""												// 사진 업로드하고 이러저하게 자주 act값이 바뀌는데, 그것의 원래 값
32		,iframe : '<iframe src="about:blank" name="adc_up_frame" id="adc_up_frame" width="0" height="0" frameborder="0"></iframe>'	// upload용 iframe
33		,loadData : {}	
34	}
35
36	// 이미지 로딩되면 크기 재어오기
37	// IE만 이미지 로딩된후 이벤트가 먹어져서 크기를 제대로 재어오지 못해서 inline으로 스크립트 작성함
38	,getSizeLoadImage:function(_this)
39	{
40		var _w = _this.width
41			,_h = _this.height;
42		
43		_this.setAttribute("data-display-width", _w);
44		_this.setAttribute("data-display-height", _h);
45
46		// 이미지맵 이벤트
47		adWrite.map($(_this));
48	}
49
50	// 등록시 이벤트들
51	,evtCrtForm:function()
52	{	
53		var parents = this
54			,$type = $("#adc_crt_type_html, #adc_crt_type_file")
55			,$htmlBox = $("#adc_crt_html_box")
56			,$fileBox = $("#adc_crt_attach_file_box")
57			
58			,$popupType = $("#adc_crt_popup_type_layer, #adc_crt_popup_type_window")
59			,$layer = $("#adc_crt_popup_layer_opt_box")
60			,$window = $("#adc_crt_popup_window_opt_box")
61			
62			,$closeIcon = $("#adc_crt_popup_layer_icon")
63			,$iconBox = $("#adc_crt_popup_layer_icon_box")
64
65			,$closeExpire = $("#bottom_close_expire_label")
66			,$closeExpireBox = $("#bottom_close_expire_box")
67
68			,$attachFile = $("#adc_crt_attach_file")
69			,$previewFile = $("#adc_crt_file_image")
70			,$previewBox = $("#adc_crt_image_preview_box")
71			
72			,$max_file_size = $("#file_upload_max_size").val();
73		
74		// 입력부분 담아두기
75		this.vars.$textBox = $("#adc_crt_image_link_box");
76
77		// html, file 입력
78		$type.click(function(){
79			var isChecked = $(this).attr("value");
80
81			$htmlBox[isChecked==="HTML"?"removeClass":"addClass"]("is-hidden");
82			$fileBox[isChecked==="FILE"?"removeClass":"addClass"]("is-hidden");
83		});
84
85		// 미리보기 호출 //
86		$attachFile.change(function(){
87			var form = document.adc_form;
88
89			if (typeof (FileReader) != "undefined") {
90
91				var file = $(this)[0].files[0]
92					,regex = ['jpg', 'jpeg', 'png', 'gif', 'swf']
93					,filesize = file.size
94					,extension = file.name.split('.').pop().toLowerCase();
95
96				if(filesize > $max_file_size){
97					alert('업로드 용량이 초과되었습니다.');
98					$attachFile.val("");
99					return false;
100				}
101				
102				if((regex.indexOf(extension) > -1) === false){
103					alert('jpg, png, gif, swf 확장자만 선택하여 주세요.');
104					$attachFile.val("");
105
106					//입력시만 함정발동 예정
107					$previewBox.addClass("is-hidden");
108					return false;
109				}
110
111				if(extension == "swf"){
112					$previewBox.addClass("is-hidden");
113					return false;
114				}
115			
116				var reader = new FileReader();
117				reader.onload = function (e) {
118					var img = new Image();
119					img.src = e.target.result;
120
121					img.onload = function(){
122						$previewFile.attr({"src":e.target.result,"data-display-width":this.width, "data-display-height":this.height, "data-width":this.width, "data-height":this.height, "alt":(form.title.value)?form.title.value:form.idxno.value});
123						$previewBox.removeClass("is-hidden");
124						
125						// 이미지가 실제사이즈가 보이는 사이즈보다 크면 다시 보이는 사이즈를 넣자
126						if(this.width > $previewFile.width()) {
127							$previewFile.attr({"data-display-width":$previewFile.width(), "data-display-height":$previewFile.height()});	
128						}
129						
130						$('#size_width').val(this.width);
131						$('#size_height').val(this.height);
132		
133						$('#popup_width').val(this.width);
134						$('#popup_height').val(this.height);
135
136						// 이미지맵 이벤트
137						parents.map($previewFile);
138					}
139				}
140
141				reader.readAsDataURL(file);
142				parents.mapDeleteAll();
143			}
144		});
145
146		var $mapRadio = $("#adc_crt_image_link_total, #adc_crt_image_link_part, #adc_crt_image_link_not")
147			,$imgLinkSelect = $(".adcil_btns")
148			,$imgLink = $("#adc_crt_image_link")
149			,$imgLinkFile = $("#adc_crt_image_link_file")
150			,$selectPopup = $("#adc_crt_image_link_popup")		
151			,$btnMapRegist = $("#adc_crt_img_link_btn_regist")
152			,$linkAction = '';
153
154		// 전체 또는 이미지 맵 선택시
155		$mapRadio.click(function(){
156			var $this = $(this)		
157				,type = $this.attr("data-type");
158
159			if(type == 'total' || type == 'map'){
160				
161				//if(type == 'map') $('#link_event_tag').hide();
162                //else $('#link_event_tag').show();
163
164				$("#adc_crt_image_link_box").removeClass('is-hidden');
165
166				$btnMapRegist[type==="map"?"removeClass":"addClass"]("is-hidden");
167				
168				if(type==="total") parents.mapDeleteAll();									// 전체선택일때, 이전 데이타 모두 지움
169				
170			}else{
171				$("#adc_crt_image_link_box").addClass('is-hidden');
172			}
173		});
174
175		// layer or window 선택
176		$popupType.click(function(){
177			var isChecked = $(this).attr("data-type");
178
179			$layer[isChecked==="layer"?"removeClass":"addClass"]("is-hidden");
180			$window[isChecked==="window"?"removeClass":"addClass"]("is-hidden");
181		});
182		
183		// 닫기 아이콘 클릭시 아이콘 형태 선택 박스 열게
184		$closeIcon.click(function(){
185			var $label_attr_for = $(this).attr('for')
186				,isChecked = $('#'+$label_attr_for).is(":checked");
187
188			$iconBox[isChecked===false?"removeClass":"addClass"]("is-hidden");
189		});
190		
191		// 몇일 동안 열지 않기 입력박스 열기
192		$closeExpire.click(function(){
193			var $label_attr_for = $(this).attr('for')
194				,isChecked = $('#'+$label_attr_for).is(":checked");
195
196			$closeExpireBox[isChecked===false?"removeClass":"addClass"]("is-hidden");
197		});
198
199		// 어떤형태의 링크인지 확인
200		// link, popup, file, close, day_close
201		$imgLinkSelect.click(function(){
202			var $this = $(this)
203				,type = $this.attr("data-type");
204			
205			if(type==="popup" || type==="close" || type==="day_close"){
206				$imgLink.add($imgLinkFile).addClass("is-hidden");
207				$selectPopup[type==="popup"?"removeClass":"addClass"]("is-hidden");
208			}else{
209				$imgLink[type==="link"?"removeClass":"addClass"]("is-hidden");
210				$imgLinkFile[type==="link"?"addClass":"removeClass"]("is-hidden");
211				$selectPopup.addClass("is-hidden");
212			}
213		});
214
215		$btnMapRegist.click(function(){
216
217			// 맵 등록 수정
218			var $popupSelect = $("#adc_crt_image_link_popup_select")
219				,$linkText = $("#adcil_link_text")
220				,$etcFile = $("#adcilf_attach")
221				,$linkTarget = $(".adcil_btns_link option:selected");
222
223			if(!parents.vars.editId){
224				alert('이미지에서 수정할 맵데이타를 선택하여주세요.');
225				return false;
226			}
227
228			// close, day_close 모두 등록 눌러야 저장되게...안그럼 radio클릭만으로 이전 정보 자체를 날려버림
229			var type = $(".adcil_btns:checked").attr('data-type')
230				,url = ""
231				,target = "";
232			
233			if(!type) return false;
234			if(type==="link"){
235				url = $linkText.val();
236				if(!url){
237					alert('링크를 입력하여 주세요.');
238					$linkText.focus();
239					return false;
240				}
241				
242				target = $linkTarget.val();
243			}else if(type==="popup"){
244				url = $popupSelect.val();
245				if(!url){
246					alert('팝업을 선택하여 주세요.')
247					$popupSelect.focus();
248					return false;
249				}
250			}else if(type==="file"){
251				if(!$etcFile.val()){
252					alert('파일을 선택하여 주세요.');
253					$etcFile.focus();
254					return false;
255				}
256				
257				parents.uploadAttachTmpFile();
258				
259				return false;
260			}
261			
262			parents.insertData({
263									type:type
264									,url:url
265									,target:target
266								})
267			return false;
268		});
269	}
270	
271	// 이미지맵의 파일일때 저장 
272	,uploadAttachTmpFile:function()
273	{
274		var parents = this
275			,iframe = this.vars.iframe
276			,form = document.adc_form;
277		
278		$(document.body).append(iframe);
279		
280		form.action = "/bannerpop/upload_act.php";
281		form.target = "adc_up_frame";
282		form.submit();
283	}
284	
285	// 이미지맵의 임시파일저장후 리턴 값
286	,afterUploadAttachTmpFile:function(result)
287	{
288		// 성공이던 아니던 폼은 일단 초기화함
289		this.releaseForm();
290		$("#adc_up_frame").remove();
291
292		var json = $.parseJSON(adWrite.rawurldecode(result))
293			,filename = json[0].filename;
294
295		if(!filename){
296			alert('업로드시 에러가 발생했습니다. 다시 업로드하여 주세요.');
297			return false;
298		}
299
300		this.insertData({type:"file",url:filename,target:"self",json_obj:result});
301	}
302
303	//rawurldecode
304	,rawurldecode:function(str) {
305		return decodeURIComponent((str + '')
306			.replace(/%(?![\da-f]{2})/gi, function() {
307				return '%25';
308			}));
309	}
310
311	// 이미지맵 입력폼 초기화
312	,initInsertForm:function(data)
313	{
314		var parents = this
315			,type = data.type||"link"
316			,$btns = $(".adcil_btns")
317			,$imgLink = $("#adc_crt_image_link")
318			,$imgLinkFile = $("#adc_crt_image_link_file")
319			,$selectPopup = $("#adc_crt_image_link_popup")
320			,$filebox = $("#adcilf_uploaded_file");
321		
322		//$btns.filter("[data-type='"+type+"']").prop("checked", true);
323		$btns.filter("[data-type='"+type+"']").click(); // 커스텀 radio box 라서 이렇게 처리 
324		$filebox.hide();
325		
326		if(type==="popup" || type==="close" || type==="day_close"){
327			$imgLink.add($imgLinkFile).addClass("is-hidden");
328			$selectPopup[type==="popup"?"removeClass":"addClass"]("is-hidden");
329			
330			if(type==="popup") $("#adc_crt_image_link_popup_select").val(data.url);
331			
332		}else{			
333			$imgLink[type==="link"?"removeClass":"addClass"]("is-hidden");
334			$imgLinkFile[type==="link"?"addClass":"removeClass"]("is-hidden");
335			$selectPopup.addClass("is-hidden");
336			
337			if(type==="link"){
338				$(".adcil_btns_link option[value="+(data.target||"blank")+"]").prop("selected", true);
339				$("#adcil_link_text").val(data.url)
340			}else if(type==="file"){
341				var $attach = $("#adcilf_attach")
342					,$delBtn = $("#adcilfuf_btn")
343					,$filename = $("#adcilfuf_file")
344					,$fmode = $filename.attr('data-type');
345				
346				$attach.replaceWith($attach.clone());
347				
348				if(data.url){
349					// 파일삭제
350					$filebox.show();
351					$filename.html(data.url);
352					$delBtn.unbind("click").on("click", function(){
353						if(confirm("서버에서 파일이 바로 제거됩니다.\n그래도 삭제하시겠습니까?")) {
354						var file = data.url
355							,extension = file.split('.').pop().toLowerCase()
356							,filename = file.replace('.'+extension,'');
357
358						$.post(SITE_DOMAIN + "/bannerpop/upload_act.php"
359								,{mode:'dlt', fmode:$fmode, idxno:document.adc_form.idxno.value||"", filename:file}
360								,function(data,rst){
361									if(rst==="success"){
362										if(data.result==="success"){
363											$filename.empty();
364											$filebox.hide();
365											parents.insertData({type:"file", url:"", target:"", json_obj:""}, "no");
366											//alert(decodeURIComponent(data.msg));
367										}else alert(decodeURIComponent(data.msg));
368									}else alert('생성할 수 있는 탭 제한수를 초과하였습니다.');
369								},"json");
370						}
371					});
372				}
373			}
374		}
375	}
376	
377	// 상위폼 초기화
378	,releaseForm:function(form)
379	{
380		if(!form) form = document.adc_form;
381	
382		// 해제
383		form.action = this.vars.act;
384		form.target = "";
385	}
386	
387	// 데이타 얻어오기
388	,getHiddenData:function()
389	{
390		var $id = $("#input_"+this.vars.editId)
391			,val = $id.val().split(this.vars.separator);
392		
393		return {id:$id, val:val};
394	}
395		
396	// input type 에 넣음
397	,insertData:function(data, isInit)
398	{
399		if(!data) data={};
400		if(!this.vars.editId) return false;
401		if(!isInit) isInit = "ok";
402		
403		var $data = this.getHiddenData()
404			,$id = $data.id
405			,val = $data.val;
406		
407		if(val.length<=0) return false;
408
409		val.splice(4, 4, data.type, data.url, data.target, (data.type == 'file' && data.url) ? data.json_obj : '')
410		var value = val.join(this.vars.separator);
411		
412		$id.val(value);
413		
414		if(isInit==="ok") {
415            //$("#link_event_tag").val("")
416            this.initInsertForm({type:"link", url:"", target:"self"});
417        }
418		this.vars.editId = null;
419		
420		alert('적용되었습니다.');
421	}
422	
423	// 수정폼
424	,modifyForm:function(id)
425	{
426		if(!id) return false;
427		this.vars.editId = id;
428		
429		var $data = this.getHiddenData()
430			,val = $data.val
431			,type = val[4]||"link"
432			,url = val[5]||""
433			,target = val[6]||"self";
434
435		//이미지맵의 파일인지, 전체링크의 파일인지 구분짓기 위함
436		$("#adcilfuf_file").attr('data-type', 'M' + (Number(this.vars.editId.replace(/[^0-9]/g,'')) + 1));
437
438		this.initInsertForm({type:type, url:url, target:target});
439		this.mapBlinkArea();
440	}
441	
442	// 이미지 맵 잡기 위해 임시 저장
443	,afterUploadTmpFile:function(json)
444	{
445		var form = document.adc_form
446			,result = json.result||"error"
447			,data = json.data||""
448			,width = json.width||""
449			,height = json.height||""
450			,mime = json.mime||"";
451		
452		// 해제
453		this.releaseForm(form);
454		
455		if(result === "error"){
456			alert(data);
457			return false;
458		}
459		
460		// 나중에 폼 name으로 바꿀것!!!
461		//$("#adc_crt_popup_size_width").val(width);
462		//$("#adc_crt_popup_size_height").val(height);
463		if(form.popup_width) form.popup_width.value = width;
464		if(form.popup_height) form.popup_height.value = height;
465		
466		// 창 보이고, 이미지 미리보기 - 표시되는 사이즈 재오기
467		$("#adc_crt_image_preview_box").show();
468		$("#adc_crt_file_image").attr({"src":"data:"+mime+";base64,"+data, "data-width":width, "data-height":height});
469		
470		// 새로 올린것이니, 로딩된후 모든 이전에 저장된 맵 정보 날림
471		// 이전 데이타 삭제
472		this.mapDeleteAll();
473	}
474	
475
476	// 비율대로 좌표 계산하기
477	,mapCalcPositionRatio:function(val, ratio)
478	{
479		if(ratio === 1) return val;
480		
481		return Math.round(val * ratio);
482	}
483	
484	// 비율대로 좌표 계산하기-축소
485	,mapScalePositionRatio:function(val, ratio)
486	{
487		if(ratio === 1) return val;
488		
489		return Math.round(val / ratio);
490	}
491	
492	/**
493	 * input type="hidden" 생성
494	 * id : string
495	 * pos : object - 실제 위치
496	 * kind : string -  링크,파일 등
497	 * url : string - 링크, javascript function
498	 * target : string - 현재창,새창,부모창
499	 */
500	,mapHidden:function($form, id, pos, kind, url, target)
501	{
502		var inputId = "input_"+id
503			,val = [pos.x1, pos.y1, pos.x2, pos.y2, kind, url, target].join(this.vars.separator)
504			,input = '<input type="hidden" name="link_url[]" id="'+inputId+'" class="adc_crt_image_map_data" value="'+val+'" />';
505		
506		$form.append(input);
507	}
508	
509	// 생성된 맵 삭제
510	,mapDelete:function(id)
511	{
512		var bId = "btn_"+id
513			,inputId = "input_"+id;
514		
515		$("#"+id+",#"+bId+",#"+inputId).remove();
516		this.initInsertForm({type:"link", url:"", target:"self"});
517		alert('삭제되었습니다.');
518	}
519	
520	// 생성된 맴 전체 삭제
521	,mapDeleteAll:function()
522	{
523		$(".adc_crt_image_map_data, .ad-map, .ad-map-btns").remove();
524	}
525	
526	// 입력부분 깜빡임
527	,mapBlinkArea:function()
528	{
529		var parents = this;
530		parents.vars.$textBox.addClass("ad-map-bg");
531		setTimeout(function(){
532			parents.vars.$textBox.removeClass("ad-map-bg")
533		},500);
534	}
535
536	// 이미지 맵 잡기
537	,map:function(target)
538	{		
539		var parents = this
540			,$img = !!target.jquery ? target : $(target)
541			,width = Number($img.attr("data-width"))||0							// 실제 사이즈
542			,height = Number($img.attr("data-height"))||0
543			,dWidth = Number($img.attr("data-display-width"))||0				// 표시 사이즈
544			,dHeight = Number($img.attr("data-display-height"))||0
545			,ratio = width>dWidth ? Number((width/dWidth).toFixed(1)) : 1		// 실제 사이즈가 표시된 사이즈보다 클경우 비율 맞추기 위해
546			,box = parents.vars.box
547			,buttons = parents.vars.buttons
548			,$imgmapRadio = $("#adc_crt_image_link_part")
549			,$imgmapBtnRegist = $("#adc_crt_img_link_btn_regist")
550			,$form = $("#adc_form");
551
552					
553		return {
554			exe:function()
555			{
556				this.canvas().loadData().addEvent();
557			}
558		
559			// 덧붙이기
560			,canvas:function()
561			{
562				$img.next("#adc_crt_edit_canvas").remove().end().after('<div id="adc_crt_edit_canvas" class="ad-canvas" style="left:'+$img.position().left+'px;width:'+dWidth+'px;height:'+dHeight+'px"></div>');
563				return this;
564			}
565			
566			// 로드된 맵 데이타에 따라 그리기
567			,loadData:function()
568			{
569				var _parent = this
570					,$input = $(".adc_crt_image_map_data")
571					,$canvas = $("#adc_crt_edit_canvas");
572				
573				// 전체선택이라면
574				if($input.length<=0){
575					parents.initInsertForm(parents.vars.loadData);					
576					return this;
577				}
578				
579				//if($input.length>0) $('#link_event_tag').hide();
580				
581				// 이미지 맵 설정으로 수정
582				$imgmapRadio.not(":checked").prop("checked", true);
583				$imgmapBtnRegist.show();
584				
585				$.each($input, function(i,ele){
586					var $ele = $(ele)
587						,id = ele.id.replace("input_","")
588						,val = $ele.val().split(parents.vars.separator)||[]
589						,x1 = val[0]||0
590						,y1 = val[1]||0
591						,x2 = val[2]||0
592						,y2 = val[3]||0
593						,type = val[4]||"link"
594						,url = val[5]||""
595						,target = val[6]||"self";
596					
597					_parent.display($canvas, id, {x1:x1, y1:y1, x2:x2, y2:y2});					
598				});
599				
600				return this;
601			}
602			
603			// 영역 그림
604			,display:function($canvas, id, data)
605			{
606				if(!data) data={};
607				
608				var $box = $(parents.vars.box)
609					,$buttons = $(parents.vars.buttons)
610					,offsetGap = $canvas.position().left||0			// 절대 좌표이기에 캔바스보다 작은 이미지일경우 gap만큼 더해서 표시해줌
611					,bId = "btn_"+id
612					,x1 = (Number(parents.mapScalePositionRatio(data.x1, ratio))+offsetGap)||0
613					,y1 = parents.mapScalePositionRatio(data.y1, ratio)||0
614					,x2 = (Number(parents.mapScalePositionRatio(data.x2, ratio))+offsetGap)||0
615					,y2 = parents.mapScalePositionRatio(data.y2, ratio)||0
616					,width = Math.abs(x1-x2)
617					,height = Math.abs(y1-y2);
618			
619				// 버튼 만들기
620				$buttons.css({"top":y1+"px", "left":x2+"px"}).attr({"id":bId})
621				.find(".adcmb_button").click(function(){
622					var $this = $(this)
623						,isModify = $this.is(".adcmb_modify");
624					
625					if(isModify===true){
626						parents.modifyForm(id);
627					}else{
628						parents.mapDelete(id);
629					}
630				});
631				
632				// box 만들기
633				$box.css({"top":y1+"px", "left":x1+"px", "width":width, "height":height}).attr({"id":id});
634				
635				$canvas.after($box);
636				$box.after($buttons);
637								
638				return this;
639			}
640						
641			// event
642			,addEvent:function()
643			{
644				var _this = this
645					,position = {x:0, y:0}
646					,$box = null
647					,start = false;
648				
649				$(document.body).off("mousedown mousemove mouseup touchstart touchmove touchend","#adc_crt_edit_canvas")
650				.on({
651						"mousedown touchstart":function(event)
652						{
653							start = true;
654							
655							var $this = $(this)
656								,evt = parents.getEventObject(window.event || event)
657								,$evtTarget = $(evt.target||evt.srcElement)
658								,offsetGap = $evtTarget.position().left									// 상대위치기 때문에 값 left 값을 더해줘야 함
659								,x = Math.round(evt.offsetX||(evt.pageX-$evtTarget.offset().left))
660								,y = Math.round(evt.offsetY||(evt.pageY-$evtTarget.offset().top))
661								,id = "acem_"+new Date().getTime();
662							
663							position.x = x;
664							position.y = y;
665							
666							$box = $(box).css({"top":y, "left":x+offsetGap}).attr({"id":id})
667							$this.after($box);
668							
669							//evt.cancelBubble = true;
670							//evt.stopPropagation();
671							//evt.preventDefault();
672						}
673					
674						,"mousemove touchmove":function(event)
675						{							
676							if(start === true){
677								var evt = parents.getEventObject(window.event || event)
678									,$evtTarget = $(evt.target||evt.srcElement)
679									,offsetGap = $evtTarget.position().left									// 상대위치기 때문에 값 left 값을 더해줘야 함
680									,x = Math.round(evt.offsetX||(evt.pageX-$evtTarget.offset().left))
681									,y = Math.round(evt.offsetY||(evt.pageY-$evtTarget.offset().top))
682									//,width = Math.abs(x-position.x)-5
683									//,height = Math.abs(y-position.y)-5
684									,width = Math.abs(x-position.x)
685									,height = Math.abs(y-position.y)
686									,css = {};
687								
688								css = {"width":width, "height":height};
689								
690								if(position.x>x && position.y>y){				// 좌상
691									css.left = position.x-width+offsetGap;
692									css.top = position.y-height;
693								}else if(position.x>x && position.y<y){			// 좌하
694									css.left = position.x-width+offsetGap;						
695								}else if(position.x<x && position.y>y){			// 우상	
696									css.top = position.y-height;
697								}
698								
699								$box.css(css);
700							}
701						}
702						
703						,"mouseup touchend":function(event)
704						{							
705							start = false;
706							
707							// $box기준으로 x1,y1,x2,y2 가져옴
708							var width = $box.width()
709								,height = $box.height();
710							
711							if(width<20 && height<20){
712								$box.remove();
713								return false;
714							}
715							
716							var	$buttons = $(buttons)
717								,evt = parents.getEventObject(window.event || event)
718								,$evtTarget = $(evt.target||evt.srcElement)
719								,offsetGap = $evtTarget.position().left									// 상대위치기 때문에 값 left 값을 빼줘야지 진짜 맵이 됨
720								,pos = $box.css(["top","left"])
721								,x1 = parents.castIntFromCss(pos.left)
722								,y1 = parents.castIntFromCss(pos.top)
723								,id = $box.attr("id")
724								,bId = "btn_"+id
725								,inputId = "input_"+id
726								,info = { x1 : x1, y1 : y1, x2 : x1 + width, y2 : y1 + height }
727								,real = { x1 : parents.mapCalcPositionRatio(info.x1, ratio)-offsetGap, y1 : parents.mapCalcPositionRatio(info.y1, ratio), x2 : parents.mapCalcPositionRatio(info.x2, ratio)-offsetGap, y2 : parents.mapCalcPositionRatio(info.y2, ratio)};
728							
729							// 수정 삭제 이벤트
730							$buttons.css({"top":info.y1, "left":info.x2}).attr({"id":bId})
731							.find(".adcmb_button").click(function(){
732								var $this = $(this)
733									,isModify = $this.is(".adcmb_modify");
734
735								if(isModify===true){
736									parents.modifyForm(id);
737								}else{
738									parents.mapDelete(id);
739								}
740							});
741							
742							$box.after($buttons);
743							parents.mapHidden($form, id, real, "", "", "");
744							parents.initInsertForm({type:"link", url:"", target:"self"});									// 폼 초기화
745							parents.vars.editId = id;
746							
747							// 이미지맵으로 체크
748							$imgmapRadio.not(":checked").click().prop("checked", true);
749							$imgmapBtnRegist.show();
750							
751							parents.mapBlinkArea();																			// 글쓰기 폼 이펙트
752							
753							//util.toast(lang.adcRequireLink);
754						}
755					},"#adc_crt_edit_canvas");
756				
757				return this;
758			}
759			
760		}.exe();
761	}
762
763	// jquery 이벤트 등록 사용시, 이벤트 알아내기
764	,getEventObject:function(e)
765	{
766		var evt = window.event||e;
767			evt = evt.targetTouches?evt.targetTouches[0]:evt;  	// jquery touch event
768		return evt;
769	}
770	
771	// css px제거후 숫자형으로
772	,castIntFromCss:function(v)
773	{
774		return Number(v.replace("px",""));
775	}
776	
777	// list에서 버튼 이벤트
778	,evtClickedButtons:function()
779	{	
780		// edit
781		var edit_info = $('#admin-ad-list')
782		,edit_section = edit_info.attr("data-edit-section")	
783		,edit_area = edit_info.attr("data-edit-area")	
784		,edit_step = edit_info.attr("data-edit-step")	
785		,edit_idxno = edit_info.attr("data-edit-idxno")
786		,edit_mode = edit_info.attr("data-edit-mode")
787		,org_banner_kind = edit_info.attr("data-edit-org-banner-kind")
788		,banner_kind = edit_info.attr("data-edit-banner-kind")
789		,page = edit_info.attr("data-page")
790		//,tmp_banner_idxno = edit_info.attr("data-edit-tmp-banner-idxno")
791		,sc_area = edit_info.attr("data-search-scarea")
792		,sc_word = encodeURIComponent(edit_info.attr("data-search-scword"))
793
794		$(".ad-tile-toolkit, .content-inert").on("click", "button"
795		, function(){
796			var $this = $(this)
797				,type = $this.attr("data-btn-type")
798				,$parent = $this.closest(".adccfg_list_items")
799				,bannerIdxno = $parent.attr("data-banner-idxno")
800				,banner_type = $parent.attr("data-banner-type")
801				,linkInfo = $parent.attr("data-link-info")
802				,title = $.trim($parent.find(".acli_title").text())
803				,state = $.trim($parent.find(".ad-tile-state").text())
804				,Imgbp_Tag = $.trim($parent.find(".Imgbp_Tag").html());
805
806			switch(type){
807				case "add":
808					if(banner_type == 'popup') {
809						var data = {'mode':edit_mode,'section':edit_section,'popup_title':encodeURIComponent(title),'popup_idxno':bannerIdxno}
810						adWrite.addEditPopupContents(data);
811					}else{
812						var data = {mode:edit_mode,'idxno':edit_idxno,'area':edit_area,'section':edit_section,'step':edit_step,'banner_title':encodeURIComponent(title),'banner_idxno':bannerIdxno,'kind':banner_kind,'edit_msg':'선택한 배너로 교체하시겠습니까?'};
813						adWrite.addEditContents(data);
814					}
815					break;
816				case "down":
817					location.href = '/bannerpop/attach_down.php?idxno='+bannerIdxno+'&mode=O';
818					break;
819				case "linkInfo":					// 업로드된 파일 링크 복사					
820					var source = '/bannerpop/uploads/image/'+linkInfo;
821					adWrite.copyExe(source);
822					break;
823				case "sourceCopy":					// 소스복사
824				/*if(state == '무제한') {
825					if(!Imgbp_Tag) return false;
826					var _html = '<!--'+title+'-->'
827							  + Imgbp_Tag
828							  + '<!--//'+title+'-->';	
829				}else{*/
830					var _time = new Date().getTime()
831						,_html = '<!--'+title+'-->'
832							   + '<script type="text/javascript">var ___BANNER = "ban_'+_time+'";</script>'
833							   + '<script type="text/javascript" charset="utf-8" src="/bannerpop/uploads/js/'+bannerId
833xno+'.js?'+_time+'" id="ban_'+_time+'"></script>'
834							   + '<!--//'+title+'-->';
835				//}
836					
837					adWrite.copyExe(_html);
838				break;
839				case "preview":
840					if(!window.___popup) return false;
841					
842					var p = ___popup[bannerIdxno];
843
844					if(!p) return false;
845					if(!window.___currentTime) window.___currentTime = Math.floor(new Date().getTime()/1000);// 시간이 설정되지 않았다면 js 시간으로 설정함
846					
847					// 관리자만...										
848					$(".layer_box").remove();				// 다른게 열려있다면 삭제
849					bannerpop.vars.popup.view = "manager";
850					bannerpop.float(p);
851					break;
852				case "mdf":
853					var $ahref = '/bannerpop/';
854					$ahref += edit_section ? 'edit.html' : 'write.html';
855					$ahref += '?type='+banner_type+'&mode=modify&idxno='+bannerIdxno+'&page='+page;
856					if(edit_section) $ahref += '&edit_section=' + edit_section;
857					if(edit_area) $ahref += '&edit_area=' + edit_area;
858					if(edit_step) $ahref += '&edit_step=' + edit_step;
859					if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
860					if(edit_mode) $ahref += '&edit_mode=' + edit_mode;
861					//if(tmp_banner_idxno) $ahref += '&tmp_banner_idxno=' + tmp_banner_idxno;
862					if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
863					if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
864					if(sc_area) $ahref += '&sc_area=' + sc_area;
865					if(sc_word) $ahref += '&sc_word=' + sc_word;
866					location.href = $ahref;
867					break;
868				case "del":
869					if(window.confirm('삭제할까요?')) {	
870						var $ahref = '/bannerpop/delete_act.php?type='+banner_type+'&idxno='+bannerIdxno+'&page='+page;
871						if(edit_section) $ahref += '&edit_section=' + edit_section;
872						if(edit_area) $ahref += '&edit_area=' + edit_area;
873						if(edit_step) $ahref += '&edit_step=' + edit_step;
874						if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
875						if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
876						if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
877						if(sc_area) $ahref += '&sc_area=' + sc_area;
878						if(sc_word) $ahref += '&sc_word=' + sc_word;
879						location.href = $ahref;
880					}
881					break;
882				case "mdf_activity":
883					var $ahref = '/bannerpop/';
884					$ahref += edit_section ? 'edit.html' : 'write_activity.html';
885					$ahref += '?type='+banner_type+'&mode=modify&activity_idxno='+bannerIdxno+'&page='+page;
886					if(edit_section) $ahref += '&edit_section=' + edit_section;
887					if(edit_area) $ahref += '&edit_area=' + edit_area;
888					if(edit_step) $ahref += '&edit_step=' + edit_step;
889					if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
890					if(edit_mode) $ahref += '&edit_mode=' + edit_mode;
891					if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
892					if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
893					//if(tmp_banner_idxno) $ahref += '&tmp_banner_idxno=' + tmp_banner_idxno;
894					if(sc_area) $ahref += '&sc_area=' + sc_area;
895					if(sc_word) $ahref += '&sc_word=' + sc_word;
896					location.href = $ahref;
897					break;
898				case "del_activity":
899					if(window.confirm('삭제할까요?')) {	
900						var $ahref = '/bannerpop/delete_activity_act.php?type='+banner_type+'&activity_idxno='+bannerIdxno+'&page='+page;
901						if(edit_section) $ahref += '&edit_section=' + edit_section;
902						if(edit_area) $ahref += '&edit_area=' + edit_area;
903						if(edit_step) $ahref += '&edit_step=' + edit_step;
904						if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
905						if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
906						if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
907						if(sc_area) $ahref += '&sc_area=' + sc_area;
908						if(sc_word) $ahref += '&sc_word=' + sc_word;
909						location.href = $ahref;
910					}
911					break;				
912				case "sourceCopy_activity":					// 소스복사
913					var _time = new Date().getTime()
914					,_html = '<!--'+title+'-->'
915						   + '<script type="text/javascript">var ___BANNER = "ban_'+_time+'";</script>'
916						   + '<script type="text/javascript" charset="utf-8" src="/bannerpop/uploads/js_activity/'+bannerId
916xno+'.js?'+_time+'" id="ban_'+_time+'"></script>'
917						   + '<!--//'+title+'-->';
918					
919					adWrite.copyExe(_html);
920					break;
921                case "mdf_multi":
922                    var $ahref = '/bannerpop/';
923                    $ahref += edit_section ? 'edit.html' : 'write_activity_multi.html';
924                    $ahref += '?type='+banner_type+'&mode=modify&multi_idxno='+bannerIdxno+'&page='+page;
925                    if(edit_section) $ahref += '&edit_section=' + edit_section;
926                    if(edit_area) $ahref += '&edit_area=' + edit_area;
927                    if(edit_step) $ahref += '&edit_step=' + edit_step;
928                    if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
929                    if(edit_mode) $ahref += '&edit_mode=' + edit_mode;
930                    if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
931                    if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
932                    //if(tmp_banner_idxno) $ahref += '&tmp_banner_idxno=' + tmp_banner_idxno;
933                    if(sc_area) $ahref += '&sc_area=' + sc_area;
934                    if(sc_word) $ahref += '&sc_word=' + sc_word;
935                    location.href = $ahref;
936                    break;
937                case "del_multi":
938                    if(window.confirm('삭제할까요?')) {
939                        var $ahref = '/bannerpop/delete_activity_multi_act.php?type='+banner_type+'&multi_idxno='+bannerIdxno+'&page='+page;
940                        if(edit_section) $ahref += '&edit_section=' + edit_section;
941                        if(edit_area) $ahref += '&edit_area=' + edit_area;
942                        if(edit_step) $ahref += '&edit_step=' + edit_step;
943                        if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
944                        if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
945                        if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
946                        if(sc_area) $ahref += '&sc_area=' + sc_area;
947                        if(sc_word) $ahref += '&sc_word=' + sc_word;
948                        location.href = $ahref;
949                    }
950                    break;                
951                case "sourceCopy_multi":
952                    var _time = new Date().getTime()
953                    ,_html = '<!--'+title+'-->'
954                           + '<script type="text/javascript">var ___BANNER = "ban_'+_time+'";</script>'
955                           + '<script type="text/javascript" charset="utf-8" src="/bannerpop/uploads/js_multi/'+bannerIdxno+'.js?'+_time+'" id="ban_'+_time+'"></script>'
956                           + '<!--//'+title+'-->';
957                    adWrite.copyExe(_html);
958                    break;
959			}
960
961			return false;
962		});
963	}
964
965	//수정시 섹션판 컨텐츠 삽입
966	,addEditContents:function(data)
967	{			
968		//var flag = false;
969		var flag = true;
970
971		/*if(data.mode == 'modify') {
972			if(data.tmp_banner_idxno != data.banner_idxno) {
973				if(confirm(data.edit_msg)) flag = true;
974				else flag = false;
975			}else flag = true;
976		}else flag = true;*/
977
978		if(flag) { 			
979			data = JSON.stringify(data);
980			$.ajax({
981				url:"/edit/adminReservationBannerWrite.php"
982				,type:'post'
983				,dataType:'json'
984				,contentType:'application/x-www-form-urlencoded; charset=utf-8'
985				,data:{post_data:data}
986				,success:function(json, result) {
987					if(result == 'success') {
988						if(json.response == 'ok') { 
989							window.parent.location.reload();
990						}else{
991							alert(json.msg);
992							return false;
993						}
994					}else return false;
995				}
996			});
997		}else{
998			return false;
999		}
1000	}
1001
1002	//수정시 섹션판 컨텐츠 삽입
1003	,addEditPopupContents:function(data)
1004	{					
1005		data = JSON.stringify(data);
1006		$.ajax({
1007			url:"/edit/adminReservationPopupWrite.php"
1008			,type:'post'
1009			,dataType:'json'
1010			,contentType:'application/x-www-form-urlencoded; charset=utf-8'
1011			,data:{post_data:data}
1012			,success:function(json, result) {
1013				if(result == 'success') {
1014					if(json.response == 'ok') {
1015						//window.parent.location.reload();
1016						parent.$('#edit-modal').find('.close-button').trigger('click');
1017						adWrite.addPopupContentsList(json);
1018					}else{
1019						alert(json.msg);
1020						return false;
1021					}
1022				}else return false;
1023			}
1024		});
1025	}
1026
1027	,addPopupContentsList:function(json) {
1028		var html = '';
1029		if(json.rows.length>0) {
1030			for(var i = 0; i < json.rows.length; i++) {
1031				var index = i+1;
1032				html += '<!-- 팝업 //-->';
1033				html += '<div class="option-popup-item">';
1034				html += '	<input type="radio" name="editPopup" id="editPopup' + index + '" class="popup_element_ckecked" title="' + adWrite.rawurldecode(json.rows[i].popup_title) + '" data-idxno="' + json.rows[i].idxno + '" data-step="' + json.rows[i].step + '" value="' + json.rows[i].popup_idxno + '" />';
1035				html += '	<label for="editPopup' + index + '">';
1036				if(json.rows[i].popup_image && json.rows[i].extension != 'swf') {
1037					html += '<img src="/bannerpop/uploads/image/' + json.rows[i].popup_image + '" alt="' + adWrite.rawurldecode(json.rows[i].popup_title) + '" />';
1038				}else{
1039					if(json.rows[i].extension == 'swf') html += 'SWF';
1040					else html += 'HTML';
1041				}
1042				html += '		<div class="option-popup-item-title">' + adWrite.rawurldecode(json.rows[i].popup_title) + '</div>';
1043				html += '	</label>';
1044				html += '</div>';
1045				html += '<!--// 팝업 -->';
1046			}
1047		}
1048
1049		parent.$('.option-popup-group').html(html);
1050	}
1051
1052	//전체선택ㆍ해제
1053	,allChk:function()
1054	{	
1055		var $allChk = $('#allCheck');
1056		$allChk.click(function(){
1057			if($(this).is(':checked') == true) {
1058				$('.elembox').prop('checked',true);
1059			}else{
1060				$('.elembox').prop('checked',false);
1061			}
1062		});
1063	}
1064
1065	/**
1066	 * 클립보드 복사 
1067	 * source : 복사할 정보
1068	 */
1069	,copyExe:function(source)
1070	{
1071		if(window.clipboardData){			// ie
1072			window.clipboardData.setData('Text',source);
1073			alert("복사되었습니다. 원하는 곳에 붙여넣기하여 주세요.");
1074		}else{								// etc
1075			//var $tmpDiv=$('<div class="blind">'+source.replace(/</g,"&lt;").replace(/>/g,"&gt;")+'</div>').appendTo("body")
1076			// blind가 display:none 속성 때문에 제거
1077			var $tmpDiv=$('<div>'+source.replace(/</g,"&lt;").replace(/>/g,"&gt;")+'</div>').appendTo("body")
1078				,range=document.createRange()
1079				,selection=null;
1080
1081			range.selectNodeContents($tmpDiv.get(0));
1082			selection=window.getSelection();
1083			selection.removeAllRanges();
1084			selection.addRange(range);
1085			
1086			if(document.execCommand("copy", false, null)) alert("복사되었습니다. 원하는 곳에 붙여넣기하여 주세요.");
1087			else window.prompt('키보드의 ctrl+C 또는 마우스 오른쪽의 복사하기를 이용해주세요.', source);
1088
1089			$tmpDiv.remove();
1090		}
1091	}
1092
1093	/**
1094	 * 기능성 배너 추가/순서변경/삭제/
1095	 */
1096	 ,evtClickActivityAdd:function() {
1097		//sessionStorage.removeItem("last_idx");
1098		var activity_idxno=window.parent.$('#all-banner-list').closest('div').attr('data-activity-idxno')||'';
1099		$('#activity-add-btn').click(function() {
1100			var $this=$(this);
1101				//,$viewHref=$('#activity-view-btn').attr('href')
1102				//,$last_idx=(activity_idxno)?activity_idxno:sessionStorage.getItem('last_idx');
1103			
1104			if($('.banner_element_ckecked').is(':checked') == false) {
1105				alert('배너를 선택해주세요.');
1106				//if(!$last_idx) $('#activity-view-btn').addClass('is-hidden');
1107				return false;
1108			}else{
1109				var $checked=$(".banner_element_ckecked:checked")
1110					,arr = new Array();
1111				if($checked.length>0) {
1112					$.each($checked, function(idx, v) {
1113						arr.push(v.value);
1114					});
1115
1116					var data = {mode:activity_idxno?'modify':'input', activity_idxno:activity_idxno, banner_idxno:arr};
1117					data = JSON.stringify(data);
1118					//console.log(data);
1119					$.ajax({
1120						url:"/bannerpop/activity_act.php"
1121						,type:'post'
1122						,dataType:'json'
1123						,contentType:'application/x-www-form-urlencoded; charset=utf-8'
1124						,data:{post_data:data}
1125						,success:function(json, result) {
1126							if(result == 'success') {
1127								if(json.response == 'ok') {
1128									//alert('추가되었습니다.\n우측에 버튼을 클릭하시면 상세 화면으로 이동합니다.');
1129									/*if(!activity_idxno) {
1130										sessionStorage.setItem('last_idx', json.last_insert_id);
1131										$('#activity-view-btn').attr('href', $viewHref + '&activity_idxno='+json.last_insert_id);
1132									}
1133									$('#activity-view-btn').removeClass('is-hidden');*/
1134									window.parent.location.reload();
1135								}else{
1136									//alert(json.msg);
1137									return false;
1138								}
1139							}else return false;
1140						},
1141     error:function(request,status,error){
1142        alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
1143       }
1144					});
1145				}
1146			}
1147		});
1148
1149		$('#banner-activity-box').sortable({
1150			axis: '',
1151			update: function() {
1152				//console.log($(this));
1153			}
1154		});
1155
1156		$('.trash').click(function() {
1157			if($('.banner-activity-list').length <= 1) {
1158				alert('마지막 배너는 삭제 할 수 없습니다.');
1159				return false;
1160			}
1161
1162			var $this=$(this)
1163			,$parent = $this.closest('.banner-activity-list');
1164
1165			$parent.fadeOut('fast', function(){
1166				$parent.remove();	
1167			});
1168		});
1169
1170		$('#all-banner-list').on('click', function(e) {
1171
1172			$this = $(this);
1173			href = $this.attr('href');
1174
1175			$("#edit-modal-iframe").attr("src", href);
1176			$('#edit-modal').foundation('open');
1177
1178			return false;
1179		});
1180
1181		$('#edit-modal').on('open.zf.reveal', function(e){
1182			$('#for-loading').show();
1183		});
1184
1185		$('#edit-modal').on('closed.zf.reveal', function(e){
1186			$("#edit-modal-iframe").attr("src", "about:blank").height('0px').closest('#activity-modal').css('height', '0px');
1187		});
1188	 }
1189
1190	 ,valid_activity:function() {
1191		if($('#activity_title').val() == '') {
1192			alert('제목을 입력하세요.');
1193			$('#activity_title').focus();
1194			return false;
1195		}
1196
1197		if($('.banner-activity-list').length<=0) {
1198			alert('배너를 하나 이상 추가하셔야 합니다.');
1199			return false;
1200		}
1201
1202		return true;
1203	 }
1204
1205}; // end adWrite 
1206
1207
1208/*****************************************************************************
1209*게시판 이미지 위치 적용
1210*****************************************************************************/
1211var bbsFreeImg = {
1212
1213    set:function(){
1214        $("input[name^=uploadFile]").each(function(i){
1215            var img_num = i+1;
1216            if($(this).siblings(".insert-img").length == 0){
1217                $(this).after('<div class="insert-img dis-none" id="insert-img'+img_num+'"><div class="insert-btn">본문삽입</div></div>');
1218                $(this).closest("div").addClass("insert-img-wrap");
1219            }
1220        });
1221
1222        //미리보기 적용
1223        $("input[name^=uploadFile]").on("change", function(){
1224            bbsFreeImg.thumbnailView(event, $(this).closest(".insert-img-wrap").data("image-num"));
1225        });
1226
1227        // 이미지 본문 삽입
1228        $(".insert-img").on('click', function(){
1229            InsertHTML('<div style="text-align:center"><figure class="image img_'+$(this).closest(".insert-img-wrap").data("image-num")+'"><img alt="'+$(this).data("image-name")+'" src="'+$(this).find('img').attr('src')+'"><figcaption>&nbsp;</figcaption></figure></div><p>&nbsp;</p>');
1230        });
1231    },
1232
1233    thumbnailView:function(event, image_num) {
1234        var ckeditor = CKEDITOR.instances.content;
1235
1236        var reader = new FileReader();
1237        var img_file = event.target.files[0];
1238
1239        var img_obj = $("#insert-img"+image_num+" img");
1240        var insert_img_num = $("#insert-img"+image_num);
1241
1242        var figure_regex = new RegExp('<figure class="image img_'+image_num+'.*?>.*?<\/figure>', 'sg');
1243
1244        if (img_file && img_file.type.match('image.*')) {
1245            reader.readAsDataURL(img_file);
1246            reader.onload = function(event) {
1247                var img_src = event.target.result;
1248
1249                if(img_obj.length > 0) img_obj.attr("src", img_src);
1250                else {
1251                    var img = document.createElement("img");
1252                    img.setAttribute("src", img_src);
1253
1254                    insert_img_num.append(img);
1255                }
1256
1257                insert_img_num.attr("data-image-name", img_file.name).removeClass("dis-none");
1258                                
1259                                //변경된 이미지로 치환
1260                if(figure_regex.test(ckeditor.getData())){
1261                    ckeditor.setData(ckeditor.getData().replaceAll(figure_regex, '<figure class="image img_'+image_num+'"><img alt="'+img_file.name+'" src="'+img_src+'"><figcaption>&nbsp;</figcaption></figure>'));
1262                }
1263            };
1264        } else {
1265            //본문 이미지 제거
1266            ckeditor.setData(ckeditor.getData().replaceAll(figure_regex, '').replace(/<div.*?[\r|\n]*<\/div>/, ''));
1267            insert_img_num.addClass("dis-none").find("img").remove();
1268        }
1269    }
1270}
1271
1272var bannerpop={
1273	vars:{
1274		popup:{
1275			bodyWidth:0
1276			,bodyLeft:0
1277			,screenWidth:0
1278			,popname:"popup_"
1279			,width:{ window:[],layer:[] }
1280			,height:{ window:[],layer:[] }
1281			,top:{ window:[],layer:[] }
1282			,left:{ window:[],layer:[] }
1283			,order:0						// z-index용 순차적
1284			,view:"normal"					// 일반 : normal or 관리자 : manager
1285		}
1286		,isMobileMode:false
1287	}
1288
1289	/**
1290	 * 배너 효과
1291	 * 태그 작성 예::: bannerpop.banner(".banner_event_box");
1292	 <div class="boder_box banner_event_box" data-type="slide" data-idxno="3" data-speed="0.3">		
1293		<div class="boder_box beb_box">
1294			<ul class="no_type beb_ul">
1295				<li class="beb_li" data-delay="1"><a href=""><img src="http://sample.ndsoftnews.com/template_sian/download.php?idxno=856&file_extension=jpg&filename=Untitled-1.jpg" alt="배너 : 제목" /></a></li>
1296				<li class="beb_li" data-delay="1"><a href=""><img src="http://sample.ndsoftnews.com/template_sian/download.php?idxno=854&file_extension=jpg&filename=250%B0%E6%B3%B2%B5%B5%B9%CE%BD%C5%B9%AE.jpg" alt="배너 : 제목" /></a></li>
1297				<li class="beb_li" data-delay="1"><a href=""><img src="http://sample.ndsoftnews.com/template_sian/download.php?idxno=846&file_extension=jpg&filename=330%C6%F7%C5%E4.jpg" alt="배너 : 제목" /></a></li>
1298				<li class="beb_li" data-delay="1"><a href=""><img src="http://sample.ndsoftnews.com/template_sian/download.php?idxno=848&file_extension=jpg&filename=675_weeklyjournal.jpg" alt="배너 : 제목" /></a></li>
1299				<li class="beb_li" data-delay="5"><iframe width="640" height="360" src="http://www.youtube.com/embed/dykTgBpgbVs?feature=player_detailpage" frameborder="0" allowfullscreen></iframe></li>
1300			</ul>
1301		</div>
1302		<div class="beb_buttons">
1303			<button type="button" class="beb_btns beb_btn_prev">뒤로</button>
1304			<button type="button" class="beb_btns beb_btn_stop">멈춤</button>
1305			<button type="button" class="beb_btns beb_btn_next">앞으로</button>
1306		</div>
1307	 </div>
1308	 */
1309	,effect:function()
1310	{
1311		var savePrefix = "banner_order_";
1312
1313		// 배너 넓이 
1314		function setSizeInfo($this){
1315			var idxno = $this.attr("data-idxno")
1316				 ,$ul = $this.find(".beb_ul")
1317				 ,$li = $ul.find(".beb_li")
1318				 ,boxWidth = $this.innerWidth()||$this.closest("#float_side_box").width()	// 윙 사이드의 배너일경우 재측정
1319				 ,liCount = $li.length||0;
1320			
1321			// 관리자 페이지가 아닐때 실제 노출중인 것만 찾음
1322			//if(ADM_DOMAIN.indexOf(location.host)<0){
1323				$.each($li,function(){
1324					var $this=$(this), len=$this.find(".banner_box").length;
1325					if(!len) $this.remove();
1326				});
1327				$li = $ul.find(".beb_li");
1328				liCount = $li.length||0;
1329			//}
1330
1331			// 부모박스 기준으로 ul 최대 넓이 지정
1332			$ul.width(boxWidth*liCount);
1333
1334			// 배너마다 넓이가 다를수 있으니 부모박스 넓이기준으로함
1335			$li.width(boxWidth);
1336
1337			return {
1338						idxno : idxno
1339						,$ul : $ul
1340						,$li : $li
1341						,boxWidth : boxWidth
1342						,liCount : liCount
1343					};
1344		}
1345
1346		return {
1347			// 순서대로 하나의 배너만 보임 
1348			order:function(){
1349				var _this = this
1350					,$this = $(_this)
1351					,$info = setSizeInfo($this)
1352					,idxno = $info.idxno
1353					,$li =$info.$li
1354					,liCount = $info.liCount-1
1355					,saveKey = savePrefix+idxno
1356					,order = Number(localStorage.getItem(saveKey))||0;
1357
1358				// 랜덤 선택된것만 보임, 버튼 없앰
1359				$li.css("display","list-item").not(":eq("+order+")").css("display","none");
1360
1361				localStorage.setItem(saveKey, (order>=liCount ? 0 : order+1));
1362			}
1363
1364			// random banner
1365			,random:function(){
1366				var _this = this
1367					,$this = $(_this)
1368					,$info = setSizeInfo($this)
1369					,$li =$info.$li
1370					,liCount = $info.liCount
1371					,random = Math.floor(Math.random()*liCount);
1372
1373					// 랜덤 선택된것만 보임, 버튼 없앰
1374				$li.css("display","list-item").not(":eq("+random+")").css("display","none");
1375			}
1376			
1377			// random 배너 선택후 슬라이드
1378			,randomSlide:function(){
1379				bannerpop.effect()['slide'].call(this, true);
1380			}
1381
1382			// slide banner
1383			// rand true or false
1384			,slide:function(rand){
1385				var _this = this
1386					,$this = $(_this)
1387					,$info = setSizeInfo($this)
1388					,$ul = $info.$ul
1389					,$li =$info.$li.css("display","list-item")
1390					,$btnBox = $this.find(".beb_buttons")
1391					,$btnStop = $btnBox.find(".beb_btn_stop")
1392					,$btnCurrent = null						// 현재 선택된 버튼 prev,next,play,stop of buttons
1393					,speed = Number(_this.getAttribute("data-speed"))||.3
1394					,delayInfo = $li.map(function(){ return Number(this.getAttribute("data-delay"))||5; }).get()
1395					,boxWidth =$info.boxWidth
1396					,liCount = $info.liCount
1397					,count = (rand===true?Math.floor(Math.random()*(liCount)):-1)	// 처음부터 +1 하고 시작하기에 -1초기값-random일때는 배너수중 1개
1398					,delay = null													// 멈춰잇는 시간(초)
1399					,left = boxWidth												// 움직이는 간격
1400					,si = null														// setInterval 변수 : animate complete에서 delay로 해결하려 했는데 뭔가 잘 안풀림
1401					,tmpDelay = null												// next, prev 시 delay 없이 넘김
1402					,firstBtnClicked = 0;											// prev,next로 이동하는가 - rotate에서 또한번 +,- 하기에 처음만 실행되어야 함
1403
1404				/**** function //s ****/
1405				/*
1406					다음 배너
1407					@params
1408					 loop : 반복될것인가
1409					 mode : + or -
1410				*/
1411				function rotate(loop, mode){
1412					if(!mode) mode="+";
1413					if(mode==="+") count++;
1414					else  count--;
1415
1416					if(count>=liCount || count<=0) count = 0;					// 지연시간 담은 배열찾기 key
1417					var front = count+1;													// 지연후 움직여야 하는 거리 미리 담아둠
1418					if(count>=(liCount-1)) front = 0;
1419					left = boxWidth*front*-1;
1420					delay = tmpDelay===null?delayInfo[count]:tmpDelay;
1421
1422					si = setTimeout(function(){
1423						$ul.animate({ marginLeft:left }
1424										,speed*1000,
1425										function(){
1426											if(loop===false) $btnCurrent.prop("disabled", false);
1427											tmpDelay = null;
1428										});//.delay(delay*1000);	
1429						if(loop!==false) rotate();
1430					},delay*1000);								
1431				}
1432
1433				// stop
1434				function stop(){
1435					firstBtnClicked++;
1436
1437					//$ul.stop(true, false);
1438					clearTimeout(si);
1439					tmpDelay=null;
1440					$btnStop.addClass("beb_btn_start").text("play");
1441				}
1442
1443				// restart
1444				function start(){
1445					firstBtnClicked = 0;
1446
1447					count--;
1448					if(count<=0) count=0;
1449
1450					tmpDelay=null;
1451					rotate();
1452
1453					$btnStop.removeClass("beb_btn_start").text("멈춤");
1454				}
1455				
1456				// 이전
1457				function prev(){
1458					stop();
1459
1460					if(firstBtnClicked===1) count--;			// 처음만 이미 증가된값을 감소시킴
1461					if(count<=0) count=liCount;
1462
1463					tmpDelay=0;
1464					rotate(false,"-");
1465
1466					$btnCurrent.prop("disabled", true);
1467				}
1468
1469				// 이후
1470				function next(){
1471					stop();
1472
1473					if(firstBtnClicked===1) count--;
1474					if(count>=liCount) count=0;
1475
1476					tmpDelay=0;
1477					rotate(false);
1478
1479					$btnCurrent.prop("disabled", true);
1480				}
1481				/**** function //e ****/
1482
1483				// 처음 배너를 보이지 않는다는 것은 랜덤 배너의 슬라이드라는 것-처음보일배너 설정
1484				if(count>=0 && rand===true){
1485					var _boxWidth = boxWidth*(count>=liCount?liCount-1:count)*-1;
1486					count--;
1487					$ul.css("margin-left",_boxWidth+"px");
1488				}
1489				
1490				// 실행
1491				rotate();						
1492				
1493				// 버튼보임
1494				$btnBox/*.css("display","block")*/.find(".beb_btns").unbind("click")
1495				.click(function(){
1496					var $this = $(this);
1497	
1498					$btnCurrent = $this;
1499					if($this.is(".beb_btn_prev")) prev();
1500					else if($this.is(".beb_btn_next")) next();
1501					else if($this.is(".beb_btn_stop")){
1502						if($this.is(".beb_btn_start")) start();
1503						else stop();
1504					}
1505				});
1506
1507				// mouseover event
1508				$ul.on(bannerpop.vars.isMobileMode?{touchstart:stop,touchend:start}:{mouseenter:stop,mouseleave:start});
1509			}
1510		};
1511	}
1512
1513	// 배너호출
1514	,banner:function(target)
1515	{	
1516		var parents = this
1517			,$target = !!target.jquery?target:$(target);
1518
1519		// mobile or pc mode?
1520		try{ bannerpop.vars.isMobileMode=document.querySelector("#user-wrap").className.indexOf("mobile")>=0||false }catch(e){ }
1521		
1522		//console.log($target);
1523		$.each($target, function(i, ele){
1524			var type = ele.getAttribute("data-type")||"random";
1525			parents.effect()[type].call(this);
1526		});
1527	}
1528
1529	,getCookie:function(name)
1530	{	/*
1531		var cookie = document.cookie;
1532		if(cookie.indexOf(name)<0) return "";
1533		
1534		var regexp = new RegExp("^(.*)"+name+"=(.*?);(.*)$","g");
1535		return cookie.replace(regexp,"$2").replace(/^\s+|\s+$/g,"");
1536		*/
1537		name+="=";
1538	    var ca = document.cookie.split(';');
1539	    for(var i=0; i<ca.length; i++) {
1540	        var c = ca[i];
1541	        while (c.charAt(0)==' ') c = c.substring(1);
1542	        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
1543	    }
1544	    return "";
1545	}
1546	
1547	,setCookie:function(name, value, days, domain)
1548	{
1549		var expires = "";
1550		if(days){
1551			var date = new Date();
1552			date.setTime(date.getTime()+(days*24*60*60*1000));
1553			expires = "; expires="+date.toGMTString();
1554		}
1555		
1556		/*
1557		var dm=SITE_DOMAIN.replace('http://','');
1558		dm=dm.replace('https://','');
1559		if(!domain) domain="." + dm;
1560		*/
1561
1562		if(!domain) domain='.'+SITE_DOMAIN.replace(/^http(s)?:\/\//i,'').replace(/^(www|cms|slv|cdn|m)\./i,'');
1563		
1564		document.cookie = name+"="+value+expires+"; path=/; " + (domain?"domain="+domain+";":"");
1565	}
1566
1567	// url을 array로
1568	,linkToJson:function(link)
1569	{
1570		if(!link) return false;
1571		
1572		var json = {}
1573			,tmp = link.replace(/^\/\?/,"").split("&");
1574		
1575		if(tmp.length<=0 || !tmp) return false;
1576		for(var i in tmp){
1577			var param = tmp[i].split("=")
1578				,key = param[0]
1579				,value = param[1];
1580			
1581			json[key] = value;
1582		}
1583		return json;
1584	}
1585
1586	// 배너 append
1587	,append:function()
1588	{
1589		var id = ___BANNER
1590			,status = bannerStatus
1591			,time = ___currentTime
1592			,sTime = startTime
1593			,eTime = endTime
1594			,content = decodeURIComponent(bannerContent)
1595			,title = typeof bannerTitle == "undefined" ? "":decodeURIComponent(bannerTitle)
1596			,$target = $("#"+id)
1597			,voteUse = typeof bannerVoteUse == "undefined" ? "N":bannerVoteUse
1598			,explain = '';
1599			//,explain = "\n<br />"+util.timestampToDatetime(sTime).strDateTime.substring(0,16)+"~"+util.timestampToDatetime(eTime).strDateTime.substring(0,16);
1600
1601
1602		if(!id || $target.length<=0 || $target.attr("data-append")=="true") return false; // 객체가 없거나 시작전,이미 추가되었다면 중단
1603		
1604		// 예정,종료 배너
1605		else if(sTime > time || time > eTime || status=="0"){	
1606            var adminPageBool = (location.href.indexOf('/edit/adminSection.html') < 0)? false:true;
1607            if(!adminPageBool) {
1608                if(!($('body').hasClass('ndip_user_body_view') && voteUse == 'Y' && status == "0")) {
1609                    return false;    // 종료 메시지 안띄우기
1610                }
1611            }
1612            var voteAdcClass = "";
1613			var adcMsg=""
1614				,adcClass="";
1615			if(sTime > time && status!="0"){
1616				adcMsg = '노출예정 배너';
1617				adcClass = "banner-later";
1618			}else if(time > eTime || status=="0"){
1619				adcMsg = '종료된 배너';
1620				adcClass = "banner-finish";
1621				if(voteUse == "Y") voteAdcClass = "vote_banner_box_finish";
1622			}
1623			
1624			if(!adminPageBool) $target.attr("data-append","true").after('<div class="ad-finished '+voteAdcClass+'"></div>');    // 선거배너 종료 DIV
1625            else $target.attr("data-append","true").after('<div class="ad-finished"><span class="'+adcClass+'"><i class="icon-clock-o"></i>&nbsp;'+adcMsg+' "'+title+'"</span>'+explain+'</div>');
1625	// 종료 메시지 띄우고 종료
1626			bannerTitle="";//초기화
1627			
1628			return false;
1629		}
1630		
1631		// cdn host 따라가게
1632		var _uri=$target[0].src
1633			,_host=((typeof URL === "function")?new URL(_uri).origin:_uri.match(/^(http.*)\/bannerpop\//)[1]||"");
1634		if(_host) content=content.replace('<img src="/bannerpop/', '<img src="'+(_host.search(/^http(s)?:\/\/cms\./)<0?_host:SITE_DOMAIN)+'/bannerpop/');
1635		
1636		$target.attr("data-append","true").after(content);	// 추가 되었으면 data-append 태그 나김
1637	}
1638
1639	/****** 팝업 띄우기 
1640	var ___popup = [{},...];
1641	
1642	* json 내용 *
1643		idxno - 팝업 idxno 고유번호 
1644		title - 팝업의 제목 
1645		start - 팝업 시작일시
1646		end - 팝업 종료일시 
1647		status - 진행상태 (1=진행, 0=종료)
1648		popup_type - 팝업형태 (layer=레이어, window=윈도우)
1649		popup_size - auto (사용안함)
1650		popup_width - 팝업창크기(가로)
1651		popup_height - 팝업창크기(세로)
1652		position - auto (사용안함)
1653		x_position - 창의 x 위치 
1654		y_position - 창의 y 위치 
1655		apply_page - 적용페이지 (main, section, list, view 값이 입력 되어있음 , php에서 페이지 구분해서 json으로 만들어 줍니다.) 
1656		bottom_close - 하단표시 창닫기 출력여부 (Y=출력, N=출력안함)
1657		bottom_close_expire_ck - **동안 열지않기 (none=사용안함, day=하루동안 열지않기, days=몇일동안 열지않기)
1658		bottom_close_expire - 몇일인지
1659		layer_border - 레이어 팝업인 경우 외곽선 (Y=사용함, N=사용안함)
1660		layer_move - 레이어 팝업인 경우 드래그 가능 (Y=사용함, N=사용안함)
1661		layer_scroll - 레이어 팝업인 경우 스크롤 따라다니기 (Y=사용함, N=사용안함)
1662		layer_close - 레이어 팝업인 경우 닫기 아이콘 (Y=사용함, N=사용안함)
1663		layer_close_icon - 레이어 팝업인 경우 닫기 아이콘 유형 
1664		layer_close_position - 레이어 팝업인 경우 닫기 아이콘 출력 위치 (TL-상/좌, TR-상/우, BL-하/좌, BR-하/우)
1665		window_scroll - 윈도우 팝업인 경우 스크롤 활성화 (Y=사용함, N=사용안함)
1666		content - 출력 HTML 내용
1667	*****/
1668	,float:function(j)
1669	{
1670		// json 값
1671		var current = ___currentTime
1672			,start = Number(j.start)||0
1673			,end = Number(j.end)||(new Date().getTime()+100)	// 종료일이 기입되지 않았다면, 현재보다 100씩더해서 계속 늘림 
1674			,status = j.status||"0";
1675	
1676		if(this.vars.popup.view!="manager" && (status=="0" || current < start || (current > end && end!==0))) return false;												// 종료 or 기간이 아니라면 통과
1677			
1678		var	parents = this
1679			,idxno = j.idxno||"0"
1680			,oriTitle = j.title||""
1681			,title = decodeURIComponent(j.title)||""
1682			,popupType = j.popup_type||"window"
1683			,popupSize = j.popup_size||"auto"
1684			,popupWidth = Number(j.popup_width)||0
1685			,popupHeight = (Number(j.popup_height)||0) + 32
1686			,position = j.position||"auto"
1687			,xPosition = Number(j.x_position)||0
1688			,yPosition = Number(j.y_position)||0
1689			,applyPage = j.apply_page||"main"
1690			,bottomClose = j.bottom_close||"N"
1691			,bottomCloseExpireCk = j.bottom_close_expire_ck||"none"
1692			,bottomCloseExpire	= j.bottom_close_expire||1
1693			,layerBorder = j.layer_border||"N"
1694			,layerMove = j.layer_move||"N"
1695			,layerScroll = j.layer_scroll||"N"
1696			,layerClose = j.layer_close||"N"
1697			,layerCloseIcon = j.layer_close_icon||""
1698			,layerClosePosition = j.layer_close_position||"BR"
1699			,windowScroll = j.window_scroll||"Y"
1700			,content = decodeURIComponent(j.content)||""
1701			,popupUrl = j.popup_url||""// + (parents.vars.popup.view=="manager"?"?edit_mode=preview":"")||""
1702			,top = 0
1703			,left = 0
1704			,popname = parents.vars.popup.popname+idxno
1705			,_type = popupType; 								// default: 각자띄움 - 팝업과 레이어가 위치값을 공유하여 차례로 띄울려면 "window" or 공유하지 않고 각자 띄울려면 popupType;
1706
1707		var type = {		
1708			calcPosition:function(){
1709				// x,y 가 0일때는 auto로 간주
1710				if((xPosition===0 && yPosition===0)/* || position=="auto"*/){
1711					var maxHeight = parents.arrayMaxMin(parents.vars.popup.height[_type],"max")
1712						,maxTop = parents.arrayMaxMin(parents.vars.popup.top[_type],"max")
1713						,initLeft = popupType=="window"?0:parents.vars.popup.bodyLeft
1714						,prevWidth = parents.vars.popup.width[_type][parents.vars.popup.width[_type].length-1]||0
1715						,prevLeft = parents.vars.popup.left[_type][parents.vars.popup.left[_type].length-1]||initLeft;			// 바로 이전 팝업 넓이를 left값으로 정함-window:0, layer:content의 left
1716		
1717					//console.log(popupWidth);
1718					left = prevLeft+prevWidth;
1719					
1720					// 페이지 넓이보다 자리잡은 left값이 크다면 화면상 한단계 내림
1721					if(left>parents.vars.popup[popupType=="window"?"screenWidth":"bodyWidth"]){
1722						top += maxHeight;						
1723						left = initLeft;
1724						
1725						// 다음 단계이니까 초기화 함
1726						parents.vars.popup.width[_type] = [];
1727						parents.vars.popup.height[_type] = [];
1728						parents.vars.popup.top[_type] = [];
1729						parents.vars.popup.left[_type] = [];
1730					}else{
1731						top = (maxTop||0);
1732					}
1733					
1734					// 변화된값 배열에 넣기 위해 조작
1735					xPosition = left;
1736					yPosition = top;
1737					
1738					// 변수에 담음
1739					parents.vars.popup.width[_type].push(popupWidth||0);
1740					parents.vars.popup.height[_type].push(popupHeight||0);
1741					parents.vars.popup.top[_type].push(yPosition||0);
1742					parents.vars.popup.left[_type].push(xPosition||0);
1743										
1744				}else{
1745					top = yPosition;
1746					left = xPosition;
1747				}
1748			}
1749		
1750			// 관리자 미리보기시 중앙에
1751			,setPositionCenter:function(){
1752				var _width = (document.body.clientWidth/2)-(popupWidth/2)
1753					,_scrollTop = document.body.scrollTop;
1754				
1755				top = _scrollTop + 50;
1756				left = _width;
1757			}
1758			
1759			// 띄울 페이지 applyPage
1760			,isApplyPage:function()
1761			{
1762				// 관리자 통과
1763				if(parents.vars.popup.view=="manager") return true;
1764				/*
1765				var params = bannerpop.linkToJson(location.search.replace("?",""))
1766					,mod = params.mod||""
1767					,act = params.act||""
1768					,section = params.section||"";
1769				
1770				// 메인
1771				if(((mod=="main" && act=="index" && !section) || (!mod && !act && !section)) && applyPage.indexOf("main")>=0) return true;
1772				// 섹션
1773				else if(mod=="main" && act=="index" && section && applyPage.indexOf("section")>=0) return true;
1774				// 기사 리스트
1775				else if(mod=="news" && act=="articleList" && applyPage.indexOf("list")>=0) return true;
1776				// 기사뷰
1777				else if(mod=="news" && act=="articleView" && applyPage.indexOf("view")>=0) return true;
1778				*/
1779			}
1780		
1781			,window:function(){
1782				//if(this.isApplyPage()!==true) return false;
1783				
1784				this.calcPosition(); // 위치 계산
1785				var winpopupUrl = '/bannerpop/popup.html?win_popup_idxno=' + idxno;
1786				window.open(winpopupUrl, popname, "width="+popupWidth+",height="+popupHeight+",scrollbars="+(windowScroll=="Y"?"yes":"no")+",resizable=yes,top="+top+",left="+left);
1787			}
1788		
1789			,layer:function(){
1790				//if(this.isApplyPage()!==true) return false;
1791				
1792				this.calcPosition(); // 위치 계산
1793			
1794				var $content = $(content);
1795
1796				$content.attr({"id":popname})
1797				.css({"top":top+"px","left":left+"px","max-width":popupWidth+"px","min-height":popupHeight+"px","z-index":"100" + parents.vars.popup.order}).addClass("layer_box"+(layerScroll=="Y"?" layer_box_fixed":"")+(layerBorder=="Y"?" layer_box_border":""))
1798				.find(".popup_close_box").addClass("layer_close_box");
1799				
1800				// 드래그 가능
1801				if(layerMove=="Y") $content.addClass("layer_box_cursor_move").draggable();				
1802				
1803				// 창닫기-icon 닫기 버튼은 별개다
1804				//if(bottomClose=="Y"){	
1805				var $btnClose = $content.find(".popup_close, .popup_close_map, .popup_icon_close");
1806				$btnClose.each(function(){
1807					var _$this = $(this);
1808					//if(_$this.is(".popup_close") && bottomClose=="Y") _$this.text('창닫기');
1809
1810					if(_$this.is(".popup_icon_close")) {
1811						if(layerClosePosition == 'BL' || layerClosePosition == 'BR') {
1812							
1813							if($content.find(".popup_close, .popup_close_map").length>0) {
1814								_$this.css('top',Number(j.popup_height)-40+'px');	
1815							}
1816						}
1817
1818						_$this.addClass("layer_position_"+layerClosePosition);
1819					}
1820				});
1821				
1822				$btnClose.click(function(){
1823					parents.evtClose(popupType, idxno);	
1824					return false;
1825				});
1826				//}
1827
1828				// 이미지내 링크가 창닫기 라면
1829				//$content.find("a[href*='javascript:window.close()']").click(function(){
1830				$content.find("[href*='javascript:window.close()']").click(function(){
1831					parents.evtClose(popupType, idxno);	
1832					return false;
1833				});
1834
1835				// 하루, 몇일동안 열지 않기
1836				parents.daysNotOpen(bottomCloseExpireCk, bottomCloseExpire, $content.find(".popup-days, .popup_day_close_map"), j);
1837				
1838				// 관리자 미리보기시 중앙에
1839				if(parents.vars.popup.view=="manager"){
1840					$content.appendTo(document.body);
1841					this.setPositionCenter();	
1842					$content.removeClass("layer_box_fixed").css({"top":top+"px", "left"
1842:left+"px"});
1843				}else{
1844					$content.appendTo($("#layer-popups"));
1845				}
1846				
1847				// 이미지맵 리사이즈
1848				$('img[usemap]', $content).rwdImageMaps();
1849			}				
1850		};
1851	
1852		type[popupType]();		
1853	}
1854	
1855	// 팝업띄우기
1856	,popup:function()
1857	{
1858		//try{
1859			var parents = this;
1860			$(window).on("load", function(){
1861				if(!window.___popup) return ;
1862				if($.isArray(___popup)===false && ___popup.length>0) return ;
1863				if(!window.___currentTime) ___currentTime = Math.floor(new Date().getTime()/1000);// 시간이 설정되지 않았다면 js 시간으로 설정함
1864								
1865				var $content = $("#layer-popups");
1866				
1867				if($content.length<=0) return false;
1868				parents.vars.popup.bodyWidth = $content.innerWidth();			
1869				parents.vars.popup.bodyLeft = $content.position().left;
1870				parents.vars.popup.screenWidth = window.screen.width;
1871				for(var i=0,cnt=___popup.length; i<cnt; i++){
1872					// 쿠키인지 판단후 열기
1873					var coo = "";
1874					coo = bannerpop.getCookie(parents.vars.popup.popname+___popup[i].idxno)
1875
1876					if(!coo){
1877						parents.vars.popup.order++;
1878						parents.float(___popup[i]);
1879					}
1880				}
1881			});
1882		//}catch(e){}		
1883	}	
1884	
1885	// 창닫기
1886	,evtClose:function(mode, idxno)
1887	{
1888		if(mode=="layer"){
1889			var layerId = bannerpop.vars.popup.popname+idxno;
1890			
1891			$("#"+layerId).fadeOut("fast", function(){
1892				$(this).remove();
1893			});
1894		}else window.close();
1895	}
1896	
1897	// cookie
1898	,evtCookieClose:function(name, days)
1899	{
1900		bannerpop.setCookie(name, "popup", days);
1901	}
1902	
1903	// 하루,몇일동안 열지 않기
1904	,daysNotOpen:function(expire, period, $btn, p)
1905	{
1906		var parents = this
1907			,idxno = p.idxno
1908			,isClickedMap = false;
1909		
1910		if(expire!="none"){
1911			$btn.each(function(i,v) {
1912				var $thisBtn = $(this);
1913				if($thisBtn.is(".popup-days")){
1914					// 하루동안
1915					if(expire=="day"){
1916						$thisBtn.click(function(){
1917							parents.evtCookieClose(parents.vars.popup.popname+idxno, "1");
1918							parents.evtClose(p.popup_type, p.idxno);
1919							return false;
1920						})
1921						// 닫기 태그 안에 암것두 없는 거 찾아 닫기 텍스트 넣어주기
1922						.not(":has(*)").html('<a href="#close-to-layer">하루동안 보지 않기</a>');
1923					}
1924					// 몇일동안 daySubfix
1925					else if(expire=="days"){
1926						var select = '<a href="#link">'
1927									+'<label class="show-for-sr" for="popDays"></label>'
1928									+'<select name="popDays" id="popDays" class="tiny" title="기간">'
1929									+'	<option value="1">하루</option>'
1930									+'	<option value="2">2일</option>'
1931									+'	<option value="3">3일</option>'
1932									+'	<option value="4">4일</option>'
1933									+'	<option value="5">5일</option>'
1934									+'	<option value="6">6일</option>'
1935									+'	<option value="7">7일</option>'
1936									+'</select> 동안 열지않기'
1937									+'</a>';
1938						var html = '<a href="#link">'
1939									+ (period>1 ? '몇일동안 보지 않기' : '하루동안 보지 않기')
1940									+'</a>';
1941						//$btn.not(":has(*)").append(select).click(function(){
1942						$thisBtn.append(html).click(function(){
1943							var $this = $(this)
1944								//,days = $this.prev("select").val();
1945								,days = period;
1946							
1947							parents.evtCookieClose(parents.vars.popup.popname+idxno, days);
1948							parents.evtClose(p.popup_type, p.idxno);
1949							return false;
1950						});					
1951					}
1952				}else{
1953					// 이미지맵일때, 하루동안 열지않기
1954					$thisBtn.click(function(){
1955						parents.evtCookieClose(parents.vars.popup.popname+idxno, "1");
1956						parents.evtClose(p.popup_type, p.idxno);	
1957						return false;
1958					});	
1959					
1960					isClickedMap = true;
1961				}
1962			});
1963		}
1964		
1965		// expire 값이랑 관계없이 이미지맵을 찾아 처리
1966		if(isClickedMap===false && $btn.is(".popup_day_close_map")){
1967			// 이미지맵일때, 하루동안 열지않기
1968			$btn.click(function(){
1969				parents.evtCookieClose(parents.vars.popup.popname+idxno, "1");
1970				parents.evtClose(p.popup_type, p.idxno);	
1971				return false;
1972			});	
1973		}
1974	}
1975	
1976	// window popup control
1977	,popupControl:function()
1978	{
1979		if(!___popup) return ;
1980		if((typeof ___popup)!=="object") return ;
1981		
1982		var parents = this
1983			,p = ___popup		
1984			,title = decodeURIComponent(p.title)||"" 
1985			,popupType = p.popup_type||"window"
1986			,bottomClose = p.bottom_close||"Y"
1987			,bottomCloseExpireCk = p.bottom_close_expire_ck||"day"	// : day,days,none
1988			,bottomCloseExpire = p.bottom_close_expire||1	// : 몇일
1989			,$btnClose = $(".popup_close, .popup_close_map, .popup_icon_close")
1990			,$btnDayClose = $(".popup-days, .popup_day_close_map");
1991		
1992		if(popupType!="window") return ;
1993		
1994		// 윈도우 바 타이틀 교체
1995		document.title = title;
1996	
1997		// 창닫기
1998		if(bottomClose=="Y"){
1999			$btnClose.each(function(){
2000				var _$this = $(this);
2001				//if(_$this.is(".popup_close")) _$this.text('창닫기');
2002			});
2003			
2004			$btnClose.click(function(){
2005				parents.evtClose(p.popup_type, p.idxno);	
2006				return false;
2007			});
2008		}
2009		
2010		// 하루, 몇일동안 열지 않기
2011		this.daysNotOpen(bottomCloseExpireCk, bottomCloseExpire, $btnDayClose, p);
2012		
2013	}
2014
2015	// array 최고값
2016	,arrayMaxMin:function(arr, mode)
2017	{
2018		if($.isArray(arr)===false) return false;
2019	
2020		if(!mode) mode = "max";
2021		arr.sort(function(a, b){
2022			return b-a;
2023		});
2024		return (mode=="max"?arr[0]:arr[arr.length-1])||0;
2025	}
2026
2027    // 통계 애널리틱스 이벤트 연결
2028    ,analytics:function(type, banner, agent) {
2029        if (!type||!banner||!agent) return;
2030
2031        switch (type) {
2032            case "view":
2033                agent.forEach(function(agt) {
2034                    try{
2035                        if (agt=="ga" && typeof ga!="undefined") {
2036                            ga('send', 'event', '배너뷰', 'NDVIEWBANNER', banner);
2037                        }
2038                        if (agt=="gtag" && typeof gtag!="undefined") {
2039                            gtag('event', 'NDVIEWBANNER', {'event_category': '배너뷰', 'event_label': banner});
2040                        }
2041                        if (agt=="gtm" && typeof dataLayer!="undefined") {
2042                            dataLayer.push({'event':'NDVIEWBANNER','event_category':'배너뷰', 'event_label':banner});
2043                        }
2044                        if (agt=="wcsnaver" && typeof wcs!="undefined") {
2045                            wcs.event(banner, 'NDVIEWBANNER');
2046                        }
2047                    } catch (e) {}
2048                });
2049                break;
2050
2051            case "click":
2052                agent.forEach(function(agt) {
2053                    try {
2054                        if (agt=="ga" && typeof ga!="undefined") {
2055                            ga('send', 'event', '배너클릭', 'NDCLICKBANNER', banner);
2056                        }
2057                        if (agt=="gtag" && typeof gtag!="undefined") {
2058                            gtag('event', 'NDCLICKBANNER', {'event_category': '배너클릭', 'event_label': banner});
2059                        }
2060                        if (agt=="gtm" && typeof dataLayer!="undefined") {
2061                            dataLayer.push({'event':'NDCLICKBANNER','event_category':'배너클릭', 'event_label':banner});
2062                        }
2063                        if (agt=="wcsnaver" && typeof wcs!="undefined") {
2064                            wcs.event(banner, 'NDCLICKBANNER');
2065                        }
2066                    } catch(e) {}
2067                });
2068                break;
2069        }
2070
2071        // Tip!!
2072        // ga('send', 'event', 카테고리, 액션, 라벨)                    // 구글 유니버설 애널리틱스 태그 사용시 (analytics.js)
2073        // gtag('event', event_name, {event_category, event_label})    // 구글 글로벌 사이트 태그 사용시 (gtag.js)
2074        // dataLayer.push({var:value});                                // 구글 태그 관리자 데이터 영역 변수 필요시 (GA4 구성 사용)		
2075        // wcs.event('이벤트카테고리명', '이벤트명')                     // 네이버 애널리틱스 사용시
2076    }
2077
2078	,isMobileDevice:function(){
2079		return /(iPhone|iPod|IPad|Android|Blackberry|Opera Mini|Windows CE|Nokia|Sony|Samsung|LGTelecom|SKT|Mobile|Phone)/.test(navigator.userAgent);		
2080	}
2081};
2082
2083/******************************************************************************************************************
2084* 멀티 기능성 배너
2085*
2086* @update 2018/07/18
2087*/
2088var bannerpopMulti = {
2089    // php 전달 변수
2090    vars:{
2091        $banner_list:null,
2092        $edit_mode:""
2093    }
2094    
2095    // 페이지 초기 로드
2096    ,init:function() {
2097        $('input[name="effect_type"]').on("click", function() {
2098            if ($(this).val()=='none') {
2099                $("#row_num").val(0).attr("disabled", true);
2100                $("#scroll_num").val(0).attr("disabled", true);
2101            } else {
2102                $("#row_num").removeAttr("disabled");
2103                $("#scroll_num").removeAttr("disabled");
2104            }
2105        });
2106
2107        $('input[name="autoplay"]').on("click", function() {
2108            if ($(this).val()=='Y') {
2109                $("#autoplay_speed").removeAttr("disabled");
2110            } else {
2111                $("#autoplay_speed").attr("disabled", true);
2112            }
2113        });
2114
2115        $('#all-banner-list').on('click', function(e) {
2116            $this = $(this);
2117            href = $this.attr('href');
2118            $("#edit-modal-iframe").attr("src", href);
2119            $('#edit-modal').foundation('open');
2120            return false;
2121        });
2122
2123        $('#banner-activity-box').sortable({
2124            axis: '',
2125            update: function() {
2126                console.log($(this));
2127            }
2128        });
2129
2130        $('#edit-modal').on('open.zf.reveal', function(e){
2131            $('#for-loading').show();
2132        });
2133
2134        $('#edit-modal').on('closed.zf.reveal', function(e){
2135            $("#edit-modal-iframe").attr("src", "about:blank").height('0px').closest('#activity-modal').css('height', '0px');
2136        });
2137
2138        $(document).on("click", '.trash', function() {
2139            var $this=$(this)
2140            ,$parent = $this.closest('.banner-activity-list');
2141            $parent.fadeOut('fast', function(){
2142                $parent.remove();
2143            });
2144        });
2145    }
2146
2147    // 배너 가져오기
2148    ,evtClickMultipleAdd:function() {
2149        var multi_idxno=window.parent.$('#all-banner-list').closest('div').attr('data-multi-idxno')||'';
2150        $('#activity-add-btn').on("click", function() { // #activity-add-btn 기능성배너 버튼 클릭 이벤트를 이용
2151            var $this=$(this);
2152            if($('.banner_element_ckecked').is(':checked') == false) {
2153                alert('배너를 선택해주세요.');
2154                return false;
2155            }else{
2156                var $checked=$(".banner_element_ckecked:checked")
2157                    ,arr = new Array();
2158                if($checked.length>0) {
2159                    $.each($checked, function(idx, v) {
2160                        arr.push(v.value);
2161                    });
2162
2163                    var data = {mode:multi_idxno?'modify':'input', multi_idxno:multi_idxno, banner_idxno:arr};
2164                    data = JSON.stringify(data);
2165                    //console.log(data);
2166
2167                    $.ajax({
2168                        url:"/bannerpop/activity_multi_act.php"
2169                        ,type:'post'
2170                        ,dataType:'json'
2171                        ,contentType:'application/x-www-form-urlencoded; charset=utf-8'
2172                        ,data:{post_data:data}
2173                        ,success:function(json, result) {
2174                            if(result == 'success') {
2175                                if(json.response == 'ok') {
2176                                    var item = JSON.parse(json.data),
2177										$target = window.parent.$("#banner-activity-box"),
2178                                        $sample = window.parent.$("#sample");
2179                                    bannerpopMulti.vars.$banner_list = item;
2180                                    bannerpopMulti.bannerCollocate($target, $sample);
2181                                    window.parent.$(".close-button").trigger("click");
2182                                }else{
2183                                    return false;
2184                                }
2185                            }else return false;
2186                        },
2187                        error:function(request,status,error){
2188                            alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
2189                        }
2190                    });
2191                }
2192            }
2193        });
2194    }
2195
2196    // 배너 배치 하기
2197    ,bannerCollocate:function($targetArea, $sample) {
2198        if (!this.vars.$banner_list) return false;
2199        if (typeof $targetArea != "object" || typeof $sample != "object") return false;
2200        var item = this.vars.$banner_list;
2201        for (var i=0;i<item.length;i++) {
2202            var $areaBox = $targetArea,
2203                $clone = $sample.clone(),
2204                stateIcon = "";
2205            if (typeof $clone == "object") {
2206                if (item[i].state=="previous") stateIcon = '<span class="label success tiny">진행전</span>';
2207                else if (item[i].state=="proceeding") stateIcon = '<span class="label tiny">진행중</span>';
2208                else stateIcon = '<span class="label secondary tiny">진행종료</span>';
2209                $clone.attr("data-banner-idxno", item[i].idxno);
2210                $clone.find(".banner-activity-list").attr("data-banner-idxno", item[i].idxno).end().
2211                    find(".dis-table-cell").append(item[i].banner).end().
2212                    find('input[name="banner_idxno[]"]').val(item[i].idxno).end().
2213                    find(".dis-status").empty().append(stateIcon).end().
2214                    find('input[name="delay[]"]').attr("id", "delay_"+item[i].idxno).attr("value", item[i].delay).end().
2215                    find('.input-group-label').attr("for", "delay_"+item[i].idxno);
2216                $areaBox.append($clone.html());
2217            }
2218        }
2219    }
2220
2221    // 선택된 배너 표시
2222    ,selectBannerCheck:function() {
2223        var $areaBox = window.parent.$("#banner-activity-box"),
2224            $list = $areaBox.find('input[name="banner_idxno[]"]'),
2225            $bannerItems = $(".adccfg_list_items"),
2226            bannerList = [],
2227            i = 0;
2228        $list.each(function() {
2229            bannerList.push($(this).val());
2230        });
2231        //console.log(bannerList);
2232
2233        $bannerItems.each(function() {
2234            var $this = $(this),
2235                idxno = $this.attr("data-banner-idxno");
2236            if ($.inArray(idxno, bannerList)!=-1) {
2237                $this.find(".ad-tile").append('<div class="content-inert"><button type="button" class="content-buttons display has-tip" title="삽입된배너" data-tooltip><i class="icon-tv"><span class="show-for-sr">삽입된배너</span></i></button></div>');
2238            }
2239        });
2240    }
2241    
2242    // 배너 등록하기
2243    ,valid_multi:function(form) {
2244        if(form.title.value == '') {
2245            alert('제목을 입력하세요.');
2246            form.title.focus();
2247            return false;
2248        }
2249
2250        if (form.column_num.value>9) {
2251            alert("열수는 1~9까지만 입력할 수 있습니다.");
2252            form.column_num.focus();
2253            return false;
2254        }
2255
2256        if (form.row_num.value>9) {
2257            alert("행수는 1~9까지만 입력할 수 있습니다.");
2258            form.row_num.focus();
2259            return false;
2260        }
2261
2262        if (form.scroll_num.value>9) {
2263            alert("스크롤수는 1~9까지만 입력할 수 있습니다.");
2264            form.scroll_num.focus();
2265            return false;
2266        }
2267
2268        if($('.banner-activity-list').length-1<=0) {
2269            alert('배너를 하나 이상 추가하셔야 합니다.');
2270            return false;
2271        }
2272
2273        return true;
2274    }
2275
2276    // 멀티 기능성 배너 이벤트 로드
2277    ,bannerLoad:function() {
2278        $('.banner-multi-box').each(function() {
2279            var $effectType = $(this).attr("data-effect-type"),
2280                $rowNum = $(this).attr("data-row-num")||1,
2281                $colNum = $(this).attr("data-column-num")||1,
2282                $scrollNum = $(this).attr("data-scroll-num")||1,
2283                $moveDisplay = $(this).attr("data-move-display")||'none',
2284                $autoplay = $(this).attr("data-autoplay")||'N',
2285                $autoplaySpeed = $(this).attr("data-autoplay-speed")||5,
2286                $speed = $(this).attr("data-speed")||300,
2287                $random = $(this).attr("data-random")||'N',
2288                $bannerMultiBoxHtml = $(this);
2289                
2290                // 예약배너이거나 종료 배너일 경우 제외 처리.
2291                if(location.href.indexOf('/edit/adminSection.html')<0) {
2292                    $(this).find(".slick-slide").each(function(){
2293                        if($(this).find('.banner_box').length<=0) {
2294                            //$bannerMultiBoxHtml.find(".slick-slide").eq($(".slick-slide", $bannerMultiBoxHtml).index(this)).remove();
2295							$(this).remove();
2296                        }
2297                    });
2298                }
2299
2300            if ($effectType!="none") {
2301                var totalSlide=$(this).find(".slick-slide").length||0,
2302					slideCount=$effectType=="horizon"?(totalSlide/Number($rowNum))||0:totalSlide,
2303					randomStart=Math.floor(Math.random()*slideCount);
2304                randomStart = ($random=="Y") ? randomStart : 0;
2305
2306                var slickParam = {};
2307                slickParam.prevArrow = '<button type="button" class="roll-btns btn-prev"><i class="icon-angle-left-thin"><span class="show-for-sr">prev</span></i></button>';  // 이전버튼
2308                slickParam.nextArrow = '<button type="button" class="roll-btns btn-next"><i class="icon-angle-right-thin"><span class="show-for-sr">next</span></i></button>'; // 다음버튼
2309                slickParam.infinite = true;                                                                                                                     // 무한 넘기기
2310                slickParam.draggable = false;                                                                                                                   // 제스처(모바일용)
2311
2312                switch ($effectType) {
2313                    case "vertical":
2314                        slickParam.slidesToShow = parseInt($rowNum,10);
2315                        slickParam.vertical = true;
2316                        slickParam.verticalSwiping = true;
2317                        if ($random=="Y"&&totalSlide>parseInt($rowNum,10)) slickParam.initialSlide = randomStart;
2318                        break;
2319                    case "horizon":
2320                    default:
2321                        slickParam.slidesToShow = parseInt($colNum,10);
2322                        if (parseInt($rowNum,10)>1) slickParam.rows = parseInt($rowNum,10);
2323                        if ($random=="Y") slickParam.initialSlide = randomStart;
2324                        break;
2325                }
2326
2327                slickParam.slidesToScroll = parseInt($scrollNum,10);
2328                slickParam.arrows = ($moveDisplay=="arrow"&&bannerpopMulti.vars.$edit_mode!="delete")?true:false;
2329                slickParam.dots = ($moveDisplay=="dot"&&bannerpopMulti.vars.$edit_mode!="delete")?true:false;
2330                slickParam.dotsClass = "auto-pager";
2331                slickParam.autoplay = ($autoplay== "Y")?true:false;
2332                slickParam.autoplaySpeed = ($autoplay== "Y")?parseInt($autoplaySpeed,10)*1000:0;
2333                slickParam.speed = parseInt($speed, 10);
2334                slickParam.centerMode = false;
2335                slickParam.variableWidth = false;
2336                slickParam.focusOnSelect = true;
2337                //console.log(slickParam);
2338
2339                $(this).slick(slickParam);
2340            } else {
2341                if ($random=="Y") shuffle($(this));
2342            }
2343
2344            function shuffleArray(d) {
2345                for (var c = d.length - 1; c > 0; c--) {
2346                    var b = Math.floor(Math.random() * (c + 1));
2347                    var a = d[c];
2348                    d[c] = d[b];
2349                    d[b] = a;
2350                }
2351                return d;
2352            }
2353
2354            function shuffle(target){
2355                var $box = $(target).children(".slick-slide-none")
2356                    ,$container = $box.children(".row")
2357                    ,$li = $box.find(".columns")
2358                    ,total = $li.length
2359                    ,tmp = [];
2360
2361                for(var i=0;i<total;i++) tmp.push(i);
2362
2363                $container.empty();
2364                setTimeout(
2365                    shuffleArray(tmp).forEach(function(a,b){
2366                        var $bannerBoxs=$li[a].querySelectorAll(".banner_box")
2367                            ,length=$bannerBoxs.length
2368                            ,div=document.createElement("div");
2369                        for(var i=0;i<length;i++){
2370                            div.appendChild($bannerBoxs[i]);
2371                            div.className = "columns";
2372                        }
2373                        $container.append(div);
2374                    })
2375                ,0);
2376            }
2377        });
2378    }
2379};
2380
2381/* ****************************************** */
2382/* /script/resizePhoto.js					  */
2383/* ****************************************** */
2384
2385function resizePhoto() {	
2386
2387	var $_container = $('#article-view-content-div');
2388	var articleViewDivWidth = $_container.width();
2389	
2390	$_container.find('img').each(function(e){
2391		if($(this).closest('figure').length) {
2392			var ViewimageObj = new Image();
2393			var $_thisImgObj = $(this);
2394			ViewimageObj.src = $(this).attr("src");
2395			ViewimageObj.onload = function() {
2396				imageWidth = this.width;
2397				if(articleViewDivWidth <= imageWidth) {
2398					$_thisImgObj.closest('figure').addClass('bigsize');
2399				}
2400			};
2401
2402		}
2403	});	
2404
2405	$_container.on('click', 'figure.bigsize', function(e){
2406		$('<form action="/news/userArticlePhoto.html" method="POST"><input type="hidden" name="src" value="'+$(this).find("img").attr('src')+'"></form>').appendTo('body').submit();
2407	})
2408	.on('click', 'figure.bigsize figcaption', function(e){
2409		e.preventDefault();
2410		e.stopPropagation();
2411	});
2412}
2413
2414/* ****************************************** */
2415/* /script/floating.banner.js                 */
2416/* ****************************************** */
2417$(function() {
2418	$(window).scroll(function() {
2419		
2420		if(!($('#floating_banner_left').length || $('#floating_banner_right').length)) return false;
2421		
2422		var floatBannerLeft = $('#floating_banner_left'),
2423			floatBannerRight = $('#floating_banner_right'),
2424			
2425			HeadHeight = $('#user-header').height(),
2426			footerBoxTop = $('#user-footer').offset().top,
2427			footerBoxHeight = $('#user-footer').height(),
2428
2429			scrollTop = $(window).scrollTop(),
2430
2431			flBnLHeight = floatBannerLeft.height(),
2432			flBnRHeight = floatBannerRight.height(),
2433
2434			ahtHeight = $('.aht-wrapper').height(),
2435
2436			flBnLscrollLimit = footerBoxTop - flBnLHeight - HeadHeight - floatBannerLeft.data('down-margin'),
2437			flBnLscrollLimitChk = flBnLscrollLimit + footerBoxHeight + floatBannerLeft.data('down-margin'),
2438			flBnRscrollLimit = footerBoxTop - flBnRHeight - HeadHeight - floatBannerRight.data('down-margin'),
2439			flBnRscrollLimitChk = flBnRscrollLimit + footerBoxHeight + floatBannerRight.data('down-margin'),
2440
2441			flBnLscrollTop = scrollTop - HeadHeight + ahtHeight + floatBannerLeft.data('top-margin'),
2442			flBnRscrollTop = scrollTop - HeadHeight + ahtHeight + floatBannerRight.data('top-margin');
2443
2444		if(floatBannerLeft.data('scroll') == 'y'){
2445			if(floatBannerLeft.data('duration') > 0) floatBannerLeft.stop();
2446			if(scrollTop < HeadHeight) floatBannerLeft.animate({top: '0px'}, floatBannerLeft.data('duration'), 'linear');
2447			else if(scrollTop >= flBnLscrollLimitChk) floatBannerLeft.animate({top:flBnLscrollLimit + 'px'}, floatBannerLeft.data('duration'), 'linear');
2448			else if(scrollTop >= HeadHeight) floatBannerLeft.animate({top:flBnLscrollTop + 'px'}, floatBannerLeft.data('duration'), 'linear');
2449		}
2450
2451		if(floatBannerRight.data('scroll') == 'y'){
2452			if(floatBannerRight.data('duration') > 0) floatBannerRight.stop();
2453			if(scrollTop < HeadHeight) floatBannerRight.animate({top: '0px'}, floatBannerRight.data('duration'), 'linear');
2454			else if(scrollTop >= flBnRscrollLimitChk) floatBannerRight.animate({top:flBnRscrollLimit + 'px'}, floatBannerRight.data('duration'), 'linear');
2455			else if(scrollTop >= HeadHeight) floatBannerRight.animate({top:flBnRscrollTop + 'px'}, floatBannerRight.data('duration'), 'linear');
2456		}
2457	});
2458});
2459
2460/* ****************************************** */
2461/* /script/mosaic.js					  	*/
2462/* ****************************************** */
2463
2464function mosaic_autobox(data) {
2465	var $_container		= $(data[0].container);
2466	var autoplay		= data[0].autoplay;
2467	var autotime		= data[0].autotime;
2468	var temp_autoplay	= autoplay;
2469	var totalcount		= $_container.find('ul.auto-nav > li').length;
2470	var point			= 0;
2471	
2472	$_container.on('mouseenter', '.auto-cursor', function(e){
2473		mosaic_cmd('current', $(this).index());
2474	});
2475
2476	$_container.on('mouseenter', function(e){
2477		if(autoplay) temp_autoplay = false;
2478	}).on('mouseleave', function(e){
2479		if(autoplay) temp_autoplay = true;
2480	});
2481
2482	if(autoplay) {
2483		var rolling = window.setInterval(function () {
2484			if(temp_autoplay) mosaic_cmd('next', 0);
2485		}, autotime);
2486	}
2487
2488	function mosaic_cmd(mode, current_point) {
2489		
2490		if(mode == "prev") {
2491			point -= 1;
2492			if(point < 0) point = totalcount - 1;
2493		}else if(mode == "next") {
2494			point += 1;
2495			if(point >= totalcount) point = 0;
2496		}else if(mode == "current") {
2497			point = current_point;
2498		}
2499
2500		$_container.find('ul.auto-container > li').eq(point).show().siblings().hide();
2501		$_container.find('ul.auto-nav > li').eq(point).addClass('active').siblings().removeClass('active');
2502
2503		if(point < 2){
2504			$_container.find('ul.auto-container').css({"left":"33.333333%","top":"33.333333%"});
2505		} else if(point < 4 && point >= 2) {
2506			$_container.find('ul.auto-container').css({"left":"0px","top":"33.333333%"});
2507		} else if(point < 6 && point >= 4) {
2508			$_container.find('ul.auto-container').css({"left":"0px","top":"0px"});
2509		} else if(point >= 6) {
2510			$_container.find('ul.auto-container').css({"left":"33.333333%","top":"0px"});
2511		}
2512
2513		return false;
2514	}
2515}
2516
2517/* ****************************************** */
2518/* /script/newsAutoCall.js					  */
2519/* ****************************************** */
2520
2521function fn_articleAutoCall(mode, cycle) {
2522
2523	var autoCallMode	= mode;
2524	var autoCallCycle	= 1000*60*cycle;
2525	var _autoCallWatch  = setInterval(action, autoCallCycle);
2526
2527	// DESK중복수정이면 초기 1회 바로실행.
2528	if(autoCallMode == "desk") action();
2529
2530	function action() {
2531		if(autoCallMode == "save") {
2532			if($('.auto-save', '#admin-aside').length > 0 && $('input:hidden[name="autoSave"]', '#newsWriteForm').val() != "") $('.auto-save', '#admin-aside').show();  
2533			TxRx("/news/articleAutoSave.ajax.php");
2534		}
2535		else if(autoCallMode == "desk")		TxRx("/news/articleAutoDesk.ajax.php");
2536		else								stop();
2537	}
2538
2539	function TxRx(url) {
2540
2541		$.ajax({
2542			type: "post",
2543			dataType: "json",
2544			url:url,
2545			data:$('#newsWriteForm').serialize(),
2546			success: function(data) {
2547				console.log(data[1]);
2548			},
2549			error: function(error, request) {
2550				console.log("자동콜에러 - code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
2551				stop();
2552			}
2553		}).always(function() {
2554			if($('.auto-save', '#admin-aside').length > 0) $('.auto-save', '#admin-aside').fadeOut(1500);
2555		});
2556	}
2557
2558	function stop() {
2559		clearInterval(_autoCallWatch);
2560		console.log(autoCallMode + '스톱');
2561	}
2562}
2563
2564/* ****************************************** */
2565/* 기존	common.js							  */
2566/* ****************************************** */
2567
2568/*---------------------------------------------------------------------------------------------
2569                                      JAVASCRIPT CODE
2570  ---------------------------------------------------------------------------------------------
2571	function name						| description				| use process
2572  ---------------------------------------------------------------------------------------------
2573	setCookie(쿠키명, 값, 유효기간(일))	| 							| 쿠키생성
2574	getCookie(쿠키명)					| 							| 쿠키가져오기
2575  ---------------------------------------------------------------------------------------------*/
2576
2577// 쿠키 생성
2578function setCookie(cName, cValue, cDay, cDomain){
2579    var expire = new Date();
2580    expire.setDate(expire.getDate() + cDay);
2581    var cookies = cName + '=' + escape(cValue) + '; path=/; '; // 한글 깨짐을 막기위해 escape(cValue)를 합니다.
2582    if(typeof cDay!='undefined')    cookies += 'expires=' + expire.toGMTString() + '; ';
2583    if(typeof cDomain!='undefined') cookies += "domain=" + cDomain + ';';
2584    else {
2585        var host=(typeof SITE_DOMAIN!='undefined')?SITE_DOMAIN:window.location.host
2586            ,domain='.'+host.replace(/^http(s)?:\/\//i,'').replace(/^(www|cms|slv|cdn|m)\./i,'');
2587        cookies += "domain=" + domain + ';';
2588    }
2589    document.cookie = cookies;
2590}
2591
2592// 쿠키 가져오기
2593function getCookie(cName) {
2594	cName = cName + '=';
2595	var cookieData = document.cookie;
2596	var start = cookieData.indexOf(cName);
2597	var cValue = '';
2598	if(start != -1){
2599		start += cName.length;
2600		var end = cookieData.indexOf(';', start);
2601		if(end == -1)end = cookieData.length;
2602		cValue = cookieData.substring(start, end);
2603	}
2604	return unescape(cValue);
2605}
2606
2607// 쿠키 지움
2608function delCookie(cName) {
2609    var today = new Date();
2610    today.setTime(today.getTime() - 1);
2611    var value = getCookie(cName);
2612    if(value != "") {
2613        var host=(typeof SITE_DOMAIN!='undefined')?SITE_DOMAIN:window.location.host
2614            ,domain='.'+host.replace(/^http(s)?:\/\//i,'').replace(/^(www|cms|slv|cdn|m)\./i,'')
2615            ,cookies = cName + "=" + value + "; path=/; expires=" + today.toGMTString() + '; ' + "domain=" + domain + ';';
2616        document.cookie = cookies;
2617    }
2618}
2619
2620
2621/*---------------------------------------------------------------------------------------------
2622                                      JAVASCRIPT CODE
2623  ---------------------------------------------------------------------------------------------
2624	function name						| description				| use process
2625  ---------------------------------------------------------------------------------------------
2626	checkMsgLength()					| 입력된 문자열 길이 검사			| 기사 댓글
2627	calculateMsgLength()				| 문자열 길이 반환				| 기사 댓글
2628	assertMsgLength()					| 문자열 길이만큼 잘라 변환		| 기사 댓글
2629  ---------------------------------------------------------------------------------------------*/
2630
2631// 문자열길이 검사
2632function checkMsgLength(frm, id, lenStr) {
2633	var length = calculateMsgLength(document.getElementById(frm).value);
2634	document.getElementById(id).innerHTML = length;
2635	if (length > lenStr) {
2636		alert("최대 "+lenStr+" 바이트까지 남기실 수 있습니다.\r\n초과된 " + (length - lenStr) + "바이트는 자동으로 삭제됩니다.");
2637		document.getElementById(frm).value = assertMsgLength(document.getElementById(frm).value, lenStr, id);
2638	}
2639}
2640
2641//문자열길이 반환
2642function calculateMsgLength(message) {
2643	var nbytes = 0;
2644
2645	for (i=0; i<message.length; i++) {
2646		var ch = message.charAt(i);
2647
2648		if (escape(ch).length > 4) {
2649			nbytes += 2;
2650		} else if (ch != "\r") {
2651			nbytes++;
2652		}
2653	}
2654
2655	return nbytes;
2656}
2657
2658//문자열 길이만큼 잘라 변환
2659function assertMsgLength(message, maximum, id) {
2660	var inc = 0;
2661	var nbytes = 0;
2662	var msg = "";
2663	var msglen = message.length;
2664
2665	for (i=0; i<msglen; i++) {
2666		var ch = message.charAt(i);
2667
2668		if (escape(ch).length > 4) {
2669			inc = 2;
2670		} else if (ch != "\r") {
2671			inc = 1;
2672		}
2673
2674		if ((nbytes + inc) > maximum) {
2675			break;
2676		}
2677
2678		nbytes += inc;
2679		msg += ch;
2680	}
2681
2682	document.getElementById(id).innerHTML = nbytes;
2683	return msg;
2684}
2685
2686
2687// 관리자에서 기사본문 복사하여 블로그에 퍼 나를시 링크가 관리자 링크로 되어 이를 보완
2688function avReplaceImgUrlOnCopy(){
2689	var $aView=document.querySelector('#article-view')
2690		,chgUrl=CDN_DOMAIN||SITE_DOMAIN;
2691
2692	if(!$aView || !chgUrl) return ;
2693	$aView.addEventListener("copy", function(e){
2694		Array.prototype.slice.call(e.currentTarget.querySelectorAll("img,a[href^='/news/download.php']")).map(function($o, i){
2695			if($o.tagName.toLowerCase() == 'a'){		// download link
2696				var href=$o.getAttribute("href");
2697				$o.href=SITE_DOMAIN+href;	
2698			}else{										// image
2699				var src=$o.getAttribute("src");
2700				if(!/^http(s)?:\/\//i.test(src)) $o.src=chgUrl+src;	
2701			}
2702		});
2703	});
2704}
2705
2706/*---------------------------------------------------------------------------------------------
2707                                      JAVASCRIPT CODE
2708  ---------------------------------------------------------------------------------------------
2709	function name						| description				| use process
2710  ---------------------------------------------------------------------------------------------
2711	articleHeader()						| 기사뷰 헤더 네비			| 기사뷰 헤더 네비
2712  ---------------------------------------------------------------------------------------------*/
2713
2714var articleHeader = {
2715
2716	// 헤더 네비게이션 생성
2717	setScroll:function(){		
2718		jQuery(window).scroll(function() {
2719			if (jQuery(this).scrollTop() > 300) {
2720				jQuery('#sticky-header').addClass('scroll');
2721			} else {
2722				jQuery('#sticky-header').removeClass('scroll');
2723			}
2724		});			
2725	},
2726	
2727
2728	// 기사이동
2729	move:function(mod, order_type, order_value, section_code, sub_section_code, serial_code){
2730		jQuery.post( "ajaxGetForwardIdxno.php", { mod: mod, order_type:order_type, order_value: order_value, section_code: section_code, sub_section_code: sub_section_code, serial_code: serial_code }, function( f_idxno ) {
2731			
2732			if(f_idxno){
2733				location.href = '/news/articleView.html?idxno='+f_idxno				
2734			}else{
2735				alert('기사가 존재하지 않습니다');
2736			}
2737			
2738		});
2739	}
2740	
2741}
2742
2743
2744/*---------------------------------------------------------------------------------------------
2745                                      JAVASCRIPT CODE
2746  ---------------------------------------------------------------------------------------------
2747	function name						| description				| use process
2748  ---------------------------------------------------------------------------------------------
2749  	bbsPrint(idxno)						| 게시물 인쇄창 오픈				| 게시물 인쇄창 오픈
2750	articlePrint(idxno)					| 인쇄창 오픈					| 인쇄창 오픈
2751	articleMail(idxno)					| 메일보내기창 오픈				| 메일보내기창 오픈
2752	articleErr(idxno)					| 오류신고창 오픈				| 오류신고창 오픈
2753	articleSingo(idxno)					| 댓글신고창 오픈				| 댓글신고창 오픈
2754	fn_guid()							| (랜덤)고유아이디 생성			| (랜덤)고유아이디 생성 
2755  ---------------------------------------------------------------------------------------------*/
2756
2757//인쇄창 오픈
2758function bbsPrint( idxno, ps ) {
2759    var ps_str = "";
2760    if(ps != "") ps_str = "&ps="+ps;
2761    window.open('/bbs/bbsPrint.html?idxno='+idxno+ps_str, 'bbsPrint', 'width=660,height=500,scrollbars=yes');
2762}
2763
2764// 인쇄창 오픈
2765function articlePrint( idxno ) {
2766	window.open('/news/articlePrint.html?idxno='+idxno, 'articlePrint', 'width=660,height=500,scrollbars=yes');
2767}
2768
2769// 메일보내기창 오픈
2770function articleMail( idxno ) {
2771	window.open('/news/articleMail.html?idxno='+idxno, 'articleMail', 'width=660,height=500,scrollbars=yes');
2772}
2773
2774// 오류신고창 오픈
2775function articleErr( idxno ) {
2776	window.open('/news/articleErr.html?idxno='+idxno, 'articleErr', 'width=660,height=500,scrollbars=yes');
2777}
2778
2779// 댓글신고창 오픈
2780function articleSingo( idxno ) {
2781	window.open('/news/articleSingo.html?idxno='+idxno, 'articleSingo', 'width=660,height=500,scrollbars=yes');
2782}
2783
2784//고유값생성 (기사등록 관련기사 띄울때 사용)
2785function fn_guid() {
2786    function s4() {
2787        return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
2788    }
2789    return s4() + s4() + s4() + s4() + s4() + s4() + s4() + s4();
2790}
2791
2792/*****************************************************************************
2793*게시판 카테고리 설정
2794*****************************************************************************/
2795var bbsCfg={
2796
2797	 // 카테고리 셋팅
2798     setCategory:function() {	
2799
2800		 // 추가
2801        $('#admin-content').on('click', '#btn_category_add, .btn_category_delete, .btn_category_modify', function(e){
2802
2803			var _this = this
2804			,$this = $(_this)
2805			,isAddButton = $this.is("#btn_category_add")
2806			,isDltButton = $this.is(".btn_category_delete")
2807			,isModalButton = $this.is(".btn_category_modify")
2808			,$categoryName = $('#category_name').val()
2809			,categoryArr = $categoryName.split(',');
2810
2811			if(isAddButton){ // 추가
2812				categoryArr =categoryArr.filter(Boolean);
2813				for (var i in categoryArr) {
2814					var category = categoryArr[i];
2815	
2816					// 필수 항목 체크
2817					if(!category || category == "") {
2818						alert("카테고리명을 정확하게 입력해주세요.");
2819						return false;
2820					}
2821
2822					// 중복체크
2823					if($('#category-div').find("input[class='category'][value='"+category+"']").length>0) {
2824						alert(category+' 카테고리는 존재합니다.');
2825						$('#category_name').val('');
2826						return false;
2827					}
2828					
2829					var _time = (Math.random()*new Date().getTime()).toFixed(0);
2830				    var html='';
2831					   html += "<li class='add-category-entity'> ";
2832					   html += "	<input type='hidden' name='category["+_time+"]' class='category' value='"+category+"'>";
2833					   html += "	<span class='button nd-pink small default-cursor btn_category_modify' data-cate-idxno='"+_time+"'><i class='icon-wrench'>&nbsp;</i>"+category+"</span><button type='button' class='button secondary small btn_category_delete' data-cate-idxno='"+_time+"' ><i class='icon-trash-o'></i></button>";
2834					   html += "</li>";
2835					$('#add-category').append(html); 
2836				}
2837
2838				//초기화
2839				$('#category_name').val('');
2840
2841			} else if(isModalButton) { // 수정 모달 
2842
2843				var $this = $(this)
2844					,$form = $('#form_bbs_category')
2845					,$item = $this.closest(".add-category-entity")
2846					,$span = $this.closest(".btn_category_modify")
2847					,cate_idxno = $span.data("cate-idxno")
2848					,category = $item.find("input:hidden[name='category["+cate_idxno+"]']").val();
2849
2850				$form.find('input:hidden[name="cate_idxno"]').val(cate_idxno);
2851				$form.find('input:text[name="category"]').val(category);
2852
2853				$('#categoryAddModal').foundation('open');
2854				
2855				// 수정 
2856				$form.on('click', '.chk', function(e){
2857					if($item) { 
2858						var cate_idxno= $form.find('input:hidden[name="cate_idxno"]').val()
2859						   ,category = $form.find('input[name="category"]').val();
2860
2861						if($form.find('[name="category"]').val() == ""){
2862							alert('카테고리 명을 정확하게 입력해주세요');
2863							$form.find('[name="category"]').focus();
2864							return false;
2865						}
2866							
2867						$item.find("input:hidden[name='category["+cate_idxno+"]']").val(category);
2868						$item.find("span[data-cate-idxno='"+cate_idxno+"']").html("<i class='icon-wrench'>&nbsp;</i>"+category).attr("data-category",category);
2869					}
2870
2871					$('#categoryAddModal').foundation('close');
2872				});
2873
2874			} else if(isDltButton) {  //삭제		
2875				var cate_idxno = $(this).closest(".btn_category_delete").data("cate-idxno");
2876				if(!window.confirm("삭제하시겠습니까?")) return false;
2877				$.post(	"/bbs/axBbsCategory.php"
2878						,{mode:"categoryChk",cate_idxno:cate_idxno}
2879						,function(data, rst){
2880							if(data.result === "success"){
2881								$this.closest(".add-category-entity").fadeOut("fast",function(){$(this).remove();});	
2882							}else alert(decodeURIComponent(data.msg));
2883
2884				},"json");	
2885				return false;		
2886			}
2887		});
2888	 }
2889
2890	 //정렬
2891	,evtSortableCategory:function(){
2892		var $box = $("#add-category"),
2893			table_name = $box.attr("data-table");
2894			
2895		$box.sortable({
2896			placeholder: "ui-state-highlight"
2897			,forcePlaceholderSize:true
2898			,update:function(event, ui){
2899			// 저장안함
2900			}
2901		});
2902	}
2903
2904 	//카테고리 이동
2905 	,categoryMove:function(checkBoxIdxno){
2906
2907        // 전체선택
2908		$("#all-dummy").click(function(e){
2909			$('input:checkbox[name="bbs_idxno[]"]', '#bbs_table').each(function(i){
2910				this.checked = $('input:checkbox[name="all_dummy"]', '#bbs_table').is(':checked');
2911			});
2912		});
2913
2914		// 추가
2915		$('.bbs-skin').on('click', '.categoryModalBtn', function(e){
2916			var data=$(checkBoxIdxno).filter(function(i){ return this.checked?true:false; }).map(function(a,b){ return b.value; }).get();
2917			if(data.length<=0){
2918				alert("카테고리 이동 할 게시물을 선택해주세요.");
2919				return false;
2920			}
2921			//console.log(data);
2922			$('#categoryMoveModal').foundation('open');
2923			
2924			$('#categoryMoveForm').on('click', '.category_move_btn', function(e){
2925				var to_category = $('#categoryMoveForm').find('#toCategory option:selected').val(),
2926					table_name =  $('#categoryMoveForm').find('input:hidden[name="table_name"]').val();
2927
2928				if(!window.confirm("카테고리 이동 할 게시물로 변경하시겠습니까?")) return false;
2929				$.post("/bbs/axBbsCategory.php"
2930						,{mode:"bbsCategoryMove","bbs_idxno[]":data,"to_category":to_category,"table_name":table_name}
2931						,function(data,rst){
2932							console.log(data);
2933							if(data.result!="success"){
2934								alert(data.msg||"문제가 생겼습니다. 잠시후 다시 시도 하여 주세요.");
2935								return false;
2936							}
2937							//alert("카테고리 이동이 완료되었습니다.");
2938							location.reload(true);
2939						},"json");
2940
2941				return false;
2942			});
2943		});
2944    }
2945}
2946
2947/*****************************************************************************
2948* 다중섹션설정
2949*****************************************************************************/
2950var multiSection ={
2951
2952	// 섹션로드
2953	sectionLoad:function() {
2954		
2955		$('#admin-content').on('change', '.add-section-select', function(e){
2956			var tp = $(this).data('type');
2957			var code = $(this).val();
2958			var $_obj = $('#add_section');
2959
2960			if(tp == 1) multiSection.changeSectionCode(tp, code);
2961			else if(tp == 2) {
2962				if($(this).val() == "") {
2963					multiSection.changeSectionCode(1, $_obj.val());
2964				}
2965				else multiSection.changeSectionCode(tp, code);
2966			}
2967		});
2968
2969		//삭제
2970		$('#section-div').on('click', '.delete-button', function(e){
2971			var tp = $(this).data('type');
2972			$(this).closest('.'+tp+'-section-entity').remove();
2973		});
2974	}
2975
2976	//섹션 코드 호출
2977	,changeSectionCode:function(tp,code) {
2978
2979		var $_subsection = $('#add_subsection');
2980		var $_serial = $('#add_serial');
2981	
2982		$.ajax({
2983			type: "post",
2984			dataType: "json",
2985			url: "/news/changeSectionCode.ajax.php",
2986			data:{tp:tp, code:code},
2987			success: function(data) {
2988				if(data[0] == "Y"){
2989					if(tp == 1){
2990						$_subsection.html(data[1]);
2991						$_serial.html(data[2]);
2992					}else if(tp == 2){
2993						$_serial.html(data[2]);
2994					}
2995				}
2996			},
2997			error: function(error, request) {
2998				alert('error!!!');
2999				console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
3000			}
3001		});
3002	
3003		return false;
3004	}
3005
3006	// 자동박스 섹션추가&제외
3007	,addSectionCode:function() {
3008
3009		// 섹션 단락 노출 여부 
3010		if($('.add-section-entity').length > 0) $('#section-div').show();
3011		else  $('#section-div').hide();
3012
3013		$('#admin-content').on('click', '#sectionBtn', function(e){
3014
3015			// 추가 or 제외
3016			var tp = $(this).data('type');
3017
3018			//1차섹션
3019			var sectioncode = $('#add_section option:selected').val();
3020			var sectionname = $('#add_section option:selected').text();
3021			//2차섹션
3022			var subsectioncode = $('#add_subsection option:selected').val();
3023			var subsectionname = $('#add_subsection option:selected').text();
3024			//3차섹션
3025			var serialcode = $('#add_serial option:selected').val();
3026			var serialname = $('#add_serial option:selected').text();
3027
3028			//1차섹션을 선택 안했을시...
3029			if(!sectioncode || sectioncode == "") {
3030				alert("추가할 섹션을 선택해주세요.");
3031				return false;
3032			}
3033
3034			//  중복코드 체크
3035			var addSecCode = sectioncode;
3036			if(subsectioncode) addSecCode += '>'+subsectioncode;
3037			if(serialcode) addSecCode += '>'+serialcode;
3038			
3039			var duplicateChk = false;    
3040
3041			// 동일한 섹션 구성이 추가&제외 동시 추가 제어
3042			$('.input_setion_data').each(function(){
3043				if( $(this).val() == addSecCode) {
3044					alert('이미 중복 된 코드가 존재합니다.');
3045					eixt;
3046					duplicateChk = true;
3047					return false;
3048				}
3049			});
3050			
3051			if(tp == 'add') {
3052				//전체가 선택 된 경우 단일 선택 제어
3053				$('.add_section_data').each(function(){
3054					if($(this).val() == "ALL"){
3055						alert('전체를 선택하실 경우 단일 섹션 선택은 하실 수 없습니다.');
3056						duplicateChk = true;
3057						return false;
3058					}
3059				});
3060
3061				// 단일 섹션 선택시 전체 선택 제어
3062				if($('.add-section-entity').length > 0) {
3063					if(addSecCode == "ALL"){
3064						alert('단일 섹션이 이미 선택되어 있습니다. 전체는 선택하실 수 없습니다.');
3065						duplicateChk = true;
3066						return false;
3067					}
3068				}
3069
3070			} else if(tp == "exc") { 
3071
3072				if(addSecCode == "ALL"){
3073					alert('제외 섹션으로는 전체를 선택하실 수 없습니다.');
3074					duplicateChk = true;
3075					return false;
3076				} else {
3077
3078					if($('.add-section-entity').length > 0) {
3079						$('.add_section_data').each(function(){
3080							if($(this).val().indexOf(addSecCode) != -1) { //포함할 경우 
3081								alert('추가 섹션에 포함 된 1차 섹션으로 제외할 수 없습니다. ');
3082								duplicateChk = true;
3083								return false;
3084							}
3085							if($(this).val() != "ALL"){
3086								if(addSecCode.indexOf(">") == -1) {
3087									alert('제외 섹션으로 처리할 수 없습니다.');
3088									duplicateChk = true;
3089									return false;
3090								}
3091							}
3092						});
3093					}
3094				}
3095
3096				if($('.add-section-entity').length == 0) {
3097					alert('추가 섹션을 먼저 선택해주세요.');
3098					duplicateChk = true;
3099					return false;
3100				}
3101			}
3102			
3103			if(duplicateChk) return false;
3104
3105			// 추가 될 경우 노출 
3106			$('#section-div').show();
3107
3108			var title = "<span class='hollow button nd-pink default-cursor'>"+sectionname+"</span>";
3109			if(subsectioncode || subsectioncode != "") title += "<span class='hollow button warning default-cursor'>"+subsectionname+"</span>";
3110			if(serialcode || serialcode != "") title += "<span class='hollow button alert default-cursor'>"+serialname+"</span>";
3111
3112			var html='';
3113			html += "<div class='button-group small "+tp+"-section-entity'>"; 
3114			html += "	<input type='hidden' name='"+tp+"_section_data[]' class='"+tp+"_section_data input_setion_data' value='"+addSecCode+"'>";
3115		//	html += "	<input type='hidden' class='"+tp+"-chk-sec' value='"+addSecCode+"'>";
3116			html += title;
3117			html += "	<button type='button' class='button nd-white tiny delete-button' data-type='"+tp+"' title='"+sectionname+" 삭제'><i class='icon-trash-o'></i><span class='show-for-sr'>삭제</span></button>";
3118			html += "</div>";
3119							
3120			$('#'+tp+'-section').append(html);  
3121
3122			//.attr("data-code",category)
3123			
3124		});
3125	}
3126
3127	//전송
3128	,multiSectionSumbit:function(form)
3129	{
3130	
3131	   if(!form.description.value)
3132	   {
3133		   alert("리스트명을 입력해주세요.");
3134		   description.focus();
3135		   return false;
3136	   }
3137
3138	   if($('.add-section-entity').length == 0) {
3139			alert("연결 섹션을 선택해주세요.");
3140			return false;
3141	   }
3142
3143		if(confirm("선택한 섹션을 하나의 리스트로 구성합니다. \n정말로 실행하시겠습니까?")) return true;
3144		else return false;
3145
3146	}
3147	
3148}
3149
3150/* ****************************************** */
3151/* /script/app.js	(파운데이션 실행파일			  */
3152/* ****************************************** */
3153
3154$(function(){ 
3155	$(document).foundation();    
3156});
3157
3158/*****************************************************************************
3159*기사 카운트 
3160*****************************************************************************/
3161var _statistics={
3162	articleCookieCount:function(article_idxno){
3163		if(!article_idxno) return false;
3164		
3165		var cookieRestore = false
3166			,articleIdxno = article_idxno
3167			,articleUniqView = _statistics.getCookie('___AUV')
3168			,dateTime = new Date();
3169
3170		var regexp = new RegExp("_"+articleIdxno+"\.(\\d{10})x","i");
3171		var dataArr = articleUniqView.match(regexp); 
3172
3173		if(dataArr !== null){
3174			var limitTime =  dateTime.setHours(dateTime.getHours() - 1);
3175			limitTime =  Math.floor(limitTime / 1000);
3176			if (limitTime > dataArr[1]){
3177				articleUniqView = articleUniqView.replace(dataArr[0], '');
3178				cookieRestore = true;
3179			}
3180		} else cookieRestore = true;
3181
3182		if(cookieRestore === true) {  
3183			var newData = '_'+articleIdxno+'.'+ Math.floor(new Date().getTime() / 1000) +'x';
3184			$.ajax({
3185				url:'/news/makeArticleUniqSave.ajax.php',
3186				type:'POST',
3187				dataType:'json',
3188				cahse: false,
3189				data: {article_idxno:articleIdxno},
3190				success:function(rst,data){
3191					if(rst.result == "success"){
3192						var tmpTotalSize = 8 + articleUniqView.length + newData.length; 
3193						if (tmpTotalSize >= 2048) articleUniqView = articleUniqView.substr(0, (articleUniqView.length - newData.length));
3194						articleUniqView = newData + articleUniqView;
3195
3196						var domain = '.'+ countDomain.replace(/^http(s)?:\/\//i,'').replace(/^(www|m)\./i,'');
3197						_statistics.setCookie("___AUV", articleUniqView.trim(), 30, domain);
3198					}
3199				},
3200				error: function(error, request) {
3201					console.log("error:"+error+"\n"+"request:"+request);
3202				}
3203			});
3204		}
3205	}
3206	,getCookie:function(name)
3207	{	
3208		name+="=";
3209		var ca = document.cookie.split(';');
3210		for(var i=0; i<ca.length; i++) {
3211			var c = ca[i];
3212			while (c.charAt(0)==' ') c = c.substring(1);
3213			if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
3214		}
3215		return "";
3216	}
3217	,setCookie:function(name, value, days, domain)
3218	{
3219		var expires = "";
3220		if(days){
3221			var date = new Date();
3222			date.setTime(date.getTime()+(days*24*60*60*1000));
3223			expires = "; expires="+date.toGMTString();
3224		}
3225		if(!domain) domain = countDomain.replace(/^http(s)?:\/\//i,'').replace(/^(www|m)\./i,'');
3226		document.cookie = name+"="+value+expires+"; path=/; " + (domain?"domain="+domain+";":"");
3227	}
3228}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.