PageSourceSearch

https://dynews1.com/script/common.js

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

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.