PageSourceSearch

https://cdn.cvinfo.com/script/common.js

js cvinfo.com collected 2026-10-05 05:10:38 UTC 92,437 bytes, 2,644 lines download raw bytes

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

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.