PageSourceSearch

https://golfdigest.co.kr/script/bannerpop.js?ver=11

js golfdigest.co.kr collected 2026-10-02 12:00:16 UTC 61,032 bytes, 1,868 lines download raw bytes

1var adWrite={
2	// php 전달 변수
3	vars:{
4		separator : "|"
5		,editId : null												// 수정할 id
6		,box : '<div class="ad-map" />'					// 생성된 박스
7		,buttons : '<div class="ad-map-btns"><div class="btn-group-vertical"><button type="button" class="btn_com btn_com_0_699 adcmb_button adcmb_modify button secondary tiny" title="수정"><i class="fa fa-link fa-fw" aria-hidden="true"></i></button><button type="button" class="btn_com btn_com_35_699 adcmb_button adcmb_delete button tiny nd-gray" title="삭제"><i class="fa fa-trash-o fa-fw" aria-hidden="true"></i></button></div></div>'		//생선된 박스의 버튼들
8		,$textBox : null
9		,act : ""												// 사진 업로드하고 이러저하게 자주 act값이 바뀌는데, 그것의 원래 값
10		,iframe : '<iframe src="about:blank" name="adc_up_frame" id="adc_up_frame" width="0" height="0" frameborder="0"></iframe>'	// upload용 iframe
11		,loadData : {}	
12	}
13
14	// 이미지 로딩되면 크기 재어오기
15	// IE만 이미지 로딩된후 이벤트가 먹어져서 크기를 제대로 재어오지 못해서 inline으로 스크립트 작성함
16	,getSizeLoadImage:function(_this)
17	{
18		var _w = _this.width
19			,_h = _this.height;
20		
21		_this.setAttribute("data-display-width", _w);
22		_this.setAttribute("data-display-height", _h);
23
24		// 이미지맵 이벤트
25		adWrite.map($(_this));
26	}
27
28	// 등록시 이벤트들
29	,evtCrtForm:function()
30	{	
31		var parents = this
32			,$type = $("#adc_crt_type_html, #adc_crt_type_file")
33			,$htmlBox = $("#adc_crt_html_box")
34			,$fileBox = $("#adc_crt_attach_file_box")
35			
36			,$popupType = $("#adc_crt_popup_type_layer, #adc_crt_popup_type_window")
37			,$layer = $("#adc_crt_popup_layer_opt_box")
38			,$window = $("#adc_crt_popup_window_opt_box")
39			
40			,$closeIcon = $("#adc_crt_popup_layer_icon")
41			,$iconBox = $("#adc_crt_popup_layer_icon_box")
42
43			,$closeExpire = $("#bottom_close_expire_label")
44			,$closeExpireBox = $("#bottom_close_expire_box")
45
46			,$attachFile = $("#adc_crt_attach_file")
47			,$previewFile = $("#adc_crt_file_image")
48			,$previewBox = $("#adc_crt_image_preview_box")
49			
50			,$max_file_size = $("#file_upload_max_size").val();
51		
52		// 입력부분 담아두기
53		this.vars.$textBox = $("#adc_crt_image_link_box");
54
55		// html, file 입력
56		$type.click(function(){
57			var isChecked = $(this).attr("value");
58
59			$htmlBox[isChecked==="HTML"?"removeClass":"addClass"]("is-hidden");
60			$fileBox[isChecked==="FILE"?"removeClass":"addClass"]("is-hidden");
61		});
62
63		// 미리보기 호출 //
64		$attachFile.change(function(){
65			var form = document.adc_form;
66
67			if (typeof (FileReader) != "undefined") {
68
69				var file = $(this)[0].files[0]
70					,regex = ['jpg', 'jpeg', 'png', 'gif', 'swf']
71					,filesize = file.size
72					,extension = file.name.split('.').pop().toLowerCase();
73
74				if(filesize > $max_file_size){
75					alert('업로드 용량이 초과되었습니다.');
76					$attachFile.val("");
77					return false;
78				}
79				
80				if((regex.indexOf(extension) > -1) === false){
81					alert('jpg, png, gif, swf 확장자만 선택하여 주세요.');
82					$attachFile.val("");
83
84					//입력시만 함정발동 예정
85					$previewBox.addClass("is-hidden");
86					return false;
87				}
88
89				if(extension == "swf"){
90					$previewBox.addClass("is-hidden");
91					return false;
92				}
93			
94				var reader = new FileReader();
95				reader.onload = function (e) {
96					var img = new Image();
97					img.src = e.target.result;
98
99					img.onload = function(){
100						$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});
101						$previewBox.removeClass("is-hidden");
102		
103						$('#size_width').val(this.width);
104						$('#size_height').val(this.height);
105		
106						$('#popup_width').val(this.width);
107						$('#popup_height').val(this.height);
108
109						// 이미지맵 이벤트
110						parents.map($previewFile);
111					}
112				}
113
114				reader.readAsDataURL(file);
115				parents.mapDeleteAll();
116			}
117		});
118
119		var $mapRadio = $("#adc_crt_image_link_total, #adc_crt_image_link_part, #adc_crt_image_link_not")
120			,$imgLinkSelect = $(".adcil_btns")
121			,$imgLink = $("#adc_crt_image_link")
122			,$imgLinkFile = $("#adc_crt_image_link_file")
123			,$selectPopup = $("#adc_crt_image_link_popup")		
124			,$btnMapRegist = $("#adc_crt_img_link_btn_regist")
125			,$linkAction = '';
126
127		// 전체 또는 이미지 맵 선택시
128		$mapRadio.click(function(){
129			var $this = $(this)		
130				,type = $this.attr("data-type");
131
132			if(type == 'total' || type == 'map'){
133
134				$("#adc_crt_image_link_box").removeClass('is-hidden');
135
136				$btnMapRegist[type==="map"?"removeClass":"addClass"]("is-hidden");
137				
138				if(type==="total") parents.mapDeleteAll();									// 전체선택일때, 이전 데이타 모두 지움
139				
140			}else{
141				$("#adc_crt_image_link_box").addClass('is-hidden');
142			}
143		});
144
145		// layer or window 선택
146		$popupType.click(function(){
147			var isChecked = $(this).attr("data-type");
148
149			$layer[isChecked==="layer"?"removeClass":"addClass"]("is-hidden");
150			$window[isChecked==="window"?"removeClass":"addClass"]("is-hidden");
151		});
152		
153		// 닫기 아이콘 클릭시 아이콘 형태 선택 박스 열게
154		$closeIcon.click(function(){
155			var $label_attr_for = $(this).attr('for')
156				,isChecked = $('#'+$label_attr_for).is(":checked");
157
158			$iconBox[isChecked===false?"removeClass":"addClass"]("is-hidden");
159		});
160		
161		// 몇일 동안 열지 않기 입력박스 열기
162		$closeExpire.click(function(){
163			var $label_attr_for = $(this).attr('for')
164				,isChecked = $('#'+$label_attr_for).is(":checked");
165
166			$closeExpireBox[isChecked===false?"removeClass":"addClass"]("is-hidden");
167		});
168
169		// 어떤형태의 링크인지 확인
170		// link, popup, file, close, day_close
171		$imgLinkSelect.click(function(){
172			var $this = $(this)
173				,type = $this.attr("data-type");
174			
175			if(type==="popup" || type==="close" || type==="day_close"){
176				$imgLink.add($imgLinkFile).addClass("is-hidden");
177				$selectPopup[type==="popup"?"removeClass":"addClass"]("is-hidden");
178			}else{
179				$imgLink[type==="link"?"removeClass":"addClass"]("is-hidden");
180				$imgLinkFile[type==="link"?"addClass":"removeClass"]("is-hidden");
181				$selectPopup.addClass("is-hidden");
182			}
183		});
184
185		$btnMapRegist.click(function(){
186
187			// 맵 등록 수정
188			var $popupSelect = $("#adc_crt_image_link_popup_select")
189				,$linkText = $("#adcil_link_text")
190				,$etcFile = $("#adcilf_attach")
191				,$linkTarget = $(".adcil_btns_link option:selected");
192
193			if(!parents.vars.editId){
194				alert('이미지에서 수정할 맵데이타를 선택하여주세요.');
195				return false;
196			}
197
198			// close, day_close 모두 등록 눌러야 저장되게...안그럼 radio클릭만으로 이전 정보 자체를 날려버림
199			var type = $(".adcil_btns:checked").attr('data-type')
200				,url = ""
201				,target = "";
202			
203			if(!type) return false;
204			if(type==="link"){
205				url = $linkText.val();
206				if(!url){
207					alert('링크를 입력하여 주세요.');
208					$linkText.focus();
209					return false;
210				}
211				
212				target = $linkTarget.val();
213			}else if(type==="popup"){
214				url = $popupSelect.val();
215				if(!url){
216					alert('팝업을 선택하여 주세요.')
217					$popupSelect.focus();
218					return false;
219				}
220			}else if(type==="file"){
221				if(!$etcFile.val()){
222					alert('파일을 선택하여 주세요.');
223					$etcFile.focus();
224					return false;
225				}
226				
227				parents.uploadAttachTmpFile();
228				
229				return false;
230			}
231			
232			parents.insertData({
233									type:type
234									,url:url
235									,target:target
236								})
237			return false;
238		});
239	}
240	
241	// 이미지맵의 파일일때 저장 
242	,uploadAttachTmpFile:function()
243	{
244		var parents = this
245			,iframe = this.vars.iframe
246			,form = document.adc_form;
247		
248		$(document.body).append(iframe);
249		
250		form.action = "/bannerpop/upload_act.php";
251		form.target = "adc_up_frame";
252		form.submit();
253	}
254	
255	// 이미지맵의 임시파일저장후 리턴 값
256	,afterUploadAttachTmpFile:function(result)
257	{
258		// 성공이던 아니던 폼은 일단 초기화함
259		this.releaseForm();
260		$("#adc_up_frame").remove();
261
262		var json = $.parseJSON(adWrite.rawurldecode(result))
263			,filename = json[0].filename;
264
265		if(!filename){
266			alert('업로드시 에러가 발생했습니다. 다시 업로드하여 주세요.');
267			return false;
268		}
269
270		this.insertData({type:"file",url:filename,target:"self",json_obj:result});
271	}
272
273	//rawurldecode
274	,rawurldecode:function(str) {
275		return decodeURIComponent((str + '')
276			.replace(/%(?![\da-f]{2})/gi, function() {
277				return '%25';
278			}));
279	}
280
281	// 이미지맵 입력폼 초기화
282	,initInsertForm:function(data)
283	{
284		var parents = this
285			,type = data.type||"link"
286			,$btns = $(".adcil_btns")
287			,$imgLink = $("#adc_crt_image_link")
288			,$imgLinkFile = $("#adc_crt_image_link_file")
289			,$selectPopup = $("#adc_crt_image_link_popup")
290			,$filebox = $("#adcilf_uploaded_file");
291		
292		//$btns.filter("[data-type='"+type+"']").prop("checked", true);
293		$btns.filter("[data-type='"+type+"']").click(); // 커스텀 radio box 라서 이렇게 처리 
294		$filebox.hide();
295		
296		if(type==="popup" || type==="close" || type==="day_close"){
297			$imgLink.add($imgLinkFile).addClass("is-hidden");
298			$selectPopup[type==="popup"?"removeClass":"addClass"]("is-hidden");
299			
300			if(type==="popup") $("#adc_crt_image_link_popup_select").val(data.url);
301			
302		}else{			
303			$imgLink[type==="link"?"removeClass":"addClass"]("is-hidden");
304			$imgLinkFile[type==="link"?"addClass":"removeClass"]("is-hidden");
305			$selectPopup.addClass("is-hidden");
306			
307			if(type==="link"){
308				$(".adcil_btns_link option[value="+(data.target||"blank")+"]").prop("selected", true);
309				$("#adcil_link_text").val(data.url)
310			}else if(type==="file"){
311				var $attach = $("#adcilf_attach")
312					,$delBtn = $("#adcilfuf_btn")
313					,$filename = $("#adcilfuf_file")
314					,$fmode = $filename.attr('data-type');
315				
316				$attach.replaceWith($attach.clone());
317				
318				if(data.url){
319					// 파일삭제
320					$filebox.show();
321					$filename.html(data.url);
322					$delBtn.unbind("click").on("click", function(){
323						if(confirm("서버에서 파일이 바로 제거됩니다.\n그래도 삭제하시겠습니까?")) {
324						var file = data.url
325							,extension = file.split('.').pop().toLowerCase()
326							,filename = file.replace('.'+extension,'');
327
328						$.post(SITE_DOMAIN + "/bannerpop/upload_act.php"
329								,{mode:'dlt', fmode:$fmode, idxno:document.adc_form.idxno.value||"", filename:file}
330								,function(data,rst){
331									if(rst==="success"){
332										if(data.result==="success"){
333											$filename.empty();
334											$filebox.hide();
335											parents.insertData({type:"file", url:"", target:"", json_obj:""}, "no");
336											//alert(decodeURIComponent(data.msg));
337										}else alert(decodeURIComponent(data.msg));
338									}else alert('생성할 수 있는 탭 제한수를 초과하였습니다.');
339								},"json");
340						}
341					});
342				}
343			}
344		}
345	}
346	
347	// 상위폼 초기화
348	,releaseForm:function(form)
349	{
350		if(!form) form = document.adc_form;
351	
352		// 해제
353		form.action = this.vars.act;
354		form.target = "";
355	}
356	
357	// 데이타 얻어오기
358	,getHiddenData:function()
359	{
360		var $id = $("#input_"+this.vars.editId)
361			,val = $id.val().split(this.vars.separator);
362		
363		return {id:$id, val:val};
364	}
365		
366	// input type 에 넣음
367	,insertData:function(data, isInit)
368	{
369		if(!data) data={};
370		if(!this.vars.editId) return false;
371		if(!isInit) isInit = "ok";
372		
373		var $data = this.getHiddenData()
374			,$id = $data.id
375			,val = $data.val;
376		
377		if(val.length<=0) return false;
378
379		val.splice(4, 4, data.type, data.url, data.target, (data.type == 'file' && data.url) ? data.json_obj : '')
380		var value = val.join(this.vars.separator);
381		
382		$id.val(value);
383		
384		if(isInit==="ok") this.initInsertForm({type:"link", url:"", target:"self"});
385		this.vars.editId = null;
386		
387		alert('적용되었습니다.');
388	}
389	
390	// 수정폼
391	,modifyForm:function(id)
392	{
393		if(!id) return false;
394		this.vars.editId = id;
395		
396		var $data = this.getHiddenData()
397			,val = $data.val
398			,type = val[4]||"link"
399			,url = val[5]||""
400			,target = val[6]||"self";
401
402		//이미지맵의 파일인지, 전체링크의 파일인지 구분짓기 위함
403		$("#adcilfuf_file").attr('data-type', 'M' + (Number(this.vars.editId.replace(/[^0-9]/g,'')) + 1));
404
405		this.initInsertForm({type:type, url:url, target:target});
406		this.mapBlinkArea();
407	}
408	
409	// 이미지 맵 잡기 위해 임시 저장
410	,afterUploadTmpFile:function(json)
411	{
412		var form = document.adc_form
413			,result = json.result||"error"
414			,data = json.data||""
415			,width = json.width||""
416			,height = json.height||""
417			,mime = json.mime||"";
418		
419		// 해제
420		this.releaseForm(form);
421		
422		if(result === "error"){
423			alert(data);
424			return false;
425		}
426		
427		// 나중에 폼 name으로 바꿀것!!!
428		//$("#adc_crt_popup_size_width").val(width);
429		//$("#adc_crt_popup_size_height").val(height);
430		if(form.popup_width) form.popup_width.value = width;
431		if(form.popup_height) form.popup_height.value = height;
432		
433		// 창 보이고, 이미지 미리보기 - 표시되는 사이즈 재오기
434		$("#adc_crt_image_preview_box").show();
435		$("#adc_crt_file_image").attr({"src":"data:"+mime+";base64,"+data, "data-width":width, "data-height":height});
436		
437		// 새로 올린것이니, 로딩된후 모든 이전에 저장된 맵 정보 날림
438		// 이전 데이타 삭제
439		this.mapDeleteAll();
440	}
441	
442
443	// 비율대로 좌표 계산하기
444	,mapCalcPositionRatio:function(val, ratio)
445	{
446		if(ratio === 1) return val;
447		
448		return Math.round(val * ratio);
449	}
450	
451	// 비율대로 좌표 계산하기-축소
452	,mapScalePositionRatio:function(val, ratio)
453	{
454		if(ratio === 1) return val;
455		
456		return Math.round(val / ratio);
457	}
458	
459	/**
460	 * input type="hidden" 생성
461	 * id : string
462	 * pos : object - 실제 위치
463	 * kind : string -  링크,파일 등
464	 * url : string - 링크, javascript function
465	 * target : string - 현재창,새창,부모창
466	 */
467	,mapHidden:function($form, id, pos, kind, url, target)
468	{
469		var inputId = "input_"+id
470			,val = [pos.x1, pos.y1, pos.x2, pos.y2, kind, url, target].join(this.vars.separator)
471			,input = '<input type="hidden" name="link_url[]" id="'+inputId+'" class="adc_crt_image_map_data" value="'+val+'" />';
472		
473		$form.append(input);
474	}
475	
476	// 생성된 맵 삭제
477	,mapDelete:function(id)
478	{
479		var bId = "btn_"+id
480			,inputId = "input_"+id;
481		
482		$("#"+id+",#"+bId+",#"+inputId).remove();
483		this.initInsertForm({type:"link", url:"", target:"self"});
484		alert('삭제되었습니다.');
485	}
486	
487	// 생성된 맴 전체 삭제
488	,mapDeleteAll:function()
489	{
490		$(".adc_crt_image_map_data, .ad-map, .ad-map-btns").remove();
491	}
492	
493	// 입력부분 깜빡임
494	,mapBlinkArea:function()
495	{
496		var parents = this;
497		parents.vars.$textBox.addClass("ad-map-bg");
498		setTimeout(function(){
499			parents.vars.$textBox.removeClass("ad-map-bg")
500		},500);
501	}
502
503	// 이미지 맵 잡기
504	,map:function(target)
505	{		
506		var parents = this
507			,$img = !!target.jquery ? target : $(target)
508			,width = Number($img.attr("data-width"))||0							// 실제 사이즈
509			,height = Number($img.attr("data-height"))||0
510			,dWidth = Number($img.attr("data-display-width"))||0				// 표시 사이즈
511			,dHeight = Number($img.attr("data-display-height"))||0
512			,ratio = width>dWidth ? Number((width/dWidth).toFixed(1)) : 1		// 실제 사이즈가 표시된 사이즈보다 클경우 비율 맞추기 위해
513			,box = parents.vars.box
514			,buttons = parents.vars.buttons
515			,$imgmapRadio = $("#adc_crt_image_link_part")
516			,$imgmapBtnRegist = $("#adc_crt_img_link_btn_regist")
517			,$form = $("#adc_form");
518
519					
520		return {
521			exe:function()
522			{
523				this.canvas().loadData().addEvent();
524			}
525		
526			// 덧붙이기
527			,canvas:function()
528			{
529				$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>');
530				return this;
531			}
532			
533			// 로드된 맵 데이타에 따라 그리기
534			,loadData:function()
535			{
536				var _parent = this
537					,$input = $(".adc_crt_image_map_data")
538					,$canvas = $("#adc_crt_edit_canvas");
539				
540				// 전체선택이라면
541				if($input.length<=0){
542					parents.initInsertForm(parents.vars.loadData);					
543					return this;
544				}
545
546				// 이미지 맵 설정으로 수정
547				$imgmapRadio.not(":checked").prop("checked", true);
548				$imgmapBtnRegist.show();
549				
550				$.each($input, function(i,ele){
551					var $ele = $(ele)
552						,id = ele.id.replace("input_","")
553						,val = $ele.val().split(parents.vars.separator)||[]
554						,x1 = val[0]||0
555						,y1 = val[1]||0
556						,x2 = val[2]||0
557						,y2 = val[3]||0
558						,type = val[4]||"link"
559						,url = val[5]||""
560						,target = val[6]||"self";
561					
562					_parent.display($canvas, id, {x1:x1, y1:y1, x2:x2, y2:y2});					
563				});
564				
565				return this;
566			}
567			
568			// 영역 그림
569			,display:function($canvas, id, data)
570			{
571				if(!data) data={};
572				
573				var $box = $(parents.vars.box)
574					,$buttons = $(parents.vars.buttons)
575					,offsetGap = $canvas.position().left||0			// 절대 좌표이기에 캔바스보다 작은 이미지일경우 gap만큼 더해서 표시해줌
576					,bId = "btn_"+id
577					,x1 = (Number(parents.mapScalePositionRatio(data.x1, ratio))+offsetGap)||0
578					,y1 = parents.mapScalePositionRatio(data.y1, ratio)||0
579					,x2 = (Number(parents.mapScalePositionRatio(data.x2, ratio))+offsetGap)||0
580					,y2 = parents.mapScalePositionRatio(data.y2, ratio)||0
581					,width = Math.abs(x1-x2)
582					,height = Math.abs(y1-y2);
583			
584				// 버튼 만들기
585				$buttons.css({"top":y1+"px", "left":x2+"px"}).attr({"id":bId})
586				.find(".adcmb_button").click(function(){
587					var $this = $(this)
588						,isModify = $this.is(".adcmb_modify");
589					
590					if(isModify===true){
591						parents.modifyForm(id);
592					}else{
593						parents.mapDelete(id);
594					}
595				});
596				
597				// box 만들기
598				$box.css({"top":y1+"px", "left":x1+"px", "width":width, "height":height}).attr({"id":id});
599				
600				$canvas.after($box);
601				$box.after($buttons);
602								
603				return this;
604			}
605						
606			// event
607			,addEvent:function()
608			{
609				var _this = this
610					,position = {x:0, y:0}
611					,$box = null
612					,start = false;
613				
614				$(document.body).off("mousedown mousemove mouseup touchstart touchmove touchend","#adc_crt_edit_canvas")
615				.on({
616						"mousedown touchstart":function(event)
617						{
618							start = true;
619							
620							var $this = $(this)
621								,evt = parents.getEventObject(window.event || event)
622								,$evtTarget = $(evt.target||evt.srcElement)
623								,offsetGap = $evtTarget.position().left									// 상대위치기 때문에 값 left 값을 더해줘야 함
624								,x = Math.round(evt.offsetX||(evt.pageX-$evtTarget.offset().left))
625								,y = Math.round(evt.offsetY||(evt.pageY-$evtTarget.offset().top))
626								,id = "acem_"+new Date().getTime();
627							
628							position.x = x;
629							position.y = y;
630							
631							$box = $(box).css({"top":y, "left":x+offsetGap}).attr({"id":id})
632							$this.after($box);
633							
634							//evt.cancelBubble = true;
635							//evt.stopPropagation();
636							//evt.preventDefault();
637						}
638					
639						,"mousemove touchmove":function(event)
640						{							
641							if(start === true){
642								var evt = parents.getEventObject(window.event || event)
643									,$evtTarget = $(evt.target||evt.srcElement)
644									,offsetGap = $evtTarget.position().left									// 상대위치기 때문에 값 left 값을 더해줘야 함
645									,x = Math.round(evt.offsetX||(evt.pageX-$evtTarget.offset().left))
646									,y = Math.round(evt.offsetY||(evt.pageY-$evtTarget.offset().top))
647									//,width = Math.abs(x-position.x)-5
648									//,height = Math.abs(y-position.y)-5
649									,width = Math.abs(x-position.x)
650									,height = Math.abs(y-position.y)
651									,css = {};
652								
653								css = {"width":width, "height":height};
654								
655								if(position.x>x && position.y>y){				// 좌상
656									css.left = position.x-width+offsetGap;
657									css.top = position.y-height;
658								}else if(position.x>x && position.y<y){			// 좌하
659									css.left = position.x-width+offsetGap;						
660								}else if(position.x<x && position.y>y){			// 우상	
661									css.top = position.y-height;
662								}
663								
664								$box.css(css);
665							}
666						}
667						
668						,"mouseup touchend":function(event)
669						{							
670							start = false;
671							
672							// $box기준으로 x1,y1,x2,y2 가져옴
673							var width = $box.width()
674								,height = $box.height();
675							
676							if(width<20 && height<20){
677								$box.remove();
678								return false;
679							}
680							
681							var	$buttons = $(buttons)
682								,evt = parents.getEventObject(window.event || event)
683								,$evtTarget = $(evt.target||evt.srcElement)
684								,offsetGap = $evtTarget.position().left									// 상대위치기 때문에 값 left 값을 빼줘야지 진짜 맵이 됨
685								,pos = $box.css(["top","left"])
686								,x1 = parents.castIntFromCss(pos.left)
687								,y1 = parents.castIntFromCss(pos.top)
688								,id = $box.attr("id")
689								,bId = "btn_"+id
690								,inputId = "input_"+id
691								,info = { x1 : x1, y1 : y1, x2 : x1 + width, y2 : y1 + height }
692								,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)};
693							
694							// 수정 삭제 이벤트
695							$buttons.css({"top":info.y1, "left":info.x2}).attr({"id":bId})
696							.find(".adcmb_button").click(function(){
697								var $this = $(this)
698									,isModify = $this.is(".adcmb_modify");
699
700								if(isModify===true){
701									parents.modifyForm(id);
702								}else{
703									parents.mapDelete(id);
704								}
705							});
706							
707							$box.after($buttons);
708							parents.mapHidden($form, id, real, "", "", "");
709							parents.initInsertForm({type:"link", url:"", target:"self"});									// 폼 초기화
710							parents.vars.editId = id;
711							
712							// 이미지맵으로 체크
713							$imgmapRadio.not(":checked").click().prop("checked", true);
714							$imgmapBtnRegist.show();
715							
716							parents.mapBlinkArea();																			// 글쓰기 폼 이펙트
717							
718							//util.toast(lang.adcRequireLink);
719						}
720					},"#adc_crt_edit_canvas");
721				
722				return this;
723			}
724			
725		}.exe();
726	}
727
728	// jquery 이벤트 등록 사용시, 이벤트 알아내기
729	,getEventObject:function(e)
730	{
731		var evt = window.event||e;
732			evt = evt.targetTouches?evt.targetTouches[0]:evt;  	// jquery touch event
733		return evt;
734	}
735	
736	// css px제거후 숫자형으로
737	,castIntFromCss:function(v)
738	{
739		return Number(v.replace("px",""));
740	}
741	
742	// list에서 버튼 이벤트
743	,evtClickedButtons:function()
744	{	
745		// edit
746		var edit_info = $('#admin-ad-list')
747		,edit_section = edit_info.attr("data-edit-section")	
748		,edit_area = edit_info.attr("data-edit-area")	
749		,edit_step = edit_info.attr("data-edit-step")	
750		,edit_idxno = edit_info.attr("data-edit-idxno")
751		,edit_mode = edit_info.attr("data-edit-mode")
752		,org_banner_kind = edit_info.attr("data-edit-org-banner-kind")
753		,banner_kind = edit_info.attr("data-edit-banner-kind")
754		,page = edit_info.attr("data-page")
755		//,tmp_banner_idxno = edit_info.attr("data-edit-tmp-banner-idxno")
756		,sc_area = edit_info.attr("data-search-scarea")
757		,sc_word = encodeURIComponent(edit_info.attr("data-search-scword"))
758
759		$(".ad-tile-toolkit, .content-inert").on("click", "button"
760		, function(){
761			var $this = $(this)
762				,type = $this.attr("data-btn-type")
763				,$parent = $this.closest(".adccfg_list_items")
764				,bannerIdxno = $parent.attr("data-banner-idxno")
765				,banner_type = $parent.attr("data-banner-type")
766				,linkInfo = $parent.attr("data-link-info")
767				,title = $.trim($parent.find(".acli_title").text())
768				,state = $.trim($parent.find(".ad-tile-state").text())
769				,Imgbp_Tag = $.trim($parent.find(".Imgbp_Tag").html());
770
771			switch(type){
772				case "add":
773					if(banner_type == 'popup') {
774						var data = {'mode':edit_mode,'section':edit_section,'popup_title':encodeURIComponent(title),'popup_idxno':bannerIdxno}
775						adWrite.addEditPopupContents(data);
776					}else{
777						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':'선택한 배너로 교체하시겠습니까?'};
778						adWrite.addEditContents(data);
779					}
780					break;
781				case "down":
782					location.href = '/bannerpop/attach_down.php?idxno='+bannerId
782xno+'&mode=O';
783					break;
784				case "linkInfo":					// 업로드된 파일 링크 복사					
785					var source = '/bannerpop/uploads/image/'+linkInfo;
786					adWrite.copyExe(source);
787					break;
788				case "sourceCopy":					// 소스복사
789				/*if(state == '무제한') {
790					if(!Imgbp_Tag) return false;
791					var _html = '<!--'+title+'-->'
792							  + Imgbp_Tag
793							  + '<!--//'+title+'-->';	
794				}else{*/
795					var _time = new Date().getTime()
796						,_html = '<!--'+title+'-->'
797							   + '<script type="text/javascript">var ___BANNER = "ban_'+_time+'";</script>'
798							   + '<script type="text/javascript" charset="utf-8" src="/bannerpop/uploads/js/'+bannerIdxno+'.js?'+_time+'" id="ban_'+_time+'"></script>'
799							   + '<!--//'+title+'-->';
800				//}
801					
802					adWrite.copyExe(_html);
803				break;
804				case "preview":
805					if(!window.___popup) return false;
806					
807					var p = ___popup[bannerIdxno];
808
809					if(!p) return false;
810					if(!window.___currentTime) window.___currentTime = Math.floor(new Date().getTime()/1000);// 시간이 설정되지 않았다면 js 시간으로 설정함
811					
812					// 관리자만...										
813					$(".layer_box").remove();				// 다른게 열려있다면 삭제
814					bannerpop.vars.popup.view = "manager";
815					bannerpop.float(p);
816					break;
817				case "mdf":
818					var $ahref = '/bannerpop/';
819					$ahref += edit_section ? 'edit.html' : 'write.html';
820					$ahref += '?type='+banner_type+'&mode=modify&idxno='+bannerIdxno+'&page='+page;
821					if(edit_section) $ahref += '&edit_section=' + edit_section;
822					if(edit_area) $ahref += '&edit_area=' + edit_area;
823					if(edit_step) $ahref += '&edit_step=' + edit_step;
824					if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
825					if(edit_mode) $ahref += '&edit_mode=' + edit_mode;
826					//if(tmp_banner_idxno) $ahref += '&tmp_banner_idxno=' + tmp_banner_idxno;
827					if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
828					if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
829					if(sc_area) $ahref += '&sc_area=' + sc_area;
830					if(sc_word) $ahref += '&sc_word=' + sc_word;
831					location.href = $ahref;
832					break;
833				case "del":
834					if(window.confirm('삭제할까요?')) {	
835						var $ahref = '/bannerpop/delete_act.php?type='+banner_type+'&idxno='+bannerIdxno+'&page='+page;
836						if(edit_section) $ahref += '&edit_section=' + edit_section;
837						if(edit_area) $ahref += '&edit_area=' + edit_area;
838						if(edit_step) $ahref += '&edit_step=' + edit_step;
839						if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
840						if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
841						if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
842						if(sc_area) $ahref += '&sc_area=' + sc_area;
843						if(sc_word) $ahref += '&sc_word=' + sc_word;
844						location.href = $ahref;
845					}
846					break;
847				case "mdf_activity":
848					var $ahref = '/bannerpop/';
849					$ahref += edit_section ? 'edit.html' : 'write_activity.html';
850					$ahref += '?type='+banner_type+'&mode=modify&activity_idxno='+bannerIdxno+'&page='+page;
851					if(edit_section) $ahref += '&edit_section=' + edit_section;
852					if(edit_area) $ahref += '&edit_area=' + edit_area;
853					if(edit_step) $ahref += '&edit_step=' + edit_step;
854					if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
855					if(edit_mode) $ahref += '&edit_mode=' + edit_mode;
856					if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
857					if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
858					//if(tmp_banner_idxno) $ahref += '&tmp_banner_idxno=' + tmp_banner_idxno;
859					if(sc_area) $ahref += '&sc_area=' + sc_area;
860					if(sc_word) $ahref += '&sc_word=' + sc_word;
861					location.href = $ahref;
862					break;
863				case "del_activity":
864					if(window.confirm('삭제할까요?')) {	
865						var $ahref = '/bannerpop/delete_activity_act.php?type='+banner_type+'&activity_idxno='+bannerIdxno+'&page='+page;
866						if(edit_section) $ahref += '&edit_section=' + edit_section;
867						if(edit_area) $ahref += '&edit_area=' + edit_area;
868						if(edit_step) $ahref += '&edit_step=' + edit_step;
869						if(edit_idxno) $ahref += '&edit_idxno=' + edit_idxno;
870						if(org_banner_kind) $ahref += '&org_banner_kind=' + org_banner_kind;
871						if(banner_kind) $ahref += '&banner_kind=' + banner_kind;
872						if(sc_area) $ahref += '&sc_area=' + sc_area;
873						if(sc_word) $ahref += '&sc_word=' + sc_word;
874						location.href = $ahref;
875					}
876					break;				
877				case "sourceCopy_activity":					// 소스복사
878					var _time = new Date().getTime()
879					,_html = '<!--'+title+'-->'
880						   + '<script type="text/javascript">var ___BANNER = "ban_'+_time+'";</script>'
881						   + '<script type="text/javascript" charset="utf-8" src="/bannerpop/uploads/js_activity/'+bannerIdxno+'.js?'+_time+'" id="ban_'+_time+'"></script>'
882						   + '<!--//'+title+'-->';
883					
884					adWrite.copyExe(_html);
885				break;
886			}
887
888			return false;
889		});
890	}
891
892	//수정시 섹션판 컨텐츠 삽입
893	,addEditContents:function(data)
894	{			
895		//var flag = false;
896		var flag = true;
897
898		/*if(data.mode == 'modify') {
899			if(data.tmp_banner_idxno != data.banner_idxno) {
900				if(confirm(data.edit_msg)) flag = true;
901				else flag = false;
902			}else flag = true;
903		}else flag = true;*/
904
905		if(flag) { 			
906			data = JSON.stringify(data);
907			$.ajax({
908				url:"/edit/adminReservationBannerWrite.php"
909				,type:'post'
910				,dataType:'json'
911				,contentType:'application/x-www-form-urlencoded; charset=utf-8'
912				,data:{post_data:data}
913				,success:function(json, result) {
914					if(result == 'success') {
915						if(json.response == 'ok') { 
916							window.parent.location.reload();
917						}else{
918							alert(json.msg);
919							return false;
920						}
921					}else return false;
922				}
923			});
924		}else{
925			return false;
926		}
927	}
928
929	//수정시 섹션판 컨텐츠 삽입
930	,addEditPopupContents:function(data)
931	{					
932		data = JSON.stringify(data);
933		$.ajax({
934			url:"/edit/adminReservationPopupWrite.php"
935			,type:'post'
936			,dataType:'json'
937			,contentType:'application/x-www-form-urlencoded; charset=utf-8'
938			,data:{post_data:data}
939			,success:function(json, result) {
940				if(result == 'success') {
941					if(json.response == 'ok') {
942						//window.parent.location.reload();
943						parent.$('#edit-modal').find('.close-buttons').trigger('click');
944						adWrite.addPopupContentsList(json);
945					}else{
946						alert(json.msg);
947						return false;
948					}
949				}else return false;
950			}
951		});
952	}
953
954	,addPopupContentsList:function(json) {
955		var html = '';
956
957		console.log(json);
958		
959		if(json.rows.length>0) {
960			for(var i = 0; i < json.rows.length; i++) {
961				var index = i+1;
962				html += '<!-- 팝업 //-->';
963				html += '<div class="option-popup-item">';
964				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 + '" />';
965				html += '	<label for="editPopup' + index + '">';
966				if(json.rows[i].popup_image && json.rows[i].extension != 'swf') {
967					html += '<img src="/bannerpop/uploads/image/' + json.rows[i].popup_image + '" alt="' + adWrite.rawurldecode(json.rows[i].popup_title) + '" />';
968				}else{
969					if(json.rows[i].extension == 'swf') html += 'SWF';
970					else html += 'HTML';
971				}
972				html += '		<div class="option-popup-item-title">' + adWrite.rawurldecode(json.rows[i].popup_title) + '</div>';
973				html += '	</label>';
974				html += '</div>';
975				html += '<!--// 팝업 -->';
976			}
977		}
978
979		parent.$('.option-popup-group').html(html);
980	}
981
982	//전체선택ㆍ해제
983	,allChk:function()
984	{	
985		var $allChk = $('#allCheck');
986		$allChk.click(function(){
987			if($(this).is(':checked') == true) {
988				$('.elembox').prop('checked',true);
989			}else{
990				$('.elembox').prop('checked',false);
991			}
992		});
993	}
994
995	/**
996	 * 클립보드 복사 
997	 * source : 복사할 정보
998	 */
999	,copyExe:function(source)
1000	{
1001		if(window.clipboardData){			// ie
1002			window.clipboardData.setData('Text',source);
1003			alert("복사되었습니다. 원하는 곳에 붙여넣기하여 주세요.");
1004		}else{								// etc
1005			
1006			var $tmpDiv=$('<div class="blind">'+source.replace(/</g,"&lt;").replace(/>/g,"&gt;")+'</div>').appendTo("body")
1007				,range=document.createRange()
1008				,selection=null;
1009
1010			range.selectNodeContents($tmpDiv.get(0));
1011			selection=window.getSelection();
1012			selection.removeAllRanges();
1013			selection.addRange(range);
1014			
1015			if(document.execCommand("copy", false, null)) alert("복사되었습니다. 원하는 곳에 붙여넣기하여 주세요.");
1016			else window.prompt('키보드의 ctrl+C 또는 마우스 오른쪽의 복사하기를 이용해주세요.', source);
1017
1018			$tmpDiv.remove();
1019		}
1020	}
1021
1022	/**
1023	 * 기능성 배너 추가/순서변경/삭제/
1024	 */
1025	 ,evtClickActivityAdd:function() {
1026		//sessionStorage.removeItem("last_idx");
1027		var activity_idxno=window.parent.$('#all-banner-list').closest('div').attr('data-activity-idxno')||'';
1028		$('#activity-add-btn').click(function() {
1029			var $this=$(this);
1030				//,$viewHref=$('#activity-view-btn').attr('href')
1031				//,$last_idx=(activity_idxno)?activity_idxno:sessionStorage.getItem('last_idx');
1032			
1033			if($('.banner_element_ckecked').is(':checked') == false) {
1034				alert('배너를 선택해주세요.');
1035				//if(!$last_idx) $('#activity-view-btn').addClass('is-hidden');
1036				return false;
1037			}else{
1038				var $checked=$(".banner_element_ckecked:checked")
1039					,arr = new Array();
1040				if($checked.length>0) {
1041					$.each($checked, function(idx, v) {
1042						arr.push(v.value);
1043					});
1044
1045					var data = {mode:activity_idxno?'modify':'input', activity_idxno:activity_idxno, banner_idxno:arr};
1046					data = JSON.stringify(data);
1047					console.log(data);
1048					$.ajax({
1049						url:"/bannerpop/activity_act.php"
1050						,type:'post'
1051						,dataType:'json'
1052						,contentType:'application/x-www-form-urlencoded; charset=utf-8'
1053						,data:{post_data:data}
1054						,success:function(json, result) {
1055							if(result == 'success') {
1056								if(json.response == 'ok') {
1057									//alert('추가되었습니다.\n우측에 버튼을 클릭하시면 상세 화면으로 이동합니다.');
1058									/*if(!activity_idxno) {
1059										sessionStorage.setItem('last_idx', json.last_insert_id);
1060										$('#activity-view-btn').attr('href', $viewHref + '&activity_idxno='+json.last_insert_id);
1061									}
1062									$('#activity-view-btn').removeClass('is-hidden');*/
1063									window.parent.location.reload();
1064								}else{
1065									//alert(json.msg);
1066									return false;
1067								}
1068							}else return false;
1069						},
1070     error:function(request,status,error){
1071        alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
1072       }
1073					});
1074				}
1075			}
1076		});
1077
1078		$('#banner-activity-box').sortable({
1079			axis: '',
1080			update: function() {
1081				//console.log($(this));
1082			}
1083		});
1084
1085		$('.trash').click(function() {
1086			if($('.banner-activity-list').length <= 1) {
1087				alert('마지막 배너는 삭제 할 수 없습니다.');
1088				return false;
1089			}
1090
1091			var $this=$(this)
1092			,$parent = $this.closest('.banner-activity-list');
1093
1094			$parent.fadeOut('fast', function(){
1095				$parent.remove();	
1096			});
1097		});
1098
1099		$('#all-banner-list').on('click', function(e) {
1100
1101			$this = $(this);
1102			href = $this.attr('href');
1103
1104			$("#edit-modal-iframe").attr("src", href);
1105			$('#edit-modal').foundation('open');
1106
1107			return false;
1108		});
1109
1110		$('#edit-modal').on('open.zf.reveal', function(e){
1111			$('#for-loading').show();
1112		});
1113
1114		$('#edit-modal').on('closed.zf.reveal', function(e){
1115			$("#edit-modal-iframe").attr("src", "about:blank").height('0px').closest('#activity-modal').css('height', '0px');
1116		});
1117	 }
1118
1119	 ,valid_activity:function() {
1120		if($('#activity_title').val() == '') {
1121			alert('제목을 입력하세요.');
1122			$('#activity_title').focus();
1123			return false;
1124		}
1125
1126		if($('.banner-activity-list').length<=0) {
1127			alert('배너를 하나 이상 추가하셔야 합니다.');
1128			return false;
1129		}
1130
1131		return true;
1132	 }
1133
1134}; // end adWrite 
1135
1136var bannerpop={
1137	vars:{
1138		popup:{
1139			bodyWidth:0
1140			,bodyLeft:0
1141			,screenWidth:0
1142			,popname:"popup_"
1143			,width:{ window:[],layer:[] }
1144			,height:{ window:[],layer:[] }
1145			,top:{ window:[],layer:[] }
1146			,left:{ window:[],layer:[] }
1147			,order:0						// z-index용 순차적
1148			,view:"normal"					// 일반 : normal or 관리자 : manager
1149		}
1150	}
1151
1152	/**
1153	 * 배너 효과
1154	 * 태그 작성 예::: bannerpop.banner(".banner_event_box");
1155	 <div class="boder_box banner_event_box" data-type="slide" data-idxno="3" data-speed="0.3">		
1156		<div class="boder_box beb_box">
1157			<ul class="no_type beb_ul">
1158				<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>
1159				<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>
1160				<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>
1161				<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>
1162				<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>
1163			</ul>
1164		</div>
1165		<div class="beb_buttons">
1166			<button type="button" class="beb_btns beb_btn_prev">뒤로</button>
1167			<button type="button" class="beb_btns beb_btn_stop">멈춤</button>
1168			<button type="button" class="beb_btns beb_btn_next">앞으로</button>
1169		</div>
1170	 </div>
1171	 */
1172	,effect:function()
1173	{
1174		var savePrefix = "banner_order_";
1175
1176		// 배너 넓이 
1177		function setSizeInfo($this){
1178			var idxno = $this.attr("data-idxno")
1179				 ,$ul = $this.find(".beb_ul")
1180				 ,$li = $ul.find(".beb_li")
1181				 ,boxWidth = $this.innerWidth()||$this.closest("#float_side_box").width()	// 윙 사이드의 배너일경우 재측정
1182				 ,liCount = $li.length||0;
1183			
1184			// 관리자 페이지가 아닐때 실제 노출중인 것만 찾음
1185			//if(ADM_DOMAIN.indexOf(location.host)<0){
1186				$.each($li,function(){
1187					var $this=$(this), len=$this.find(".banner_box").length;
1188					if(!len) $this.remove();
1189				});
1190				$li = $ul.find(".beb_li");
1191				liCount = $li.length||0;
1192			//}
1193
1194			// 부모박스 기준으로 ul 최대 넓이 지정
1195			$ul.width(boxWidth*liCount);
1196
1197			// 배너마다 넓이가 다를수 있으니 부모박스 넓이기준으로함
1198			$li.width(boxWidth);
1199
1200			return {
1201						idxno : idxno
1202						,$ul : $ul
1203						,$li : $li
1204						,boxWidth : boxWidth
1205						,liCount : liCount
1206					};
1207		}
1208
1209		return {
1210			// 순서대로 하나의 배너만 보임 
1211			order:function(){
1212				var _this = this
1213					,$this = $(_this)
1214					,$info = setSizeInfo($this)
1215					,idxno = $info.idxno
1216					,$li =$info.$li
1217					,liCount = $info.liCount-1
1218					,saveKey = savePrefix+idxno
1219					,order = Number(localStorage.getItem(saveKey))||0;
1220
1221				// 랜덤 선택된것만 보임, 버튼 없앰
1222				$li.css("display","list-item").not(":eq("+order+")").css("display","none");
1223
1224				localStorage.setItem(saveKey, (order>=liCount ? 0 : order+1));
1225			}
1226
1227			// random banner
1228			,random:function(){
1229				var _this = this
1230					,$this = $(_this)
1231					,$info = setSizeInfo($this)
1232					,$li =$info.$li
1233					,liCount = $info.liCount
1234					,random = Math.floor(Math.random()*liCount);
1235
1236					// 랜덤 선택된것만 보임, 버튼 없앰
1237				$li.css("display","list-item").not(":eq("+random+")").css("display","none");
1238			}
1239			
1240			// random 배너 선택후 슬라이드
1241			,randomSlide:function(){
1242				bannerpop.effect()['slide'].call(this, true);
1243			}
1244
1245			// slide banner
1246			// rand true or false
1247			,slide:function(rand){
1248				var _this = this
1249					,$this = $(_this)
1250					,$info = setSizeInfo($this)
1251					,$ul = $info.$ul
1252					,$li =$info.$li.css("display","list-item")
1253					,$btnBox = $this.find(".beb_buttons")
1254					,$btnStop = $btnBox.find(".beb_btn_stop")
1255					,$btnCurrent = null						// 현재 선택된 버튼 prev,next,play,stop of buttons
1256					,speed = Number(_this.getAttribute("data-speed"))||.3
1257					,delayInfo = $li.map(function(){ return Number(this.getAttribute("data-delay"))||5; }).get()
1258					,boxWidth =$info.boxWidth
1259					,liCount = $info.liCount
1260					,count = (rand===true?Math.floor(Math.random()*(liCount)):-1)	// 처음부터 +1 하고 시작하기에 -1초기값-random일때는 배너수중 1개
1261					,delay = null													// 멈춰잇는 시간(초)
1262					,left = boxWidth												// 움직이는 간격
1263					,si = null														// setInterval 변수 : animate complete에서 delay로 해결하려 했는데 뭔가 잘 안풀림
1264					,tmpDelay = null												// next, prev 시 delay 없이 넘김
1265					,firstBtnClicked = 0;											// prev,next로 이동하는가 - rotate에서 또한번 +,- 하기에 처음만 실행되어야 함
1266
1267				/**** function //s ****/
1268				/*
1269					다음 배너
1270					@params
1271					 loop : 반복될것인가
1272					 mode : + or -
1273				*/
1274				function rotate(loop, mode){
1275					if(!mode) mode="+";
1276					if(mode==="+") count++;
1277					else  count--;
1278
1279					if(count>=liCount || count<=0) count = 0;					// 지연시간 담은 배열찾기 key
1280					var front = count+1;													// 지연후 움직여야 하는 거리 미리 담아둠
1281					if(count>=(liCount-1)) front = 0;
1282					left = boxWidth*front*-1;
1283					delay = tmpDelay===null?delayInfo[count]:tmpDelay;
1284
1285					si = setTimeout(function(){
1286						$ul.animate({ marginLeft:left }
1287										,speed*1000,
1288										function(){
1289											if(loop===false) $btnCurrent.prop("disabled", false);
1290											tmpDelay = null;
1291										});//.delay(delay*1000);	
1292						if(loop!==false) rotate();
1293					},delay*1000);								
1294				}
1295
1296				// stop
1297				function stop(){
1298					firstBtnClicked++;
1299
1300					//$ul.stop(true, false);
1301					clearTimeout(si);
1302					tmpDelay=null;
1303					$btnStop.addClass("beb_btn_start").text("play");
1304				}
1305
1306				// restart
1307				function start(){
1308					firstBtnClicked = 0;
1309
1310					count--;
1311					if(count<=0) count=0;
1312
1313					tmpDelay=null;
1314					rotate();
1315
1316					$btnStop.removeClass("beb_btn_start").text("멈춤");
1317				}
1318				
1319				// 이전
1320				function prev(){
1321					stop();
1322
1323					if(firstBtnClicked===1) count--;			// 처음만 이미 증가된값을 감소시킴
1324					if(count<=0) count=liCount;
1325
1326					tmpDelay=0;
1327					rotate(false,"-");
1328
1329					$btnCurrent.prop("disabled", true);
1330				}
1331
1332				// 이후
1333				function next(){
1334					stop();
1335
1336					if(firstBtnClicked===1) count--;
1337					if(count>=liCount) count=0;
1338
1339					tmpDelay=0;
1340					rotate(false);
1341
1342					$btnCurrent.prop("disabled", true);
1343				}
1344				/**** function //e ****/
1345
1346				// 처음 배너를 보이지 않는다는 것은 랜덤 배너의 슬라이드라는 것-처음보일배너 설정
1347				if(count>=0 && rand===true){
1348					var _boxWidth = boxWidth*(count>=liCount?liCount-1:count)*-1;
1349					count--;
1350					$ul.css("margin-left",_boxWidth+"px");
1351				}
1352				
1353				// 실행
1354				rotate();						
1355				
1356				// 버튼보임
1357				$btnBox/*.css("display","block")*/.find(".beb_btns").unbind("click")
1358				.click(function(){
1359					var $this = $(this);
1360	
1361					$btnCurrent = $this;
1362					if($this.is(".beb_btn_prev")) prev();
1363					else if($this.is(".beb_btn_next")) next();
1364					else if($this.is(".beb_btn_stop")){
1365						if($this.is(".beb_btn_start")) start();
1366						else stop();
1367					}
1368				});
1369
1370				// mouseover event
1371				$ul.on({
1372							mouseenter:stop
1373							,mouseleave:start
1374						});
1375			}
1376		};
1377	}
1378
1379	// 배너호출
1380	,banner:function(target)
1381	{	
1382		var parents = this
1383			,$target = !!target.jquery?target:$(target);
1384		
1385		//console.log($target);
1386		$.each($target, function(i, ele){
1387			var type = ele.getAttribute("data-type")||"random";
1388			parents.effect()[type].call(this);
1389		});
1390	}
1391
1392	,getCookie:function(name)
1393	{	/*
1394		var cookie = document.cookie;
1395		if(cookie.indexOf(name)<0) return "";
1396		
1397		var regexp = new RegExp("^(.*)"+name+"=(.*?);(.*)$","g");
1398		return cookie.replace(regexp,"$2").replace(/^\s+|\s+$/g,"");
1399		*/
1400		name+="=";
1401	    var ca = document.cookie.split(';');
1402	    for(var i=0; i<ca.length; i++) {
1403	        var c = ca[i];
1404	        while (c.charAt(0)==' ') c = c.substring(1);
1405	        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
1406	    }
1407	    return "";
1408	}
1409	
1410	,setCookie:function(name, value, days, domain)
1411	{
1412		var expires = "";
1413		if(days){
1414			var date = new Date();
1415			date.setTime(date.getTime()+(days*24*60*60*1000));
1416			expires = "; expires="+date.toGMTString();
1417		}
1418		
1419		var dm=SITE_DOMAIN.replace('http://','');
1420		if(!domain) domain="." + dm;
1421		
1422		document.cookie = name+"="+value+expires+"; path=/; " + (domain?"domain="+domain+";":"");
1423	}
1424
1425	// url을 array로
1426	,linkToJson:function(link)
1427	{
1428		if(!link) return false;
1429		
1430		var json = {}
1431			,tmp = link.replace(/^\/\?/,"").split("&");
1432		
1433		if(tmp.length<=0 || !tmp) return false;
1434		for(var i in tmp){
1435			var param = tmp[i].split("=")
1436				,key = param[0]
1437				,value = param[1];
1438			
1439			json[key] = value;
1440		}
1441		return json;
1442	}
1443
1444	// 배너 append
1445	,append:function()
1446	{	
1447		var id = ___BANNER
1448			,status = bannerStatus
1449			,time = ___currentTime
1450			,sTime = startTime
1451			,eTime = endTime
1452			,content = decodeURIComponent(bannerContent)
1453			,title = typeof bannerTitle == "undefined" ? "":decodeURIComponent(bannerTitle)
1454			,$target = $("#"+id)
1455			,explain = '';
1456			//,explain = "\n<br />"+util.timestampToDatetime(sTime).strDateTime.substring(0,16)+"~"+util.timestampToDatetime(eTime).strDateTime.substring(0,16);
1457
1458
1459		if(!id || $target.length<=0 || $target.attr("data-append")=="true") return false; // 객체가 없거나 시작전,이미 추가되었다면 중단
1460		
1461		// 예정,종료 배너
1462		else if(sTime > time || time > eTime || status=="0"){	
1463			if(location.href.indexOf('/edit/adminSection.html')<0) return false;	// 관리자가 아니라면 종료 메시지 안띄우기
1464			var adcMsg=""
1465				,adcClass="";
1466			if(sTime > time && status!="0"){
1467				adcMsg = '노출예정 배너';
1468				adcClass = "banner-later";
1469			}else if(time > eTime || status=="0"){
1470				adcMsg = '종료된 배너';
1471				adcClass = "banner-finish";
1472			}
1473			
1474			$target.attr("data-append","true").after('<div class="ad-finished"><span class="'+adcClass+'"><i class="fa fa-clock-o"></i>&nbsp;'+adcMsg+' "'+title+'"</span>'+explain+'</div>');
1474	// 종료 메시지 띄우고 종료
1475			bannerTitle="";//초기화
1476			
1477			return false;
1478		}
1479		
1480		$target.attr("data-append","true").after(content);	// 추가 되었으면 data-append 태그 나김
1481	}
1482
1483	/****** 팝업 띄우기 
1484	var ___popup = [{},...];
1485	
1486	* json 내용 *
1487		idxno - 팝업 idxno 고유번호 
1488		title - 팝업의 제목 
1489		start - 팝업 시작일시
1490		end - 팝업 종료일시 
1491		status - 진행상태 (1=진행, 0=종료)
1492		popup_type - 팝업형태 (layer=레이어, window=윈도우)
1493		popup_size - auto (사용안함)
1494		popup_width - 팝업창크기(가로)
1495		popup_height - 팝업창크기(세로)
1496		position - auto (사용안함)
1497		x_position - 창의 x 위치 
1498		y_position - 창의 y 위치 
1499		apply_page - 적용페이지 (main, section, list, view 값이 입력 되어있음 , php에서 페이지 구분해서 json으로 만들어 줍니다.) 
1500		bottom_close - 하단표시 창닫기 출력여부 (Y=출력, N=출력안함)
1501		bottom_close_expire_ck - **동안 열지않기 (none=사용안함, day=하루동안 열지않기, days=몇일동안 열지않기)
1502		bottom_close_expire - 몇일인지
1503		layer_border - 레이어 팝업인 경우 외곽선 (Y=사용함, N=사용안함)
1504		layer_move - 레이어 팝업인 경우 드래그 가능 (Y=사용함, N=사용안함)
1505		layer_scroll - 레이어 팝업인 경우 스크롤 따라다니기 (Y=사용함, N=사용안함)
1506		layer_close - 레이어 팝업인 경우 닫기 아이콘 (Y=사용함, N=사용안함)
1507		layer_close_icon - 레이어 팝업인 경우 닫기 아이콘 유형 
1508		layer_close_position - 레이어 팝업인 경우 닫기 아이콘 출력 위치 (TL-상/좌, TR-상/우, BL-하/좌, BR-하/우)
1509		window_scroll - 윈도우 팝업인 경우 스크롤 활성화 (Y=사용함, N=사용안함)
1510		content - 출력 HTML 내용
1511	*****/
1512	,float:function(j)
1513	{
1514		// json 값
1515		var current = ___currentTime
1516			,start = Number(j.start)||0
1517			,end = Number(j.end)||(new Date().getTime()+100)	// 종료일이 기입되지 않았다면, 현재보다 100씩더해서 계속 늘림 
1518			,status = j.status||"0";
1519	
1520		if(this.vars.popup.view!="manager" && (status=="0" || current < start || (current > end && end!==0))) return false;												// 종료 or 기간이 아니라면 통과
1521			
1522		var	parents = this
1523			,idxno = j.idxno||"0"
1524			,oriTitle = j.title||""
1525			,title = decodeURIComponent(j.title)||""
1526			,popupType = j.popup_type||"window"
1527			,popupSize = j.popup_size||"auto"
1528			,popupWidth = Number(j.popup_width)||0
1529			,popupHeight = (Number(j.popup_height)||0) + 32
1530			,position = j.position||"auto"
1531			,xPosition = Number(j.x_position)||0
1532			,yPosition = Number(j.y_position)||0
1533			,applyPage = j.apply_page||"main"
1534			,bottomClose = j.bottom_close||"N"
1535			,bottomCloseExpireCk = j.bottom_close_expire_ck||"none"
1536			,bottomCloseExpire	= j.bottom_close_expire||1
1537			,layerBorder = j.layer_border||"N"
1538			,layerMove = j.layer_move||"N"
1539			,layerScroll = j.layer_scroll||"N"
1540			,layerClose = j.layer_close||"N"
1541			,layerCloseIcon = j.layer_close_icon||""
1542			,layerClosePosition = j.layer_close_position||"BR"
1543			,windowScroll = j.window_scroll||"Y"
1544			,content = decodeURIComponent(j.content)||""
1545			,popupUrl = j.popup_url||""// + (parents.vars.popup.view=="manager"?"?edit_mode=preview":"")||""
1546			,top = 0
1547			,left = 0
1548			,popname = parents.vars.popup.popname+idxno
1549			,_type = popupType; 								// default: 각자띄움 - 팝업과 레이어가 위치값을 공유하여 차례로 띄울려면 "window" or 공유하지 않고 각자 띄울려면 popupType;
1550
1551		var type = {		
1552			calcPosition:function(){
1553				// x,y 가 0일때는 auto로 간주
1554				if((xPosition===0 && yPosition===0)/* || position=="auto"*/){
1555					var maxHeight = parents.arrayMaxMin(parents.vars.popup.height[_type],"max")
1556						,maxTop = parents.arrayMaxMin(parents.vars.popup.top[_type],"max")
1557						,initLeft = popupType=="window"?0:parents.vars.popup.bodyLeft
1558						,prevWidth = parents.vars.popup.width[_type][parents.vars.popup.width[_type].length-1]||0
1559						,prevLeft = parents.vars.popup.left[_type][parents.vars.popup.left[_type].length-1]||initLeft;			// 바로 이전 팝업 넓이를 left값으로 정함-window:0, layer:content의 left
1560		
1561		//console.log(popupWidth);
1562					left = prevLeft+prevWidth;
1563					
1564					// 페이지 넓이보다 자리잡은 left값이 크다면 화면상 한단계 내림
1565					if(left>parents.vars.popup[popupType=="window"?"screenWidth":"bodyWidth"]){
1566						top += maxHeight;						
1567						left = initLeft;
1568						
1569						// 다음 단계이니까 초기화 함
1570						parents.vars.popup.width[_type] = [];
1571						parents.vars.popup.height[_type] = [];
1572						parents.vars.popup.top[_type] = [];
1573						parents.vars.popup.left[_type] = [];
1574					}else{
1575						top = (maxTop||0);
1576					}
1577					
1578					// 변화된값 배열에 넣기 위해 조작
1579					xPosition = left;
1580					yPosition = top;
1581					
1582					// 변수에 담음
1583					parents.vars.popup.width[_type].push(popupWidth||0);
1584					parents.vars.popup.height[_type].push(popupHeight||0);
1585					parents.vars.popup.top[_type].push(yPosition||0);
1586					parents.vars.popup.left[_type].push(xPosition||0);
1587										
1588				}else{
1589					top = yPosition;
1590					left = xPosition;
1591				}
1592			}
1593		
1594			// 관리자 미리보기시 중앙에
1595			,setPositionCenter:function(){
1596				var _width = (document.body.clientWidth/2)-(popupWidth/2)
1597					,_scrollTop = document.body.scrollTop;
1598				
1599				top = _scrollTop + 50;
1600				left = _width;
1601			}
1602			
1603			// 띄울 페이지 applyPage
1604			,isApplyPage:function()
1605			{
1606				// 관리자 통과
1607				if(parents.vars.popup.view=="manager") return true;
1608				/*
1609				var params = bannerpop.linkToJson(location.search.replace("?",""))
1610					,mod = params.mod||""
1611					,act = params.act||""
1612					,section = params.section||"";
1613				
1614				// 메인
1615				if(((mod=="main" && act=="index" && !section) || (!mod && !act && !section)) && applyPage.indexOf("main")>=0) return true;
1616				// 섹션
1617				else if(mod=="main" && act=="index" && section && applyPage.indexOf("section")>=0) return true;
1618				// 기사 리스트
1619				else if(mod=="news" && act=="articleList" && applyPage.indexOf("list")>=0) return true;
1620				// 기사뷰
1621				else if(mod=="news" && act=="articleView" && applyPage.indexOf("view")>=0) return true;
1622				*/
1623			}
1624		
1625			,window:function(){
1626				//if(this.isApplyPage()!==true) return false;
1627				
1628				this.calcPosition(); // 위치 계산
1629				var winpopupUrl = '/bannerpop/popup.html?win_popup_idxno=' + idxno;
1630				window.open(winpopupUrl, popname, "width="+popupWidth+",height="+popupHeight+",scrollbars="+(windowScroll=="Y"?"yes":"no")+",resizable=yes,top="+top+",left="+left);
1631			}
1632		
1633			,layer:function(){
1634				//if(this.isApplyPage()!==true) return false;
1635				
1636				this.calcPosition(); // 위치 계산
1637			
1638				var $content = $(content);
1639
1640				$content.attr({"id":popname})
1641				.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":""))
1642				.find(".popup_close_box").addClass("layer_close_box");
1643				
1644				// 드래그 가능
1645				if(layerMove=="Y") $content.addClass("layer_box_cursor_move").draggable();				
1646				
1647				// 창닫기-icon 닫기 버튼은 별개다
1648				//if(bottomClose=="Y"){	
1649				var $btnClose = $content.find(".popup_close, .popup_close_map, .popup_icon_close");
1650				$btnClose.each(function(){
1651					var _$this = $(this);
1652					//if(_$this.is(".popup_close") && bottomClose=="Y") _$this.text('창닫기');
1653
1654					if(_$this.is(".popup_icon_close")) {
1655						if(layerClosePosition == 'BL' || layerClosePosition == 'BR') {
1656							
1657							if($content.find(".popup_close, .popup_close_map").length>0) {
1658								_$this.css('top',Number(j.popup_height)-40+'px');	
1659							}
1660						}
1661
1662						_$this.addClass("layer_position_"+layerClosePosition);
1663					}
1664				});
1665				
1666				$btnClose.click(function(){
1667					parents.evtClose(popupType, idxno);	
1668					return false;
1669				});
1670				//}
1671
1672				// 이미지내 링크가 창닫기 라면
1673				//$content.find("a[href*='javascript:window.close()']").click(function(){
1674				$content.find("[href*='javascript:window.close()']").click(function(){
1675					parents.evtClose(popupType, idxno);	
1676					return false;
1677				});
1678
1679				// 하루, 몇일동안 열지 않기
1680				parents.daysNotOpen(bottomCloseExpireCk, bottomCloseExpire, $content.find(".popup-days, .popup_day_close_map"), j);
1681				
1682				// 관리자 미리보기시 중앙에
1683				if(parents.vars.popup.view=="manager"){
1684					$content.appendTo(document.body);
1685					this.setPositionCenter();	
1686					$content.removeClass("layer_box_fixed").css({"top":top+"px", "left":left+"px"});
1687				}else{
1688					$content.appendTo($("#layer-popups"));
1689				}
1690			}				
1691		};
1692	
1693		type[popupType]();		
1694	}
1695	
1696	// 팝업띄우기
1697	,popup:function()
1698	{
1699		//try{
1700			var parents = this;
1701			$(window).on("load", function(){
1702				if(!window.___popup) return ;
1703				if($.isArray(___popup)===false && ___popup.length>0) return ;
1704				if(!window.___currentTime) ___currentTime = Math.floor(new Date().getTime()/1000);// 시간이 설정되지 않았다면 js 시간으로 설정함
1705								
1706				var $content = $("#layer-popups");
1707				
1708				if($content.length<=0) return false;
1709				parents.vars.popup.bodyWidth = $content.innerWidth();			
1710				parents.vars.popup.bodyLeft = $content.position().left;
1711				parents.vars.popup.screenWidth = window.screen.width;
1712				for(var i=0,cnt=___popup.length; i<cnt; i++){
1713					// 쿠키인지 판단후 열기
1714					var coo = "";
1715					coo = bannerpop.getCookie(parents.vars.popup.popname+___popup[i].idxno)
1716
1717					if(!coo){
1718						parents.vars.popup.order++;
1719						parents.float(___popup[i]);
1720					}
1721				}
1722			});
1723		//}catch(e){}		
1724	}
1725	
1726	
1727	// 창닫기
1728	,evtClose:function(mode, idxno)
1729	{
1730		if(mode=="layer"){
1731			var layerId = bannerpop.vars.popup.popname+idxno;
1732			
1733			$("#"+layerId).fadeOut("fast", function(){
1734				$(this).remove();
1735			});
1736		}else window.close();
1737	}
1738	
1739	// cookie
1740	,evtCookieClose:function(name, days)
1741	{
1742		bannerpop.setCookie(name, "popup", days);
1743	}
1744	
1745	// 하루,몇일동안 열지 않기
1746	,daysNotOpen:function(expire, period, $btn, p)
1747	{
1748		var parents = this
1749			,idxno = p.idxno
1750			,isClickedMap = false;
1751		
1752		if(expire!="none"){
1753			$btn.each(function(i,v) {
1754				var $thisBtn = $(this);
1755				if($thisBtn.is(".popup-days")){
1756					// 하루동안
1757					if(expire=="day"){
1758						$thisBtn.click(function(){
1759							parents.evtCookieClose(parents.vars.popup.popname+idxno, "1");
1760							parents.evtClose(p.popup_type, p.idxno);
1761							return false;
1762						})
1763						// 닫기 태그 안에 암것두 없는 거 찾아 닫기 텍스트 넣어주기
1764						.not(":has(*)").html('<a href="#close-to-layer">하루동안 보지 않기</a>');
1765					}
1766					// 몇일동안 daySubfix
1767					else if(expire=="days"){
1768						var select = '<a href="#link">'
1769									+'<label class="sr-only" for="popDays"></label>'
1770									+'<select name="popDays" id="popDays" class="tiny" title="기간">'
1771									+'	<option value="1">하루</option>'
1772									+'	<option value="2">2일</option>'
1773									+'	<option value="3">3일</option>'
1774									+'	<option value="4">4일</option>'
1775									+'	<option value="5">5일</option>'
1776									+'	<option value="6">6일</option>'
1777									+'	<option value="7">7일</option>'
1778									+'</select> 동안 열지않기'
1779									+'</a>';
1780						var html = '<a href="#link">'
1781									+ (period>1 ? '몇일동안 보지 않기' : '하루동안 보지 않기')
1782									+'</a>';
1783						//$btn.not(":has(*)").append(select).click(function(){
1784						$thisBtn.append(html).click(function(){
1785							var $this = $(this)
1786								//,days = $this.prev("select").val();
1787								,days = period;
1788							
1789							parents.evtCookieClose(parents.vars.popup.popname+idxno, days);
1790							parents.evtClose(p.popup_type, p.idxno);
1791							return false;
1792						});					
1793					}
1794				}else{
1795					// 이미지맵일때, 하루동안 열지않기
1796					$thisBtn.click(function(){
1797						parents.evtCookieClose(parents.vars.popup.popname+idxno, "1");
1798						parents.evtClose(p.popup_type, p.idxno);	
1799						return false;
1800					});	
1801					
1802					isClickedMap = true;
1803				}
1804			});
1805		}
1806		
1807		// expire 값이랑 관계없이 이미지맵을 찾아 처리
1808		if(isClickedMap===false && $btn.is(".popup_day_close_map")){
1809			// 이미지맵일때, 하루동안 열지않기
1810			$btn.click(function(){
1811				parents.evtCookieClose(parents.vars.popup.popname+idxno, "1");
1812				parents.evtClose(p.popup_type, p.idxno);	
1813				return false;
1814			});	
1815		}
1816	}
1817	
1818	// window popup control
1819	,popupControl:function()
1820	{
1821		if(!___popup) return ;
1822		if((typeof ___popup)!=="object") return ;
1823		
1824		var parents = this
1825			,p = ___popup		
1826			,title = decodeURIComponent(p.title)||"" 
1827			,popupType = p.popup_type||"window"
1828			,bottomClose = p.bottom_close||"Y"
1829			,bottomCloseExpireCk = p.bottom_close_expire_ck||"day"	// : day,days,none
1830			,bottomCloseExpire = p.bottom_close_expire||1	// : 몇일
1831			,$btnClose = $(".popup_close, .popup_close_map, .popup_icon_close")
1832			,$btnDayClose = $(".popup-days, .popup_day_close_map");
1833		
1834		if(popupType!="window") return ;
1835		
1836		// 윈도우 바 타이틀 교체
1837		document.title = title;
1838	
1839		// 창닫기
1840		if(bottomClose=="Y"){
1841			$btnClose.each(function(){
1842				var _$this = $(this);
1843				//if(_$this.is(".popup_close")) _$this.text('창닫기');
1844			});
1845			
1846			$btnClose.click(function(){
1847				parents.evtClose(p.popup_type, p.idxno);	
1848				return false;
1849			});
1850		}
1851		
1852		// 하루, 몇일동안 열지 않기
1853		this.daysNotOpen(bottomCloseExpireCk, bottomCloseExpire, $btnDayClose, p);
1854		
1855	}
1856
1857	// array 최고값
1858	,arrayMaxMin:function(arr, mode)
1859	{
1860		if($.isArray(arr)===false) return false;
1861	
1862		if(!mode) mode = "max";
1863		arr.sort(function(a, b){
1864			return b-a;
1865		});
1866		return (mode=="max"?arr[0]:arr[arr.length-1])||0;
1867	}
1868};

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.